compiler-sfc.esm-browser.js 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343
  1. /**
  2. * @vue/compiler-sfc v3.4.23
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. /*! #__NO_SIDE_EFFECTS__ */
  7. // @__NO_SIDE_EFFECTS__
  8. function makeMap(str, expectsLowerCase) {
  9. const set = new Set(str.split(","));
  10. return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const NOOP = () => {
  14. };
  15. const NO = () => false;
  16. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  17. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  18. const extend = Object.assign;
  19. const hasOwnProperty$4 = Object.prototype.hasOwnProperty;
  20. const hasOwn = (val, key) => hasOwnProperty$4.call(val, key);
  21. const isArray$3 = Array.isArray;
  22. const isMap = (val) => toTypeString(val) === "[object Map]";
  23. const isSet = (val) => toTypeString(val) === "[object Set]";
  24. const isFunction$1 = (val) => typeof val === "function";
  25. const isString$2 = (val) => typeof val === "string";
  26. const isSymbol$1 = (val) => typeof val === "symbol";
  27. const isObject$2 = (val) => val !== null && typeof val === "object";
  28. const objectToString$1 = Object.prototype.toString;
  29. const toTypeString = (value) => objectToString$1.call(value);
  30. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  31. const isReservedProp = /* @__PURE__ */ makeMap(
  32. // the leading comma is intentional so empty string "" is also included
  33. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  34. );
  35. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  36. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  37. );
  38. const cacheStringFunction = (fn) => {
  39. const cache = /* @__PURE__ */ Object.create(null);
  40. return (str) => {
  41. const hit = cache[str];
  42. return hit || (cache[str] = fn(str));
  43. };
  44. };
  45. const camelizeRE = /-(\w)/g;
  46. const camelize = cacheStringFunction((str) => {
  47. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  48. });
  49. const hyphenateRE = /\B([A-Z])/g;
  50. const hyphenate = cacheStringFunction(
  51. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  52. );
  53. const capitalize$1 = cacheStringFunction((str) => {
  54. return str.charAt(0).toUpperCase() + str.slice(1);
  55. });
  56. const toHandlerKey = cacheStringFunction((str) => {
  57. const s = str ? `on${capitalize$1(str)}` : ``;
  58. return s;
  59. });
  60. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  61. function genPropsAccessExp(name) {
  62. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  63. }
  64. const PatchFlagNames = {
  65. [1]: `TEXT`,
  66. [2]: `CLASS`,
  67. [4]: `STYLE`,
  68. [8]: `PROPS`,
  69. [16]: `FULL_PROPS`,
  70. [32]: `NEED_HYDRATION`,
  71. [64]: `STABLE_FRAGMENT`,
  72. [128]: `KEYED_FRAGMENT`,
  73. [256]: `UNKEYED_FRAGMENT`,
  74. [512]: `NEED_PATCH`,
  75. [1024]: `DYNAMIC_SLOTS`,
  76. [2048]: `DEV_ROOT_FRAGMENT`,
  77. [-1]: `HOISTED`,
  78. [-2]: `BAIL`
  79. };
  80. const slotFlagsText = {
  81. [1]: "STABLE",
  82. [2]: "DYNAMIC",
  83. [3]: "FORWARDED"
  84. };
  85. const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
  86. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  87. const range = 2;
  88. function generateCodeFrame(source, start = 0, end = source.length) {
  89. let lines = source.split(/(\r?\n)/);
  90. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  91. lines = lines.filter((_, idx) => idx % 2 === 0);
  92. let count = 0;
  93. const res = [];
  94. for (let i = 0; i < lines.length; i++) {
  95. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  96. if (count >= start) {
  97. for (let j = i - range; j <= i + range || end > count; j++) {
  98. if (j < 0 || j >= lines.length)
  99. continue;
  100. const line = j + 1;
  101. res.push(
  102. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  103. );
  104. const lineLength = lines[j].length;
  105. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  106. if (j === i) {
  107. const pad = start - (count - (lineLength + newLineSeqLength));
  108. const length = Math.max(
  109. 1,
  110. end > count ? lineLength - pad : end - start
  111. );
  112. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  113. } else if (j > i) {
  114. if (end > count) {
  115. const length = Math.max(Math.min(end - count, lineLength), 1);
  116. res.push(` | ` + "^".repeat(length));
  117. }
  118. count += lineLength + newLineSeqLength;
  119. }
  120. }
  121. break;
  122. }
  123. }
  124. return res.join("\n");
  125. }
  126. function normalizeStyle(value) {
  127. if (isArray$3(value)) {
  128. const res = {};
  129. for (let i = 0; i < value.length; i++) {
  130. const item = value[i];
  131. const normalized = isString$2(item) ? parseStringStyle(item) : normalizeStyle(item);
  132. if (normalized) {
  133. for (const key in normalized) {
  134. res[key] = normalized[key];
  135. }
  136. }
  137. }
  138. return res;
  139. } else if (isString$2(value) || isObject$2(value)) {
  140. return value;
  141. }
  142. }
  143. const listDelimiterRE = /;(?![^(]*\))/g;
  144. const propertyDelimiterRE = /:([^]+)/;
  145. const styleCommentRE = /\/\*[^]*?\*\//g;
  146. function parseStringStyle(cssText) {
  147. const ret = {};
  148. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  149. if (item) {
  150. const tmp = item.split(propertyDelimiterRE);
  151. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  152. }
  153. });
  154. return ret;
  155. }
  156. function stringifyStyle(styles) {
  157. let ret = "";
  158. if (!styles || isString$2(styles)) {
  159. return ret;
  160. }
  161. for (const key in styles) {
  162. const value = styles[key];
  163. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  164. if (isString$2(value) || typeof value === "number") {
  165. ret += `${normalizedKey}:${value};`;
  166. }
  167. }
  168. return ret;
  169. }
  170. function normalizeClass(value) {
  171. let res = "";
  172. if (isString$2(value)) {
  173. res = value;
  174. } else if (isArray$3(value)) {
  175. for (let i = 0; i < value.length; i++) {
  176. const normalized = normalizeClass(value[i]);
  177. if (normalized) {
  178. res += normalized + " ";
  179. }
  180. }
  181. } else if (isObject$2(value)) {
  182. for (const name in value) {
  183. if (value[name]) {
  184. res += name + " ";
  185. }
  186. }
  187. }
  188. return res.trim();
  189. }
  190. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  191. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  192. const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
  193. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  194. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  195. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  196. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  197. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  198. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  199. const isBooleanAttr = /* @__PURE__ */ makeMap(
  200. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  201. );
  202. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  203. const attrValidationCache = {};
  204. function isSSRSafeAttrName(name) {
  205. if (attrValidationCache.hasOwnProperty(name)) {
  206. return attrValidationCache[name];
  207. }
  208. const isUnsafe = unsafeAttrCharRE.test(name);
  209. if (isUnsafe) {
  210. console.error(`unsafe attribute name: ${name}`);
  211. }
  212. return attrValidationCache[name] = !isUnsafe;
  213. }
  214. const propsToAttrMap = {
  215. acceptCharset: "accept-charset",
  216. className: "class",
  217. htmlFor: "for",
  218. httpEquiv: "http-equiv"
  219. };
  220. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  221. `accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
  222. );
  223. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  224. `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
  225. );
  226. const escapeRE = /["'&<>]/;
  227. function escapeHtml(string) {
  228. const str = "" + string;
  229. const match = escapeRE.exec(str);
  230. if (!match) {
  231. return str;
  232. }
  233. let html = "";
  234. let escaped;
  235. let index;
  236. let lastIndex = 0;
  237. for (index = match.index; index < str.length; index++) {
  238. switch (str.charCodeAt(index)) {
  239. case 34:
  240. escaped = "&quot;";
  241. break;
  242. case 38:
  243. escaped = "&amp;";
  244. break;
  245. case 39:
  246. escaped = "&#39;";
  247. break;
  248. case 60:
  249. escaped = "&lt;";
  250. break;
  251. case 62:
  252. escaped = "&gt;";
  253. break;
  254. default:
  255. continue;
  256. }
  257. if (lastIndex !== index) {
  258. html += str.slice(lastIndex, index);
  259. }
  260. lastIndex = index + 1;
  261. html += escaped;
  262. }
  263. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  264. }
  265. const toDisplayString = (val) => {
  266. return isString$2(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$1(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
  267. };
  268. const replacer = (_key, val) => {
  269. if (val && val.__v_isRef) {
  270. return replacer(_key, val.value);
  271. } else if (isMap(val)) {
  272. return {
  273. [`Map(${val.size})`]: [...val.entries()].reduce(
  274. (entries, [key, val2], i) => {
  275. entries[stringifySymbol(key, i) + " =>"] = val2;
  276. return entries;
  277. },
  278. {}
  279. )
  280. };
  281. } else if (isSet(val)) {
  282. return {
  283. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  284. };
  285. } else if (isSymbol$1(val)) {
  286. return stringifySymbol(val);
  287. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  288. return String(val);
  289. }
  290. return val;
  291. };
  292. const stringifySymbol = (v, i = "") => {
  293. var _a;
  294. return (
  295. // Symbol.description in es2019+ so we need to cast here to pass
  296. // the lib: es2016 check
  297. isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  298. );
  299. };
  300. const FRAGMENT = Symbol(`Fragment` );
  301. const TELEPORT = Symbol(`Teleport` );
  302. const SUSPENSE = Symbol(`Suspense` );
  303. const KEEP_ALIVE = Symbol(`KeepAlive` );
  304. const BASE_TRANSITION = Symbol(`BaseTransition` );
  305. const OPEN_BLOCK = Symbol(`openBlock` );
  306. const CREATE_BLOCK = Symbol(`createBlock` );
  307. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  308. const CREATE_VNODE = Symbol(`createVNode` );
  309. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  310. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  311. const CREATE_TEXT = Symbol(`createTextVNode` );
  312. const CREATE_STATIC = Symbol(`createStaticVNode` );
  313. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  314. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  315. `resolveDynamicComponent`
  316. );
  317. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  318. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  319. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  320. const RENDER_LIST = Symbol(`renderList` );
  321. const RENDER_SLOT = Symbol(`renderSlot` );
  322. const CREATE_SLOTS = Symbol(`createSlots` );
  323. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  324. const MERGE_PROPS = Symbol(`mergeProps` );
  325. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  326. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  327. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  328. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  329. const TO_HANDLERS = Symbol(`toHandlers` );
  330. const CAMELIZE = Symbol(`camelize` );
  331. const CAPITALIZE = Symbol(`capitalize` );
  332. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  333. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  334. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  335. const POP_SCOPE_ID = Symbol(`popScopeId` );
  336. const WITH_CTX = Symbol(`withCtx` );
  337. const UNREF = Symbol(`unref` );
  338. const IS_REF = Symbol(`isRef` );
  339. const WITH_MEMO = Symbol(`withMemo` );
  340. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  341. const helperNameMap = {
  342. [FRAGMENT]: `Fragment`,
  343. [TELEPORT]: `Teleport`,
  344. [SUSPENSE]: `Suspense`,
  345. [KEEP_ALIVE]: `KeepAlive`,
  346. [BASE_TRANSITION]: `BaseTransition`,
  347. [OPEN_BLOCK]: `openBlock`,
  348. [CREATE_BLOCK]: `createBlock`,
  349. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  350. [CREATE_VNODE]: `createVNode`,
  351. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  352. [CREATE_COMMENT]: `createCommentVNode`,
  353. [CREATE_TEXT]: `createTextVNode`,
  354. [CREATE_STATIC]: `createStaticVNode`,
  355. [RESOLVE_COMPONENT]: `resolveComponent`,
  356. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  357. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  358. [RESOLVE_FILTER]: `resolveFilter`,
  359. [WITH_DIRECTIVES]: `withDirectives`,
  360. [RENDER_LIST]: `renderList`,
  361. [RENDER_SLOT]: `renderSlot`,
  362. [CREATE_SLOTS]: `createSlots`,
  363. [TO_DISPLAY_STRING]: `toDisplayString`,
  364. [MERGE_PROPS]: `mergeProps`,
  365. [NORMALIZE_CLASS]: `normalizeClass`,
  366. [NORMALIZE_STYLE]: `normalizeStyle`,
  367. [NORMALIZE_PROPS]: `normalizeProps`,
  368. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  369. [TO_HANDLERS]: `toHandlers`,
  370. [CAMELIZE]: `camelize`,
  371. [CAPITALIZE]: `capitalize`,
  372. [TO_HANDLER_KEY]: `toHandlerKey`,
  373. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  374. [PUSH_SCOPE_ID]: `pushScopeId`,
  375. [POP_SCOPE_ID]: `popScopeId`,
  376. [WITH_CTX]: `withCtx`,
  377. [UNREF]: `unref`,
  378. [IS_REF]: `isRef`,
  379. [WITH_MEMO]: `withMemo`,
  380. [IS_MEMO_SAME]: `isMemoSame`
  381. };
  382. function registerRuntimeHelpers(helpers) {
  383. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  384. helperNameMap[s] = helpers[s];
  385. });
  386. }
  387. const Namespaces = {
  388. "HTML": 0,
  389. "0": "HTML",
  390. "SVG": 1,
  391. "1": "SVG",
  392. "MATH_ML": 2,
  393. "2": "MATH_ML"
  394. };
  395. const NodeTypes = {
  396. "ROOT": 0,
  397. "0": "ROOT",
  398. "ELEMENT": 1,
  399. "1": "ELEMENT",
  400. "TEXT": 2,
  401. "2": "TEXT",
  402. "COMMENT": 3,
  403. "3": "COMMENT",
  404. "SIMPLE_EXPRESSION": 4,
  405. "4": "SIMPLE_EXPRESSION",
  406. "INTERPOLATION": 5,
  407. "5": "INTERPOLATION",
  408. "ATTRIBUTE": 6,
  409. "6": "ATTRIBUTE",
  410. "DIRECTIVE": 7,
  411. "7": "DIRECTIVE",
  412. "COMPOUND_EXPRESSION": 8,
  413. "8": "COMPOUND_EXPRESSION",
  414. "IF": 9,
  415. "9": "IF",
  416. "IF_BRANCH": 10,
  417. "10": "IF_BRANCH",
  418. "FOR": 11,
  419. "11": "FOR",
  420. "TEXT_CALL": 12,
  421. "12": "TEXT_CALL",
  422. "VNODE_CALL": 13,
  423. "13": "VNODE_CALL",
  424. "JS_CALL_EXPRESSION": 14,
  425. "14": "JS_CALL_EXPRESSION",
  426. "JS_OBJECT_EXPRESSION": 15,
  427. "15": "JS_OBJECT_EXPRESSION",
  428. "JS_PROPERTY": 16,
  429. "16": "JS_PROPERTY",
  430. "JS_ARRAY_EXPRESSION": 17,
  431. "17": "JS_ARRAY_EXPRESSION",
  432. "JS_FUNCTION_EXPRESSION": 18,
  433. "18": "JS_FUNCTION_EXPRESSION",
  434. "JS_CONDITIONAL_EXPRESSION": 19,
  435. "19": "JS_CONDITIONAL_EXPRESSION",
  436. "JS_CACHE_EXPRESSION": 20,
  437. "20": "JS_CACHE_EXPRESSION",
  438. "JS_BLOCK_STATEMENT": 21,
  439. "21": "JS_BLOCK_STATEMENT",
  440. "JS_TEMPLATE_LITERAL": 22,
  441. "22": "JS_TEMPLATE_LITERAL",
  442. "JS_IF_STATEMENT": 23,
  443. "23": "JS_IF_STATEMENT",
  444. "JS_ASSIGNMENT_EXPRESSION": 24,
  445. "24": "JS_ASSIGNMENT_EXPRESSION",
  446. "JS_SEQUENCE_EXPRESSION": 25,
  447. "25": "JS_SEQUENCE_EXPRESSION",
  448. "JS_RETURN_STATEMENT": 26,
  449. "26": "JS_RETURN_STATEMENT"
  450. };
  451. const ElementTypes = {
  452. "ELEMENT": 0,
  453. "0": "ELEMENT",
  454. "COMPONENT": 1,
  455. "1": "COMPONENT",
  456. "SLOT": 2,
  457. "2": "SLOT",
  458. "TEMPLATE": 3,
  459. "3": "TEMPLATE"
  460. };
  461. const ConstantTypes = {
  462. "NOT_CONSTANT": 0,
  463. "0": "NOT_CONSTANT",
  464. "CAN_SKIP_PATCH": 1,
  465. "1": "CAN_SKIP_PATCH",
  466. "CAN_HOIST": 2,
  467. "2": "CAN_HOIST",
  468. "CAN_STRINGIFY": 3,
  469. "3": "CAN_STRINGIFY"
  470. };
  471. const locStub = {
  472. start: { line: 1, column: 1, offset: 0 },
  473. end: { line: 1, column: 1, offset: 0 },
  474. source: ""
  475. };
  476. function createRoot(children, source = "") {
  477. return {
  478. type: 0,
  479. source,
  480. children,
  481. helpers: /* @__PURE__ */ new Set(),
  482. components: [],
  483. directives: [],
  484. hoists: [],
  485. imports: [],
  486. cached: 0,
  487. temps: 0,
  488. codegenNode: void 0,
  489. loc: locStub
  490. };
  491. }
  492. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  493. if (context) {
  494. if (isBlock) {
  495. context.helper(OPEN_BLOCK);
  496. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  497. } else {
  498. context.helper(getVNodeHelper(context.inSSR, isComponent));
  499. }
  500. if (directives) {
  501. context.helper(WITH_DIRECTIVES);
  502. }
  503. }
  504. return {
  505. type: 13,
  506. tag,
  507. props,
  508. children,
  509. patchFlag,
  510. dynamicProps,
  511. directives,
  512. isBlock,
  513. disableTracking,
  514. isComponent,
  515. loc
  516. };
  517. }
  518. function createArrayExpression(elements, loc = locStub) {
  519. return {
  520. type: 17,
  521. loc,
  522. elements
  523. };
  524. }
  525. function createObjectExpression(properties, loc = locStub) {
  526. return {
  527. type: 15,
  528. loc,
  529. properties
  530. };
  531. }
  532. function createObjectProperty(key, value) {
  533. return {
  534. type: 16,
  535. loc: locStub,
  536. key: isString$2(key) ? createSimpleExpression(key, true) : key,
  537. value
  538. };
  539. }
  540. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  541. return {
  542. type: 4,
  543. loc,
  544. content,
  545. isStatic,
  546. constType: isStatic ? 3 : constType
  547. };
  548. }
  549. function createInterpolation(content, loc) {
  550. return {
  551. type: 5,
  552. loc,
  553. content: isString$2(content) ? createSimpleExpression(content, false, loc) : content
  554. };
  555. }
  556. function createCompoundExpression(children, loc = locStub) {
  557. return {
  558. type: 8,
  559. loc,
  560. children
  561. };
  562. }
  563. function createCallExpression(callee, args = [], loc = locStub) {
  564. return {
  565. type: 14,
  566. loc,
  567. callee,
  568. arguments: args
  569. };
  570. }
  571. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  572. return {
  573. type: 18,
  574. params,
  575. returns,
  576. newline,
  577. isSlot,
  578. loc
  579. };
  580. }
  581. function createConditionalExpression(test, consequent, alternate, newline = true) {
  582. return {
  583. type: 19,
  584. test,
  585. consequent,
  586. alternate,
  587. newline,
  588. loc: locStub
  589. };
  590. }
  591. function createCacheExpression(index, value, isVNode = false) {
  592. return {
  593. type: 20,
  594. index,
  595. value,
  596. isVNode,
  597. loc: locStub
  598. };
  599. }
  600. function createBlockStatement(body) {
  601. return {
  602. type: 21,
  603. body,
  604. loc: locStub
  605. };
  606. }
  607. function createTemplateLiteral(elements) {
  608. return {
  609. type: 22,
  610. elements,
  611. loc: locStub
  612. };
  613. }
  614. function createIfStatement(test, consequent, alternate) {
  615. return {
  616. type: 23,
  617. test,
  618. consequent,
  619. alternate,
  620. loc: locStub
  621. };
  622. }
  623. function createAssignmentExpression(left, right) {
  624. return {
  625. type: 24,
  626. left,
  627. right,
  628. loc: locStub
  629. };
  630. }
  631. function createSequenceExpression(expressions) {
  632. return {
  633. type: 25,
  634. expressions,
  635. loc: locStub
  636. };
  637. }
  638. function createReturnStatement(returns) {
  639. return {
  640. type: 26,
  641. returns,
  642. loc: locStub
  643. };
  644. }
  645. function getVNodeHelper(ssr, isComponent) {
  646. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  647. }
  648. function getVNodeBlockHelper(ssr, isComponent) {
  649. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  650. }
  651. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  652. if (!node.isBlock) {
  653. node.isBlock = true;
  654. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  655. helper(OPEN_BLOCK);
  656. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  657. }
  658. }
  659. // Generated using scripts/write-decode-map.ts
  660. var htmlDecodeTree = new Uint16Array(
  661. // prettier-ignore
  662. "\u1d41<\xd5\u0131\u028a\u049d\u057b\u05d0\u0675\u06de\u07a2\u07d6\u080f\u0a4a\u0a91\u0da1\u0e6d\u0f09\u0f26\u10ca\u1228\u12e1\u1415\u149d\u14c3\u14df\u1525\0\0\0\0\0\0\u156b\u16cd\u198d\u1c12\u1ddd\u1f7e\u2060\u21b0\u228d\u23c0\u23fb\u2442\u2824\u2912\u2d08\u2e48\u2fce\u3016\u32ba\u3639\u37ac\u38fe\u3a28\u3a71\u3ae0\u3b2e\u0800EMabcfglmnoprstu\\bfms\x7f\x84\x8b\x90\x95\x98\xa6\xb3\xb9\xc8\xcflig\u803b\xc6\u40c6P\u803b&\u4026cute\u803b\xc1\u40c1reve;\u4102\u0100iyx}rc\u803b\xc2\u40c2;\u4410r;\uc000\ud835\udd04rave\u803b\xc0\u40c0pha;\u4391acr;\u4100d;\u6a53\u0100gp\x9d\xa1on;\u4104f;\uc000\ud835\udd38plyFunction;\u6061ing\u803b\xc5\u40c5\u0100cs\xbe\xc3r;\uc000\ud835\udc9cign;\u6254ilde\u803b\xc3\u40c3ml\u803b\xc4\u40c4\u0400aceforsu\xe5\xfb\xfe\u0117\u011c\u0122\u0127\u012a\u0100cr\xea\xf2kslash;\u6216\u0176\xf6\xf8;\u6ae7ed;\u6306y;\u4411\u0180crt\u0105\u010b\u0114ause;\u6235noullis;\u612ca;\u4392r;\uc000\ud835\udd05pf;\uc000\ud835\udd39eve;\u42d8c\xf2\u0113mpeq;\u624e\u0700HOacdefhilorsu\u014d\u0151\u0156\u0180\u019e\u01a2\u01b5\u01b7\u01ba\u01dc\u0215\u0273\u0278\u027ecy;\u4427PY\u803b\xa9\u40a9\u0180cpy\u015d\u0162\u017aute;\u4106\u0100;i\u0167\u0168\u62d2talDifferentialD;\u6145leys;\u612d\u0200aeio\u0189\u018e\u0194\u0198ron;\u410cdil\u803b\xc7\u40c7rc;\u4108nint;\u6230ot;\u410a\u0100dn\u01a7\u01adilla;\u40b8terDot;\u40b7\xf2\u017fi;\u43a7rcle\u0200DMPT\u01c7\u01cb\u01d1\u01d6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01e2\u01f8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020foubleQuote;\u601duote;\u6019\u0200lnpu\u021e\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6a74\u0180git\u022f\u0236\u023aruent;\u6261nt;\u622fourIntegral;\u622e\u0100fr\u024c\u024e;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6a2fcr;\uc000\ud835\udc9ep\u0100;C\u0284\u0285\u62d3ap;\u624d\u0580DJSZacefios\u02a0\u02ac\u02b0\u02b4\u02b8\u02cb\u02d7\u02e1\u02e6\u0333\u048d\u0100;o\u0179\u02a5trahd;\u6911cy;\u4402cy;\u4405cy;\u440f\u0180grs\u02bf\u02c4\u02c7ger;\u6021r;\u61a1hv;\u6ae4\u0100ay\u02d0\u02d5ron;\u410e;\u4414l\u0100;t\u02dd\u02de\u6207a;\u4394r;\uc000\ud835\udd07\u0100af\u02eb\u0327\u0100cm\u02f0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031ccute;\u40b4o\u0174\u030b\u030d;\u42d9bleAcute;\u42ddrave;\u4060ilde;\u42dcond;\u62c4ferentialD;\u6146\u0470\u033d\0\0\0\u0342\u0354\0\u0405f;\uc000\ud835\udd3b\u0180;DE\u0348\u0349\u034d\u40a8ot;\u60dcqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03cf\u03e2\u03f8ontourIntegra\xec\u0239o\u0274\u0379\0\0\u037b\xbb\u0349nArrow;\u61d3\u0100eo\u0387\u03a4ft\u0180ART\u0390\u0396\u03a1rrow;\u61d0ightArrow;\u61d4e\xe5\u02cang\u0100LR\u03ab\u03c4eft\u0100AR\u03b3\u03b9rrow;\u67f8ightArrow;\u67faightArrow;\u67f9ight\u0100AT\u03d8\u03derrow;\u61d2ee;\u62a8p\u0241\u03e9\0\0\u03efrrow;\u61d1ownArrow;\u61d5erticalBar;\u6225n\u0300ABLRTa\u0412\u042a\u0430\u045e\u047f\u037crrow\u0180;BU\u041d\u041e\u0422\u6193ar;\u6913pArrow;\u61f5reve;\u4311eft\u02d2\u043a\0\u0446\0\u0450ightVector;\u6950eeVector;\u695eector\u0100;B\u0459\u045a\u61bdar;\u6956ight\u01d4\u0467\0\u0471eeVector;\u695fector\u0100;B\u047a\u047b\u61c1ar;\u6957ee\u0100;A\u0486\u0487\u62a4rrow;\u61a7\u0100ct\u0492\u0497r;\uc000\ud835\udc9frok;\u4110\u0800NTacdfglmopqstux\u04bd\u04c0\u04c4\u04cb\u04de\u04e2\u04e7\u04ee\u04f5\u0521\u052f\u0536\u0552\u055d\u0560\u0565G;\u414aH\u803b\xd0\u40d0cute\u803b\xc9\u40c9\u0180aiy\u04d2\u04d7\u04dcron;\u411arc\u803b\xca\u40ca;\u442dot;\u4116r;\uc000\ud835\udd08rave\u803b\xc8\u40c8ement;\u6208\u0100ap\u04fa\u04fecr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65fberySmallSquare;\u65ab\u0100gp\u0526\u052aon;\u4118f;\uc000\ud835\udd3csilon;\u4395u\u0100ai\u053c\u0549l\u0100;T\u0542\u0543\u6a75ilde;\u6242librium;\u61cc\u0100ci\u0557\u055ar;\u6130m;\u6a73a;\u4397ml\u803b\xcb\u40cb\u0100ip\u056a\u056fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058d\u05b2\u05ccy;\u4424r;\uc000\ud835\udd09lled\u0253\u0597\0\0\u05a3mallSquare;\u65fcerySmallSquare;\u65aa\u0370\u05ba\0\u05bf\0\0\u05c4f;\uc000\ud835\udd3dAll;\u6200riertrf;\u6131c\xf2\u05cb\u0600JTabcdfgorst\u05e8\u05ec\u05ef\u05fa\u0600\u0612\u0616\u061b\u061d\u0623\u066c\u0672cy;\u4403\u803b>\u403emma\u0100;d\u05f7\u05f8\u4393;\u43dcreve;\u411e\u0180eiy\u0607\u060c\u0610dil;\u4122rc;\u411c;\u4413ot;\u4120r;\uc000\ud835\udd0a;\u62d9pf;\uc000\ud835\udd3eeater\u0300EFGLST\u0635\u0644\u064e\u0656\u065b\u0666qual\u0100;L\u063e\u063f\u6265ess;\u62dbullEqual;\u6267reater;\u6aa2ess;\u6277lantEqual;\u6a7eilde;\u6273cr;\uc000\ud835\udca2;\u626b\u0400Aacfiosu\u0685\u068b\u0696\u069b\u069e\u06aa\u06be\u06caRDcy;\u442a\u0100ct\u0690\u0694ek;\u42c7;\u405eirc;\u4124r;\u610clbertSpace;\u610b\u01f0\u06af\0\u06b2f;\u610dizontalLine;\u6500\u0100ct\u06c3\u06c5\xf2\u06a9rok;\u4126mp\u0144\u06d0\u06d8ownHum\xf0\u012fqual;\u624f\u0700EJOacdfgmnostu\u06fa\u06fe\u0703\u0707\u070e\u071a\u071e\u0721\u0728\u0744\u0778\u078b\u078f\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803b\xcd\u40cd\u0100iy\u0713\u0718rc\u803b\xce\u40ce;\u4418ot;\u4130r;\u6111rave\u803b\xcc\u40cc\u0180;ap\u0720\u072f\u073f\u0100cg\u0734\u0737r;\u412ainaryI;\u6148lie\xf3\u03dd\u01f4\u0749\0\u0762\u0100;e\u074d\u074e\u622c\u0100gr\u0753\u0758ral;\u622bsection;\u62c2isible\u0100CT\u076c\u0772omma;\u6063imes;\u6062\u0180gpt\u077f\u0783\u0788on;\u412ef;\uc000\ud835\udd40a;\u4399cr;\u6110ilde;\u4128\u01eb\u079a\0\u079ecy;\u4406l\u803b\xcf\u40cf\u0280cfosu\u07ac\u07b7\u07bc\u07c2\u07d0\u0100iy\u07b1\u07b5rc;\u4134;\u4419r;\uc000\ud835\udd0dpf;\uc000\ud835\udd41\u01e3\u07c7\0\u07ccr;\uc000\ud835\udca5rcy;\u4408kcy;\u4404\u0380HJacfos\u07e4\u07e8\u07ec\u07f1\u07fd\u0802\u0808cy;\u4425cy;\u440cppa;\u439a\u0100ey\u07f6\u07fbdil;\u4136;\u441ar;\uc000\ud835\udd0epf;\uc000\ud835\udd42cr;\uc000\ud835\udca6\u0580JTaceflmost\u0825\u0829\u082c\u0850\u0863\u09b3\u09b8\u09c7\u09cd\u0a37\u0a47cy;\u4409\u803b<\u403c\u0280cmnpr\u0837\u083c\u0841\u0844\u084dute;\u4139bda;\u439bg;\u67ealacetrf;\u6112r;\u619e\u0180aey\u0857\u085c\u0861ron;\u413ddil;\u413b;\u441b\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087e\u08a9\u08b1\u08e0\u08e6\u08fc\u092f\u095b\u0390\u096a\u0100nr\u0883\u088fgleBracket;\u67e8row\u0180;BR\u0899\u089a\u089e\u6190ar;\u61e4ightArrow;\u61c6eiling;\u6308o\u01f5\u08b7\0\u08c3bleBracket;\u67e6n\u01d4\u08c8\0\u08d2eeVector;\u6961ector\u0100;B\u08db\u08dc\u61c3ar;\u6959loor;\u630aight\u0100AV\u08ef\u08f5rrow;\u6194ector;\u694e\u0100er\u0901\u0917e\u0180;AV\u0909\u090a\u0910\u62a3rrow;\u61a4ector;\u695aiangle\u0180;BE\u0924\u0925\u0929\u62b2ar;\u69cfqual;\u62b4p\u0180DTV\u0937\u0942\u094cownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61bfar;\u6958ector\u0100;B\u0965\u0966\u61bcar;\u6952ight\xe1\u039cs\u0300EFGLST\u097e\u098b\u0995\u099d\u09a2\u09adqualGreater;\u62daullEqual;\u6266reater;\u6276ess;\u6aa1lantEqual;\u6a7dilde;\u6272r;\uc000\ud835\udd0f\u0100;e\u09bd\u09be\u62d8ftarrow;\u61daidot;\u413f\u0180npw\u09d4\u0a16\u0a1bg\u0200LRlr\u09de\u09f7\u0a02\u0a10eft\u0100AR\u09e6\u09ecrrow;\u67f5ightArrow;\u67f7ightArrow;\u67f6eft\u0100ar\u03b3\u0a0aight\xe1\u03bfight\xe1\u03caf;\uc000\ud835\udd43er\u0100LR\u0a22\u0a2ceftArrow;\u6199ightArrow;\u6198\u0180cht\u0a3e\u0a40\u0a42\xf2\u084c;\u61b0rok;\u4141;\u626a\u0400acefiosu\u0a5a\u0a5d\u0a60\u0a77\u0a7c\u0a85\u0a8b\u0a8ep;\u6905y;\u441c\u0100dl\u0a65\u0a6fiumSpace;\u605flintrf;\u6133r;\uc000\ud835\udd10nusPlus;\u6213pf;\uc000\ud835\udd44c\xf2\u0a76;\u439c\u0480Jacefostu\u0aa3\u0aa7\u0aad\u0ac0\u0b14\u0b19\u0d91\u0d97\u0d9ecy;\u440acute;\u4143\u0180aey\u0ab4\u0ab9\u0aberon;\u4147dil;\u4145;\u441d\u0180gsw\u0ac7\u0af0\u0b0eative\u0180MTV\u0ad3\u0adf\u0ae8ediumSpace;\u600bhi\u0100cn\u0ae6\u0ad8\xeb\u0ad9eryThi\xee\u0ad9ted\u0100GL\u0af8\u0b06reaterGreate\xf2\u0673essLes\xf3\u0a48Line;\u400ar;\uc000\ud835\udd11\u0200Bnpt\u0b22\u0b28\u0b37\u0b3areak;\u6060BreakingSpace;\u40a0f;\u6115\u0680;CDEGHLNPRSTV\u0b55\u0b56\u0b6a\u0b7c\u0ba1\u0beb\u0c04\u0c5e\u0c84\u0ca6\u0cd8\u0d61\u0d85\u6aec\u0100ou\u0b5b\u0b64ngruent;\u6262pCap;\u626doubleVerticalBar;\u6226\u0180lqx\u0b83\u0b8a\u0b9bement;\u6209ual\u0100;T\u0b92\u0b93\u6260ilde;\uc000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0bb6\u0bb7\u0bbd\u0bc9\u0bd3\u0bd8\u0be5\u626fqual;\u6271ullEqual;\uc000\u2267\u0338reater;\uc000\u226b\u0338ess;\u6279lantEqual;\uc000\u2a7e\u0338ilde;\u6275ump\u0144\u0bf2\u0bfdownHump;\uc000\u224e\u0338qual;\uc000\u224f\u0338e\u0100fs\u0c0a\u0c27tTriangle\u0180;BE\u0c1a\u0c1b\u0c21\u62eaar;\uc000\u29cf\u0338qual;\u62ecs\u0300;EGLST\u0c35\u0c36\u0c3c\u0c44\u0c4b\u0c58\u626equal;\u6270reater;\u6278ess;\uc000\u226a\u0338lantEqual;\uc000\u2a7d\u0338ilde;\u6274ested\u0100GL\u0c68\u0c79reaterGreater;\uc000\u2aa2\u0338essLess;\uc000\u2aa1\u0338recedes\u0180;ES\u0c92\u0c93\u0c9b\u6280qual;\uc000\u2aaf\u0338lantEqual;\u62e0\u0100ei\u0cab\u0cb9verseElement;\u620cghtTriangle\u0180;BE\u0ccb\u0ccc\u0cd2\u62ebar;\uc000\u29d0\u0338qual;\u62ed\u0100qu\u0cdd\u0d0cuareSu\u0100bp\u0ce8\u0cf9set\u0100;E\u0cf0\u0cf3\uc000\u228f\u0338qual;\u62e2erset\u0100;E\u0d03\u0d06\uc000\u2290\u0338qual;\u62e3\u0180bcp\u0d13\u0d24\u0d4eset\u0100;E\u0d1b\u0d1e\uc000\u2282\u20d2qual;\u6288ceeds\u0200;EST\u0d32\u0d33\u0d3b\u0d46\u6281qual;\uc000\u2ab0\u0338lantEqual;\u62e1ilde;\uc000\u227f\u0338erset\u0100;E\u0d58\u0d5b\uc000\u2283\u20d2qual;\u6289ilde\u0200;EFT\u0d6e\u0d6f\u0d75\u0d7f\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uc000\ud835\udca9ilde\u803b\xd1\u40d1;\u439d\u0700Eacdfgmoprstuv\u0dbd\u0dc2\u0dc9\u0dd5\u0ddb\u0de0\u0de7\u0dfc\u0e02\u0e20\u0e22\u0e32\u0e3f\u0e44lig;\u4152cute\u803b\xd3\u40d3\u0100iy\u0dce\u0dd3rc\u803b\xd4\u40d4;\u441eblac;\u4150r;\uc000\ud835\udd12rave\u803b\xd2\u40d2\u0180aei\u0dee\u0df2\u0df6cr;\u414cga;\u43a9cron;\u439fpf;\uc000\ud835\udd46enCurly\u0100DQ\u0e0e\u0e1aoubleQuote;\u601cuote;\u6018;\u6a54\u0100cl\u0e27\u0e2cr;\uc000\ud835\udcaaash\u803b\xd8\u40d8i\u016c\u0e37\u0e3cde\u803b\xd5\u40d5es;\u6a37ml\u803b\xd6\u40d6er\u0100BP\u0e4b\u0e60\u0100ar\u0e50\u0e53r;\u603eac\u0100ek\u0e5a\u0e5c;\u63deet;\u63b4arenthesis;\u63dc\u0480acfhilors\u0e7f\u0e87\u0e8a\u0e8f\u0e92\u0e94\u0e9d\u0eb0\u0efcrtialD;\u6202y;\u441fr;\uc000\ud835\udd13i;\u43a6;\u43a0usMinus;\u40b1\u0100ip\u0ea2\u0eadncareplan\xe5\u069df;\u6119\u0200;eio\u0eb9\u0eba\u0ee0\u0ee4\u6abbcedes\u0200;EST\u0ec8\u0ec9\u0ecf\u0eda\u627aqual;\u6aaflantEqual;\u627cilde;\u627eme;\u6033\u0100dp\u0ee9\u0eeeuct;\u620fortion\u0100;a\u0225\u0ef9l;\u621d\u0100ci\u0f01\u0f06r;\uc000\ud835\udcab;\u43a8\u0200Ufos\u0f11\u0f16\u0f1b\u0f1fOT\u803b\"\u4022r;\uc000\ud835\udd14pf;\u611acr;\uc000\ud835\udcac\u0600BEacefhiorsu\u0f3e\u0f43\u0f47\u0f60\u0f73\u0fa7\u0faa\u0fad\u1096\u10a9\u10b4\u10bearr;\u6910G\u803b\xae\u40ae\u0180cnr\u0f4e\u0f53\u0f56ute;\u4154g;\u67ebr\u0100;t\u0f5c\u0f5d\u61a0l;\u6916\u0180aey\u0f67\u0f6c\u0f71ron;\u4158dil;\u4156;\u4420\u0100;v\u0f78\u0f79\u611cerse\u0100EU\u0f82\u0f99\u0100lq\u0f87\u0f8eement;\u620builibrium;\u61cbpEquilibrium;\u696fr\xbb\u0f79o;\u43a1ght\u0400ACDFTUVa\u0fc1\u0feb\u0ff3\u1022\u1028\u105b\u1087\u03d8\u0100nr\u0fc6\u0fd2gleBracket;\u67e9row\u0180;BL\u0fdc\u0fdd\u0fe1\u6192ar;\u61e5eftArrow;\u61c4eiling;\u6309o\u01f5\u0ff9\0\u1005bleBracket;\u67e7n\u01d4\u100a\0\u1014eeVector;\u695dector\u0100;B\u101d\u101e\u61c2ar;\u6955loor;\u630b\u0100er\u102d\u1043e\u0180;AV\u1035\u1036\u103c\u62a2rrow;\u61a6ector;\u695biangle\u0180;BE\u1050\u1051\u1055\u62b3ar;\u69d0qual;\u62b5p\u0180DTV\u1063\u106e\u1078ownVector;\u694feeVector;\u695cector\u0100;B\u1082\u1083\u61bear;\u6954ector\u0100;B\u1091\u1092\u61c0ar;\u6953\u0100pu\u109b\u109ef;\u611dndImplies;\u6970ightarrow;\u61db\u0100ch\u10b9\u10bcr;\u611b;\u61b1leDelayed;\u69f4\u0680HOacfhimoqstu\u10e4\u10f1\u10f7\u10fd\u1119\u111e\u1151\u1156\u1161\u1167\u11b5\u11bb\u11bf\u0100Cc\u10e9\u10eeHcy;\u4429y;\u4428FTcy;\u442ccute;\u415a\u0280;aeiy\u1108\u1109\u110e\u1113\u1117\u6abcron;\u4160dil;\u415erc;\u415c;\u4421r;\uc000\ud835\udd16ort\u0200DLRU\u112a\u1134\u113e\u1149ownArrow\xbb\u041eeftArrow\xbb\u089aightArrow\xbb\u0fddpArrow;\u6191gma;\u43a3allCircle;\u6218pf;\uc000\ud835\udd4a\u0272\u116d\0\0\u1170t;\u621aare\u0200;ISU\u117b\u117c\u1189\u11af\u65a1ntersection;\u6293u\u0100bp\u118f\u119eset\u0100;E\u1197\u1198\u628fqual;\u6291erset\u0100;E\u11a8\u11a9\u6290qual;\u6292nion;\u6294cr;\uc000\ud835\udcaear;\u62c6\u0200bcmp\u11c8\u11db\u1209\u120b\u0100;s\u11cd\u11ce\u62d0et\u0100;E\u11cd\u11d5qual;\u6286\u0100ch\u11e0\u1205eeds\u0200;EST\u11ed\u11ee\u11f4\u11ff\u627bqual;\u6ab0lantEqual;\u627dilde;\u627fTh\xe1\u0f8c;\u6211\u0180;es\u1212\u1213\u1223\u62d1rset\u0100;E\u121c\u121d\u6283qual;\u6287et\xbb\u1213\u0580HRSacfhiors\u123e\u1244\u1249\u1255\u125e\u1271\u1276\u129f\u12c2\u12c8\u12d1ORN\u803b\xde\u40deADE;\u6122\u0100Hc\u124e\u1252cy;\u440by;\u4426\u0100bu\u125a\u125c;\u4009;\u43a4\u0180aey\u1265\u126a\u126fron;\u4164dil;\u4162;\u4422r;\uc000\ud835\udd17\u0100ei\u127b\u1289\u01f2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128e\u1298kSpace;\uc000\u205f\u200aSpace;\u6009lde\u0200;EFT\u12ab\u12ac\u12b2\u12bc\u623cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uc000\ud835\udd4bipleDot;\u60db\u0100ct\u12d6\u12dbr;\uc000\ud835\udcafrok;\u4166\u0ae1\u12f7\u130e\u131a\u1326\0\u132c\u1331\0\0\0\0\0\u1338\u133d\u1377\u1385\0\u13ff\u1404\u140a\u1410\u0100cr\u12fb\u1301ute\u803b\xda\u40dar\u0100;o\u1307\u1308\u619fcir;\u6949r\u01e3\u1313\0\u1316y;\u440eve;\u416c\u0100iy\u131e\u1323rc\u803b\xdb\u40db;\u4423blac;\u4170r;\uc000\ud835\udd18rave\u803b\xd9\u40d9acr;\u416a\u0100di\u1341\u1369er\u0100BP\u1348\u135d\u0100ar\u134d\u1350r;\u405fac\u0100ek\u1357\u1359;\u63dfet;\u63b5arenthesis;\u63ddon\u0100;P\u1370\u1371\u62c3lus;\u628e\u0100gp\u137b\u137fon;\u4172f;\uc000\ud835\udd4c\u0400ADETadps\u1395\u13ae\u13b8\u13c4\u03e8\u13d2\u13d7\u13f3rrow\u0180;BD\u1150\u13a0\u13a4ar;\u6912ownArrow;\u61c5ownArrow;\u6195quilibrium;\u696eee\u0100;A\u13cb\u13cc\u62a5rrow;\u61a5own\xe1\u03f3er\u0100LR\u13de\u13e8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13f9\u13fa\u43d2on;\u43a5ing;\u416ecr;\uc000\ud835\udcb0ilde;\u4168ml\u803b\xdc\u40dc\u0480Dbcdefosv\u1427\u142c\u1430\u1433\u143e\u1485\u148a\u1490\u1496ash;\u62abar;\u6aeby;\u4412ash\u0100;l\u143b\u143c\u62a9;\u6ae6\u0100er\u1443\u1445;\u62c1\u0180bty\u144c\u1450\u147aar;\u6016\u0100;i\u144f\u1455cal\u0200BLST\u1461\u1465\u146a\u1474ar;\u6223ine;\u407ceparator;\u6758ilde;\u6240ThinSpace;\u600ar;\uc000\ud835\udd19pf;\uc000\ud835\udd4dcr;\uc000\ud835\udcb1dash;\u62aa\u0280cefos\u14a7\u14ac\u14b1\u14b6\u14bcirc;\u4174dge;\u62c0r;\uc000\ud835\udd1apf;\uc000\ud835\udd4ecr;\uc000\ud835\udcb2\u0200fios\u14cb\u14d0\u14d2\u14d8r;\uc000\ud835\udd1b;\u439epf;\uc000\ud835\udd4fcr;\uc000\ud835\udcb3\u0480AIUacfosu\u14f1\u14f5\u14f9\u14fd\u1504\u150f\u1514\u151a\u1520cy;\u442fcy;\u4407cy;\u442ecute\u803b\xdd\u40dd\u0100iy\u1509\u150drc;\u4176;\u442br;\uc000\ud835\udd1cpf;\uc000\ud835\udd50cr;\uc000\ud835\udcb4ml;\u4178\u0400Hacdefos\u1535\u1539\u153f\u154b\u154f\u155d\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417d;\u4417ot;\u417b\u01f2\u1554\0\u155boWidt\xe8\u0ad9a;\u4396r;\u6128pf;\u6124cr;\uc000\ud835\udcb5\u0be1\u1583\u158a\u1590\0\u15b0\u15b6\u15bf\0\0\0\0\u15c6\u15db\u15eb\u165f\u166d\0\u1695\u169b\u16b2\u16b9\0\u16becute\u803b\xe1\u40e1reve;\u4103\u0300;Ediuy\u159c\u159d\u15a1\u15a3\u15a8\u15ad\u623e;\uc000\u223e\u0333;\u623frc\u803b\xe2\u40e2te\u80bb\xb4\u0306;\u4430lig\u803b\xe6\u40e6\u0100;r\xb2\u15ba;\uc000\ud835\udd1erave\u803b\xe0\u40e0\u0100ep\u15ca\u15d6\u0100fp\u15cf\u15d4sym;\u6135\xe8\u15d3ha;\u43b1\u0100ap\u15dfc\u0100cl\u15e4\u15e7r;\u4101g;\u6a3f\u0264\u15f0\0\0\u160a\u0280;adsv\u15fa\u15fb\u15ff\u1601\u1607\u6227nd;\u6a55;\u6a5clope;\u6a58;\u6a5a\u0380;elmrsz\u1618\u1619\u161b\u161e\u163f\u164f\u1659\u6220;\u69a4e\xbb\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163a\u163c\u163e;\u69a8;\u69a9;\u69aa;\u69ab;\u69ac;\u69ad;\u69ae;\u69aft\u0100;v\u1645\u1646\u621fb\u0100;d\u164c\u164d\u62be;\u699d\u0100pt\u1654\u1657h;\u6222\xbb\xb9arr;\u637c\u0100gp\u1663\u1667on;\u4105f;\uc000\ud835\udd52\u0380;Eaeiop\u12c1\u167b\u167d\u1682\u1684\u1687\u168a;\u6a70cir;\u6a6f;\u624ad;\u624bs;\u4027rox\u0100;e\u12c1\u1692\xf1\u1683ing\u803b\xe5\u40e5\u0180cty\u16a1\u16a6\u16a8r;\uc000\ud835\udcb6;\u402amp\u0100;e\u12c1\u16af\xf1\u0288ilde\u803b\xe3\u40e3ml\u803b\xe4\u40e4\u0100ci\u16c2\u16c8onin\xf4\u0272nt;\u6a11\u0800Nabcdefiklnoprsu\u16ed\u16f1\u1730\u173c\u1743\u1748\u1778\u177d\u17e0\u17e6\u1839\u1850\u170d\u193d\u1948\u1970ot;\u6aed\u0100cr\u16f6\u171ek\u0200ceps\u1700\u1705\u170d\u1713ong;\u624cpsilon;\u43f6rime;\u6035im\u0100;e\u171a\u171b\u623dq;\u62cd\u0176\u1722\u1726ee;\u62bded\u0100;g\u172c\u172d\u6305e\xbb\u172drk\u0100;t\u135c\u1737brk;\u63b6\u0100oy\u1701\u1741;\u4431quo;\u601e\u0280cmprt\u1753\u175b\u1761\u1764\u1768aus\u0100;e\u010a\u0109ptyv;\u69b0s\xe9\u170cno\xf5\u0113\u0180ahw\u176f\u1771\u1773;\u43b2;\u6136een;\u626cr;\uc000\ud835\udd1fg\u0380costuvw\u178d\u179d\u17b3\u17c1\u17d5\u17db\u17de\u0180aiu\u1794\u1796\u179a\xf0\u0760rc;\u65efp\xbb\u1371\u0180dpt\u17a4\u17a8\u17adot;\u6a00lus;\u6a01imes;\u6a02\u0271\u17b9\0\0\u17becup;\u6a06ar;\u6605riangle\u0100du\u17cd\u17d2own;\u65bdp;\u65b3plus;\u6a04e\xe5\u1444\xe5\u14adarow;\u690d\u0180ako\u17ed\u1826\u1835\u0100cn\u17f2\u1823k\u0180lst\u17fa\u05ab\u1802ozenge;\u69ebriangle\u0200;dlr\u1812\u1813\u1818\u181d\u65b4own;\u65beeft;\u65c2ight;\u65b8k;\u6423\u01b1\u182b\0\u1833\u01b2\u182f\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183e\u184d\u0100;q\u1843\u1846\uc000=\u20e5uiv;\uc000\u2261\u20e5t;\u6310\u0200ptwx\u1859\u185e\u1867\u186cf;\uc000\ud835\udd53\u0100;t\u13cb\u1863om\xbb\u13cctie;\u62c8\u0600DHUVbdhmptuv\u1885\u1896\u18aa\u18bb\u18d7\u18db\u18ec\u18ff\u1905\u190a\u1910\u1921\u0200LRlr\u188e\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18a1\u18a2\u18a4\u18a6\u18a8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18b3\u18b5\u18b7\u18b9;\u655d;\u655a;\u655c;\u6559\u0380;HLRhlr\u18ca\u18cb\u18cd\u18cf\u18d1\u18d3\u18d5\u6551;\u656c;\u6563;\u6560;\u656b;\u6562;\u655fox;\u69c9\u0200LRlr\u18e4\u18e6\u18e8\u18ea;\u6555;\u6552;\u6510;\u650c\u0280;DUdu\u06bd\u18f7\u18f9\u18fb\u18fd;\u6565;\u6568;\u652c;\u6534inus;\u629flus;\u629eimes;\u62a0\u0200LRlr\u1919\u191b\u191d\u191f;\u655b;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193b\u6502;\u656a;\u6561;\u655e;\u653c;\u6524;\u651c\u0100ev\u0123\u1942bar\u803b\xa6\u40a6\u0200ceio\u1951\u1956\u195a\u1960r;\uc000\ud835\udcb7mi;\u604fm\u0100;e\u171a\u171cl\u0180;bh\u1968\u1969\u196b\u405c;\u69c5sub;\u67c8\u016c\u1974\u197el\u0100;e\u1979\u197a\u6022t\xbb\u197ap\u0180;Ee\u012f\u1985\u1987;\u6aae\u0100;q\u06dc\u06db\u0ce1\u19a7\0\u19e8\u1a11\u1a15\u1a32\0\u1a37\u1a50\0\0\u1ab4\0\0\u1ac1\0\0\u1b21\u1b2e\u1b4d\u1b52\0\u1bfd\0\u1c0c\u0180cpr\u19ad\u19b2\u19ddute;\u4107\u0300;abcds\u19bf\u19c0\u19c4\u19ca\u19d5\u19d9\u6229nd;\u6a44rcup;\u6a49\u0100au\u19cf\u19d2p;\u6a4bp;\u6a47ot;\u6a40;\uc000\u2229\ufe00\u0100eo\u19e2\u19e5t;\u6041\xee\u0693\u0200aeiu\u19f0\u19fb\u1a01\u1a05\u01f0\u19f5\0\u19f8s;\u6a4don;\u410ddil\u803b\xe7\u40e7rc;\u4109ps\u0100;s\u1a0c\u1a0d\u6a4cm;\u6a50ot;\u410b\u0180dmn\u1a1b\u1a20\u1a26il\u80bb\xb8\u01adptyv;\u69b2t\u8100\xa2;e\u1a2d\u1a2e\u40a2r\xe4\u01b2r;\uc000\ud835\udd20\u0180cei\u1a3d\u1a40\u1a4dy;\u4447ck\u0100;m\u1a47\u1a48\u6713ark\xbb\u1a48;\u43c7r\u0380;Ecefms\u1a5f\u1a60\u1a62\u1a6b\u1aa4\u1aaa\u1aae\u65cb;\u69c3\u0180;el\u1a69\u1a6a\u1a6d\u42c6q;\u6257e\u0261\u1a74\0\0\u1a88rrow\u0100lr\u1a7c\u1a81eft;\u61baight;\u61bb\u0280RSacd\u1a92\u1a94\u1a96\u1a9a\u1a9f\xbb\u0f47;\u64c8st;\u629birc;\u629aash;\u629dnint;\u6a10id;\u6aefcir;\u69c2ubs\u0100;u\u1abb\u1abc\u6663it\xbb\u1abc\u02ec\u1ac7\u1ad4\u1afa\0\u1b0aon\u0100;e\u1acd\u1ace\u403a\u0100;q\xc7\xc6\u026d\u1ad9\0\0\u1ae2a\u0100;t\u1ade\u1adf\u402c;\u4040\u0180;fl\u1ae8\u1ae9\u1aeb\u6201\xee\u1160e\u0100mx\u1af1\u1af6ent\xbb\u1ae9e\xf3\u024d\u01e7\u1afe\0\u1b07\u0100;d\u12bb\u1b02ot;\u6a6dn\xf4\u0246\u0180fry\u1b10\u1b14\u1b17;\uc000\ud835\udd54o\xe4\u0254\u8100\xa9;s\u0155\u1b1dr;\u6117\u0100ao\u1b25\u1b29rr;\u61b5ss;\u6717\u0100cu\u1b32\u1b37r;\uc000\ud835\udcb8\u0100bp\u1b3c\u1b44\u0100;e\u1b41\u1b42\u6acf;\u6ad1\u0100;e\u1b49\u1b4a\u6ad0;\u6ad2dot;\u62ef\u0380delprvw\u1b60\u1b6c\u1b77\u1b82\u1bac\u1bd4\u1bf9arr\u0100lr\u1b68\u1b6a;\u6938;\u6935\u0270\u1b72\0\0\u1b75r;\u62dec;\u62dfarr\u0100;p\u1b7f\u1b80\u61b6;\u693d\u0300;bcdos\u1b8f\u1b90\u1b96\u1ba1\u1ba5\u1ba8\u622arcap;\u6a48\u0100au\u1b9b\u1b9ep;\u6a46p;\u6a4aot;\u628dr;\u6a45;\uc000\u222a\ufe00\u0200alrv\u1bb5\u1bbf\u1bde\u1be3rr\u0100;m\u1bbc\u1bbd\u61b7;\u693cy\u0180evw\u1bc7\u1bd4\u1bd8q\u0270\u1bce\0\0\u1bd2re\xe3\u1b73u\xe3\u1b75ee;\u62ceedge;\u62cfen\u803b\xa4\u40a4earrow\u0100lr\u1bee\u1bf3eft\xbb\u1b80ight\xbb\u1bbde\xe4\u1bdd\u0100ci\u1c01\u1c07onin\xf4\u01f7nt;\u6231lcty;\u632d\u0980AHabcdefhijlorstuwz\u1c38\u1c3b\u1c3f\u1c5d\u1c69\u1c75\u1c8a\u1c9e\u1cac\u1cb7\u1cfb\u1cff\u1d0d\u1d7b\u1d91\u1dab\u1dbb\u1dc6\u1dcdr\xf2\u0381ar;\u6965\u0200glrs\u1c48\u1c4d\u1c52\u1c54ger;\u6020eth;\u6138\xf2\u1133h\u0100;v\u1c5a\u1c5b\u6010\xbb\u090a\u016b\u1c61\u1c67arow;\u690fa\xe3\u0315\u0100ay\u1c6e\u1c73ron;\u410f;\u4434\u0180;ao\u0332\u1c7c\u1c84\u0100gr\u02bf\u1c81r;\u61catseq;\u6a77\u0180glm\u1c91\u1c94\u1c98\u803b\xb0\u40b0ta;\u43b4ptyv;\u69b1\u0100ir\u1ca3\u1ca8sht;\u697f;\uc000\ud835\udd21ar\u0100lr\u1cb3\u1cb5\xbb\u08dc\xbb\u101e\u0280aegsv\u1cc2\u0378\u1cd6\u1cdc\u1ce0m\u0180;os\u0326\u1cca\u1cd4nd\u0100;s\u0326\u1cd1uit;\u6666amma;\u43ddin;\u62f2\u0180;io\u1ce7\u1ce8\u1cf8\u40f7de\u8100\xf7;o\u1ce7\u1cf0ntimes;\u62c7n\xf8\u1cf7cy;\u4452c\u026f\u1d06\0\0\u1d0arn;\u631eop;\u630d\u0280lptuw\u1d18\u1d1d\u1d22\u1d49\u1d55lar;\u4024f;\uc000\ud835\udd55\u0280;emps\u030b\u1d2d\u1d37\u1d3d\u1d42q\u0100;d\u0352\u1d33ot;\u6251inus;\u6238lus;\u6214quare;\u62a1blebarwedg\xe5\xfan\u0180adh\u112e\u1d5d\u1d67ownarrow\xf3\u1c83arpoon\u0100lr\u1d72\u1d76ef\xf4\u1cb4igh\xf4\u1cb6\u0162\u1d7f\u1d85karo\xf7\u0f42\u026f\u1d8a\0\0\u1d8ern;\u631fop;\u630c\u0180cot\u1d98\u1da3\u1da6\u0100ry\u1d9d\u1da1;\uc000\ud835\udcb9;\u4455l;\u69f6rok;\u4111\u0100dr\u1db0\u1db4ot;\u62f1i\u0100;f\u1dba\u1816\u65bf\u0100ah\u1dc0\u1dc3r\xf2\u0429a\xf2\u0fa6angle;\u69a6\u0100ci\u1dd2\u1dd5y;\u445fgrarr;\u67ff\u0900Dacdefglmnopqrstux\u1e01\u1e09\u1e19\u1e38\u0578\u1e3c\u1e49\u1e61\u1e7e\u1ea5\u1eaf\u1ebd\u1ee1\u1f2a\u1f37\u1f44\u1f4e\u1f5a\u0100Do\u1e06\u1d34o\xf4\u1c89\u0100cs\u1e0e\u1e14ute\u803b\xe9\u40e9ter;\u6a6e\u0200aioy\u1e22\u1e27\u1e31\u1e36ron;\u411br\u0100;c\u1e2d\u1e2e\u6256\u803b\xea\u40ealon;\u6255;\u444dot;\u4117\u0100Dr\u1e41\u1e45ot;\u6252;\uc000\ud835\udd22\u0180;rs\u1e50\u1e51\u1e57\u6a9aave\u803b\xe8\u40e8\u0100;d\u1e5c\u1e5d\u6a96ot;\u6a98\u0200;ils\u1e6a\u1e6b\u1e72\u1e74\u6a99nters;\u63e7;\u6113\u0100;d\u1e79\u1e7a\u6a95ot;\u6a97\u0180aps\u1e85\u1e89\u1e97cr;\u4113ty\u0180;sv\u1e92\u1e93\u1e95\u6205et\xbb\u1e93p\u01001;\u1e9d\u1ea4\u0133\u1ea1\u1ea3;\u6004;\u6005\u6003\u0100gs\u1eaa\u1eac;\u414bp;\u6002\u0100gp\u1eb4\u1eb8on;\u4119f;\uc000\ud835\udd56\u0180als\u1ec4\u1ece\u1ed2r\u0100;s\u1eca\u1ecb\u62d5l;\u69e3us;\u6a71i\u0180;lv\u1eda\u1edb\u1edf\u43b5on\xbb\u1edb;\u43f5\u0200csuv\u1eea\u1ef3\u1f0b\u1f23\u0100io\u1eef\u1e31rc\xbb\u1e2e\u0269\u1ef9\0\0\u1efb\xed\u0548ant\u0100gl\u1f02\u1f06tr\xbb\u1e5dess\xbb\u1e7a\u0180aei\u1f12\u1f16\u1f1als;\u403dst;\u625fv\u0100;D\u0235\u1f20D;\u6a78parsl;\u69e5\u0100Da\u1f2f\u1f33ot;\u6253rr;\u6971\u0180cdi\u1f3e\u1f41\u1ef8r;\u612fo\xf4\u0352\u0100ah\u1f49\u1f4b;\u43b7\u803b\xf0\u40f0\u0100mr\u1f53\u1f57l\u803b\xeb\u40ebo;\u60ac\u0180cip\u1f61\u1f64\u1f67l;\u4021s\xf4\u056e\u0100eo\u1f6c\u1f74ctatio\xee\u0559nential\xe5\u0579\u09e1\u1f92\0\u1f9e\0\u1fa1\u1fa7\0\0\u1fc6\u1fcc\0\u1fd3\0\u1fe6\u1fea\u2000\0\u2008\u205allingdotse\xf1\u1e44y;\u4444male;\u6640\u0180ilr\u1fad\u1fb3\u1fc1lig;\u8000\ufb03\u0269\u1fb9\0\0\u1fbdg;\u8000\ufb00ig;\u8000\ufb04;\uc000\ud835\udd23lig;\u8000\ufb01lig;\uc000fj\u0180alt\u1fd9\u1fdc\u1fe1t;\u666dig;\u8000\ufb02ns;\u65b1of;\u4192\u01f0\u1fee\0\u1ff3f;\uc000\ud835\udd57\u0100ak\u05bf\u1ff7\u0100;v\u1ffc\u1ffd\u62d4;\u6ad9artint;\u6a0d\u0100ao\u200c\u2055\u0100cs\u2011\u2052\u03b1\u201a\u2030\u2038\u2045\u2048\0\u2050\u03b2\u2022\u2025\u2027\u202a\u202c\0\u202e\u803b\xbd\u40bd;\u6153\u803b\xbc\u40bc;\u6155;\u6159;\u615b\u01b3\u2034\0\u2036;\u6154;\u6156\u02b4\u203e\u2041\0\0\u2043\u803b\xbe\u40be;\u6157;\u615c5;\u6158\u01b6\u204c\0\u204e;\u615a;\u615d8;\u615el;\u6044wn;\u6322cr;\uc000\ud835\udcbb\u0880Eabcdefgijlnorstv\u2082\u2089\u209f\u20a5\u20b0\u20b4\u20f0\u20f5\u20fa\u20ff\u2103\u2112\u2138\u0317\u213e\u2152\u219e\u0100;l\u064d\u2087;\u6a8c\u0180cmp\u2090\u2095\u209dute;\u41f5ma\u0100;d\u209c\u1cda\u43b3;\u6a86reve;\u411f\u0100iy\u20aa\u20aerc;\u411d;\u4433ot;\u4121\u0200;lqs\u063e\u0642\u20bd\u20c9\u0180;qs\u063e\u064c\u20c4lan\xf4\u0665\u0200;cdl\u0665\u20d2\u20d5\u20e5c;\u6aa9ot\u0100;o\u20dc\u20dd\u6a80\u0100;l\u20e2\u20e3\u6a82;\u6a84\u0100;e\u20ea\u20ed\uc000\u22db\ufe00s;\u6a94r;\uc000\ud835\udd24\u0100;g\u0673\u061bmel;\u6137cy;\u4453\u0200;Eaj\u065a\u210c\u210e\u2110;\u6a92;\u6aa5;\u6aa4\u0200Eaes\u211b\u211d\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6a8arox\xbb\u2124\u0100;q\u212e\u212f\u6a88\u0100;q\u212e\u211bim;\u62e7pf;\uc000\ud835\udd58\u0100ci\u2143\u2146r;\u610am\u0180;el\u066b\u214e\u2150;\u6a8e;\u6a90\u8300>;cdlqr\u05ee\u2160\u216a\u216e\u2173\u2179\u0100ci\u2165\u2167;\u6aa7r;\u6a7aot;\u62d7Par;\u6995uest;\u6a7c\u0280adels\u2184\u216a\u2190\u0656\u219b\u01f0\u2189\0\u218epro\xf8\u209er;\u6978q\u0100lq\u063f\u2196les\xf3\u2088i\xed\u066b\u0100en\u21a3\u21adrtneqq;\uc000\u2269\ufe00\xc5\u21aa\u0500Aabcefkosy\u21c4\u21c7\u21f1\u21f5\u21fa\u2218\u221d\u222f\u2268\u227dr\xf2\u03a0\u0200ilmr\u21d0\u21d4\u21d7\u21dbrs\xf0\u1484f\xbb\u2024il\xf4\u06a9\u0100dr\u21e0\u21e4cy;\u444a\u0180;cw\u08f4\u21eb\u21efir;\u6948;\u61adar;\u610firc;\u4125\u0180alr\u2201\u220e\u2213rts\u0100;u\u2209\u220a\u6665it\xbb\u220alip;\u6026con;\u62b9r;\uc000\ud835\udd25s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223a\u223e\u2243\u225e\u2263rr;\u61fftht;\u623bk\u0100lr\u2249\u2253eftarrow;\u61a9ightarrow;\u61aaf;\uc000\ud835\udd59bar;\u6015\u0180clt\u226f\u2274\u2278r;\uc000\ud835\udcbdas\xe8\u21f4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xbb\u1c5b\u0ae1\u22a3\0\u22aa\0\u22b8\u22c5\u22ce\0\u22d5\u22f3\0\0\u22f8\u2322\u2367\u2362\u237f\0\u2386\u23aa\u23b4cute\u803b\xed\u40ed\u0180;iy\u0771\u22b0\u22b5rc\u803b\xee\u40ee;\u4438\u0100cx\u22bc\u22bfy;\u4435cl\u803b\xa1\u40a1\u0100fr\u039f\u22c9;\uc000\ud835\udd26rave\u803b\xec\u40ec\u0200;ino\u073e\u22dd\u22e9\u22ee\u0100in\u22e2\u22e6nt;\u6a0ct;\u622dfin;\u69dcta;\u6129lig;\u4133\u0180aop\u22fe\u231a\u231d\u0180cgt\u2305\u2308\u2317r;\u412b\u0180elp\u071f\u230f\u2313in\xe5\u078ear\xf4\u0720h;\u4131f;\u62b7ed;\u41b5\u0280;cfot\u04f4\u232c\u2331\u233d\u2341are;\u6105in\u0100;t\u2338\u2339\u621eie;\u69dddo\xf4\u2319\u0280;celp\u0757\u234c\u2350\u235b\u2361al;\u62ba\u0100gr\u2355\u2359er\xf3\u1563\xe3\u234darhk;\u6a17rod;\u6a3c\u0200cgpt\u236f\u2372\u2376\u237by;\u4451on;\u412ff;\uc000\ud835\udd5aa;\u43b9uest\u803b\xbf\u40bf\u0100ci\u238a\u238fr;\uc000\ud835\udcben\u0280;Edsv\u04f4\u239b\u239d\u23a1\u04f3;\u62f9ot;\u62f5\u0100;v\u23a6\u23a7\u62f4;\u62f3\u0100;i\u0777\u23aelde;\u4129\u01eb\u23b8\0\u23bccy;\u4456l\u803b\xef\u40ef\u0300cfmosu\u23cc\u23d7\u23dc\u23e1\u23e7\u23f5\u0100iy\u23d1\u23d5rc;\u4135;\u4439r;\uc000\ud835\udd27ath;\u4237pf;\uc000\ud835\udd5b\u01e3\u23ec\0\u23f1r;\uc000\ud835\udcbfrcy;\u4458kcy;\u4454\u0400acfghjos\u240b\u2416\u2422\u2427\u242d\u2431\u2435\u243bppa\u0100;v\u2413\u2414\u43ba;\u43f0\u0100ey\u241b\u2420dil;\u4137;\u443ar;\uc000\ud835\udd28reen;\u4138cy;\u4445cy;\u445cpf;\uc000\ud835\udd5ccr;\uc000\ud835\udcc0\u0b80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248d\u2491\u250e\u253d\u255a\u2580\u264e\u265e\u2665\u2679\u267d\u269a\u26b2\u26d8\u275d\u2768\u278b\u27c0\u2801\u2812\u0180art\u2477\u247a\u247cr\xf2\u09c6\xf2\u0395ail;\u691barr;\u690e\u0100;g\u0994\u248b;\u6a8bar;\u6962\u0963\u24a5\0\u24aa\0\u24b1\0\0\0\0\0\u24b5\u24ba\0\u24c6\u24c8\u24cd\0\u24f9ute;\u413amptyv;\u69b4ra\xee\u084cbda;\u43bbg\u0180;dl\u088e\u24c1\u24c3;\u6991\xe5\u088e;\u6a85uo\u803b\xab\u40abr\u0400;bfhlpst\u0899\u24de\u24e6\u24e9\u24eb\u24ee\u24f1\u24f5\u0100;f\u089d\u24e3s;\u691fs;\u691d\xeb\u2252p;\u61abl;\u6939im;\u6973l;\u61a2\u0180;ae\u24ff\u2500\u2504\u6aabil;\u6919\u0100;s\u2509\u250a\u6aad;\uc000\u2aad\ufe00\u0180abr\u2515\u2519\u251drr;\u690crk;\u6772\u0100ak\u2522\u252cc\u0100ek\u2528\u252a;\u407b;\u405b\u0100es\u2531\u2533;\u698bl\u0100du\u2539\u253b;\u698f;\u698d\u0200aeuy\u2546\u254b\u2556\u2558ron;\u413e\u0100di\u2550\u2554il;\u413c\xec\u08b0\xe2\u2529;\u443b\u0200cqrs\u2563\u2566\u256d\u257da;\u6936uo\u0100;r\u0e19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694bh;\u61b2\u0280;fgqs\u258b\u258c\u0989\u25f3\u25ff\u6264t\u0280ahlrt\u2598\u25a4\u25b7\u25c2\u25e8rrow\u0100;t\u0899\u25a1a\xe9\u24f6arpoon\u0100du\u25af\u25b4own\xbb\u045ap\xbb\u0966eftarrows;\u61c7ight\u0180ahs\u25cd\u25d6\u25derrow\u0100;s\u08f4\u08a7arpoon\xf3\u0f98quigarro\xf7\u21f0hreetimes;\u62cb\u0180;qs\u258b\u0993\u25falan\xf4\u09ac\u0280;cdgs\u09ac\u260a\u260d\u261d\u2628c;\u6aa8ot\u0100;o\u2614\u2615\u6a7f\u0100;r\u261a\u261b\u6a81;\u6a83\u0100;e\u2622\u2625\uc000\u22da\ufe00s;\u6a93\u0280adegs\u2633\u2639\u263d\u2649\u264bppro\xf8\u24c6ot;\u62d6q\u0100gq\u2643\u2645\xf4\u0989gt\xf2\u248c\xf4\u099bi\xed\u09b2\u0180ilr\u2655\u08e1\u265asht;\u697c;\uc000\ud835\udd29\u0100;E\u099c\u2663;\u6a91\u0161\u2669\u2676r\u0100du\u25b2\u266e\u0100;l\u0965\u2673;\u696alk;\u6584cy;\u4459\u0280;acht\u0a48\u2688\u268b\u2691\u2696r\xf2\u25c1orne\xf2\u1d08ard;\u696bri;\u65fa\u0100io\u269f\u26a4dot;\u4140ust\u0100;a\u26ac\u26ad\u63b0che\xbb\u26ad\u0200Eaes\u26bb\u26bd\u26c9\u26d4;\u6268p\u0100;p\u26c3\u26c4\u6a89rox\xbb\u26c4\u0100;q\u26ce\u26cf\u6a87\u0100;q\u26ce\u26bbim;\u62e6\u0400abnoptwz\u26e9\u26f4\u26f7\u271a\u272f\u2741\u2747\u2750\u0100nr\u26ee\u26f1g;\u67ecr;\u61fdr\xeb\u08c1g\u0180lmr\u26ff\u270d\u2714eft\u0100ar\u09e6\u2707ight\xe1\u09f2apsto;\u67fcight\xe1\u09fdparrow\u0100lr\u2725\u2729ef\xf4\u24edight;\u61ac\u0180afl\u2736\u2739\u273dr;\u6985;\uc000\ud835\udd5dus;\u6a2dimes;\u6a34\u0161\u274b\u274fst;\u6217\xe1\u134e\u0180;ef\u2757\u2758\u1800\u65cange\xbb\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277c\u2785\u2787r\xf2\u08a8orne\xf2\u1d8car\u0100;d\u0f98\u2783;\u696d;\u600eri;\u62bf\u0300achiqt\u2798\u279d\u0a40\u27a2\u27ae\u27bbquo;\u6039r;\uc000\ud835\udcc1m\u0180;eg\u09b2\u27aa\u27ac;\u6a8d;\u6a8f\u0100bu\u252a\u27b3o\u0100;r\u0e1f\u27b9;\u601arok;\u4142\u8400<;cdhilqr\u082b\u27d2\u2639\u27dc\u27e0\u27e5\u27ea\u27f0\u0100ci\u27d7\u27d9;\u6aa6r;\u6a79re\xe5\u25f2mes;\u62c9arr;\u6976uest;\u6a7b\u0100Pi\u27f5\u27f9ar;\u6996\u0180;ef\u2800\u092d\u181b\u65c3r\u0100du\u2807\u280dshar;\u694ahar;\u6966\u0100en\u2817\u2821rtneqq;\uc000\u2268\ufe00\xc5\u281e\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288e\u2893\u28a0\u28a5\u28a8\u28da\u28e2\u28e4\u0a83\u28f3\u2902Dot;\u623a\u0200clpr\u284e\u2852\u2863\u287dr\u803b\xaf\u40af\u0100et\u2857\u2859;\u6642\u0100;e\u285e\u285f\u6720se\xbb\u285f\u0100;s\u103b\u2868to\u0200;dlu\u103b\u2873\u2877\u287bow\xee\u048cef\xf4\u090f\xf0\u13d1ker;\u65ae\u0100oy\u2887\u288cmma;\u6a29;\u443cash;\u6014asuredangle\xbb\u1626r;\uc000\ud835\udd2ao;\u6127\u0180cdn\u28af\u28b4\u28c9ro\u803b\xb5\u40b5\u0200;acd\u1464\u28bd\u28c0\u28c4s\xf4\u16a7ir;\u6af0ot\u80bb\xb7\u01b5us\u0180;bd\u28d2\u1903\u28d3\u6212\u0100;u\u1d3c\u28d8;\u6a2a\u0163\u28de\u28e1p;\u6adb\xf2\u2212\xf0\u0a81\u0100dp\u28e9\u28eeels;\u62a7f;\uc000\ud835\udd5e\u0100ct\u28f8\u28fdr;\uc000\ud835\udcc2pos\xbb\u159d\u0180;lm\u2909\u290a\u290d\u43bctimap;\u62b8\u0c00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297e\u2989\u2998\u29da\u29e9\u2a15\u2a1a\u2a58\u2a5d\u2a83\u2a95\u2aa4\u2aa8\u2b04\u2b07\u2b44\u2b7f\u2bae\u2c34\u2c67\u2c7c\u2ce9\u0100gt\u2947\u294b;\uc000\u22d9\u0338\u0100;v\u2950\u0bcf\uc000\u226b\u20d2\u0180elt\u295a\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61cdightarrow;\u61ce;\uc000\u22d8\u0338\u0100;v\u297b\u0c47\uc000\u226a\u20d2ightarrow;\u61cf\u0100Dd\u298e\u2993ash;\u62afash;\u62ae\u0280bcnpt\u29a3\u29a7\u29ac\u29b1\u29ccla\xbb\u02deute;\u4144g;\uc000\u2220\u20d2\u0280;Eiop\u0d84\u29bc\u29c0\u29c5\u29c8;\uc000\u2a70\u0338d;\uc000\u224b\u0338s;\u4149ro\xf8\u0d84ur\u0100;a\u29d3\u29d4\u666el\u0100;s\u29d3\u0b38\u01f3\u29df\0\u29e3p\u80bb\xa0\u0b37mp\u0100;e\u0bf9\u0c00\u0280aeouy\u29f4\u29fe\u2a03\u2a10\u2a13\u01f0\u29f9\0\u29fb;\u6a43on;\u4148dil;\u4146ng\u0100;d\u0d7e\u2a0aot;\uc000\u2a6d\u0338p;\u6a42;\u443dash;\u6013\u0380;Aadqsx\u0b92\u2a29\u2a2d\u2a3b\u2a41\u2a45\u2a50rr;\u61d7r\u0100hr\u2a33\u2a36k;\u6924\u0100;o\u13f2\u13f0ot;\uc000\u2250\u0338ui\xf6\u0b63\u0100ei\u2a4a\u2a4ear;\u6928\xed\u0b98ist\u0100;s\u0ba0\u0b9fr;\uc000\ud835\udd2b\u0200Eest\u0bc5\u2a66\u2a79\u2a7c\u0180;qs\u0bbc\u2a6d\u0be1\u0180;qs\u0bbc\u0bc5\u2a74lan\xf4\u0be2i\xed\u0bea\u0100;r\u0bb6\u2a81\xbb\u0bb7\u0180Aap\u2a8a\u2a8d\u2a91r\xf2\u2971rr;\u61aear;\u6af2\u0180;sv\u0f8d\u2a9c\u0f8c\u0100;d\u2aa1\u2aa2\u62fc;\u62facy;\u445a\u0380AEadest\u2ab7\u2aba\u2abe\u2ac2\u2ac5\u2af6\u2af9r\xf2\u2966;\uc000\u2266\u0338rr;\u619ar;\u6025\u0200;fqs\u0c3b\u2ace\u2ae3\u2aeft\u0100ar\u2ad4\u2ad9rro\xf7\u2ac1ightarro\xf7\u2a90\u0180;qs\u0c3b\u2aba\u2aealan\xf4\u0c55\u0100;s\u0c55\u2af4\xbb\u0c36i\xed\u0c5d\u0100;r\u0c35\u2afei\u0100;e\u0c1a\u0c25i\xe4\u0d90\u0100pt\u2b0c\u2b11f;\uc000\ud835\udd5f\u8180\xac;in\u2b19\u2b1a\u2b36\u40acn\u0200;Edv\u0b89\u2b24\u2b28\u2b2e;\uc000\u22f9\u0338ot;\uc000\u22f5\u0338\u01e1\u0b89\u2b33\u2b35;\u62f7;\u62f6i\u0100;v\u0cb8\u2b3c\u01e1\u0cb8\u2b41\u2b43;\u62fe;\u62fd\u0180aor\u2b4b\u2b63\u2b69r\u0200;ast\u0b7b\u2b55\u2b5a\u2b5flle\xec\u0b7bl;\uc000\u2afd\u20e5;\uc000\u2202\u0338lint;\u6a14\u0180;ce\u0c92\u2b70\u2b73u\xe5\u0ca5\u0100;c\u0c98\u2b78\u0100;e\u0c92\u2b7d\xf1\u0c98\u0200Aait\u2b88\u2b8b\u2b9d\u2ba7r\xf2\u2988rr\u0180;cw\u2b94\u2b95\u2b99\u619b;\uc000\u2933\u0338;\uc000\u219d\u0338ghtarrow\xbb\u2b95ri\u0100;e\u0ccb\u0cd6\u0380chimpqu\u2bbd\u2bcd\u2bd9\u2b04\u0b78\u2be4\u2bef\u0200;cer\u0d32\u2bc6\u0d37\u2bc9u\xe5\u0d45;\uc000\ud835\udcc3ort\u026d\u2b05\0\0\u2bd6ar\xe1\u2b56m\u0100;e\u0d6e\u2bdf\u0100;q\u0d74\u0d73su\u0100bp\u2beb\u2bed\xe5\u0cf8\xe5\u0d0b\u0180bcp\u2bf6\u2c11\u2c19\u0200;Ees\u2bff\u2c00\u0d22\u2c04\u6284;\uc000\u2ac5\u0338et\u0100;e\u0d1b\u2c0bq\u0100;q\u0d23\u2c00c\u0100;e\u0d32\u2c17\xf1\u0d38\u0200;Ees\u2c22\u2c23\u0d5f\u2c27\u6285;\uc000\u2ac6\u0338et\u0100;e\u0d58\u2c2eq\u0100;q\u0d60\u2c23\u0200gilr\u2c3d\u2c3f\u2c45\u2c47\xec\u0bd7lde\u803b\xf1\u40f1\xe7\u0c43iangle\u0100lr\u2c52\u2c5ceft\u0100;e\u0c1a\u2c5a\xf1\u0c26ight\u0100;e\u0ccb\u2c65\xf1\u0cd7\u0100;m\u2c6c\u2c6d\u43bd\u0180;es\u2c74\u2c75\u2c79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2c8f\u2c94\u2c99\u2c9e\u2ca3\u2cb0\u2cb6\u2cd3\u2ce3ash;\u62adarr;\u6904p;\uc000\u224d\u20d2ash;\u62ac\u0100et\u2ca8\u2cac;\uc000\u2265\u20d2;\uc000>\u20d2nfin;\u69de\u0180Aet\u2cbd\u2cc1\u2cc5rr;\u6902;\uc000\u2264\u20d2\u0100;r\u2cca\u2ccd\uc000<\u20d2ie;\uc000\u22b4\u20d2\u0100At\u2cd8\u2cdcrr;\u6903rie;\uc000\u22b5\u20d2im;\uc000\u223c\u20d2\u0180Aan\u2cf0\u2cf4\u2d02rr;\u61d6r\u0100hr\u2cfa\u2cfdk;\u6923\u0100;o\u13e7\u13e5ear;\u6927\u1253\u1a95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2d2d\0\u2d38\u2d48\u2d60\u2d65\u2d72\u2d84\u1b07\0\0\u2d8d\u2dab\0\u2dc8\u2dce\0\u2ddc\u2e19\u2e2b\u2e3e\u2e43\u0100cs\u2d31\u1a97ute\u803b\xf3\u40f3\u0100iy\u2d3c\u2d45r\u0100;c\u1a9e\u2d42\u803b\xf4\u40f4;\u443e\u0280abios\u1aa0\u2d52\u2d57\u01c8\u2d5alac;\u4151v;\u6a38old;\u69bclig;\u4153\u0100cr\u2d69\u2d6dir;\u69bf;\uc000\ud835\udd2c\u036f\u2d79\0\0\u2d7c\0\u2d82n;\u42dbave\u803b\xf2\u40f2;\u69c1\u0100bm\u2d88\u0df4ar;\u69b5\u0200acit\u2d95\u2d98\u2da5\u2da8r\xf2\u1a80\u0100ir\u2d9d\u2da0r;\u69beoss;\u69bbn\xe5\u0e52;\u69c0\u0180aei\u2db1\u2db5\u2db9cr;\u414dga;\u43c9\u0180cdn\u2dc0\u2dc5\u01cdron;\u43bf;\u69b6pf;\uc000\ud835\udd60\u0180ael\u2dd4\u2dd7\u01d2r;\u69b7rp;\u69b9\u0380;adiosv\u2dea\u2deb\u2dee\u2e08\u2e0d\u2e10\u2e16\u6228r\xf2\u1a86\u0200;efm\u2df7\u2df8\u2e02\u2e05\u6a5dr\u0100;o\u2dfe\u2dff\u6134f\xbb\u2dff\u803b\xaa\u40aa\u803b\xba\u40bagof;\u62b6r;\u6a56lope;\u6a57;\u6a5b\u0180clo\u2e1f\u2e21\u2e27\xf2\u2e01ash\u803b\xf8\u40f8l;\u6298i\u016c\u2e2f\u2e34de\u803b\xf5\u40f5es\u0100;a\u01db\u2e3as;\u6a36ml\u803b\xf6\u40f6bar;\u633d\u0ae1\u2e5e\0\u2e7d\0\u2e80\u2e9d\0\u2ea2\u2eb9\0\0\u2ecb\u0e9c\0\u2f13\0\0\u2f2b\u2fbc\0\u2fc8r\u0200;ast\u0403\u2e67\u2e72\u0e85\u8100\xb6;l\u2e6d\u2e6e\u40b6le\xec\u0403\u0269\u2e78\0\0\u2e7bm;\u6af3;\u6afdy;\u443fr\u0280cimpt\u2e8b\u2e8f\u2e93\u1865\u2e97nt;\u4025od;\u402eil;\u6030enk;\u6031r;\uc000\ud835\udd2d\u0180imo\u2ea8\u2eb0\u2eb4\u0100;v\u2ead\u2eae\u43c6;\u43d5ma\xf4\u0a76ne;\u660e\u0180;tv\u2ebf\u2ec0\u2ec8\u43c0chfork\xbb\u1ffd;\u43d6\u0100au\u2ecf\u2edfn\u0100ck\u2ed5\u2eddk\u0100;h\u21f4\u2edb;\u610e\xf6\u21f4s\u0480;abcdemst\u2ef3\u2ef4\u1908\u2ef9\u2efd\u2f04\u2f06\u2f0a\u2f0e\u402bcir;\u6a23ir;\u6a22\u0100ou\u1d40\u2f02;\u6a25;\u6a72n\u80bb\xb1\u0e9dim;\u6a26wo;\u6a27\u0180ipu\u2f19\u2f20\u2f25ntint;\u6a15f;\uc000\ud835\udd61nd\u803b\xa3\u40a3\u0500;Eaceinosu\u0ec8\u2f3f\u2f41\u2f44\u2f47\u2f81\u2f89\u2f92\u2f7e\u2fb6;\u6ab3p;\u6ab7u\xe5\u0ed9\u0100;c\u0ece\u2f4c\u0300;acens\u0ec8\u2f59\u2f5f\u2f66\u2f68\u2f7eppro\xf8\u2f43urlye\xf1\u0ed9\xf1\u0ece\u0180aes\u2f6f\u2f76\u2f7approx;\u6ab9qq;\u6ab5im;\u62e8i\xed\u0edfme\u0100;s\u2f88\u0eae\u6032\u0180Eas\u2f78\u2f90\u2f7a\xf0\u2f75\u0180dfp\u0eec\u2f99\u2faf\u0180als\u2fa0\u2fa5\u2faalar;\u632eine;\u6312urf;\u6313\u0100;t\u0efb\u2fb4\xef\u0efbrel;\u62b0\u0100ci\u2fc0\u2fc5r;\uc000\ud835\udcc5;\u43c8ncsp;\u6008\u0300fiopsu\u2fda\u22e2\u2fdf\u2fe5\u2feb\u2ff1r;\uc000\ud835\udd2epf;\uc000\ud835\udd62rime;\u6057cr;\uc000\ud835\udcc6\u0180aeo\u2ff8\u3009\u3013t\u0100ei\u2ffe\u3005rnion\xf3\u06b0nt;\u6a16st\u0100;e\u3010\u3011\u403f\xf1\u1f19\xf4\u0f14\u0a80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30e0\u310e\u312b\u3147\u3162\u3172\u318e\u3206\u3215\u3224\u3229\u3258\u326e\u3272\u3290\u32b0\u32b7\u0180art\u3047\u304a\u304cr\xf2\u10b3\xf2\u03ddail;\u691car\xf2\u1c65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307f\u308f\u3094\u30cc\u0100eu\u306d\u3071;\uc000\u223d\u0331te;\u4155i\xe3\u116emptyv;\u69b3g\u0200;del\u0fd1\u3089\u308b\u308d;\u6992;\u69a5\xe5\u0fd1uo\u803b\xbb\u40bbr\u0580;abcfhlpstw\u0fdc\u30ac\u30af\u30b7\u30b9\u30bc\u30be\u30c0\u30c3\u30c7\u30cap;\u6975\u0100;f\u0fe0\u30b4s;\u6920;\u6933s;\u691e\xeb\u225d\xf0\u272el;\u6945im;\u6974l;\u61a3;\u619d\u0100ai\u30d1\u30d5il;\u691ao\u0100;n\u30db\u30dc\u6236al\xf3\u0f1e\u0180abr\u30e7\u30ea\u30eer\xf2\u17e5rk;\u6773\u0100ak\u30f3\u30fdc\u0100ek\u30f9\u30fb;\u407d;\u405d\u0100es\u3102\u3104;\u698cl\u0100du\u310a\u310c;\u698e;\u6990\u0200aeuy\u3117\u311c\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xec\u0ff2\xe2\u30fa;\u4440\u0200clqs\u3134\u3137\u313d\u3144a;\u6937dhar;\u6969uo\u0100;r\u020e\u020dh;\u61b3\u0180acg\u314e\u315f\u0f44l\u0200;ips\u0f78\u3158\u315b\u109cn\xe5\u10bbar\xf4\u0fa9t;\u65ad\u0180ilr\u3169\u1023\u316esht;\u697d;\uc000\ud835\udd2f\u0100ao\u3177\u3186r\u0100du\u317d\u317f\xbb\u047b\u0100;l\u1091\u3184;\u696c\u0100;v\u318b\u318c\u43c1;\u43f1\u0180gns\u3195\u31f9\u31fcht\u0300ahlrst\u31a4\u31b0\u31c2\u31d8\u31e4\u31eerrow\u0100;t\u0fdc\u31ada\xe9\u30c8arpoon\u0100du\u31bb\u31bfow\xee\u317ep\xbb\u1092eft\u0100ah\u31ca\u31d0rrow\xf3\u0feaarpoon\xf3\u0551ightarrows;\u61c9quigarro\xf7\u30cbhreetimes;\u62ccg;\u42daingdotse\xf1\u1f32\u0180ahm\u320d\u3210\u3213r\xf2\u0feaa\xf2\u0551;\u600foust\u0100;a\u321e\u321f\u63b1che\xbb\u321fmid;\u6aee\u0200abpt\u3232\u323d\u3240\u3252\u0100nr\u3237\u323ag;\u67edr;\u61fer\xeb\u1003\u0180afl\u3247\u324a\u324er;\u6986;\uc000\ud835\udd63us;\u6a2eimes;\u6a35\u0100ap\u325d\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6a12ar\xf2\u31e3\u0200achq\u327b\u3280\u10bc\u3285quo;\u603ar;\uc000\ud835\udcc7\u0100bu\u30fb\u328ao\u0100;r\u0214\u0213\u0180hir\u3297\u329b\u32a0re\xe5\u31f8mes;\u62cai\u0200;efl\u32aa\u1059\u1821\u32ab\u65b9tri;\u69celuhar;\u6968;\u611e\u0d61\u32d5\u32db\u32df\u332c\u3338\u3371\0\u337a\u33a4\0\0\u33ec\u33f0\0\u3428\u3448\u345a\u34ad\u34b1\u34ca\u34f1\0\u3616\0\0\u3633cute;\u415bqu\xef\u27ba\u0500;Eaceinpsy\u11ed\u32f3\u32f5\u32ff\u3302\u330b\u330f\u331f\u3326\u3329;\u6ab4\u01f0\u32fa\0\u32fc;\u6ab8on;\u4161u\xe5\u11fe\u0100;d\u11f3\u3307il;\u415frc;\u415d\u0180Eas\u3316\u3318\u331b;\u6ab6p;\u6abaim;\u62e9olint;\u6a13i\xed\u1204;\u4441ot\u0180;be\u3334\u1d47\u3335\u62c5;\u6a66\u0380Aacmstx\u3346\u334a\u3357\u335b\u335e\u3363\u336drr;\u61d8r\u0100hr\u3350\u3352\xeb\u2228\u0100;o\u0a36\u0a34t\u803b\xa7\u40a7i;\u403bwar;\u6929m\u0100in\u3369\xf0nu\xf3\xf1t;\u6736r\u0100;o\u3376\u2055\uc000\ud835\udd30\u0200acoy\u3382\u3386\u3391\u33a0rp;\u666f\u0100hy\u338b\u338fcy;\u4449;\u4448rt\u026d\u3399\0\0\u339ci\xe4\u1464ara\xec\u2e6f\u803b\xad\u40ad\u0100gm\u33a8\u33b4ma\u0180;fv\u33b1\u33b2\u33b2\u43c3;\u43c2\u0400;deglnpr\u12ab\u33c5\u33c9\u33ce\u33d6\u33de\u33e1\u33e6ot;\u6a6a\u0100;q\u12b1\u12b0\u0100;E\u33d3\u33d4\u6a9e;\u6aa0\u0100;E\u33db\u33dc\u6a9d;\u6a9fe;\u6246lus;\u6a24arr;\u6972ar\xf2\u113d\u0200aeit\u33f8\u3408\u340f\u3417\u0100ls\u33fd\u3404lsetm\xe9\u336ahp;\u6a33parsl;\u69e4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341c\u341d\u6aaa\u0100;s\u3422\u3423\u6aac;\uc000\u2aac\ufe00\u0180flp\u342e\u3433\u3442tcy;\u444c\u0100;b\u3438\u3439\u402f\u0100;a\u343e\u343f\u69c4r;\u633ff;\uc000\ud835\udd64a\u0100dr\u344d\u0402es\u0100;u\u3454\u3455\u6660it\xbb\u3455\u0180csu\u3460\u3479\u349f\u0100au\u3465\u346fp\u0100;s\u1188\u346b;\uc000\u2293\ufe00p\u0100;s\u11b4\u3475;\uc000\u2294\ufe00u\u0100bp\u347f\u348f\u0180;es\u1197\u119c\u3486et\u0100;e\u1197\u348d\xf1\u119d\u0180;es\u11a8\u11ad\u3496et\u0100;e\u11a8\u349d\xf1\u11ae\u0180;af\u117b\u34a6\u05b0r\u0165\u34ab\u05b1\xbb\u117car\xf2\u1148\u0200cemt\u34b9\u34be\u34c2\u34c5r;\uc000\ud835\udcc8tm\xee\xf1i\xec\u3415ar\xe6\u11be\u0100ar\u34ce\u34d5r\u0100;f\u34d4\u17bf\u6606\u0100an\u34da\u34edight\u0100ep\u34e3\u34eapsilo\xee\u1ee0h\xe9\u2eafs\xbb\u2852\u0280bcmnp\u34fb\u355e\u1209\u358b\u358e\u0480;Edemnprs\u350e\u350f\u3511\u3515\u351e\u3523\u352c\u3531\u3536\u6282;\u6ac5ot;\u6abd\u0100;d\u11da\u351aot;\u6ac3ult;\u6ac1\u0100Ee\u3528\u352a;\u6acb;\u628alus;\u6abfarr;\u6979\u0180eiu\u353d\u3552\u3555t\u0180;en\u350e\u3545\u354bq\u0100;q\u11da\u350feq\u0100;q\u352b\u3528m;\u6ac7\u0100bp\u355a\u355c;\u6ad5;\u6ad3c\u0300;acens\u11ed\u356c\u3572\u3579\u357b\u3326ppro\xf8\u32faurlye\xf1\u11fe\xf1\u11f3\u0180aes\u3582\u3588\u331bppro\xf8\u331aq\xf1\u3317g;\u666a\u0680123;Edehlmnps\u35a9\u35ac\u35af\u121c\u35b2\u35b4\u35c0\u35c9\u35d5\u35da\u35df\u35e8\u35ed\u803b\xb9\u40b9\u803b\xb2\u40b2\u803b\xb3\u40b3;\u6ac6\u0100os\u35b9\u35bct;\u6abeub;\u6ad8\u0100;d\u1222\u35c5ot;\u6ac4s\u0100ou\u35cf\u35d2l;\u67c9b;\u6ad7arr;\u697bult;\u6ac2\u0100Ee\u35e4\u35e6;\u6acc;\u628blus;\u6ac0\u0180eiu\u35f4\u3609\u360ct\u0180;en\u121c\u35fc\u3602q\u0100;q\u1222\u35b2eq\u0100;q\u35e7\u35e4m;\u6ac8\u0100bp\u3611\u3613;\u6ad4;\u6ad6\u0180Aan\u361c\u3620\u362drr;\u61d9r\u0100hr\u3626\u3628\xeb\u222e\u0100;o\u0a2b\u0a29war;\u692alig\u803b\xdf\u40df\u0be1\u3651\u365d\u3660\u12ce\u3673\u3679\0\u367e\u36c2\0\0\0\0\0\u36db\u3703\0\u3709\u376c\0\0\0\u3787\u0272\u3656\0\0\u365bget;\u6316;\u43c4r\xeb\u0e5f\u0180aey\u3666\u366b\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uc000\ud835\udd31\u0200eiko\u3686\u369d\u36b5\u36bc\u01f2\u368b\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369b\u43b8ym;\u43d1\u0100cn\u36a2\u36b2k\u0100as\u36a8\u36aeppro\xf8\u12c1im\xbb\u12acs\xf0\u129e\u0100as\u36ba\u36ae\xf0\u12c1rn\u803b\xfe\u40fe\u01ec\u031f\u36c6\u22e7es\u8180\xd7;bd\u36cf\u36d0\u36d8\u40d7\u0100;a\u190f\u36d5r;\u6a31;\u6a30\u0180eps\u36e1\u36e3\u3700\xe1\u2a4d\u0200;bcf\u0486\u36ec\u36f0\u36f4ot;\u6336ir;\u6af1\u0100;o\u36f9\u36fc\uc000\ud835\udd65rk;\u6ada\xe1\u3362rime;\u6034\u0180aip\u370f\u3712\u3764d\xe5\u1248\u0380adempst\u3721\u374d\u3740\u3751\u3757\u375c\u375fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65b5own\xbb\u1dbbeft\u0100;e\u2800\u373e\xf1\u092e;\u625cight\u0100;e\u32aa\u374b\xf1\u105aot;\u65ecinus;\u6a3alus;\u6a39b;\u69cdime;\u6a3bezium;\u63e2\u0180cht\u3772\u377d\u3781\u0100ry\u3777\u377b;\uc000\ud835\udcc9;\u4446cy;\u445brok;\u4167\u0100io\u378b\u378ex\xf4\u1777head\u0100lr\u3797\u37a0eftarro\xf7\u084fightarrow\xbb\u0f5d\u0900AHabcdfghlmoprstuw\u37d0\u37d3\u37d7\u37e4\u37f0\u37fc\u380e\u381c\u3823\u3834\u3851\u385d\u386b\u38a9\u38cc\u38d2\u38ea\u38f6r\xf2\u03edar;\u6963\u0100cr\u37dc\u37e2ute\u803b\xfa\u40fa\xf2\u1150r\u01e3\u37ea\0\u37edy;\u445eve;\u416d\u0100iy\u37f5\u37farc\u803b\xfb\u40fb;\u4443\u0180abh\u3803\u3806\u380br\xf2\u13adlac;\u4171a\xf2\u13c3\u0100ir\u3813\u3818sht;\u697e;\uc000\ud835\udd32rave\u803b\xf9\u40f9\u0161\u3827\u3831r\u0100lr\u382c\u382e\xbb\u0957\xbb\u1083lk;\u6580\u0100ct\u3839\u384d\u026f\u383f\0\0\u384arn\u0100;e\u3845\u3846\u631cr\xbb\u3846op;\u630fri;\u65f8\u0100al\u3856\u385acr;\u416b\u80bb\xa8\u0349\u0100gp\u3862\u3866on;\u4173f;\uc000\ud835\udd66\u0300adhlsu\u114b\u3878\u387d\u1372\u3891\u38a0own\xe1\u13b3arpoon\u0100lr\u3888\u388cef\xf4\u382digh\xf4\u382fi\u0180;hl\u3899\u389a\u389c\u43c5\xbb\u13faon\xbb\u389aparrows;\u61c8\u0180cit\u38b0\u38c4\u38c8\u026f\u38b6\0\0\u38c1rn\u0100;e\u38bc\u38bd\u631dr\xbb\u38bdop;\u630eng;\u416fri;\u65f9cr;\uc000\ud835\udcca\u0180dir\u38d9\u38dd\u38e2ot;\u62f0lde;\u4169i\u0100;f\u3730\u38e8\xbb\u1813\u0100am\u38ef\u38f2r\xf2\u38a8l\u803b\xfc\u40fcangle;\u69a7\u0780ABDacdeflnoprsz\u391c\u391f\u3929\u392d\u39b5\u39b8\u39bd\u39df\u39e4\u39e8\u39f3\u39f9\u39fd\u3a01\u3a20r\xf2\u03f7ar\u0100;v\u3926\u3927\u6ae8;\u6ae9as\xe8\u03e1\u0100nr\u3932\u3937grt;\u699c\u0380eknprst\u34e3\u3946\u394b\u3952\u395d\u3964\u3996app\xe1\u2415othin\xe7\u1e96\u0180hir\u34eb\u2ec8\u3959op\xf4\u2fb5\u0100;h\u13b7\u3962\xef\u318d\u0100iu\u3969\u396dgm\xe1\u33b3\u0100bp\u3972\u3984setneq\u0100;q\u397d\u3980\uc000\u228a\ufe00;\uc000\u2acb\ufe00setneq\u0100;q\u398f\u3992\uc000\u228b\ufe00;\uc000\u2acc\ufe00\u0100hr\u399b\u399fet\xe1\u369ciangle\u0100lr\u39aa\u39afeft\xbb\u0925ight\xbb\u1051y;\u4432ash\xbb\u1036\u0180elr\u39c4\u39d2\u39d7\u0180;be\u2dea\u39cb\u39cfar;\u62bbq;\u625alip;\u62ee\u0100bt\u39dc\u1468a\xf2\u1469r;\uc000\ud835\udd33tr\xe9\u39aesu\u0100bp\u39ef\u39f1\xbb\u0d1c\xbb\u0d59pf;\uc000\ud835\udd67ro\xf0\u0efbtr\xe9\u39b4\u0100cu\u3a06\u3a0br;\uc000\ud835\udccb\u0100bp\u3a10\u3a18n\u0100Ee\u3980\u3a16\xbb\u397en\u0100Ee\u3992\u3a1e\xbb\u3990igzag;\u699a\u0380cefoprs\u3a36\u3a3b\u3a56\u3a5b\u3a54\u3a61\u3a6airc;\u4175\u0100di\u3a40\u3a51\u0100bg\u3a45\u3a49ar;\u6a5fe\u0100;q\u15fa\u3a4f;\u6259erp;\u6118r;\uc000\ud835\udd34pf;\uc000\ud835\udd68\u0100;e\u1479\u3a66at\xe8\u1479cr;\uc000\ud835\udccc\u0ae3\u178e\u3a87\0\u3a8b\0\u3a90\u3a9b\0\0\u3a9d\u3aa8\u3aab\u3aaf\0\0\u3ac3\u3ace\0\u3ad8\u17dc\u17dftr\xe9\u17d1r;\uc000\ud835\udd35\u0100Aa\u3a94\u3a97r\xf2\u03c3r\xf2\u09f6;\u43be\u0100Aa\u3aa1\u3aa4r\xf2\u03b8r\xf2\u09eba\xf0\u2713is;\u62fb\u0180dpt\u17a4\u3ab5\u3abe\u0100fl\u3aba\u17a9;\uc000\ud835\udd69im\xe5\u17b2\u0100Aa\u3ac7\u3acar\xf2\u03cer\xf2\u0a01\u0100cq\u3ad2\u17b8r;\uc000\ud835\udccd\u0100pt\u17d6\u3adcr\xe9\u17d4\u0400acefiosu\u3af0\u3afd\u3b08\u3b0c\u3b11\u3b15\u3b1b\u3b21c\u0100uy\u3af6\u3afbte\u803b\xfd\u40fd;\u444f\u0100iy\u3b02\u3b06rc;\u4177;\u444bn\u803b\xa5\u40a5r;\uc000\ud835\udd36cy;\u4457pf;\uc000\ud835\udd6acr;\uc000\ud835\udcce\u0100cm\u3b26\u3b29y;\u444el\u803b\xff\u40ff\u0500acdefhiosw\u3b42\u3b48\u3b54\u3b58\u3b64\u3b69\u3b6d\u3b74\u3b7a\u3b80cute;\u417a\u0100ay\u3b4d\u3b52ron;\u417e;\u4437ot;\u417c\u0100et\u3b5d\u3b61tr\xe6\u155fa;\u43b6r;\uc000\ud835\udd37cy;\u4436grarr;\u61ddpf;\uc000\ud835\udd6bcr;\uc000\ud835\udccf\u0100jn\u3b85\u3b87;\u600dj;\u600c"
  663. .split("")
  664. .map((c) => c.charCodeAt(0)));
  665. // Generated using scripts/write-decode-map.ts
  666. var xmlDecodeTree = new Uint16Array(
  667. // prettier-ignore
  668. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  669. .split("")
  670. .map((c) => c.charCodeAt(0)));
  671. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  672. var _a$1;
  673. const decodeMap = new Map([
  674. [0, 65533],
  675. // C1 Unicode control character reference replacements
  676. [128, 8364],
  677. [130, 8218],
  678. [131, 402],
  679. [132, 8222],
  680. [133, 8230],
  681. [134, 8224],
  682. [135, 8225],
  683. [136, 710],
  684. [137, 8240],
  685. [138, 352],
  686. [139, 8249],
  687. [140, 338],
  688. [142, 381],
  689. [145, 8216],
  690. [146, 8217],
  691. [147, 8220],
  692. [148, 8221],
  693. [149, 8226],
  694. [150, 8211],
  695. [151, 8212],
  696. [152, 732],
  697. [153, 8482],
  698. [154, 353],
  699. [155, 8250],
  700. [156, 339],
  701. [158, 382],
  702. [159, 376],
  703. ]);
  704. /**
  705. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  706. */
  707. const fromCodePoint =
  708. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  709. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  710. let output = "";
  711. if (codePoint > 0xffff) {
  712. codePoint -= 0x10000;
  713. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  714. codePoint = 0xdc00 | (codePoint & 0x3ff);
  715. }
  716. output += String.fromCharCode(codePoint);
  717. return output;
  718. };
  719. /**
  720. * Replace the given code point with a replacement character if it is a
  721. * surrogate or is outside the valid range. Otherwise return the code
  722. * point unchanged.
  723. */
  724. function replaceCodePoint(codePoint) {
  725. var _a;
  726. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  727. return 0xfffd;
  728. }
  729. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  730. }
  731. var CharCodes;
  732. (function (CharCodes) {
  733. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  734. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  735. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  736. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  737. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  738. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  739. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  740. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  741. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  742. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  743. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  744. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  745. })(CharCodes || (CharCodes = {}));
  746. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  747. const TO_LOWER_BIT = 0b100000;
  748. var BinTrieFlags;
  749. (function (BinTrieFlags) {
  750. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  751. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  752. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  753. })(BinTrieFlags || (BinTrieFlags = {}));
  754. function isNumber$2(code) {
  755. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  756. }
  757. function isHexadecimalCharacter(code) {
  758. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  759. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  760. }
  761. function isAsciiAlphaNumeric(code) {
  762. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  763. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  764. isNumber$2(code));
  765. }
  766. /**
  767. * Checks if the given character is a valid end character for an entity in an attribute.
  768. *
  769. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  770. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  771. */
  772. function isEntityInAttributeInvalidEnd(code) {
  773. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  774. }
  775. var EntityDecoderState;
  776. (function (EntityDecoderState) {
  777. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  778. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  779. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  780. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  781. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  782. })(EntityDecoderState || (EntityDecoderState = {}));
  783. var DecodingMode;
  784. (function (DecodingMode) {
  785. /** Entities in text nodes that can end with any character. */
  786. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  787. /** Only allow entities terminated with a semicolon. */
  788. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  789. /** Entities in attributes have limitations on ending characters. */
  790. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  791. })(DecodingMode || (DecodingMode = {}));
  792. /**
  793. * Token decoder with support of writing partial entities.
  794. */
  795. class EntityDecoder {
  796. constructor(
  797. /** The tree used to decode entities. */
  798. decodeTree,
  799. /**
  800. * The function that is called when a codepoint is decoded.
  801. *
  802. * For multi-byte named entities, this will be called multiple times,
  803. * with the second codepoint, and the same `consumed` value.
  804. *
  805. * @param codepoint The decoded codepoint.
  806. * @param consumed The number of bytes consumed by the decoder.
  807. */
  808. emitCodePoint,
  809. /** An object that is used to produce errors. */
  810. errors) {
  811. this.decodeTree = decodeTree;
  812. this.emitCodePoint = emitCodePoint;
  813. this.errors = errors;
  814. /** The current state of the decoder. */
  815. this.state = EntityDecoderState.EntityStart;
  816. /** Characters that were consumed while parsing an entity. */
  817. this.consumed = 1;
  818. /**
  819. * The result of the entity.
  820. *
  821. * Either the result index of a numeric entity, or the codepoint of a
  822. * numeric entity.
  823. */
  824. this.result = 0;
  825. /** The current index in the decode tree. */
  826. this.treeIndex = 0;
  827. /** The number of characters that were consumed in excess. */
  828. this.excess = 1;
  829. /** The mode in which the decoder is operating. */
  830. this.decodeMode = DecodingMode.Strict;
  831. }
  832. /** Resets the instance to make it reusable. */
  833. startEntity(decodeMode) {
  834. this.decodeMode = decodeMode;
  835. this.state = EntityDecoderState.EntityStart;
  836. this.result = 0;
  837. this.treeIndex = 0;
  838. this.excess = 1;
  839. this.consumed = 1;
  840. }
  841. /**
  842. * Write an entity to the decoder. This can be called multiple times with partial entities.
  843. * If the entity is incomplete, the decoder will return -1.
  844. *
  845. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  846. * entity is incomplete, and resume when the next string is written.
  847. *
  848. * @param string The string containing the entity (or a continuation of the entity).
  849. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  850. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  851. */
  852. write(str, offset) {
  853. switch (this.state) {
  854. case EntityDecoderState.EntityStart: {
  855. if (str.charCodeAt(offset) === CharCodes.NUM) {
  856. this.state = EntityDecoderState.NumericStart;
  857. this.consumed += 1;
  858. return this.stateNumericStart(str, offset + 1);
  859. }
  860. this.state = EntityDecoderState.NamedEntity;
  861. return this.stateNamedEntity(str, offset);
  862. }
  863. case EntityDecoderState.NumericStart: {
  864. return this.stateNumericStart(str, offset);
  865. }
  866. case EntityDecoderState.NumericDecimal: {
  867. return this.stateNumericDecimal(str, offset);
  868. }
  869. case EntityDecoderState.NumericHex: {
  870. return this.stateNumericHex(str, offset);
  871. }
  872. case EntityDecoderState.NamedEntity: {
  873. return this.stateNamedEntity(str, offset);
  874. }
  875. }
  876. }
  877. /**
  878. * Switches between the numeric decimal and hexadecimal states.
  879. *
  880. * Equivalent to the `Numeric character reference state` in the HTML spec.
  881. *
  882. * @param str The string containing the entity (or a continuation of the entity).
  883. * @param offset The current offset.
  884. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  885. */
  886. stateNumericStart(str, offset) {
  887. if (offset >= str.length) {
  888. return -1;
  889. }
  890. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  891. this.state = EntityDecoderState.NumericHex;
  892. this.consumed += 1;
  893. return this.stateNumericHex(str, offset + 1);
  894. }
  895. this.state = EntityDecoderState.NumericDecimal;
  896. return this.stateNumericDecimal(str, offset);
  897. }
  898. addToNumericResult(str, start, end, base) {
  899. if (start !== end) {
  900. const digitCount = end - start;
  901. this.result =
  902. this.result * Math.pow(base, digitCount) +
  903. parseInt(str.substr(start, digitCount), base);
  904. this.consumed += digitCount;
  905. }
  906. }
  907. /**
  908. * Parses a hexadecimal numeric entity.
  909. *
  910. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  911. *
  912. * @param str The string containing the entity (or a continuation of the entity).
  913. * @param offset The current offset.
  914. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  915. */
  916. stateNumericHex(str, offset) {
  917. const startIdx = offset;
  918. while (offset < str.length) {
  919. const char = str.charCodeAt(offset);
  920. if (isNumber$2(char) || isHexadecimalCharacter(char)) {
  921. offset += 1;
  922. }
  923. else {
  924. this.addToNumericResult(str, startIdx, offset, 16);
  925. return this.emitNumericEntity(char, 3);
  926. }
  927. }
  928. this.addToNumericResult(str, startIdx, offset, 16);
  929. return -1;
  930. }
  931. /**
  932. * Parses a decimal numeric entity.
  933. *
  934. * Equivalent to the `Decimal character reference state` in the HTML spec.
  935. *
  936. * @param str The string containing the entity (or a continuation of the entity).
  937. * @param offset The current offset.
  938. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  939. */
  940. stateNumericDecimal(str, offset) {
  941. const startIdx = offset;
  942. while (offset < str.length) {
  943. const char = str.charCodeAt(offset);
  944. if (isNumber$2(char)) {
  945. offset += 1;
  946. }
  947. else {
  948. this.addToNumericResult(str, startIdx, offset, 10);
  949. return this.emitNumericEntity(char, 2);
  950. }
  951. }
  952. this.addToNumericResult(str, startIdx, offset, 10);
  953. return -1;
  954. }
  955. /**
  956. * Validate and emit a numeric entity.
  957. *
  958. * Implements the logic from the `Hexademical character reference start
  959. * state` and `Numeric character reference end state` in the HTML spec.
  960. *
  961. * @param lastCp The last code point of the entity. Used to see if the
  962. * entity was terminated with a semicolon.
  963. * @param expectedLength The minimum number of characters that should be
  964. * consumed. Used to validate that at least one digit
  965. * was consumed.
  966. * @returns The number of characters that were consumed.
  967. */
  968. emitNumericEntity(lastCp, expectedLength) {
  969. var _a;
  970. // Ensure we consumed at least one digit.
  971. if (this.consumed <= expectedLength) {
  972. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  973. return 0;
  974. }
  975. // Figure out if this is a legit end of the entity
  976. if (lastCp === CharCodes.SEMI) {
  977. this.consumed += 1;
  978. }
  979. else if (this.decodeMode === DecodingMode.Strict) {
  980. return 0;
  981. }
  982. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  983. if (this.errors) {
  984. if (lastCp !== CharCodes.SEMI) {
  985. this.errors.missingSemicolonAfterCharacterReference();
  986. }
  987. this.errors.validateNumericCharacterReference(this.result);
  988. }
  989. return this.consumed;
  990. }
  991. /**
  992. * Parses a named entity.
  993. *
  994. * Equivalent to the `Named character reference state` in the HTML spec.
  995. *
  996. * @param str The string containing the entity (or a continuation of the entity).
  997. * @param offset The current offset.
  998. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  999. */
  1000. stateNamedEntity(str, offset) {
  1001. const { decodeTree } = this;
  1002. let current = decodeTree[this.treeIndex];
  1003. // The mask is the number of bytes of the value, including the current byte.
  1004. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1005. for (; offset < str.length; offset++, this.excess++) {
  1006. const char = str.charCodeAt(offset);
  1007. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1008. if (this.treeIndex < 0) {
  1009. return this.result === 0 ||
  1010. // If we are parsing an attribute
  1011. (this.decodeMode === DecodingMode.Attribute &&
  1012. // We shouldn't have consumed any characters after the entity,
  1013. (valueLength === 0 ||
  1014. // And there should be no invalid characters.
  1015. isEntityInAttributeInvalidEnd(char)))
  1016. ? 0
  1017. : this.emitNotTerminatedNamedEntity();
  1018. }
  1019. current = decodeTree[this.treeIndex];
  1020. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1021. // If the branch is a value, store it and continue
  1022. if (valueLength !== 0) {
  1023. // If the entity is terminated by a semicolon, we are done.
  1024. if (char === CharCodes.SEMI) {
  1025. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1026. }
  1027. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1028. if (this.decodeMode !== DecodingMode.Strict) {
  1029. this.result = this.treeIndex;
  1030. this.consumed += this.excess;
  1031. this.excess = 0;
  1032. }
  1033. }
  1034. }
  1035. return -1;
  1036. }
  1037. /**
  1038. * Emit a named entity that was not terminated with a semicolon.
  1039. *
  1040. * @returns The number of characters consumed.
  1041. */
  1042. emitNotTerminatedNamedEntity() {
  1043. var _a;
  1044. const { result, decodeTree } = this;
  1045. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1046. this.emitNamedEntityData(result, valueLength, this.consumed);
  1047. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1048. return this.consumed;
  1049. }
  1050. /**
  1051. * Emit a named entity.
  1052. *
  1053. * @param result The index of the entity in the decode tree.
  1054. * @param valueLength The number of bytes in the entity.
  1055. * @param consumed The number of characters consumed.
  1056. *
  1057. * @returns The number of characters consumed.
  1058. */
  1059. emitNamedEntityData(result, valueLength, consumed) {
  1060. const { decodeTree } = this;
  1061. this.emitCodePoint(valueLength === 1
  1062. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1063. : decodeTree[result + 1], consumed);
  1064. if (valueLength === 3) {
  1065. // For multi-byte values, we need to emit the second byte.
  1066. this.emitCodePoint(decodeTree[result + 2], consumed);
  1067. }
  1068. return consumed;
  1069. }
  1070. /**
  1071. * Signal to the parser that the end of the input was reached.
  1072. *
  1073. * Remaining data will be emitted and relevant errors will be produced.
  1074. *
  1075. * @returns The number of characters consumed.
  1076. */
  1077. end() {
  1078. var _a;
  1079. switch (this.state) {
  1080. case EntityDecoderState.NamedEntity: {
  1081. // Emit a named entity if we have one.
  1082. return this.result !== 0 &&
  1083. (this.decodeMode !== DecodingMode.Attribute ||
  1084. this.result === this.treeIndex)
  1085. ? this.emitNotTerminatedNamedEntity()
  1086. : 0;
  1087. }
  1088. // Otherwise, emit a numeric entity if we have one.
  1089. case EntityDecoderState.NumericDecimal: {
  1090. return this.emitNumericEntity(0, 2);
  1091. }
  1092. case EntityDecoderState.NumericHex: {
  1093. return this.emitNumericEntity(0, 3);
  1094. }
  1095. case EntityDecoderState.NumericStart: {
  1096. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1097. return 0;
  1098. }
  1099. case EntityDecoderState.EntityStart: {
  1100. // Return 0 if we have no entity.
  1101. return 0;
  1102. }
  1103. }
  1104. }
  1105. }
  1106. /**
  1107. * Creates a function that decodes entities in a string.
  1108. *
  1109. * @param decodeTree The decode tree.
  1110. * @returns A function that decodes entities in a string.
  1111. */
  1112. function getDecoder(decodeTree) {
  1113. let ret = "";
  1114. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1115. return function decodeWithTrie(str, decodeMode) {
  1116. let lastIndex = 0;
  1117. let offset = 0;
  1118. while ((offset = str.indexOf("&", offset)) >= 0) {
  1119. ret += str.slice(lastIndex, offset);
  1120. decoder.startEntity(decodeMode);
  1121. const len = decoder.write(str,
  1122. // Skip the "&"
  1123. offset + 1);
  1124. if (len < 0) {
  1125. lastIndex = offset + decoder.end();
  1126. break;
  1127. }
  1128. lastIndex = offset + len;
  1129. // If `len` is 0, skip the current `&` and continue.
  1130. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1131. }
  1132. const result = ret + str.slice(lastIndex);
  1133. // Make sure we don't keep a reference to the final string.
  1134. ret = "";
  1135. return result;
  1136. };
  1137. }
  1138. /**
  1139. * Determines the branch of the current node that is taken given the current
  1140. * character. This function is used to traverse the trie.
  1141. *
  1142. * @param decodeTree The trie.
  1143. * @param current The current node.
  1144. * @param nodeIdx The index right after the current node and its value.
  1145. * @param char The current character.
  1146. * @returns The index of the next node, or -1 if no branch is taken.
  1147. */
  1148. function determineBranch(decodeTree, current, nodeIdx, char) {
  1149. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1150. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1151. // Case 1: Single branch encoded in jump offset
  1152. if (branchCount === 0) {
  1153. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1154. }
  1155. // Case 2: Multiple branches encoded in jump table
  1156. if (jumpOffset) {
  1157. const value = char - jumpOffset;
  1158. return value < 0 || value >= branchCount
  1159. ? -1
  1160. : decodeTree[nodeIdx + value] - 1;
  1161. }
  1162. // Case 3: Multiple branches encoded in dictionary
  1163. // Binary search for the character.
  1164. let lo = nodeIdx;
  1165. let hi = lo + branchCount - 1;
  1166. while (lo <= hi) {
  1167. const mid = (lo + hi) >>> 1;
  1168. const midVal = decodeTree[mid];
  1169. if (midVal < char) {
  1170. lo = mid + 1;
  1171. }
  1172. else if (midVal > char) {
  1173. hi = mid - 1;
  1174. }
  1175. else {
  1176. return decodeTree[mid + branchCount];
  1177. }
  1178. }
  1179. return -1;
  1180. }
  1181. const htmlDecoder = getDecoder(htmlDecodeTree);
  1182. getDecoder(xmlDecodeTree);
  1183. /**
  1184. * Decodes an HTML string.
  1185. *
  1186. * @param str The string to decode.
  1187. * @param mode The decoding mode.
  1188. * @returns The decoded string.
  1189. */
  1190. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1191. return htmlDecoder(str, mode);
  1192. }
  1193. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1194. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1195. function isTagStartChar(c) {
  1196. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1197. }
  1198. function isWhitespace$1(c) {
  1199. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1200. }
  1201. function isEndOfTagSection(c) {
  1202. return c === 47 || c === 62 || isWhitespace$1(c);
  1203. }
  1204. function toCharCodes(str) {
  1205. const ret = new Uint8Array(str.length);
  1206. for (let i = 0; i < str.length; i++) {
  1207. ret[i] = str.charCodeAt(i);
  1208. }
  1209. return ret;
  1210. }
  1211. const Sequences = {
  1212. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1213. // CDATA[
  1214. CdataEnd: new Uint8Array([93, 93, 62]),
  1215. // ]]>
  1216. CommentEnd: new Uint8Array([45, 45, 62]),
  1217. // `-->`
  1218. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1219. // `<\/script`
  1220. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1221. // `</style`
  1222. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1223. // `</title`
  1224. TextareaEnd: new Uint8Array([
  1225. 60,
  1226. 47,
  1227. 116,
  1228. 101,
  1229. 120,
  1230. 116,
  1231. 97,
  1232. 114,
  1233. 101,
  1234. 97
  1235. ])
  1236. // `</textarea
  1237. };
  1238. let Tokenizer$1 = class Tokenizer {
  1239. constructor(stack, cbs) {
  1240. this.stack = stack;
  1241. this.cbs = cbs;
  1242. /** The current state the tokenizer is in. */
  1243. this.state = 1;
  1244. /** The read buffer. */
  1245. this.buffer = "";
  1246. /** The beginning of the section that is currently being read. */
  1247. this.sectionStart = 0;
  1248. /** The index within the buffer that we are currently looking at. */
  1249. this.index = 0;
  1250. /** The start of the last entity. */
  1251. this.entityStart = 0;
  1252. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1253. this.baseState = 1;
  1254. /** For special parsing behavior inside of script and style tags. */
  1255. this.inRCDATA = false;
  1256. /** For disabling RCDATA tags handling */
  1257. this.inXML = false;
  1258. /** For disabling interpolation parsing in v-pre */
  1259. this.inVPre = false;
  1260. /** Record newline positions for fast line / column calculation */
  1261. this.newlines = [];
  1262. this.mode = 0;
  1263. this.delimiterOpen = defaultDelimitersOpen;
  1264. this.delimiterClose = defaultDelimitersClose;
  1265. this.delimiterIndex = -1;
  1266. this.currentSequence = void 0;
  1267. this.sequenceIndex = 0;
  1268. {
  1269. this.entityDecoder = new EntityDecoder(
  1270. htmlDecodeTree,
  1271. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1272. );
  1273. }
  1274. }
  1275. get inSFCRoot() {
  1276. return this.mode === 2 && this.stack.length === 0;
  1277. }
  1278. reset() {
  1279. this.state = 1;
  1280. this.mode = 0;
  1281. this.buffer = "";
  1282. this.sectionStart = 0;
  1283. this.index = 0;
  1284. this.baseState = 1;
  1285. this.inRCDATA = false;
  1286. this.currentSequence = void 0;
  1287. this.newlines.length = 0;
  1288. this.delimiterOpen = defaultDelimitersOpen;
  1289. this.delimiterClose = defaultDelimitersClose;
  1290. }
  1291. /**
  1292. * Generate Position object with line / column information using recorded
  1293. * newline positions. We know the index is always going to be an already
  1294. * processed index, so all the newlines up to this index should have been
  1295. * recorded.
  1296. */
  1297. getPos(index) {
  1298. let line = 1;
  1299. let column = index + 1;
  1300. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1301. const newlineIndex = this.newlines[i];
  1302. if (index > newlineIndex) {
  1303. line = i + 2;
  1304. column = index - newlineIndex;
  1305. break;
  1306. }
  1307. }
  1308. return {
  1309. column,
  1310. line,
  1311. offset: index
  1312. };
  1313. }
  1314. peek() {
  1315. return this.buffer.charCodeAt(this.index + 1);
  1316. }
  1317. stateText(c) {
  1318. if (c === 60) {
  1319. if (this.index > this.sectionStart) {
  1320. this.cbs.ontext(this.sectionStart, this.index);
  1321. }
  1322. this.state = 5;
  1323. this.sectionStart = this.index;
  1324. } else if (c === 38) {
  1325. this.startEntity();
  1326. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1327. this.state = 2;
  1328. this.delimiterIndex = 0;
  1329. this.stateInterpolationOpen(c);
  1330. }
  1331. }
  1332. stateInterpolationOpen(c) {
  1333. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1334. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1335. const start = this.index + 1 - this.delimiterOpen.length;
  1336. if (start > this.sectionStart) {
  1337. this.cbs.ontext(this.sectionStart, start);
  1338. }
  1339. this.state = 3;
  1340. this.sectionStart = start;
  1341. } else {
  1342. this.delimiterIndex++;
  1343. }
  1344. } else if (this.inRCDATA) {
  1345. this.state = 32;
  1346. this.stateInRCDATA(c);
  1347. } else {
  1348. this.state = 1;
  1349. this.stateText(c);
  1350. }
  1351. }
  1352. stateInterpolation(c) {
  1353. if (c === this.delimiterClose[0]) {
  1354. this.state = 4;
  1355. this.delimiterIndex = 0;
  1356. this.stateInterpolationClose(c);
  1357. }
  1358. }
  1359. stateInterpolationClose(c) {
  1360. if (c === this.delimiterClose[this.delimiterIndex]) {
  1361. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1362. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1363. if (this.inRCDATA) {
  1364. this.state = 32;
  1365. } else {
  1366. this.state = 1;
  1367. }
  1368. this.sectionStart = this.index + 1;
  1369. } else {
  1370. this.delimiterIndex++;
  1371. }
  1372. } else {
  1373. this.state = 3;
  1374. this.stateInterpolation(c);
  1375. }
  1376. }
  1377. stateSpecialStartSequence(c) {
  1378. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1379. const isMatch = isEnd ? (
  1380. // If we are at the end of the sequence, make sure the tag name has ended
  1381. isEndOfTagSection(c)
  1382. ) : (
  1383. // Otherwise, do a case-insensitive comparison
  1384. (c | 32) === this.currentSequence[this.sequenceIndex]
  1385. );
  1386. if (!isMatch) {
  1387. this.inRCDATA = false;
  1388. } else if (!isEnd) {
  1389. this.sequenceIndex++;
  1390. return;
  1391. }
  1392. this.sequenceIndex = 0;
  1393. this.state = 6;
  1394. this.stateInTagName(c);
  1395. }
  1396. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1397. stateInRCDATA(c) {
  1398. if (this.sequenceIndex === this.currentSequence.length) {
  1399. if (c === 62 || isWhitespace$1(c)) {
  1400. const endOfText = this.index - this.currentSequence.length;
  1401. if (this.sectionStart < endOfText) {
  1402. const actualIndex = this.index;
  1403. this.index = endOfText;
  1404. this.cbs.ontext(this.sectionStart, endOfText);
  1405. this.index = actualIndex;
  1406. }
  1407. this.sectionStart = endOfText + 2;
  1408. this.stateInClosingTagName(c);
  1409. this.inRCDATA = false;
  1410. return;
  1411. }
  1412. this.sequenceIndex = 0;
  1413. }
  1414. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1415. this.sequenceIndex += 1;
  1416. } else if (this.sequenceIndex === 0) {
  1417. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1418. if (c === 38) {
  1419. this.startEntity();
  1420. } else if (c === this.delimiterOpen[0]) {
  1421. this.state = 2;
  1422. this.delimiterIndex = 0;
  1423. this.stateInterpolationOpen(c);
  1424. }
  1425. } else if (this.fastForwardTo(60)) {
  1426. this.sequenceIndex = 1;
  1427. }
  1428. } else {
  1429. this.sequenceIndex = Number(c === 60);
  1430. }
  1431. }
  1432. stateCDATASequence(c) {
  1433. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1434. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1435. this.state = 28;
  1436. this.currentSequence = Sequences.CdataEnd;
  1437. this.sequenceIndex = 0;
  1438. this.sectionStart = this.index + 1;
  1439. }
  1440. } else {
  1441. this.sequenceIndex = 0;
  1442. this.state = 23;
  1443. this.stateInDeclaration(c);
  1444. }
  1445. }
  1446. /**
  1447. * When we wait for one specific character, we can speed things up
  1448. * by skipping through the buffer until we find it.
  1449. *
  1450. * @returns Whether the character was found.
  1451. */
  1452. fastForwardTo(c) {
  1453. while (++this.index < this.buffer.length) {
  1454. const cc = this.buffer.charCodeAt(this.index);
  1455. if (cc === 10) {
  1456. this.newlines.push(this.index);
  1457. }
  1458. if (cc === c) {
  1459. return true;
  1460. }
  1461. }
  1462. this.index = this.buffer.length - 1;
  1463. return false;
  1464. }
  1465. /**
  1466. * Comments and CDATA end with `-->` and `]]>`.
  1467. *
  1468. * Their common qualities are:
  1469. * - Their end sequences have a distinct character they start with.
  1470. * - That character is then repeated, so we have to check multiple repeats.
  1471. * - All characters but the start character of the sequence can be skipped.
  1472. */
  1473. stateInCommentLike(c) {
  1474. if (c === this.currentSequence[this.sequenceIndex]) {
  1475. if (++this.sequenceIndex === this.currentSequence.length) {
  1476. if (this.currentSequence === Sequences.CdataEnd) {
  1477. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1478. } else {
  1479. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1480. }
  1481. this.sequenceIndex = 0;
  1482. this.sectionStart = this.index + 1;
  1483. this.state = 1;
  1484. }
  1485. } else if (this.sequenceIndex === 0) {
  1486. if (this.fastForwardTo(this.currentSequence[0])) {
  1487. this.sequenceIndex = 1;
  1488. }
  1489. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1490. this.sequenceIndex = 0;
  1491. }
  1492. }
  1493. startSpecial(sequence, offset) {
  1494. this.enterRCDATA(sequence, offset);
  1495. this.state = 31;
  1496. }
  1497. enterRCDATA(sequence, offset) {
  1498. this.inRCDATA = true;
  1499. this.currentSequence = sequence;
  1500. this.sequenceIndex = offset;
  1501. }
  1502. stateBeforeTagName(c) {
  1503. if (c === 33) {
  1504. this.state = 22;
  1505. this.sectionStart = this.index + 1;
  1506. } else if (c === 63) {
  1507. this.state = 24;
  1508. this.sectionStart = this.index + 1;
  1509. } else if (isTagStartChar(c)) {
  1510. this.sectionStart = this.index;
  1511. if (this.mode === 0) {
  1512. this.state = 6;
  1513. } else if (this.inSFCRoot) {
  1514. this.state = 34;
  1515. } else if (!this.inXML) {
  1516. if (c === 116) {
  1517. this.state = 30;
  1518. } else {
  1519. this.state = c === 115 ? 29 : 6;
  1520. }
  1521. } else {
  1522. this.state = 6;
  1523. }
  1524. } else if (c === 47) {
  1525. this.state = 8;
  1526. } else {
  1527. this.state = 1;
  1528. this.stateText(c);
  1529. }
  1530. }
  1531. stateInTagName(c) {
  1532. if (isEndOfTagSection(c)) {
  1533. this.handleTagName(c);
  1534. }
  1535. }
  1536. stateInSFCRootTagName(c) {
  1537. if (isEndOfTagSection(c)) {
  1538. const tag = this.buffer.slice(this.sectionStart, this.index);
  1539. if (tag !== "template") {
  1540. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1541. }
  1542. this.handleTagName(c);
  1543. }
  1544. }
  1545. handleTagName(c) {
  1546. this.cbs.onopentagname(this.sectionStart, this.index);
  1547. this.sectionStart = -1;
  1548. this.state = 11;
  1549. this.stateBeforeAttrName(c);
  1550. }
  1551. stateBeforeClosingTagName(c) {
  1552. if (isWhitespace$1(c)) ; else if (c === 62) {
  1553. {
  1554. this.cbs.onerr(14, this.index);
  1555. }
  1556. this.state = 1;
  1557. this.sectionStart = this.index + 1;
  1558. } else {
  1559. this.state = isTagStartChar(c) ? 9 : 27;
  1560. this.sectionStart = this.index;
  1561. }
  1562. }
  1563. stateInClosingTagName(c) {
  1564. if (c === 62 || isWhitespace$1(c)) {
  1565. this.cbs.onclosetag(this.sectionStart, this.index);
  1566. this.sectionStart = -1;
  1567. this.state = 10;
  1568. this.stateAfterClosingTagName(c);
  1569. }
  1570. }
  1571. stateAfterClosingTagName(c) {
  1572. if (c === 62) {
  1573. this.state = 1;
  1574. this.sectionStart = this.index + 1;
  1575. }
  1576. }
  1577. stateBeforeAttrName(c) {
  1578. if (c === 62) {
  1579. this.cbs.onopentagend(this.index);
  1580. if (this.inRCDATA) {
  1581. this.state = 32;
  1582. } else {
  1583. this.state = 1;
  1584. }
  1585. this.sectionStart = this.index + 1;
  1586. } else if (c === 47) {
  1587. this.state = 7;
  1588. if (this.peek() !== 62) {
  1589. this.cbs.onerr(22, this.index);
  1590. }
  1591. } else if (c === 60 && this.peek() === 47) {
  1592. this.cbs.onopentagend(this.index);
  1593. this.state = 5;
  1594. this.sectionStart = this.index;
  1595. } else if (!isWhitespace$1(c)) {
  1596. if (c === 61) {
  1597. this.cbs.onerr(
  1598. 19,
  1599. this.index
  1600. );
  1601. }
  1602. this.handleAttrStart(c);
  1603. }
  1604. }
  1605. handleAttrStart(c) {
  1606. if (c === 118 && this.peek() === 45) {
  1607. this.state = 13;
  1608. this.sectionStart = this.index;
  1609. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1610. this.cbs.ondirname(this.index, this.index + 1);
  1611. this.state = 14;
  1612. this.sectionStart = this.index + 1;
  1613. } else {
  1614. this.state = 12;
  1615. this.sectionStart = this.index;
  1616. }
  1617. }
  1618. stateInSelfClosingTag(c) {
  1619. if (c === 62) {
  1620. this.cbs.onselfclosingtag(this.index);
  1621. this.state = 1;
  1622. this.sectionStart = this.index + 1;
  1623. this.inRCDATA = false;
  1624. } else if (!isWhitespace$1(c)) {
  1625. this.state = 11;
  1626. this.stateBeforeAttrName(c);
  1627. }
  1628. }
  1629. stateInAttrName(c) {
  1630. if (c === 61 || isEndOfTagSection(c)) {
  1631. this.cbs.onattribname(this.sectionStart, this.index);
  1632. this.handleAttrNameEnd(c);
  1633. } else if (c === 34 || c === 39 || c === 60) {
  1634. this.cbs.onerr(
  1635. 17,
  1636. this.index
  1637. );
  1638. }
  1639. }
  1640. stateInDirName(c) {
  1641. if (c === 61 || isEndOfTagSection(c)) {
  1642. this.cbs.ondirname(this.sectionStart, this.index);
  1643. this.handleAttrNameEnd(c);
  1644. } else if (c === 58) {
  1645. this.cbs.ondirname(this.sectionStart, this.index);
  1646. this.state = 14;
  1647. this.sectionStart = this.index + 1;
  1648. } else if (c === 46) {
  1649. this.cbs.ondirname(this.sectionStart, this.index);
  1650. this.state = 16;
  1651. this.sectionStart = this.index + 1;
  1652. }
  1653. }
  1654. stateInDirArg(c) {
  1655. if (c === 61 || isEndOfTagSection(c)) {
  1656. this.cbs.ondirarg(this.sectionStart, this.index);
  1657. this.handleAttrNameEnd(c);
  1658. } else if (c === 91) {
  1659. this.state = 15;
  1660. } else if (c === 46) {
  1661. this.cbs.ondirarg(this.sectionStart, this.index);
  1662. this.state = 16;
  1663. this.sectionStart = this.index + 1;
  1664. }
  1665. }
  1666. stateInDynamicDirArg(c) {
  1667. if (c === 93) {
  1668. this.state = 14;
  1669. } else if (c === 61 || isEndOfTagSection(c)) {
  1670. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1671. this.handleAttrNameEnd(c);
  1672. {
  1673. this.cbs.onerr(
  1674. 27,
  1675. this.index
  1676. );
  1677. }
  1678. }
  1679. }
  1680. stateInDirModifier(c) {
  1681. if (c === 61 || isEndOfTagSection(c)) {
  1682. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1683. this.handleAttrNameEnd(c);
  1684. } else if (c === 46) {
  1685. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1686. this.sectionStart = this.index + 1;
  1687. }
  1688. }
  1689. handleAttrNameEnd(c) {
  1690. this.sectionStart = this.index;
  1691. this.state = 17;
  1692. this.cbs.onattribnameend(this.index);
  1693. this.stateAfterAttrName(c);
  1694. }
  1695. stateAfterAttrName(c) {
  1696. if (c === 61) {
  1697. this.state = 18;
  1698. } else if (c === 47 || c === 62) {
  1699. this.cbs.onattribend(0, this.sectionStart);
  1700. this.sectionStart = -1;
  1701. this.state = 11;
  1702. this.stateBeforeAttrName(c);
  1703. } else if (!isWhitespace$1(c)) {
  1704. this.cbs.onattribend(0, this.sectionStart);
  1705. this.handleAttrStart(c);
  1706. }
  1707. }
  1708. stateBeforeAttrValue(c) {
  1709. if (c === 34) {
  1710. this.state = 19;
  1711. this.sectionStart = this.index + 1;
  1712. } else if (c === 39) {
  1713. this.state = 20;
  1714. this.sectionStart = this.index + 1;
  1715. } else if (!isWhitespace$1(c)) {
  1716. this.sectionStart = this.index;
  1717. this.state = 21;
  1718. this.stateInAttrValueNoQuotes(c);
  1719. }
  1720. }
  1721. handleInAttrValue(c, quote) {
  1722. if (c === quote || false) {
  1723. this.cbs.onattribdata(this.sectionStart, this.index);
  1724. this.sectionStart = -1;
  1725. this.cbs.onattribend(
  1726. quote === 34 ? 3 : 2,
  1727. this.index + 1
  1728. );
  1729. this.state = 11;
  1730. } else if (c === 38) {
  1731. this.startEntity();
  1732. }
  1733. }
  1734. stateInAttrValueDoubleQuotes(c) {
  1735. this.handleInAttrValue(c, 34);
  1736. }
  1737. stateInAttrValueSingleQuotes(c) {
  1738. this.handleInAttrValue(c, 39);
  1739. }
  1740. stateInAttrValueNoQuotes(c) {
  1741. if (isWhitespace$1(c) || c === 62) {
  1742. this.cbs.onattribdata(this.sectionStart, this.index);
  1743. this.sectionStart = -1;
  1744. this.cbs.onattribend(1, this.index);
  1745. this.state = 11;
  1746. this.stateBeforeAttrName(c);
  1747. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1748. this.cbs.onerr(
  1749. 18,
  1750. this.index
  1751. );
  1752. } else if (c === 38) {
  1753. this.startEntity();
  1754. }
  1755. }
  1756. stateBeforeDeclaration(c) {
  1757. if (c === 91) {
  1758. this.state = 26;
  1759. this.sequenceIndex = 0;
  1760. } else {
  1761. this.state = c === 45 ? 25 : 23;
  1762. }
  1763. }
  1764. stateInDeclaration(c) {
  1765. if (c === 62 || this.fastForwardTo(62)) {
  1766. this.state = 1;
  1767. this.sectionStart = this.index + 1;
  1768. }
  1769. }
  1770. stateInProcessingInstruction(c) {
  1771. if (c === 62 || this.fastForwardTo(62)) {
  1772. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1773. this.state = 1;
  1774. this.sectionStart = this.index + 1;
  1775. }
  1776. }
  1777. stateBeforeComment(c) {
  1778. if (c === 45) {
  1779. this.state = 28;
  1780. this.currentSequence = Sequences.CommentEnd;
  1781. this.sequenceIndex = 2;
  1782. this.sectionStart = this.index + 1;
  1783. } else {
  1784. this.state = 23;
  1785. }
  1786. }
  1787. stateInSpecialComment(c) {
  1788. if (c === 62 || this.fastForwardTo(62)) {
  1789. this.cbs.oncomment(this.sectionStart, this.index);
  1790. this.state = 1;
  1791. this.sectionStart = this.index + 1;
  1792. }
  1793. }
  1794. stateBeforeSpecialS(c) {
  1795. if (c === Sequences.ScriptEnd[3]) {
  1796. this.startSpecial(Sequences.ScriptEnd, 4);
  1797. } else if (c === Sequences.StyleEnd[3]) {
  1798. this.startSpecial(Sequences.StyleEnd, 4);
  1799. } else {
  1800. this.state = 6;
  1801. this.stateInTagName(c);
  1802. }
  1803. }
  1804. stateBeforeSpecialT(c) {
  1805. if (c === Sequences.TitleEnd[3]) {
  1806. this.startSpecial(Sequences.TitleEnd, 4);
  1807. } else if (c === Sequences.TextareaEnd[3]) {
  1808. this.startSpecial(Sequences.TextareaEnd, 4);
  1809. } else {
  1810. this.state = 6;
  1811. this.stateInTagName(c);
  1812. }
  1813. }
  1814. startEntity() {
  1815. {
  1816. this.baseState = this.state;
  1817. this.state = 33;
  1818. this.entityStart = this.index;
  1819. this.entityDecoder.startEntity(
  1820. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1821. );
  1822. }
  1823. }
  1824. stateInEntity() {
  1825. {
  1826. const length = this.entityDecoder.write(this.buffer, this.index);
  1827. if (length >= 0) {
  1828. this.state = this.baseState;
  1829. if (length === 0) {
  1830. this.index = this.entityStart;
  1831. }
  1832. } else {
  1833. this.index = this.buffer.length - 1;
  1834. }
  1835. }
  1836. }
  1837. /**
  1838. * Iterates through the buffer, calling the function corresponding to the current state.
  1839. *
  1840. * States that are more likely to be hit are higher up, as a performance improvement.
  1841. */
  1842. parse(input) {
  1843. this.buffer = input;
  1844. while (this.index < this.buffer.length) {
  1845. const c = this.buffer.charCodeAt(this.index);
  1846. if (c === 10) {
  1847. this.newlines.push(this.index);
  1848. }
  1849. switch (this.state) {
  1850. case 1: {
  1851. this.stateText(c);
  1852. break;
  1853. }
  1854. case 2: {
  1855. this.stateInterpolationOpen(c);
  1856. break;
  1857. }
  1858. case 3: {
  1859. this.stateInterpolation(c);
  1860. break;
  1861. }
  1862. case 4: {
  1863. this.stateInterpolationClose(c);
  1864. break;
  1865. }
  1866. case 31: {
  1867. this.stateSpecialStartSequence(c);
  1868. break;
  1869. }
  1870. case 32: {
  1871. this.stateInRCDATA(c);
  1872. break;
  1873. }
  1874. case 26: {
  1875. this.stateCDATASequence(c);
  1876. break;
  1877. }
  1878. case 19: {
  1879. this.stateInAttrValueDoubleQuotes(c);
  1880. break;
  1881. }
  1882. case 12: {
  1883. this.stateInAttrName(c);
  1884. break;
  1885. }
  1886. case 13: {
  1887. this.stateInDirName(c);
  1888. break;
  1889. }
  1890. case 14: {
  1891. this.stateInDirArg(c);
  1892. break;
  1893. }
  1894. case 15: {
  1895. this.stateInDynamicDirArg(c);
  1896. break;
  1897. }
  1898. case 16: {
  1899. this.stateInDirModifier(c);
  1900. break;
  1901. }
  1902. case 28: {
  1903. this.stateInCommentLike(c);
  1904. break;
  1905. }
  1906. case 27: {
  1907. this.stateInSpecialComment(c);
  1908. break;
  1909. }
  1910. case 11: {
  1911. this.stateBeforeAttrName(c);
  1912. break;
  1913. }
  1914. case 6: {
  1915. this.stateInTagName(c);
  1916. break;
  1917. }
  1918. case 34: {
  1919. this.stateInSFCRootTagName(c);
  1920. break;
  1921. }
  1922. case 9: {
  1923. this.stateInClosingTagName(c);
  1924. break;
  1925. }
  1926. case 5: {
  1927. this.stateBeforeTagName(c);
  1928. break;
  1929. }
  1930. case 17: {
  1931. this.stateAfterAttrName(c);
  1932. break;
  1933. }
  1934. case 20: {
  1935. this.stateInAttrValueSingleQuotes(c);
  1936. break;
  1937. }
  1938. case 18: {
  1939. this.stateBeforeAttrValue(c);
  1940. break;
  1941. }
  1942. case 8: {
  1943. this.stateBeforeClosingTagName(c);
  1944. break;
  1945. }
  1946. case 10: {
  1947. this.stateAfterClosingTagName(c);
  1948. break;
  1949. }
  1950. case 29: {
  1951. this.stateBeforeSpecialS(c);
  1952. break;
  1953. }
  1954. case 30: {
  1955. this.stateBeforeSpecialT(c);
  1956. break;
  1957. }
  1958. case 21: {
  1959. this.stateInAttrValueNoQuotes(c);
  1960. break;
  1961. }
  1962. case 7: {
  1963. this.stateInSelfClosingTag(c);
  1964. break;
  1965. }
  1966. case 23: {
  1967. this.stateInDeclaration(c);
  1968. break;
  1969. }
  1970. case 22: {
  1971. this.stateBeforeDeclaration(c);
  1972. break;
  1973. }
  1974. case 25: {
  1975. this.stateBeforeComment(c);
  1976. break;
  1977. }
  1978. case 24: {
  1979. this.stateInProcessingInstruction(c);
  1980. break;
  1981. }
  1982. case 33: {
  1983. this.stateInEntity();
  1984. break;
  1985. }
  1986. }
  1987. this.index++;
  1988. }
  1989. this.cleanup();
  1990. this.finish();
  1991. }
  1992. /**
  1993. * Remove data that has already been consumed from the buffer.
  1994. */
  1995. cleanup() {
  1996. if (this.sectionStart !== this.index) {
  1997. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  1998. this.cbs.ontext(this.sectionStart, this.index);
  1999. this.sectionStart = this.index;
  2000. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  2001. this.cbs.onattribdata(this.sectionStart, this.index);
  2002. this.sectionStart = this.index;
  2003. }
  2004. }
  2005. }
  2006. finish() {
  2007. if (this.state === 33) {
  2008. this.entityDecoder.end();
  2009. this.state = this.baseState;
  2010. }
  2011. this.handleTrailingData();
  2012. this.cbs.onend();
  2013. }
  2014. /** Handle any trailing data. */
  2015. handleTrailingData() {
  2016. const endIndex = this.buffer.length;
  2017. if (this.sectionStart >= endIndex) {
  2018. return;
  2019. }
  2020. if (this.state === 28) {
  2021. if (this.currentSequence === Sequences.CdataEnd) {
  2022. this.cbs.oncdata(this.sectionStart, endIndex);
  2023. } else {
  2024. this.cbs.oncomment(this.sectionStart, endIndex);
  2025. }
  2026. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
  2027. this.cbs.ontext(this.sectionStart, endIndex);
  2028. }
  2029. }
  2030. emitCodePoint(cp, consumed) {
  2031. {
  2032. if (this.baseState !== 1 && this.baseState !== 32) {
  2033. if (this.sectionStart < this.entityStart) {
  2034. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2035. }
  2036. this.sectionStart = this.entityStart + consumed;
  2037. this.index = this.sectionStart - 1;
  2038. this.cbs.onattribentity(
  2039. fromCodePoint(cp),
  2040. this.entityStart,
  2041. this.sectionStart
  2042. );
  2043. } else {
  2044. if (this.sectionStart < this.entityStart) {
  2045. this.cbs.ontext(this.sectionStart, this.entityStart);
  2046. }
  2047. this.sectionStart = this.entityStart + consumed;
  2048. this.index = this.sectionStart - 1;
  2049. this.cbs.ontextentity(
  2050. fromCodePoint(cp),
  2051. this.entityStart,
  2052. this.sectionStart
  2053. );
  2054. }
  2055. }
  2056. }
  2057. };
  2058. const CompilerDeprecationTypes = {
  2059. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2060. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2061. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2062. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2063. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2064. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2065. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2066. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2067. };
  2068. const deprecationData = {
  2069. ["COMPILER_IS_ON_ELEMENT"]: {
  2070. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  2071. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2072. },
  2073. ["COMPILER_V_BIND_SYNC"]: {
  2074. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  2075. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2076. },
  2077. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2078. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  2079. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2080. },
  2081. ["COMPILER_V_ON_NATIVE"]: {
  2082. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2083. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2084. },
  2085. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2086. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  2087. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2088. },
  2089. ["COMPILER_NATIVE_TEMPLATE"]: {
  2090. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2091. },
  2092. ["COMPILER_INLINE_TEMPLATE"]: {
  2093. message: `"inline-template" has been removed in Vue 3.`,
  2094. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2095. },
  2096. ["COMPILER_FILTERS"]: {
  2097. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  2098. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2099. }
  2100. };
  2101. function getCompatValue(key, { compatConfig }) {
  2102. const value = compatConfig && compatConfig[key];
  2103. if (key === "MODE") {
  2104. return value || 3;
  2105. } else {
  2106. return value;
  2107. }
  2108. }
  2109. function isCompatEnabled(key, context) {
  2110. const mode = getCompatValue("MODE", context);
  2111. const value = getCompatValue(key, context);
  2112. return mode === 3 ? value === true : value !== false;
  2113. }
  2114. function checkCompatEnabled(key, context, loc, ...args) {
  2115. const enabled = isCompatEnabled(key, context);
  2116. if (enabled) {
  2117. warnDeprecation(key, context, loc, ...args);
  2118. }
  2119. return enabled;
  2120. }
  2121. function warnDeprecation(key, context, loc, ...args) {
  2122. const val = getCompatValue(key, context);
  2123. if (val === "suppress-warning") {
  2124. return;
  2125. }
  2126. const { message, link } = deprecationData[key];
  2127. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2128. Details: ${link}` : ``}`;
  2129. const err = new SyntaxError(msg);
  2130. err.code = key;
  2131. if (loc)
  2132. err.loc = loc;
  2133. context.onWarn(err);
  2134. }
  2135. function defaultOnError(error) {
  2136. throw error;
  2137. }
  2138. function defaultOnWarn(msg) {
  2139. console.warn(`[Vue warn] ${msg.message}`);
  2140. }
  2141. function createCompilerError(code, loc, messages, additionalMessage) {
  2142. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2143. const error = new SyntaxError(String(msg));
  2144. error.code = code;
  2145. error.loc = loc;
  2146. return error;
  2147. }
  2148. const ErrorCodes = {
  2149. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2150. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2151. "CDATA_IN_HTML_CONTENT": 1,
  2152. "1": "CDATA_IN_HTML_CONTENT",
  2153. "DUPLICATE_ATTRIBUTE": 2,
  2154. "2": "DUPLICATE_ATTRIBUTE",
  2155. "END_TAG_WITH_ATTRIBUTES": 3,
  2156. "3": "END_TAG_WITH_ATTRIBUTES",
  2157. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2158. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2159. "EOF_BEFORE_TAG_NAME": 5,
  2160. "5": "EOF_BEFORE_TAG_NAME",
  2161. "EOF_IN_CDATA": 6,
  2162. "6": "EOF_IN_CDATA",
  2163. "EOF_IN_COMMENT": 7,
  2164. "7": "EOF_IN_COMMENT",
  2165. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2166. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2167. "EOF_IN_TAG": 9,
  2168. "9": "EOF_IN_TAG",
  2169. "INCORRECTLY_CLOSED_COMMENT": 10,
  2170. "10": "INCORRECTLY_CLOSED_COMMENT",
  2171. "INCORRECTLY_OPENED_COMMENT": 11,
  2172. "11": "INCORRECTLY_OPENED_COMMENT",
  2173. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2174. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2175. "MISSING_ATTRIBUTE_VALUE": 13,
  2176. "13": "MISSING_ATTRIBUTE_VALUE",
  2177. "MISSING_END_TAG_NAME": 14,
  2178. "14": "MISSING_END_TAG_NAME",
  2179. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2180. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2181. "NESTED_COMMENT": 16,
  2182. "16": "NESTED_COMMENT",
  2183. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2184. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2185. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2186. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2187. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2188. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2189. "UNEXPECTED_NULL_CHARACTER": 20,
  2190. "20": "UNEXPECTED_NULL_CHARACTER",
  2191. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2192. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2193. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2194. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2195. "X_INVALID_END_TAG": 23,
  2196. "23": "X_INVALID_END_TAG",
  2197. "X_MISSING_END_TAG": 24,
  2198. "24": "X_MISSING_END_TAG",
  2199. "X_MISSING_INTERPOLATION_END": 25,
  2200. "25": "X_MISSING_INTERPOLATION_END",
  2201. "X_MISSING_DIRECTIVE_NAME": 26,
  2202. "26": "X_MISSING_DIRECTIVE_NAME",
  2203. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2204. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2205. "X_V_IF_NO_EXPRESSION": 28,
  2206. "28": "X_V_IF_NO_EXPRESSION",
  2207. "X_V_IF_SAME_KEY": 29,
  2208. "29": "X_V_IF_SAME_KEY",
  2209. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2210. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2211. "X_V_FOR_NO_EXPRESSION": 31,
  2212. "31": "X_V_FOR_NO_EXPRESSION",
  2213. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2214. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2215. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2216. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2217. "X_V_BIND_NO_EXPRESSION": 34,
  2218. "34": "X_V_BIND_NO_EXPRESSION",
  2219. "X_V_ON_NO_EXPRESSION": 35,
  2220. "35": "X_V_ON_NO_EXPRESSION",
  2221. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2222. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2223. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2224. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2225. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2226. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2227. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2228. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2229. "X_V_SLOT_MISPLACED": 40,
  2230. "40": "X_V_SLOT_MISPLACED",
  2231. "X_V_MODEL_NO_EXPRESSION": 41,
  2232. "41": "X_V_MODEL_NO_EXPRESSION",
  2233. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2234. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2235. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2236. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2237. "X_V_MODEL_ON_PROPS": 44,
  2238. "44": "X_V_MODEL_ON_PROPS",
  2239. "X_INVALID_EXPRESSION": 45,
  2240. "45": "X_INVALID_EXPRESSION",
  2241. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2242. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2243. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2244. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2245. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2246. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2247. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2248. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2249. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2250. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2251. "X_VNODE_HOOKS": 51,
  2252. "51": "X_VNODE_HOOKS",
  2253. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2254. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2255. "__EXTEND_POINT__": 53,
  2256. "53": "__EXTEND_POINT__"
  2257. };
  2258. const errorMessages$1 = {
  2259. // parse errors
  2260. [0]: "Illegal comment.",
  2261. [1]: "CDATA section is allowed only in XML context.",
  2262. [2]: "Duplicate attribute.",
  2263. [3]: "End tag cannot have attributes.",
  2264. [4]: "Illegal '/' in tags.",
  2265. [5]: "Unexpected EOF in tag.",
  2266. [6]: "Unexpected EOF in CDATA section.",
  2267. [7]: "Unexpected EOF in comment.",
  2268. [8]: "Unexpected EOF in script.",
  2269. [9]: "Unexpected EOF in tag.",
  2270. [10]: "Incorrectly closed comment.",
  2271. [11]: "Incorrectly opened comment.",
  2272. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2273. [13]: "Attribute value was expected.",
  2274. [14]: "End tag name was expected.",
  2275. [15]: "Whitespace was expected.",
  2276. [16]: "Unexpected '<!--' in comment.",
  2277. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2278. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2279. [19]: "Attribute name cannot start with '='.",
  2280. [21]: "'<?' is allowed only in XML context.",
  2281. [20]: `Unexpected null character.`,
  2282. [22]: "Illegal '/' in tags.",
  2283. // Vue-specific parse errors
  2284. [23]: "Invalid end tag.",
  2285. [24]: "Element is missing end tag.",
  2286. [25]: "Interpolation end sign was not found.",
  2287. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2288. [26]: "Legal directive name was expected.",
  2289. // transform errors
  2290. [28]: `v-if/v-else-if is missing expression.`,
  2291. [29]: `v-if/else branches must use unique keys.`,
  2292. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2293. [31]: `v-for is missing expression.`,
  2294. [32]: `v-for has invalid expression.`,
  2295. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2296. [34]: `v-bind is missing expression.`,
  2297. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2298. [35]: `v-on is missing expression.`,
  2299. [36]: `Unexpected custom directive on <slot> outlet.`,
  2300. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  2301. [38]: `Duplicate slot names found. `,
  2302. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2303. [40]: `v-slot can only be used on components or <template> tags.`,
  2304. [41]: `v-model is missing expression.`,
  2305. [42]: `v-model value must be a valid JavaScript member expression.`,
  2306. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2307. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2308. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2309. [45]: `Error parsing JavaScript expression: `,
  2310. [46]: `<KeepAlive> expects exactly one child component.`,
  2311. [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  2312. // generic errors
  2313. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2314. [48]: `ES module mode is not supported in this build of compiler.`,
  2315. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2316. [50]: `"scopeId" option is only supported in module mode.`,
  2317. // just to fulfill types
  2318. [53]: ``
  2319. };
  2320. function getDefaultExportFromCjs (x) {
  2321. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2322. }
  2323. function getAugmentedNamespace(n) {
  2324. if (n.__esModule) return n;
  2325. var f = n.default;
  2326. if (typeof f == "function") {
  2327. var a = function a () {
  2328. if (this instanceof a) {
  2329. return Reflect.construct(f, arguments, this.constructor);
  2330. }
  2331. return f.apply(this, arguments);
  2332. };
  2333. a.prototype = f.prototype;
  2334. } else a = {};
  2335. Object.defineProperty(a, '__esModule', {value: true});
  2336. Object.keys(n).forEach(function (k) {
  2337. var d = Object.getOwnPropertyDescriptor(n, k);
  2338. Object.defineProperty(a, k, d.get ? d : {
  2339. enumerable: true,
  2340. get: function () {
  2341. return n[k];
  2342. }
  2343. });
  2344. });
  2345. return a;
  2346. }
  2347. var lib = {};
  2348. Object.defineProperty(lib, '__esModule', {
  2349. value: true
  2350. });
  2351. function _objectWithoutPropertiesLoose(source, excluded) {
  2352. if (source == null) return {};
  2353. var target = {};
  2354. var sourceKeys = Object.keys(source);
  2355. var key, i;
  2356. for (i = 0; i < sourceKeys.length; i++) {
  2357. key = sourceKeys[i];
  2358. if (excluded.indexOf(key) >= 0) continue;
  2359. target[key] = source[key];
  2360. }
  2361. return target;
  2362. }
  2363. class Position {
  2364. constructor(line, col, index) {
  2365. this.line = void 0;
  2366. this.column = void 0;
  2367. this.index = void 0;
  2368. this.line = line;
  2369. this.column = col;
  2370. this.index = index;
  2371. }
  2372. }
  2373. class SourceLocation {
  2374. constructor(start, end) {
  2375. this.start = void 0;
  2376. this.end = void 0;
  2377. this.filename = void 0;
  2378. this.identifierName = void 0;
  2379. this.start = start;
  2380. this.end = end;
  2381. }
  2382. }
  2383. function createPositionWithColumnOffset(position, columnOffset) {
  2384. const {
  2385. line,
  2386. column,
  2387. index
  2388. } = position;
  2389. return new Position(line, column + columnOffset, index + columnOffset);
  2390. }
  2391. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2392. var ModuleErrors = {
  2393. ImportMetaOutsideModule: {
  2394. message: `import.meta may appear only with 'sourceType: "module"'`,
  2395. code
  2396. },
  2397. ImportOutsideModule: {
  2398. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2399. code
  2400. }
  2401. };
  2402. const NodeDescriptions = {
  2403. ArrayPattern: "array destructuring pattern",
  2404. AssignmentExpression: "assignment expression",
  2405. AssignmentPattern: "assignment expression",
  2406. ArrowFunctionExpression: "arrow function expression",
  2407. ConditionalExpression: "conditional expression",
  2408. CatchClause: "catch clause",
  2409. ForOfStatement: "for-of statement",
  2410. ForInStatement: "for-in statement",
  2411. ForStatement: "for-loop",
  2412. FormalParameters: "function parameter list",
  2413. Identifier: "identifier",
  2414. ImportSpecifier: "import specifier",
  2415. ImportDefaultSpecifier: "import default specifier",
  2416. ImportNamespaceSpecifier: "import namespace specifier",
  2417. ObjectPattern: "object destructuring pattern",
  2418. ParenthesizedExpression: "parenthesized expression",
  2419. RestElement: "rest element",
  2420. UpdateExpression: {
  2421. true: "prefix operation",
  2422. false: "postfix operation"
  2423. },
  2424. VariableDeclarator: "variable declaration",
  2425. YieldExpression: "yield expression"
  2426. };
  2427. const toNodeDescription = ({
  2428. type,
  2429. prefix
  2430. }) => type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[String(prefix)] : NodeDescriptions[type];
  2431. var StandardErrors = {
  2432. AccessorIsGenerator: ({
  2433. kind
  2434. }) => `A ${kind}ter cannot be a generator.`,
  2435. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2436. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2437. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2438. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2439. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2440. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2441. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2442. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  2443. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2444. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2445. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2446. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2447. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2448. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2449. ConstructorIsAsync: "Constructor can't be an async function.",
  2450. ConstructorIsGenerator: "Constructor can't be a generator.",
  2451. DeclarationMissingInitializer: ({
  2452. kind
  2453. }) => `Missing initializer in ${kind} declaration.`,
  2454. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2455. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2456. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2457. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2458. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2459. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2460. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2461. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2462. DeletePrivateField: "Deleting a private field is not allowed.",
  2463. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2464. DuplicateConstructor: "Duplicate constructor in the same class.",
  2465. DuplicateDefaultExport: "Only one default export allowed per module.",
  2466. DuplicateExport: ({
  2467. exportName
  2468. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2469. DuplicateProto: "Redefinition of __proto__ property.",
  2470. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2471. DynamicImportPhaseRequiresImportExpressions: ({
  2472. phase
  2473. }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
  2474. ElementAfterRest: "Rest element must be last element.",
  2475. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2476. ExportBindingIsString: ({
  2477. localName,
  2478. exportName
  2479. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2480. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2481. ForInOfLoopInitializer: ({
  2482. type
  2483. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2484. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2485. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2486. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2487. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2488. IllegalBreakContinue: ({
  2489. type
  2490. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2491. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2492. IllegalReturn: "'return' outside of function.",
  2493. ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",
  2494. ImportBindingIsString: ({
  2495. importName
  2496. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2497. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  2498. ImportCallArity: ({
  2499. maxArgumentCount
  2500. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  2501. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2502. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2503. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2504. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2505. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2506. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2507. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2508. InvalidCodePoint: "Code point out of bounds.",
  2509. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2510. InvalidDecimal: "Invalid decimal.",
  2511. InvalidDigit: ({
  2512. radix
  2513. }) => `Expected number in radix ${radix}.`,
  2514. InvalidEscapeSequence: "Bad character escape sequence.",
  2515. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2516. InvalidEscapedReservedWord: ({
  2517. reservedWord
  2518. }) => `Escape sequence in keyword ${reservedWord}.`,
  2519. InvalidIdentifier: ({
  2520. identifierName
  2521. }) => `Invalid identifier ${identifierName}.`,
  2522. InvalidLhs: ({
  2523. ancestor
  2524. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2525. InvalidLhsBinding: ({
  2526. ancestor
  2527. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2528. InvalidLhsOptionalChaining: ({
  2529. ancestor
  2530. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2531. InvalidNumber: "Invalid number.",
  2532. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2533. InvalidOrUnexpectedToken: ({
  2534. unexpected
  2535. }) => `Unexpected character '${unexpected}'.`,
  2536. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2537. InvalidPrivateFieldResolution: ({
  2538. identifierName
  2539. }) => `Private name #${identifierName} is not defined.`,
  2540. InvalidPropertyBindingPattern: "Binding member expression.",
  2541. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2542. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2543. LabelRedeclaration: ({
  2544. labelName
  2545. }) => `Label '${labelName}' is already declared.`,
  2546. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2547. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2548. MalformedRegExpFlags: "Invalid regular expression flag.",
  2549. MissingClassName: "A class name is required.",
  2550. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2551. MissingSemicolon: "Missing semicolon.",
  2552. MissingPlugin: ({
  2553. missingPlugin
  2554. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2555. MissingOneOfPlugins: ({
  2556. missingPlugin
  2557. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2558. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2559. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2560. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2561. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2562. ModuleAttributesWithDuplicateKeys: ({
  2563. key
  2564. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2565. ModuleExportNameHasLoneSurrogate: ({
  2566. surrogateCharCode
  2567. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2568. ModuleExportUndefined: ({
  2569. localName
  2570. }) => `Export '${localName}' is not defined.`,
  2571. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2572. NewlineAfterThrow: "Illegal newline after throw.",
  2573. NoCatchOrFinally: "Missing catch or finally clause.",
  2574. NumberIdentifier: "Identifier directly after number.",
  2575. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2576. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2577. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2578. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2579. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2580. ParamDupe: "Argument name clash.",
  2581. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2582. PatternHasMethod: "Object pattern can't contain methods.",
  2583. PrivateInExpectedIn: ({
  2584. identifierName
  2585. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2586. PrivateNameRedeclaration: ({
  2587. identifierName
  2588. }) => `Duplicate private name #${identifierName}.`,
  2589. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2590. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2591. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2592. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2593. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2594. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2595. SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
  2596. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2597. StaticPrototype: "Classes may not have static property named prototype.",
  2598. SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
  2599. SuperPrivateField: "Private fields can't be accessed on super.",
  2600. TrailingDecorator: "Decorators must be attached to a class element.",
  2601. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2602. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2603. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2604. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2605. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2606. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2607. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2608. UnexpectedKeyword: ({
  2609. keyword
  2610. }) => `Unexpected keyword '${keyword}'.`,
  2611. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2612. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2613. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2614. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2615. UnexpectedPrivateField: "Unexpected private name.",
  2616. UnexpectedReservedWord: ({
  2617. reservedWord
  2618. }) => `Unexpected reserved word '${reservedWord}'.`,
  2619. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2620. UnexpectedToken: ({
  2621. expected,
  2622. unexpected
  2623. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2624. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2625. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  2626. UnsupportedBind: "Binding should be performed on object property.",
  2627. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2628. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2629. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2630. UnsupportedMetaProperty: ({
  2631. target,
  2632. onlyValidPropertyName
  2633. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2634. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2635. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2636. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2637. UnterminatedComment: "Unterminated comment.",
  2638. UnterminatedRegExp: "Unterminated regular expression.",
  2639. UnterminatedString: "Unterminated string constant.",
  2640. UnterminatedTemplate: "Unterminated template.",
  2641. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2642. VarRedeclaration: ({
  2643. identifierName
  2644. }) => `Identifier '${identifierName}' has already been declared.`,
  2645. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2646. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2647. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2648. };
  2649. var StrictModeErrors = {
  2650. StrictDelete: "Deleting local variable in strict mode.",
  2651. StrictEvalArguments: ({
  2652. referenceName
  2653. }) => `Assigning to '${referenceName}' in strict mode.`,
  2654. StrictEvalArgumentsBinding: ({
  2655. bindingName
  2656. }) => `Binding '${bindingName}' in strict mode.`,
  2657. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2658. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2659. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2660. StrictWith: "'with' in strict mode."
  2661. };
  2662. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2663. var PipelineOperatorErrors = {
  2664. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2665. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2666. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2667. PipeTopicUnconfiguredToken: ({
  2668. token
  2669. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2670. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2671. PipeUnparenthesizedBody: ({
  2672. type
  2673. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2674. type
  2675. })}; please wrap it in parentheses.`,
  2676. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2677. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2678. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2679. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2680. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2681. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2682. };
  2683. const _excluded = ["toMessage"],
  2684. _excluded2 = ["message"];
  2685. function defineHidden(obj, key, value) {
  2686. Object.defineProperty(obj, key, {
  2687. enumerable: false,
  2688. configurable: true,
  2689. value
  2690. });
  2691. }
  2692. function toParseErrorConstructor(_ref) {
  2693. let {
  2694. toMessage
  2695. } = _ref,
  2696. properties = _objectWithoutPropertiesLoose(_ref, _excluded);
  2697. return function constructor(loc, details) {
  2698. const error = new SyntaxError();
  2699. Object.assign(error, properties, {
  2700. loc,
  2701. pos: loc.index
  2702. });
  2703. if ("missingPlugin" in details) {
  2704. Object.assign(error, {
  2705. missingPlugin: details.missingPlugin
  2706. });
  2707. }
  2708. defineHidden(error, "clone", function clone(overrides = {}) {
  2709. var _overrides$loc;
  2710. const {
  2711. line,
  2712. column,
  2713. index
  2714. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2715. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2716. });
  2717. defineHidden(error, "details", details);
  2718. Object.defineProperty(error, "message", {
  2719. configurable: true,
  2720. get() {
  2721. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2722. this.message = message;
  2723. return message;
  2724. },
  2725. set(value) {
  2726. Object.defineProperty(this, "message", {
  2727. value,
  2728. writable: true
  2729. });
  2730. }
  2731. });
  2732. return error;
  2733. };
  2734. }
  2735. function ParseErrorEnum(argument, syntaxPlugin) {
  2736. if (Array.isArray(argument)) {
  2737. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2738. }
  2739. const ParseErrorConstructors = {};
  2740. for (const reasonCode of Object.keys(argument)) {
  2741. const template = argument[reasonCode];
  2742. const _ref2 = typeof template === "string" ? {
  2743. message: () => template
  2744. } : typeof template === "function" ? {
  2745. message: template
  2746. } : template,
  2747. {
  2748. message
  2749. } = _ref2,
  2750. rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
  2751. const toMessage = typeof message === "string" ? () => message : message;
  2752. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2753. code: "BABEL_PARSER_SYNTAX_ERROR",
  2754. reasonCode,
  2755. toMessage
  2756. }, syntaxPlugin ? {
  2757. syntaxPlugin
  2758. } : {}, rest));
  2759. }
  2760. return ParseErrorConstructors;
  2761. }
  2762. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2763. const {
  2764. defineProperty
  2765. } = Object;
  2766. const toUnenumerable = (object, key) => defineProperty(object, key, {
  2767. enumerable: false,
  2768. value: object[key]
  2769. });
  2770. function toESTreeLocation(node) {
  2771. node.loc.start && toUnenumerable(node.loc.start, "index");
  2772. node.loc.end && toUnenumerable(node.loc.end, "index");
  2773. return node;
  2774. }
  2775. var estree = superClass => class ESTreeParserMixin extends superClass {
  2776. parse() {
  2777. const file = toESTreeLocation(super.parse());
  2778. if (this.options.tokens) {
  2779. file.tokens = file.tokens.map(toESTreeLocation);
  2780. }
  2781. return file;
  2782. }
  2783. parseRegExpLiteral({
  2784. pattern,
  2785. flags
  2786. }) {
  2787. let regex = null;
  2788. try {
  2789. regex = new RegExp(pattern, flags);
  2790. } catch (e) {}
  2791. const node = this.estreeParseLiteral(regex);
  2792. node.regex = {
  2793. pattern,
  2794. flags
  2795. };
  2796. return node;
  2797. }
  2798. parseBigIntLiteral(value) {
  2799. let bigInt;
  2800. try {
  2801. bigInt = BigInt(value);
  2802. } catch (_unused) {
  2803. bigInt = null;
  2804. }
  2805. const node = this.estreeParseLiteral(bigInt);
  2806. node.bigint = String(node.value || value);
  2807. return node;
  2808. }
  2809. parseDecimalLiteral(value) {
  2810. const decimal = null;
  2811. const node = this.estreeParseLiteral(decimal);
  2812. node.decimal = String(node.value || value);
  2813. return node;
  2814. }
  2815. estreeParseLiteral(value) {
  2816. return this.parseLiteral(value, "Literal");
  2817. }
  2818. parseStringLiteral(value) {
  2819. return this.estreeParseLiteral(value);
  2820. }
  2821. parseNumericLiteral(value) {
  2822. return this.estreeParseLiteral(value);
  2823. }
  2824. parseNullLiteral() {
  2825. return this.estreeParseLiteral(null);
  2826. }
  2827. parseBooleanLiteral(value) {
  2828. return this.estreeParseLiteral(value);
  2829. }
  2830. directiveToStmt(directive) {
  2831. const expression = directive.value;
  2832. delete directive.value;
  2833. expression.type = "Literal";
  2834. expression.raw = expression.extra.raw;
  2835. expression.value = expression.extra.expressionValue;
  2836. const stmt = directive;
  2837. stmt.type = "ExpressionStatement";
  2838. stmt.expression = expression;
  2839. stmt.directive = expression.extra.rawValue;
  2840. delete expression.extra;
  2841. return stmt;
  2842. }
  2843. initFunction(node, isAsync) {
  2844. super.initFunction(node, isAsync);
  2845. node.expression = false;
  2846. }
  2847. checkDeclaration(node) {
  2848. if (node != null && this.isObjectProperty(node)) {
  2849. this.checkDeclaration(node.value);
  2850. } else {
  2851. super.checkDeclaration(node);
  2852. }
  2853. }
  2854. getObjectOrClassMethodParams(method) {
  2855. return method.value.params;
  2856. }
  2857. isValidDirective(stmt) {
  2858. var _stmt$expression$extr;
  2859. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  2860. }
  2861. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  2862. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  2863. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  2864. node.body = directiveStatements.concat(node.body);
  2865. delete node.directives;
  2866. }
  2867. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  2868. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  2869. if (method.typeParameters) {
  2870. method.value.typeParameters = method.typeParameters;
  2871. delete method.typeParameters;
  2872. }
  2873. classBody.body.push(method);
  2874. }
  2875. parsePrivateName() {
  2876. const node = super.parsePrivateName();
  2877. {
  2878. if (!this.getPluginOption("estree", "classFeatures")) {
  2879. return node;
  2880. }
  2881. }
  2882. return this.convertPrivateNameToPrivateIdentifier(node);
  2883. }
  2884. convertPrivateNameToPrivateIdentifier(node) {
  2885. const name = super.getPrivateNameSV(node);
  2886. node = node;
  2887. delete node.id;
  2888. node.name = name;
  2889. node.type = "PrivateIdentifier";
  2890. return node;
  2891. }
  2892. isPrivateName(node) {
  2893. {
  2894. if (!this.getPluginOption("estree", "classFeatures")) {
  2895. return super.isPrivateName(node);
  2896. }
  2897. }
  2898. return node.type === "PrivateIdentifier";
  2899. }
  2900. getPrivateNameSV(node) {
  2901. {
  2902. if (!this.getPluginOption("estree", "classFeatures")) {
  2903. return super.getPrivateNameSV(node);
  2904. }
  2905. }
  2906. return node.name;
  2907. }
  2908. parseLiteral(value, type) {
  2909. const node = super.parseLiteral(value, type);
  2910. node.raw = node.extra.raw;
  2911. delete node.extra;
  2912. return node;
  2913. }
  2914. parseFunctionBody(node, allowExpression, isMethod = false) {
  2915. super.parseFunctionBody(node, allowExpression, isMethod);
  2916. node.expression = node.body.type !== "BlockStatement";
  2917. }
  2918. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  2919. let funcNode = this.startNode();
  2920. funcNode.kind = node.kind;
  2921. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  2922. funcNode.type = "FunctionExpression";
  2923. delete funcNode.kind;
  2924. node.value = funcNode;
  2925. if (type === "ClassPrivateMethod") {
  2926. node.computed = false;
  2927. }
  2928. return this.finishNode(node, "MethodDefinition");
  2929. }
  2930. parseClassProperty(...args) {
  2931. const propertyNode = super.parseClassProperty(...args);
  2932. {
  2933. if (!this.getPluginOption("estree", "classFeatures")) {
  2934. return propertyNode;
  2935. }
  2936. }
  2937. propertyNode.type = "PropertyDefinition";
  2938. return propertyNode;
  2939. }
  2940. parseClassPrivateProperty(...args) {
  2941. const propertyNode = super.parseClassPrivateProperty(...args);
  2942. {
  2943. if (!this.getPluginOption("estree", "classFeatures")) {
  2944. return propertyNode;
  2945. }
  2946. }
  2947. propertyNode.type = "PropertyDefinition";
  2948. propertyNode.computed = false;
  2949. return propertyNode;
  2950. }
  2951. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  2952. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  2953. if (node) {
  2954. node.type = "Property";
  2955. if (node.kind === "method") {
  2956. node.kind = "init";
  2957. }
  2958. node.shorthand = false;
  2959. }
  2960. return node;
  2961. }
  2962. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  2963. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  2964. if (node) {
  2965. node.kind = "init";
  2966. node.type = "Property";
  2967. }
  2968. return node;
  2969. }
  2970. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  2971. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  2972. }
  2973. isAssignable(node, isBinding) {
  2974. if (node != null && this.isObjectProperty(node)) {
  2975. return this.isAssignable(node.value, isBinding);
  2976. }
  2977. return super.isAssignable(node, isBinding);
  2978. }
  2979. toAssignable(node, isLHS = false) {
  2980. if (node != null && this.isObjectProperty(node)) {
  2981. const {
  2982. key,
  2983. value
  2984. } = node;
  2985. if (this.isPrivateName(key)) {
  2986. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  2987. }
  2988. this.toAssignable(value, isLHS);
  2989. } else {
  2990. super.toAssignable(node, isLHS);
  2991. }
  2992. }
  2993. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  2994. if (prop.kind === "get" || prop.kind === "set") {
  2995. this.raise(Errors.PatternHasAccessor, prop.key);
  2996. } else if (prop.method) {
  2997. this.raise(Errors.PatternHasMethod, prop.key);
  2998. } else {
  2999. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  3000. }
  3001. }
  3002. finishCallExpression(unfinished, optional) {
  3003. const node = super.finishCallExpression(unfinished, optional);
  3004. if (node.callee.type === "Import") {
  3005. node.type = "ImportExpression";
  3006. node.source = node.arguments[0];
  3007. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  3008. var _node$arguments$, _node$arguments$2;
  3009. node.options = (_node$arguments$ = node.arguments[1]) != null ? _node$arguments$ : null;
  3010. node.attributes = (_node$arguments$2 = node.arguments[1]) != null ? _node$arguments$2 : null;
  3011. }
  3012. delete node.arguments;
  3013. delete node.callee;
  3014. }
  3015. return node;
  3016. }
  3017. toReferencedArguments(node) {
  3018. if (node.type === "ImportExpression") {
  3019. return;
  3020. }
  3021. super.toReferencedArguments(node);
  3022. }
  3023. parseExport(unfinished, decorators) {
  3024. const exportStartLoc = this.state.lastTokStartLoc;
  3025. const node = super.parseExport(unfinished, decorators);
  3026. switch (node.type) {
  3027. case "ExportAllDeclaration":
  3028. node.exported = null;
  3029. break;
  3030. case "ExportNamedDeclaration":
  3031. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3032. node.type = "ExportAllDeclaration";
  3033. node.exported = node.specifiers[0].exported;
  3034. delete node.specifiers;
  3035. }
  3036. case "ExportDefaultDeclaration":
  3037. {
  3038. var _declaration$decorato;
  3039. const {
  3040. declaration
  3041. } = node;
  3042. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3043. this.resetStartLocation(node, exportStartLoc);
  3044. }
  3045. }
  3046. break;
  3047. }
  3048. return node;
  3049. }
  3050. parseSubscript(base, startLoc, noCalls, state) {
  3051. const node = super.parseSubscript(base, startLoc, noCalls, state);
  3052. if (state.optionalChainMember) {
  3053. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  3054. node.type = node.type.substring(8);
  3055. }
  3056. if (state.stop) {
  3057. const chain = this.startNodeAtNode(node);
  3058. chain.expression = node;
  3059. return this.finishNode(chain, "ChainExpression");
  3060. }
  3061. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  3062. node.optional = false;
  3063. }
  3064. return node;
  3065. }
  3066. isOptionalMemberExpression(node) {
  3067. if (node.type === "ChainExpression") {
  3068. return node.expression.type === "MemberExpression";
  3069. }
  3070. return super.isOptionalMemberExpression(node);
  3071. }
  3072. hasPropertyAsPrivateName(node) {
  3073. if (node.type === "ChainExpression") {
  3074. node = node.expression;
  3075. }
  3076. return super.hasPropertyAsPrivateName(node);
  3077. }
  3078. isObjectProperty(node) {
  3079. return node.type === "Property" && node.kind === "init" && !node.method;
  3080. }
  3081. isObjectMethod(node) {
  3082. return node.method || node.kind === "get" || node.kind === "set";
  3083. }
  3084. finishNodeAt(node, type, endLoc) {
  3085. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3086. }
  3087. resetStartLocation(node, startLoc) {
  3088. super.resetStartLocation(node, startLoc);
  3089. toESTreeLocation(node);
  3090. }
  3091. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3092. super.resetEndLocation(node, endLoc);
  3093. toESTreeLocation(node);
  3094. }
  3095. };
  3096. class TokContext {
  3097. constructor(token, preserveSpace) {
  3098. this.token = void 0;
  3099. this.preserveSpace = void 0;
  3100. this.token = token;
  3101. this.preserveSpace = !!preserveSpace;
  3102. }
  3103. }
  3104. const types$1 = {
  3105. brace: new TokContext("{"),
  3106. j_oTag: new TokContext("<tag"),
  3107. j_cTag: new TokContext("</tag"),
  3108. j_expr: new TokContext("<tag>...</tag>", true)
  3109. };
  3110. {
  3111. types$1.template = new TokContext("`", true);
  3112. }
  3113. const beforeExpr = true;
  3114. const startsExpr = true;
  3115. const isLoop = true;
  3116. const isAssign = true;
  3117. const prefix = true;
  3118. const postfix = true;
  3119. class ExportedTokenType {
  3120. constructor(label, conf = {}) {
  3121. this.label = void 0;
  3122. this.keyword = void 0;
  3123. this.beforeExpr = void 0;
  3124. this.startsExpr = void 0;
  3125. this.rightAssociative = void 0;
  3126. this.isLoop = void 0;
  3127. this.isAssign = void 0;
  3128. this.prefix = void 0;
  3129. this.postfix = void 0;
  3130. this.binop = void 0;
  3131. this.label = label;
  3132. this.keyword = conf.keyword;
  3133. this.beforeExpr = !!conf.beforeExpr;
  3134. this.startsExpr = !!conf.startsExpr;
  3135. this.rightAssociative = !!conf.rightAssociative;
  3136. this.isLoop = !!conf.isLoop;
  3137. this.isAssign = !!conf.isAssign;
  3138. this.prefix = !!conf.prefix;
  3139. this.postfix = !!conf.postfix;
  3140. this.binop = conf.binop != null ? conf.binop : null;
  3141. {
  3142. this.updateContext = null;
  3143. }
  3144. }
  3145. }
  3146. const keywords$1 = new Map();
  3147. function createKeyword(name, options = {}) {
  3148. options.keyword = name;
  3149. const token = createToken(name, options);
  3150. keywords$1.set(name, token);
  3151. return token;
  3152. }
  3153. function createBinop(name, binop) {
  3154. return createToken(name, {
  3155. beforeExpr,
  3156. binop
  3157. });
  3158. }
  3159. let tokenTypeCounter = -1;
  3160. const tokenTypes$1 = [];
  3161. const tokenLabels = [];
  3162. const tokenBinops = [];
  3163. const tokenBeforeExprs = [];
  3164. const tokenStartsExprs = [];
  3165. const tokenPrefixes = [];
  3166. function createToken(name, options = {}) {
  3167. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3168. ++tokenTypeCounter;
  3169. tokenLabels.push(name);
  3170. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3171. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3172. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3173. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3174. tokenTypes$1.push(new ExportedTokenType(name, options));
  3175. return tokenTypeCounter;
  3176. }
  3177. function createKeywordLike(name, options = {}) {
  3178. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3179. ++tokenTypeCounter;
  3180. keywords$1.set(name, tokenTypeCounter);
  3181. tokenLabels.push(name);
  3182. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3183. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3184. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3185. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3186. tokenTypes$1.push(new ExportedTokenType("name", options));
  3187. return tokenTypeCounter;
  3188. }
  3189. const tt = {
  3190. bracketL: createToken("[", {
  3191. beforeExpr,
  3192. startsExpr
  3193. }),
  3194. bracketHashL: createToken("#[", {
  3195. beforeExpr,
  3196. startsExpr
  3197. }),
  3198. bracketBarL: createToken("[|", {
  3199. beforeExpr,
  3200. startsExpr
  3201. }),
  3202. bracketR: createToken("]"),
  3203. bracketBarR: createToken("|]"),
  3204. braceL: createToken("{", {
  3205. beforeExpr,
  3206. startsExpr
  3207. }),
  3208. braceBarL: createToken("{|", {
  3209. beforeExpr,
  3210. startsExpr
  3211. }),
  3212. braceHashL: createToken("#{", {
  3213. beforeExpr,
  3214. startsExpr
  3215. }),
  3216. braceR: createToken("}"),
  3217. braceBarR: createToken("|}"),
  3218. parenL: createToken("(", {
  3219. beforeExpr,
  3220. startsExpr
  3221. }),
  3222. parenR: createToken(")"),
  3223. comma: createToken(",", {
  3224. beforeExpr
  3225. }),
  3226. semi: createToken(";", {
  3227. beforeExpr
  3228. }),
  3229. colon: createToken(":", {
  3230. beforeExpr
  3231. }),
  3232. doubleColon: createToken("::", {
  3233. beforeExpr
  3234. }),
  3235. dot: createToken("."),
  3236. question: createToken("?", {
  3237. beforeExpr
  3238. }),
  3239. questionDot: createToken("?."),
  3240. arrow: createToken("=>", {
  3241. beforeExpr
  3242. }),
  3243. template: createToken("template"),
  3244. ellipsis: createToken("...", {
  3245. beforeExpr
  3246. }),
  3247. backQuote: createToken("`", {
  3248. startsExpr
  3249. }),
  3250. dollarBraceL: createToken("${", {
  3251. beforeExpr,
  3252. startsExpr
  3253. }),
  3254. templateTail: createToken("...`", {
  3255. startsExpr
  3256. }),
  3257. templateNonTail: createToken("...${", {
  3258. beforeExpr,
  3259. startsExpr
  3260. }),
  3261. at: createToken("@"),
  3262. hash: createToken("#", {
  3263. startsExpr
  3264. }),
  3265. interpreterDirective: createToken("#!..."),
  3266. eq: createToken("=", {
  3267. beforeExpr,
  3268. isAssign
  3269. }),
  3270. assign: createToken("_=", {
  3271. beforeExpr,
  3272. isAssign
  3273. }),
  3274. slashAssign: createToken("_=", {
  3275. beforeExpr,
  3276. isAssign
  3277. }),
  3278. xorAssign: createToken("_=", {
  3279. beforeExpr,
  3280. isAssign
  3281. }),
  3282. moduloAssign: createToken("_=", {
  3283. beforeExpr,
  3284. isAssign
  3285. }),
  3286. incDec: createToken("++/--", {
  3287. prefix,
  3288. postfix,
  3289. startsExpr
  3290. }),
  3291. bang: createToken("!", {
  3292. beforeExpr,
  3293. prefix,
  3294. startsExpr
  3295. }),
  3296. tilde: createToken("~", {
  3297. beforeExpr,
  3298. prefix,
  3299. startsExpr
  3300. }),
  3301. doubleCaret: createToken("^^", {
  3302. startsExpr
  3303. }),
  3304. doubleAt: createToken("@@", {
  3305. startsExpr
  3306. }),
  3307. pipeline: createBinop("|>", 0),
  3308. nullishCoalescing: createBinop("??", 1),
  3309. logicalOR: createBinop("||", 1),
  3310. logicalAND: createBinop("&&", 2),
  3311. bitwiseOR: createBinop("|", 3),
  3312. bitwiseXOR: createBinop("^", 4),
  3313. bitwiseAND: createBinop("&", 5),
  3314. equality: createBinop("==/!=/===/!==", 6),
  3315. lt: createBinop("</>/<=/>=", 7),
  3316. gt: createBinop("</>/<=/>=", 7),
  3317. relational: createBinop("</>/<=/>=", 7),
  3318. bitShift: createBinop("<</>>/>>>", 8),
  3319. bitShiftL: createBinop("<</>>/>>>", 8),
  3320. bitShiftR: createBinop("<</>>/>>>", 8),
  3321. plusMin: createToken("+/-", {
  3322. beforeExpr,
  3323. binop: 9,
  3324. prefix,
  3325. startsExpr
  3326. }),
  3327. modulo: createToken("%", {
  3328. binop: 10,
  3329. startsExpr
  3330. }),
  3331. star: createToken("*", {
  3332. binop: 10
  3333. }),
  3334. slash: createBinop("/", 10),
  3335. exponent: createToken("**", {
  3336. beforeExpr,
  3337. binop: 11,
  3338. rightAssociative: true
  3339. }),
  3340. _in: createKeyword("in", {
  3341. beforeExpr,
  3342. binop: 7
  3343. }),
  3344. _instanceof: createKeyword("instanceof", {
  3345. beforeExpr,
  3346. binop: 7
  3347. }),
  3348. _break: createKeyword("break"),
  3349. _case: createKeyword("case", {
  3350. beforeExpr
  3351. }),
  3352. _catch: createKeyword("catch"),
  3353. _continue: createKeyword("continue"),
  3354. _debugger: createKeyword("debugger"),
  3355. _default: createKeyword("default", {
  3356. beforeExpr
  3357. }),
  3358. _else: createKeyword("else", {
  3359. beforeExpr
  3360. }),
  3361. _finally: createKeyword("finally"),
  3362. _function: createKeyword("function", {
  3363. startsExpr
  3364. }),
  3365. _if: createKeyword("if"),
  3366. _return: createKeyword("return", {
  3367. beforeExpr
  3368. }),
  3369. _switch: createKeyword("switch"),
  3370. _throw: createKeyword("throw", {
  3371. beforeExpr,
  3372. prefix,
  3373. startsExpr
  3374. }),
  3375. _try: createKeyword("try"),
  3376. _var: createKeyword("var"),
  3377. _const: createKeyword("const"),
  3378. _with: createKeyword("with"),
  3379. _new: createKeyword("new", {
  3380. beforeExpr,
  3381. startsExpr
  3382. }),
  3383. _this: createKeyword("this", {
  3384. startsExpr
  3385. }),
  3386. _super: createKeyword("super", {
  3387. startsExpr
  3388. }),
  3389. _class: createKeyword("class", {
  3390. startsExpr
  3391. }),
  3392. _extends: createKeyword("extends", {
  3393. beforeExpr
  3394. }),
  3395. _export: createKeyword("export"),
  3396. _import: createKeyword("import", {
  3397. startsExpr
  3398. }),
  3399. _null: createKeyword("null", {
  3400. startsExpr
  3401. }),
  3402. _true: createKeyword("true", {
  3403. startsExpr
  3404. }),
  3405. _false: createKeyword("false", {
  3406. startsExpr
  3407. }),
  3408. _typeof: createKeyword("typeof", {
  3409. beforeExpr,
  3410. prefix,
  3411. startsExpr
  3412. }),
  3413. _void: createKeyword("void", {
  3414. beforeExpr,
  3415. prefix,
  3416. startsExpr
  3417. }),
  3418. _delete: createKeyword("delete", {
  3419. beforeExpr,
  3420. prefix,
  3421. startsExpr
  3422. }),
  3423. _do: createKeyword("do", {
  3424. isLoop,
  3425. beforeExpr
  3426. }),
  3427. _for: createKeyword("for", {
  3428. isLoop
  3429. }),
  3430. _while: createKeyword("while", {
  3431. isLoop
  3432. }),
  3433. _as: createKeywordLike("as", {
  3434. startsExpr
  3435. }),
  3436. _assert: createKeywordLike("assert", {
  3437. startsExpr
  3438. }),
  3439. _async: createKeywordLike("async", {
  3440. startsExpr
  3441. }),
  3442. _await: createKeywordLike("await", {
  3443. startsExpr
  3444. }),
  3445. _defer: createKeywordLike("defer", {
  3446. startsExpr
  3447. }),
  3448. _from: createKeywordLike("from", {
  3449. startsExpr
  3450. }),
  3451. _get: createKeywordLike("get", {
  3452. startsExpr
  3453. }),
  3454. _let: createKeywordLike("let", {
  3455. startsExpr
  3456. }),
  3457. _meta: createKeywordLike("meta", {
  3458. startsExpr
  3459. }),
  3460. _of: createKeywordLike("of", {
  3461. startsExpr
  3462. }),
  3463. _sent: createKeywordLike("sent", {
  3464. startsExpr
  3465. }),
  3466. _set: createKeywordLike("set", {
  3467. startsExpr
  3468. }),
  3469. _source: createKeywordLike("source", {
  3470. startsExpr
  3471. }),
  3472. _static: createKeywordLike("static", {
  3473. startsExpr
  3474. }),
  3475. _using: createKeywordLike("using", {
  3476. startsExpr
  3477. }),
  3478. _yield: createKeywordLike("yield", {
  3479. startsExpr
  3480. }),
  3481. _asserts: createKeywordLike("asserts", {
  3482. startsExpr
  3483. }),
  3484. _checks: createKeywordLike("checks", {
  3485. startsExpr
  3486. }),
  3487. _exports: createKeywordLike("exports", {
  3488. startsExpr
  3489. }),
  3490. _global: createKeywordLike("global", {
  3491. startsExpr
  3492. }),
  3493. _implements: createKeywordLike("implements", {
  3494. startsExpr
  3495. }),
  3496. _intrinsic: createKeywordLike("intrinsic", {
  3497. startsExpr
  3498. }),
  3499. _infer: createKeywordLike("infer", {
  3500. startsExpr
  3501. }),
  3502. _is: createKeywordLike("is", {
  3503. startsExpr
  3504. }),
  3505. _mixins: createKeywordLike("mixins", {
  3506. startsExpr
  3507. }),
  3508. _proto: createKeywordLike("proto", {
  3509. startsExpr
  3510. }),
  3511. _require: createKeywordLike("require", {
  3512. startsExpr
  3513. }),
  3514. _satisfies: createKeywordLike("satisfies", {
  3515. startsExpr
  3516. }),
  3517. _keyof: createKeywordLike("keyof", {
  3518. startsExpr
  3519. }),
  3520. _readonly: createKeywordLike("readonly", {
  3521. startsExpr
  3522. }),
  3523. _unique: createKeywordLike("unique", {
  3524. startsExpr
  3525. }),
  3526. _abstract: createKeywordLike("abstract", {
  3527. startsExpr
  3528. }),
  3529. _declare: createKeywordLike("declare", {
  3530. startsExpr
  3531. }),
  3532. _enum: createKeywordLike("enum", {
  3533. startsExpr
  3534. }),
  3535. _module: createKeywordLike("module", {
  3536. startsExpr
  3537. }),
  3538. _namespace: createKeywordLike("namespace", {
  3539. startsExpr
  3540. }),
  3541. _interface: createKeywordLike("interface", {
  3542. startsExpr
  3543. }),
  3544. _type: createKeywordLike("type", {
  3545. startsExpr
  3546. }),
  3547. _opaque: createKeywordLike("opaque", {
  3548. startsExpr
  3549. }),
  3550. name: createToken("name", {
  3551. startsExpr
  3552. }),
  3553. string: createToken("string", {
  3554. startsExpr
  3555. }),
  3556. num: createToken("num", {
  3557. startsExpr
  3558. }),
  3559. bigint: createToken("bigint", {
  3560. startsExpr
  3561. }),
  3562. decimal: createToken("decimal", {
  3563. startsExpr
  3564. }),
  3565. regexp: createToken("regexp", {
  3566. startsExpr
  3567. }),
  3568. privateName: createToken("#name", {
  3569. startsExpr
  3570. }),
  3571. eof: createToken("eof"),
  3572. jsxName: createToken("jsxName"),
  3573. jsxText: createToken("jsxText", {
  3574. beforeExpr: true
  3575. }),
  3576. jsxTagStart: createToken("jsxTagStart", {
  3577. startsExpr: true
  3578. }),
  3579. jsxTagEnd: createToken("jsxTagEnd"),
  3580. placeholder: createToken("%%", {
  3581. startsExpr: true
  3582. })
  3583. };
  3584. function tokenIsIdentifier(token) {
  3585. return token >= 93 && token <= 132;
  3586. }
  3587. function tokenKeywordOrIdentifierIsKeyword(token) {
  3588. return token <= 92;
  3589. }
  3590. function tokenIsKeywordOrIdentifier(token) {
  3591. return token >= 58 && token <= 132;
  3592. }
  3593. function tokenIsLiteralPropertyName(token) {
  3594. return token >= 58 && token <= 136;
  3595. }
  3596. function tokenComesBeforeExpression(token) {
  3597. return tokenBeforeExprs[token];
  3598. }
  3599. function tokenCanStartExpression(token) {
  3600. return tokenStartsExprs[token];
  3601. }
  3602. function tokenIsAssignment(token) {
  3603. return token >= 29 && token <= 33;
  3604. }
  3605. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3606. return token >= 129 && token <= 131;
  3607. }
  3608. function tokenIsLoop(token) {
  3609. return token >= 90 && token <= 92;
  3610. }
  3611. function tokenIsKeyword(token) {
  3612. return token >= 58 && token <= 92;
  3613. }
  3614. function tokenIsOperator(token) {
  3615. return token >= 39 && token <= 59;
  3616. }
  3617. function tokenIsPostfix(token) {
  3618. return token === 34;
  3619. }
  3620. function tokenIsPrefix(token) {
  3621. return tokenPrefixes[token];
  3622. }
  3623. function tokenIsTSTypeOperator(token) {
  3624. return token >= 121 && token <= 123;
  3625. }
  3626. function tokenIsTSDeclarationStart(token) {
  3627. return token >= 124 && token <= 130;
  3628. }
  3629. function tokenLabelName(token) {
  3630. return tokenLabels[token];
  3631. }
  3632. function tokenOperatorPrecedence(token) {
  3633. return tokenBinops[token];
  3634. }
  3635. function tokenIsRightAssociative(token) {
  3636. return token === 57;
  3637. }
  3638. function tokenIsTemplate(token) {
  3639. return token >= 24 && token <= 25;
  3640. }
  3641. function getExportedToken(token) {
  3642. return tokenTypes$1[token];
  3643. }
  3644. {
  3645. tokenTypes$1[8].updateContext = context => {
  3646. context.pop();
  3647. };
  3648. tokenTypes$1[5].updateContext = tokenTypes$1[7].updateContext = tokenTypes$1[23].updateContext = context => {
  3649. context.push(types$1.brace);
  3650. };
  3651. tokenTypes$1[22].updateContext = context => {
  3652. if (context[context.length - 1] === types$1.template) {
  3653. context.pop();
  3654. } else {
  3655. context.push(types$1.template);
  3656. }
  3657. };
  3658. tokenTypes$1[142].updateContext = context => {
  3659. context.push(types$1.j_expr, types$1.j_oTag);
  3660. };
  3661. }
  3662. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  3663. let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
  3664. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3665. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3666. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3667. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
  3668. const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  3669. function isInAstralSet(code, set) {
  3670. let pos = 0x10000;
  3671. for (let i = 0, length = set.length; i < length; i += 2) {
  3672. pos += set[i];
  3673. if (pos > code) return false;
  3674. pos += set[i + 1];
  3675. if (pos >= code) return true;
  3676. }
  3677. return false;
  3678. }
  3679. function isIdentifierStart(code) {
  3680. if (code < 65) return code === 36;
  3681. if (code <= 90) return true;
  3682. if (code < 97) return code === 95;
  3683. if (code <= 122) return true;
  3684. if (code <= 0xffff) {
  3685. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3686. }
  3687. return isInAstralSet(code, astralIdentifierStartCodes);
  3688. }
  3689. function isIdentifierChar(code) {
  3690. if (code < 48) return code === 36;
  3691. if (code < 58) return true;
  3692. if (code < 65) return false;
  3693. if (code <= 90) return true;
  3694. if (code < 97) return code === 95;
  3695. if (code <= 122) return true;
  3696. if (code <= 0xffff) {
  3697. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3698. }
  3699. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3700. }
  3701. const reservedWords = {
  3702. keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
  3703. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3704. strictBind: ["eval", "arguments"]
  3705. };
  3706. const keywords = new Set(reservedWords.keyword);
  3707. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3708. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3709. function isReservedWord(word, inModule) {
  3710. return inModule && word === "await" || word === "enum";
  3711. }
  3712. function isStrictReservedWord(word, inModule) {
  3713. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3714. }
  3715. function isStrictBindOnlyReservedWord(word) {
  3716. return reservedWordsStrictBindSet.has(word);
  3717. }
  3718. function isStrictBindReservedWord(word, inModule) {
  3719. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3720. }
  3721. function isKeyword(word) {
  3722. return keywords.has(word);
  3723. }
  3724. function isIteratorStart(current, next, next2) {
  3725. return current === 64 && next === 64 && isIdentifierStart(next2);
  3726. }
  3727. const reservedWordLikeSet = new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "eval", "arguments", "enum", "await"]);
  3728. function canBeReservedWord(word) {
  3729. return reservedWordLikeSet.has(word);
  3730. }
  3731. class Scope {
  3732. constructor(flags) {
  3733. this.flags = 0;
  3734. this.names = new Map();
  3735. this.firstLexicalName = "";
  3736. this.flags = flags;
  3737. }
  3738. }
  3739. class ScopeHandler {
  3740. constructor(parser, inModule) {
  3741. this.parser = void 0;
  3742. this.scopeStack = [];
  3743. this.inModule = void 0;
  3744. this.undefinedExports = new Map();
  3745. this.parser = parser;
  3746. this.inModule = inModule;
  3747. }
  3748. get inTopLevel() {
  3749. return (this.currentScope().flags & 1) > 0;
  3750. }
  3751. get inFunction() {
  3752. return (this.currentVarScopeFlags() & 2) > 0;
  3753. }
  3754. get allowSuper() {
  3755. return (this.currentThisScopeFlags() & 16) > 0;
  3756. }
  3757. get allowDirectSuper() {
  3758. return (this.currentThisScopeFlags() & 32) > 0;
  3759. }
  3760. get inClass() {
  3761. return (this.currentThisScopeFlags() & 64) > 0;
  3762. }
  3763. get inClassAndNotInNonArrowFunction() {
  3764. const flags = this.currentThisScopeFlags();
  3765. return (flags & 64) > 0 && (flags & 2) === 0;
  3766. }
  3767. get inStaticBlock() {
  3768. for (let i = this.scopeStack.length - 1;; i--) {
  3769. const {
  3770. flags
  3771. } = this.scopeStack[i];
  3772. if (flags & 128) {
  3773. return true;
  3774. }
  3775. if (flags & (387 | 64)) {
  3776. return false;
  3777. }
  3778. }
  3779. }
  3780. get inNonArrowFunction() {
  3781. return (this.currentThisScopeFlags() & 2) > 0;
  3782. }
  3783. get treatFunctionsAsVar() {
  3784. return this.treatFunctionsAsVarInScope(this.currentScope());
  3785. }
  3786. createScope(flags) {
  3787. return new Scope(flags);
  3788. }
  3789. enter(flags) {
  3790. this.scopeStack.push(this.createScope(flags));
  3791. }
  3792. exit() {
  3793. const scope = this.scopeStack.pop();
  3794. return scope.flags;
  3795. }
  3796. treatFunctionsAsVarInScope(scope) {
  3797. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  3798. }
  3799. declareName(name, bindingType, loc) {
  3800. let scope = this.currentScope();
  3801. if (bindingType & 8 || bindingType & 16) {
  3802. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3803. let type = scope.names.get(name) || 0;
  3804. if (bindingType & 16) {
  3805. type = type | 4;
  3806. } else {
  3807. if (!scope.firstLexicalName) {
  3808. scope.firstLexicalName = name;
  3809. }
  3810. type = type | 2;
  3811. }
  3812. scope.names.set(name, type);
  3813. if (bindingType & 8) {
  3814. this.maybeExportDefined(scope, name);
  3815. }
  3816. } else if (bindingType & 4) {
  3817. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  3818. scope = this.scopeStack[i];
  3819. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3820. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  3821. this.maybeExportDefined(scope, name);
  3822. if (scope.flags & 387) break;
  3823. }
  3824. }
  3825. if (this.parser.inModule && scope.flags & 1) {
  3826. this.undefinedExports.delete(name);
  3827. }
  3828. }
  3829. maybeExportDefined(scope, name) {
  3830. if (this.parser.inModule && scope.flags & 1) {
  3831. this.undefinedExports.delete(name);
  3832. }
  3833. }
  3834. checkRedeclarationInScope(scope, name, bindingType, loc) {
  3835. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  3836. this.parser.raise(Errors.VarRedeclaration, loc, {
  3837. identifierName: name
  3838. });
  3839. }
  3840. }
  3841. isRedeclaredInScope(scope, name, bindingType) {
  3842. if (!(bindingType & 1)) return false;
  3843. if (bindingType & 8) {
  3844. return scope.names.has(name);
  3845. }
  3846. const type = scope.names.get(name);
  3847. if (bindingType & 16) {
  3848. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  3849. }
  3850. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  3851. }
  3852. checkLocalExport(id) {
  3853. const {
  3854. name
  3855. } = id;
  3856. const topLevelScope = this.scopeStack[0];
  3857. if (!topLevelScope.names.has(name)) {
  3858. this.undefinedExports.set(name, id.loc.start);
  3859. }
  3860. }
  3861. currentScope() {
  3862. return this.scopeStack[this.scopeStack.length - 1];
  3863. }
  3864. currentVarScopeFlags() {
  3865. for (let i = this.scopeStack.length - 1;; i--) {
  3866. const {
  3867. flags
  3868. } = this.scopeStack[i];
  3869. if (flags & 387) {
  3870. return flags;
  3871. }
  3872. }
  3873. }
  3874. currentThisScopeFlags() {
  3875. for (let i = this.scopeStack.length - 1;; i--) {
  3876. const {
  3877. flags
  3878. } = this.scopeStack[i];
  3879. if (flags & (387 | 64) && !(flags & 4)) {
  3880. return flags;
  3881. }
  3882. }
  3883. }
  3884. }
  3885. class FlowScope extends Scope {
  3886. constructor(...args) {
  3887. super(...args);
  3888. this.declareFunctions = new Set();
  3889. }
  3890. }
  3891. class FlowScopeHandler extends ScopeHandler {
  3892. createScope(flags) {
  3893. return new FlowScope(flags);
  3894. }
  3895. declareName(name, bindingType, loc) {
  3896. const scope = this.currentScope();
  3897. if (bindingType & 2048) {
  3898. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3899. this.maybeExportDefined(scope, name);
  3900. scope.declareFunctions.add(name);
  3901. return;
  3902. }
  3903. super.declareName(name, bindingType, loc);
  3904. }
  3905. isRedeclaredInScope(scope, name, bindingType) {
  3906. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  3907. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  3908. const type = scope.names.get(name);
  3909. return (type & 4) > 0 || (type & 2) > 0;
  3910. }
  3911. return false;
  3912. }
  3913. checkLocalExport(id) {
  3914. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  3915. super.checkLocalExport(id);
  3916. }
  3917. }
  3918. }
  3919. class BaseParser {
  3920. constructor() {
  3921. this.sawUnambiguousESM = false;
  3922. this.ambiguousScriptDifferentAst = false;
  3923. }
  3924. hasPlugin(pluginConfig) {
  3925. if (typeof pluginConfig === "string") {
  3926. return this.plugins.has(pluginConfig);
  3927. } else {
  3928. const [pluginName, pluginOptions] = pluginConfig;
  3929. if (!this.hasPlugin(pluginName)) {
  3930. return false;
  3931. }
  3932. const actualOptions = this.plugins.get(pluginName);
  3933. for (const key of Object.keys(pluginOptions)) {
  3934. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  3935. return false;
  3936. }
  3937. }
  3938. return true;
  3939. }
  3940. }
  3941. getPluginOption(plugin, name) {
  3942. var _this$plugins$get;
  3943. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  3944. }
  3945. }
  3946. function setTrailingComments(node, comments) {
  3947. if (node.trailingComments === undefined) {
  3948. node.trailingComments = comments;
  3949. } else {
  3950. node.trailingComments.unshift(...comments);
  3951. }
  3952. }
  3953. function setLeadingComments(node, comments) {
  3954. if (node.leadingComments === undefined) {
  3955. node.leadingComments = comments;
  3956. } else {
  3957. node.leadingComments.unshift(...comments);
  3958. }
  3959. }
  3960. function setInnerComments(node, comments) {
  3961. if (node.innerComments === undefined) {
  3962. node.innerComments = comments;
  3963. } else {
  3964. node.innerComments.unshift(...comments);
  3965. }
  3966. }
  3967. function adjustInnerComments(node, elements, commentWS) {
  3968. let lastElement = null;
  3969. let i = elements.length;
  3970. while (lastElement === null && i > 0) {
  3971. lastElement = elements[--i];
  3972. }
  3973. if (lastElement === null || lastElement.start > commentWS.start) {
  3974. setInnerComments(node, commentWS.comments);
  3975. } else {
  3976. setTrailingComments(lastElement, commentWS.comments);
  3977. }
  3978. }
  3979. class CommentsParser extends BaseParser {
  3980. addComment(comment) {
  3981. if (this.filename) comment.loc.filename = this.filename;
  3982. const {
  3983. commentsLen
  3984. } = this.state;
  3985. if (this.comments.length != commentsLen) this.comments.length = commentsLen;
  3986. this.comments.push(comment);
  3987. this.state.commentsLen++;
  3988. }
  3989. processComment(node) {
  3990. const {
  3991. commentStack
  3992. } = this.state;
  3993. const commentStackLength = commentStack.length;
  3994. if (commentStackLength === 0) return;
  3995. let i = commentStackLength - 1;
  3996. const lastCommentWS = commentStack[i];
  3997. if (lastCommentWS.start === node.end) {
  3998. lastCommentWS.leadingNode = node;
  3999. i--;
  4000. }
  4001. const {
  4002. start: nodeStart
  4003. } = node;
  4004. for (; i >= 0; i--) {
  4005. const commentWS = commentStack[i];
  4006. const commentEnd = commentWS.end;
  4007. if (commentEnd > nodeStart) {
  4008. commentWS.containingNode = node;
  4009. this.finalizeComment(commentWS);
  4010. commentStack.splice(i, 1);
  4011. } else {
  4012. if (commentEnd === nodeStart) {
  4013. commentWS.trailingNode = node;
  4014. }
  4015. break;
  4016. }
  4017. }
  4018. }
  4019. finalizeComment(commentWS) {
  4020. const {
  4021. comments
  4022. } = commentWS;
  4023. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  4024. if (commentWS.leadingNode !== null) {
  4025. setTrailingComments(commentWS.leadingNode, comments);
  4026. }
  4027. if (commentWS.trailingNode !== null) {
  4028. setLeadingComments(commentWS.trailingNode, comments);
  4029. }
  4030. } else {
  4031. const {
  4032. containingNode: node,
  4033. start: commentStart
  4034. } = commentWS;
  4035. if (this.input.charCodeAt(commentStart - 1) === 44) {
  4036. switch (node.type) {
  4037. case "ObjectExpression":
  4038. case "ObjectPattern":
  4039. case "RecordExpression":
  4040. adjustInnerComments(node, node.properties, commentWS);
  4041. break;
  4042. case "CallExpression":
  4043. case "OptionalCallExpression":
  4044. adjustInnerComments(node, node.arguments, commentWS);
  4045. break;
  4046. case "FunctionDeclaration":
  4047. case "FunctionExpression":
  4048. case "ArrowFunctionExpression":
  4049. case "ObjectMethod":
  4050. case "ClassMethod":
  4051. case "ClassPrivateMethod":
  4052. adjustInnerComments(node, node.params, commentWS);
  4053. break;
  4054. case "ArrayExpression":
  4055. case "ArrayPattern":
  4056. case "TupleExpression":
  4057. adjustInnerComments(node, node.elements, commentWS);
  4058. break;
  4059. case "ExportNamedDeclaration":
  4060. case "ImportDeclaration":
  4061. adjustInnerComments(node, node.specifiers, commentWS);
  4062. break;
  4063. default:
  4064. {
  4065. setInnerComments(node, comments);
  4066. }
  4067. }
  4068. } else {
  4069. setInnerComments(node, comments);
  4070. }
  4071. }
  4072. }
  4073. finalizeRemainingComments() {
  4074. const {
  4075. commentStack
  4076. } = this.state;
  4077. for (let i = commentStack.length - 1; i >= 0; i--) {
  4078. this.finalizeComment(commentStack[i]);
  4079. }
  4080. this.state.commentStack = [];
  4081. }
  4082. resetPreviousNodeTrailingComments(node) {
  4083. const {
  4084. commentStack
  4085. } = this.state;
  4086. const {
  4087. length
  4088. } = commentStack;
  4089. if (length === 0) return;
  4090. const commentWS = commentStack[length - 1];
  4091. if (commentWS.leadingNode === node) {
  4092. commentWS.leadingNode = null;
  4093. }
  4094. }
  4095. resetPreviousIdentifierLeadingComments(node) {
  4096. const {
  4097. commentStack
  4098. } = this.state;
  4099. const {
  4100. length
  4101. } = commentStack;
  4102. if (length === 0) return;
  4103. if (commentStack[length - 1].trailingNode === node) {
  4104. commentStack[length - 1].trailingNode = null;
  4105. } else if (length >= 2 && commentStack[length - 2].trailingNode === node) {
  4106. commentStack[length - 2].trailingNode = null;
  4107. }
  4108. }
  4109. takeSurroundingComments(node, start, end) {
  4110. const {
  4111. commentStack
  4112. } = this.state;
  4113. const commentStackLength = commentStack.length;
  4114. if (commentStackLength === 0) return;
  4115. let i = commentStackLength - 1;
  4116. for (; i >= 0; i--) {
  4117. const commentWS = commentStack[i];
  4118. const commentEnd = commentWS.end;
  4119. const commentStart = commentWS.start;
  4120. if (commentStart === end) {
  4121. commentWS.leadingNode = node;
  4122. } else if (commentEnd === start) {
  4123. commentWS.trailingNode = node;
  4124. } else if (commentEnd < start) {
  4125. break;
  4126. }
  4127. }
  4128. }
  4129. }
  4130. const lineBreak = /\r\n?|[\n\u2028\u2029]/;
  4131. const lineBreakG = new RegExp(lineBreak.source, "g");
  4132. function isNewLine(code) {
  4133. switch (code) {
  4134. case 10:
  4135. case 13:
  4136. case 8232:
  4137. case 8233:
  4138. return true;
  4139. default:
  4140. return false;
  4141. }
  4142. }
  4143. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  4144. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  4145. const skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
  4146. function isWhitespace(code) {
  4147. switch (code) {
  4148. case 0x0009:
  4149. case 0x000b:
  4150. case 0x000c:
  4151. case 32:
  4152. case 160:
  4153. case 5760:
  4154. case 0x2000:
  4155. case 0x2001:
  4156. case 0x2002:
  4157. case 0x2003:
  4158. case 0x2004:
  4159. case 0x2005:
  4160. case 0x2006:
  4161. case 0x2007:
  4162. case 0x2008:
  4163. case 0x2009:
  4164. case 0x200a:
  4165. case 0x202f:
  4166. case 0x205f:
  4167. case 0x3000:
  4168. case 0xfeff:
  4169. return true;
  4170. default:
  4171. return false;
  4172. }
  4173. }
  4174. class State {
  4175. constructor() {
  4176. this.flags = 1024;
  4177. this.curLine = void 0;
  4178. this.lineStart = void 0;
  4179. this.startLoc = void 0;
  4180. this.endLoc = void 0;
  4181. this.errors = [];
  4182. this.potentialArrowAt = -1;
  4183. this.noArrowAt = [];
  4184. this.noArrowParamsConversionAt = [];
  4185. this.topicContext = {
  4186. maxNumOfResolvableTopics: 0,
  4187. maxTopicIndex: null
  4188. };
  4189. this.labels = [];
  4190. this.commentsLen = 0;
  4191. this.commentStack = [];
  4192. this.pos = 0;
  4193. this.type = 139;
  4194. this.value = null;
  4195. this.start = 0;
  4196. this.end = 0;
  4197. this.lastTokEndLoc = null;
  4198. this.lastTokStartLoc = null;
  4199. this.context = [types$1.brace];
  4200. this.firstInvalidTemplateEscapePos = null;
  4201. this.strictErrors = new Map();
  4202. this.tokensLength = 0;
  4203. }
  4204. get strict() {
  4205. return (this.flags & 1) > 0;
  4206. }
  4207. set strict(value) {
  4208. if (value) {
  4209. this.flags |= 1;
  4210. } else {
  4211. this.flags &= ~1;
  4212. }
  4213. }
  4214. init({
  4215. strictMode,
  4216. sourceType,
  4217. startLine,
  4218. startColumn
  4219. }) {
  4220. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  4221. this.curLine = startLine;
  4222. this.lineStart = -startColumn;
  4223. this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
  4224. }
  4225. get maybeInArrowParameters() {
  4226. return (this.flags & 2) > 0;
  4227. }
  4228. set maybeInArrowParameters(value) {
  4229. if (value) {
  4230. this.flags |= 2;
  4231. } else {
  4232. this.flags &= ~2;
  4233. }
  4234. }
  4235. get inType() {
  4236. return (this.flags & 4) > 0;
  4237. }
  4238. set inType(value) {
  4239. if (value) {
  4240. this.flags |= 4;
  4241. } else {
  4242. this.flags &= ~4;
  4243. }
  4244. }
  4245. get noAnonFunctionType() {
  4246. return (this.flags & 8) > 0;
  4247. }
  4248. set noAnonFunctionType(value) {
  4249. if (value) {
  4250. this.flags |= 8;
  4251. } else {
  4252. this.flags &= ~8;
  4253. }
  4254. }
  4255. get hasFlowComment() {
  4256. return (this.flags & 16) > 0;
  4257. }
  4258. set hasFlowComment(value) {
  4259. if (value) {
  4260. this.flags |= 16;
  4261. } else {
  4262. this.flags &= ~16;
  4263. }
  4264. }
  4265. get isAmbientContext() {
  4266. return (this.flags & 32) > 0;
  4267. }
  4268. set isAmbientContext(value) {
  4269. if (value) {
  4270. this.flags |= 32;
  4271. } else {
  4272. this.flags &= ~32;
  4273. }
  4274. }
  4275. get inAbstractClass() {
  4276. return (this.flags & 64) > 0;
  4277. }
  4278. set inAbstractClass(value) {
  4279. if (value) {
  4280. this.flags |= 64;
  4281. } else {
  4282. this.flags &= ~64;
  4283. }
  4284. }
  4285. get inDisallowConditionalTypesContext() {
  4286. return (this.flags & 128) > 0;
  4287. }
  4288. set inDisallowConditionalTypesContext(value) {
  4289. if (value) {
  4290. this.flags |= 128;
  4291. } else {
  4292. this.flags &= ~128;
  4293. }
  4294. }
  4295. get soloAwait() {
  4296. return (this.flags & 256) > 0;
  4297. }
  4298. set soloAwait(value) {
  4299. if (value) {
  4300. this.flags |= 256;
  4301. } else {
  4302. this.flags &= ~256;
  4303. }
  4304. }
  4305. get inFSharpPipelineDirectBody() {
  4306. return (this.flags & 512) > 0;
  4307. }
  4308. set inFSharpPipelineDirectBody(value) {
  4309. if (value) {
  4310. this.flags |= 512;
  4311. } else {
  4312. this.flags &= ~512;
  4313. }
  4314. }
  4315. get canStartJSXElement() {
  4316. return (this.flags & 1024) > 0;
  4317. }
  4318. set canStartJSXElement(value) {
  4319. if (value) {
  4320. this.flags |= 1024;
  4321. } else {
  4322. this.flags &= ~1024;
  4323. }
  4324. }
  4325. get containsEsc() {
  4326. return (this.flags & 2048) > 0;
  4327. }
  4328. set containsEsc(value) {
  4329. if (value) {
  4330. this.flags |= 2048;
  4331. } else {
  4332. this.flags &= ~2048;
  4333. }
  4334. }
  4335. curPosition() {
  4336. return new Position(this.curLine, this.pos - this.lineStart, this.pos);
  4337. }
  4338. clone() {
  4339. const state = new State();
  4340. state.flags = this.flags;
  4341. state.curLine = this.curLine;
  4342. state.lineStart = this.lineStart;
  4343. state.startLoc = this.startLoc;
  4344. state.endLoc = this.endLoc;
  4345. state.errors = this.errors.slice();
  4346. state.potentialArrowAt = this.potentialArrowAt;
  4347. state.noArrowAt = this.noArrowAt.slice();
  4348. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  4349. state.topicContext = this.topicContext;
  4350. state.labels = this.labels.slice();
  4351. state.commentsLen = this.commentsLen;
  4352. state.commentStack = this.commentStack.slice();
  4353. state.pos = this.pos;
  4354. state.type = this.type;
  4355. state.value = this.value;
  4356. state.start = this.start;
  4357. state.end = this.end;
  4358. state.lastTokEndLoc = this.lastTokEndLoc;
  4359. state.lastTokStartLoc = this.lastTokStartLoc;
  4360. state.context = this.context.slice();
  4361. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  4362. state.strictErrors = this.strictErrors;
  4363. state.tokensLength = this.tokensLength;
  4364. return state;
  4365. }
  4366. }
  4367. var _isDigit = function isDigit(code) {
  4368. return code >= 48 && code <= 57;
  4369. };
  4370. const forbiddenNumericSeparatorSiblings = {
  4371. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  4372. hex: new Set([46, 88, 95, 120])
  4373. };
  4374. const isAllowedNumericSeparatorSibling = {
  4375. bin: ch => ch === 48 || ch === 49,
  4376. oct: ch => ch >= 48 && ch <= 55,
  4377. dec: ch => ch >= 48 && ch <= 57,
  4378. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  4379. };
  4380. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  4381. const initialPos = pos;
  4382. const initialLineStart = lineStart;
  4383. const initialCurLine = curLine;
  4384. let out = "";
  4385. let firstInvalidLoc = null;
  4386. let chunkStart = pos;
  4387. const {
  4388. length
  4389. } = input;
  4390. for (;;) {
  4391. if (pos >= length) {
  4392. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4393. out += input.slice(chunkStart, pos);
  4394. break;
  4395. }
  4396. const ch = input.charCodeAt(pos);
  4397. if (isStringEnd(type, ch, input, pos)) {
  4398. out += input.slice(chunkStart, pos);
  4399. break;
  4400. }
  4401. if (ch === 92) {
  4402. out += input.slice(chunkStart, pos);
  4403. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  4404. if (res.ch === null && !firstInvalidLoc) {
  4405. firstInvalidLoc = {
  4406. pos,
  4407. lineStart,
  4408. curLine
  4409. };
  4410. } else {
  4411. out += res.ch;
  4412. }
  4413. ({
  4414. pos,
  4415. lineStart,
  4416. curLine
  4417. } = res);
  4418. chunkStart = pos;
  4419. } else if (ch === 8232 || ch === 8233) {
  4420. ++pos;
  4421. ++curLine;
  4422. lineStart = pos;
  4423. } else if (ch === 10 || ch === 13) {
  4424. if (type === "template") {
  4425. out += input.slice(chunkStart, pos) + "\n";
  4426. ++pos;
  4427. if (ch === 13 && input.charCodeAt(pos) === 10) {
  4428. ++pos;
  4429. }
  4430. ++curLine;
  4431. chunkStart = lineStart = pos;
  4432. } else {
  4433. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4434. }
  4435. } else {
  4436. ++pos;
  4437. }
  4438. }
  4439. return {
  4440. pos,
  4441. str: out,
  4442. firstInvalidLoc,
  4443. lineStart,
  4444. curLine,
  4445. containsInvalid: !!firstInvalidLoc
  4446. };
  4447. }
  4448. function isStringEnd(type, ch, input, pos) {
  4449. if (type === "template") {
  4450. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  4451. }
  4452. return ch === (type === "double" ? 34 : 39);
  4453. }
  4454. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  4455. const throwOnInvalid = !inTemplate;
  4456. pos++;
  4457. const res = ch => ({
  4458. pos,
  4459. ch,
  4460. lineStart,
  4461. curLine
  4462. });
  4463. const ch = input.charCodeAt(pos++);
  4464. switch (ch) {
  4465. case 110:
  4466. return res("\n");
  4467. case 114:
  4468. return res("\r");
  4469. case 120:
  4470. {
  4471. let code;
  4472. ({
  4473. code,
  4474. pos
  4475. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  4476. return res(code === null ? null : String.fromCharCode(code));
  4477. }
  4478. case 117:
  4479. {
  4480. let code;
  4481. ({
  4482. code,
  4483. pos
  4484. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  4485. return res(code === null ? null : String.fromCodePoint(code));
  4486. }
  4487. case 116:
  4488. return res("\t");
  4489. case 98:
  4490. return res("\b");
  4491. case 118:
  4492. return res("\u000b");
  4493. case 102:
  4494. return res("\f");
  4495. case 13:
  4496. if (input.charCodeAt(pos) === 10) {
  4497. ++pos;
  4498. }
  4499. case 10:
  4500. lineStart = pos;
  4501. ++curLine;
  4502. case 8232:
  4503. case 8233:
  4504. return res("");
  4505. case 56:
  4506. case 57:
  4507. if (inTemplate) {
  4508. return res(null);
  4509. } else {
  4510. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  4511. }
  4512. default:
  4513. if (ch >= 48 && ch <= 55) {
  4514. const startPos = pos - 1;
  4515. const match = input.slice(startPos, pos + 2).match(/^[0-7]+/);
  4516. let octalStr = match[0];
  4517. let octal = parseInt(octalStr, 8);
  4518. if (octal > 255) {
  4519. octalStr = octalStr.slice(0, -1);
  4520. octal = parseInt(octalStr, 8);
  4521. }
  4522. pos += octalStr.length - 1;
  4523. const next = input.charCodeAt(pos);
  4524. if (octalStr !== "0" || next === 56 || next === 57) {
  4525. if (inTemplate) {
  4526. return res(null);
  4527. } else {
  4528. errors.strictNumericEscape(startPos, lineStart, curLine);
  4529. }
  4530. }
  4531. return res(String.fromCharCode(octal));
  4532. }
  4533. return res(String.fromCharCode(ch));
  4534. }
  4535. }
  4536. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  4537. const initialPos = pos;
  4538. let n;
  4539. ({
  4540. n,
  4541. pos
  4542. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  4543. if (n === null) {
  4544. if (throwOnInvalid) {
  4545. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  4546. } else {
  4547. pos = initialPos - 1;
  4548. }
  4549. }
  4550. return {
  4551. code: n,
  4552. pos
  4553. };
  4554. }
  4555. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  4556. const start = pos;
  4557. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  4558. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  4559. let invalid = false;
  4560. let total = 0;
  4561. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  4562. const code = input.charCodeAt(pos);
  4563. let val;
  4564. if (code === 95 && allowNumSeparator !== "bail") {
  4565. const prev = input.charCodeAt(pos - 1);
  4566. const next = input.charCodeAt(pos + 1);
  4567. if (!allowNumSeparator) {
  4568. if (bailOnError) return {
  4569. n: null,
  4570. pos
  4571. };
  4572. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  4573. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  4574. if (bailOnError) return {
  4575. n: null,
  4576. pos
  4577. };
  4578. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  4579. }
  4580. ++pos;
  4581. continue;
  4582. }
  4583. if (code >= 97) {
  4584. val = code - 97 + 10;
  4585. } else if (code >= 65) {
  4586. val = code - 65 + 10;
  4587. } else if (_isDigit(code)) {
  4588. val = code - 48;
  4589. } else {
  4590. val = Infinity;
  4591. }
  4592. if (val >= radix) {
  4593. if (val <= 9 && bailOnError) {
  4594. return {
  4595. n: null,
  4596. pos
  4597. };
  4598. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  4599. val = 0;
  4600. } else if (forceLen) {
  4601. val = 0;
  4602. invalid = true;
  4603. } else {
  4604. break;
  4605. }
  4606. }
  4607. ++pos;
  4608. total = total * radix + val;
  4609. }
  4610. if (pos === start || len != null && pos - start !== len || invalid) {
  4611. return {
  4612. n: null,
  4613. pos
  4614. };
  4615. }
  4616. return {
  4617. n: total,
  4618. pos
  4619. };
  4620. }
  4621. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  4622. const ch = input.charCodeAt(pos);
  4623. let code;
  4624. if (ch === 123) {
  4625. ++pos;
  4626. ({
  4627. code,
  4628. pos
  4629. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  4630. ++pos;
  4631. if (code !== null && code > 0x10ffff) {
  4632. if (throwOnInvalid) {
  4633. errors.invalidCodePoint(pos, lineStart, curLine);
  4634. } else {
  4635. return {
  4636. code: null,
  4637. pos
  4638. };
  4639. }
  4640. }
  4641. } else {
  4642. ({
  4643. code,
  4644. pos
  4645. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  4646. }
  4647. return {
  4648. code,
  4649. pos
  4650. };
  4651. }
  4652. function buildPosition(pos, lineStart, curLine) {
  4653. return new Position(curLine, pos - lineStart, pos);
  4654. }
  4655. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  4656. class Token {
  4657. constructor(state) {
  4658. this.type = state.type;
  4659. this.value = state.value;
  4660. this.start = state.start;
  4661. this.end = state.end;
  4662. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  4663. }
  4664. }
  4665. class Tokenizer extends CommentsParser {
  4666. constructor(options, input) {
  4667. super();
  4668. this.isLookahead = void 0;
  4669. this.tokens = [];
  4670. this.errorHandlers_readInt = {
  4671. invalidDigit: (pos, lineStart, curLine, radix) => {
  4672. if (!this.options.errorRecovery) return false;
  4673. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  4674. radix
  4675. });
  4676. return true;
  4677. },
  4678. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  4679. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  4680. };
  4681. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  4682. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  4683. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  4684. });
  4685. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  4686. strictNumericEscape: (pos, lineStart, curLine) => {
  4687. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  4688. },
  4689. unterminated: (pos, lineStart, curLine) => {
  4690. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  4691. }
  4692. });
  4693. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  4694. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  4695. unterminated: (pos, lineStart, curLine) => {
  4696. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  4697. }
  4698. });
  4699. this.state = new State();
  4700. this.state.init(options);
  4701. this.input = input;
  4702. this.length = input.length;
  4703. this.comments = [];
  4704. this.isLookahead = false;
  4705. }
  4706. pushToken(token) {
  4707. this.tokens.length = this.state.tokensLength;
  4708. this.tokens.push(token);
  4709. ++this.state.tokensLength;
  4710. }
  4711. next() {
  4712. this.checkKeywordEscapes();
  4713. if (this.options.tokens) {
  4714. this.pushToken(new Token(this.state));
  4715. }
  4716. this.state.lastTokEndLoc = this.state.endLoc;
  4717. this.state.lastTokStartLoc = this.state.startLoc;
  4718. this.nextToken();
  4719. }
  4720. eat(type) {
  4721. if (this.match(type)) {
  4722. this.next();
  4723. return true;
  4724. } else {
  4725. return false;
  4726. }
  4727. }
  4728. match(type) {
  4729. return this.state.type === type;
  4730. }
  4731. createLookaheadState(state) {
  4732. return {
  4733. pos: state.pos,
  4734. value: null,
  4735. type: state.type,
  4736. start: state.start,
  4737. end: state.end,
  4738. context: [this.curContext()],
  4739. inType: state.inType,
  4740. startLoc: state.startLoc,
  4741. lastTokEndLoc: state.lastTokEndLoc,
  4742. curLine: state.curLine,
  4743. lineStart: state.lineStart,
  4744. curPosition: state.curPosition
  4745. };
  4746. }
  4747. lookahead() {
  4748. const old = this.state;
  4749. this.state = this.createLookaheadState(old);
  4750. this.isLookahead = true;
  4751. this.nextToken();
  4752. this.isLookahead = false;
  4753. const curr = this.state;
  4754. this.state = old;
  4755. return curr;
  4756. }
  4757. nextTokenStart() {
  4758. return this.nextTokenStartSince(this.state.pos);
  4759. }
  4760. nextTokenStartSince(pos) {
  4761. skipWhiteSpace.lastIndex = pos;
  4762. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  4763. }
  4764. lookaheadCharCode() {
  4765. return this.input.charCodeAt(this.nextTokenStart());
  4766. }
  4767. nextTokenInLineStart() {
  4768. return this.nextTokenInLineStartSince(this.state.pos);
  4769. }
  4770. nextTokenInLineStartSince(pos) {
  4771. skipWhiteSpaceInLine.lastIndex = pos;
  4772. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  4773. }
  4774. lookaheadInLineCharCode() {
  4775. return this.input.charCodeAt(this.nextTokenInLineStart());
  4776. }
  4777. codePointAtPos(pos) {
  4778. let cp = this.input.charCodeAt(pos);
  4779. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  4780. const trail = this.input.charCodeAt(pos);
  4781. if ((trail & 0xfc00) === 0xdc00) {
  4782. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  4783. }
  4784. }
  4785. return cp;
  4786. }
  4787. setStrict(strict) {
  4788. this.state.strict = strict;
  4789. if (strict) {
  4790. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  4791. this.state.strictErrors.clear();
  4792. }
  4793. }
  4794. curContext() {
  4795. return this.state.context[this.state.context.length - 1];
  4796. }
  4797. nextToken() {
  4798. this.skipSpace();
  4799. this.state.start = this.state.pos;
  4800. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  4801. if (this.state.pos >= this.length) {
  4802. this.finishToken(139);
  4803. return;
  4804. }
  4805. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  4806. }
  4807. skipBlockComment(commentEnd) {
  4808. let startLoc;
  4809. if (!this.isLookahead) startLoc = this.state.curPosition();
  4810. const start = this.state.pos;
  4811. const end = this.input.indexOf(commentEnd, start + 2);
  4812. if (end === -1) {
  4813. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  4814. }
  4815. this.state.pos = end + commentEnd.length;
  4816. lineBreakG.lastIndex = start + 2;
  4817. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  4818. ++this.state.curLine;
  4819. this.state.lineStart = lineBreakG.lastIndex;
  4820. }
  4821. if (this.isLookahead) return;
  4822. const comment = {
  4823. type: "CommentBlock",
  4824. value: this.input.slice(start + 2, end),
  4825. start,
  4826. end: end + commentEnd.length,
  4827. loc: new SourceLocation(startLoc, this.state.curPosition())
  4828. };
  4829. if (this.options.tokens) this.pushToken(comment);
  4830. return comment;
  4831. }
  4832. skipLineComment(startSkip) {
  4833. const start = this.state.pos;
  4834. let startLoc;
  4835. if (!this.isLookahead) startLoc = this.state.curPosition();
  4836. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  4837. if (this.state.pos < this.length) {
  4838. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4839. ch = this.input.charCodeAt(this.state.pos);
  4840. }
  4841. }
  4842. if (this.isLookahead) return;
  4843. const end = this.state.pos;
  4844. const value = this.input.slice(start + startSkip, end);
  4845. const comment = {
  4846. type: "CommentLine",
  4847. value,
  4848. start,
  4849. end,
  4850. loc: new SourceLocation(startLoc, this.state.curPosition())
  4851. };
  4852. if (this.options.tokens) this.pushToken(comment);
  4853. return comment;
  4854. }
  4855. skipSpace() {
  4856. const spaceStart = this.state.pos;
  4857. const comments = [];
  4858. loop: while (this.state.pos < this.length) {
  4859. const ch = this.input.charCodeAt(this.state.pos);
  4860. switch (ch) {
  4861. case 32:
  4862. case 160:
  4863. case 9:
  4864. ++this.state.pos;
  4865. break;
  4866. case 13:
  4867. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  4868. ++this.state.pos;
  4869. }
  4870. case 10:
  4871. case 8232:
  4872. case 8233:
  4873. ++this.state.pos;
  4874. ++this.state.curLine;
  4875. this.state.lineStart = this.state.pos;
  4876. break;
  4877. case 47:
  4878. switch (this.input.charCodeAt(this.state.pos + 1)) {
  4879. case 42:
  4880. {
  4881. const comment = this.skipBlockComment("*/");
  4882. if (comment !== undefined) {
  4883. this.addComment(comment);
  4884. if (this.options.attachComment) comments.push(comment);
  4885. }
  4886. break;
  4887. }
  4888. case 47:
  4889. {
  4890. const comment = this.skipLineComment(2);
  4891. if (comment !== undefined) {
  4892. this.addComment(comment);
  4893. if (this.options.attachComment) comments.push(comment);
  4894. }
  4895. break;
  4896. }
  4897. default:
  4898. break loop;
  4899. }
  4900. break;
  4901. default:
  4902. if (isWhitespace(ch)) {
  4903. ++this.state.pos;
  4904. } else if (ch === 45 && !this.inModule && this.options.annexB) {
  4905. const pos = this.state.pos;
  4906. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  4907. const comment = this.skipLineComment(3);
  4908. if (comment !== undefined) {
  4909. this.addComment(comment);
  4910. if (this.options.attachComment) comments.push(comment);
  4911. }
  4912. } else {
  4913. break loop;
  4914. }
  4915. } else if (ch === 60 && !this.inModule && this.options.annexB) {
  4916. const pos = this.state.pos;
  4917. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  4918. const comment = this.skipLineComment(4);
  4919. if (comment !== undefined) {
  4920. this.addComment(comment);
  4921. if (this.options.attachComment) comments.push(comment);
  4922. }
  4923. } else {
  4924. break loop;
  4925. }
  4926. } else {
  4927. break loop;
  4928. }
  4929. }
  4930. }
  4931. if (comments.length > 0) {
  4932. const end = this.state.pos;
  4933. const commentWhitespace = {
  4934. start: spaceStart,
  4935. end,
  4936. comments,
  4937. leadingNode: null,
  4938. trailingNode: null,
  4939. containingNode: null
  4940. };
  4941. this.state.commentStack.push(commentWhitespace);
  4942. }
  4943. }
  4944. finishToken(type, val) {
  4945. this.state.end = this.state.pos;
  4946. this.state.endLoc = this.state.curPosition();
  4947. const prevType = this.state.type;
  4948. this.state.type = type;
  4949. this.state.value = val;
  4950. if (!this.isLookahead) {
  4951. this.updateContext(prevType);
  4952. }
  4953. }
  4954. replaceToken(type) {
  4955. this.state.type = type;
  4956. this.updateContext();
  4957. }
  4958. readToken_numberSign() {
  4959. if (this.state.pos === 0 && this.readToken_interpreter()) {
  4960. return;
  4961. }
  4962. const nextPos = this.state.pos + 1;
  4963. const next = this.codePointAtPos(nextPos);
  4964. if (next >= 48 && next <= 57) {
  4965. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  4966. }
  4967. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  4968. this.expectPlugin("recordAndTuple");
  4969. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  4970. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  4971. }
  4972. this.state.pos += 2;
  4973. if (next === 123) {
  4974. this.finishToken(7);
  4975. } else {
  4976. this.finishToken(1);
  4977. }
  4978. } else if (isIdentifierStart(next)) {
  4979. ++this.state.pos;
  4980. this.finishToken(138, this.readWord1(next));
  4981. } else if (next === 92) {
  4982. ++this.state.pos;
  4983. this.finishToken(138, this.readWord1());
  4984. } else {
  4985. this.finishOp(27, 1);
  4986. }
  4987. }
  4988. readToken_dot() {
  4989. const next = this.input.charCodeAt(this.state.pos + 1);
  4990. if (next >= 48 && next <= 57) {
  4991. this.readNumber(true);
  4992. return;
  4993. }
  4994. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  4995. this.state.pos += 3;
  4996. this.finishToken(21);
  4997. } else {
  4998. ++this.state.pos;
  4999. this.finishToken(16);
  5000. }
  5001. }
  5002. readToken_slash() {
  5003. const next = this.input.charCodeAt(this.state.pos + 1);
  5004. if (next === 61) {
  5005. this.finishOp(31, 2);
  5006. } else {
  5007. this.finishOp(56, 1);
  5008. }
  5009. }
  5010. readToken_interpreter() {
  5011. if (this.state.pos !== 0 || this.length < 2) return false;
  5012. let ch = this.input.charCodeAt(this.state.pos + 1);
  5013. if (ch !== 33) return false;
  5014. const start = this.state.pos;
  5015. this.state.pos += 1;
  5016. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  5017. ch = this.input.charCodeAt(this.state.pos);
  5018. }
  5019. const value = this.input.slice(start + 2, this.state.pos);
  5020. this.finishToken(28, value);
  5021. return true;
  5022. }
  5023. readToken_mult_modulo(code) {
  5024. let type = code === 42 ? 55 : 54;
  5025. let width = 1;
  5026. let next = this.input.charCodeAt(this.state.pos + 1);
  5027. if (code === 42 && next === 42) {
  5028. width++;
  5029. next = this.input.charCodeAt(this.state.pos + 2);
  5030. type = 57;
  5031. }
  5032. if (next === 61 && !this.state.inType) {
  5033. width++;
  5034. type = code === 37 ? 33 : 30;
  5035. }
  5036. this.finishOp(type, width);
  5037. }
  5038. readToken_pipe_amp(code) {
  5039. const next = this.input.charCodeAt(this.state.pos + 1);
  5040. if (next === code) {
  5041. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  5042. this.finishOp(30, 3);
  5043. } else {
  5044. this.finishOp(code === 124 ? 41 : 42, 2);
  5045. }
  5046. return;
  5047. }
  5048. if (code === 124) {
  5049. if (next === 62) {
  5050. this.finishOp(39, 2);
  5051. return;
  5052. }
  5053. if (this.hasPlugin("recordAndTuple") && next === 125) {
  5054. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5055. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5056. }
  5057. this.state.pos += 2;
  5058. this.finishToken(9);
  5059. return;
  5060. }
  5061. if (this.hasPlugin("recordAndTuple") && next === 93) {
  5062. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5063. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5064. }
  5065. this.state.pos += 2;
  5066. this.finishToken(4);
  5067. return;
  5068. }
  5069. }
  5070. if (next === 61) {
  5071. this.finishOp(30, 2);
  5072. return;
  5073. }
  5074. this.finishOp(code === 124 ? 43 : 45, 1);
  5075. }
  5076. readToken_caret() {
  5077. const next = this.input.charCodeAt(this.state.pos + 1);
  5078. if (next === 61 && !this.state.inType) {
  5079. this.finishOp(32, 2);
  5080. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  5081. proposal: "hack",
  5082. topicToken: "^^"
  5083. }])) {
  5084. this.finishOp(37, 2);
  5085. const lookaheadCh = this.input.codePointAt(this.state.pos);
  5086. if (lookaheadCh === 94) {
  5087. this.unexpected();
  5088. }
  5089. } else {
  5090. this.finishOp(44, 1);
  5091. }
  5092. }
  5093. readToken_atSign() {
  5094. const next = this.input.charCodeAt(this.state.pos + 1);
  5095. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  5096. proposal: "hack",
  5097. topicToken: "@@"
  5098. }])) {
  5099. this.finishOp(38, 2);
  5100. } else {
  5101. this.finishOp(26, 1);
  5102. }
  5103. }
  5104. readToken_plus_min(code) {
  5105. const next = this.input.charCodeAt(this.state.pos + 1);
  5106. if (next === code) {
  5107. this.finishOp(34, 2);
  5108. return;
  5109. }
  5110. if (next === 61) {
  5111. this.finishOp(30, 2);
  5112. } else {
  5113. this.finishOp(53, 1);
  5114. }
  5115. }
  5116. readToken_lt() {
  5117. const {
  5118. pos
  5119. } = this.state;
  5120. const next = this.input.charCodeAt(pos + 1);
  5121. if (next === 60) {
  5122. if (this.input.charCodeAt(pos + 2) === 61) {
  5123. this.finishOp(30, 3);
  5124. return;
  5125. }
  5126. this.finishOp(51, 2);
  5127. return;
  5128. }
  5129. if (next === 61) {
  5130. this.finishOp(49, 2);
  5131. return;
  5132. }
  5133. this.finishOp(47, 1);
  5134. }
  5135. readToken_gt() {
  5136. const {
  5137. pos
  5138. } = this.state;
  5139. const next = this.input.charCodeAt(pos + 1);
  5140. if (next === 62) {
  5141. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  5142. if (this.input.charCodeAt(pos + size) === 61) {
  5143. this.finishOp(30, size + 1);
  5144. return;
  5145. }
  5146. this.finishOp(52, size);
  5147. return;
  5148. }
  5149. if (next === 61) {
  5150. this.finishOp(49, 2);
  5151. return;
  5152. }
  5153. this.finishOp(48, 1);
  5154. }
  5155. readToken_eq_excl(code) {
  5156. const next = this.input.charCodeAt(this.state.pos + 1);
  5157. if (next === 61) {
  5158. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  5159. return;
  5160. }
  5161. if (code === 61 && next === 62) {
  5162. this.state.pos += 2;
  5163. this.finishToken(19);
  5164. return;
  5165. }
  5166. this.finishOp(code === 61 ? 29 : 35, 1);
  5167. }
  5168. readToken_question() {
  5169. const next = this.input.charCodeAt(this.state.pos + 1);
  5170. const next2 = this.input.charCodeAt(this.state.pos + 2);
  5171. if (next === 63) {
  5172. if (next2 === 61) {
  5173. this.finishOp(30, 3);
  5174. } else {
  5175. this.finishOp(40, 2);
  5176. }
  5177. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  5178. this.state.pos += 2;
  5179. this.finishToken(18);
  5180. } else {
  5181. ++this.state.pos;
  5182. this.finishToken(17);
  5183. }
  5184. }
  5185. getTokenFromCode(code) {
  5186. switch (code) {
  5187. case 46:
  5188. this.readToken_dot();
  5189. return;
  5190. case 40:
  5191. ++this.state.pos;
  5192. this.finishToken(10);
  5193. return;
  5194. case 41:
  5195. ++this.state.pos;
  5196. this.finishToken(11);
  5197. return;
  5198. case 59:
  5199. ++this.state.pos;
  5200. this.finishToken(13);
  5201. return;
  5202. case 44:
  5203. ++this.state.pos;
  5204. this.finishToken(12);
  5205. return;
  5206. case 91:
  5207. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5208. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5209. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5210. }
  5211. this.state.pos += 2;
  5212. this.finishToken(2);
  5213. } else {
  5214. ++this.state.pos;
  5215. this.finishToken(0);
  5216. }
  5217. return;
  5218. case 93:
  5219. ++this.state.pos;
  5220. this.finishToken(3);
  5221. return;
  5222. case 123:
  5223. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5224. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5225. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5226. }
  5227. this.state.pos += 2;
  5228. this.finishToken(6);
  5229. } else {
  5230. ++this.state.pos;
  5231. this.finishToken(5);
  5232. }
  5233. return;
  5234. case 125:
  5235. ++this.state.pos;
  5236. this.finishToken(8);
  5237. return;
  5238. case 58:
  5239. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  5240. this.finishOp(15, 2);
  5241. } else {
  5242. ++this.state.pos;
  5243. this.finishToken(14);
  5244. }
  5245. return;
  5246. case 63:
  5247. this.readToken_question();
  5248. return;
  5249. case 96:
  5250. this.readTemplateToken();
  5251. return;
  5252. case 48:
  5253. {
  5254. const next = this.input.charCodeAt(this.state.pos + 1);
  5255. if (next === 120 || next === 88) {
  5256. this.readRadixNumber(16);
  5257. return;
  5258. }
  5259. if (next === 111 || next === 79) {
  5260. this.readRadixNumber(8);
  5261. return;
  5262. }
  5263. if (next === 98 || next === 66) {
  5264. this.readRadixNumber(2);
  5265. return;
  5266. }
  5267. }
  5268. case 49:
  5269. case 50:
  5270. case 51:
  5271. case 52:
  5272. case 53:
  5273. case 54:
  5274. case 55:
  5275. case 56:
  5276. case 57:
  5277. this.readNumber(false);
  5278. return;
  5279. case 34:
  5280. case 39:
  5281. this.readString(code);
  5282. return;
  5283. case 47:
  5284. this.readToken_slash();
  5285. return;
  5286. case 37:
  5287. case 42:
  5288. this.readToken_mult_modulo(code);
  5289. return;
  5290. case 124:
  5291. case 38:
  5292. this.readToken_pipe_amp(code);
  5293. return;
  5294. case 94:
  5295. this.readToken_caret();
  5296. return;
  5297. case 43:
  5298. case 45:
  5299. this.readToken_plus_min(code);
  5300. return;
  5301. case 60:
  5302. this.readToken_lt();
  5303. return;
  5304. case 62:
  5305. this.readToken_gt();
  5306. return;
  5307. case 61:
  5308. case 33:
  5309. this.readToken_eq_excl(code);
  5310. return;
  5311. case 126:
  5312. this.finishOp(36, 1);
  5313. return;
  5314. case 64:
  5315. this.readToken_atSign();
  5316. return;
  5317. case 35:
  5318. this.readToken_numberSign();
  5319. return;
  5320. case 92:
  5321. this.readWord();
  5322. return;
  5323. default:
  5324. if (isIdentifierStart(code)) {
  5325. this.readWord(code);
  5326. return;
  5327. }
  5328. }
  5329. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  5330. unexpected: String.fromCodePoint(code)
  5331. });
  5332. }
  5333. finishOp(type, size) {
  5334. const str = this.input.slice(this.state.pos, this.state.pos + size);
  5335. this.state.pos += size;
  5336. this.finishToken(type, str);
  5337. }
  5338. readRegexp() {
  5339. const startLoc = this.state.startLoc;
  5340. const start = this.state.start + 1;
  5341. let escaped, inClass;
  5342. let {
  5343. pos
  5344. } = this.state;
  5345. for (;; ++pos) {
  5346. if (pos >= this.length) {
  5347. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5348. }
  5349. const ch = this.input.charCodeAt(pos);
  5350. if (isNewLine(ch)) {
  5351. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5352. }
  5353. if (escaped) {
  5354. escaped = false;
  5355. } else {
  5356. if (ch === 91) {
  5357. inClass = true;
  5358. } else if (ch === 93 && inClass) {
  5359. inClass = false;
  5360. } else if (ch === 47 && !inClass) {
  5361. break;
  5362. }
  5363. escaped = ch === 92;
  5364. }
  5365. }
  5366. const content = this.input.slice(start, pos);
  5367. ++pos;
  5368. let mods = "";
  5369. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  5370. while (pos < this.length) {
  5371. const cp = this.codePointAtPos(pos);
  5372. const char = String.fromCharCode(cp);
  5373. if (VALID_REGEX_FLAGS.has(cp)) {
  5374. if (cp === 118) {
  5375. if (mods.includes("u")) {
  5376. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5377. }
  5378. } else if (cp === 117) {
  5379. if (mods.includes("v")) {
  5380. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5381. }
  5382. }
  5383. if (mods.includes(char)) {
  5384. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  5385. }
  5386. } else if (isIdentifierChar(cp) || cp === 92) {
  5387. this.raise(Errors.MalformedRegExpFlags, nextPos());
  5388. } else {
  5389. break;
  5390. }
  5391. ++pos;
  5392. mods += char;
  5393. }
  5394. this.state.pos = pos;
  5395. this.finishToken(137, {
  5396. pattern: content,
  5397. flags: mods
  5398. });
  5399. }
  5400. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  5401. const {
  5402. n,
  5403. pos
  5404. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  5405. this.state.pos = pos;
  5406. return n;
  5407. }
  5408. readRadixNumber(radix) {
  5409. const startLoc = this.state.curPosition();
  5410. let isBigInt = false;
  5411. this.state.pos += 2;
  5412. const val = this.readInt(radix);
  5413. if (val == null) {
  5414. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  5415. radix
  5416. });
  5417. }
  5418. const next = this.input.charCodeAt(this.state.pos);
  5419. if (next === 110) {
  5420. ++this.state.pos;
  5421. isBigInt = true;
  5422. } else if (next === 109) {
  5423. throw this.raise(Errors.InvalidDecimal, startLoc);
  5424. }
  5425. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5426. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5427. }
  5428. if (isBigInt) {
  5429. const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, "");
  5430. this.finishToken(135, str);
  5431. return;
  5432. }
  5433. this.finishToken(134, val);
  5434. }
  5435. readNumber(startsWithDot) {
  5436. const start = this.state.pos;
  5437. const startLoc = this.state.curPosition();
  5438. let isFloat = false;
  5439. let isBigInt = false;
  5440. let isDecimal = false;
  5441. let hasExponent = false;
  5442. let isOctal = false;
  5443. if (!startsWithDot && this.readInt(10) === null) {
  5444. this.raise(Errors.InvalidNumber, this.state.curPosition());
  5445. }
  5446. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5447. if (hasLeadingZero) {
  5448. const integer = this.input.slice(start, this.state.pos);
  5449. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  5450. if (!this.state.strict) {
  5451. const underscorePos = integer.indexOf("_");
  5452. if (underscorePos > 0) {
  5453. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  5454. }
  5455. }
  5456. isOctal = hasLeadingZero && !/[89]/.test(integer);
  5457. }
  5458. let next = this.input.charCodeAt(this.state.pos);
  5459. if (next === 46 && !isOctal) {
  5460. ++this.state.pos;
  5461. this.readInt(10);
  5462. isFloat = true;
  5463. next = this.input.charCodeAt(this.state.pos);
  5464. }
  5465. if ((next === 69 || next === 101) && !isOctal) {
  5466. next = this.input.charCodeAt(++this.state.pos);
  5467. if (next === 43 || next === 45) {
  5468. ++this.state.pos;
  5469. }
  5470. if (this.readInt(10) === null) {
  5471. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  5472. }
  5473. isFloat = true;
  5474. hasExponent = true;
  5475. next = this.input.charCodeAt(this.state.pos);
  5476. }
  5477. if (next === 110) {
  5478. if (isFloat || hasLeadingZero) {
  5479. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  5480. }
  5481. ++this.state.pos;
  5482. isBigInt = true;
  5483. }
  5484. if (next === 109) {
  5485. this.expectPlugin("decimal", this.state.curPosition());
  5486. if (hasExponent || hasLeadingZero) {
  5487. this.raise(Errors.InvalidDecimal, startLoc);
  5488. }
  5489. ++this.state.pos;
  5490. isDecimal = true;
  5491. }
  5492. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5493. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5494. }
  5495. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  5496. if (isBigInt) {
  5497. this.finishToken(135, str);
  5498. return;
  5499. }
  5500. if (isDecimal) {
  5501. this.finishToken(136, str);
  5502. return;
  5503. }
  5504. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  5505. this.finishToken(134, val);
  5506. }
  5507. readCodePoint(throwOnInvalid) {
  5508. const {
  5509. code,
  5510. pos
  5511. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  5512. this.state.pos = pos;
  5513. return code;
  5514. }
  5515. readString(quote) {
  5516. const {
  5517. str,
  5518. pos,
  5519. curLine,
  5520. lineStart
  5521. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  5522. this.state.pos = pos + 1;
  5523. this.state.lineStart = lineStart;
  5524. this.state.curLine = curLine;
  5525. this.finishToken(133, str);
  5526. }
  5527. readTemplateContinuation() {
  5528. if (!this.match(8)) {
  5529. this.unexpected(null, 8);
  5530. }
  5531. this.state.pos--;
  5532. this.readTemplateToken();
  5533. }
  5534. readTemplateToken() {
  5535. const opening = this.input[this.state.pos];
  5536. const {
  5537. str,
  5538. firstInvalidLoc,
  5539. pos,
  5540. curLine,
  5541. lineStart
  5542. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  5543. this.state.pos = pos + 1;
  5544. this.state.lineStart = lineStart;
  5545. this.state.curLine = curLine;
  5546. if (firstInvalidLoc) {
  5547. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
  5548. }
  5549. if (this.input.codePointAt(pos) === 96) {
  5550. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  5551. } else {
  5552. this.state.pos++;
  5553. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  5554. }
  5555. }
  5556. recordStrictModeErrors(toParseError, at) {
  5557. const index = at.index;
  5558. if (this.state.strict && !this.state.strictErrors.has(index)) {
  5559. this.raise(toParseError, at);
  5560. } else {
  5561. this.state.strictErrors.set(index, [toParseError, at]);
  5562. }
  5563. }
  5564. readWord1(firstCode) {
  5565. this.state.containsEsc = false;
  5566. let word = "";
  5567. const start = this.state.pos;
  5568. let chunkStart = this.state.pos;
  5569. if (firstCode !== undefined) {
  5570. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  5571. }
  5572. while (this.state.pos < this.length) {
  5573. const ch = this.codePointAtPos(this.state.pos);
  5574. if (isIdentifierChar(ch)) {
  5575. this.state.pos += ch <= 0xffff ? 1 : 2;
  5576. } else if (ch === 92) {
  5577. this.state.containsEsc = true;
  5578. word += this.input.slice(chunkStart, this.state.pos);
  5579. const escStart = this.state.curPosition();
  5580. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  5581. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  5582. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  5583. chunkStart = this.state.pos - 1;
  5584. continue;
  5585. }
  5586. ++this.state.pos;
  5587. const esc = this.readCodePoint(true);
  5588. if (esc !== null) {
  5589. if (!identifierCheck(esc)) {
  5590. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  5591. }
  5592. word += String.fromCodePoint(esc);
  5593. }
  5594. chunkStart = this.state.pos;
  5595. } else {
  5596. break;
  5597. }
  5598. }
  5599. return word + this.input.slice(chunkStart, this.state.pos);
  5600. }
  5601. readWord(firstCode) {
  5602. const word = this.readWord1(firstCode);
  5603. const type = keywords$1.get(word);
  5604. if (type !== undefined) {
  5605. this.finishToken(type, tokenLabelName(type));
  5606. } else {
  5607. this.finishToken(132, word);
  5608. }
  5609. }
  5610. checkKeywordEscapes() {
  5611. const {
  5612. type
  5613. } = this.state;
  5614. if (tokenIsKeyword(type) && this.state.containsEsc) {
  5615. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  5616. reservedWord: tokenLabelName(type)
  5617. });
  5618. }
  5619. }
  5620. raise(toParseError, at, details = {}) {
  5621. const loc = at instanceof Position ? at : at.loc.start;
  5622. const error = toParseError(loc, details);
  5623. if (!this.options.errorRecovery) throw error;
  5624. if (!this.isLookahead) this.state.errors.push(error);
  5625. return error;
  5626. }
  5627. raiseOverwrite(toParseError, at, details = {}) {
  5628. const loc = at instanceof Position ? at : at.loc.start;
  5629. const pos = loc.index;
  5630. const errors = this.state.errors;
  5631. for (let i = errors.length - 1; i >= 0; i--) {
  5632. const error = errors[i];
  5633. if (error.loc.index === pos) {
  5634. return errors[i] = toParseError(loc, details);
  5635. }
  5636. if (error.loc.index < pos) break;
  5637. }
  5638. return this.raise(toParseError, at, details);
  5639. }
  5640. updateContext(prevType) {}
  5641. unexpected(loc, type) {
  5642. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  5643. expected: type ? tokenLabelName(type) : null
  5644. });
  5645. }
  5646. expectPlugin(pluginName, loc) {
  5647. if (this.hasPlugin(pluginName)) {
  5648. return true;
  5649. }
  5650. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  5651. missingPlugin: [pluginName]
  5652. });
  5653. }
  5654. expectOnePlugin(pluginNames) {
  5655. if (!pluginNames.some(name => this.hasPlugin(name))) {
  5656. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  5657. missingPlugin: pluginNames
  5658. });
  5659. }
  5660. }
  5661. errorBuilder(error) {
  5662. return (pos, lineStart, curLine) => {
  5663. this.raise(error, buildPosition(pos, lineStart, curLine));
  5664. };
  5665. }
  5666. }
  5667. class ClassScope {
  5668. constructor() {
  5669. this.privateNames = new Set();
  5670. this.loneAccessors = new Map();
  5671. this.undefinedPrivateNames = new Map();
  5672. }
  5673. }
  5674. class ClassScopeHandler {
  5675. constructor(parser) {
  5676. this.parser = void 0;
  5677. this.stack = [];
  5678. this.undefinedPrivateNames = new Map();
  5679. this.parser = parser;
  5680. }
  5681. current() {
  5682. return this.stack[this.stack.length - 1];
  5683. }
  5684. enter() {
  5685. this.stack.push(new ClassScope());
  5686. }
  5687. exit() {
  5688. const oldClassScope = this.stack.pop();
  5689. const current = this.current();
  5690. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  5691. if (current) {
  5692. if (!current.undefinedPrivateNames.has(name)) {
  5693. current.undefinedPrivateNames.set(name, loc);
  5694. }
  5695. } else {
  5696. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5697. identifierName: name
  5698. });
  5699. }
  5700. }
  5701. }
  5702. declarePrivateName(name, elementType, loc) {
  5703. const {
  5704. privateNames,
  5705. loneAccessors,
  5706. undefinedPrivateNames
  5707. } = this.current();
  5708. let redefined = privateNames.has(name);
  5709. if (elementType & 3) {
  5710. const accessor = redefined && loneAccessors.get(name);
  5711. if (accessor) {
  5712. const oldStatic = accessor & 4;
  5713. const newStatic = elementType & 4;
  5714. const oldKind = accessor & 3;
  5715. const newKind = elementType & 3;
  5716. redefined = oldKind === newKind || oldStatic !== newStatic;
  5717. if (!redefined) loneAccessors.delete(name);
  5718. } else if (!redefined) {
  5719. loneAccessors.set(name, elementType);
  5720. }
  5721. }
  5722. if (redefined) {
  5723. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  5724. identifierName: name
  5725. });
  5726. }
  5727. privateNames.add(name);
  5728. undefinedPrivateNames.delete(name);
  5729. }
  5730. usePrivateName(name, loc) {
  5731. let classScope;
  5732. for (classScope of this.stack) {
  5733. if (classScope.privateNames.has(name)) return;
  5734. }
  5735. if (classScope) {
  5736. classScope.undefinedPrivateNames.set(name, loc);
  5737. } else {
  5738. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5739. identifierName: name
  5740. });
  5741. }
  5742. }
  5743. }
  5744. class ExpressionScope {
  5745. constructor(type = 0) {
  5746. this.type = type;
  5747. }
  5748. canBeArrowParameterDeclaration() {
  5749. return this.type === 2 || this.type === 1;
  5750. }
  5751. isCertainlyParameterDeclaration() {
  5752. return this.type === 3;
  5753. }
  5754. }
  5755. class ArrowHeadParsingScope extends ExpressionScope {
  5756. constructor(type) {
  5757. super(type);
  5758. this.declarationErrors = new Map();
  5759. }
  5760. recordDeclarationError(ParsingErrorClass, at) {
  5761. const index = at.index;
  5762. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  5763. }
  5764. clearDeclarationError(index) {
  5765. this.declarationErrors.delete(index);
  5766. }
  5767. iterateErrors(iterator) {
  5768. this.declarationErrors.forEach(iterator);
  5769. }
  5770. }
  5771. class ExpressionScopeHandler {
  5772. constructor(parser) {
  5773. this.parser = void 0;
  5774. this.stack = [new ExpressionScope()];
  5775. this.parser = parser;
  5776. }
  5777. enter(scope) {
  5778. this.stack.push(scope);
  5779. }
  5780. exit() {
  5781. this.stack.pop();
  5782. }
  5783. recordParameterInitializerError(toParseError, node) {
  5784. const origin = node.loc.start;
  5785. const {
  5786. stack
  5787. } = this;
  5788. let i = stack.length - 1;
  5789. let scope = stack[i];
  5790. while (!scope.isCertainlyParameterDeclaration()) {
  5791. if (scope.canBeArrowParameterDeclaration()) {
  5792. scope.recordDeclarationError(toParseError, origin);
  5793. } else {
  5794. return;
  5795. }
  5796. scope = stack[--i];
  5797. }
  5798. this.parser.raise(toParseError, origin);
  5799. }
  5800. recordArrowParameterBindingError(error, node) {
  5801. const {
  5802. stack
  5803. } = this;
  5804. const scope = stack[stack.length - 1];
  5805. const origin = node.loc.start;
  5806. if (scope.isCertainlyParameterDeclaration()) {
  5807. this.parser.raise(error, origin);
  5808. } else if (scope.canBeArrowParameterDeclaration()) {
  5809. scope.recordDeclarationError(error, origin);
  5810. } else {
  5811. return;
  5812. }
  5813. }
  5814. recordAsyncArrowParametersError(at) {
  5815. const {
  5816. stack
  5817. } = this;
  5818. let i = stack.length - 1;
  5819. let scope = stack[i];
  5820. while (scope.canBeArrowParameterDeclaration()) {
  5821. if (scope.type === 2) {
  5822. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  5823. }
  5824. scope = stack[--i];
  5825. }
  5826. }
  5827. validateAsPattern() {
  5828. const {
  5829. stack
  5830. } = this;
  5831. const currentScope = stack[stack.length - 1];
  5832. if (!currentScope.canBeArrowParameterDeclaration()) return;
  5833. currentScope.iterateErrors(([toParseError, loc]) => {
  5834. this.parser.raise(toParseError, loc);
  5835. let i = stack.length - 2;
  5836. let scope = stack[i];
  5837. while (scope.canBeArrowParameterDeclaration()) {
  5838. scope.clearDeclarationError(loc.index);
  5839. scope = stack[--i];
  5840. }
  5841. });
  5842. }
  5843. }
  5844. function newParameterDeclarationScope() {
  5845. return new ExpressionScope(3);
  5846. }
  5847. function newArrowHeadScope() {
  5848. return new ArrowHeadParsingScope(1);
  5849. }
  5850. function newAsyncArrowScope() {
  5851. return new ArrowHeadParsingScope(2);
  5852. }
  5853. function newExpressionScope() {
  5854. return new ExpressionScope();
  5855. }
  5856. class ProductionParameterHandler {
  5857. constructor() {
  5858. this.stacks = [];
  5859. }
  5860. enter(flags) {
  5861. this.stacks.push(flags);
  5862. }
  5863. exit() {
  5864. this.stacks.pop();
  5865. }
  5866. currentFlags() {
  5867. return this.stacks[this.stacks.length - 1];
  5868. }
  5869. get hasAwait() {
  5870. return (this.currentFlags() & 2) > 0;
  5871. }
  5872. get hasYield() {
  5873. return (this.currentFlags() & 1) > 0;
  5874. }
  5875. get hasReturn() {
  5876. return (this.currentFlags() & 4) > 0;
  5877. }
  5878. get hasIn() {
  5879. return (this.currentFlags() & 8) > 0;
  5880. }
  5881. }
  5882. function functionFlags(isAsync, isGenerator) {
  5883. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  5884. }
  5885. class UtilParser extends Tokenizer {
  5886. addExtra(node, key, value, enumerable = true) {
  5887. if (!node) return;
  5888. const extra = node.extra = node.extra || {};
  5889. if (enumerable) {
  5890. extra[key] = value;
  5891. } else {
  5892. Object.defineProperty(extra, key, {
  5893. enumerable,
  5894. value
  5895. });
  5896. }
  5897. }
  5898. isContextual(token) {
  5899. return this.state.type === token && !this.state.containsEsc;
  5900. }
  5901. isUnparsedContextual(nameStart, name) {
  5902. const nameEnd = nameStart + name.length;
  5903. if (this.input.slice(nameStart, nameEnd) === name) {
  5904. const nextCh = this.input.charCodeAt(nameEnd);
  5905. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  5906. }
  5907. return false;
  5908. }
  5909. isLookaheadContextual(name) {
  5910. const next = this.nextTokenStart();
  5911. return this.isUnparsedContextual(next, name);
  5912. }
  5913. eatContextual(token) {
  5914. if (this.isContextual(token)) {
  5915. this.next();
  5916. return true;
  5917. }
  5918. return false;
  5919. }
  5920. expectContextual(token, toParseError) {
  5921. if (!this.eatContextual(token)) {
  5922. if (toParseError != null) {
  5923. throw this.raise(toParseError, this.state.startLoc);
  5924. }
  5925. this.unexpected(null, token);
  5926. }
  5927. }
  5928. canInsertSemicolon() {
  5929. return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
  5930. }
  5931. hasPrecedingLineBreak() {
  5932. return lineBreak.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start));
  5933. }
  5934. hasFollowingLineBreak() {
  5935. skipWhiteSpaceToLineBreak.lastIndex = this.state.end;
  5936. return skipWhiteSpaceToLineBreak.test(this.input);
  5937. }
  5938. isLineTerminator() {
  5939. return this.eat(13) || this.canInsertSemicolon();
  5940. }
  5941. semicolon(allowAsi = true) {
  5942. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  5943. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  5944. }
  5945. expect(type, loc) {
  5946. this.eat(type) || this.unexpected(loc, type);
  5947. }
  5948. tryParse(fn, oldState = this.state.clone()) {
  5949. const abortSignal = {
  5950. node: null
  5951. };
  5952. try {
  5953. const node = fn((node = null) => {
  5954. abortSignal.node = node;
  5955. throw abortSignal;
  5956. });
  5957. if (this.state.errors.length > oldState.errors.length) {
  5958. const failState = this.state;
  5959. this.state = oldState;
  5960. this.state.tokensLength = failState.tokensLength;
  5961. return {
  5962. node,
  5963. error: failState.errors[oldState.errors.length],
  5964. thrown: false,
  5965. aborted: false,
  5966. failState
  5967. };
  5968. }
  5969. return {
  5970. node,
  5971. error: null,
  5972. thrown: false,
  5973. aborted: false,
  5974. failState: null
  5975. };
  5976. } catch (error) {
  5977. const failState = this.state;
  5978. this.state = oldState;
  5979. if (error instanceof SyntaxError) {
  5980. return {
  5981. node: null,
  5982. error,
  5983. thrown: true,
  5984. aborted: false,
  5985. failState
  5986. };
  5987. }
  5988. if (error === abortSignal) {
  5989. return {
  5990. node: abortSignal.node,
  5991. error: null,
  5992. thrown: false,
  5993. aborted: true,
  5994. failState
  5995. };
  5996. }
  5997. throw error;
  5998. }
  5999. }
  6000. checkExpressionErrors(refExpressionErrors, andThrow) {
  6001. if (!refExpressionErrors) return false;
  6002. const {
  6003. shorthandAssignLoc,
  6004. doubleProtoLoc,
  6005. privateKeyLoc,
  6006. optionalParametersLoc
  6007. } = refExpressionErrors;
  6008. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
  6009. if (!andThrow) {
  6010. return hasErrors;
  6011. }
  6012. if (shorthandAssignLoc != null) {
  6013. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  6014. }
  6015. if (doubleProtoLoc != null) {
  6016. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  6017. }
  6018. if (privateKeyLoc != null) {
  6019. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  6020. }
  6021. if (optionalParametersLoc != null) {
  6022. this.unexpected(optionalParametersLoc);
  6023. }
  6024. }
  6025. isLiteralPropertyName() {
  6026. return tokenIsLiteralPropertyName(this.state.type);
  6027. }
  6028. isPrivateName(node) {
  6029. return node.type === "PrivateName";
  6030. }
  6031. getPrivateNameSV(node) {
  6032. return node.id.name;
  6033. }
  6034. hasPropertyAsPrivateName(node) {
  6035. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  6036. }
  6037. isObjectProperty(node) {
  6038. return node.type === "ObjectProperty";
  6039. }
  6040. isObjectMethod(node) {
  6041. return node.type === "ObjectMethod";
  6042. }
  6043. initializeScopes(inModule = this.options.sourceType === "module") {
  6044. const oldLabels = this.state.labels;
  6045. this.state.labels = [];
  6046. const oldExportedIdentifiers = this.exportedIdentifiers;
  6047. this.exportedIdentifiers = new Set();
  6048. const oldInModule = this.inModule;
  6049. this.inModule = inModule;
  6050. const oldScope = this.scope;
  6051. const ScopeHandler = this.getScopeHandler();
  6052. this.scope = new ScopeHandler(this, inModule);
  6053. const oldProdParam = this.prodParam;
  6054. this.prodParam = new ProductionParameterHandler();
  6055. const oldClassScope = this.classScope;
  6056. this.classScope = new ClassScopeHandler(this);
  6057. const oldExpressionScope = this.expressionScope;
  6058. this.expressionScope = new ExpressionScopeHandler(this);
  6059. return () => {
  6060. this.state.labels = oldLabels;
  6061. this.exportedIdentifiers = oldExportedIdentifiers;
  6062. this.inModule = oldInModule;
  6063. this.scope = oldScope;
  6064. this.prodParam = oldProdParam;
  6065. this.classScope = oldClassScope;
  6066. this.expressionScope = oldExpressionScope;
  6067. };
  6068. }
  6069. enterInitialScopes() {
  6070. let paramFlags = 0;
  6071. if (this.inModule) {
  6072. paramFlags |= 2;
  6073. }
  6074. this.scope.enter(1);
  6075. this.prodParam.enter(paramFlags);
  6076. }
  6077. checkDestructuringPrivate(refExpressionErrors) {
  6078. const {
  6079. privateKeyLoc
  6080. } = refExpressionErrors;
  6081. if (privateKeyLoc !== null) {
  6082. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  6083. }
  6084. }
  6085. }
  6086. class ExpressionErrors {
  6087. constructor() {
  6088. this.shorthandAssignLoc = null;
  6089. this.doubleProtoLoc = null;
  6090. this.privateKeyLoc = null;
  6091. this.optionalParametersLoc = null;
  6092. }
  6093. }
  6094. let Node$5 = class Node {
  6095. constructor(parser, pos, loc) {
  6096. this.type = "";
  6097. this.start = pos;
  6098. this.end = 0;
  6099. this.loc = new SourceLocation(loc);
  6100. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  6101. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  6102. }
  6103. };
  6104. const NodePrototype = Node$5.prototype;
  6105. {
  6106. NodePrototype.__clone = function () {
  6107. const newNode = new Node$5(undefined, this.start, this.loc.start);
  6108. const keys = Object.keys(this);
  6109. for (let i = 0, length = keys.length; i < length; i++) {
  6110. const key = keys[i];
  6111. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  6112. newNode[key] = this[key];
  6113. }
  6114. }
  6115. return newNode;
  6116. };
  6117. }
  6118. function clonePlaceholder(node) {
  6119. return cloneIdentifier(node);
  6120. }
  6121. function cloneIdentifier(node) {
  6122. const {
  6123. type,
  6124. start,
  6125. end,
  6126. loc,
  6127. range,
  6128. extra,
  6129. name
  6130. } = node;
  6131. const cloned = Object.create(NodePrototype);
  6132. cloned.type = type;
  6133. cloned.start = start;
  6134. cloned.end = end;
  6135. cloned.loc = loc;
  6136. cloned.range = range;
  6137. cloned.extra = extra;
  6138. cloned.name = name;
  6139. if (type === "Placeholder") {
  6140. cloned.expectedNode = node.expectedNode;
  6141. }
  6142. return cloned;
  6143. }
  6144. function cloneStringLiteral(node) {
  6145. const {
  6146. type,
  6147. start,
  6148. end,
  6149. loc,
  6150. range,
  6151. extra
  6152. } = node;
  6153. if (type === "Placeholder") {
  6154. return clonePlaceholder(node);
  6155. }
  6156. const cloned = Object.create(NodePrototype);
  6157. cloned.type = type;
  6158. cloned.start = start;
  6159. cloned.end = end;
  6160. cloned.loc = loc;
  6161. cloned.range = range;
  6162. if (node.raw !== undefined) {
  6163. cloned.raw = node.raw;
  6164. } else {
  6165. cloned.extra = extra;
  6166. }
  6167. cloned.value = node.value;
  6168. return cloned;
  6169. }
  6170. class NodeUtils extends UtilParser {
  6171. startNode() {
  6172. const loc = this.state.startLoc;
  6173. return new Node$5(this, loc.index, loc);
  6174. }
  6175. startNodeAt(loc) {
  6176. return new Node$5(this, loc.index, loc);
  6177. }
  6178. startNodeAtNode(type) {
  6179. return this.startNodeAt(type.loc.start);
  6180. }
  6181. finishNode(node, type) {
  6182. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  6183. }
  6184. finishNodeAt(node, type, endLoc) {
  6185. node.type = type;
  6186. node.end = endLoc.index;
  6187. node.loc.end = endLoc;
  6188. if (this.options.ranges) node.range[1] = endLoc.index;
  6189. if (this.options.attachComment) this.processComment(node);
  6190. return node;
  6191. }
  6192. resetStartLocation(node, startLoc) {
  6193. node.start = startLoc.index;
  6194. node.loc.start = startLoc;
  6195. if (this.options.ranges) node.range[0] = startLoc.index;
  6196. }
  6197. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  6198. node.end = endLoc.index;
  6199. node.loc.end = endLoc;
  6200. if (this.options.ranges) node.range[1] = endLoc.index;
  6201. }
  6202. resetStartLocationFromNode(node, locationNode) {
  6203. this.resetStartLocation(node, locationNode.loc.start);
  6204. }
  6205. }
  6206. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  6207. const FlowErrors = ParseErrorEnum`flow`({
  6208. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  6209. AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.",
  6210. AssignReservedType: ({
  6211. reservedType
  6212. }) => `Cannot overwrite reserved type ${reservedType}.`,
  6213. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  6214. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  6215. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  6216. EnumBooleanMemberNotInitialized: ({
  6217. memberName,
  6218. enumName
  6219. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  6220. EnumDuplicateMemberName: ({
  6221. memberName,
  6222. enumName
  6223. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  6224. EnumInconsistentMemberValues: ({
  6225. enumName
  6226. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  6227. EnumInvalidExplicitType: ({
  6228. invalidEnumType,
  6229. enumName
  6230. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6231. EnumInvalidExplicitTypeUnknownSupplied: ({
  6232. enumName
  6233. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6234. EnumInvalidMemberInitializerPrimaryType: ({
  6235. enumName,
  6236. memberName,
  6237. explicitType
  6238. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  6239. EnumInvalidMemberInitializerSymbolType: ({
  6240. enumName,
  6241. memberName
  6242. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  6243. EnumInvalidMemberInitializerUnknownType: ({
  6244. enumName,
  6245. memberName
  6246. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  6247. EnumInvalidMemberName: ({
  6248. enumName,
  6249. memberName,
  6250. suggestion
  6251. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  6252. EnumNumberMemberNotInitialized: ({
  6253. enumName,
  6254. memberName
  6255. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  6256. EnumStringMemberInconsistentlyInitialized: ({
  6257. enumName
  6258. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  6259. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  6260. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  6261. ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",
  6262. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  6263. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  6264. InexactVariance: "Explicit inexact syntax cannot have variance.",
  6265. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  6266. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  6267. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  6268. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  6269. PatternIsOptional: Object.assign({
  6270. message: "A binding pattern parameter cannot be optional in an implementation signature."
  6271. }, {
  6272. reasonCode: "OptionalBindingPattern"
  6273. }),
  6274. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  6275. SpreadVariance: "Spread properties cannot have variance.",
  6276. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  6277. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  6278. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  6279. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  6280. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  6281. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  6282. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  6283. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  6284. UnexpectedReservedType: ({
  6285. reservedType
  6286. }) => `Unexpected reserved type ${reservedType}.`,
  6287. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  6288. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  6289. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  6290. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  6291. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  6292. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  6293. UnsupportedDeclareExportKind: ({
  6294. unsupportedExportKind,
  6295. suggestion
  6296. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  6297. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  6298. UnterminatedFlowComment: "Unterminated flow-comment."
  6299. });
  6300. function isEsModuleType(bodyElement) {
  6301. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  6302. }
  6303. function hasTypeImportKind(node) {
  6304. return node.importKind === "type" || node.importKind === "typeof";
  6305. }
  6306. const exportSuggestions = {
  6307. const: "declare export var",
  6308. let: "declare export var",
  6309. type: "export type",
  6310. interface: "export interface"
  6311. };
  6312. function partition(list, test) {
  6313. const list1 = [];
  6314. const list2 = [];
  6315. for (let i = 0; i < list.length; i++) {
  6316. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  6317. }
  6318. return [list1, list2];
  6319. }
  6320. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  6321. var flow = superClass => class FlowParserMixin extends superClass {
  6322. constructor(...args) {
  6323. super(...args);
  6324. this.flowPragma = undefined;
  6325. }
  6326. getScopeHandler() {
  6327. return FlowScopeHandler;
  6328. }
  6329. shouldParseTypes() {
  6330. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  6331. }
  6332. shouldParseEnums() {
  6333. return !!this.getPluginOption("flow", "enums");
  6334. }
  6335. finishToken(type, val) {
  6336. if (type !== 133 && type !== 13 && type !== 28) {
  6337. if (this.flowPragma === undefined) {
  6338. this.flowPragma = null;
  6339. }
  6340. }
  6341. super.finishToken(type, val);
  6342. }
  6343. addComment(comment) {
  6344. if (this.flowPragma === undefined) {
  6345. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  6346. if (!matches) ;else if (matches[1] === "flow") {
  6347. this.flowPragma = "flow";
  6348. } else if (matches[1] === "noflow") {
  6349. this.flowPragma = "noflow";
  6350. } else {
  6351. throw new Error("Unexpected flow pragma");
  6352. }
  6353. }
  6354. super.addComment(comment);
  6355. }
  6356. flowParseTypeInitialiser(tok) {
  6357. const oldInType = this.state.inType;
  6358. this.state.inType = true;
  6359. this.expect(tok || 14);
  6360. const type = this.flowParseType();
  6361. this.state.inType = oldInType;
  6362. return type;
  6363. }
  6364. flowParsePredicate() {
  6365. const node = this.startNode();
  6366. const moduloLoc = this.state.startLoc;
  6367. this.next();
  6368. this.expectContextual(110);
  6369. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  6370. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  6371. }
  6372. if (this.eat(10)) {
  6373. node.value = super.parseExpression();
  6374. this.expect(11);
  6375. return this.finishNode(node, "DeclaredPredicate");
  6376. } else {
  6377. return this.finishNode(node, "InferredPredicate");
  6378. }
  6379. }
  6380. flowParseTypeAndPredicateInitialiser() {
  6381. const oldInType = this.state.inType;
  6382. this.state.inType = true;
  6383. this.expect(14);
  6384. let type = null;
  6385. let predicate = null;
  6386. if (this.match(54)) {
  6387. this.state.inType = oldInType;
  6388. predicate = this.flowParsePredicate();
  6389. } else {
  6390. type = this.flowParseType();
  6391. this.state.inType = oldInType;
  6392. if (this.match(54)) {
  6393. predicate = this.flowParsePredicate();
  6394. }
  6395. }
  6396. return [type, predicate];
  6397. }
  6398. flowParseDeclareClass(node) {
  6399. this.next();
  6400. this.flowParseInterfaceish(node, true);
  6401. return this.finishNode(node, "DeclareClass");
  6402. }
  6403. flowParseDeclareFunction(node) {
  6404. this.next();
  6405. const id = node.id = this.parseIdentifier();
  6406. const typeNode = this.startNode();
  6407. const typeContainer = this.startNode();
  6408. if (this.match(47)) {
  6409. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  6410. } else {
  6411. typeNode.typeParameters = null;
  6412. }
  6413. this.expect(10);
  6414. const tmp = this.flowParseFunctionTypeParams();
  6415. typeNode.params = tmp.params;
  6416. typeNode.rest = tmp.rest;
  6417. typeNode.this = tmp._this;
  6418. this.expect(11);
  6419. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6420. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  6421. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  6422. this.resetEndLocation(id);
  6423. this.semicolon();
  6424. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  6425. return this.finishNode(node, "DeclareFunction");
  6426. }
  6427. flowParseDeclare(node, insideModule) {
  6428. if (this.match(80)) {
  6429. return this.flowParseDeclareClass(node);
  6430. } else if (this.match(68)) {
  6431. return this.flowParseDeclareFunction(node);
  6432. } else if (this.match(74)) {
  6433. return this.flowParseDeclareVariable(node);
  6434. } else if (this.eatContextual(127)) {
  6435. if (this.match(16)) {
  6436. return this.flowParseDeclareModuleExports(node);
  6437. } else {
  6438. if (insideModule) {
  6439. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  6440. }
  6441. return this.flowParseDeclareModule(node);
  6442. }
  6443. } else if (this.isContextual(130)) {
  6444. return this.flowParseDeclareTypeAlias(node);
  6445. } else if (this.isContextual(131)) {
  6446. return this.flowParseDeclareOpaqueType(node);
  6447. } else if (this.isContextual(129)) {
  6448. return this.flowParseDeclareInterface(node);
  6449. } else if (this.match(82)) {
  6450. return this.flowParseDeclareExportDeclaration(node, insideModule);
  6451. } else {
  6452. this.unexpected();
  6453. }
  6454. }
  6455. flowParseDeclareVariable(node) {
  6456. this.next();
  6457. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  6458. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  6459. this.semicolon();
  6460. return this.finishNode(node, "DeclareVariable");
  6461. }
  6462. flowParseDeclareModule(node) {
  6463. this.scope.enter(0);
  6464. if (this.match(133)) {
  6465. node.id = super.parseExprAtom();
  6466. } else {
  6467. node.id = this.parseIdentifier();
  6468. }
  6469. const bodyNode = node.body = this.startNode();
  6470. const body = bodyNode.body = [];
  6471. this.expect(5);
  6472. while (!this.match(8)) {
  6473. let bodyNode = this.startNode();
  6474. if (this.match(83)) {
  6475. this.next();
  6476. if (!this.isContextual(130) && !this.match(87)) {
  6477. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  6478. }
  6479. super.parseImport(bodyNode);
  6480. } else {
  6481. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  6482. bodyNode = this.flowParseDeclare(bodyNode, true);
  6483. }
  6484. body.push(bodyNode);
  6485. }
  6486. this.scope.exit();
  6487. this.expect(8);
  6488. this.finishNode(bodyNode, "BlockStatement");
  6489. let kind = null;
  6490. let hasModuleExport = false;
  6491. body.forEach(bodyElement => {
  6492. if (isEsModuleType(bodyElement)) {
  6493. if (kind === "CommonJS") {
  6494. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6495. }
  6496. kind = "ES";
  6497. } else if (bodyElement.type === "DeclareModuleExports") {
  6498. if (hasModuleExport) {
  6499. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  6500. }
  6501. if (kind === "ES") {
  6502. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6503. }
  6504. kind = "CommonJS";
  6505. hasModuleExport = true;
  6506. }
  6507. });
  6508. node.kind = kind || "CommonJS";
  6509. return this.finishNode(node, "DeclareModule");
  6510. }
  6511. flowParseDeclareExportDeclaration(node, insideModule) {
  6512. this.expect(82);
  6513. if (this.eat(65)) {
  6514. if (this.match(68) || this.match(80)) {
  6515. node.declaration = this.flowParseDeclare(this.startNode());
  6516. } else {
  6517. node.declaration = this.flowParseType();
  6518. this.semicolon();
  6519. }
  6520. node.default = true;
  6521. return this.finishNode(node, "DeclareExportDeclaration");
  6522. } else {
  6523. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  6524. const label = this.state.value;
  6525. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  6526. unsupportedExportKind: label,
  6527. suggestion: exportSuggestions[label]
  6528. });
  6529. }
  6530. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  6531. node.declaration = this.flowParseDeclare(this.startNode());
  6532. node.default = false;
  6533. return this.finishNode(node, "DeclareExportDeclaration");
  6534. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  6535. node = this.parseExport(node, null);
  6536. if (node.type === "ExportNamedDeclaration") {
  6537. node.type = "ExportDeclaration";
  6538. node.default = false;
  6539. delete node.exportKind;
  6540. }
  6541. node.type = "Declare" + node.type;
  6542. return node;
  6543. }
  6544. }
  6545. this.unexpected();
  6546. }
  6547. flowParseDeclareModuleExports(node) {
  6548. this.next();
  6549. this.expectContextual(111);
  6550. node.typeAnnotation = this.flowParseTypeAnnotation();
  6551. this.semicolon();
  6552. return this.finishNode(node, "DeclareModuleExports");
  6553. }
  6554. flowParseDeclareTypeAlias(node) {
  6555. this.next();
  6556. const finished = this.flowParseTypeAlias(node);
  6557. finished.type = "DeclareTypeAlias";
  6558. return finished;
  6559. }
  6560. flowParseDeclareOpaqueType(node) {
  6561. this.next();
  6562. const finished = this.flowParseOpaqueType(node, true);
  6563. finished.type = "DeclareOpaqueType";
  6564. return finished;
  6565. }
  6566. flowParseDeclareInterface(node) {
  6567. this.next();
  6568. this.flowParseInterfaceish(node, false);
  6569. return this.finishNode(node, "DeclareInterface");
  6570. }
  6571. flowParseInterfaceish(node, isClass) {
  6572. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  6573. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  6574. if (this.match(47)) {
  6575. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6576. } else {
  6577. node.typeParameters = null;
  6578. }
  6579. node.extends = [];
  6580. if (this.eat(81)) {
  6581. do {
  6582. node.extends.push(this.flowParseInterfaceExtends());
  6583. } while (!isClass && this.eat(12));
  6584. }
  6585. if (isClass) {
  6586. node.implements = [];
  6587. node.mixins = [];
  6588. if (this.eatContextual(117)) {
  6589. do {
  6590. node.mixins.push(this.flowParseInterfaceExtends());
  6591. } while (this.eat(12));
  6592. }
  6593. if (this.eatContextual(113)) {
  6594. do {
  6595. node.implements.push(this.flowParseInterfaceExtends());
  6596. } while (this.eat(12));
  6597. }
  6598. }
  6599. node.body = this.flowParseObjectType({
  6600. allowStatic: isClass,
  6601. allowExact: false,
  6602. allowSpread: false,
  6603. allowProto: isClass,
  6604. allowInexact: false
  6605. });
  6606. }
  6607. flowParseInterfaceExtends() {
  6608. const node = this.startNode();
  6609. node.id = this.flowParseQualifiedTypeIdentifier();
  6610. if (this.match(47)) {
  6611. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6612. } else {
  6613. node.typeParameters = null;
  6614. }
  6615. return this.finishNode(node, "InterfaceExtends");
  6616. }
  6617. flowParseInterface(node) {
  6618. this.flowParseInterfaceish(node, false);
  6619. return this.finishNode(node, "InterfaceDeclaration");
  6620. }
  6621. checkNotUnderscore(word) {
  6622. if (word === "_") {
  6623. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  6624. }
  6625. }
  6626. checkReservedType(word, startLoc, declaration) {
  6627. if (!reservedTypes.has(word)) return;
  6628. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  6629. reservedType: word
  6630. });
  6631. }
  6632. flowParseRestrictedIdentifier(liberal, declaration) {
  6633. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  6634. return this.parseIdentifier(liberal);
  6635. }
  6636. flowParseTypeAlias(node) {
  6637. node.id = this.flowParseRestrictedIdentifier(false, true);
  6638. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6639. if (this.match(47)) {
  6640. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6641. } else {
  6642. node.typeParameters = null;
  6643. }
  6644. node.right = this.flowParseTypeInitialiser(29);
  6645. this.semicolon();
  6646. return this.finishNode(node, "TypeAlias");
  6647. }
  6648. flowParseOpaqueType(node, declare) {
  6649. this.expectContextual(130);
  6650. node.id = this.flowParseRestrictedIdentifier(true, true);
  6651. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6652. if (this.match(47)) {
  6653. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6654. } else {
  6655. node.typeParameters = null;
  6656. }
  6657. node.supertype = null;
  6658. if (this.match(14)) {
  6659. node.supertype = this.flowParseTypeInitialiser(14);
  6660. }
  6661. node.impltype = null;
  6662. if (!declare) {
  6663. node.impltype = this.flowParseTypeInitialiser(29);
  6664. }
  6665. this.semicolon();
  6666. return this.finishNode(node, "OpaqueType");
  6667. }
  6668. flowParseTypeParameter(requireDefault = false) {
  6669. const nodeStartLoc = this.state.startLoc;
  6670. const node = this.startNode();
  6671. const variance = this.flowParseVariance();
  6672. const ident = this.flowParseTypeAnnotatableIdentifier();
  6673. node.name = ident.name;
  6674. node.variance = variance;
  6675. node.bound = ident.typeAnnotation;
  6676. if (this.match(29)) {
  6677. this.eat(29);
  6678. node.default = this.flowParseType();
  6679. } else {
  6680. if (requireDefault) {
  6681. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  6682. }
  6683. }
  6684. return this.finishNode(node, "TypeParameter");
  6685. }
  6686. flowParseTypeParameterDeclaration() {
  6687. const oldInType = this.state.inType;
  6688. const node = this.startNode();
  6689. node.params = [];
  6690. this.state.inType = true;
  6691. if (this.match(47) || this.match(142)) {
  6692. this.next();
  6693. } else {
  6694. this.unexpected();
  6695. }
  6696. let defaultRequired = false;
  6697. do {
  6698. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  6699. node.params.push(typeParameter);
  6700. if (typeParameter.default) {
  6701. defaultRequired = true;
  6702. }
  6703. if (!this.match(48)) {
  6704. this.expect(12);
  6705. }
  6706. } while (!this.match(48));
  6707. this.expect(48);
  6708. this.state.inType = oldInType;
  6709. return this.finishNode(node, "TypeParameterDeclaration");
  6710. }
  6711. flowParseTypeParameterInstantiation() {
  6712. const node = this.startNode();
  6713. const oldInType = this.state.inType;
  6714. node.params = [];
  6715. this.state.inType = true;
  6716. this.expect(47);
  6717. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6718. this.state.noAnonFunctionType = false;
  6719. while (!this.match(48)) {
  6720. node.params.push(this.flowParseType());
  6721. if (!this.match(48)) {
  6722. this.expect(12);
  6723. }
  6724. }
  6725. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6726. this.expect(48);
  6727. this.state.inType = oldInType;
  6728. return this.finishNode(node, "TypeParameterInstantiation");
  6729. }
  6730. flowParseTypeParameterInstantiationCallOrNew() {
  6731. const node = this.startNode();
  6732. const oldInType = this.state.inType;
  6733. node.params = [];
  6734. this.state.inType = true;
  6735. this.expect(47);
  6736. while (!this.match(48)) {
  6737. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  6738. if (!this.match(48)) {
  6739. this.expect(12);
  6740. }
  6741. }
  6742. this.expect(48);
  6743. this.state.inType = oldInType;
  6744. return this.finishNode(node, "TypeParameterInstantiation");
  6745. }
  6746. flowParseInterfaceType() {
  6747. const node = this.startNode();
  6748. this.expectContextual(129);
  6749. node.extends = [];
  6750. if (this.eat(81)) {
  6751. do {
  6752. node.extends.push(this.flowParseInterfaceExtends());
  6753. } while (this.eat(12));
  6754. }
  6755. node.body = this.flowParseObjectType({
  6756. allowStatic: false,
  6757. allowExact: false,
  6758. allowSpread: false,
  6759. allowProto: false,
  6760. allowInexact: false
  6761. });
  6762. return this.finishNode(node, "InterfaceTypeAnnotation");
  6763. }
  6764. flowParseObjectPropertyKey() {
  6765. return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
  6766. }
  6767. flowParseObjectTypeIndexer(node, isStatic, variance) {
  6768. node.static = isStatic;
  6769. if (this.lookahead().type === 14) {
  6770. node.id = this.flowParseObjectPropertyKey();
  6771. node.key = this.flowParseTypeInitialiser();
  6772. } else {
  6773. node.id = null;
  6774. node.key = this.flowParseType();
  6775. }
  6776. this.expect(3);
  6777. node.value = this.flowParseTypeInitialiser();
  6778. node.variance = variance;
  6779. return this.finishNode(node, "ObjectTypeIndexer");
  6780. }
  6781. flowParseObjectTypeInternalSlot(node, isStatic) {
  6782. node.static = isStatic;
  6783. node.id = this.flowParseObjectPropertyKey();
  6784. this.expect(3);
  6785. this.expect(3);
  6786. if (this.match(47) || this.match(10)) {
  6787. node.method = true;
  6788. node.optional = false;
  6789. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6790. } else {
  6791. node.method = false;
  6792. if (this.eat(17)) {
  6793. node.optional = true;
  6794. }
  6795. node.value = this.flowParseTypeInitialiser();
  6796. }
  6797. return this.finishNode(node, "ObjectTypeInternalSlot");
  6798. }
  6799. flowParseObjectTypeMethodish(node) {
  6800. node.params = [];
  6801. node.rest = null;
  6802. node.typeParameters = null;
  6803. node.this = null;
  6804. if (this.match(47)) {
  6805. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6806. }
  6807. this.expect(10);
  6808. if (this.match(78)) {
  6809. node.this = this.flowParseFunctionTypeParam(true);
  6810. node.this.name = null;
  6811. if (!this.match(11)) {
  6812. this.expect(12);
  6813. }
  6814. }
  6815. while (!this.match(11) && !this.match(21)) {
  6816. node.params.push(this.flowParseFunctionTypeParam(false));
  6817. if (!this.match(11)) {
  6818. this.expect(12);
  6819. }
  6820. }
  6821. if (this.eat(21)) {
  6822. node.rest = this.flowParseFunctionTypeParam(false);
  6823. }
  6824. this.expect(11);
  6825. node.returnType = this.flowParseTypeInitialiser();
  6826. return this.finishNode(node, "FunctionTypeAnnotation");
  6827. }
  6828. flowParseObjectTypeCallProperty(node, isStatic) {
  6829. const valueNode = this.startNode();
  6830. node.static = isStatic;
  6831. node.value = this.flowParseObjectTypeMethodish(valueNode);
  6832. return this.finishNode(node, "ObjectTypeCallProperty");
  6833. }
  6834. flowParseObjectType({
  6835. allowStatic,
  6836. allowExact,
  6837. allowSpread,
  6838. allowProto,
  6839. allowInexact
  6840. }) {
  6841. const oldInType = this.state.inType;
  6842. this.state.inType = true;
  6843. const nodeStart = this.startNode();
  6844. nodeStart.callProperties = [];
  6845. nodeStart.properties = [];
  6846. nodeStart.indexers = [];
  6847. nodeStart.internalSlots = [];
  6848. let endDelim;
  6849. let exact;
  6850. let inexact = false;
  6851. if (allowExact && this.match(6)) {
  6852. this.expect(6);
  6853. endDelim = 9;
  6854. exact = true;
  6855. } else {
  6856. this.expect(5);
  6857. endDelim = 8;
  6858. exact = false;
  6859. }
  6860. nodeStart.exact = exact;
  6861. while (!this.match(endDelim)) {
  6862. let isStatic = false;
  6863. let protoStartLoc = null;
  6864. let inexactStartLoc = null;
  6865. const node = this.startNode();
  6866. if (allowProto && this.isContextual(118)) {
  6867. const lookahead = this.lookahead();
  6868. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6869. this.next();
  6870. protoStartLoc = this.state.startLoc;
  6871. allowStatic = false;
  6872. }
  6873. }
  6874. if (allowStatic && this.isContextual(106)) {
  6875. const lookahead = this.lookahead();
  6876. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6877. this.next();
  6878. isStatic = true;
  6879. }
  6880. }
  6881. const variance = this.flowParseVariance();
  6882. if (this.eat(0)) {
  6883. if (protoStartLoc != null) {
  6884. this.unexpected(protoStartLoc);
  6885. }
  6886. if (this.eat(0)) {
  6887. if (variance) {
  6888. this.unexpected(variance.loc.start);
  6889. }
  6890. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  6891. } else {
  6892. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  6893. }
  6894. } else if (this.match(10) || this.match(47)) {
  6895. if (protoStartLoc != null) {
  6896. this.unexpected(protoStartLoc);
  6897. }
  6898. if (variance) {
  6899. this.unexpected(variance.loc.start);
  6900. }
  6901. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  6902. } else {
  6903. let kind = "init";
  6904. if (this.isContextual(99) || this.isContextual(104)) {
  6905. const lookahead = this.lookahead();
  6906. if (tokenIsLiteralPropertyName(lookahead.type)) {
  6907. kind = this.state.value;
  6908. this.next();
  6909. }
  6910. }
  6911. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  6912. if (propOrInexact === null) {
  6913. inexact = true;
  6914. inexactStartLoc = this.state.lastTokStartLoc;
  6915. } else {
  6916. nodeStart.properties.push(propOrInexact);
  6917. }
  6918. }
  6919. this.flowObjectTypeSemicolon();
  6920. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  6921. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  6922. }
  6923. }
  6924. this.expect(endDelim);
  6925. if (allowSpread) {
  6926. nodeStart.inexact = inexact;
  6927. }
  6928. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  6929. this.state.inType = oldInType;
  6930. return out;
  6931. }
  6932. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  6933. if (this.eat(21)) {
  6934. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  6935. if (isInexactToken) {
  6936. if (!allowSpread) {
  6937. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  6938. } else if (!allowInexact) {
  6939. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  6940. }
  6941. if (variance) {
  6942. this.raise(FlowErrors.InexactVariance, variance);
  6943. }
  6944. return null;
  6945. }
  6946. if (!allowSpread) {
  6947. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  6948. }
  6949. if (protoStartLoc != null) {
  6950. this.unexpected(protoStartLoc);
  6951. }
  6952. if (variance) {
  6953. this.raise(FlowErrors.SpreadVariance, variance);
  6954. }
  6955. node.argument = this.flowParseType();
  6956. return this.finishNode(node, "ObjectTypeSpreadProperty");
  6957. } else {
  6958. node.key = this.flowParseObjectPropertyKey();
  6959. node.static = isStatic;
  6960. node.proto = protoStartLoc != null;
  6961. node.kind = kind;
  6962. let optional = false;
  6963. if (this.match(47) || this.match(10)) {
  6964. node.method = true;
  6965. if (protoStartLoc != null) {
  6966. this.unexpected(protoStartLoc);
  6967. }
  6968. if (variance) {
  6969. this.unexpected(variance.loc.start);
  6970. }
  6971. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6972. if (kind === "get" || kind === "set") {
  6973. this.flowCheckGetterSetterParams(node);
  6974. }
  6975. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  6976. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  6977. }
  6978. } else {
  6979. if (kind !== "init") this.unexpected();
  6980. node.method = false;
  6981. if (this.eat(17)) {
  6982. optional = true;
  6983. }
  6984. node.value = this.flowParseTypeInitialiser();
  6985. node.variance = variance;
  6986. }
  6987. node.optional = optional;
  6988. return this.finishNode(node, "ObjectTypeProperty");
  6989. }
  6990. }
  6991. flowCheckGetterSetterParams(property) {
  6992. const paramCount = property.kind === "get" ? 0 : 1;
  6993. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  6994. if (property.value.this) {
  6995. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  6996. }
  6997. if (length !== paramCount) {
  6998. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  6999. }
  7000. if (property.kind === "set" && property.value.rest) {
  7001. this.raise(Errors.BadSetterRestParameter, property);
  7002. }
  7003. }
  7004. flowObjectTypeSemicolon() {
  7005. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  7006. this.unexpected();
  7007. }
  7008. }
  7009. flowParseQualifiedTypeIdentifier(startLoc, id) {
  7010. var _startLoc;
  7011. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  7012. let node = id || this.flowParseRestrictedIdentifier(true);
  7013. while (this.eat(16)) {
  7014. const node2 = this.startNodeAt(startLoc);
  7015. node2.qualification = node;
  7016. node2.id = this.flowParseRestrictedIdentifier(true);
  7017. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  7018. }
  7019. return node;
  7020. }
  7021. flowParseGenericType(startLoc, id) {
  7022. const node = this.startNodeAt(startLoc);
  7023. node.typeParameters = null;
  7024. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  7025. if (this.match(47)) {
  7026. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7027. }
  7028. return this.finishNode(node, "GenericTypeAnnotation");
  7029. }
  7030. flowParseTypeofType() {
  7031. const node = this.startNode();
  7032. this.expect(87);
  7033. node.argument = this.flowParsePrimaryType();
  7034. return this.finishNode(node, "TypeofTypeAnnotation");
  7035. }
  7036. flowParseTupleType() {
  7037. const node = this.startNode();
  7038. node.types = [];
  7039. this.expect(0);
  7040. while (this.state.pos < this.length && !this.match(3)) {
  7041. node.types.push(this.flowParseType());
  7042. if (this.match(3)) break;
  7043. this.expect(12);
  7044. }
  7045. this.expect(3);
  7046. return this.finishNode(node, "TupleTypeAnnotation");
  7047. }
  7048. flowParseFunctionTypeParam(first) {
  7049. let name = null;
  7050. let optional = false;
  7051. let typeAnnotation = null;
  7052. const node = this.startNode();
  7053. const lh = this.lookahead();
  7054. const isThis = this.state.type === 78;
  7055. if (lh.type === 14 || lh.type === 17) {
  7056. if (isThis && !first) {
  7057. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  7058. }
  7059. name = this.parseIdentifier(isThis);
  7060. if (this.eat(17)) {
  7061. optional = true;
  7062. if (isThis) {
  7063. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  7064. }
  7065. }
  7066. typeAnnotation = this.flowParseTypeInitialiser();
  7067. } else {
  7068. typeAnnotation = this.flowParseType();
  7069. }
  7070. node.name = name;
  7071. node.optional = optional;
  7072. node.typeAnnotation = typeAnnotation;
  7073. return this.finishNode(node, "FunctionTypeParam");
  7074. }
  7075. reinterpretTypeAsFunctionTypeParam(type) {
  7076. const node = this.startNodeAt(type.loc.start);
  7077. node.name = null;
  7078. node.optional = false;
  7079. node.typeAnnotation = type;
  7080. return this.finishNode(node, "FunctionTypeParam");
  7081. }
  7082. flowParseFunctionTypeParams(params = []) {
  7083. let rest = null;
  7084. let _this = null;
  7085. if (this.match(78)) {
  7086. _this = this.flowParseFunctionTypeParam(true);
  7087. _this.name = null;
  7088. if (!this.match(11)) {
  7089. this.expect(12);
  7090. }
  7091. }
  7092. while (!this.match(11) && !this.match(21)) {
  7093. params.push(this.flowParseFunctionTypeParam(false));
  7094. if (!this.match(11)) {
  7095. this.expect(12);
  7096. }
  7097. }
  7098. if (this.eat(21)) {
  7099. rest = this.flowParseFunctionTypeParam(false);
  7100. }
  7101. return {
  7102. params,
  7103. rest,
  7104. _this
  7105. };
  7106. }
  7107. flowIdentToTypeAnnotation(startLoc, node, id) {
  7108. switch (id.name) {
  7109. case "any":
  7110. return this.finishNode(node, "AnyTypeAnnotation");
  7111. case "bool":
  7112. case "boolean":
  7113. return this.finishNode(node, "BooleanTypeAnnotation");
  7114. case "mixed":
  7115. return this.finishNode(node, "MixedTypeAnnotation");
  7116. case "empty":
  7117. return this.finishNode(node, "EmptyTypeAnnotation");
  7118. case "number":
  7119. return this.finishNode(node, "NumberTypeAnnotation");
  7120. case "string":
  7121. return this.finishNode(node, "StringTypeAnnotation");
  7122. case "symbol":
  7123. return this.finishNode(node, "SymbolTypeAnnotation");
  7124. default:
  7125. this.checkNotUnderscore(id.name);
  7126. return this.flowParseGenericType(startLoc, id);
  7127. }
  7128. }
  7129. flowParsePrimaryType() {
  7130. const startLoc = this.state.startLoc;
  7131. const node = this.startNode();
  7132. let tmp;
  7133. let type;
  7134. let isGroupedType = false;
  7135. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7136. switch (this.state.type) {
  7137. case 5:
  7138. return this.flowParseObjectType({
  7139. allowStatic: false,
  7140. allowExact: false,
  7141. allowSpread: true,
  7142. allowProto: false,
  7143. allowInexact: true
  7144. });
  7145. case 6:
  7146. return this.flowParseObjectType({
  7147. allowStatic: false,
  7148. allowExact: true,
  7149. allowSpread: true,
  7150. allowProto: false,
  7151. allowInexact: false
  7152. });
  7153. case 0:
  7154. this.state.noAnonFunctionType = false;
  7155. type = this.flowParseTupleType();
  7156. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7157. return type;
  7158. case 47:
  7159. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7160. this.expect(10);
  7161. tmp = this.flowParseFunctionTypeParams();
  7162. node.params = tmp.params;
  7163. node.rest = tmp.rest;
  7164. node.this = tmp._this;
  7165. this.expect(11);
  7166. this.expect(19);
  7167. node.returnType = this.flowParseType();
  7168. return this.finishNode(node, "FunctionTypeAnnotation");
  7169. case 10:
  7170. this.next();
  7171. if (!this.match(11) && !this.match(21)) {
  7172. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  7173. const token = this.lookahead().type;
  7174. isGroupedType = token !== 17 && token !== 14;
  7175. } else {
  7176. isGroupedType = true;
  7177. }
  7178. }
  7179. if (isGroupedType) {
  7180. this.state.noAnonFunctionType = false;
  7181. type = this.flowParseType();
  7182. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7183. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  7184. this.expect(11);
  7185. return type;
  7186. } else {
  7187. this.eat(12);
  7188. }
  7189. }
  7190. if (type) {
  7191. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  7192. } else {
  7193. tmp = this.flowParseFunctionTypeParams();
  7194. }
  7195. node.params = tmp.params;
  7196. node.rest = tmp.rest;
  7197. node.this = tmp._this;
  7198. this.expect(11);
  7199. this.expect(19);
  7200. node.returnType = this.flowParseType();
  7201. node.typeParameters = null;
  7202. return this.finishNode(node, "FunctionTypeAnnotation");
  7203. case 133:
  7204. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  7205. case 85:
  7206. case 86:
  7207. node.value = this.match(85);
  7208. this.next();
  7209. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  7210. case 53:
  7211. if (this.state.value === "-") {
  7212. this.next();
  7213. if (this.match(134)) {
  7214. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  7215. }
  7216. if (this.match(135)) {
  7217. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  7218. }
  7219. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  7220. }
  7221. this.unexpected();
  7222. return;
  7223. case 134:
  7224. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  7225. case 135:
  7226. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  7227. case 88:
  7228. this.next();
  7229. return this.finishNode(node, "VoidTypeAnnotation");
  7230. case 84:
  7231. this.next();
  7232. return this.finishNode(node, "NullLiteralTypeAnnotation");
  7233. case 78:
  7234. this.next();
  7235. return this.finishNode(node, "ThisTypeAnnotation");
  7236. case 55:
  7237. this.next();
  7238. return this.finishNode(node, "ExistsTypeAnnotation");
  7239. case 87:
  7240. return this.flowParseTypeofType();
  7241. default:
  7242. if (tokenIsKeyword(this.state.type)) {
  7243. const label = tokenLabelName(this.state.type);
  7244. this.next();
  7245. return super.createIdentifier(node, label);
  7246. } else if (tokenIsIdentifier(this.state.type)) {
  7247. if (this.isContextual(129)) {
  7248. return this.flowParseInterfaceType();
  7249. }
  7250. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  7251. }
  7252. }
  7253. this.unexpected();
  7254. }
  7255. flowParsePostfixType() {
  7256. const startLoc = this.state.startLoc;
  7257. let type = this.flowParsePrimaryType();
  7258. let seenOptionalIndexedAccess = false;
  7259. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  7260. const node = this.startNodeAt(startLoc);
  7261. const optional = this.eat(18);
  7262. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  7263. this.expect(0);
  7264. if (!optional && this.match(3)) {
  7265. node.elementType = type;
  7266. this.next();
  7267. type = this.finishNode(node, "ArrayTypeAnnotation");
  7268. } else {
  7269. node.objectType = type;
  7270. node.indexType = this.flowParseType();
  7271. this.expect(3);
  7272. if (seenOptionalIndexedAccess) {
  7273. node.optional = optional;
  7274. type = this.finishNode(node, "OptionalIndexedAccessType");
  7275. } else {
  7276. type = this.finishNode(node, "IndexedAccessType");
  7277. }
  7278. }
  7279. }
  7280. return type;
  7281. }
  7282. flowParsePrefixType() {
  7283. const node = this.startNode();
  7284. if (this.eat(17)) {
  7285. node.typeAnnotation = this.flowParsePrefixType();
  7286. return this.finishNode(node, "NullableTypeAnnotation");
  7287. } else {
  7288. return this.flowParsePostfixType();
  7289. }
  7290. }
  7291. flowParseAnonFunctionWithoutParens() {
  7292. const param = this.flowParsePrefixType();
  7293. if (!this.state.noAnonFunctionType && this.eat(19)) {
  7294. const node = this.startNodeAt(param.loc.start);
  7295. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  7296. node.rest = null;
  7297. node.this = null;
  7298. node.returnType = this.flowParseType();
  7299. node.typeParameters = null;
  7300. return this.finishNode(node, "FunctionTypeAnnotation");
  7301. }
  7302. return param;
  7303. }
  7304. flowParseIntersectionType() {
  7305. const node = this.startNode();
  7306. this.eat(45);
  7307. const type = this.flowParseAnonFunctionWithoutParens();
  7308. node.types = [type];
  7309. while (this.eat(45)) {
  7310. node.types.push(this.flowParseAnonFunctionWithoutParens());
  7311. }
  7312. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  7313. }
  7314. flowParseUnionType() {
  7315. const node = this.startNode();
  7316. this.eat(43);
  7317. const type = this.flowParseIntersectionType();
  7318. node.types = [type];
  7319. while (this.eat(43)) {
  7320. node.types.push(this.flowParseIntersectionType());
  7321. }
  7322. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  7323. }
  7324. flowParseType() {
  7325. const oldInType = this.state.inType;
  7326. this.state.inType = true;
  7327. const type = this.flowParseUnionType();
  7328. this.state.inType = oldInType;
  7329. return type;
  7330. }
  7331. flowParseTypeOrImplicitInstantiation() {
  7332. if (this.state.type === 132 && this.state.value === "_") {
  7333. const startLoc = this.state.startLoc;
  7334. const node = this.parseIdentifier();
  7335. return this.flowParseGenericType(startLoc, node);
  7336. } else {
  7337. return this.flowParseType();
  7338. }
  7339. }
  7340. flowParseTypeAnnotation() {
  7341. const node = this.startNode();
  7342. node.typeAnnotation = this.flowParseTypeInitialiser();
  7343. return this.finishNode(node, "TypeAnnotation");
  7344. }
  7345. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  7346. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  7347. if (this.match(14)) {
  7348. ident.typeAnnotation = this.flowParseTypeAnnotation();
  7349. this.resetEndLocation(ident);
  7350. }
  7351. return ident;
  7352. }
  7353. typeCastToParameter(node) {
  7354. node.expression.typeAnnotation = node.typeAnnotation;
  7355. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  7356. return node.expression;
  7357. }
  7358. flowParseVariance() {
  7359. let variance = null;
  7360. if (this.match(53)) {
  7361. variance = this.startNode();
  7362. if (this.state.value === "+") {
  7363. variance.kind = "plus";
  7364. } else {
  7365. variance.kind = "minus";
  7366. }
  7367. this.next();
  7368. return this.finishNode(variance, "Variance");
  7369. }
  7370. return variance;
  7371. }
  7372. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  7373. if (allowExpressionBody) {
  7374. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  7375. return;
  7376. }
  7377. super.parseFunctionBody(node, false, isMethod);
  7378. }
  7379. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  7380. if (this.match(14)) {
  7381. const typeNode = this.startNode();
  7382. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  7383. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  7384. }
  7385. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  7386. }
  7387. parseStatementLike(flags) {
  7388. if (this.state.strict && this.isContextual(129)) {
  7389. const lookahead = this.lookahead();
  7390. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  7391. const node = this.startNode();
  7392. this.next();
  7393. return this.flowParseInterface(node);
  7394. }
  7395. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7396. const node = this.startNode();
  7397. this.next();
  7398. return this.flowParseEnumDeclaration(node);
  7399. }
  7400. const stmt = super.parseStatementLike(flags);
  7401. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  7402. this.flowPragma = null;
  7403. }
  7404. return stmt;
  7405. }
  7406. parseExpressionStatement(node, expr, decorators) {
  7407. if (expr.type === "Identifier") {
  7408. if (expr.name === "declare") {
  7409. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  7410. return this.flowParseDeclare(node);
  7411. }
  7412. } else if (tokenIsIdentifier(this.state.type)) {
  7413. if (expr.name === "interface") {
  7414. return this.flowParseInterface(node);
  7415. } else if (expr.name === "type") {
  7416. return this.flowParseTypeAlias(node);
  7417. } else if (expr.name === "opaque") {
  7418. return this.flowParseOpaqueType(node, false);
  7419. }
  7420. }
  7421. }
  7422. return super.parseExpressionStatement(node, expr, decorators);
  7423. }
  7424. shouldParseExportDeclaration() {
  7425. const {
  7426. type
  7427. } = this.state;
  7428. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7429. return !this.state.containsEsc;
  7430. }
  7431. return super.shouldParseExportDeclaration();
  7432. }
  7433. isExportDefaultSpecifier() {
  7434. const {
  7435. type
  7436. } = this.state;
  7437. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7438. return this.state.containsEsc;
  7439. }
  7440. return super.isExportDefaultSpecifier();
  7441. }
  7442. parseExportDefaultExpression() {
  7443. if (this.shouldParseEnums() && this.isContextual(126)) {
  7444. const node = this.startNode();
  7445. this.next();
  7446. return this.flowParseEnumDeclaration(node);
  7447. }
  7448. return super.parseExportDefaultExpression();
  7449. }
  7450. parseConditional(expr, startLoc, refExpressionErrors) {
  7451. if (!this.match(17)) return expr;
  7452. if (this.state.maybeInArrowParameters) {
  7453. const nextCh = this.lookaheadCharCode();
  7454. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  7455. this.setOptionalParametersError(refExpressionErrors);
  7456. return expr;
  7457. }
  7458. }
  7459. this.expect(17);
  7460. const state = this.state.clone();
  7461. const originalNoArrowAt = this.state.noArrowAt;
  7462. const node = this.startNodeAt(startLoc);
  7463. let {
  7464. consequent,
  7465. failed
  7466. } = this.tryParseConditionalConsequent();
  7467. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7468. if (failed || invalid.length > 0) {
  7469. const noArrowAt = [...originalNoArrowAt];
  7470. if (invalid.length > 0) {
  7471. this.state = state;
  7472. this.state.noArrowAt = noArrowAt;
  7473. for (let i = 0; i < invalid.length; i++) {
  7474. noArrowAt.push(invalid[i].start);
  7475. }
  7476. ({
  7477. consequent,
  7478. failed
  7479. } = this.tryParseConditionalConsequent());
  7480. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7481. }
  7482. if (failed && valid.length > 1) {
  7483. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  7484. }
  7485. if (failed && valid.length === 1) {
  7486. this.state = state;
  7487. noArrowAt.push(valid[0].start);
  7488. this.state.noArrowAt = noArrowAt;
  7489. ({
  7490. consequent,
  7491. failed
  7492. } = this.tryParseConditionalConsequent());
  7493. }
  7494. }
  7495. this.getArrowLikeExpressions(consequent, true);
  7496. this.state.noArrowAt = originalNoArrowAt;
  7497. this.expect(14);
  7498. node.test = expr;
  7499. node.consequent = consequent;
  7500. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  7501. return this.finishNode(node, "ConditionalExpression");
  7502. }
  7503. tryParseConditionalConsequent() {
  7504. this.state.noArrowParamsConversionAt.push(this.state.start);
  7505. const consequent = this.parseMaybeAssignAllowIn();
  7506. const failed = !this.match(14);
  7507. this.state.noArrowParamsConversionAt.pop();
  7508. return {
  7509. consequent,
  7510. failed
  7511. };
  7512. }
  7513. getArrowLikeExpressions(node, disallowInvalid) {
  7514. const stack = [node];
  7515. const arrows = [];
  7516. while (stack.length !== 0) {
  7517. const node = stack.pop();
  7518. if (node.type === "ArrowFunctionExpression") {
  7519. if (node.typeParameters || !node.returnType) {
  7520. this.finishArrowValidation(node);
  7521. } else {
  7522. arrows.push(node);
  7523. }
  7524. stack.push(node.body);
  7525. } else if (node.type === "ConditionalExpression") {
  7526. stack.push(node.consequent);
  7527. stack.push(node.alternate);
  7528. }
  7529. }
  7530. if (disallowInvalid) {
  7531. arrows.forEach(node => this.finishArrowValidation(node));
  7532. return [arrows, []];
  7533. }
  7534. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  7535. }
  7536. finishArrowValidation(node) {
  7537. var _node$extra;
  7538. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  7539. this.scope.enter(2 | 4);
  7540. super.checkParams(node, false, true);
  7541. this.scope.exit();
  7542. }
  7543. forwardNoArrowParamsConversionAt(node, parse) {
  7544. let result;
  7545. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  7546. this.state.noArrowParamsConversionAt.push(this.state.start);
  7547. result = parse();
  7548. this.state.noArrowParamsConversionAt.pop();
  7549. } else {
  7550. result = parse();
  7551. }
  7552. return result;
  7553. }
  7554. parseParenItem(node, startLoc) {
  7555. node = super.parseParenItem(node, startLoc);
  7556. if (this.eat(17)) {
  7557. node.optional = true;
  7558. this.resetEndLocation(node);
  7559. }
  7560. if (this.match(14)) {
  7561. const typeCastNode = this.startNodeAt(startLoc);
  7562. typeCastNode.expression = node;
  7563. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  7564. return this.finishNode(typeCastNode, "TypeCastExpression");
  7565. }
  7566. return node;
  7567. }
  7568. assertModuleNodeAllowed(node) {
  7569. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  7570. return;
  7571. }
  7572. super.assertModuleNodeAllowed(node);
  7573. }
  7574. parseExportDeclaration(node) {
  7575. if (this.isContextual(130)) {
  7576. node.exportKind = "type";
  7577. const declarationNode = this.startNode();
  7578. this.next();
  7579. if (this.match(5)) {
  7580. node.specifiers = this.parseExportSpecifiers(true);
  7581. super.parseExportFrom(node);
  7582. return null;
  7583. } else {
  7584. return this.flowParseTypeAlias(declarationNode);
  7585. }
  7586. } else if (this.isContextual(131)) {
  7587. node.exportKind = "type";
  7588. const declarationNode = this.startNode();
  7589. this.next();
  7590. return this.flowParseOpaqueType(declarationNode, false);
  7591. } else if (this.isContextual(129)) {
  7592. node.exportKind = "type";
  7593. const declarationNode = this.startNode();
  7594. this.next();
  7595. return this.flowParseInterface(declarationNode);
  7596. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7597. node.exportKind = "value";
  7598. const declarationNode = this.startNode();
  7599. this.next();
  7600. return this.flowParseEnumDeclaration(declarationNode);
  7601. } else {
  7602. return super.parseExportDeclaration(node);
  7603. }
  7604. }
  7605. eatExportStar(node) {
  7606. if (super.eatExportStar(node)) return true;
  7607. if (this.isContextual(130) && this.lookahead().type === 55) {
  7608. node.exportKind = "type";
  7609. this.next();
  7610. this.next();
  7611. return true;
  7612. }
  7613. return false;
  7614. }
  7615. maybeParseExportNamespaceSpecifier(node) {
  7616. const {
  7617. startLoc
  7618. } = this.state;
  7619. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  7620. if (hasNamespace && node.exportKind === "type") {
  7621. this.unexpected(startLoc);
  7622. }
  7623. return hasNamespace;
  7624. }
  7625. parseClassId(node, isStatement, optionalId) {
  7626. super.parseClassId(node, isStatement, optionalId);
  7627. if (this.match(47)) {
  7628. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7629. }
  7630. }
  7631. parseClassMember(classBody, member, state) {
  7632. const {
  7633. startLoc
  7634. } = this.state;
  7635. if (this.isContextual(125)) {
  7636. if (super.parseClassMemberFromModifier(classBody, member)) {
  7637. return;
  7638. }
  7639. member.declare = true;
  7640. }
  7641. super.parseClassMember(classBody, member, state);
  7642. if (member.declare) {
  7643. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  7644. this.raise(FlowErrors.DeclareClassElement, startLoc);
  7645. } else if (member.value) {
  7646. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  7647. }
  7648. }
  7649. }
  7650. isIterator(word) {
  7651. return word === "iterator" || word === "asyncIterator";
  7652. }
  7653. readIterator() {
  7654. const word = super.readWord1();
  7655. const fullWord = "@@" + word;
  7656. if (!this.isIterator(word) || !this.state.inType) {
  7657. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  7658. identifierName: fullWord
  7659. });
  7660. }
  7661. this.finishToken(132, fullWord);
  7662. }
  7663. getTokenFromCode(code) {
  7664. const next = this.input.charCodeAt(this.state.pos + 1);
  7665. if (code === 123 && next === 124) {
  7666. this.finishOp(6, 2);
  7667. } else if (this.state.inType && (code === 62 || code === 60)) {
  7668. this.finishOp(code === 62 ? 48 : 47, 1);
  7669. } else if (this.state.inType && code === 63) {
  7670. if (next === 46) {
  7671. this.finishOp(18, 2);
  7672. } else {
  7673. this.finishOp(17, 1);
  7674. }
  7675. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  7676. this.state.pos += 2;
  7677. this.readIterator();
  7678. } else {
  7679. super.getTokenFromCode(code);
  7680. }
  7681. }
  7682. isAssignable(node, isBinding) {
  7683. if (node.type === "TypeCastExpression") {
  7684. return this.isAssignable(node.expression, isBinding);
  7685. } else {
  7686. return super.isAssignable(node, isBinding);
  7687. }
  7688. }
  7689. toAssignable(node, isLHS = false) {
  7690. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  7691. node.left = this.typeCastToParameter(node.left);
  7692. }
  7693. super.toAssignable(node, isLHS);
  7694. }
  7695. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  7696. for (let i = 0; i < exprList.length; i++) {
  7697. const expr = exprList[i];
  7698. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  7699. exprList[i] = this.typeCastToParameter(expr);
  7700. }
  7701. }
  7702. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  7703. }
  7704. toReferencedList(exprList, isParenthesizedExpr) {
  7705. for (let i = 0; i < exprList.length; i++) {
  7706. var _expr$extra;
  7707. const expr = exprList[i];
  7708. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  7709. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  7710. }
  7711. }
  7712. return exprList;
  7713. }
  7714. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  7715. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  7716. if (canBePattern && !this.state.maybeInArrowParameters) {
  7717. this.toReferencedList(node.elements);
  7718. }
  7719. return node;
  7720. }
  7721. isValidLVal(type, isParenthesized, binding) {
  7722. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  7723. }
  7724. parseClassProperty(node) {
  7725. if (this.match(14)) {
  7726. node.typeAnnotation = this.flowParseTypeAnnotation();
  7727. }
  7728. return super.parseClassProperty(node);
  7729. }
  7730. parseClassPrivateProperty(node) {
  7731. if (this.match(14)) {
  7732. node.typeAnnotation = this.flowParseTypeAnnotation();
  7733. }
  7734. return super.parseClassPrivateProperty(node);
  7735. }
  7736. isClassMethod() {
  7737. return this.match(47) || super.isClassMethod();
  7738. }
  7739. isClassProperty() {
  7740. return this.match(14) || super.isClassProperty();
  7741. }
  7742. isNonstaticConstructor(method) {
  7743. return !this.match(14) && super.isNonstaticConstructor(method);
  7744. }
  7745. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  7746. if (method.variance) {
  7747. this.unexpected(method.variance.loc.start);
  7748. }
  7749. delete method.variance;
  7750. if (this.match(47)) {
  7751. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7752. }
  7753. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  7754. if (method.params && isConstructor) {
  7755. const params = method.params;
  7756. if (params.length > 0 && this.isThisParam(params[0])) {
  7757. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7758. }
  7759. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  7760. const params = method.value.params;
  7761. if (params.length > 0 && this.isThisParam(params[0])) {
  7762. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7763. }
  7764. }
  7765. }
  7766. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  7767. if (method.variance) {
  7768. this.unexpected(method.variance.loc.start);
  7769. }
  7770. delete method.variance;
  7771. if (this.match(47)) {
  7772. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7773. }
  7774. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  7775. }
  7776. parseClassSuper(node) {
  7777. super.parseClassSuper(node);
  7778. if (node.superClass && this.match(47)) {
  7779. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  7780. }
  7781. if (this.isContextual(113)) {
  7782. this.next();
  7783. const implemented = node.implements = [];
  7784. do {
  7785. const node = this.startNode();
  7786. node.id = this.flowParseRestrictedIdentifier(true);
  7787. if (this.match(47)) {
  7788. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7789. } else {
  7790. node.typeParameters = null;
  7791. }
  7792. implemented.push(this.finishNode(node, "ClassImplements"));
  7793. } while (this.eat(12));
  7794. }
  7795. }
  7796. checkGetterSetterParams(method) {
  7797. super.checkGetterSetterParams(method);
  7798. const params = this.getObjectOrClassMethodParams(method);
  7799. if (params.length > 0) {
  7800. const param = params[0];
  7801. if (this.isThisParam(param) && method.kind === "get") {
  7802. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  7803. } else if (this.isThisParam(param)) {
  7804. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  7805. }
  7806. }
  7807. }
  7808. parsePropertyNamePrefixOperator(node) {
  7809. node.variance = this.flowParseVariance();
  7810. }
  7811. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  7812. if (prop.variance) {
  7813. this.unexpected(prop.variance.loc.start);
  7814. }
  7815. delete prop.variance;
  7816. let typeParameters;
  7817. if (this.match(47) && !isAccessor) {
  7818. typeParameters = this.flowParseTypeParameterDeclaration();
  7819. if (!this.match(10)) this.unexpected();
  7820. }
  7821. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  7822. if (typeParameters) {
  7823. (result.value || result).typeParameters = typeParameters;
  7824. }
  7825. return result;
  7826. }
  7827. parseAssignableListItemTypes(param) {
  7828. if (this.eat(17)) {
  7829. if (param.type !== "Identifier") {
  7830. this.raise(FlowErrors.PatternIsOptional, param);
  7831. }
  7832. if (this.isThisParam(param)) {
  7833. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  7834. }
  7835. param.optional = true;
  7836. }
  7837. if (this.match(14)) {
  7838. param.typeAnnotation = this.flowParseTypeAnnotation();
  7839. } else if (this.isThisParam(param)) {
  7840. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  7841. }
  7842. if (this.match(29) && this.isThisParam(param)) {
  7843. this.raise(FlowErrors.ThisParamNoDefault, param);
  7844. }
  7845. this.resetEndLocation(param);
  7846. return param;
  7847. }
  7848. parseMaybeDefault(startLoc, left) {
  7849. const node = super.parseMaybeDefault(startLoc, left);
  7850. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  7851. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  7852. }
  7853. return node;
  7854. }
  7855. checkImportReflection(node) {
  7856. super.checkImportReflection(node);
  7857. if (node.module && node.importKind !== "value") {
  7858. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  7859. }
  7860. }
  7861. parseImportSpecifierLocal(node, specifier, type) {
  7862. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  7863. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  7864. }
  7865. isPotentialImportPhase(isExport) {
  7866. if (super.isPotentialImportPhase(isExport)) return true;
  7867. if (this.isContextual(130)) {
  7868. if (!isExport) return true;
  7869. const ch = this.lookaheadCharCode();
  7870. return ch === 123 || ch === 42;
  7871. }
  7872. return !isExport && this.isContextual(87);
  7873. }
  7874. applyImportPhase(node, isExport, phase, loc) {
  7875. super.applyImportPhase(node, isExport, phase, loc);
  7876. if (isExport) {
  7877. if (!phase && this.match(65)) {
  7878. return;
  7879. }
  7880. node.exportKind = phase === "type" ? phase : "value";
  7881. } else {
  7882. if (phase === "type" && this.match(55)) this.unexpected();
  7883. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  7884. }
  7885. }
  7886. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  7887. const firstIdent = specifier.imported;
  7888. let specifierTypeKind = null;
  7889. if (firstIdent.type === "Identifier") {
  7890. if (firstIdent.name === "type") {
  7891. specifierTypeKind = "type";
  7892. } else if (firstIdent.name === "typeof") {
  7893. specifierTypeKind = "typeof";
  7894. }
  7895. }
  7896. let isBinding = false;
  7897. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  7898. const as_ident = this.parseIdentifier(true);
  7899. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  7900. specifier.imported = as_ident;
  7901. specifier.importKind = specifierTypeKind;
  7902. specifier.local = cloneIdentifier(as_ident);
  7903. } else {
  7904. specifier.imported = firstIdent;
  7905. specifier.importKind = null;
  7906. specifier.local = this.parseIdentifier();
  7907. }
  7908. } else {
  7909. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  7910. specifier.imported = this.parseIdentifier(true);
  7911. specifier.importKind = specifierTypeKind;
  7912. } else {
  7913. if (importedIsString) {
  7914. throw this.raise(Errors.ImportBindingIsString, specifier, {
  7915. importName: firstIdent.value
  7916. });
  7917. }
  7918. specifier.imported = firstIdent;
  7919. specifier.importKind = null;
  7920. }
  7921. if (this.eatContextual(93)) {
  7922. specifier.local = this.parseIdentifier();
  7923. } else {
  7924. isBinding = true;
  7925. specifier.local = cloneIdentifier(specifier.imported);
  7926. }
  7927. }
  7928. const specifierIsTypeImport = hasTypeImportKind(specifier);
  7929. if (isInTypeOnlyImport && specifierIsTypeImport) {
  7930. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  7931. }
  7932. if (isInTypeOnlyImport || specifierIsTypeImport) {
  7933. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  7934. }
  7935. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  7936. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  7937. }
  7938. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  7939. }
  7940. parseBindingAtom() {
  7941. switch (this.state.type) {
  7942. case 78:
  7943. return this.parseIdentifier(true);
  7944. default:
  7945. return super.parseBindingAtom();
  7946. }
  7947. }
  7948. parseFunctionParams(node, isConstructor) {
  7949. const kind = node.kind;
  7950. if (kind !== "get" && kind !== "set" && this.match(47)) {
  7951. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7952. }
  7953. super.parseFunctionParams(node, isConstructor);
  7954. }
  7955. parseVarId(decl, kind) {
  7956. super.parseVarId(decl, kind);
  7957. if (this.match(14)) {
  7958. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  7959. this.resetEndLocation(decl.id);
  7960. }
  7961. }
  7962. parseAsyncArrowFromCallExpression(node, call) {
  7963. if (this.match(14)) {
  7964. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7965. this.state.noAnonFunctionType = true;
  7966. node.returnType = this.flowParseTypeAnnotation();
  7967. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7968. }
  7969. return super.parseAsyncArrowFromCallExpression(node, call);
  7970. }
  7971. shouldParseAsyncArrow() {
  7972. return this.match(14) || super.shouldParseAsyncArrow();
  7973. }
  7974. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  7975. var _jsx;
  7976. let state = null;
  7977. let jsx;
  7978. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  7979. state = this.state.clone();
  7980. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  7981. if (!jsx.error) return jsx.node;
  7982. const {
  7983. context
  7984. } = this.state;
  7985. const currentContext = context[context.length - 1];
  7986. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  7987. context.pop();
  7988. }
  7989. }
  7990. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  7991. var _jsx2, _jsx3;
  7992. state = state || this.state.clone();
  7993. let typeParameters;
  7994. const arrow = this.tryParse(abort => {
  7995. var _arrowExpression$extr;
  7996. typeParameters = this.flowParseTypeParameterDeclaration();
  7997. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  7998. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  7999. this.resetStartLocationFromNode(result, typeParameters);
  8000. return result;
  8001. });
  8002. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  8003. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  8004. if (expr.type !== "ArrowFunctionExpression") abort();
  8005. expr.typeParameters = typeParameters;
  8006. this.resetStartLocationFromNode(expr, typeParameters);
  8007. return arrowExpression;
  8008. }, state);
  8009. let arrowExpression = null;
  8010. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  8011. if (!arrow.error && !arrow.aborted) {
  8012. if (arrow.node.async) {
  8013. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  8014. }
  8015. return arrow.node;
  8016. }
  8017. arrowExpression = arrow.node;
  8018. }
  8019. if ((_jsx2 = jsx) != null && _jsx2.node) {
  8020. this.state = jsx.failState;
  8021. return jsx.node;
  8022. }
  8023. if (arrowExpression) {
  8024. this.state = arrow.failState;
  8025. return arrowExpression;
  8026. }
  8027. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  8028. if (arrow.thrown) throw arrow.error;
  8029. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  8030. }
  8031. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8032. }
  8033. parseArrow(node) {
  8034. if (this.match(14)) {
  8035. const result = this.tryParse(() => {
  8036. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8037. this.state.noAnonFunctionType = true;
  8038. const typeNode = this.startNode();
  8039. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  8040. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8041. if (this.canInsertSemicolon()) this.unexpected();
  8042. if (!this.match(19)) this.unexpected();
  8043. return typeNode;
  8044. });
  8045. if (result.thrown) return null;
  8046. if (result.error) this.state = result.failState;
  8047. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  8048. }
  8049. return super.parseArrow(node);
  8050. }
  8051. shouldParseArrow(params) {
  8052. return this.match(14) || super.shouldParseArrow(params);
  8053. }
  8054. setArrowFunctionParameters(node, params) {
  8055. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8056. node.params = params;
  8057. } else {
  8058. super.setArrowFunctionParameters(node, params);
  8059. }
  8060. }
  8061. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  8062. if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8063. return;
  8064. }
  8065. for (let i = 0; i < node.params.length; i++) {
  8066. if (this.isThisParam(node.params[i]) && i > 0) {
  8067. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  8068. }
  8069. }
  8070. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  8071. }
  8072. parseParenAndDistinguishExpression(canBeArrow) {
  8073. return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
  8074. }
  8075. parseSubscripts(base, startLoc, noCalls) {
  8076. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startLoc.index) !== -1) {
  8077. this.next();
  8078. const node = this.startNodeAt(startLoc);
  8079. node.callee = base;
  8080. node.arguments = super.parseCallExpressionArguments(11, false);
  8081. base = this.finishNode(node, "CallExpression");
  8082. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  8083. const state = this.state.clone();
  8084. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  8085. if (!arrow.error && !arrow.aborted) return arrow.node;
  8086. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  8087. if (result.node && !result.error) return result.node;
  8088. if (arrow.node) {
  8089. this.state = arrow.failState;
  8090. return arrow.node;
  8091. }
  8092. if (result.node) {
  8093. this.state = result.failState;
  8094. return result.node;
  8095. }
  8096. throw arrow.error || result.error;
  8097. }
  8098. return super.parseSubscripts(base, startLoc, noCalls);
  8099. }
  8100. parseSubscript(base, startLoc, noCalls, subscriptState) {
  8101. if (this.match(18) && this.isLookaheadToken_lt()) {
  8102. subscriptState.optionalChainMember = true;
  8103. if (noCalls) {
  8104. subscriptState.stop = true;
  8105. return base;
  8106. }
  8107. this.next();
  8108. const node = this.startNodeAt(startLoc);
  8109. node.callee = base;
  8110. node.typeArguments = this.flowParseTypeParameterInstantiation();
  8111. this.expect(10);
  8112. node.arguments = this.parseCallExpressionArguments(11, false);
  8113. node.optional = true;
  8114. return this.finishCallExpression(node, true);
  8115. } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {
  8116. const node = this.startNodeAt(startLoc);
  8117. node.callee = base;
  8118. const result = this.tryParse(() => {
  8119. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  8120. this.expect(10);
  8121. node.arguments = super.parseCallExpressionArguments(11, false);
  8122. if (subscriptState.optionalChainMember) {
  8123. node.optional = false;
  8124. }
  8125. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  8126. });
  8127. if (result.node) {
  8128. if (result.error) this.state = result.failState;
  8129. return result.node;
  8130. }
  8131. }
  8132. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  8133. }
  8134. parseNewCallee(node) {
  8135. super.parseNewCallee(node);
  8136. let targs = null;
  8137. if (this.shouldParseTypes() && this.match(47)) {
  8138. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  8139. }
  8140. node.typeArguments = targs;
  8141. }
  8142. parseAsyncArrowWithTypeParameters(startLoc) {
  8143. const node = this.startNodeAt(startLoc);
  8144. this.parseFunctionParams(node, false);
  8145. if (!this.parseArrow(node)) return;
  8146. return super.parseArrowExpression(node, undefined, true);
  8147. }
  8148. readToken_mult_modulo(code) {
  8149. const next = this.input.charCodeAt(this.state.pos + 1);
  8150. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  8151. this.state.hasFlowComment = false;
  8152. this.state.pos += 2;
  8153. this.nextToken();
  8154. return;
  8155. }
  8156. super.readToken_mult_modulo(code);
  8157. }
  8158. readToken_pipe_amp(code) {
  8159. const next = this.input.charCodeAt(this.state.pos + 1);
  8160. if (code === 124 && next === 125) {
  8161. this.finishOp(9, 2);
  8162. return;
  8163. }
  8164. super.readToken_pipe_amp(code);
  8165. }
  8166. parseTopLevel(file, program) {
  8167. const fileNode = super.parseTopLevel(file, program);
  8168. if (this.state.hasFlowComment) {
  8169. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  8170. }
  8171. return fileNode;
  8172. }
  8173. skipBlockComment() {
  8174. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  8175. if (this.state.hasFlowComment) {
  8176. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  8177. }
  8178. this.hasFlowCommentCompletion();
  8179. const commentSkip = this.skipFlowComment();
  8180. if (commentSkip) {
  8181. this.state.pos += commentSkip;
  8182. this.state.hasFlowComment = true;
  8183. }
  8184. return;
  8185. }
  8186. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  8187. }
  8188. skipFlowComment() {
  8189. const {
  8190. pos
  8191. } = this.state;
  8192. let shiftToFirstNonWhiteSpace = 2;
  8193. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  8194. shiftToFirstNonWhiteSpace++;
  8195. }
  8196. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  8197. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  8198. if (ch2 === 58 && ch3 === 58) {
  8199. return shiftToFirstNonWhiteSpace + 2;
  8200. }
  8201. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  8202. return shiftToFirstNonWhiteSpace + 12;
  8203. }
  8204. if (ch2 === 58 && ch3 !== 58) {
  8205. return shiftToFirstNonWhiteSpace;
  8206. }
  8207. return false;
  8208. }
  8209. hasFlowCommentCompletion() {
  8210. const end = this.input.indexOf("*/", this.state.pos);
  8211. if (end === -1) {
  8212. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8213. }
  8214. }
  8215. flowEnumErrorBooleanMemberNotInitialized(loc, {
  8216. enumName,
  8217. memberName
  8218. }) {
  8219. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  8220. memberName,
  8221. enumName
  8222. });
  8223. }
  8224. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  8225. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  8226. }
  8227. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  8228. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  8229. }
  8230. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  8231. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  8232. }
  8233. flowEnumMemberInit() {
  8234. const startLoc = this.state.startLoc;
  8235. const endOfInit = () => this.match(12) || this.match(8);
  8236. switch (this.state.type) {
  8237. case 134:
  8238. {
  8239. const literal = this.parseNumericLiteral(this.state.value);
  8240. if (endOfInit()) {
  8241. return {
  8242. type: "number",
  8243. loc: literal.loc.start,
  8244. value: literal
  8245. };
  8246. }
  8247. return {
  8248. type: "invalid",
  8249. loc: startLoc
  8250. };
  8251. }
  8252. case 133:
  8253. {
  8254. const literal = this.parseStringLiteral(this.state.value);
  8255. if (endOfInit()) {
  8256. return {
  8257. type: "string",
  8258. loc: literal.loc.start,
  8259. value: literal
  8260. };
  8261. }
  8262. return {
  8263. type: "invalid",
  8264. loc: startLoc
  8265. };
  8266. }
  8267. case 85:
  8268. case 86:
  8269. {
  8270. const literal = this.parseBooleanLiteral(this.match(85));
  8271. if (endOfInit()) {
  8272. return {
  8273. type: "boolean",
  8274. loc: literal.loc.start,
  8275. value: literal
  8276. };
  8277. }
  8278. return {
  8279. type: "invalid",
  8280. loc: startLoc
  8281. };
  8282. }
  8283. default:
  8284. return {
  8285. type: "invalid",
  8286. loc: startLoc
  8287. };
  8288. }
  8289. }
  8290. flowEnumMemberRaw() {
  8291. const loc = this.state.startLoc;
  8292. const id = this.parseIdentifier(true);
  8293. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  8294. type: "none",
  8295. loc
  8296. };
  8297. return {
  8298. id,
  8299. init
  8300. };
  8301. }
  8302. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  8303. const {
  8304. explicitType
  8305. } = context;
  8306. if (explicitType === null) {
  8307. return;
  8308. }
  8309. if (explicitType !== expectedType) {
  8310. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  8311. }
  8312. }
  8313. flowEnumMembers({
  8314. enumName,
  8315. explicitType
  8316. }) {
  8317. const seenNames = new Set();
  8318. const members = {
  8319. booleanMembers: [],
  8320. numberMembers: [],
  8321. stringMembers: [],
  8322. defaultedMembers: []
  8323. };
  8324. let hasUnknownMembers = false;
  8325. while (!this.match(8)) {
  8326. if (this.eat(21)) {
  8327. hasUnknownMembers = true;
  8328. break;
  8329. }
  8330. const memberNode = this.startNode();
  8331. const {
  8332. id,
  8333. init
  8334. } = this.flowEnumMemberRaw();
  8335. const memberName = id.name;
  8336. if (memberName === "") {
  8337. continue;
  8338. }
  8339. if (/^[a-z]/.test(memberName)) {
  8340. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  8341. memberName,
  8342. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  8343. enumName
  8344. });
  8345. }
  8346. if (seenNames.has(memberName)) {
  8347. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  8348. memberName,
  8349. enumName
  8350. });
  8351. }
  8352. seenNames.add(memberName);
  8353. const context = {
  8354. enumName,
  8355. explicitType,
  8356. memberName
  8357. };
  8358. memberNode.id = id;
  8359. switch (init.type) {
  8360. case "boolean":
  8361. {
  8362. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  8363. memberNode.init = init.value;
  8364. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  8365. break;
  8366. }
  8367. case "number":
  8368. {
  8369. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  8370. memberNode.init = init.value;
  8371. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  8372. break;
  8373. }
  8374. case "string":
  8375. {
  8376. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  8377. memberNode.init = init.value;
  8378. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  8379. break;
  8380. }
  8381. case "invalid":
  8382. {
  8383. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  8384. }
  8385. case "none":
  8386. {
  8387. switch (explicitType) {
  8388. case "boolean":
  8389. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  8390. break;
  8391. case "number":
  8392. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  8393. break;
  8394. default:
  8395. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  8396. }
  8397. }
  8398. }
  8399. if (!this.match(8)) {
  8400. this.expect(12);
  8401. }
  8402. }
  8403. return {
  8404. members,
  8405. hasUnknownMembers
  8406. };
  8407. }
  8408. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  8409. enumName
  8410. }) {
  8411. if (initializedMembers.length === 0) {
  8412. return defaultedMembers;
  8413. } else if (defaultedMembers.length === 0) {
  8414. return initializedMembers;
  8415. } else if (defaultedMembers.length > initializedMembers.length) {
  8416. for (const member of initializedMembers) {
  8417. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8418. enumName
  8419. });
  8420. }
  8421. return defaultedMembers;
  8422. } else {
  8423. for (const member of defaultedMembers) {
  8424. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8425. enumName
  8426. });
  8427. }
  8428. return initializedMembers;
  8429. }
  8430. }
  8431. flowEnumParseExplicitType({
  8432. enumName
  8433. }) {
  8434. if (!this.eatContextual(102)) return null;
  8435. if (!tokenIsIdentifier(this.state.type)) {
  8436. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  8437. enumName
  8438. });
  8439. }
  8440. const {
  8441. value
  8442. } = this.state;
  8443. this.next();
  8444. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  8445. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  8446. enumName,
  8447. invalidEnumType: value
  8448. });
  8449. }
  8450. return value;
  8451. }
  8452. flowEnumBody(node, id) {
  8453. const enumName = id.name;
  8454. const nameLoc = id.loc.start;
  8455. const explicitType = this.flowEnumParseExplicitType({
  8456. enumName
  8457. });
  8458. this.expect(5);
  8459. const {
  8460. members,
  8461. hasUnknownMembers
  8462. } = this.flowEnumMembers({
  8463. enumName,
  8464. explicitType
  8465. });
  8466. node.hasUnknownMembers = hasUnknownMembers;
  8467. switch (explicitType) {
  8468. case "boolean":
  8469. node.explicitType = true;
  8470. node.members = members.booleanMembers;
  8471. this.expect(8);
  8472. return this.finishNode(node, "EnumBooleanBody");
  8473. case "number":
  8474. node.explicitType = true;
  8475. node.members = members.numberMembers;
  8476. this.expect(8);
  8477. return this.finishNode(node, "EnumNumberBody");
  8478. case "string":
  8479. node.explicitType = true;
  8480. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8481. enumName
  8482. });
  8483. this.expect(8);
  8484. return this.finishNode(node, "EnumStringBody");
  8485. case "symbol":
  8486. node.members = members.defaultedMembers;
  8487. this.expect(8);
  8488. return this.finishNode(node, "EnumSymbolBody");
  8489. default:
  8490. {
  8491. const empty = () => {
  8492. node.members = [];
  8493. this.expect(8);
  8494. return this.finishNode(node, "EnumStringBody");
  8495. };
  8496. node.explicitType = false;
  8497. const boolsLen = members.booleanMembers.length;
  8498. const numsLen = members.numberMembers.length;
  8499. const strsLen = members.stringMembers.length;
  8500. const defaultedLen = members.defaultedMembers.length;
  8501. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  8502. return empty();
  8503. } else if (!boolsLen && !numsLen) {
  8504. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8505. enumName
  8506. });
  8507. this.expect(8);
  8508. return this.finishNode(node, "EnumStringBody");
  8509. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  8510. for (const member of members.defaultedMembers) {
  8511. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  8512. enumName,
  8513. memberName: member.id.name
  8514. });
  8515. }
  8516. node.members = members.booleanMembers;
  8517. this.expect(8);
  8518. return this.finishNode(node, "EnumBooleanBody");
  8519. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  8520. for (const member of members.defaultedMembers) {
  8521. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  8522. enumName,
  8523. memberName: member.id.name
  8524. });
  8525. }
  8526. node.members = members.numberMembers;
  8527. this.expect(8);
  8528. return this.finishNode(node, "EnumNumberBody");
  8529. } else {
  8530. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  8531. enumName
  8532. });
  8533. return empty();
  8534. }
  8535. }
  8536. }
  8537. }
  8538. flowParseEnumDeclaration(node) {
  8539. const id = this.parseIdentifier();
  8540. node.id = id;
  8541. node.body = this.flowEnumBody(this.startNode(), id);
  8542. return this.finishNode(node, "EnumDeclaration");
  8543. }
  8544. isLookaheadToken_lt() {
  8545. const next = this.nextTokenStart();
  8546. if (this.input.charCodeAt(next) === 60) {
  8547. const afterNext = this.input.charCodeAt(next + 1);
  8548. return afterNext !== 60 && afterNext !== 61;
  8549. }
  8550. return false;
  8551. }
  8552. maybeUnwrapTypeCastExpression(node) {
  8553. return node.type === "TypeCastExpression" ? node.expression : node;
  8554. }
  8555. };
  8556. const entities = {
  8557. __proto__: null,
  8558. quot: "\u0022",
  8559. amp: "&",
  8560. apos: "\u0027",
  8561. lt: "<",
  8562. gt: ">",
  8563. nbsp: "\u00A0",
  8564. iexcl: "\u00A1",
  8565. cent: "\u00A2",
  8566. pound: "\u00A3",
  8567. curren: "\u00A4",
  8568. yen: "\u00A5",
  8569. brvbar: "\u00A6",
  8570. sect: "\u00A7",
  8571. uml: "\u00A8",
  8572. copy: "\u00A9",
  8573. ordf: "\u00AA",
  8574. laquo: "\u00AB",
  8575. not: "\u00AC",
  8576. shy: "\u00AD",
  8577. reg: "\u00AE",
  8578. macr: "\u00AF",
  8579. deg: "\u00B0",
  8580. plusmn: "\u00B1",
  8581. sup2: "\u00B2",
  8582. sup3: "\u00B3",
  8583. acute: "\u00B4",
  8584. micro: "\u00B5",
  8585. para: "\u00B6",
  8586. middot: "\u00B7",
  8587. cedil: "\u00B8",
  8588. sup1: "\u00B9",
  8589. ordm: "\u00BA",
  8590. raquo: "\u00BB",
  8591. frac14: "\u00BC",
  8592. frac12: "\u00BD",
  8593. frac34: "\u00BE",
  8594. iquest: "\u00BF",
  8595. Agrave: "\u00C0",
  8596. Aacute: "\u00C1",
  8597. Acirc: "\u00C2",
  8598. Atilde: "\u00C3",
  8599. Auml: "\u00C4",
  8600. Aring: "\u00C5",
  8601. AElig: "\u00C6",
  8602. Ccedil: "\u00C7",
  8603. Egrave: "\u00C8",
  8604. Eacute: "\u00C9",
  8605. Ecirc: "\u00CA",
  8606. Euml: "\u00CB",
  8607. Igrave: "\u00CC",
  8608. Iacute: "\u00CD",
  8609. Icirc: "\u00CE",
  8610. Iuml: "\u00CF",
  8611. ETH: "\u00D0",
  8612. Ntilde: "\u00D1",
  8613. Ograve: "\u00D2",
  8614. Oacute: "\u00D3",
  8615. Ocirc: "\u00D4",
  8616. Otilde: "\u00D5",
  8617. Ouml: "\u00D6",
  8618. times: "\u00D7",
  8619. Oslash: "\u00D8",
  8620. Ugrave: "\u00D9",
  8621. Uacute: "\u00DA",
  8622. Ucirc: "\u00DB",
  8623. Uuml: "\u00DC",
  8624. Yacute: "\u00DD",
  8625. THORN: "\u00DE",
  8626. szlig: "\u00DF",
  8627. agrave: "\u00E0",
  8628. aacute: "\u00E1",
  8629. acirc: "\u00E2",
  8630. atilde: "\u00E3",
  8631. auml: "\u00E4",
  8632. aring: "\u00E5",
  8633. aelig: "\u00E6",
  8634. ccedil: "\u00E7",
  8635. egrave: "\u00E8",
  8636. eacute: "\u00E9",
  8637. ecirc: "\u00EA",
  8638. euml: "\u00EB",
  8639. igrave: "\u00EC",
  8640. iacute: "\u00ED",
  8641. icirc: "\u00EE",
  8642. iuml: "\u00EF",
  8643. eth: "\u00F0",
  8644. ntilde: "\u00F1",
  8645. ograve: "\u00F2",
  8646. oacute: "\u00F3",
  8647. ocirc: "\u00F4",
  8648. otilde: "\u00F5",
  8649. ouml: "\u00F6",
  8650. divide: "\u00F7",
  8651. oslash: "\u00F8",
  8652. ugrave: "\u00F9",
  8653. uacute: "\u00FA",
  8654. ucirc: "\u00FB",
  8655. uuml: "\u00FC",
  8656. yacute: "\u00FD",
  8657. thorn: "\u00FE",
  8658. yuml: "\u00FF",
  8659. OElig: "\u0152",
  8660. oelig: "\u0153",
  8661. Scaron: "\u0160",
  8662. scaron: "\u0161",
  8663. Yuml: "\u0178",
  8664. fnof: "\u0192",
  8665. circ: "\u02C6",
  8666. tilde: "\u02DC",
  8667. Alpha: "\u0391",
  8668. Beta: "\u0392",
  8669. Gamma: "\u0393",
  8670. Delta: "\u0394",
  8671. Epsilon: "\u0395",
  8672. Zeta: "\u0396",
  8673. Eta: "\u0397",
  8674. Theta: "\u0398",
  8675. Iota: "\u0399",
  8676. Kappa: "\u039A",
  8677. Lambda: "\u039B",
  8678. Mu: "\u039C",
  8679. Nu: "\u039D",
  8680. Xi: "\u039E",
  8681. Omicron: "\u039F",
  8682. Pi: "\u03A0",
  8683. Rho: "\u03A1",
  8684. Sigma: "\u03A3",
  8685. Tau: "\u03A4",
  8686. Upsilon: "\u03A5",
  8687. Phi: "\u03A6",
  8688. Chi: "\u03A7",
  8689. Psi: "\u03A8",
  8690. Omega: "\u03A9",
  8691. alpha: "\u03B1",
  8692. beta: "\u03B2",
  8693. gamma: "\u03B3",
  8694. delta: "\u03B4",
  8695. epsilon: "\u03B5",
  8696. zeta: "\u03B6",
  8697. eta: "\u03B7",
  8698. theta: "\u03B8",
  8699. iota: "\u03B9",
  8700. kappa: "\u03BA",
  8701. lambda: "\u03BB",
  8702. mu: "\u03BC",
  8703. nu: "\u03BD",
  8704. xi: "\u03BE",
  8705. omicron: "\u03BF",
  8706. pi: "\u03C0",
  8707. rho: "\u03C1",
  8708. sigmaf: "\u03C2",
  8709. sigma: "\u03C3",
  8710. tau: "\u03C4",
  8711. upsilon: "\u03C5",
  8712. phi: "\u03C6",
  8713. chi: "\u03C7",
  8714. psi: "\u03C8",
  8715. omega: "\u03C9",
  8716. thetasym: "\u03D1",
  8717. upsih: "\u03D2",
  8718. piv: "\u03D6",
  8719. ensp: "\u2002",
  8720. emsp: "\u2003",
  8721. thinsp: "\u2009",
  8722. zwnj: "\u200C",
  8723. zwj: "\u200D",
  8724. lrm: "\u200E",
  8725. rlm: "\u200F",
  8726. ndash: "\u2013",
  8727. mdash: "\u2014",
  8728. lsquo: "\u2018",
  8729. rsquo: "\u2019",
  8730. sbquo: "\u201A",
  8731. ldquo: "\u201C",
  8732. rdquo: "\u201D",
  8733. bdquo: "\u201E",
  8734. dagger: "\u2020",
  8735. Dagger: "\u2021",
  8736. bull: "\u2022",
  8737. hellip: "\u2026",
  8738. permil: "\u2030",
  8739. prime: "\u2032",
  8740. Prime: "\u2033",
  8741. lsaquo: "\u2039",
  8742. rsaquo: "\u203A",
  8743. oline: "\u203E",
  8744. frasl: "\u2044",
  8745. euro: "\u20AC",
  8746. image: "\u2111",
  8747. weierp: "\u2118",
  8748. real: "\u211C",
  8749. trade: "\u2122",
  8750. alefsym: "\u2135",
  8751. larr: "\u2190",
  8752. uarr: "\u2191",
  8753. rarr: "\u2192",
  8754. darr: "\u2193",
  8755. harr: "\u2194",
  8756. crarr: "\u21B5",
  8757. lArr: "\u21D0",
  8758. uArr: "\u21D1",
  8759. rArr: "\u21D2",
  8760. dArr: "\u21D3",
  8761. hArr: "\u21D4",
  8762. forall: "\u2200",
  8763. part: "\u2202",
  8764. exist: "\u2203",
  8765. empty: "\u2205",
  8766. nabla: "\u2207",
  8767. isin: "\u2208",
  8768. notin: "\u2209",
  8769. ni: "\u220B",
  8770. prod: "\u220F",
  8771. sum: "\u2211",
  8772. minus: "\u2212",
  8773. lowast: "\u2217",
  8774. radic: "\u221A",
  8775. prop: "\u221D",
  8776. infin: "\u221E",
  8777. ang: "\u2220",
  8778. and: "\u2227",
  8779. or: "\u2228",
  8780. cap: "\u2229",
  8781. cup: "\u222A",
  8782. int: "\u222B",
  8783. there4: "\u2234",
  8784. sim: "\u223C",
  8785. cong: "\u2245",
  8786. asymp: "\u2248",
  8787. ne: "\u2260",
  8788. equiv: "\u2261",
  8789. le: "\u2264",
  8790. ge: "\u2265",
  8791. sub: "\u2282",
  8792. sup: "\u2283",
  8793. nsub: "\u2284",
  8794. sube: "\u2286",
  8795. supe: "\u2287",
  8796. oplus: "\u2295",
  8797. otimes: "\u2297",
  8798. perp: "\u22A5",
  8799. sdot: "\u22C5",
  8800. lceil: "\u2308",
  8801. rceil: "\u2309",
  8802. lfloor: "\u230A",
  8803. rfloor: "\u230B",
  8804. lang: "\u2329",
  8805. rang: "\u232A",
  8806. loz: "\u25CA",
  8807. spades: "\u2660",
  8808. clubs: "\u2663",
  8809. hearts: "\u2665",
  8810. diams: "\u2666"
  8811. };
  8812. const JsxErrors = ParseErrorEnum`jsx`({
  8813. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  8814. MissingClosingTagElement: ({
  8815. openingTagName
  8816. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  8817. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  8818. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  8819. UnexpectedToken: ({
  8820. unexpected,
  8821. HTMLEntity
  8822. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  8823. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  8824. UnterminatedJsxContent: "Unterminated JSX contents.",
  8825. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  8826. });
  8827. function isFragment(object) {
  8828. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  8829. }
  8830. function getQualifiedJSXName(object) {
  8831. if (object.type === "JSXIdentifier") {
  8832. return object.name;
  8833. }
  8834. if (object.type === "JSXNamespacedName") {
  8835. return object.namespace.name + ":" + object.name.name;
  8836. }
  8837. if (object.type === "JSXMemberExpression") {
  8838. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  8839. }
  8840. throw new Error("Node had unexpected type: " + object.type);
  8841. }
  8842. var jsx = superClass => class JSXParserMixin extends superClass {
  8843. jsxReadToken() {
  8844. let out = "";
  8845. let chunkStart = this.state.pos;
  8846. for (;;) {
  8847. if (this.state.pos >= this.length) {
  8848. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  8849. }
  8850. const ch = this.input.charCodeAt(this.state.pos);
  8851. switch (ch) {
  8852. case 60:
  8853. case 123:
  8854. if (this.state.pos === this.state.start) {
  8855. if (ch === 60 && this.state.canStartJSXElement) {
  8856. ++this.state.pos;
  8857. this.finishToken(142);
  8858. } else {
  8859. super.getTokenFromCode(ch);
  8860. }
  8861. return;
  8862. }
  8863. out += this.input.slice(chunkStart, this.state.pos);
  8864. this.finishToken(141, out);
  8865. return;
  8866. case 38:
  8867. out += this.input.slice(chunkStart, this.state.pos);
  8868. out += this.jsxReadEntity();
  8869. chunkStart = this.state.pos;
  8870. break;
  8871. case 62:
  8872. case 125:
  8873. default:
  8874. if (isNewLine(ch)) {
  8875. out += this.input.slice(chunkStart, this.state.pos);
  8876. out += this.jsxReadNewLine(true);
  8877. chunkStart = this.state.pos;
  8878. } else {
  8879. ++this.state.pos;
  8880. }
  8881. }
  8882. }
  8883. }
  8884. jsxReadNewLine(normalizeCRLF) {
  8885. const ch = this.input.charCodeAt(this.state.pos);
  8886. let out;
  8887. ++this.state.pos;
  8888. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  8889. ++this.state.pos;
  8890. out = normalizeCRLF ? "\n" : "\r\n";
  8891. } else {
  8892. out = String.fromCharCode(ch);
  8893. }
  8894. ++this.state.curLine;
  8895. this.state.lineStart = this.state.pos;
  8896. return out;
  8897. }
  8898. jsxReadString(quote) {
  8899. let out = "";
  8900. let chunkStart = ++this.state.pos;
  8901. for (;;) {
  8902. if (this.state.pos >= this.length) {
  8903. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  8904. }
  8905. const ch = this.input.charCodeAt(this.state.pos);
  8906. if (ch === quote) break;
  8907. if (ch === 38) {
  8908. out += this.input.slice(chunkStart, this.state.pos);
  8909. out += this.jsxReadEntity();
  8910. chunkStart = this.state.pos;
  8911. } else if (isNewLine(ch)) {
  8912. out += this.input.slice(chunkStart, this.state.pos);
  8913. out += this.jsxReadNewLine(false);
  8914. chunkStart = this.state.pos;
  8915. } else {
  8916. ++this.state.pos;
  8917. }
  8918. }
  8919. out += this.input.slice(chunkStart, this.state.pos++);
  8920. this.finishToken(133, out);
  8921. }
  8922. jsxReadEntity() {
  8923. const startPos = ++this.state.pos;
  8924. if (this.codePointAtPos(this.state.pos) === 35) {
  8925. ++this.state.pos;
  8926. let radix = 10;
  8927. if (this.codePointAtPos(this.state.pos) === 120) {
  8928. radix = 16;
  8929. ++this.state.pos;
  8930. }
  8931. const codePoint = this.readInt(radix, undefined, false, "bail");
  8932. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  8933. ++this.state.pos;
  8934. return String.fromCodePoint(codePoint);
  8935. }
  8936. } else {
  8937. let count = 0;
  8938. let semi = false;
  8939. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) == 59)) {
  8940. ++this.state.pos;
  8941. }
  8942. if (semi) {
  8943. const desc = this.input.slice(startPos, this.state.pos);
  8944. const entity = entities[desc];
  8945. ++this.state.pos;
  8946. if (entity) {
  8947. return entity;
  8948. }
  8949. }
  8950. }
  8951. this.state.pos = startPos;
  8952. return "&";
  8953. }
  8954. jsxReadWord() {
  8955. let ch;
  8956. const start = this.state.pos;
  8957. do {
  8958. ch = this.input.charCodeAt(++this.state.pos);
  8959. } while (isIdentifierChar(ch) || ch === 45);
  8960. this.finishToken(140, this.input.slice(start, this.state.pos));
  8961. }
  8962. jsxParseIdentifier() {
  8963. const node = this.startNode();
  8964. if (this.match(140)) {
  8965. node.name = this.state.value;
  8966. } else if (tokenIsKeyword(this.state.type)) {
  8967. node.name = tokenLabelName(this.state.type);
  8968. } else {
  8969. this.unexpected();
  8970. }
  8971. this.next();
  8972. return this.finishNode(node, "JSXIdentifier");
  8973. }
  8974. jsxParseNamespacedName() {
  8975. const startLoc = this.state.startLoc;
  8976. const name = this.jsxParseIdentifier();
  8977. if (!this.eat(14)) return name;
  8978. const node = this.startNodeAt(startLoc);
  8979. node.namespace = name;
  8980. node.name = this.jsxParseIdentifier();
  8981. return this.finishNode(node, "JSXNamespacedName");
  8982. }
  8983. jsxParseElementName() {
  8984. const startLoc = this.state.startLoc;
  8985. let node = this.jsxParseNamespacedName();
  8986. if (node.type === "JSXNamespacedName") {
  8987. return node;
  8988. }
  8989. while (this.eat(16)) {
  8990. const newNode = this.startNodeAt(startLoc);
  8991. newNode.object = node;
  8992. newNode.property = this.jsxParseIdentifier();
  8993. node = this.finishNode(newNode, "JSXMemberExpression");
  8994. }
  8995. return node;
  8996. }
  8997. jsxParseAttributeValue() {
  8998. let node;
  8999. switch (this.state.type) {
  9000. case 5:
  9001. node = this.startNode();
  9002. this.setContext(types$1.brace);
  9003. this.next();
  9004. node = this.jsxParseExpressionContainer(node, types$1.j_oTag);
  9005. if (node.expression.type === "JSXEmptyExpression") {
  9006. this.raise(JsxErrors.AttributeIsEmpty, node);
  9007. }
  9008. return node;
  9009. case 142:
  9010. case 133:
  9011. return this.parseExprAtom();
  9012. default:
  9013. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  9014. }
  9015. }
  9016. jsxParseEmptyExpression() {
  9017. const node = this.startNodeAt(this.state.lastTokEndLoc);
  9018. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  9019. }
  9020. jsxParseSpreadChild(node) {
  9021. this.next();
  9022. node.expression = this.parseExpression();
  9023. this.setContext(types$1.j_expr);
  9024. this.state.canStartJSXElement = true;
  9025. this.expect(8);
  9026. return this.finishNode(node, "JSXSpreadChild");
  9027. }
  9028. jsxParseExpressionContainer(node, previousContext) {
  9029. if (this.match(8)) {
  9030. node.expression = this.jsxParseEmptyExpression();
  9031. } else {
  9032. const expression = this.parseExpression();
  9033. node.expression = expression;
  9034. }
  9035. this.setContext(previousContext);
  9036. this.state.canStartJSXElement = true;
  9037. this.expect(8);
  9038. return this.finishNode(node, "JSXExpressionContainer");
  9039. }
  9040. jsxParseAttribute() {
  9041. const node = this.startNode();
  9042. if (this.match(5)) {
  9043. this.setContext(types$1.brace);
  9044. this.next();
  9045. this.expect(21);
  9046. node.argument = this.parseMaybeAssignAllowIn();
  9047. this.setContext(types$1.j_oTag);
  9048. this.state.canStartJSXElement = true;
  9049. this.expect(8);
  9050. return this.finishNode(node, "JSXSpreadAttribute");
  9051. }
  9052. node.name = this.jsxParseNamespacedName();
  9053. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  9054. return this.finishNode(node, "JSXAttribute");
  9055. }
  9056. jsxParseOpeningElementAt(startLoc) {
  9057. const node = this.startNodeAt(startLoc);
  9058. if (this.eat(143)) {
  9059. return this.finishNode(node, "JSXOpeningFragment");
  9060. }
  9061. node.name = this.jsxParseElementName();
  9062. return this.jsxParseOpeningElementAfterName(node);
  9063. }
  9064. jsxParseOpeningElementAfterName(node) {
  9065. const attributes = [];
  9066. while (!this.match(56) && !this.match(143)) {
  9067. attributes.push(this.jsxParseAttribute());
  9068. }
  9069. node.attributes = attributes;
  9070. node.selfClosing = this.eat(56);
  9071. this.expect(143);
  9072. return this.finishNode(node, "JSXOpeningElement");
  9073. }
  9074. jsxParseClosingElementAt(startLoc) {
  9075. const node = this.startNodeAt(startLoc);
  9076. if (this.eat(143)) {
  9077. return this.finishNode(node, "JSXClosingFragment");
  9078. }
  9079. node.name = this.jsxParseElementName();
  9080. this.expect(143);
  9081. return this.finishNode(node, "JSXClosingElement");
  9082. }
  9083. jsxParseElementAt(startLoc) {
  9084. const node = this.startNodeAt(startLoc);
  9085. const children = [];
  9086. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  9087. let closingElement = null;
  9088. if (!openingElement.selfClosing) {
  9089. contents: for (;;) {
  9090. switch (this.state.type) {
  9091. case 142:
  9092. startLoc = this.state.startLoc;
  9093. this.next();
  9094. if (this.eat(56)) {
  9095. closingElement = this.jsxParseClosingElementAt(startLoc);
  9096. break contents;
  9097. }
  9098. children.push(this.jsxParseElementAt(startLoc));
  9099. break;
  9100. case 141:
  9101. children.push(this.parseExprAtom());
  9102. break;
  9103. case 5:
  9104. {
  9105. const node = this.startNode();
  9106. this.setContext(types$1.brace);
  9107. this.next();
  9108. if (this.match(21)) {
  9109. children.push(this.jsxParseSpreadChild(node));
  9110. } else {
  9111. children.push(this.jsxParseExpressionContainer(node, types$1.j_expr));
  9112. }
  9113. break;
  9114. }
  9115. default:
  9116. this.unexpected();
  9117. }
  9118. }
  9119. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  9120. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  9121. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  9122. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9123. openingTagName: getQualifiedJSXName(openingElement.name)
  9124. });
  9125. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  9126. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  9127. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9128. openingTagName: getQualifiedJSXName(openingElement.name)
  9129. });
  9130. }
  9131. }
  9132. }
  9133. if (isFragment(openingElement)) {
  9134. node.openingFragment = openingElement;
  9135. node.closingFragment = closingElement;
  9136. } else {
  9137. node.openingElement = openingElement;
  9138. node.closingElement = closingElement;
  9139. }
  9140. node.children = children;
  9141. if (this.match(47)) {
  9142. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  9143. }
  9144. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  9145. }
  9146. jsxParseElement() {
  9147. const startLoc = this.state.startLoc;
  9148. this.next();
  9149. return this.jsxParseElementAt(startLoc);
  9150. }
  9151. setContext(newContext) {
  9152. const {
  9153. context
  9154. } = this.state;
  9155. context[context.length - 1] = newContext;
  9156. }
  9157. parseExprAtom(refExpressionErrors) {
  9158. if (this.match(141)) {
  9159. return this.parseLiteral(this.state.value, "JSXText");
  9160. } else if (this.match(142)) {
  9161. return this.jsxParseElement();
  9162. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  9163. this.replaceToken(142);
  9164. return this.jsxParseElement();
  9165. } else {
  9166. return super.parseExprAtom(refExpressionErrors);
  9167. }
  9168. }
  9169. skipSpace() {
  9170. const curContext = this.curContext();
  9171. if (!curContext.preserveSpace) super.skipSpace();
  9172. }
  9173. getTokenFromCode(code) {
  9174. const context = this.curContext();
  9175. if (context === types$1.j_expr) {
  9176. this.jsxReadToken();
  9177. return;
  9178. }
  9179. if (context === types$1.j_oTag || context === types$1.j_cTag) {
  9180. if (isIdentifierStart(code)) {
  9181. this.jsxReadWord();
  9182. return;
  9183. }
  9184. if (code === 62) {
  9185. ++this.state.pos;
  9186. this.finishToken(143);
  9187. return;
  9188. }
  9189. if ((code === 34 || code === 39) && context === types$1.j_oTag) {
  9190. this.jsxReadString(code);
  9191. return;
  9192. }
  9193. }
  9194. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  9195. ++this.state.pos;
  9196. this.finishToken(142);
  9197. return;
  9198. }
  9199. super.getTokenFromCode(code);
  9200. }
  9201. updateContext(prevType) {
  9202. const {
  9203. context,
  9204. type
  9205. } = this.state;
  9206. if (type === 56 && prevType === 142) {
  9207. context.splice(-2, 2, types$1.j_cTag);
  9208. this.state.canStartJSXElement = false;
  9209. } else if (type === 142) {
  9210. context.push(types$1.j_oTag);
  9211. } else if (type === 143) {
  9212. const out = context[context.length - 1];
  9213. if (out === types$1.j_oTag && prevType === 56 || out === types$1.j_cTag) {
  9214. context.pop();
  9215. this.state.canStartJSXElement = context[context.length - 1] === types$1.j_expr;
  9216. } else {
  9217. this.setContext(types$1.j_expr);
  9218. this.state.canStartJSXElement = true;
  9219. }
  9220. } else {
  9221. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  9222. }
  9223. }
  9224. };
  9225. class TypeScriptScope extends Scope {
  9226. constructor(...args) {
  9227. super(...args);
  9228. this.tsNames = new Map();
  9229. }
  9230. }
  9231. class TypeScriptScopeHandler extends ScopeHandler {
  9232. constructor(...args) {
  9233. super(...args);
  9234. this.importsStack = [];
  9235. }
  9236. createScope(flags) {
  9237. this.importsStack.push(new Set());
  9238. return new TypeScriptScope(flags);
  9239. }
  9240. enter(flags) {
  9241. if (flags == 256) {
  9242. this.importsStack.push(new Set());
  9243. }
  9244. super.enter(flags);
  9245. }
  9246. exit() {
  9247. const flags = super.exit();
  9248. if (flags == 256) {
  9249. this.importsStack.pop();
  9250. }
  9251. return flags;
  9252. }
  9253. hasImport(name, allowShadow) {
  9254. const len = this.importsStack.length;
  9255. if (this.importsStack[len - 1].has(name)) {
  9256. return true;
  9257. }
  9258. if (!allowShadow && len > 1) {
  9259. for (let i = 0; i < len - 1; i++) {
  9260. if (this.importsStack[i].has(name)) return true;
  9261. }
  9262. }
  9263. return false;
  9264. }
  9265. declareName(name, bindingType, loc) {
  9266. if (bindingType & 4096) {
  9267. if (this.hasImport(name, true)) {
  9268. this.parser.raise(Errors.VarRedeclaration, loc, {
  9269. identifierName: name
  9270. });
  9271. }
  9272. this.importsStack[this.importsStack.length - 1].add(name);
  9273. return;
  9274. }
  9275. const scope = this.currentScope();
  9276. let type = scope.tsNames.get(name) || 0;
  9277. if (bindingType & 1024) {
  9278. this.maybeExportDefined(scope, name);
  9279. scope.tsNames.set(name, type | 16);
  9280. return;
  9281. }
  9282. super.declareName(name, bindingType, loc);
  9283. if (bindingType & 2) {
  9284. if (!(bindingType & 1)) {
  9285. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  9286. this.maybeExportDefined(scope, name);
  9287. }
  9288. type = type | 1;
  9289. }
  9290. if (bindingType & 256) {
  9291. type = type | 2;
  9292. }
  9293. if (bindingType & 512) {
  9294. type = type | 4;
  9295. }
  9296. if (bindingType & 128) {
  9297. type = type | 8;
  9298. }
  9299. if (type) scope.tsNames.set(name, type);
  9300. }
  9301. isRedeclaredInScope(scope, name, bindingType) {
  9302. const type = scope.tsNames.get(name);
  9303. if ((type & 2) > 0) {
  9304. if (bindingType & 256) {
  9305. const isConst = !!(bindingType & 512);
  9306. const wasConst = (type & 4) > 0;
  9307. return isConst !== wasConst;
  9308. }
  9309. return true;
  9310. }
  9311. if (bindingType & 128 && (type & 8) > 0) {
  9312. if (scope.names.get(name) & 2) {
  9313. return !!(bindingType & 1);
  9314. } else {
  9315. return false;
  9316. }
  9317. }
  9318. if (bindingType & 2 && (type & 1) > 0) {
  9319. return true;
  9320. }
  9321. return super.isRedeclaredInScope(scope, name, bindingType);
  9322. }
  9323. checkLocalExport(id) {
  9324. const {
  9325. name
  9326. } = id;
  9327. if (this.hasImport(name)) return;
  9328. const len = this.scopeStack.length;
  9329. for (let i = len - 1; i >= 0; i--) {
  9330. const scope = this.scopeStack[i];
  9331. const type = scope.tsNames.get(name);
  9332. if ((type & 1) > 0 || (type & 16) > 0) {
  9333. return;
  9334. }
  9335. }
  9336. super.checkLocalExport(id);
  9337. }
  9338. }
  9339. const getOwn$1 = (object, key) => hasOwnProperty.call(object, key) && object[key];
  9340. const unwrapParenthesizedExpression = node => {
  9341. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9342. };
  9343. class LValParser extends NodeUtils {
  9344. toAssignable(node, isLHS = false) {
  9345. var _node$extra, _node$extra3;
  9346. let parenthesized = undefined;
  9347. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9348. parenthesized = unwrapParenthesizedExpression(node);
  9349. if (isLHS) {
  9350. if (parenthesized.type === "Identifier") {
  9351. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9352. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9353. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9354. }
  9355. } else {
  9356. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9357. }
  9358. }
  9359. switch (node.type) {
  9360. case "Identifier":
  9361. case "ObjectPattern":
  9362. case "ArrayPattern":
  9363. case "AssignmentPattern":
  9364. case "RestElement":
  9365. break;
  9366. case "ObjectExpression":
  9367. node.type = "ObjectPattern";
  9368. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9369. var _node$extra2;
  9370. const prop = node.properties[i];
  9371. const isLast = i === last;
  9372. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9373. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9374. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9375. }
  9376. }
  9377. break;
  9378. case "ObjectProperty":
  9379. {
  9380. const {
  9381. key,
  9382. value
  9383. } = node;
  9384. if (this.isPrivateName(key)) {
  9385. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9386. }
  9387. this.toAssignable(value, isLHS);
  9388. break;
  9389. }
  9390. case "SpreadElement":
  9391. {
  9392. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9393. }
  9394. case "ArrayExpression":
  9395. node.type = "ArrayPattern";
  9396. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9397. break;
  9398. case "AssignmentExpression":
  9399. if (node.operator !== "=") {
  9400. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9401. }
  9402. node.type = "AssignmentPattern";
  9403. delete node.operator;
  9404. this.toAssignable(node.left, isLHS);
  9405. break;
  9406. case "ParenthesizedExpression":
  9407. this.toAssignable(parenthesized, isLHS);
  9408. break;
  9409. }
  9410. }
  9411. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9412. if (prop.type === "ObjectMethod") {
  9413. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9414. } else if (prop.type === "SpreadElement") {
  9415. prop.type = "RestElement";
  9416. const arg = prop.argument;
  9417. this.checkToRestConversion(arg, false);
  9418. this.toAssignable(arg, isLHS);
  9419. if (!isLast) {
  9420. this.raise(Errors.RestTrailingComma, prop);
  9421. }
  9422. } else {
  9423. this.toAssignable(prop, isLHS);
  9424. }
  9425. }
  9426. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9427. const end = exprList.length - 1;
  9428. for (let i = 0; i <= end; i++) {
  9429. const elt = exprList[i];
  9430. if (!elt) continue;
  9431. if (elt.type === "SpreadElement") {
  9432. elt.type = "RestElement";
  9433. const arg = elt.argument;
  9434. this.checkToRestConversion(arg, true);
  9435. this.toAssignable(arg, isLHS);
  9436. } else {
  9437. this.toAssignable(elt, isLHS);
  9438. }
  9439. if (elt.type === "RestElement") {
  9440. if (i < end) {
  9441. this.raise(Errors.RestTrailingComma, elt);
  9442. } else if (trailingCommaLoc) {
  9443. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9444. }
  9445. }
  9446. }
  9447. }
  9448. isAssignable(node, isBinding) {
  9449. switch (node.type) {
  9450. case "Identifier":
  9451. case "ObjectPattern":
  9452. case "ArrayPattern":
  9453. case "AssignmentPattern":
  9454. case "RestElement":
  9455. return true;
  9456. case "ObjectExpression":
  9457. {
  9458. const last = node.properties.length - 1;
  9459. return node.properties.every((prop, i) => {
  9460. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9461. });
  9462. }
  9463. case "ObjectProperty":
  9464. return this.isAssignable(node.value);
  9465. case "SpreadElement":
  9466. return this.isAssignable(node.argument);
  9467. case "ArrayExpression":
  9468. return node.elements.every(element => element === null || this.isAssignable(element));
  9469. case "AssignmentExpression":
  9470. return node.operator === "=";
  9471. case "ParenthesizedExpression":
  9472. return this.isAssignable(node.expression);
  9473. case "MemberExpression":
  9474. case "OptionalMemberExpression":
  9475. return !isBinding;
  9476. default:
  9477. return false;
  9478. }
  9479. }
  9480. toReferencedList(exprList, isParenthesizedExpr) {
  9481. return exprList;
  9482. }
  9483. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9484. this.toReferencedList(exprList, isParenthesizedExpr);
  9485. for (const expr of exprList) {
  9486. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9487. this.toReferencedListDeep(expr.elements);
  9488. }
  9489. }
  9490. }
  9491. parseSpread(refExpressionErrors) {
  9492. const node = this.startNode();
  9493. this.next();
  9494. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9495. return this.finishNode(node, "SpreadElement");
  9496. }
  9497. parseRestBinding() {
  9498. const node = this.startNode();
  9499. this.next();
  9500. node.argument = this.parseBindingAtom();
  9501. return this.finishNode(node, "RestElement");
  9502. }
  9503. parseBindingAtom() {
  9504. switch (this.state.type) {
  9505. case 0:
  9506. {
  9507. const node = this.startNode();
  9508. this.next();
  9509. node.elements = this.parseBindingList(3, 93, 1);
  9510. return this.finishNode(node, "ArrayPattern");
  9511. }
  9512. case 5:
  9513. return this.parseObjectLike(8, true);
  9514. }
  9515. return this.parseIdentifier();
  9516. }
  9517. parseBindingList(close, closeCharCode, flags) {
  9518. const allowEmpty = flags & 1;
  9519. const elts = [];
  9520. let first = true;
  9521. while (!this.eat(close)) {
  9522. if (first) {
  9523. first = false;
  9524. } else {
  9525. this.expect(12);
  9526. }
  9527. if (allowEmpty && this.match(12)) {
  9528. elts.push(null);
  9529. } else if (this.eat(close)) {
  9530. break;
  9531. } else if (this.match(21)) {
  9532. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags));
  9533. if (!this.checkCommaAfterRest(closeCharCode)) {
  9534. this.expect(close);
  9535. break;
  9536. }
  9537. } else {
  9538. const decorators = [];
  9539. if (this.match(26) && this.hasPlugin("decorators")) {
  9540. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9541. }
  9542. while (this.match(26)) {
  9543. decorators.push(this.parseDecorator());
  9544. }
  9545. elts.push(this.parseAssignableListItem(flags, decorators));
  9546. }
  9547. }
  9548. return elts;
  9549. }
  9550. parseBindingRestProperty(prop) {
  9551. this.next();
  9552. prop.argument = this.parseIdentifier();
  9553. this.checkCommaAfterRest(125);
  9554. return this.finishNode(prop, "RestElement");
  9555. }
  9556. parseBindingProperty() {
  9557. const prop = this.startNode();
  9558. const {
  9559. type,
  9560. startLoc
  9561. } = this.state;
  9562. if (type === 21) {
  9563. return this.parseBindingRestProperty(prop);
  9564. } else if (type === 138) {
  9565. this.expectPlugin("destructuringPrivate", startLoc);
  9566. this.classScope.usePrivateName(this.state.value, startLoc);
  9567. prop.key = this.parsePrivateName();
  9568. } else {
  9569. this.parsePropertyName(prop);
  9570. }
  9571. prop.method = false;
  9572. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9573. }
  9574. parseAssignableListItem(flags, decorators) {
  9575. const left = this.parseMaybeDefault();
  9576. this.parseAssignableListItemTypes(left, flags);
  9577. const elt = this.parseMaybeDefault(left.loc.start, left);
  9578. if (decorators.length) {
  9579. left.decorators = decorators;
  9580. }
  9581. return elt;
  9582. }
  9583. parseAssignableListItemTypes(param, flags) {
  9584. return param;
  9585. }
  9586. parseMaybeDefault(startLoc, left) {
  9587. var _startLoc, _left;
  9588. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  9589. left = (_left = left) != null ? _left : this.parseBindingAtom();
  9590. if (!this.eat(29)) return left;
  9591. const node = this.startNodeAt(startLoc);
  9592. node.left = left;
  9593. node.right = this.parseMaybeAssignAllowIn();
  9594. return this.finishNode(node, "AssignmentPattern");
  9595. }
  9596. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9597. return getOwn$1({
  9598. AssignmentPattern: "left",
  9599. RestElement: "argument",
  9600. ObjectProperty: "value",
  9601. ParenthesizedExpression: "expression",
  9602. ArrayPattern: "elements",
  9603. ObjectPattern: "properties"
  9604. }, type);
  9605. }
  9606. isOptionalMemberExpression(expression) {
  9607. return expression.type === "OptionalMemberExpression";
  9608. }
  9609. checkLVal(expression, {
  9610. in: ancestor,
  9611. binding = 64,
  9612. checkClashes = false,
  9613. strictModeChanged = false,
  9614. hasParenthesizedAncestor = false
  9615. }) {
  9616. var _expression$extra;
  9617. const type = expression.type;
  9618. if (this.isObjectMethod(expression)) return;
  9619. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9620. if (isOptionalMemberExpression || type === "MemberExpression") {
  9621. if (isOptionalMemberExpression) {
  9622. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9623. if (ancestor.type !== "AssignmentExpression") {
  9624. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9625. ancestor
  9626. });
  9627. }
  9628. }
  9629. if (binding !== 64) {
  9630. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9631. }
  9632. return;
  9633. }
  9634. if (type === "Identifier") {
  9635. this.checkIdentifier(expression, binding, strictModeChanged);
  9636. const {
  9637. name
  9638. } = expression;
  9639. if (checkClashes) {
  9640. if (checkClashes.has(name)) {
  9641. this.raise(Errors.ParamDupe, expression);
  9642. } else {
  9643. checkClashes.add(name);
  9644. }
  9645. }
  9646. return;
  9647. }
  9648. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9649. if (validity === true) return;
  9650. if (validity === false) {
  9651. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9652. this.raise(ParseErrorClass, expression, {
  9653. ancestor
  9654. });
  9655. return;
  9656. }
  9657. const [key, isParenthesizedExpression] = Array.isArray(validity) ? validity : [validity, type === "ParenthesizedExpression"];
  9658. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9659. type
  9660. } : ancestor;
  9661. for (const child of [].concat(expression[key])) {
  9662. if (child) {
  9663. this.checkLVal(child, {
  9664. in: nextAncestor,
  9665. binding,
  9666. checkClashes,
  9667. strictModeChanged,
  9668. hasParenthesizedAncestor: isParenthesizedExpression
  9669. });
  9670. }
  9671. }
  9672. }
  9673. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9674. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9675. if (bindingType === 64) {
  9676. this.raise(Errors.StrictEvalArguments, at, {
  9677. referenceName: at.name
  9678. });
  9679. } else {
  9680. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9681. bindingName: at.name
  9682. });
  9683. }
  9684. }
  9685. if (bindingType & 8192 && at.name === "let") {
  9686. this.raise(Errors.LetInLexicalBinding, at);
  9687. }
  9688. if (!(bindingType & 64)) {
  9689. this.declareNameFromIdentifier(at, bindingType);
  9690. }
  9691. }
  9692. declareNameFromIdentifier(identifier, binding) {
  9693. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  9694. }
  9695. checkToRestConversion(node, allowPattern) {
  9696. switch (node.type) {
  9697. case "ParenthesizedExpression":
  9698. this.checkToRestConversion(node.expression, allowPattern);
  9699. break;
  9700. case "Identifier":
  9701. case "MemberExpression":
  9702. break;
  9703. case "ArrayExpression":
  9704. case "ObjectExpression":
  9705. if (allowPattern) break;
  9706. default:
  9707. this.raise(Errors.InvalidRestAssignmentPattern, node);
  9708. }
  9709. }
  9710. checkCommaAfterRest(close) {
  9711. if (!this.match(12)) {
  9712. return false;
  9713. }
  9714. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  9715. return true;
  9716. }
  9717. }
  9718. const getOwn = (object, key) => hasOwnProperty.call(object, key) && object[key];
  9719. function nonNull(x) {
  9720. if (x == null) {
  9721. throw new Error(`Unexpected ${x} value.`);
  9722. }
  9723. return x;
  9724. }
  9725. function assert$1(x) {
  9726. if (!x) {
  9727. throw new Error("Assert fail");
  9728. }
  9729. }
  9730. const TSErrors = ParseErrorEnum`typescript`({
  9731. AbstractMethodHasImplementation: ({
  9732. methodName
  9733. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  9734. AbstractPropertyHasInitializer: ({
  9735. propertyName
  9736. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  9737. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  9738. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  9739. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  9740. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  9741. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  9742. ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  9743. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  9744. DeclareAccessor: ({
  9745. kind
  9746. }) => `'declare' is not allowed in ${kind}ters.`,
  9747. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  9748. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  9749. DuplicateAccessibilityModifier: ({
  9750. modifier
  9751. }) => `Accessibility modifier already seen.`,
  9752. DuplicateModifier: ({
  9753. modifier
  9754. }) => `Duplicate modifier: '${modifier}'.`,
  9755. EmptyHeritageClauseType: ({
  9756. token
  9757. }) => `'${token}' list cannot be empty.`,
  9758. EmptyTypeArguments: "Type argument list cannot be empty.",
  9759. EmptyTypeParameters: "Type parameter list cannot be empty.",
  9760. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  9761. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  9762. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  9763. IncompatibleModifiers: ({
  9764. modifiers
  9765. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  9766. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  9767. IndexSignatureHasAccessibility: ({
  9768. modifier
  9769. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  9770. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  9771. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  9772. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  9773. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  9774. InvalidModifierOnTypeMember: ({
  9775. modifier
  9776. }) => `'${modifier}' modifier cannot appear on a type member.`,
  9777. InvalidModifierOnTypeParameter: ({
  9778. modifier
  9779. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  9780. InvalidModifierOnTypeParameterPositions: ({
  9781. modifier
  9782. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  9783. InvalidModifiersOrder: ({
  9784. orderedModifiers
  9785. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  9786. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  9787. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  9788. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  9789. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  9790. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  9791. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  9792. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  9793. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  9794. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  9795. PrivateElementHasAccessibility: ({
  9796. modifier
  9797. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  9798. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  9799. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  9800. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  9801. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  9802. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  9803. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  9804. SingleTypeParameterWithoutTrailingComma: ({
  9805. typeParameterName
  9806. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  9807. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  9808. TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",
  9809. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  9810. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  9811. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  9812. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  9813. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  9814. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  9815. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  9816. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  9817. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  9818. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  9819. UnsupportedSignatureParameterKind: ({
  9820. type
  9821. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`
  9822. });
  9823. function keywordTypeFromName(value) {
  9824. switch (value) {
  9825. case "any":
  9826. return "TSAnyKeyword";
  9827. case "boolean":
  9828. return "TSBooleanKeyword";
  9829. case "bigint":
  9830. return "TSBigIntKeyword";
  9831. case "never":
  9832. return "TSNeverKeyword";
  9833. case "number":
  9834. return "TSNumberKeyword";
  9835. case "object":
  9836. return "TSObjectKeyword";
  9837. case "string":
  9838. return "TSStringKeyword";
  9839. case "symbol":
  9840. return "TSSymbolKeyword";
  9841. case "undefined":
  9842. return "TSUndefinedKeyword";
  9843. case "unknown":
  9844. return "TSUnknownKeyword";
  9845. default:
  9846. return undefined;
  9847. }
  9848. }
  9849. function tsIsAccessModifier(modifier) {
  9850. return modifier === "private" || modifier === "public" || modifier === "protected";
  9851. }
  9852. function tsIsVarianceAnnotations(modifier) {
  9853. return modifier === "in" || modifier === "out";
  9854. }
  9855. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  9856. constructor(...args) {
  9857. super(...args);
  9858. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  9859. allowedModifiers: ["in", "out"],
  9860. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9861. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9862. });
  9863. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  9864. allowedModifiers: ["const"],
  9865. disallowedModifiers: ["in", "out"],
  9866. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  9867. });
  9868. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  9869. allowedModifiers: ["in", "out", "const"],
  9870. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9871. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9872. });
  9873. }
  9874. getScopeHandler() {
  9875. return TypeScriptScopeHandler;
  9876. }
  9877. tsIsIdentifier() {
  9878. return tokenIsIdentifier(this.state.type);
  9879. }
  9880. tsTokenCanFollowModifier() {
  9881. return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  9882. }
  9883. tsNextTokenCanFollowModifier() {
  9884. this.next();
  9885. return this.tsTokenCanFollowModifier();
  9886. }
  9887. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
  9888. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  9889. return undefined;
  9890. }
  9891. const modifier = this.state.value;
  9892. if (allowedModifiers.indexOf(modifier) !== -1) {
  9893. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  9894. return undefined;
  9895. }
  9896. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  9897. return modifier;
  9898. }
  9899. }
  9900. return undefined;
  9901. }
  9902. tsParseModifiers({
  9903. allowedModifiers,
  9904. disallowedModifiers,
  9905. stopOnStartOfClassStaticBlock,
  9906. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  9907. }, modified) {
  9908. const enforceOrder = (loc, modifier, before, after) => {
  9909. if (modifier === before && modified[after]) {
  9910. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  9911. orderedModifiers: [before, after]
  9912. });
  9913. }
  9914. };
  9915. const incompatible = (loc, modifier, mod1, mod2) => {
  9916. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  9917. this.raise(TSErrors.IncompatibleModifiers, loc, {
  9918. modifiers: [mod1, mod2]
  9919. });
  9920. }
  9921. };
  9922. for (;;) {
  9923. const {
  9924. startLoc
  9925. } = this.state;
  9926. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
  9927. if (!modifier) break;
  9928. if (tsIsAccessModifier(modifier)) {
  9929. if (modified.accessibility) {
  9930. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  9931. modifier
  9932. });
  9933. } else {
  9934. enforceOrder(startLoc, modifier, modifier, "override");
  9935. enforceOrder(startLoc, modifier, modifier, "static");
  9936. enforceOrder(startLoc, modifier, modifier, "readonly");
  9937. modified.accessibility = modifier;
  9938. }
  9939. } else if (tsIsVarianceAnnotations(modifier)) {
  9940. if (modified[modifier]) {
  9941. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9942. modifier
  9943. });
  9944. }
  9945. modified[modifier] = true;
  9946. enforceOrder(startLoc, modifier, "in", "out");
  9947. } else {
  9948. if (hasOwnProperty.call(modified, modifier)) {
  9949. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9950. modifier
  9951. });
  9952. } else {
  9953. enforceOrder(startLoc, modifier, "static", "readonly");
  9954. enforceOrder(startLoc, modifier, "static", "override");
  9955. enforceOrder(startLoc, modifier, "override", "readonly");
  9956. enforceOrder(startLoc, modifier, "abstract", "override");
  9957. incompatible(startLoc, modifier, "declare", "override");
  9958. incompatible(startLoc, modifier, "static", "abstract");
  9959. }
  9960. modified[modifier] = true;
  9961. }
  9962. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  9963. this.raise(errorTemplate, startLoc, {
  9964. modifier
  9965. });
  9966. }
  9967. }
  9968. }
  9969. tsIsListTerminator(kind) {
  9970. switch (kind) {
  9971. case "EnumMembers":
  9972. case "TypeMembers":
  9973. return this.match(8);
  9974. case "HeritageClauseElement":
  9975. return this.match(5);
  9976. case "TupleElementTypes":
  9977. return this.match(3);
  9978. case "TypeParametersOrArguments":
  9979. return this.match(48);
  9980. }
  9981. }
  9982. tsParseList(kind, parseElement) {
  9983. const result = [];
  9984. while (!this.tsIsListTerminator(kind)) {
  9985. result.push(parseElement());
  9986. }
  9987. return result;
  9988. }
  9989. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  9990. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  9991. }
  9992. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  9993. const result = [];
  9994. let trailingCommaPos = -1;
  9995. for (;;) {
  9996. if (this.tsIsListTerminator(kind)) {
  9997. break;
  9998. }
  9999. trailingCommaPos = -1;
  10000. const element = parseElement();
  10001. if (element == null) {
  10002. return undefined;
  10003. }
  10004. result.push(element);
  10005. if (this.eat(12)) {
  10006. trailingCommaPos = this.state.lastTokStartLoc.index;
  10007. continue;
  10008. }
  10009. if (this.tsIsListTerminator(kind)) {
  10010. break;
  10011. }
  10012. if (expectSuccess) {
  10013. this.expect(12);
  10014. }
  10015. return undefined;
  10016. }
  10017. if (refTrailingCommaPos) {
  10018. refTrailingCommaPos.value = trailingCommaPos;
  10019. }
  10020. return result;
  10021. }
  10022. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  10023. if (!skipFirstToken) {
  10024. if (bracket) {
  10025. this.expect(0);
  10026. } else {
  10027. this.expect(47);
  10028. }
  10029. }
  10030. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  10031. if (bracket) {
  10032. this.expect(3);
  10033. } else {
  10034. this.expect(48);
  10035. }
  10036. return result;
  10037. }
  10038. tsParseImportType() {
  10039. const node = this.startNode();
  10040. this.expect(83);
  10041. this.expect(10);
  10042. if (!this.match(133)) {
  10043. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10044. }
  10045. node.argument = super.parseExprAtom();
  10046. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  10047. node.options = null;
  10048. }
  10049. if (this.eat(12)) {
  10050. this.expectImportAttributesPlugin();
  10051. if (!this.match(11)) {
  10052. node.options = super.parseMaybeAssignAllowIn();
  10053. this.eat(12);
  10054. }
  10055. }
  10056. this.expect(11);
  10057. if (this.eat(16)) {
  10058. node.qualifier = this.tsParseEntityName();
  10059. }
  10060. if (this.match(47)) {
  10061. node.typeParameters = this.tsParseTypeArguments();
  10062. }
  10063. return this.finishNode(node, "TSImportType");
  10064. }
  10065. tsParseEntityName(allowReservedWords = true) {
  10066. let entity = this.parseIdentifier(allowReservedWords);
  10067. while (this.eat(16)) {
  10068. const node = this.startNodeAtNode(entity);
  10069. node.left = entity;
  10070. node.right = this.parseIdentifier(allowReservedWords);
  10071. entity = this.finishNode(node, "TSQualifiedName");
  10072. }
  10073. return entity;
  10074. }
  10075. tsParseTypeReference() {
  10076. const node = this.startNode();
  10077. node.typeName = this.tsParseEntityName();
  10078. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10079. node.typeParameters = this.tsParseTypeArguments();
  10080. }
  10081. return this.finishNode(node, "TSTypeReference");
  10082. }
  10083. tsParseThisTypePredicate(lhs) {
  10084. this.next();
  10085. const node = this.startNodeAtNode(lhs);
  10086. node.parameterName = lhs;
  10087. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10088. node.asserts = false;
  10089. return this.finishNode(node, "TSTypePredicate");
  10090. }
  10091. tsParseThisTypeNode() {
  10092. const node = this.startNode();
  10093. this.next();
  10094. return this.finishNode(node, "TSThisType");
  10095. }
  10096. tsParseTypeQuery() {
  10097. const node = this.startNode();
  10098. this.expect(87);
  10099. if (this.match(83)) {
  10100. node.exprName = this.tsParseImportType();
  10101. } else {
  10102. node.exprName = this.tsParseEntityName();
  10103. }
  10104. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10105. node.typeParameters = this.tsParseTypeArguments();
  10106. }
  10107. return this.finishNode(node, "TSTypeQuery");
  10108. }
  10109. tsParseTypeParameter(parseModifiers) {
  10110. const node = this.startNode();
  10111. parseModifiers(node);
  10112. node.name = this.tsParseTypeParameterName();
  10113. node.constraint = this.tsEatThenParseType(81);
  10114. node.default = this.tsEatThenParseType(29);
  10115. return this.finishNode(node, "TSTypeParameter");
  10116. }
  10117. tsTryParseTypeParameters(parseModifiers) {
  10118. if (this.match(47)) {
  10119. return this.tsParseTypeParameters(parseModifiers);
  10120. }
  10121. }
  10122. tsParseTypeParameters(parseModifiers) {
  10123. const node = this.startNode();
  10124. if (this.match(47) || this.match(142)) {
  10125. this.next();
  10126. } else {
  10127. this.unexpected();
  10128. }
  10129. const refTrailingCommaPos = {
  10130. value: -1
  10131. };
  10132. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10133. if (node.params.length === 0) {
  10134. this.raise(TSErrors.EmptyTypeParameters, node);
  10135. }
  10136. if (refTrailingCommaPos.value !== -1) {
  10137. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10138. }
  10139. return this.finishNode(node, "TSTypeParameterDeclaration");
  10140. }
  10141. tsFillSignature(returnToken, signature) {
  10142. const returnTokenRequired = returnToken === 19;
  10143. const paramsKey = "parameters";
  10144. const returnTypeKey = "typeAnnotation";
  10145. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10146. this.expect(10);
  10147. signature[paramsKey] = this.tsParseBindingListForSignature();
  10148. if (returnTokenRequired) {
  10149. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10150. } else if (this.match(returnToken)) {
  10151. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10152. }
  10153. }
  10154. tsParseBindingListForSignature() {
  10155. const list = super.parseBindingList(11, 41, 2);
  10156. for (const pattern of list) {
  10157. const {
  10158. type
  10159. } = pattern;
  10160. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10161. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10162. type
  10163. });
  10164. }
  10165. }
  10166. return list;
  10167. }
  10168. tsParseTypeMemberSemicolon() {
  10169. if (!this.eat(12) && !this.isLineTerminator()) {
  10170. this.expect(13);
  10171. }
  10172. }
  10173. tsParseSignatureMember(kind, node) {
  10174. this.tsFillSignature(14, node);
  10175. this.tsParseTypeMemberSemicolon();
  10176. return this.finishNode(node, kind);
  10177. }
  10178. tsIsUnambiguouslyIndexSignature() {
  10179. this.next();
  10180. if (tokenIsIdentifier(this.state.type)) {
  10181. this.next();
  10182. return this.match(14);
  10183. }
  10184. return false;
  10185. }
  10186. tsTryParseIndexSignature(node) {
  10187. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10188. return;
  10189. }
  10190. this.expect(0);
  10191. const id = this.parseIdentifier();
  10192. id.typeAnnotation = this.tsParseTypeAnnotation();
  10193. this.resetEndLocation(id);
  10194. this.expect(3);
  10195. node.parameters = [id];
  10196. const type = this.tsTryParseTypeAnnotation();
  10197. if (type) node.typeAnnotation = type;
  10198. this.tsParseTypeMemberSemicolon();
  10199. return this.finishNode(node, "TSIndexSignature");
  10200. }
  10201. tsParsePropertyOrMethodSignature(node, readonly) {
  10202. if (this.eat(17)) node.optional = true;
  10203. const nodeAny = node;
  10204. if (this.match(10) || this.match(47)) {
  10205. if (readonly) {
  10206. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10207. }
  10208. const method = nodeAny;
  10209. if (method.kind && this.match(47)) {
  10210. this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition());
  10211. }
  10212. this.tsFillSignature(14, method);
  10213. this.tsParseTypeMemberSemicolon();
  10214. const paramsKey = "parameters";
  10215. const returnTypeKey = "typeAnnotation";
  10216. if (method.kind === "get") {
  10217. if (method[paramsKey].length > 0) {
  10218. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10219. if (this.isThisParam(method[paramsKey][0])) {
  10220. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10221. }
  10222. }
  10223. } else if (method.kind === "set") {
  10224. if (method[paramsKey].length !== 1) {
  10225. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10226. } else {
  10227. const firstParameter = method[paramsKey][0];
  10228. if (this.isThisParam(firstParameter)) {
  10229. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10230. }
  10231. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10232. this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition());
  10233. }
  10234. if (firstParameter.type === "RestElement") {
  10235. this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition());
  10236. }
  10237. }
  10238. if (method[returnTypeKey]) {
  10239. this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]);
  10240. }
  10241. } else {
  10242. method.kind = "method";
  10243. }
  10244. return this.finishNode(method, "TSMethodSignature");
  10245. } else {
  10246. const property = nodeAny;
  10247. if (readonly) property.readonly = true;
  10248. const type = this.tsTryParseTypeAnnotation();
  10249. if (type) property.typeAnnotation = type;
  10250. this.tsParseTypeMemberSemicolon();
  10251. return this.finishNode(property, "TSPropertySignature");
  10252. }
  10253. }
  10254. tsParseTypeMember() {
  10255. const node = this.startNode();
  10256. if (this.match(10) || this.match(47)) {
  10257. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10258. }
  10259. if (this.match(77)) {
  10260. const id = this.startNode();
  10261. this.next();
  10262. if (this.match(10) || this.match(47)) {
  10263. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10264. } else {
  10265. node.key = this.createIdentifier(id, "new");
  10266. return this.tsParsePropertyOrMethodSignature(node, false);
  10267. }
  10268. }
  10269. this.tsParseModifiers({
  10270. allowedModifiers: ["readonly"],
  10271. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10272. }, node);
  10273. const idx = this.tsTryParseIndexSignature(node);
  10274. if (idx) {
  10275. return idx;
  10276. }
  10277. super.parsePropertyName(node);
  10278. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10279. node.kind = node.key.name;
  10280. super.parsePropertyName(node);
  10281. }
  10282. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10283. }
  10284. tsParseTypeLiteral() {
  10285. const node = this.startNode();
  10286. node.members = this.tsParseObjectTypeMembers();
  10287. return this.finishNode(node, "TSTypeLiteral");
  10288. }
  10289. tsParseObjectTypeMembers() {
  10290. this.expect(5);
  10291. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10292. this.expect(8);
  10293. return members;
  10294. }
  10295. tsIsStartOfMappedType() {
  10296. this.next();
  10297. if (this.eat(53)) {
  10298. return this.isContextual(122);
  10299. }
  10300. if (this.isContextual(122)) {
  10301. this.next();
  10302. }
  10303. if (!this.match(0)) {
  10304. return false;
  10305. }
  10306. this.next();
  10307. if (!this.tsIsIdentifier()) {
  10308. return false;
  10309. }
  10310. this.next();
  10311. return this.match(58);
  10312. }
  10313. tsParseMappedTypeParameter() {
  10314. const node = this.startNode();
  10315. node.name = this.tsParseTypeParameterName();
  10316. node.constraint = this.tsExpectThenParseType(58);
  10317. return this.finishNode(node, "TSTypeParameter");
  10318. }
  10319. tsParseMappedType() {
  10320. const node = this.startNode();
  10321. this.expect(5);
  10322. if (this.match(53)) {
  10323. node.readonly = this.state.value;
  10324. this.next();
  10325. this.expectContextual(122);
  10326. } else if (this.eatContextual(122)) {
  10327. node.readonly = true;
  10328. }
  10329. this.expect(0);
  10330. node.typeParameter = this.tsParseMappedTypeParameter();
  10331. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10332. this.expect(3);
  10333. if (this.match(53)) {
  10334. node.optional = this.state.value;
  10335. this.next();
  10336. this.expect(17);
  10337. } else if (this.eat(17)) {
  10338. node.optional = true;
  10339. }
  10340. node.typeAnnotation = this.tsTryParseType();
  10341. this.semicolon();
  10342. this.expect(8);
  10343. return this.finishNode(node, "TSMappedType");
  10344. }
  10345. tsParseTupleType() {
  10346. const node = this.startNode();
  10347. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10348. let seenOptionalElement = false;
  10349. node.elementTypes.forEach(elementNode => {
  10350. const {
  10351. type
  10352. } = elementNode;
  10353. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10354. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10355. }
  10356. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10357. });
  10358. return this.finishNode(node, "TSTupleType");
  10359. }
  10360. tsParseTupleElementType() {
  10361. const {
  10362. startLoc
  10363. } = this.state;
  10364. const rest = this.eat(21);
  10365. let labeled;
  10366. let label;
  10367. let optional;
  10368. let type;
  10369. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10370. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10371. if (chAfterWord === 58) {
  10372. labeled = true;
  10373. optional = false;
  10374. label = this.parseIdentifier(true);
  10375. this.expect(14);
  10376. type = this.tsParseType();
  10377. } else if (chAfterWord === 63) {
  10378. optional = true;
  10379. const startLoc = this.state.startLoc;
  10380. const wordName = this.state.value;
  10381. const typeOrLabel = this.tsParseNonArrayType();
  10382. if (this.lookaheadCharCode() === 58) {
  10383. labeled = true;
  10384. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10385. this.expect(17);
  10386. this.expect(14);
  10387. type = this.tsParseType();
  10388. } else {
  10389. labeled = false;
  10390. type = typeOrLabel;
  10391. this.expect(17);
  10392. }
  10393. } else {
  10394. type = this.tsParseType();
  10395. optional = this.eat(17);
  10396. labeled = this.eat(14);
  10397. }
  10398. if (labeled) {
  10399. let labeledNode;
  10400. if (label) {
  10401. labeledNode = this.startNodeAtNode(label);
  10402. labeledNode.optional = optional;
  10403. labeledNode.label = label;
  10404. labeledNode.elementType = type;
  10405. if (this.eat(17)) {
  10406. labeledNode.optional = true;
  10407. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10408. }
  10409. } else {
  10410. labeledNode = this.startNodeAtNode(type);
  10411. labeledNode.optional = optional;
  10412. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10413. labeledNode.label = type;
  10414. labeledNode.elementType = this.tsParseType();
  10415. }
  10416. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10417. } else if (optional) {
  10418. const optionalTypeNode = this.startNodeAtNode(type);
  10419. optionalTypeNode.typeAnnotation = type;
  10420. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10421. }
  10422. if (rest) {
  10423. const restNode = this.startNodeAt(startLoc);
  10424. restNode.typeAnnotation = type;
  10425. type = this.finishNode(restNode, "TSRestType");
  10426. }
  10427. return type;
  10428. }
  10429. tsParseParenthesizedType() {
  10430. const node = this.startNode();
  10431. this.expect(10);
  10432. node.typeAnnotation = this.tsParseType();
  10433. this.expect(11);
  10434. return this.finishNode(node, "TSParenthesizedType");
  10435. }
  10436. tsParseFunctionOrConstructorType(type, abstract) {
  10437. const node = this.startNode();
  10438. if (type === "TSConstructorType") {
  10439. node.abstract = !!abstract;
  10440. if (abstract) this.next();
  10441. this.next();
  10442. }
  10443. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10444. return this.finishNode(node, type);
  10445. }
  10446. tsParseLiteralTypeNode() {
  10447. const node = this.startNode();
  10448. switch (this.state.type) {
  10449. case 134:
  10450. case 135:
  10451. case 133:
  10452. case 85:
  10453. case 86:
  10454. node.literal = super.parseExprAtom();
  10455. break;
  10456. default:
  10457. this.unexpected();
  10458. }
  10459. return this.finishNode(node, "TSLiteralType");
  10460. }
  10461. tsParseTemplateLiteralType() {
  10462. const node = this.startNode();
  10463. node.literal = super.parseTemplate(false);
  10464. return this.finishNode(node, "TSLiteralType");
  10465. }
  10466. parseTemplateSubstitution() {
  10467. if (this.state.inType) return this.tsParseType();
  10468. return super.parseTemplateSubstitution();
  10469. }
  10470. tsParseThisTypeOrThisTypePredicate() {
  10471. const thisKeyword = this.tsParseThisTypeNode();
  10472. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10473. return this.tsParseThisTypePredicate(thisKeyword);
  10474. } else {
  10475. return thisKeyword;
  10476. }
  10477. }
  10478. tsParseNonArrayType() {
  10479. switch (this.state.type) {
  10480. case 133:
  10481. case 134:
  10482. case 135:
  10483. case 85:
  10484. case 86:
  10485. return this.tsParseLiteralTypeNode();
  10486. case 53:
  10487. if (this.state.value === "-") {
  10488. const node = this.startNode();
  10489. const nextToken = this.lookahead();
  10490. if (nextToken.type !== 134 && nextToken.type !== 135) {
  10491. this.unexpected();
  10492. }
  10493. node.literal = this.parseMaybeUnary();
  10494. return this.finishNode(node, "TSLiteralType");
  10495. }
  10496. break;
  10497. case 78:
  10498. return this.tsParseThisTypeOrThisTypePredicate();
  10499. case 87:
  10500. return this.tsParseTypeQuery();
  10501. case 83:
  10502. return this.tsParseImportType();
  10503. case 5:
  10504. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10505. case 0:
  10506. return this.tsParseTupleType();
  10507. case 10:
  10508. return this.tsParseParenthesizedType();
  10509. case 25:
  10510. case 24:
  10511. return this.tsParseTemplateLiteralType();
  10512. default:
  10513. {
  10514. const {
  10515. type
  10516. } = this.state;
  10517. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10518. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10519. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10520. const node = this.startNode();
  10521. this.next();
  10522. return this.finishNode(node, nodeType);
  10523. }
  10524. return this.tsParseTypeReference();
  10525. }
  10526. }
  10527. }
  10528. this.unexpected();
  10529. }
  10530. tsParseArrayTypeOrHigher() {
  10531. let type = this.tsParseNonArrayType();
  10532. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10533. if (this.match(3)) {
  10534. const node = this.startNodeAtNode(type);
  10535. node.elementType = type;
  10536. this.expect(3);
  10537. type = this.finishNode(node, "TSArrayType");
  10538. } else {
  10539. const node = this.startNodeAtNode(type);
  10540. node.objectType = type;
  10541. node.indexType = this.tsParseType();
  10542. this.expect(3);
  10543. type = this.finishNode(node, "TSIndexedAccessType");
  10544. }
  10545. }
  10546. return type;
  10547. }
  10548. tsParseTypeOperator() {
  10549. const node = this.startNode();
  10550. const operator = this.state.value;
  10551. this.next();
  10552. node.operator = operator;
  10553. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10554. if (operator === "readonly") {
  10555. this.tsCheckTypeAnnotationForReadOnly(node);
  10556. }
  10557. return this.finishNode(node, "TSTypeOperator");
  10558. }
  10559. tsCheckTypeAnnotationForReadOnly(node) {
  10560. switch (node.typeAnnotation.type) {
  10561. case "TSTupleType":
  10562. case "TSArrayType":
  10563. return;
  10564. default:
  10565. this.raise(TSErrors.UnexpectedReadonly, node);
  10566. }
  10567. }
  10568. tsParseInferType() {
  10569. const node = this.startNode();
  10570. this.expectContextual(115);
  10571. const typeParameter = this.startNode();
  10572. typeParameter.name = this.tsParseTypeParameterName();
  10573. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10574. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10575. return this.finishNode(node, "TSInferType");
  10576. }
  10577. tsParseConstraintForInferType() {
  10578. if (this.eat(81)) {
  10579. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10580. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10581. return constraint;
  10582. }
  10583. }
  10584. }
  10585. tsParseTypeOperatorOrHigher() {
  10586. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10587. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10588. }
  10589. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10590. const node = this.startNode();
  10591. const hasLeadingOperator = this.eat(operator);
  10592. const types = [];
  10593. do {
  10594. types.push(parseConstituentType());
  10595. } while (this.eat(operator));
  10596. if (types.length === 1 && !hasLeadingOperator) {
  10597. return types[0];
  10598. }
  10599. node.types = types;
  10600. return this.finishNode(node, kind);
  10601. }
  10602. tsParseIntersectionTypeOrHigher() {
  10603. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10604. }
  10605. tsParseUnionTypeOrHigher() {
  10606. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  10607. }
  10608. tsIsStartOfFunctionType() {
  10609. if (this.match(47)) {
  10610. return true;
  10611. }
  10612. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  10613. }
  10614. tsSkipParameterStart() {
  10615. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  10616. this.next();
  10617. return true;
  10618. }
  10619. if (this.match(5)) {
  10620. const {
  10621. errors
  10622. } = this.state;
  10623. const previousErrorCount = errors.length;
  10624. try {
  10625. this.parseObjectLike(8, true);
  10626. return errors.length === previousErrorCount;
  10627. } catch (_unused) {
  10628. return false;
  10629. }
  10630. }
  10631. if (this.match(0)) {
  10632. this.next();
  10633. const {
  10634. errors
  10635. } = this.state;
  10636. const previousErrorCount = errors.length;
  10637. try {
  10638. super.parseBindingList(3, 93, 1);
  10639. return errors.length === previousErrorCount;
  10640. } catch (_unused2) {
  10641. return false;
  10642. }
  10643. }
  10644. return false;
  10645. }
  10646. tsIsUnambiguouslyStartOfFunctionType() {
  10647. this.next();
  10648. if (this.match(11) || this.match(21)) {
  10649. return true;
  10650. }
  10651. if (this.tsSkipParameterStart()) {
  10652. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  10653. return true;
  10654. }
  10655. if (this.match(11)) {
  10656. this.next();
  10657. if (this.match(19)) {
  10658. return true;
  10659. }
  10660. }
  10661. }
  10662. return false;
  10663. }
  10664. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  10665. return this.tsInType(() => {
  10666. const t = this.startNode();
  10667. this.expect(returnToken);
  10668. const node = this.startNode();
  10669. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  10670. if (asserts && this.match(78)) {
  10671. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  10672. if (thisTypePredicate.type === "TSThisType") {
  10673. node.parameterName = thisTypePredicate;
  10674. node.asserts = true;
  10675. node.typeAnnotation = null;
  10676. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  10677. } else {
  10678. this.resetStartLocationFromNode(thisTypePredicate, node);
  10679. thisTypePredicate.asserts = true;
  10680. }
  10681. t.typeAnnotation = thisTypePredicate;
  10682. return this.finishNode(t, "TSTypeAnnotation");
  10683. }
  10684. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  10685. if (!typePredicateVariable) {
  10686. if (!asserts) {
  10687. return this.tsParseTypeAnnotation(false, t);
  10688. }
  10689. node.parameterName = this.parseIdentifier();
  10690. node.asserts = asserts;
  10691. node.typeAnnotation = null;
  10692. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10693. return this.finishNode(t, "TSTypeAnnotation");
  10694. }
  10695. const type = this.tsParseTypeAnnotation(false);
  10696. node.parameterName = typePredicateVariable;
  10697. node.typeAnnotation = type;
  10698. node.asserts = asserts;
  10699. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10700. return this.finishNode(t, "TSTypeAnnotation");
  10701. });
  10702. }
  10703. tsTryParseTypeOrTypePredicateAnnotation() {
  10704. if (this.match(14)) {
  10705. return this.tsParseTypeOrTypePredicateAnnotation(14);
  10706. }
  10707. }
  10708. tsTryParseTypeAnnotation() {
  10709. if (this.match(14)) {
  10710. return this.tsParseTypeAnnotation();
  10711. }
  10712. }
  10713. tsTryParseType() {
  10714. return this.tsEatThenParseType(14);
  10715. }
  10716. tsParseTypePredicatePrefix() {
  10717. const id = this.parseIdentifier();
  10718. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10719. this.next();
  10720. return id;
  10721. }
  10722. }
  10723. tsParseTypePredicateAsserts() {
  10724. if (this.state.type !== 109) {
  10725. return false;
  10726. }
  10727. const containsEsc = this.state.containsEsc;
  10728. this.next();
  10729. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  10730. return false;
  10731. }
  10732. if (containsEsc) {
  10733. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  10734. reservedWord: "asserts"
  10735. });
  10736. }
  10737. return true;
  10738. }
  10739. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  10740. this.tsInType(() => {
  10741. if (eatColon) this.expect(14);
  10742. t.typeAnnotation = this.tsParseType();
  10743. });
  10744. return this.finishNode(t, "TSTypeAnnotation");
  10745. }
  10746. tsParseType() {
  10747. assert$1(this.state.inType);
  10748. const type = this.tsParseNonConditionalType();
  10749. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  10750. return type;
  10751. }
  10752. const node = this.startNodeAtNode(type);
  10753. node.checkType = type;
  10754. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  10755. this.expect(17);
  10756. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10757. this.expect(14);
  10758. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10759. return this.finishNode(node, "TSConditionalType");
  10760. }
  10761. isAbstractConstructorSignature() {
  10762. return this.isContextual(124) && this.lookahead().type === 77;
  10763. }
  10764. tsParseNonConditionalType() {
  10765. if (this.tsIsStartOfFunctionType()) {
  10766. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  10767. }
  10768. if (this.match(77)) {
  10769. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  10770. } else if (this.isAbstractConstructorSignature()) {
  10771. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  10772. }
  10773. return this.tsParseUnionTypeOrHigher();
  10774. }
  10775. tsParseTypeAssertion() {
  10776. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  10777. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  10778. }
  10779. const node = this.startNode();
  10780. node.typeAnnotation = this.tsInType(() => {
  10781. this.next();
  10782. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  10783. });
  10784. this.expect(48);
  10785. node.expression = this.parseMaybeUnary();
  10786. return this.finishNode(node, "TSTypeAssertion");
  10787. }
  10788. tsParseHeritageClause(token) {
  10789. const originalStartLoc = this.state.startLoc;
  10790. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  10791. const node = this.startNode();
  10792. node.expression = this.tsParseEntityName();
  10793. if (this.match(47)) {
  10794. node.typeParameters = this.tsParseTypeArguments();
  10795. }
  10796. return this.finishNode(node, "TSExpressionWithTypeArguments");
  10797. });
  10798. if (!delimitedList.length) {
  10799. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  10800. token
  10801. });
  10802. }
  10803. return delimitedList;
  10804. }
  10805. tsParseInterfaceDeclaration(node, properties = {}) {
  10806. if (this.hasFollowingLineBreak()) return null;
  10807. this.expectContextual(129);
  10808. if (properties.declare) node.declare = true;
  10809. if (tokenIsIdentifier(this.state.type)) {
  10810. node.id = this.parseIdentifier();
  10811. this.checkIdentifier(node.id, 130);
  10812. } else {
  10813. node.id = null;
  10814. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  10815. }
  10816. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  10817. if (this.eat(81)) {
  10818. node.extends = this.tsParseHeritageClause("extends");
  10819. }
  10820. const body = this.startNode();
  10821. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  10822. node.body = this.finishNode(body, "TSInterfaceBody");
  10823. return this.finishNode(node, "TSInterfaceDeclaration");
  10824. }
  10825. tsParseTypeAliasDeclaration(node) {
  10826. node.id = this.parseIdentifier();
  10827. this.checkIdentifier(node.id, 2);
  10828. node.typeAnnotation = this.tsInType(() => {
  10829. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  10830. this.expect(29);
  10831. if (this.isContextual(114) && this.lookahead().type !== 16) {
  10832. const node = this.startNode();
  10833. this.next();
  10834. return this.finishNode(node, "TSIntrinsicKeyword");
  10835. }
  10836. return this.tsParseType();
  10837. });
  10838. this.semicolon();
  10839. return this.finishNode(node, "TSTypeAliasDeclaration");
  10840. }
  10841. tsInNoContext(cb) {
  10842. const oldContext = this.state.context;
  10843. this.state.context = [oldContext[0]];
  10844. try {
  10845. return cb();
  10846. } finally {
  10847. this.state.context = oldContext;
  10848. }
  10849. }
  10850. tsInType(cb) {
  10851. const oldInType = this.state.inType;
  10852. this.state.inType = true;
  10853. try {
  10854. return cb();
  10855. } finally {
  10856. this.state.inType = oldInType;
  10857. }
  10858. }
  10859. tsInDisallowConditionalTypesContext(cb) {
  10860. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10861. this.state.inDisallowConditionalTypesContext = true;
  10862. try {
  10863. return cb();
  10864. } finally {
  10865. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10866. }
  10867. }
  10868. tsInAllowConditionalTypesContext(cb) {
  10869. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10870. this.state.inDisallowConditionalTypesContext = false;
  10871. try {
  10872. return cb();
  10873. } finally {
  10874. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10875. }
  10876. }
  10877. tsEatThenParseType(token) {
  10878. if (this.match(token)) {
  10879. return this.tsNextThenParseType();
  10880. }
  10881. }
  10882. tsExpectThenParseType(token) {
  10883. return this.tsInType(() => {
  10884. this.expect(token);
  10885. return this.tsParseType();
  10886. });
  10887. }
  10888. tsNextThenParseType() {
  10889. return this.tsInType(() => {
  10890. this.next();
  10891. return this.tsParseType();
  10892. });
  10893. }
  10894. tsParseEnumMember() {
  10895. const node = this.startNode();
  10896. node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  10897. if (this.eat(29)) {
  10898. node.initializer = super.parseMaybeAssignAllowIn();
  10899. }
  10900. return this.finishNode(node, "TSEnumMember");
  10901. }
  10902. tsParseEnumDeclaration(node, properties = {}) {
  10903. if (properties.const) node.const = true;
  10904. if (properties.declare) node.declare = true;
  10905. this.expectContextual(126);
  10906. node.id = this.parseIdentifier();
  10907. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  10908. this.expect(5);
  10909. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  10910. this.expect(8);
  10911. return this.finishNode(node, "TSEnumDeclaration");
  10912. }
  10913. tsParseModuleBlock() {
  10914. const node = this.startNode();
  10915. this.scope.enter(0);
  10916. this.expect(5);
  10917. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  10918. this.scope.exit();
  10919. return this.finishNode(node, "TSModuleBlock");
  10920. }
  10921. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  10922. node.id = this.parseIdentifier();
  10923. if (!nested) {
  10924. this.checkIdentifier(node.id, 1024);
  10925. }
  10926. if (this.eat(16)) {
  10927. const inner = this.startNode();
  10928. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  10929. node.body = inner;
  10930. } else {
  10931. this.scope.enter(256);
  10932. this.prodParam.enter(0);
  10933. node.body = this.tsParseModuleBlock();
  10934. this.prodParam.exit();
  10935. this.scope.exit();
  10936. }
  10937. return this.finishNode(node, "TSModuleDeclaration");
  10938. }
  10939. tsParseAmbientExternalModuleDeclaration(node) {
  10940. if (this.isContextual(112)) {
  10941. node.global = true;
  10942. node.id = this.parseIdentifier();
  10943. } else if (this.match(133)) {
  10944. node.id = super.parseStringLiteral(this.state.value);
  10945. } else {
  10946. this.unexpected();
  10947. }
  10948. if (this.match(5)) {
  10949. this.scope.enter(256);
  10950. this.prodParam.enter(0);
  10951. node.body = this.tsParseModuleBlock();
  10952. this.prodParam.exit();
  10953. this.scope.exit();
  10954. } else {
  10955. this.semicolon();
  10956. }
  10957. return this.finishNode(node, "TSModuleDeclaration");
  10958. }
  10959. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  10960. node.isExport = isExport || false;
  10961. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  10962. this.checkIdentifier(node.id, 4096);
  10963. this.expect(29);
  10964. const moduleReference = this.tsParseModuleReference();
  10965. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  10966. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  10967. }
  10968. node.moduleReference = moduleReference;
  10969. this.semicolon();
  10970. return this.finishNode(node, "TSImportEqualsDeclaration");
  10971. }
  10972. tsIsExternalModuleReference() {
  10973. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  10974. }
  10975. tsParseModuleReference() {
  10976. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  10977. }
  10978. tsParseExternalModuleReference() {
  10979. const node = this.startNode();
  10980. this.expectContextual(119);
  10981. this.expect(10);
  10982. if (!this.match(133)) {
  10983. this.unexpected();
  10984. }
  10985. node.expression = super.parseExprAtom();
  10986. this.expect(11);
  10987. this.sawUnambiguousESM = true;
  10988. return this.finishNode(node, "TSExternalModuleReference");
  10989. }
  10990. tsLookAhead(f) {
  10991. const state = this.state.clone();
  10992. const res = f();
  10993. this.state = state;
  10994. return res;
  10995. }
  10996. tsTryParseAndCatch(f) {
  10997. const result = this.tryParse(abort => f() || abort());
  10998. if (result.aborted || !result.node) return;
  10999. if (result.error) this.state = result.failState;
  11000. return result.node;
  11001. }
  11002. tsTryParse(f) {
  11003. const state = this.state.clone();
  11004. const result = f();
  11005. if (result !== undefined && result !== false) {
  11006. return result;
  11007. }
  11008. this.state = state;
  11009. }
  11010. tsTryParseDeclare(nany) {
  11011. if (this.isLineTerminator()) {
  11012. return;
  11013. }
  11014. let startType = this.state.type;
  11015. let kind;
  11016. if (this.isContextual(100)) {
  11017. startType = 74;
  11018. kind = "let";
  11019. }
  11020. return this.tsInAmbientContext(() => {
  11021. switch (startType) {
  11022. case 68:
  11023. nany.declare = true;
  11024. return super.parseFunctionStatement(nany, false, false);
  11025. case 80:
  11026. nany.declare = true;
  11027. return this.parseClass(nany, true, false);
  11028. case 126:
  11029. return this.tsParseEnumDeclaration(nany, {
  11030. declare: true
  11031. });
  11032. case 112:
  11033. return this.tsParseAmbientExternalModuleDeclaration(nany);
  11034. case 75:
  11035. case 74:
  11036. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11037. nany.declare = true;
  11038. return this.parseVarStatement(nany, kind || this.state.value, true);
  11039. }
  11040. this.expect(75);
  11041. return this.tsParseEnumDeclaration(nany, {
  11042. const: true,
  11043. declare: true
  11044. });
  11045. case 129:
  11046. {
  11047. const result = this.tsParseInterfaceDeclaration(nany, {
  11048. declare: true
  11049. });
  11050. if (result) return result;
  11051. }
  11052. default:
  11053. if (tokenIsIdentifier(startType)) {
  11054. return this.tsParseDeclaration(nany, this.state.value, true, null);
  11055. }
  11056. }
  11057. });
  11058. }
  11059. tsTryParseExportDeclaration() {
  11060. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11061. }
  11062. tsParseExpressionStatement(node, expr, decorators) {
  11063. switch (expr.name) {
  11064. case "declare":
  11065. {
  11066. const declaration = this.tsTryParseDeclare(node);
  11067. if (declaration) {
  11068. declaration.declare = true;
  11069. }
  11070. return declaration;
  11071. }
  11072. case "global":
  11073. if (this.match(5)) {
  11074. this.scope.enter(256);
  11075. this.prodParam.enter(0);
  11076. const mod = node;
  11077. mod.global = true;
  11078. mod.id = expr;
  11079. mod.body = this.tsParseModuleBlock();
  11080. this.scope.exit();
  11081. this.prodParam.exit();
  11082. return this.finishNode(mod, "TSModuleDeclaration");
  11083. }
  11084. break;
  11085. default:
  11086. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11087. }
  11088. }
  11089. tsParseDeclaration(node, value, next, decorators) {
  11090. switch (value) {
  11091. case "abstract":
  11092. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11093. return this.tsParseAbstractDeclaration(node, decorators);
  11094. }
  11095. break;
  11096. case "module":
  11097. if (this.tsCheckLineTerminator(next)) {
  11098. if (this.match(133)) {
  11099. return this.tsParseAmbientExternalModuleDeclaration(node);
  11100. } else if (tokenIsIdentifier(this.state.type)) {
  11101. return this.tsParseModuleOrNamespaceDeclaration(node);
  11102. }
  11103. }
  11104. break;
  11105. case "namespace":
  11106. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11107. return this.tsParseModuleOrNamespaceDeclaration(node);
  11108. }
  11109. break;
  11110. case "type":
  11111. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11112. return this.tsParseTypeAliasDeclaration(node);
  11113. }
  11114. break;
  11115. }
  11116. }
  11117. tsCheckLineTerminator(next) {
  11118. if (next) {
  11119. if (this.hasFollowingLineBreak()) return false;
  11120. this.next();
  11121. return true;
  11122. }
  11123. return !this.isLineTerminator();
  11124. }
  11125. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11126. if (!this.match(47)) return;
  11127. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11128. this.state.maybeInArrowParameters = true;
  11129. const res = this.tsTryParseAndCatch(() => {
  11130. const node = this.startNodeAt(startLoc);
  11131. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11132. super.parseFunctionParams(node);
  11133. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11134. this.expect(19);
  11135. return node;
  11136. });
  11137. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11138. if (!res) return;
  11139. return super.parseArrowExpression(res, null, true);
  11140. }
  11141. tsParseTypeArgumentsInExpression() {
  11142. if (this.reScan_lt() !== 47) return;
  11143. return this.tsParseTypeArguments();
  11144. }
  11145. tsParseTypeArguments() {
  11146. const node = this.startNode();
  11147. node.params = this.tsInType(() => this.tsInNoContext(() => {
  11148. this.expect(47);
  11149. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11150. }));
  11151. if (node.params.length === 0) {
  11152. this.raise(TSErrors.EmptyTypeArguments, node);
  11153. } else if (!this.state.inType && this.curContext() === types$1.brace) {
  11154. this.reScan_lt_gt();
  11155. }
  11156. this.expect(48);
  11157. return this.finishNode(node, "TSTypeParameterInstantiation");
  11158. }
  11159. tsIsDeclarationStart() {
  11160. return tokenIsTSDeclarationStart(this.state.type);
  11161. }
  11162. isExportDefaultSpecifier() {
  11163. if (this.tsIsDeclarationStart()) return false;
  11164. return super.isExportDefaultSpecifier();
  11165. }
  11166. parseAssignableListItem(flags, decorators) {
  11167. const startLoc = this.state.startLoc;
  11168. const modified = {};
  11169. this.tsParseModifiers({
  11170. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11171. }, modified);
  11172. const accessibility = modified.accessibility;
  11173. const override = modified.override;
  11174. const readonly = modified.readonly;
  11175. if (!(flags & 4) && (accessibility || readonly || override)) {
  11176. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11177. }
  11178. const left = this.parseMaybeDefault();
  11179. this.parseAssignableListItemTypes(left, flags);
  11180. const elt = this.parseMaybeDefault(left.loc.start, left);
  11181. if (accessibility || readonly || override) {
  11182. const pp = this.startNodeAt(startLoc);
  11183. if (decorators.length) {
  11184. pp.decorators = decorators;
  11185. }
  11186. if (accessibility) pp.accessibility = accessibility;
  11187. if (readonly) pp.readonly = readonly;
  11188. if (override) pp.override = override;
  11189. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11190. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11191. }
  11192. pp.parameter = elt;
  11193. return this.finishNode(pp, "TSParameterProperty");
  11194. }
  11195. if (decorators.length) {
  11196. left.decorators = decorators;
  11197. }
  11198. return elt;
  11199. }
  11200. isSimpleParameter(node) {
  11201. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11202. }
  11203. tsDisallowOptionalPattern(node) {
  11204. for (const param of node.params) {
  11205. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11206. this.raise(TSErrors.PatternIsOptional, param);
  11207. }
  11208. }
  11209. }
  11210. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11211. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11212. this.tsDisallowOptionalPattern(node);
  11213. }
  11214. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11215. if (this.match(14)) {
  11216. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11217. }
  11218. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11219. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11220. return this.finishNode(node, bodilessType);
  11221. }
  11222. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11223. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11224. if (node.declare) {
  11225. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11226. }
  11227. }
  11228. this.tsDisallowOptionalPattern(node);
  11229. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11230. }
  11231. registerFunctionStatementId(node) {
  11232. if (!node.body && node.id) {
  11233. this.checkIdentifier(node.id, 1024);
  11234. } else {
  11235. super.registerFunctionStatementId(node);
  11236. }
  11237. }
  11238. tsCheckForInvalidTypeCasts(items) {
  11239. items.forEach(node => {
  11240. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11241. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11242. }
  11243. });
  11244. }
  11245. toReferencedList(exprList, isInParens) {
  11246. this.tsCheckForInvalidTypeCasts(exprList);
  11247. return exprList;
  11248. }
  11249. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11250. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11251. if (node.type === "ArrayExpression") {
  11252. this.tsCheckForInvalidTypeCasts(node.elements);
  11253. }
  11254. return node;
  11255. }
  11256. parseSubscript(base, startLoc, noCalls, state) {
  11257. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11258. this.state.canStartJSXElement = false;
  11259. this.next();
  11260. const nonNullExpression = this.startNodeAt(startLoc);
  11261. nonNullExpression.expression = base;
  11262. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11263. }
  11264. let isOptionalCall = false;
  11265. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11266. if (noCalls) {
  11267. state.stop = true;
  11268. return base;
  11269. }
  11270. state.optionalChainMember = isOptionalCall = true;
  11271. this.next();
  11272. }
  11273. if (this.match(47) || this.match(51)) {
  11274. let missingParenErrorLoc;
  11275. const result = this.tsTryParseAndCatch(() => {
  11276. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11277. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11278. if (asyncArrowFn) {
  11279. return asyncArrowFn;
  11280. }
  11281. }
  11282. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11283. if (!typeArguments) return;
  11284. if (isOptionalCall && !this.match(10)) {
  11285. missingParenErrorLoc = this.state.curPosition();
  11286. return;
  11287. }
  11288. if (tokenIsTemplate(this.state.type)) {
  11289. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11290. result.typeParameters = typeArguments;
  11291. return result;
  11292. }
  11293. if (!noCalls && this.eat(10)) {
  11294. const node = this.startNodeAt(startLoc);
  11295. node.callee = base;
  11296. node.arguments = this.parseCallExpressionArguments(11, false);
  11297. this.tsCheckForInvalidTypeCasts(node.arguments);
  11298. node.typeParameters = typeArguments;
  11299. if (state.optionalChainMember) {
  11300. node.optional = isOptionalCall;
  11301. }
  11302. return this.finishCallExpression(node, state.optionalChainMember);
  11303. }
  11304. const tokenType = this.state.type;
  11305. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11306. return;
  11307. }
  11308. const node = this.startNodeAt(startLoc);
  11309. node.expression = base;
  11310. node.typeParameters = typeArguments;
  11311. return this.finishNode(node, "TSInstantiationExpression");
  11312. });
  11313. if (missingParenErrorLoc) {
  11314. this.unexpected(missingParenErrorLoc, 10);
  11315. }
  11316. if (result) {
  11317. if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
  11318. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11319. }
  11320. return result;
  11321. }
  11322. }
  11323. return super.parseSubscript(base, startLoc, noCalls, state);
  11324. }
  11325. parseNewCallee(node) {
  11326. var _callee$extra;
  11327. super.parseNewCallee(node);
  11328. const {
  11329. callee
  11330. } = node;
  11331. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11332. node.typeParameters = callee.typeParameters;
  11333. node.callee = callee.expression;
  11334. }
  11335. }
  11336. parseExprOp(left, leftStartLoc, minPrec) {
  11337. let isSatisfies;
  11338. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11339. const node = this.startNodeAt(leftStartLoc);
  11340. node.expression = left;
  11341. node.typeAnnotation = this.tsInType(() => {
  11342. this.next();
  11343. if (this.match(75)) {
  11344. if (isSatisfies) {
  11345. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11346. keyword: "const"
  11347. });
  11348. }
  11349. return this.tsParseTypeReference();
  11350. }
  11351. return this.tsParseType();
  11352. });
  11353. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11354. this.reScan_lt_gt();
  11355. return this.parseExprOp(node, leftStartLoc, minPrec);
  11356. }
  11357. return super.parseExprOp(left, leftStartLoc, minPrec);
  11358. }
  11359. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11360. if (!this.state.isAmbientContext) {
  11361. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11362. }
  11363. }
  11364. checkImportReflection(node) {
  11365. super.checkImportReflection(node);
  11366. if (node.module && node.importKind !== "value") {
  11367. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11368. }
  11369. }
  11370. checkDuplicateExports() {}
  11371. isPotentialImportPhase(isExport) {
  11372. if (super.isPotentialImportPhase(isExport)) return true;
  11373. if (this.isContextual(130)) {
  11374. const ch = this.lookaheadCharCode();
  11375. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11376. }
  11377. return !isExport && this.isContextual(87);
  11378. }
  11379. applyImportPhase(node, isExport, phase, loc) {
  11380. super.applyImportPhase(node, isExport, phase, loc);
  11381. if (isExport) {
  11382. node.exportKind = phase === "type" ? "type" : "value";
  11383. } else {
  11384. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11385. }
  11386. }
  11387. parseImport(node) {
  11388. if (this.match(133)) {
  11389. node.importKind = "value";
  11390. return super.parseImport(node);
  11391. }
  11392. let importNode;
  11393. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11394. node.importKind = "value";
  11395. return this.tsParseImportEqualsDeclaration(node);
  11396. } else if (this.isContextual(130)) {
  11397. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11398. if (this.lookaheadCharCode() === 61) {
  11399. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11400. } else {
  11401. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11402. }
  11403. } else {
  11404. importNode = super.parseImport(node);
  11405. }
  11406. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11407. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11408. }
  11409. return importNode;
  11410. }
  11411. parseExport(node, decorators) {
  11412. if (this.match(83)) {
  11413. this.next();
  11414. let maybeDefaultIdentifier = null;
  11415. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11416. maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11417. } else {
  11418. node.importKind = "value";
  11419. }
  11420. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, true);
  11421. } else if (this.eat(29)) {
  11422. const assign = node;
  11423. assign.expression = super.parseExpression();
  11424. this.semicolon();
  11425. this.sawUnambiguousESM = true;
  11426. return this.finishNode(assign, "TSExportAssignment");
  11427. } else if (this.eatContextual(93)) {
  11428. const decl = node;
  11429. this.expectContextual(128);
  11430. decl.id = this.parseIdentifier();
  11431. this.semicolon();
  11432. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11433. } else {
  11434. return super.parseExport(node, decorators);
  11435. }
  11436. }
  11437. isAbstractClass() {
  11438. return this.isContextual(124) && this.lookahead().type === 80;
  11439. }
  11440. parseExportDefaultExpression() {
  11441. if (this.isAbstractClass()) {
  11442. const cls = this.startNode();
  11443. this.next();
  11444. cls.abstract = true;
  11445. return this.parseClass(cls, true, true);
  11446. }
  11447. if (this.match(129)) {
  11448. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11449. if (result) return result;
  11450. }
  11451. return super.parseExportDefaultExpression();
  11452. }
  11453. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11454. const {
  11455. isAmbientContext
  11456. } = this.state;
  11457. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11458. if (!isAmbientContext) return declaration;
  11459. for (const {
  11460. id,
  11461. init
  11462. } of declaration.declarations) {
  11463. if (!init) continue;
  11464. if (kind !== "const" || !!id.typeAnnotation) {
  11465. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11466. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11467. this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11468. }
  11469. }
  11470. return declaration;
  11471. }
  11472. parseStatementContent(flags, decorators) {
  11473. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11474. const node = this.startNode();
  11475. this.expect(75);
  11476. return this.tsParseEnumDeclaration(node, {
  11477. const: true
  11478. });
  11479. }
  11480. if (this.isContextual(126)) {
  11481. return this.tsParseEnumDeclaration(this.startNode());
  11482. }
  11483. if (this.isContextual(129)) {
  11484. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11485. if (result) return result;
  11486. }
  11487. return super.parseStatementContent(flags, decorators);
  11488. }
  11489. parseAccessModifier() {
  11490. return this.tsParseModifier(["public", "protected", "private"]);
  11491. }
  11492. tsHasSomeModifiers(member, modifiers) {
  11493. return modifiers.some(modifier => {
  11494. if (tsIsAccessModifier(modifier)) {
  11495. return member.accessibility === modifier;
  11496. }
  11497. return !!member[modifier];
  11498. });
  11499. }
  11500. tsIsStartOfStaticBlocks() {
  11501. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11502. }
  11503. parseClassMember(classBody, member, state) {
  11504. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11505. this.tsParseModifiers({
  11506. allowedModifiers: modifiers,
  11507. disallowedModifiers: ["in", "out"],
  11508. stopOnStartOfClassStaticBlock: true,
  11509. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11510. }, member);
  11511. const callParseClassMemberWithIsStatic = () => {
  11512. if (this.tsIsStartOfStaticBlocks()) {
  11513. this.next();
  11514. this.next();
  11515. if (this.tsHasSomeModifiers(member, modifiers)) {
  11516. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11517. }
  11518. super.parseClassStaticBlock(classBody, member);
  11519. } else {
  11520. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11521. }
  11522. };
  11523. if (member.declare) {
  11524. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11525. } else {
  11526. callParseClassMemberWithIsStatic();
  11527. }
  11528. }
  11529. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11530. const idx = this.tsTryParseIndexSignature(member);
  11531. if (idx) {
  11532. classBody.body.push(idx);
  11533. if (member.abstract) {
  11534. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11535. }
  11536. if (member.accessibility) {
  11537. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11538. modifier: member.accessibility
  11539. });
  11540. }
  11541. if (member.declare) {
  11542. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  11543. }
  11544. if (member.override) {
  11545. this.raise(TSErrors.IndexSignatureHasOverride, member);
  11546. }
  11547. return;
  11548. }
  11549. if (!this.state.inAbstractClass && member.abstract) {
  11550. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  11551. }
  11552. if (member.override) {
  11553. if (!state.hadSuperClass) {
  11554. this.raise(TSErrors.OverrideNotInSubClass, member);
  11555. }
  11556. }
  11557. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  11558. }
  11559. parsePostMemberNameModifiers(methodOrProp) {
  11560. const optional = this.eat(17);
  11561. if (optional) methodOrProp.optional = true;
  11562. if (methodOrProp.readonly && this.match(10)) {
  11563. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  11564. }
  11565. if (methodOrProp.declare && this.match(10)) {
  11566. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  11567. }
  11568. }
  11569. parseExpressionStatement(node, expr, decorators) {
  11570. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  11571. return decl || super.parseExpressionStatement(node, expr, decorators);
  11572. }
  11573. shouldParseExportDeclaration() {
  11574. if (this.tsIsDeclarationStart()) return true;
  11575. return super.shouldParseExportDeclaration();
  11576. }
  11577. parseConditional(expr, startLoc, refExpressionErrors) {
  11578. if (!this.state.maybeInArrowParameters || !this.match(17)) {
  11579. return super.parseConditional(expr, startLoc, refExpressionErrors);
  11580. }
  11581. const result = this.tryParse(() => super.parseConditional(expr, startLoc));
  11582. if (!result.node) {
  11583. if (result.error) {
  11584. super.setOptionalParametersError(refExpressionErrors, result.error);
  11585. }
  11586. return expr;
  11587. }
  11588. if (result.error) this.state = result.failState;
  11589. return result.node;
  11590. }
  11591. parseParenItem(node, startLoc) {
  11592. node = super.parseParenItem(node, startLoc);
  11593. if (this.eat(17)) {
  11594. node.optional = true;
  11595. this.resetEndLocation(node);
  11596. }
  11597. if (this.match(14)) {
  11598. const typeCastNode = this.startNodeAt(startLoc);
  11599. typeCastNode.expression = node;
  11600. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  11601. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  11602. }
  11603. return node;
  11604. }
  11605. parseExportDeclaration(node) {
  11606. if (!this.state.isAmbientContext && this.isContextual(125)) {
  11607. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  11608. }
  11609. const startLoc = this.state.startLoc;
  11610. const isDeclare = this.eatContextual(125);
  11611. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  11612. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  11613. }
  11614. const isIdentifier = tokenIsIdentifier(this.state.type);
  11615. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  11616. if (!declaration) return null;
  11617. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  11618. node.exportKind = "type";
  11619. }
  11620. if (isDeclare) {
  11621. this.resetStartLocation(declaration, startLoc);
  11622. declaration.declare = true;
  11623. }
  11624. return declaration;
  11625. }
  11626. parseClassId(node, isStatement, optionalId, bindingType) {
  11627. if ((!isStatement || optionalId) && this.isContextual(113)) {
  11628. return;
  11629. }
  11630. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  11631. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11632. if (typeParameters) node.typeParameters = typeParameters;
  11633. }
  11634. parseClassPropertyAnnotation(node) {
  11635. if (!node.optional) {
  11636. if (this.eat(35)) {
  11637. node.definite = true;
  11638. } else if (this.eat(17)) {
  11639. node.optional = true;
  11640. }
  11641. }
  11642. const type = this.tsTryParseTypeAnnotation();
  11643. if (type) node.typeAnnotation = type;
  11644. }
  11645. parseClassProperty(node) {
  11646. this.parseClassPropertyAnnotation(node);
  11647. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  11648. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  11649. }
  11650. if (node.abstract && this.match(29)) {
  11651. const {
  11652. key
  11653. } = node;
  11654. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  11655. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  11656. });
  11657. }
  11658. return super.parseClassProperty(node);
  11659. }
  11660. parseClassPrivateProperty(node) {
  11661. if (node.abstract) {
  11662. this.raise(TSErrors.PrivateElementHasAbstract, node);
  11663. }
  11664. if (node.accessibility) {
  11665. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  11666. modifier: node.accessibility
  11667. });
  11668. }
  11669. this.parseClassPropertyAnnotation(node);
  11670. return super.parseClassPrivateProperty(node);
  11671. }
  11672. parseClassAccessorProperty(node) {
  11673. this.parseClassPropertyAnnotation(node);
  11674. if (node.optional) {
  11675. this.raise(TSErrors.AccessorCannotBeOptional, node);
  11676. }
  11677. return super.parseClassAccessorProperty(node);
  11678. }
  11679. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  11680. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11681. if (typeParameters && isConstructor) {
  11682. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  11683. }
  11684. const {
  11685. declare = false,
  11686. kind
  11687. } = method;
  11688. if (declare && (kind === "get" || kind === "set")) {
  11689. this.raise(TSErrors.DeclareAccessor, method, {
  11690. kind
  11691. });
  11692. }
  11693. if (typeParameters) method.typeParameters = typeParameters;
  11694. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  11695. }
  11696. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  11697. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11698. if (typeParameters) method.typeParameters = typeParameters;
  11699. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  11700. }
  11701. declareClassPrivateMethodInScope(node, kind) {
  11702. if (node.type === "TSDeclareMethod") return;
  11703. if (node.type === "MethodDefinition" && !node.value.body) return;
  11704. super.declareClassPrivateMethodInScope(node, kind);
  11705. }
  11706. parseClassSuper(node) {
  11707. super.parseClassSuper(node);
  11708. if (node.superClass && (this.match(47) || this.match(51))) {
  11709. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  11710. }
  11711. if (this.eatContextual(113)) {
  11712. node.implements = this.tsParseHeritageClause("implements");
  11713. }
  11714. }
  11715. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  11716. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11717. if (typeParameters) prop.typeParameters = typeParameters;
  11718. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  11719. }
  11720. parseFunctionParams(node, isConstructor) {
  11721. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11722. if (typeParameters) node.typeParameters = typeParameters;
  11723. super.parseFunctionParams(node, isConstructor);
  11724. }
  11725. parseVarId(decl, kind) {
  11726. super.parseVarId(decl, kind);
  11727. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  11728. decl.definite = true;
  11729. }
  11730. const type = this.tsTryParseTypeAnnotation();
  11731. if (type) {
  11732. decl.id.typeAnnotation = type;
  11733. this.resetEndLocation(decl.id);
  11734. }
  11735. }
  11736. parseAsyncArrowFromCallExpression(node, call) {
  11737. if (this.match(14)) {
  11738. node.returnType = this.tsParseTypeAnnotation();
  11739. }
  11740. return super.parseAsyncArrowFromCallExpression(node, call);
  11741. }
  11742. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  11743. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  11744. let state;
  11745. let jsx;
  11746. let typeCast;
  11747. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  11748. state = this.state.clone();
  11749. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11750. if (!jsx.error) return jsx.node;
  11751. const {
  11752. context
  11753. } = this.state;
  11754. const currentContext = context[context.length - 1];
  11755. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  11756. context.pop();
  11757. }
  11758. }
  11759. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  11760. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11761. }
  11762. if (!state || state === this.state) state = this.state.clone();
  11763. let typeParameters;
  11764. const arrow = this.tryParse(abort => {
  11765. var _expr$extra, _typeParameters;
  11766. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11767. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11768. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  11769. abort();
  11770. }
  11771. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  11772. this.resetStartLocationFromNode(expr, typeParameters);
  11773. }
  11774. expr.typeParameters = typeParameters;
  11775. return expr;
  11776. }, state);
  11777. if (!arrow.error && !arrow.aborted) {
  11778. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11779. return arrow.node;
  11780. }
  11781. if (!jsx) {
  11782. assert$1(!this.hasPlugin("jsx"));
  11783. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11784. if (!typeCast.error) return typeCast.node;
  11785. }
  11786. if ((_jsx2 = jsx) != null && _jsx2.node) {
  11787. this.state = jsx.failState;
  11788. return jsx.node;
  11789. }
  11790. if (arrow.node) {
  11791. this.state = arrow.failState;
  11792. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11793. return arrow.node;
  11794. }
  11795. if ((_typeCast = typeCast) != null && _typeCast.node) {
  11796. this.state = typeCast.failState;
  11797. return typeCast.node;
  11798. }
  11799. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  11800. }
  11801. reportReservedArrowTypeParam(node) {
  11802. var _node$extra;
  11803. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11804. this.raise(TSErrors.ReservedArrowTypeParam, node);
  11805. }
  11806. }
  11807. parseMaybeUnary(refExpressionErrors, sawUnary) {
  11808. if (!this.hasPlugin("jsx") && this.match(47)) {
  11809. return this.tsParseTypeAssertion();
  11810. }
  11811. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  11812. }
  11813. parseArrow(node) {
  11814. if (this.match(14)) {
  11815. const result = this.tryParse(abort => {
  11816. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11817. if (this.canInsertSemicolon() || !this.match(19)) abort();
  11818. return returnType;
  11819. });
  11820. if (result.aborted) return;
  11821. if (!result.thrown) {
  11822. if (result.error) this.state = result.failState;
  11823. node.returnType = result.node;
  11824. }
  11825. }
  11826. return super.parseArrow(node);
  11827. }
  11828. parseAssignableListItemTypes(param, flags) {
  11829. if (!(flags & 2)) return param;
  11830. if (this.eat(17)) {
  11831. param.optional = true;
  11832. }
  11833. const type = this.tsTryParseTypeAnnotation();
  11834. if (type) param.typeAnnotation = type;
  11835. this.resetEndLocation(param);
  11836. return param;
  11837. }
  11838. isAssignable(node, isBinding) {
  11839. switch (node.type) {
  11840. case "TSTypeCastExpression":
  11841. return this.isAssignable(node.expression, isBinding);
  11842. case "TSParameterProperty":
  11843. return true;
  11844. default:
  11845. return super.isAssignable(node, isBinding);
  11846. }
  11847. }
  11848. toAssignable(node, isLHS = false) {
  11849. switch (node.type) {
  11850. case "ParenthesizedExpression":
  11851. this.toAssignableParenthesizedExpression(node, isLHS);
  11852. break;
  11853. case "TSAsExpression":
  11854. case "TSSatisfiesExpression":
  11855. case "TSNonNullExpression":
  11856. case "TSTypeAssertion":
  11857. if (isLHS) {
  11858. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  11859. } else {
  11860. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  11861. }
  11862. this.toAssignable(node.expression, isLHS);
  11863. break;
  11864. case "AssignmentExpression":
  11865. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  11866. node.left = this.typeCastToParameter(node.left);
  11867. }
  11868. default:
  11869. super.toAssignable(node, isLHS);
  11870. }
  11871. }
  11872. toAssignableParenthesizedExpression(node, isLHS) {
  11873. switch (node.expression.type) {
  11874. case "TSAsExpression":
  11875. case "TSSatisfiesExpression":
  11876. case "TSNonNullExpression":
  11877. case "TSTypeAssertion":
  11878. case "ParenthesizedExpression":
  11879. this.toAssignable(node.expression, isLHS);
  11880. break;
  11881. default:
  11882. super.toAssignable(node, isLHS);
  11883. }
  11884. }
  11885. checkToRestConversion(node, allowPattern) {
  11886. switch (node.type) {
  11887. case "TSAsExpression":
  11888. case "TSSatisfiesExpression":
  11889. case "TSTypeAssertion":
  11890. case "TSNonNullExpression":
  11891. this.checkToRestConversion(node.expression, false);
  11892. break;
  11893. default:
  11894. super.checkToRestConversion(node, allowPattern);
  11895. }
  11896. }
  11897. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  11898. return getOwn({
  11899. TSTypeCastExpression: true,
  11900. TSParameterProperty: "parameter",
  11901. TSNonNullExpression: "expression",
  11902. TSAsExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11903. TSSatisfiesExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11904. TSTypeAssertion: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true]
  11905. }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  11906. }
  11907. parseBindingAtom() {
  11908. if (this.state.type === 78) {
  11909. return this.parseIdentifier(true);
  11910. }
  11911. return super.parseBindingAtom();
  11912. }
  11913. parseMaybeDecoratorArguments(expr) {
  11914. if (this.match(47) || this.match(51)) {
  11915. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11916. if (this.match(10)) {
  11917. const call = super.parseMaybeDecoratorArguments(expr);
  11918. call.typeParameters = typeArguments;
  11919. return call;
  11920. }
  11921. this.unexpected(null, 10);
  11922. }
  11923. return super.parseMaybeDecoratorArguments(expr);
  11924. }
  11925. checkCommaAfterRest(close) {
  11926. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  11927. this.next();
  11928. return false;
  11929. }
  11930. return super.checkCommaAfterRest(close);
  11931. }
  11932. isClassMethod() {
  11933. return this.match(47) || super.isClassMethod();
  11934. }
  11935. isClassProperty() {
  11936. return this.match(35) || this.match(14) || super.isClassProperty();
  11937. }
  11938. parseMaybeDefault(startLoc, left) {
  11939. const node = super.parseMaybeDefault(startLoc, left);
  11940. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  11941. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  11942. }
  11943. return node;
  11944. }
  11945. getTokenFromCode(code) {
  11946. if (this.state.inType) {
  11947. if (code === 62) {
  11948. this.finishOp(48, 1);
  11949. return;
  11950. }
  11951. if (code === 60) {
  11952. this.finishOp(47, 1);
  11953. return;
  11954. }
  11955. }
  11956. super.getTokenFromCode(code);
  11957. }
  11958. reScan_lt_gt() {
  11959. const {
  11960. type
  11961. } = this.state;
  11962. if (type === 47) {
  11963. this.state.pos -= 1;
  11964. this.readToken_lt();
  11965. } else if (type === 48) {
  11966. this.state.pos -= 1;
  11967. this.readToken_gt();
  11968. }
  11969. }
  11970. reScan_lt() {
  11971. const {
  11972. type
  11973. } = this.state;
  11974. if (type === 51) {
  11975. this.state.pos -= 2;
  11976. this.finishOp(47, 1);
  11977. return 47;
  11978. }
  11979. return type;
  11980. }
  11981. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  11982. for (let i = 0; i < exprList.length; i++) {
  11983. const expr = exprList[i];
  11984. if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
  11985. exprList[i] = this.typeCastToParameter(expr);
  11986. }
  11987. }
  11988. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  11989. }
  11990. typeCastToParameter(node) {
  11991. node.expression.typeAnnotation = node.typeAnnotation;
  11992. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  11993. return node.expression;
  11994. }
  11995. shouldParseArrow(params) {
  11996. if (this.match(14)) {
  11997. return params.every(expr => this.isAssignable(expr, true));
  11998. }
  11999. return super.shouldParseArrow(params);
  12000. }
  12001. shouldParseAsyncArrow() {
  12002. return this.match(14) || super.shouldParseAsyncArrow();
  12003. }
  12004. canHaveLeadingDecorator() {
  12005. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  12006. }
  12007. jsxParseOpeningElementAfterName(node) {
  12008. if (this.match(47) || this.match(51)) {
  12009. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  12010. if (typeArguments) node.typeParameters = typeArguments;
  12011. }
  12012. return super.jsxParseOpeningElementAfterName(node);
  12013. }
  12014. getGetterSetterExpectedParamCount(method) {
  12015. const baseCount = super.getGetterSetterExpectedParamCount(method);
  12016. const params = this.getObjectOrClassMethodParams(method);
  12017. const firstParam = params[0];
  12018. const hasContextParam = firstParam && this.isThisParam(firstParam);
  12019. return hasContextParam ? baseCount + 1 : baseCount;
  12020. }
  12021. parseCatchClauseParam() {
  12022. const param = super.parseCatchClauseParam();
  12023. const type = this.tsTryParseTypeAnnotation();
  12024. if (type) {
  12025. param.typeAnnotation = type;
  12026. this.resetEndLocation(param);
  12027. }
  12028. return param;
  12029. }
  12030. tsInAmbientContext(cb) {
  12031. const oldIsAmbientContext = this.state.isAmbientContext;
  12032. this.state.isAmbientContext = true;
  12033. try {
  12034. return cb();
  12035. } finally {
  12036. this.state.isAmbientContext = oldIsAmbientContext;
  12037. }
  12038. }
  12039. parseClass(node, isStatement, optionalId) {
  12040. const oldInAbstractClass = this.state.inAbstractClass;
  12041. this.state.inAbstractClass = !!node.abstract;
  12042. try {
  12043. return super.parseClass(node, isStatement, optionalId);
  12044. } finally {
  12045. this.state.inAbstractClass = oldInAbstractClass;
  12046. }
  12047. }
  12048. tsParseAbstractDeclaration(node, decorators) {
  12049. if (this.match(80)) {
  12050. node.abstract = true;
  12051. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12052. } else if (this.isContextual(129)) {
  12053. if (!this.hasFollowingLineBreak()) {
  12054. node.abstract = true;
  12055. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node);
  12056. return this.tsParseInterfaceDeclaration(node);
  12057. }
  12058. } else {
  12059. this.unexpected(null, 80);
  12060. }
  12061. }
  12062. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12063. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12064. if (method.abstract) {
  12065. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  12066. if (hasBody) {
  12067. const {
  12068. key
  12069. } = method;
  12070. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12071. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  12072. });
  12073. }
  12074. }
  12075. return method;
  12076. }
  12077. tsParseTypeParameterName() {
  12078. const typeName = this.parseIdentifier();
  12079. return typeName.name;
  12080. }
  12081. shouldParseAsAmbientContext() {
  12082. return !!this.getPluginOption("typescript", "dts");
  12083. }
  12084. parse() {
  12085. if (this.shouldParseAsAmbientContext()) {
  12086. this.state.isAmbientContext = true;
  12087. }
  12088. return super.parse();
  12089. }
  12090. getExpression() {
  12091. if (this.shouldParseAsAmbientContext()) {
  12092. this.state.isAmbientContext = true;
  12093. }
  12094. return super.getExpression();
  12095. }
  12096. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12097. if (!isString && isMaybeTypeOnly) {
  12098. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12099. return this.finishNode(node, "ExportSpecifier");
  12100. }
  12101. node.exportKind = "value";
  12102. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12103. }
  12104. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12105. if (!importedIsString && isMaybeTypeOnly) {
  12106. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12107. return this.finishNode(specifier, "ImportSpecifier");
  12108. }
  12109. specifier.importKind = "value";
  12110. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12111. }
  12112. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12113. const leftOfAsKey = isImport ? "imported" : "local";
  12114. const rightOfAsKey = isImport ? "local" : "exported";
  12115. let leftOfAs = node[leftOfAsKey];
  12116. let rightOfAs;
  12117. let hasTypeSpecifier = false;
  12118. let canParseAsKeyword = true;
  12119. const loc = leftOfAs.loc.start;
  12120. if (this.isContextual(93)) {
  12121. const firstAs = this.parseIdentifier();
  12122. if (this.isContextual(93)) {
  12123. const secondAs = this.parseIdentifier();
  12124. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12125. hasTypeSpecifier = true;
  12126. leftOfAs = firstAs;
  12127. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12128. canParseAsKeyword = false;
  12129. } else {
  12130. rightOfAs = secondAs;
  12131. canParseAsKeyword = false;
  12132. }
  12133. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12134. canParseAsKeyword = false;
  12135. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12136. } else {
  12137. hasTypeSpecifier = true;
  12138. leftOfAs = firstAs;
  12139. }
  12140. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12141. hasTypeSpecifier = true;
  12142. if (isImport) {
  12143. leftOfAs = this.parseIdentifier(true);
  12144. if (!this.isContextual(93)) {
  12145. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12146. }
  12147. } else {
  12148. leftOfAs = this.parseModuleExportName();
  12149. }
  12150. }
  12151. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12152. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12153. }
  12154. node[leftOfAsKey] = leftOfAs;
  12155. node[rightOfAsKey] = rightOfAs;
  12156. const kindKey = isImport ? "importKind" : "exportKind";
  12157. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12158. if (canParseAsKeyword && this.eatContextual(93)) {
  12159. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12160. }
  12161. if (!node[rightOfAsKey]) {
  12162. node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]);
  12163. }
  12164. if (isImport) {
  12165. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12166. }
  12167. }
  12168. };
  12169. function isPossiblyLiteralEnum(expression) {
  12170. if (expression.type !== "MemberExpression") return false;
  12171. const {
  12172. computed,
  12173. property
  12174. } = expression;
  12175. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12176. return false;
  12177. }
  12178. return isUncomputedMemberExpressionChain(expression.object);
  12179. }
  12180. function isValidAmbientConstInitializer(expression, estree) {
  12181. var _expression$extra;
  12182. const {
  12183. type
  12184. } = expression;
  12185. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12186. return false;
  12187. }
  12188. if (estree) {
  12189. if (type === "Literal") {
  12190. const {
  12191. value
  12192. } = expression;
  12193. if (typeof value === "string" || typeof value === "boolean") {
  12194. return true;
  12195. }
  12196. }
  12197. } else {
  12198. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12199. return true;
  12200. }
  12201. }
  12202. if (isNumber$1(expression, estree) || isNegativeNumber(expression, estree)) {
  12203. return true;
  12204. }
  12205. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12206. return true;
  12207. }
  12208. if (isPossiblyLiteralEnum(expression)) {
  12209. return true;
  12210. }
  12211. return false;
  12212. }
  12213. function isNumber$1(expression, estree) {
  12214. if (estree) {
  12215. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12216. }
  12217. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12218. }
  12219. function isNegativeNumber(expression, estree) {
  12220. if (expression.type === "UnaryExpression") {
  12221. const {
  12222. operator,
  12223. argument
  12224. } = expression;
  12225. if (operator === "-" && isNumber$1(argument, estree)) {
  12226. return true;
  12227. }
  12228. }
  12229. return false;
  12230. }
  12231. function isUncomputedMemberExpressionChain(expression) {
  12232. if (expression.type === "Identifier") return true;
  12233. if (expression.type !== "MemberExpression" || expression.computed) {
  12234. return false;
  12235. }
  12236. return isUncomputedMemberExpressionChain(expression.object);
  12237. }
  12238. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12239. ClassNameIsRequired: "A class name is required.",
  12240. UnexpectedSpace: "Unexpected space in placeholder."
  12241. });
  12242. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12243. parsePlaceholder(expectedNode) {
  12244. if (this.match(144)) {
  12245. const node = this.startNode();
  12246. this.next();
  12247. this.assertNoSpace();
  12248. node.name = super.parseIdentifier(true);
  12249. this.assertNoSpace();
  12250. this.expect(144);
  12251. return this.finishPlaceholder(node, expectedNode);
  12252. }
  12253. }
  12254. finishPlaceholder(node, expectedNode) {
  12255. const isFinished = !!(node.expectedNode && node.type === "Placeholder");
  12256. node.expectedNode = expectedNode;
  12257. return isFinished ? node : this.finishNode(node, "Placeholder");
  12258. }
  12259. getTokenFromCode(code) {
  12260. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12261. this.finishOp(144, 2);
  12262. } else {
  12263. super.getTokenFromCode(code);
  12264. }
  12265. }
  12266. parseExprAtom(refExpressionErrors) {
  12267. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12268. }
  12269. parseIdentifier(liberal) {
  12270. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12271. }
  12272. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12273. if (word !== undefined) {
  12274. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12275. }
  12276. }
  12277. parseBindingAtom() {
  12278. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12279. }
  12280. isValidLVal(type, isParenthesized, binding) {
  12281. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12282. }
  12283. toAssignable(node, isLHS) {
  12284. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12285. node.expectedNode = "Pattern";
  12286. } else {
  12287. super.toAssignable(node, isLHS);
  12288. }
  12289. }
  12290. chStartsBindingIdentifier(ch, pos) {
  12291. if (super.chStartsBindingIdentifier(ch, pos)) {
  12292. return true;
  12293. }
  12294. const nextToken = this.lookahead();
  12295. if (nextToken.type === 144) {
  12296. return true;
  12297. }
  12298. return false;
  12299. }
  12300. verifyBreakContinue(node, isBreak) {
  12301. if (node.label && node.label.type === "Placeholder") return;
  12302. super.verifyBreakContinue(node, isBreak);
  12303. }
  12304. parseExpressionStatement(node, expr) {
  12305. var _expr$extra;
  12306. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12307. return super.parseExpressionStatement(node, expr);
  12308. }
  12309. if (this.match(14)) {
  12310. const stmt = node;
  12311. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12312. this.next();
  12313. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12314. return this.finishNode(stmt, "LabeledStatement");
  12315. }
  12316. this.semicolon();
  12317. node.name = expr.name;
  12318. return this.finishPlaceholder(node, "Statement");
  12319. }
  12320. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12321. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12322. }
  12323. parseFunctionId(requireId) {
  12324. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12325. }
  12326. parseClass(node, isStatement, optionalId) {
  12327. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12328. this.next();
  12329. const oldStrict = this.state.strict;
  12330. const placeholder = this.parsePlaceholder("Identifier");
  12331. if (placeholder) {
  12332. if (this.match(81) || this.match(144) || this.match(5)) {
  12333. node.id = placeholder;
  12334. } else if (optionalId || !isStatement) {
  12335. node.id = null;
  12336. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12337. return this.finishNode(node, type);
  12338. } else {
  12339. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12340. }
  12341. } else {
  12342. this.parseClassId(node, isStatement, optionalId);
  12343. }
  12344. super.parseClassSuper(node);
  12345. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12346. return this.finishNode(node, type);
  12347. }
  12348. parseExport(node, decorators) {
  12349. const placeholder = this.parsePlaceholder("Identifier");
  12350. if (!placeholder) return super.parseExport(node, decorators);
  12351. if (!this.isContextual(98) && !this.match(12)) {
  12352. node.specifiers = [];
  12353. node.source = null;
  12354. node.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12355. return this.finishNode(node, "ExportNamedDeclaration");
  12356. }
  12357. this.expectPlugin("exportDefaultFrom");
  12358. const specifier = this.startNode();
  12359. specifier.exported = placeholder;
  12360. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12361. return super.parseExport(node, decorators);
  12362. }
  12363. isExportDefaultSpecifier() {
  12364. if (this.match(65)) {
  12365. const next = this.nextTokenStart();
  12366. if (this.isUnparsedContextual(next, "from")) {
  12367. if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
  12368. return true;
  12369. }
  12370. }
  12371. }
  12372. return super.isExportDefaultSpecifier();
  12373. }
  12374. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12375. var _specifiers;
  12376. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12377. return true;
  12378. }
  12379. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12380. }
  12381. checkExport(node) {
  12382. const {
  12383. specifiers
  12384. } = node;
  12385. if (specifiers != null && specifiers.length) {
  12386. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12387. }
  12388. super.checkExport(node);
  12389. node.specifiers = specifiers;
  12390. }
  12391. parseImport(node) {
  12392. const placeholder = this.parsePlaceholder("Identifier");
  12393. if (!placeholder) return super.parseImport(node);
  12394. node.specifiers = [];
  12395. if (!this.isContextual(98) && !this.match(12)) {
  12396. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12397. this.semicolon();
  12398. return this.finishNode(node, "ImportDeclaration");
  12399. }
  12400. const specifier = this.startNodeAtNode(placeholder);
  12401. specifier.local = placeholder;
  12402. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  12403. if (this.eat(12)) {
  12404. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  12405. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  12406. }
  12407. this.expectContextual(98);
  12408. node.source = this.parseImportSource();
  12409. this.semicolon();
  12410. return this.finishNode(node, "ImportDeclaration");
  12411. }
  12412. parseImportSource() {
  12413. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  12414. }
  12415. assertNoSpace() {
  12416. if (this.state.start > this.state.lastTokEndLoc.index) {
  12417. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  12418. }
  12419. }
  12420. };
  12421. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  12422. parseV8Intrinsic() {
  12423. if (this.match(54)) {
  12424. const v8IntrinsicStartLoc = this.state.startLoc;
  12425. const node = this.startNode();
  12426. this.next();
  12427. if (tokenIsIdentifier(this.state.type)) {
  12428. const name = this.parseIdentifierName();
  12429. const identifier = this.createIdentifier(node, name);
  12430. identifier.type = "V8IntrinsicIdentifier";
  12431. if (this.match(10)) {
  12432. return identifier;
  12433. }
  12434. }
  12435. this.unexpected(v8IntrinsicStartLoc);
  12436. }
  12437. }
  12438. parseExprAtom(refExpressionErrors) {
  12439. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  12440. }
  12441. };
  12442. function hasPlugin(plugins, expectedConfig) {
  12443. const [expectedName, expectedOptions] = typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig;
  12444. const expectedKeys = Object.keys(expectedOptions);
  12445. const expectedOptionsIsEmpty = expectedKeys.length === 0;
  12446. return plugins.some(p => {
  12447. if (typeof p === "string") {
  12448. return expectedOptionsIsEmpty && p === expectedName;
  12449. } else {
  12450. const [pluginName, pluginOptions] = p;
  12451. if (pluginName !== expectedName) {
  12452. return false;
  12453. }
  12454. for (const key of expectedKeys) {
  12455. if (pluginOptions[key] !== expectedOptions[key]) {
  12456. return false;
  12457. }
  12458. }
  12459. return true;
  12460. }
  12461. });
  12462. }
  12463. function getPluginOption(plugins, name, option) {
  12464. const plugin = plugins.find(plugin => {
  12465. if (Array.isArray(plugin)) {
  12466. return plugin[0] === name;
  12467. } else {
  12468. return plugin === name;
  12469. }
  12470. });
  12471. if (plugin && Array.isArray(plugin) && plugin.length > 1) {
  12472. return plugin[1][option];
  12473. }
  12474. return null;
  12475. }
  12476. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  12477. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  12478. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  12479. function validatePlugins(plugins) {
  12480. if (hasPlugin(plugins, "decorators")) {
  12481. if (hasPlugin(plugins, "decorators-legacy")) {
  12482. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  12483. }
  12484. const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
  12485. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  12486. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  12487. }
  12488. const allowCallParenthesized = getPluginOption(plugins, "decorators", "allowCallParenthesized");
  12489. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  12490. throw new Error("'allowCallParenthesized' must be a boolean.");
  12491. }
  12492. }
  12493. if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
  12494. throw new Error("Cannot combine flow and typescript plugins.");
  12495. }
  12496. if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
  12497. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  12498. }
  12499. if (hasPlugin(plugins, "pipelineOperator")) {
  12500. const proposal = getPluginOption(plugins, "pipelineOperator", "proposal");
  12501. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  12502. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  12503. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  12504. }
  12505. const tupleSyntaxIsHash = hasPlugin(plugins, ["recordAndTuple", {
  12506. syntaxType: "hash"
  12507. }]);
  12508. if (proposal === "hack") {
  12509. if (hasPlugin(plugins, "placeholders")) {
  12510. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  12511. }
  12512. if (hasPlugin(plugins, "v8intrinsic")) {
  12513. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  12514. }
  12515. const topicToken = getPluginOption(plugins, "pipelineOperator", "topicToken");
  12516. if (!TOPIC_TOKENS.includes(topicToken)) {
  12517. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  12518. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  12519. }
  12520. if (topicToken === "#" && tupleSyntaxIsHash) {
  12521. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  12522. }
  12523. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  12524. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  12525. }
  12526. }
  12527. if (hasPlugin(plugins, "moduleAttributes")) {
  12528. {
  12529. if (hasPlugin(plugins, "importAssertions") || hasPlugin(plugins, "importAttributes")) {
  12530. throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");
  12531. }
  12532. const moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
  12533. if (moduleAttributesVersionPluginOption !== "may-2020") {
  12534. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  12535. }
  12536. }
  12537. }
  12538. if (hasPlugin(plugins, "importAssertions") && hasPlugin(plugins, "importAttributes")) {
  12539. throw new Error("Cannot combine importAssertions and importAttributes plugins.");
  12540. }
  12541. if (hasPlugin(plugins, "recordAndTuple") && getPluginOption(plugins, "recordAndTuple", "syntaxType") != null && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) {
  12542. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  12543. }
  12544. if (hasPlugin(plugins, "asyncDoExpressions") && !hasPlugin(plugins, "doExpressions")) {
  12545. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  12546. error.missingPlugins = "doExpressions";
  12547. throw error;
  12548. }
  12549. if (hasPlugin(plugins, "optionalChainingAssign") && getPluginOption(plugins, "optionalChainingAssign", "version") !== "2023-07") {
  12550. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  12551. }
  12552. }
  12553. const mixinPlugins = {
  12554. estree,
  12555. jsx,
  12556. flow,
  12557. typescript,
  12558. v8intrinsic,
  12559. placeholders
  12560. };
  12561. const mixinPluginNames = Object.keys(mixinPlugins);
  12562. const defaultOptions = {
  12563. sourceType: "script",
  12564. sourceFilename: undefined,
  12565. startColumn: 0,
  12566. startLine: 1,
  12567. allowAwaitOutsideFunction: false,
  12568. allowReturnOutsideFunction: false,
  12569. allowNewTargetOutsideFunction: false,
  12570. allowImportExportEverywhere: false,
  12571. allowSuperOutsideMethod: false,
  12572. allowUndeclaredExports: false,
  12573. plugins: [],
  12574. strictMode: null,
  12575. ranges: false,
  12576. tokens: false,
  12577. createImportExpressions: false,
  12578. createParenthesizedExpressions: false,
  12579. errorRecovery: false,
  12580. attachComment: true,
  12581. annexB: true
  12582. };
  12583. function getOptions(opts) {
  12584. if (opts == null) {
  12585. return Object.assign({}, defaultOptions);
  12586. }
  12587. if (opts.annexB != null && opts.annexB !== false) {
  12588. throw new Error("The `annexB` option can only be set to `false`.");
  12589. }
  12590. const options = {};
  12591. for (const key of Object.keys(defaultOptions)) {
  12592. var _opts$key;
  12593. options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key];
  12594. }
  12595. return options;
  12596. }
  12597. class ExpressionParser extends LValParser {
  12598. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  12599. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  12600. return;
  12601. }
  12602. const key = prop.key;
  12603. const name = key.type === "Identifier" ? key.name : key.value;
  12604. if (name === "__proto__") {
  12605. if (isRecord) {
  12606. this.raise(Errors.RecordNoProto, key);
  12607. return;
  12608. }
  12609. if (protoRef.used) {
  12610. if (refExpressionErrors) {
  12611. if (refExpressionErrors.doubleProtoLoc === null) {
  12612. refExpressionErrors.doubleProtoLoc = key.loc.start;
  12613. }
  12614. } else {
  12615. this.raise(Errors.DuplicateProto, key);
  12616. }
  12617. }
  12618. protoRef.used = true;
  12619. }
  12620. }
  12621. shouldExitDescending(expr, potentialArrowAt) {
  12622. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  12623. }
  12624. getExpression() {
  12625. this.enterInitialScopes();
  12626. this.nextToken();
  12627. const expr = this.parseExpression();
  12628. if (!this.match(139)) {
  12629. this.unexpected();
  12630. }
  12631. this.finalizeRemainingComments();
  12632. expr.comments = this.comments;
  12633. expr.errors = this.state.errors;
  12634. if (this.options.tokens) {
  12635. expr.tokens = this.tokens;
  12636. }
  12637. return expr;
  12638. }
  12639. parseExpression(disallowIn, refExpressionErrors) {
  12640. if (disallowIn) {
  12641. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12642. }
  12643. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12644. }
  12645. parseExpressionBase(refExpressionErrors) {
  12646. const startLoc = this.state.startLoc;
  12647. const expr = this.parseMaybeAssign(refExpressionErrors);
  12648. if (this.match(12)) {
  12649. const node = this.startNodeAt(startLoc);
  12650. node.expressions = [expr];
  12651. while (this.eat(12)) {
  12652. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  12653. }
  12654. this.toReferencedList(node.expressions);
  12655. return this.finishNode(node, "SequenceExpression");
  12656. }
  12657. return expr;
  12658. }
  12659. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  12660. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12661. }
  12662. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  12663. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12664. }
  12665. setOptionalParametersError(refExpressionErrors, resultError) {
  12666. var _resultError$loc;
  12667. refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
  12668. }
  12669. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12670. const startLoc = this.state.startLoc;
  12671. if (this.isContextual(108)) {
  12672. if (this.prodParam.hasYield) {
  12673. let left = this.parseYield();
  12674. if (afterLeftParse) {
  12675. left = afterLeftParse.call(this, left, startLoc);
  12676. }
  12677. return left;
  12678. }
  12679. }
  12680. let ownExpressionErrors;
  12681. if (refExpressionErrors) {
  12682. ownExpressionErrors = false;
  12683. } else {
  12684. refExpressionErrors = new ExpressionErrors();
  12685. ownExpressionErrors = true;
  12686. }
  12687. const {
  12688. type
  12689. } = this.state;
  12690. if (type === 10 || tokenIsIdentifier(type)) {
  12691. this.state.potentialArrowAt = this.state.start;
  12692. }
  12693. let left = this.parseMaybeConditional(refExpressionErrors);
  12694. if (afterLeftParse) {
  12695. left = afterLeftParse.call(this, left, startLoc);
  12696. }
  12697. if (tokenIsAssignment(this.state.type)) {
  12698. const node = this.startNodeAt(startLoc);
  12699. const operator = this.state.value;
  12700. node.operator = operator;
  12701. if (this.match(29)) {
  12702. this.toAssignable(left, true);
  12703. node.left = left;
  12704. const startIndex = startLoc.index;
  12705. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  12706. refExpressionErrors.doubleProtoLoc = null;
  12707. }
  12708. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  12709. refExpressionErrors.shorthandAssignLoc = null;
  12710. }
  12711. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  12712. this.checkDestructuringPrivate(refExpressionErrors);
  12713. refExpressionErrors.privateKeyLoc = null;
  12714. }
  12715. } else {
  12716. node.left = left;
  12717. }
  12718. this.next();
  12719. node.right = this.parseMaybeAssign();
  12720. this.checkLVal(left, {
  12721. in: this.finishNode(node, "AssignmentExpression")
  12722. });
  12723. return node;
  12724. } else if (ownExpressionErrors) {
  12725. this.checkExpressionErrors(refExpressionErrors, true);
  12726. }
  12727. return left;
  12728. }
  12729. parseMaybeConditional(refExpressionErrors) {
  12730. const startLoc = this.state.startLoc;
  12731. const potentialArrowAt = this.state.potentialArrowAt;
  12732. const expr = this.parseExprOps(refExpressionErrors);
  12733. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12734. return expr;
  12735. }
  12736. return this.parseConditional(expr, startLoc, refExpressionErrors);
  12737. }
  12738. parseConditional(expr, startLoc, refExpressionErrors) {
  12739. if (this.eat(17)) {
  12740. const node = this.startNodeAt(startLoc);
  12741. node.test = expr;
  12742. node.consequent = this.parseMaybeAssignAllowIn();
  12743. this.expect(14);
  12744. node.alternate = this.parseMaybeAssign();
  12745. return this.finishNode(node, "ConditionalExpression");
  12746. }
  12747. return expr;
  12748. }
  12749. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  12750. return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  12751. }
  12752. parseExprOps(refExpressionErrors) {
  12753. const startLoc = this.state.startLoc;
  12754. const potentialArrowAt = this.state.potentialArrowAt;
  12755. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  12756. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12757. return expr;
  12758. }
  12759. return this.parseExprOp(expr, startLoc, -1);
  12760. }
  12761. parseExprOp(left, leftStartLoc, minPrec) {
  12762. if (this.isPrivateName(left)) {
  12763. const value = this.getPrivateNameSV(left);
  12764. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  12765. this.raise(Errors.PrivateInExpectedIn, left, {
  12766. identifierName: value
  12767. });
  12768. }
  12769. this.classScope.usePrivateName(value, left.loc.start);
  12770. }
  12771. const op = this.state.type;
  12772. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  12773. let prec = tokenOperatorPrecedence(op);
  12774. if (prec > minPrec) {
  12775. if (op === 39) {
  12776. this.expectPlugin("pipelineOperator");
  12777. if (this.state.inFSharpPipelineDirectBody) {
  12778. return left;
  12779. }
  12780. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  12781. }
  12782. const node = this.startNodeAt(leftStartLoc);
  12783. node.left = left;
  12784. node.operator = this.state.value;
  12785. const logical = op === 41 || op === 42;
  12786. const coalesce = op === 40;
  12787. if (coalesce) {
  12788. prec = tokenOperatorPrecedence(42);
  12789. }
  12790. this.next();
  12791. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  12792. proposal: "minimal"
  12793. }])) {
  12794. if (this.state.type === 96 && this.prodParam.hasAwait) {
  12795. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  12796. }
  12797. }
  12798. node.right = this.parseExprOpRightExpr(op, prec);
  12799. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  12800. const nextOp = this.state.type;
  12801. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  12802. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  12803. }
  12804. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  12805. }
  12806. }
  12807. return left;
  12808. }
  12809. parseExprOpRightExpr(op, prec) {
  12810. const startLoc = this.state.startLoc;
  12811. switch (op) {
  12812. case 39:
  12813. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  12814. case "hack":
  12815. return this.withTopicBindingContext(() => {
  12816. return this.parseHackPipeBody();
  12817. });
  12818. case "smart":
  12819. return this.withTopicBindingContext(() => {
  12820. if (this.prodParam.hasYield && this.isContextual(108)) {
  12821. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  12822. }
  12823. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  12824. });
  12825. case "fsharp":
  12826. return this.withSoloAwaitPermittingContext(() => {
  12827. return this.parseFSharpPipelineBody(prec);
  12828. });
  12829. }
  12830. default:
  12831. return this.parseExprOpBaseRightExpr(op, prec);
  12832. }
  12833. }
  12834. parseExprOpBaseRightExpr(op, prec) {
  12835. const startLoc = this.state.startLoc;
  12836. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  12837. }
  12838. parseHackPipeBody() {
  12839. var _body$extra;
  12840. const {
  12841. startLoc
  12842. } = this.state;
  12843. const body = this.parseMaybeAssign();
  12844. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  12845. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  12846. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  12847. type: body.type
  12848. });
  12849. }
  12850. if (!this.topicReferenceWasUsedInCurrentContext()) {
  12851. this.raise(Errors.PipeTopicUnused, startLoc);
  12852. }
  12853. return body;
  12854. }
  12855. checkExponentialAfterUnary(node) {
  12856. if (this.match(57)) {
  12857. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  12858. }
  12859. }
  12860. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12861. const startLoc = this.state.startLoc;
  12862. const isAwait = this.isContextual(96);
  12863. if (isAwait && this.isAwaitAllowed()) {
  12864. this.next();
  12865. const expr = this.parseAwait(startLoc);
  12866. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  12867. return expr;
  12868. }
  12869. const update = this.match(34);
  12870. const node = this.startNode();
  12871. if (tokenIsPrefix(this.state.type)) {
  12872. node.operator = this.state.value;
  12873. node.prefix = true;
  12874. if (this.match(72)) {
  12875. this.expectPlugin("throwExpressions");
  12876. }
  12877. const isDelete = this.match(89);
  12878. this.next();
  12879. node.argument = this.parseMaybeUnary(null, true);
  12880. this.checkExpressionErrors(refExpressionErrors, true);
  12881. if (this.state.strict && isDelete) {
  12882. const arg = node.argument;
  12883. if (arg.type === "Identifier") {
  12884. this.raise(Errors.StrictDelete, node);
  12885. } else if (this.hasPropertyAsPrivateName(arg)) {
  12886. this.raise(Errors.DeletePrivateField, node);
  12887. }
  12888. }
  12889. if (!update) {
  12890. if (!sawUnary) {
  12891. this.checkExponentialAfterUnary(node);
  12892. }
  12893. return this.finishNode(node, "UnaryExpression");
  12894. }
  12895. }
  12896. const expr = this.parseUpdate(node, update, refExpressionErrors);
  12897. if (isAwait) {
  12898. const {
  12899. type
  12900. } = this.state;
  12901. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  12902. if (startsExpr && !this.isAmbiguousAwait()) {
  12903. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  12904. return this.parseAwait(startLoc);
  12905. }
  12906. }
  12907. return expr;
  12908. }
  12909. parseUpdate(node, update, refExpressionErrors) {
  12910. if (update) {
  12911. const updateExpressionNode = node;
  12912. this.checkLVal(updateExpressionNode.argument, {
  12913. in: this.finishNode(updateExpressionNode, "UpdateExpression")
  12914. });
  12915. return node;
  12916. }
  12917. const startLoc = this.state.startLoc;
  12918. let expr = this.parseExprSubscripts(refExpressionErrors);
  12919. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  12920. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  12921. const node = this.startNodeAt(startLoc);
  12922. node.operator = this.state.value;
  12923. node.prefix = false;
  12924. node.argument = expr;
  12925. this.next();
  12926. this.checkLVal(expr, {
  12927. in: expr = this.finishNode(node, "UpdateExpression")
  12928. });
  12929. }
  12930. return expr;
  12931. }
  12932. parseExprSubscripts(refExpressionErrors) {
  12933. const startLoc = this.state.startLoc;
  12934. const potentialArrowAt = this.state.potentialArrowAt;
  12935. const expr = this.parseExprAtom(refExpressionErrors);
  12936. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12937. return expr;
  12938. }
  12939. return this.parseSubscripts(expr, startLoc);
  12940. }
  12941. parseSubscripts(base, startLoc, noCalls) {
  12942. const state = {
  12943. optionalChainMember: false,
  12944. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  12945. stop: false
  12946. };
  12947. do {
  12948. base = this.parseSubscript(base, startLoc, noCalls, state);
  12949. state.maybeAsyncArrow = false;
  12950. } while (!state.stop);
  12951. return base;
  12952. }
  12953. parseSubscript(base, startLoc, noCalls, state) {
  12954. const {
  12955. type
  12956. } = this.state;
  12957. if (!noCalls && type === 15) {
  12958. return this.parseBind(base, startLoc, noCalls, state);
  12959. } else if (tokenIsTemplate(type)) {
  12960. return this.parseTaggedTemplateExpression(base, startLoc, state);
  12961. }
  12962. let optional = false;
  12963. if (type === 18) {
  12964. if (noCalls) {
  12965. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  12966. if (this.lookaheadCharCode() === 40) {
  12967. state.stop = true;
  12968. return base;
  12969. }
  12970. }
  12971. state.optionalChainMember = optional = true;
  12972. this.next();
  12973. }
  12974. if (!noCalls && this.match(10)) {
  12975. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  12976. } else {
  12977. const computed = this.eat(0);
  12978. if (computed || optional || this.eat(16)) {
  12979. return this.parseMember(base, startLoc, state, computed, optional);
  12980. } else {
  12981. state.stop = true;
  12982. return base;
  12983. }
  12984. }
  12985. }
  12986. parseMember(base, startLoc, state, computed, optional) {
  12987. const node = this.startNodeAt(startLoc);
  12988. node.object = base;
  12989. node.computed = computed;
  12990. if (computed) {
  12991. node.property = this.parseExpression();
  12992. this.expect(3);
  12993. } else if (this.match(138)) {
  12994. if (base.type === "Super") {
  12995. this.raise(Errors.SuperPrivateField, startLoc);
  12996. }
  12997. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  12998. node.property = this.parsePrivateName();
  12999. } else {
  13000. node.property = this.parseIdentifier(true);
  13001. }
  13002. if (state.optionalChainMember) {
  13003. node.optional = optional;
  13004. return this.finishNode(node, "OptionalMemberExpression");
  13005. } else {
  13006. return this.finishNode(node, "MemberExpression");
  13007. }
  13008. }
  13009. parseBind(base, startLoc, noCalls, state) {
  13010. const node = this.startNodeAt(startLoc);
  13011. node.object = base;
  13012. this.next();
  13013. node.callee = this.parseNoCallExpr();
  13014. state.stop = true;
  13015. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  13016. }
  13017. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13018. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13019. let refExpressionErrors = null;
  13020. this.state.maybeInArrowParameters = true;
  13021. this.next();
  13022. const node = this.startNodeAt(startLoc);
  13023. node.callee = base;
  13024. const {
  13025. maybeAsyncArrow,
  13026. optionalChainMember
  13027. } = state;
  13028. if (maybeAsyncArrow) {
  13029. this.expressionScope.enter(newAsyncArrowScope());
  13030. refExpressionErrors = new ExpressionErrors();
  13031. }
  13032. if (optionalChainMember) {
  13033. node.optional = optional;
  13034. }
  13035. if (optional) {
  13036. node.arguments = this.parseCallExpressionArguments(11);
  13037. } else {
  13038. node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  13039. }
  13040. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13041. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13042. state.stop = true;
  13043. this.checkDestructuringPrivate(refExpressionErrors);
  13044. this.expressionScope.validateAsPattern();
  13045. this.expressionScope.exit();
  13046. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13047. } else {
  13048. if (maybeAsyncArrow) {
  13049. this.checkExpressionErrors(refExpressionErrors, true);
  13050. this.expressionScope.exit();
  13051. }
  13052. this.toReferencedArguments(finishedNode);
  13053. }
  13054. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13055. return finishedNode;
  13056. }
  13057. toReferencedArguments(node, isParenthesizedExpr) {
  13058. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13059. }
  13060. parseTaggedTemplateExpression(base, startLoc, state) {
  13061. const node = this.startNodeAt(startLoc);
  13062. node.tag = base;
  13063. node.quasi = this.parseTemplate(true);
  13064. if (state.optionalChainMember) {
  13065. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13066. }
  13067. return this.finishNode(node, "TaggedTemplateExpression");
  13068. }
  13069. atPossibleAsyncArrow(base) {
  13070. return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
  13071. }
  13072. expectImportAttributesPlugin() {
  13073. if (!this.hasPlugin("importAssertions")) {
  13074. this.expectPlugin("importAttributes");
  13075. }
  13076. }
  13077. finishCallExpression(node, optional) {
  13078. if (node.callee.type === "Import") {
  13079. if (node.arguments.length === 2) {
  13080. {
  13081. if (!this.hasPlugin("moduleAttributes")) {
  13082. this.expectImportAttributesPlugin();
  13083. }
  13084. }
  13085. }
  13086. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13087. this.raise(Errors.ImportCallArity, node, {
  13088. maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1
  13089. });
  13090. } else {
  13091. for (const arg of node.arguments) {
  13092. if (arg.type === "SpreadElement") {
  13093. this.raise(Errors.ImportCallSpreadArgument, arg);
  13094. }
  13095. }
  13096. }
  13097. }
  13098. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13099. }
  13100. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13101. const elts = [];
  13102. let first = true;
  13103. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13104. this.state.inFSharpPipelineDirectBody = false;
  13105. while (!this.eat(close)) {
  13106. if (first) {
  13107. first = false;
  13108. } else {
  13109. this.expect(12);
  13110. if (this.match(close)) {
  13111. if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  13112. this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc);
  13113. }
  13114. if (nodeForExtra) {
  13115. this.addTrailingCommaExtraToNode(nodeForExtra);
  13116. }
  13117. this.next();
  13118. break;
  13119. }
  13120. }
  13121. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  13122. }
  13123. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13124. return elts;
  13125. }
  13126. shouldParseAsyncArrow() {
  13127. return this.match(19) && !this.canInsertSemicolon();
  13128. }
  13129. parseAsyncArrowFromCallExpression(node, call) {
  13130. var _call$extra;
  13131. this.resetPreviousNodeTrailingComments(call);
  13132. this.expect(19);
  13133. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13134. if (call.innerComments) {
  13135. setInnerComments(node, call.innerComments);
  13136. }
  13137. if (call.callee.trailingComments) {
  13138. setInnerComments(node, call.callee.trailingComments);
  13139. }
  13140. return node;
  13141. }
  13142. parseNoCallExpr() {
  13143. const startLoc = this.state.startLoc;
  13144. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13145. }
  13146. parseExprAtom(refExpressionErrors) {
  13147. let node;
  13148. let decorators = null;
  13149. const {
  13150. type
  13151. } = this.state;
  13152. switch (type) {
  13153. case 79:
  13154. return this.parseSuper();
  13155. case 83:
  13156. node = this.startNode();
  13157. this.next();
  13158. if (this.match(16)) {
  13159. return this.parseImportMetaProperty(node);
  13160. }
  13161. if (this.match(10)) {
  13162. if (this.options.createImportExpressions) {
  13163. return this.parseImportCall(node);
  13164. } else {
  13165. return this.finishNode(node, "Import");
  13166. }
  13167. } else {
  13168. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13169. return this.finishNode(node, "Import");
  13170. }
  13171. case 78:
  13172. node = this.startNode();
  13173. this.next();
  13174. return this.finishNode(node, "ThisExpression");
  13175. case 90:
  13176. {
  13177. return this.parseDo(this.startNode(), false);
  13178. }
  13179. case 56:
  13180. case 31:
  13181. {
  13182. this.readRegexp();
  13183. return this.parseRegExpLiteral(this.state.value);
  13184. }
  13185. case 134:
  13186. return this.parseNumericLiteral(this.state.value);
  13187. case 135:
  13188. return this.parseBigIntLiteral(this.state.value);
  13189. case 136:
  13190. return this.parseDecimalLiteral(this.state.value);
  13191. case 133:
  13192. return this.parseStringLiteral(this.state.value);
  13193. case 84:
  13194. return this.parseNullLiteral();
  13195. case 85:
  13196. return this.parseBooleanLiteral(true);
  13197. case 86:
  13198. return this.parseBooleanLiteral(false);
  13199. case 10:
  13200. {
  13201. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13202. return this.parseParenAndDistinguishExpression(canBeArrow);
  13203. }
  13204. case 2:
  13205. case 1:
  13206. {
  13207. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13208. }
  13209. case 0:
  13210. {
  13211. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13212. }
  13213. case 6:
  13214. case 7:
  13215. {
  13216. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13217. }
  13218. case 5:
  13219. {
  13220. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13221. }
  13222. case 68:
  13223. return this.parseFunctionOrFunctionSent();
  13224. case 26:
  13225. decorators = this.parseDecorators();
  13226. case 80:
  13227. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13228. case 77:
  13229. return this.parseNewOrNewTarget();
  13230. case 25:
  13231. case 24:
  13232. return this.parseTemplate(false);
  13233. case 15:
  13234. {
  13235. node = this.startNode();
  13236. this.next();
  13237. node.object = null;
  13238. const callee = node.callee = this.parseNoCallExpr();
  13239. if (callee.type === "MemberExpression") {
  13240. return this.finishNode(node, "BindExpression");
  13241. } else {
  13242. throw this.raise(Errors.UnsupportedBind, callee);
  13243. }
  13244. }
  13245. case 138:
  13246. {
  13247. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13248. identifierName: this.state.value
  13249. });
  13250. return this.parsePrivateName();
  13251. }
  13252. case 33:
  13253. {
  13254. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13255. }
  13256. case 32:
  13257. {
  13258. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13259. }
  13260. case 37:
  13261. case 38:
  13262. {
  13263. return this.parseTopicReference("hack");
  13264. }
  13265. case 44:
  13266. case 54:
  13267. case 27:
  13268. {
  13269. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13270. if (pipeProposal) {
  13271. return this.parseTopicReference(pipeProposal);
  13272. }
  13273. this.unexpected();
  13274. break;
  13275. }
  13276. case 47:
  13277. {
  13278. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13279. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13280. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13281. } else {
  13282. this.unexpected();
  13283. }
  13284. break;
  13285. }
  13286. default:
  13287. if (tokenIsIdentifier(type)) {
  13288. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13289. return this.parseModuleExpression();
  13290. }
  13291. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13292. const containsEsc = this.state.containsEsc;
  13293. const id = this.parseIdentifier();
  13294. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13295. const {
  13296. type
  13297. } = this.state;
  13298. if (type === 68) {
  13299. this.resetPreviousNodeTrailingComments(id);
  13300. this.next();
  13301. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13302. } else if (tokenIsIdentifier(type)) {
  13303. if (this.lookaheadCharCode() === 61) {
  13304. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13305. } else {
  13306. return id;
  13307. }
  13308. } else if (type === 90) {
  13309. this.resetPreviousNodeTrailingComments(id);
  13310. return this.parseDo(this.startNodeAtNode(id), true);
  13311. }
  13312. }
  13313. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13314. this.next();
  13315. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13316. }
  13317. return id;
  13318. } else {
  13319. this.unexpected();
  13320. }
  13321. }
  13322. }
  13323. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13324. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13325. if (pipeProposal) {
  13326. this.state.type = topicTokenType;
  13327. this.state.value = topicTokenValue;
  13328. this.state.pos--;
  13329. this.state.end--;
  13330. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13331. return this.parseTopicReference(pipeProposal);
  13332. } else {
  13333. this.unexpected();
  13334. }
  13335. }
  13336. parseTopicReference(pipeProposal) {
  13337. const node = this.startNode();
  13338. const startLoc = this.state.startLoc;
  13339. const tokenType = this.state.type;
  13340. this.next();
  13341. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13342. }
  13343. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13344. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13345. const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
  13346. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13347. this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc);
  13348. }
  13349. this.registerTopicReference();
  13350. return this.finishNode(node, nodeType);
  13351. } else {
  13352. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13353. token: tokenLabelName(tokenType)
  13354. });
  13355. }
  13356. }
  13357. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13358. switch (pipeProposal) {
  13359. case "hack":
  13360. {
  13361. return this.hasPlugin(["pipelineOperator", {
  13362. topicToken: tokenLabelName(tokenType)
  13363. }]);
  13364. }
  13365. case "smart":
  13366. return tokenType === 27;
  13367. default:
  13368. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13369. }
  13370. }
  13371. parseAsyncArrowUnaryFunction(node) {
  13372. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13373. const params = [this.parseIdentifier()];
  13374. this.prodParam.exit();
  13375. if (this.hasPrecedingLineBreak()) {
  13376. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13377. }
  13378. this.expect(19);
  13379. return this.parseArrowExpression(node, params, true);
  13380. }
  13381. parseDo(node, isAsync) {
  13382. this.expectPlugin("doExpressions");
  13383. if (isAsync) {
  13384. this.expectPlugin("asyncDoExpressions");
  13385. }
  13386. node.async = isAsync;
  13387. this.next();
  13388. const oldLabels = this.state.labels;
  13389. this.state.labels = [];
  13390. if (isAsync) {
  13391. this.prodParam.enter(2);
  13392. node.body = this.parseBlock();
  13393. this.prodParam.exit();
  13394. } else {
  13395. node.body = this.parseBlock();
  13396. }
  13397. this.state.labels = oldLabels;
  13398. return this.finishNode(node, "DoExpression");
  13399. }
  13400. parseSuper() {
  13401. const node = this.startNode();
  13402. this.next();
  13403. if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  13404. this.raise(Errors.SuperNotAllowed, node);
  13405. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  13406. this.raise(Errors.UnexpectedSuper, node);
  13407. }
  13408. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13409. this.raise(Errors.UnsupportedSuper, node);
  13410. }
  13411. return this.finishNode(node, "Super");
  13412. }
  13413. parsePrivateName() {
  13414. const node = this.startNode();
  13415. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13416. const name = this.state.value;
  13417. this.next();
  13418. node.id = this.createIdentifier(id, name);
  13419. return this.finishNode(node, "PrivateName");
  13420. }
  13421. parseFunctionOrFunctionSent() {
  13422. const node = this.startNode();
  13423. this.next();
  13424. if (this.prodParam.hasYield && this.match(16)) {
  13425. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13426. this.next();
  13427. if (this.match(103)) {
  13428. this.expectPlugin("functionSent");
  13429. } else if (!this.hasPlugin("functionSent")) {
  13430. this.unexpected();
  13431. }
  13432. return this.parseMetaProperty(node, meta, "sent");
  13433. }
  13434. return this.parseFunction(node);
  13435. }
  13436. parseMetaProperty(node, meta, propertyName) {
  13437. node.meta = meta;
  13438. const containsEsc = this.state.containsEsc;
  13439. node.property = this.parseIdentifier(true);
  13440. if (node.property.name !== propertyName || containsEsc) {
  13441. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13442. target: meta.name,
  13443. onlyValidPropertyName: propertyName
  13444. });
  13445. }
  13446. return this.finishNode(node, "MetaProperty");
  13447. }
  13448. parseImportMetaProperty(node) {
  13449. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  13450. this.next();
  13451. if (this.isContextual(101)) {
  13452. if (!this.inModule) {
  13453. this.raise(Errors.ImportMetaOutsideModule, id);
  13454. }
  13455. this.sawUnambiguousESM = true;
  13456. } else if (this.isContextual(105) || this.isContextual(97)) {
  13457. const isSource = this.isContextual(105);
  13458. if (!isSource) this.unexpected();
  13459. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  13460. if (!this.options.createImportExpressions) {
  13461. throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, {
  13462. phase: this.state.value
  13463. });
  13464. }
  13465. this.next();
  13466. node.phase = isSource ? "source" : "defer";
  13467. return this.parseImportCall(node);
  13468. }
  13469. return this.parseMetaProperty(node, id, "meta");
  13470. }
  13471. parseLiteralAtNode(value, type, node) {
  13472. this.addExtra(node, "rawValue", value);
  13473. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13474. node.value = value;
  13475. this.next();
  13476. return this.finishNode(node, type);
  13477. }
  13478. parseLiteral(value, type) {
  13479. const node = this.startNode();
  13480. return this.parseLiteralAtNode(value, type, node);
  13481. }
  13482. parseStringLiteral(value) {
  13483. return this.parseLiteral(value, "StringLiteral");
  13484. }
  13485. parseNumericLiteral(value) {
  13486. return this.parseLiteral(value, "NumericLiteral");
  13487. }
  13488. parseBigIntLiteral(value) {
  13489. return this.parseLiteral(value, "BigIntLiteral");
  13490. }
  13491. parseDecimalLiteral(value) {
  13492. return this.parseLiteral(value, "DecimalLiteral");
  13493. }
  13494. parseRegExpLiteral(value) {
  13495. const node = this.parseLiteral(value.value, "RegExpLiteral");
  13496. node.pattern = value.pattern;
  13497. node.flags = value.flags;
  13498. return node;
  13499. }
  13500. parseBooleanLiteral(value) {
  13501. const node = this.startNode();
  13502. node.value = value;
  13503. this.next();
  13504. return this.finishNode(node, "BooleanLiteral");
  13505. }
  13506. parseNullLiteral() {
  13507. const node = this.startNode();
  13508. this.next();
  13509. return this.finishNode(node, "NullLiteral");
  13510. }
  13511. parseParenAndDistinguishExpression(canBeArrow) {
  13512. const startLoc = this.state.startLoc;
  13513. let val;
  13514. this.next();
  13515. this.expressionScope.enter(newArrowHeadScope());
  13516. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13517. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13518. this.state.maybeInArrowParameters = true;
  13519. this.state.inFSharpPipelineDirectBody = false;
  13520. const innerStartLoc = this.state.startLoc;
  13521. const exprList = [];
  13522. const refExpressionErrors = new ExpressionErrors();
  13523. let first = true;
  13524. let spreadStartLoc;
  13525. let optionalCommaStartLoc;
  13526. while (!this.match(11)) {
  13527. if (first) {
  13528. first = false;
  13529. } else {
  13530. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  13531. if (this.match(11)) {
  13532. optionalCommaStartLoc = this.state.startLoc;
  13533. break;
  13534. }
  13535. }
  13536. if (this.match(21)) {
  13537. const spreadNodeStartLoc = this.state.startLoc;
  13538. spreadStartLoc = this.state.startLoc;
  13539. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  13540. if (!this.checkCommaAfterRest(41)) {
  13541. break;
  13542. }
  13543. } else {
  13544. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  13545. }
  13546. }
  13547. const innerEndLoc = this.state.lastTokEndLoc;
  13548. this.expect(11);
  13549. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13550. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13551. let arrowNode = this.startNodeAt(startLoc);
  13552. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  13553. this.checkDestructuringPrivate(refExpressionErrors);
  13554. this.expressionScope.validateAsPattern();
  13555. this.expressionScope.exit();
  13556. this.parseArrowExpression(arrowNode, exprList, false);
  13557. return arrowNode;
  13558. }
  13559. this.expressionScope.exit();
  13560. if (!exprList.length) {
  13561. this.unexpected(this.state.lastTokStartLoc);
  13562. }
  13563. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  13564. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  13565. this.checkExpressionErrors(refExpressionErrors, true);
  13566. this.toReferencedListDeep(exprList, true);
  13567. if (exprList.length > 1) {
  13568. val = this.startNodeAt(innerStartLoc);
  13569. val.expressions = exprList;
  13570. this.finishNode(val, "SequenceExpression");
  13571. this.resetEndLocation(val, innerEndLoc);
  13572. } else {
  13573. val = exprList[0];
  13574. }
  13575. return this.wrapParenthesis(startLoc, val);
  13576. }
  13577. wrapParenthesis(startLoc, expression) {
  13578. if (!this.options.createParenthesizedExpressions) {
  13579. this.addExtra(expression, "parenthesized", true);
  13580. this.addExtra(expression, "parenStart", startLoc.index);
  13581. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  13582. return expression;
  13583. }
  13584. const parenExpression = this.startNodeAt(startLoc);
  13585. parenExpression.expression = expression;
  13586. return this.finishNode(parenExpression, "ParenthesizedExpression");
  13587. }
  13588. shouldParseArrow(params) {
  13589. return !this.canInsertSemicolon();
  13590. }
  13591. parseArrow(node) {
  13592. if (this.eat(19)) {
  13593. return node;
  13594. }
  13595. }
  13596. parseParenItem(node, startLoc) {
  13597. return node;
  13598. }
  13599. parseNewOrNewTarget() {
  13600. const node = this.startNode();
  13601. this.next();
  13602. if (this.match(16)) {
  13603. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  13604. this.next();
  13605. const metaProp = this.parseMetaProperty(node, meta, "target");
  13606. if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) {
  13607. this.raise(Errors.UnexpectedNewTarget, metaProp);
  13608. }
  13609. return metaProp;
  13610. }
  13611. return this.parseNew(node);
  13612. }
  13613. parseNew(node) {
  13614. this.parseNewCallee(node);
  13615. if (this.eat(10)) {
  13616. const args = this.parseExprList(11);
  13617. this.toReferencedList(args);
  13618. node.arguments = args;
  13619. } else {
  13620. node.arguments = [];
  13621. }
  13622. return this.finishNode(node, "NewExpression");
  13623. }
  13624. parseNewCallee(node) {
  13625. const isImport = this.match(83);
  13626. const callee = this.parseNoCallExpr();
  13627. node.callee = callee;
  13628. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  13629. this.raise(Errors.ImportCallNotNewExpression, callee);
  13630. }
  13631. }
  13632. parseTemplateElement(isTagged) {
  13633. const {
  13634. start,
  13635. startLoc,
  13636. end,
  13637. value
  13638. } = this.state;
  13639. const elemStart = start + 1;
  13640. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  13641. if (value === null) {
  13642. if (!isTagged) {
  13643. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  13644. }
  13645. }
  13646. const isTail = this.match(24);
  13647. const endOffset = isTail ? -1 : -2;
  13648. const elemEnd = end + endOffset;
  13649. elem.value = {
  13650. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  13651. cooked: value === null ? null : value.slice(1, endOffset)
  13652. };
  13653. elem.tail = isTail;
  13654. this.next();
  13655. const finishedNode = this.finishNode(elem, "TemplateElement");
  13656. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  13657. return finishedNode;
  13658. }
  13659. parseTemplate(isTagged) {
  13660. const node = this.startNode();
  13661. node.expressions = [];
  13662. let curElt = this.parseTemplateElement(isTagged);
  13663. node.quasis = [curElt];
  13664. while (!curElt.tail) {
  13665. node.expressions.push(this.parseTemplateSubstitution());
  13666. this.readTemplateContinuation();
  13667. node.quasis.push(curElt = this.parseTemplateElement(isTagged));
  13668. }
  13669. return this.finishNode(node, "TemplateLiteral");
  13670. }
  13671. parseTemplateSubstitution() {
  13672. return this.parseExpression();
  13673. }
  13674. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  13675. if (isRecord) {
  13676. this.expectPlugin("recordAndTuple");
  13677. }
  13678. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13679. this.state.inFSharpPipelineDirectBody = false;
  13680. const propHash = Object.create(null);
  13681. let first = true;
  13682. const node = this.startNode();
  13683. node.properties = [];
  13684. this.next();
  13685. while (!this.match(close)) {
  13686. if (first) {
  13687. first = false;
  13688. } else {
  13689. this.expect(12);
  13690. if (this.match(close)) {
  13691. this.addTrailingCommaExtraToNode(node);
  13692. break;
  13693. }
  13694. }
  13695. let prop;
  13696. if (isPattern) {
  13697. prop = this.parseBindingProperty();
  13698. } else {
  13699. prop = this.parsePropertyDefinition(refExpressionErrors);
  13700. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  13701. }
  13702. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  13703. this.raise(Errors.InvalidRecordProperty, prop);
  13704. }
  13705. if (prop.shorthand) {
  13706. this.addExtra(prop, "shorthand", true);
  13707. }
  13708. node.properties.push(prop);
  13709. }
  13710. this.next();
  13711. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13712. let type = "ObjectExpression";
  13713. if (isPattern) {
  13714. type = "ObjectPattern";
  13715. } else if (isRecord) {
  13716. type = "RecordExpression";
  13717. }
  13718. return this.finishNode(node, type);
  13719. }
  13720. addTrailingCommaExtraToNode(node) {
  13721. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  13722. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  13723. }
  13724. maybeAsyncOrAccessorProp(prop) {
  13725. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  13726. }
  13727. parsePropertyDefinition(refExpressionErrors) {
  13728. let decorators = [];
  13729. if (this.match(26)) {
  13730. if (this.hasPlugin("decorators")) {
  13731. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  13732. }
  13733. while (this.match(26)) {
  13734. decorators.push(this.parseDecorator());
  13735. }
  13736. }
  13737. const prop = this.startNode();
  13738. let isAsync = false;
  13739. let isAccessor = false;
  13740. let startLoc;
  13741. if (this.match(21)) {
  13742. if (decorators.length) this.unexpected();
  13743. return this.parseSpread();
  13744. }
  13745. if (decorators.length) {
  13746. prop.decorators = decorators;
  13747. decorators = [];
  13748. }
  13749. prop.method = false;
  13750. if (refExpressionErrors) {
  13751. startLoc = this.state.startLoc;
  13752. }
  13753. let isGenerator = this.eat(55);
  13754. this.parsePropertyNamePrefixOperator(prop);
  13755. const containsEsc = this.state.containsEsc;
  13756. const key = this.parsePropertyName(prop, refExpressionErrors);
  13757. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  13758. const keyName = key.name;
  13759. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  13760. isAsync = true;
  13761. this.resetPreviousNodeTrailingComments(key);
  13762. isGenerator = this.eat(55);
  13763. this.parsePropertyName(prop);
  13764. }
  13765. if (keyName === "get" || keyName === "set") {
  13766. isAccessor = true;
  13767. this.resetPreviousNodeTrailingComments(key);
  13768. prop.kind = keyName;
  13769. if (this.match(55)) {
  13770. isGenerator = true;
  13771. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  13772. kind: keyName
  13773. });
  13774. this.next();
  13775. }
  13776. this.parsePropertyName(prop);
  13777. }
  13778. }
  13779. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  13780. }
  13781. getGetterSetterExpectedParamCount(method) {
  13782. return method.kind === "get" ? 0 : 1;
  13783. }
  13784. getObjectOrClassMethodParams(method) {
  13785. return method.params;
  13786. }
  13787. checkGetterSetterParams(method) {
  13788. var _params;
  13789. const paramCount = this.getGetterSetterExpectedParamCount(method);
  13790. const params = this.getObjectOrClassMethodParams(method);
  13791. if (params.length !== paramCount) {
  13792. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  13793. }
  13794. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  13795. this.raise(Errors.BadSetterRestParameter, method);
  13796. }
  13797. }
  13798. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  13799. if (isAccessor) {
  13800. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  13801. this.checkGetterSetterParams(finishedProp);
  13802. return finishedProp;
  13803. }
  13804. if (isAsync || isGenerator || this.match(10)) {
  13805. if (isPattern) this.unexpected();
  13806. prop.kind = "method";
  13807. prop.method = true;
  13808. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  13809. }
  13810. }
  13811. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  13812. prop.shorthand = false;
  13813. if (this.eat(14)) {
  13814. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  13815. return this.finishNode(prop, "ObjectProperty");
  13816. }
  13817. if (!prop.computed && prop.key.type === "Identifier") {
  13818. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  13819. if (isPattern) {
  13820. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13821. } else if (this.match(29)) {
  13822. const shorthandAssignLoc = this.state.startLoc;
  13823. if (refExpressionErrors != null) {
  13824. if (refExpressionErrors.shorthandAssignLoc === null) {
  13825. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  13826. }
  13827. } else {
  13828. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  13829. }
  13830. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13831. } else {
  13832. prop.value = cloneIdentifier(prop.key);
  13833. }
  13834. prop.shorthand = true;
  13835. return this.finishNode(prop, "ObjectProperty");
  13836. }
  13837. }
  13838. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  13839. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  13840. if (!node) this.unexpected();
  13841. return node;
  13842. }
  13843. parsePropertyName(prop, refExpressionErrors) {
  13844. if (this.eat(0)) {
  13845. prop.computed = true;
  13846. prop.key = this.parseMaybeAssignAllowIn();
  13847. this.expect(3);
  13848. } else {
  13849. const {
  13850. type,
  13851. value
  13852. } = this.state;
  13853. let key;
  13854. if (tokenIsKeywordOrIdentifier(type)) {
  13855. key = this.parseIdentifier(true);
  13856. } else {
  13857. switch (type) {
  13858. case 134:
  13859. key = this.parseNumericLiteral(value);
  13860. break;
  13861. case 133:
  13862. key = this.parseStringLiteral(value);
  13863. break;
  13864. case 135:
  13865. key = this.parseBigIntLiteral(value);
  13866. break;
  13867. case 136:
  13868. key = this.parseDecimalLiteral(value);
  13869. break;
  13870. case 138:
  13871. {
  13872. const privateKeyLoc = this.state.startLoc;
  13873. if (refExpressionErrors != null) {
  13874. if (refExpressionErrors.privateKeyLoc === null) {
  13875. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  13876. }
  13877. } else {
  13878. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  13879. }
  13880. key = this.parsePrivateName();
  13881. break;
  13882. }
  13883. default:
  13884. this.unexpected();
  13885. }
  13886. }
  13887. prop.key = key;
  13888. if (type !== 138) {
  13889. prop.computed = false;
  13890. }
  13891. }
  13892. return prop.key;
  13893. }
  13894. initFunction(node, isAsync) {
  13895. node.id = null;
  13896. node.generator = false;
  13897. node.async = isAsync;
  13898. }
  13899. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  13900. this.initFunction(node, isAsync);
  13901. node.generator = isGenerator;
  13902. this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
  13903. this.prodParam.enter(functionFlags(isAsync, node.generator));
  13904. this.parseFunctionParams(node, isConstructor);
  13905. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  13906. this.prodParam.exit();
  13907. this.scope.exit();
  13908. return finishedNode;
  13909. }
  13910. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  13911. if (isTuple) {
  13912. this.expectPlugin("recordAndTuple");
  13913. }
  13914. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13915. this.state.inFSharpPipelineDirectBody = false;
  13916. const node = this.startNode();
  13917. this.next();
  13918. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  13919. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13920. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  13921. }
  13922. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  13923. this.scope.enter(2 | 4);
  13924. let flags = functionFlags(isAsync, false);
  13925. if (!this.match(5) && this.prodParam.hasIn) {
  13926. flags |= 8;
  13927. }
  13928. this.prodParam.enter(flags);
  13929. this.initFunction(node, isAsync);
  13930. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13931. if (params) {
  13932. this.state.maybeInArrowParameters = true;
  13933. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  13934. }
  13935. this.state.maybeInArrowParameters = false;
  13936. this.parseFunctionBody(node, true);
  13937. this.prodParam.exit();
  13938. this.scope.exit();
  13939. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13940. return this.finishNode(node, "ArrowFunctionExpression");
  13941. }
  13942. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  13943. this.toAssignableList(params, trailingCommaLoc, false);
  13944. node.params = params;
  13945. }
  13946. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  13947. this.parseFunctionBody(node, false, isMethod);
  13948. return this.finishNode(node, type);
  13949. }
  13950. parseFunctionBody(node, allowExpression, isMethod = false) {
  13951. const isExpression = allowExpression && !this.match(5);
  13952. this.expressionScope.enter(newExpressionScope());
  13953. if (isExpression) {
  13954. node.body = this.parseMaybeAssign();
  13955. this.checkParams(node, false, allowExpression, false);
  13956. } else {
  13957. const oldStrict = this.state.strict;
  13958. const oldLabels = this.state.labels;
  13959. this.state.labels = [];
  13960. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  13961. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  13962. const nonSimple = !this.isSimpleParamList(node.params);
  13963. if (hasStrictModeDirective && nonSimple) {
  13964. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  13965. }
  13966. const strictModeChanged = !oldStrict && this.state.strict;
  13967. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  13968. if (this.state.strict && node.id) {
  13969. this.checkIdentifier(node.id, 65, strictModeChanged);
  13970. }
  13971. });
  13972. this.prodParam.exit();
  13973. this.state.labels = oldLabels;
  13974. }
  13975. this.expressionScope.exit();
  13976. }
  13977. isSimpleParameter(node) {
  13978. return node.type === "Identifier";
  13979. }
  13980. isSimpleParamList(params) {
  13981. for (let i = 0, len = params.length; i < len; i++) {
  13982. if (!this.isSimpleParameter(params[i])) return false;
  13983. }
  13984. return true;
  13985. }
  13986. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  13987. const checkClashes = !allowDuplicates && new Set();
  13988. const formalParameters = {
  13989. type: "FormalParameters"
  13990. };
  13991. for (const param of node.params) {
  13992. this.checkLVal(param, {
  13993. in: formalParameters,
  13994. binding: 5,
  13995. checkClashes,
  13996. strictModeChanged
  13997. });
  13998. }
  13999. }
  14000. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  14001. const elts = [];
  14002. let first = true;
  14003. while (!this.eat(close)) {
  14004. if (first) {
  14005. first = false;
  14006. } else {
  14007. this.expect(12);
  14008. if (this.match(close)) {
  14009. if (nodeForExtra) {
  14010. this.addTrailingCommaExtraToNode(nodeForExtra);
  14011. }
  14012. this.next();
  14013. break;
  14014. }
  14015. }
  14016. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  14017. }
  14018. return elts;
  14019. }
  14020. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  14021. let elt;
  14022. if (this.match(12)) {
  14023. if (!allowEmpty) {
  14024. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14025. unexpected: ","
  14026. });
  14027. }
  14028. elt = null;
  14029. } else if (this.match(21)) {
  14030. const spreadNodeStartLoc = this.state.startLoc;
  14031. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14032. } else if (this.match(17)) {
  14033. this.expectPlugin("partialApplication");
  14034. if (!allowPlaceholder) {
  14035. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14036. }
  14037. const node = this.startNode();
  14038. this.next();
  14039. elt = this.finishNode(node, "ArgumentPlaceholder");
  14040. } else {
  14041. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  14042. }
  14043. return elt;
  14044. }
  14045. parseIdentifier(liberal) {
  14046. const node = this.startNode();
  14047. const name = this.parseIdentifierName(liberal);
  14048. return this.createIdentifier(node, name);
  14049. }
  14050. createIdentifier(node, name) {
  14051. node.name = name;
  14052. node.loc.identifierName = name;
  14053. return this.finishNode(node, "Identifier");
  14054. }
  14055. parseIdentifierName(liberal) {
  14056. let name;
  14057. const {
  14058. startLoc,
  14059. type
  14060. } = this.state;
  14061. if (tokenIsKeywordOrIdentifier(type)) {
  14062. name = this.state.value;
  14063. } else {
  14064. this.unexpected();
  14065. }
  14066. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14067. if (liberal) {
  14068. if (tokenIsKeyword) {
  14069. this.replaceToken(132);
  14070. }
  14071. } else {
  14072. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14073. }
  14074. this.next();
  14075. return name;
  14076. }
  14077. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14078. if (word.length > 10) {
  14079. return;
  14080. }
  14081. if (!canBeReservedWord(word)) {
  14082. return;
  14083. }
  14084. if (checkKeywords && isKeyword(word)) {
  14085. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14086. keyword: word
  14087. });
  14088. return;
  14089. }
  14090. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14091. if (reservedTest(word, this.inModule)) {
  14092. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14093. reservedWord: word
  14094. });
  14095. return;
  14096. } else if (word === "yield") {
  14097. if (this.prodParam.hasYield) {
  14098. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14099. return;
  14100. }
  14101. } else if (word === "await") {
  14102. if (this.prodParam.hasAwait) {
  14103. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14104. return;
  14105. }
  14106. if (this.scope.inStaticBlock) {
  14107. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14108. return;
  14109. }
  14110. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14111. } else if (word === "arguments") {
  14112. if (this.scope.inClassAndNotInNonArrowFunction) {
  14113. this.raise(Errors.ArgumentsInClass, startLoc);
  14114. return;
  14115. }
  14116. }
  14117. }
  14118. isAwaitAllowed() {
  14119. if (this.prodParam.hasAwait) return true;
  14120. if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
  14121. return true;
  14122. }
  14123. return false;
  14124. }
  14125. parseAwait(startLoc) {
  14126. const node = this.startNodeAt(startLoc);
  14127. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14128. if (this.eat(55)) {
  14129. this.raise(Errors.ObsoleteAwaitStar, node);
  14130. }
  14131. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  14132. if (this.isAmbiguousAwait()) {
  14133. this.ambiguousScriptDifferentAst = true;
  14134. } else {
  14135. this.sawUnambiguousESM = true;
  14136. }
  14137. }
  14138. if (!this.state.soloAwait) {
  14139. node.argument = this.parseMaybeUnary(null, true);
  14140. }
  14141. return this.finishNode(node, "AwaitExpression");
  14142. }
  14143. isAmbiguousAwait() {
  14144. if (this.hasPrecedingLineBreak()) return true;
  14145. const {
  14146. type
  14147. } = this.state;
  14148. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14149. }
  14150. parseYield() {
  14151. const node = this.startNode();
  14152. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14153. this.next();
  14154. let delegating = false;
  14155. let argument = null;
  14156. if (!this.hasPrecedingLineBreak()) {
  14157. delegating = this.eat(55);
  14158. switch (this.state.type) {
  14159. case 13:
  14160. case 139:
  14161. case 8:
  14162. case 11:
  14163. case 3:
  14164. case 9:
  14165. case 14:
  14166. case 12:
  14167. if (!delegating) break;
  14168. default:
  14169. argument = this.parseMaybeAssign();
  14170. }
  14171. }
  14172. node.delegate = delegating;
  14173. node.argument = argument;
  14174. return this.finishNode(node, "YieldExpression");
  14175. }
  14176. parseImportCall(node) {
  14177. this.next();
  14178. node.source = this.parseMaybeAssignAllowIn();
  14179. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  14180. node.options = null;
  14181. }
  14182. if (this.eat(12)) {
  14183. this.expectImportAttributesPlugin();
  14184. if (!this.match(11)) {
  14185. node.options = this.parseMaybeAssignAllowIn();
  14186. this.eat(12);
  14187. }
  14188. }
  14189. this.expect(11);
  14190. return this.finishNode(node, "ImportExpression");
  14191. }
  14192. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14193. if (this.hasPlugin(["pipelineOperator", {
  14194. proposal: "smart"
  14195. }])) {
  14196. if (left.type === "SequenceExpression") {
  14197. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14198. }
  14199. }
  14200. }
  14201. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14202. if (this.isSimpleReference(childExpr)) {
  14203. const bodyNode = this.startNodeAt(startLoc);
  14204. bodyNode.callee = childExpr;
  14205. return this.finishNode(bodyNode, "PipelineBareFunction");
  14206. } else {
  14207. const bodyNode = this.startNodeAt(startLoc);
  14208. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14209. bodyNode.expression = childExpr;
  14210. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14211. }
  14212. }
  14213. isSimpleReference(expression) {
  14214. switch (expression.type) {
  14215. case "MemberExpression":
  14216. return !expression.computed && this.isSimpleReference(expression.object);
  14217. case "Identifier":
  14218. return true;
  14219. default:
  14220. return false;
  14221. }
  14222. }
  14223. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14224. if (this.match(19)) {
  14225. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14226. }
  14227. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14228. this.raise(Errors.PipelineTopicUnused, startLoc);
  14229. }
  14230. }
  14231. withTopicBindingContext(callback) {
  14232. const outerContextTopicState = this.state.topicContext;
  14233. this.state.topicContext = {
  14234. maxNumOfResolvableTopics: 1,
  14235. maxTopicIndex: null
  14236. };
  14237. try {
  14238. return callback();
  14239. } finally {
  14240. this.state.topicContext = outerContextTopicState;
  14241. }
  14242. }
  14243. withSmartMixTopicForbiddingContext(callback) {
  14244. if (this.hasPlugin(["pipelineOperator", {
  14245. proposal: "smart"
  14246. }])) {
  14247. const outerContextTopicState = this.state.topicContext;
  14248. this.state.topicContext = {
  14249. maxNumOfResolvableTopics: 0,
  14250. maxTopicIndex: null
  14251. };
  14252. try {
  14253. return callback();
  14254. } finally {
  14255. this.state.topicContext = outerContextTopicState;
  14256. }
  14257. } else {
  14258. return callback();
  14259. }
  14260. }
  14261. withSoloAwaitPermittingContext(callback) {
  14262. const outerContextSoloAwaitState = this.state.soloAwait;
  14263. this.state.soloAwait = true;
  14264. try {
  14265. return callback();
  14266. } finally {
  14267. this.state.soloAwait = outerContextSoloAwaitState;
  14268. }
  14269. }
  14270. allowInAnd(callback) {
  14271. const flags = this.prodParam.currentFlags();
  14272. const prodParamToSet = 8 & ~flags;
  14273. if (prodParamToSet) {
  14274. this.prodParam.enter(flags | 8);
  14275. try {
  14276. return callback();
  14277. } finally {
  14278. this.prodParam.exit();
  14279. }
  14280. }
  14281. return callback();
  14282. }
  14283. disallowInAnd(callback) {
  14284. const flags = this.prodParam.currentFlags();
  14285. const prodParamToClear = 8 & flags;
  14286. if (prodParamToClear) {
  14287. this.prodParam.enter(flags & ~8);
  14288. try {
  14289. return callback();
  14290. } finally {
  14291. this.prodParam.exit();
  14292. }
  14293. }
  14294. return callback();
  14295. }
  14296. registerTopicReference() {
  14297. this.state.topicContext.maxTopicIndex = 0;
  14298. }
  14299. topicReferenceIsAllowedInCurrentContext() {
  14300. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14301. }
  14302. topicReferenceWasUsedInCurrentContext() {
  14303. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14304. }
  14305. parseFSharpPipelineBody(prec) {
  14306. const startLoc = this.state.startLoc;
  14307. this.state.potentialArrowAt = this.state.start;
  14308. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14309. this.state.inFSharpPipelineDirectBody = true;
  14310. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14311. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14312. return ret;
  14313. }
  14314. parseModuleExpression() {
  14315. this.expectPlugin("moduleBlocks");
  14316. const node = this.startNode();
  14317. this.next();
  14318. if (!this.match(5)) {
  14319. this.unexpected(null, 5);
  14320. }
  14321. const program = this.startNodeAt(this.state.endLoc);
  14322. this.next();
  14323. const revertScopes = this.initializeScopes(true);
  14324. this.enterInitialScopes();
  14325. try {
  14326. node.body = this.parseProgram(program, 8, "module");
  14327. } finally {
  14328. revertScopes();
  14329. }
  14330. return this.finishNode(node, "ModuleExpression");
  14331. }
  14332. parsePropertyNamePrefixOperator(prop) {}
  14333. }
  14334. const loopLabel = {
  14335. kind: 1
  14336. },
  14337. switchLabel = {
  14338. kind: 2
  14339. };
  14340. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14341. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14342. function babel7CompatTokens(tokens, input) {
  14343. for (let i = 0; i < tokens.length; i++) {
  14344. const token = tokens[i];
  14345. const {
  14346. type
  14347. } = token;
  14348. if (typeof type === "number") {
  14349. {
  14350. if (type === 138) {
  14351. const {
  14352. loc,
  14353. start,
  14354. value,
  14355. end
  14356. } = token;
  14357. const hashEndPos = start + 1;
  14358. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14359. tokens.splice(i, 1, new Token({
  14360. type: getExportedToken(27),
  14361. value: "#",
  14362. start: start,
  14363. end: hashEndPos,
  14364. startLoc: loc.start,
  14365. endLoc: hashEndLoc
  14366. }), new Token({
  14367. type: getExportedToken(132),
  14368. value: value,
  14369. start: hashEndPos,
  14370. end: end,
  14371. startLoc: hashEndLoc,
  14372. endLoc: loc.end
  14373. }));
  14374. i++;
  14375. continue;
  14376. }
  14377. if (tokenIsTemplate(type)) {
  14378. const {
  14379. loc,
  14380. start,
  14381. value,
  14382. end
  14383. } = token;
  14384. const backquoteEnd = start + 1;
  14385. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14386. let startToken;
  14387. if (input.charCodeAt(start) === 96) {
  14388. startToken = new Token({
  14389. type: getExportedToken(22),
  14390. value: "`",
  14391. start: start,
  14392. end: backquoteEnd,
  14393. startLoc: loc.start,
  14394. endLoc: backquoteEndLoc
  14395. });
  14396. } else {
  14397. startToken = new Token({
  14398. type: getExportedToken(8),
  14399. value: "}",
  14400. start: start,
  14401. end: backquoteEnd,
  14402. startLoc: loc.start,
  14403. endLoc: backquoteEndLoc
  14404. });
  14405. }
  14406. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14407. if (type === 24) {
  14408. templateElementEnd = end - 1;
  14409. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14410. templateValue = value === null ? null : value.slice(1, -1);
  14411. endToken = new Token({
  14412. type: getExportedToken(22),
  14413. value: "`",
  14414. start: templateElementEnd,
  14415. end: end,
  14416. startLoc: templateElementEndLoc,
  14417. endLoc: loc.end
  14418. });
  14419. } else {
  14420. templateElementEnd = end - 2;
  14421. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  14422. templateValue = value === null ? null : value.slice(1, -2);
  14423. endToken = new Token({
  14424. type: getExportedToken(23),
  14425. value: "${",
  14426. start: templateElementEnd,
  14427. end: end,
  14428. startLoc: templateElementEndLoc,
  14429. endLoc: loc.end
  14430. });
  14431. }
  14432. tokens.splice(i, 1, startToken, new Token({
  14433. type: getExportedToken(20),
  14434. value: templateValue,
  14435. start: backquoteEnd,
  14436. end: templateElementEnd,
  14437. startLoc: backquoteEndLoc,
  14438. endLoc: templateElementEndLoc
  14439. }), endToken);
  14440. i += 2;
  14441. continue;
  14442. }
  14443. }
  14444. token.type = getExportedToken(type);
  14445. }
  14446. }
  14447. return tokens;
  14448. }
  14449. class StatementParser extends ExpressionParser {
  14450. parseTopLevel(file, program) {
  14451. file.program = this.parseProgram(program);
  14452. file.comments = this.comments;
  14453. if (this.options.tokens) {
  14454. file.tokens = babel7CompatTokens(this.tokens, this.input);
  14455. }
  14456. return this.finishNode(file, "File");
  14457. }
  14458. parseProgram(program, end = 139, sourceType = this.options.sourceType) {
  14459. program.sourceType = sourceType;
  14460. program.interpreter = this.parseInterpreterDirective();
  14461. this.parseBlockBody(program, true, true, end);
  14462. if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  14463. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  14464. this.raise(Errors.ModuleExportUndefined, at, {
  14465. localName
  14466. });
  14467. }
  14468. }
  14469. let finishedProgram;
  14470. if (end === 139) {
  14471. finishedProgram = this.finishNode(program, "Program");
  14472. } else {
  14473. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  14474. }
  14475. return finishedProgram;
  14476. }
  14477. stmtToDirective(stmt) {
  14478. const directive = stmt;
  14479. directive.type = "Directive";
  14480. directive.value = directive.expression;
  14481. delete directive.expression;
  14482. const directiveLiteral = directive.value;
  14483. const expressionValue = directiveLiteral.value;
  14484. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  14485. const val = directiveLiteral.value = raw.slice(1, -1);
  14486. this.addExtra(directiveLiteral, "raw", raw);
  14487. this.addExtra(directiveLiteral, "rawValue", val);
  14488. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  14489. directiveLiteral.type = "DirectiveLiteral";
  14490. return directive;
  14491. }
  14492. parseInterpreterDirective() {
  14493. if (!this.match(28)) {
  14494. return null;
  14495. }
  14496. const node = this.startNode();
  14497. node.value = this.state.value;
  14498. this.next();
  14499. return this.finishNode(node, "InterpreterDirective");
  14500. }
  14501. isLet() {
  14502. if (!this.isContextual(100)) {
  14503. return false;
  14504. }
  14505. return this.hasFollowingBindingAtom();
  14506. }
  14507. chStartsBindingIdentifier(ch, pos) {
  14508. if (isIdentifierStart(ch)) {
  14509. keywordRelationalOperator.lastIndex = pos;
  14510. if (keywordRelationalOperator.test(this.input)) {
  14511. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  14512. if (!isIdentifierChar(endCh) && endCh !== 92) {
  14513. return false;
  14514. }
  14515. }
  14516. return true;
  14517. } else if (ch === 92) {
  14518. return true;
  14519. } else {
  14520. return false;
  14521. }
  14522. }
  14523. chStartsBindingPattern(ch) {
  14524. return ch === 91 || ch === 123;
  14525. }
  14526. hasFollowingBindingAtom() {
  14527. const next = this.nextTokenStart();
  14528. const nextCh = this.codePointAtPos(next);
  14529. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  14530. }
  14531. hasInLineFollowingBindingIdentifier() {
  14532. const next = this.nextTokenInLineStart();
  14533. const nextCh = this.codePointAtPos(next);
  14534. return this.chStartsBindingIdentifier(nextCh, next);
  14535. }
  14536. startsUsingForOf() {
  14537. const {
  14538. type,
  14539. containsEsc
  14540. } = this.lookahead();
  14541. if (type === 102 && !containsEsc) {
  14542. return false;
  14543. } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) {
  14544. this.expectPlugin("explicitResourceManagement");
  14545. return true;
  14546. }
  14547. }
  14548. startsAwaitUsing() {
  14549. let next = this.nextTokenInLineStart();
  14550. if (this.isUnparsedContextual(next, "using")) {
  14551. next = this.nextTokenInLineStartSince(next + 5);
  14552. const nextCh = this.codePointAtPos(next);
  14553. if (this.chStartsBindingIdentifier(nextCh, next)) {
  14554. this.expectPlugin("explicitResourceManagement");
  14555. return true;
  14556. }
  14557. }
  14558. return false;
  14559. }
  14560. parseModuleItem() {
  14561. return this.parseStatementLike(1 | 2 | 4 | 8);
  14562. }
  14563. parseStatementListItem() {
  14564. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  14565. }
  14566. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  14567. let flags = 0;
  14568. if (this.options.annexB && !this.state.strict) {
  14569. flags |= 4;
  14570. if (allowLabeledFunction) {
  14571. flags |= 8;
  14572. }
  14573. }
  14574. return this.parseStatementLike(flags);
  14575. }
  14576. parseStatement() {
  14577. return this.parseStatementLike(0);
  14578. }
  14579. parseStatementLike(flags) {
  14580. let decorators = null;
  14581. if (this.match(26)) {
  14582. decorators = this.parseDecorators(true);
  14583. }
  14584. return this.parseStatementContent(flags, decorators);
  14585. }
  14586. parseStatementContent(flags, decorators) {
  14587. const starttype = this.state.type;
  14588. const node = this.startNode();
  14589. const allowDeclaration = !!(flags & 2);
  14590. const allowFunctionDeclaration = !!(flags & 4);
  14591. const topLevel = flags & 1;
  14592. switch (starttype) {
  14593. case 60:
  14594. return this.parseBreakContinueStatement(node, true);
  14595. case 63:
  14596. return this.parseBreakContinueStatement(node, false);
  14597. case 64:
  14598. return this.parseDebuggerStatement(node);
  14599. case 90:
  14600. return this.parseDoWhileStatement(node);
  14601. case 91:
  14602. return this.parseForStatement(node);
  14603. case 68:
  14604. if (this.lookaheadCharCode() === 46) break;
  14605. if (!allowFunctionDeclaration) {
  14606. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  14607. }
  14608. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  14609. case 80:
  14610. if (!allowDeclaration) this.unexpected();
  14611. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  14612. case 69:
  14613. return this.parseIfStatement(node);
  14614. case 70:
  14615. return this.parseReturnStatement(node);
  14616. case 71:
  14617. return this.parseSwitchStatement(node);
  14618. case 72:
  14619. return this.parseThrowStatement(node);
  14620. case 73:
  14621. return this.parseTryStatement(node);
  14622. case 96:
  14623. if (!this.state.containsEsc && this.startsAwaitUsing()) {
  14624. if (!this.isAwaitAllowed()) {
  14625. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  14626. } else if (!allowDeclaration) {
  14627. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  14628. }
  14629. this.next();
  14630. return this.parseVarStatement(node, "await using");
  14631. }
  14632. break;
  14633. case 107:
  14634. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifier()) {
  14635. break;
  14636. }
  14637. this.expectPlugin("explicitResourceManagement");
  14638. if (!this.scope.inModule && this.scope.inTopLevel) {
  14639. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  14640. } else if (!allowDeclaration) {
  14641. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14642. }
  14643. return this.parseVarStatement(node, "using");
  14644. case 100:
  14645. {
  14646. if (this.state.containsEsc) {
  14647. break;
  14648. }
  14649. const next = this.nextTokenStart();
  14650. const nextCh = this.codePointAtPos(next);
  14651. if (nextCh !== 91) {
  14652. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  14653. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  14654. break;
  14655. }
  14656. }
  14657. }
  14658. case 75:
  14659. {
  14660. if (!allowDeclaration) {
  14661. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14662. }
  14663. }
  14664. case 74:
  14665. {
  14666. const kind = this.state.value;
  14667. return this.parseVarStatement(node, kind);
  14668. }
  14669. case 92:
  14670. return this.parseWhileStatement(node);
  14671. case 76:
  14672. return this.parseWithStatement(node);
  14673. case 5:
  14674. return this.parseBlock();
  14675. case 13:
  14676. return this.parseEmptyStatement(node);
  14677. case 83:
  14678. {
  14679. const nextTokenCharCode = this.lookaheadCharCode();
  14680. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  14681. break;
  14682. }
  14683. }
  14684. case 82:
  14685. {
  14686. if (!this.options.allowImportExportEverywhere && !topLevel) {
  14687. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  14688. }
  14689. this.next();
  14690. let result;
  14691. if (starttype === 83) {
  14692. result = this.parseImport(node);
  14693. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  14694. this.sawUnambiguousESM = true;
  14695. }
  14696. } else {
  14697. result = this.parseExport(node, decorators);
  14698. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  14699. this.sawUnambiguousESM = true;
  14700. }
  14701. }
  14702. this.assertModuleNodeAllowed(result);
  14703. return result;
  14704. }
  14705. default:
  14706. {
  14707. if (this.isAsyncFunction()) {
  14708. if (!allowDeclaration) {
  14709. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  14710. }
  14711. this.next();
  14712. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  14713. }
  14714. }
  14715. }
  14716. const maybeName = this.state.value;
  14717. const expr = this.parseExpression();
  14718. if (tokenIsIdentifier(starttype) && expr.type === "Identifier" && this.eat(14)) {
  14719. return this.parseLabeledStatement(node, maybeName, expr, flags);
  14720. } else {
  14721. return this.parseExpressionStatement(node, expr, decorators);
  14722. }
  14723. }
  14724. assertModuleNodeAllowed(node) {
  14725. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  14726. this.raise(Errors.ImportOutsideModule, node);
  14727. }
  14728. }
  14729. decoratorsEnabledBeforeExport() {
  14730. if (this.hasPlugin("decorators-legacy")) return true;
  14731. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  14732. }
  14733. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  14734. if (maybeDecorators) {
  14735. if (classNode.decorators && classNode.decorators.length > 0) {
  14736. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  14737. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  14738. }
  14739. classNode.decorators.unshift(...maybeDecorators);
  14740. } else {
  14741. classNode.decorators = maybeDecorators;
  14742. }
  14743. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  14744. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  14745. }
  14746. return classNode;
  14747. }
  14748. canHaveLeadingDecorator() {
  14749. return this.match(80);
  14750. }
  14751. parseDecorators(allowExport) {
  14752. const decorators = [];
  14753. do {
  14754. decorators.push(this.parseDecorator());
  14755. } while (this.match(26));
  14756. if (this.match(82)) {
  14757. if (!allowExport) {
  14758. this.unexpected();
  14759. }
  14760. if (!this.decoratorsEnabledBeforeExport()) {
  14761. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  14762. }
  14763. } else if (!this.canHaveLeadingDecorator()) {
  14764. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  14765. }
  14766. return decorators;
  14767. }
  14768. parseDecorator() {
  14769. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  14770. const node = this.startNode();
  14771. this.next();
  14772. if (this.hasPlugin("decorators")) {
  14773. const startLoc = this.state.startLoc;
  14774. let expr;
  14775. if (this.match(10)) {
  14776. const startLoc = this.state.startLoc;
  14777. this.next();
  14778. expr = this.parseExpression();
  14779. this.expect(11);
  14780. expr = this.wrapParenthesis(startLoc, expr);
  14781. const paramsStartLoc = this.state.startLoc;
  14782. node.expression = this.parseMaybeDecoratorArguments(expr);
  14783. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  14784. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  14785. }
  14786. } else {
  14787. expr = this.parseIdentifier(false);
  14788. while (this.eat(16)) {
  14789. const node = this.startNodeAt(startLoc);
  14790. node.object = expr;
  14791. if (this.match(138)) {
  14792. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  14793. node.property = this.parsePrivateName();
  14794. } else {
  14795. node.property = this.parseIdentifier(true);
  14796. }
  14797. node.computed = false;
  14798. expr = this.finishNode(node, "MemberExpression");
  14799. }
  14800. node.expression = this.parseMaybeDecoratorArguments(expr);
  14801. }
  14802. } else {
  14803. node.expression = this.parseExprSubscripts();
  14804. }
  14805. return this.finishNode(node, "Decorator");
  14806. }
  14807. parseMaybeDecoratorArguments(expr) {
  14808. if (this.eat(10)) {
  14809. const node = this.startNodeAtNode(expr);
  14810. node.callee = expr;
  14811. node.arguments = this.parseCallExpressionArguments(11, false);
  14812. this.toReferencedList(node.arguments);
  14813. return this.finishNode(node, "CallExpression");
  14814. }
  14815. return expr;
  14816. }
  14817. parseBreakContinueStatement(node, isBreak) {
  14818. this.next();
  14819. if (this.isLineTerminator()) {
  14820. node.label = null;
  14821. } else {
  14822. node.label = this.parseIdentifier();
  14823. this.semicolon();
  14824. }
  14825. this.verifyBreakContinue(node, isBreak);
  14826. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  14827. }
  14828. verifyBreakContinue(node, isBreak) {
  14829. let i;
  14830. for (i = 0; i < this.state.labels.length; ++i) {
  14831. const lab = this.state.labels[i];
  14832. if (node.label == null || lab.name === node.label.name) {
  14833. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  14834. break;
  14835. }
  14836. if (node.label && isBreak) break;
  14837. }
  14838. }
  14839. if (i === this.state.labels.length) {
  14840. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  14841. this.raise(Errors.IllegalBreakContinue, node, {
  14842. type
  14843. });
  14844. }
  14845. }
  14846. parseDebuggerStatement(node) {
  14847. this.next();
  14848. this.semicolon();
  14849. return this.finishNode(node, "DebuggerStatement");
  14850. }
  14851. parseHeaderExpression() {
  14852. this.expect(10);
  14853. const val = this.parseExpression();
  14854. this.expect(11);
  14855. return val;
  14856. }
  14857. parseDoWhileStatement(node) {
  14858. this.next();
  14859. this.state.labels.push(loopLabel);
  14860. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  14861. this.state.labels.pop();
  14862. this.expect(92);
  14863. node.test = this.parseHeaderExpression();
  14864. this.eat(13);
  14865. return this.finishNode(node, "DoWhileStatement");
  14866. }
  14867. parseForStatement(node) {
  14868. this.next();
  14869. this.state.labels.push(loopLabel);
  14870. let awaitAt = null;
  14871. if (this.isAwaitAllowed() && this.eatContextual(96)) {
  14872. awaitAt = this.state.lastTokStartLoc;
  14873. }
  14874. this.scope.enter(0);
  14875. this.expect(10);
  14876. if (this.match(13)) {
  14877. if (awaitAt !== null) {
  14878. this.unexpected(awaitAt);
  14879. }
  14880. return this.parseFor(node, null);
  14881. }
  14882. const startsWithLet = this.isContextual(100);
  14883. {
  14884. const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing();
  14885. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf();
  14886. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  14887. if (this.match(74) || this.match(75) || isLetOrUsing) {
  14888. const initNode = this.startNode();
  14889. let kind;
  14890. if (startsWithAwaitUsing) {
  14891. kind = "await using";
  14892. if (!this.isAwaitAllowed()) {
  14893. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  14894. }
  14895. this.next();
  14896. } else {
  14897. kind = this.state.value;
  14898. }
  14899. this.next();
  14900. this.parseVar(initNode, true, kind);
  14901. const init = this.finishNode(initNode, "VariableDeclaration");
  14902. const isForIn = this.match(58);
  14903. if (isForIn && starsWithUsingDeclaration) {
  14904. this.raise(Errors.ForInUsing, init);
  14905. }
  14906. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  14907. return this.parseForIn(node, init, awaitAt);
  14908. }
  14909. if (awaitAt !== null) {
  14910. this.unexpected(awaitAt);
  14911. }
  14912. return this.parseFor(node, init);
  14913. }
  14914. }
  14915. const startsWithAsync = this.isContextual(95);
  14916. const refExpressionErrors = new ExpressionErrors();
  14917. const init = this.parseExpression(true, refExpressionErrors);
  14918. const isForOf = this.isContextual(102);
  14919. if (isForOf) {
  14920. if (startsWithLet) {
  14921. this.raise(Errors.ForOfLet, init);
  14922. }
  14923. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  14924. this.raise(Errors.ForOfAsync, init);
  14925. }
  14926. }
  14927. if (isForOf || this.match(58)) {
  14928. this.checkDestructuringPrivate(refExpressionErrors);
  14929. this.toAssignable(init, true);
  14930. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  14931. this.checkLVal(init, {
  14932. in: {
  14933. type
  14934. }
  14935. });
  14936. return this.parseForIn(node, init, awaitAt);
  14937. } else {
  14938. this.checkExpressionErrors(refExpressionErrors, true);
  14939. }
  14940. if (awaitAt !== null) {
  14941. this.unexpected(awaitAt);
  14942. }
  14943. return this.parseFor(node, init);
  14944. }
  14945. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  14946. this.next();
  14947. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  14948. }
  14949. parseIfStatement(node) {
  14950. this.next();
  14951. node.test = this.parseHeaderExpression();
  14952. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  14953. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  14954. return this.finishNode(node, "IfStatement");
  14955. }
  14956. parseReturnStatement(node) {
  14957. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  14958. this.raise(Errors.IllegalReturn, this.state.startLoc);
  14959. }
  14960. this.next();
  14961. if (this.isLineTerminator()) {
  14962. node.argument = null;
  14963. } else {
  14964. node.argument = this.parseExpression();
  14965. this.semicolon();
  14966. }
  14967. return this.finishNode(node, "ReturnStatement");
  14968. }
  14969. parseSwitchStatement(node) {
  14970. this.next();
  14971. node.discriminant = this.parseHeaderExpression();
  14972. const cases = node.cases = [];
  14973. this.expect(5);
  14974. this.state.labels.push(switchLabel);
  14975. this.scope.enter(0);
  14976. let cur;
  14977. for (let sawDefault; !this.match(8);) {
  14978. if (this.match(61) || this.match(65)) {
  14979. const isCase = this.match(61);
  14980. if (cur) this.finishNode(cur, "SwitchCase");
  14981. cases.push(cur = this.startNode());
  14982. cur.consequent = [];
  14983. this.next();
  14984. if (isCase) {
  14985. cur.test = this.parseExpression();
  14986. } else {
  14987. if (sawDefault) {
  14988. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  14989. }
  14990. sawDefault = true;
  14991. cur.test = null;
  14992. }
  14993. this.expect(14);
  14994. } else {
  14995. if (cur) {
  14996. cur.consequent.push(this.parseStatementListItem());
  14997. } else {
  14998. this.unexpected();
  14999. }
  15000. }
  15001. }
  15002. this.scope.exit();
  15003. if (cur) this.finishNode(cur, "SwitchCase");
  15004. this.next();
  15005. this.state.labels.pop();
  15006. return this.finishNode(node, "SwitchStatement");
  15007. }
  15008. parseThrowStatement(node) {
  15009. this.next();
  15010. if (this.hasPrecedingLineBreak()) {
  15011. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  15012. }
  15013. node.argument = this.parseExpression();
  15014. this.semicolon();
  15015. return this.finishNode(node, "ThrowStatement");
  15016. }
  15017. parseCatchClauseParam() {
  15018. const param = this.parseBindingAtom();
  15019. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15020. this.checkLVal(param, {
  15021. in: {
  15022. type: "CatchClause"
  15023. },
  15024. binding: 9
  15025. });
  15026. return param;
  15027. }
  15028. parseTryStatement(node) {
  15029. this.next();
  15030. node.block = this.parseBlock();
  15031. node.handler = null;
  15032. if (this.match(62)) {
  15033. const clause = this.startNode();
  15034. this.next();
  15035. if (this.match(10)) {
  15036. this.expect(10);
  15037. clause.param = this.parseCatchClauseParam();
  15038. this.expect(11);
  15039. } else {
  15040. clause.param = null;
  15041. this.scope.enter(0);
  15042. }
  15043. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15044. this.scope.exit();
  15045. node.handler = this.finishNode(clause, "CatchClause");
  15046. }
  15047. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15048. if (!node.handler && !node.finalizer) {
  15049. this.raise(Errors.NoCatchOrFinally, node);
  15050. }
  15051. return this.finishNode(node, "TryStatement");
  15052. }
  15053. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15054. this.next();
  15055. this.parseVar(node, false, kind, allowMissingInitializer);
  15056. this.semicolon();
  15057. return this.finishNode(node, "VariableDeclaration");
  15058. }
  15059. parseWhileStatement(node) {
  15060. this.next();
  15061. node.test = this.parseHeaderExpression();
  15062. this.state.labels.push(loopLabel);
  15063. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15064. this.state.labels.pop();
  15065. return this.finishNode(node, "WhileStatement");
  15066. }
  15067. parseWithStatement(node) {
  15068. if (this.state.strict) {
  15069. this.raise(Errors.StrictWith, this.state.startLoc);
  15070. }
  15071. this.next();
  15072. node.object = this.parseHeaderExpression();
  15073. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15074. return this.finishNode(node, "WithStatement");
  15075. }
  15076. parseEmptyStatement(node) {
  15077. this.next();
  15078. return this.finishNode(node, "EmptyStatement");
  15079. }
  15080. parseLabeledStatement(node, maybeName, expr, flags) {
  15081. for (const label of this.state.labels) {
  15082. if (label.name === maybeName) {
  15083. this.raise(Errors.LabelRedeclaration, expr, {
  15084. labelName: maybeName
  15085. });
  15086. }
  15087. }
  15088. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15089. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15090. const label = this.state.labels[i];
  15091. if (label.statementStart === node.start) {
  15092. label.statementStart = this.state.start;
  15093. label.kind = kind;
  15094. } else {
  15095. break;
  15096. }
  15097. }
  15098. this.state.labels.push({
  15099. name: maybeName,
  15100. kind: kind,
  15101. statementStart: this.state.start
  15102. });
  15103. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15104. this.state.labels.pop();
  15105. node.label = expr;
  15106. return this.finishNode(node, "LabeledStatement");
  15107. }
  15108. parseExpressionStatement(node, expr, decorators) {
  15109. node.expression = expr;
  15110. this.semicolon();
  15111. return this.finishNode(node, "ExpressionStatement");
  15112. }
  15113. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15114. const node = this.startNode();
  15115. if (allowDirectives) {
  15116. this.state.strictErrors.clear();
  15117. }
  15118. this.expect(5);
  15119. if (createNewLexicalScope) {
  15120. this.scope.enter(0);
  15121. }
  15122. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15123. if (createNewLexicalScope) {
  15124. this.scope.exit();
  15125. }
  15126. return this.finishNode(node, "BlockStatement");
  15127. }
  15128. isValidDirective(stmt) {
  15129. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15130. }
  15131. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15132. const body = node.body = [];
  15133. const directives = node.directives = [];
  15134. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15135. }
  15136. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15137. const oldStrict = this.state.strict;
  15138. let hasStrictModeDirective = false;
  15139. let parsedNonDirective = false;
  15140. while (!this.match(end)) {
  15141. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15142. if (directives && !parsedNonDirective) {
  15143. if (this.isValidDirective(stmt)) {
  15144. const directive = this.stmtToDirective(stmt);
  15145. directives.push(directive);
  15146. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15147. hasStrictModeDirective = true;
  15148. this.setStrict(true);
  15149. }
  15150. continue;
  15151. }
  15152. parsedNonDirective = true;
  15153. this.state.strictErrors.clear();
  15154. }
  15155. body.push(stmt);
  15156. }
  15157. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15158. if (!oldStrict) {
  15159. this.setStrict(false);
  15160. }
  15161. this.next();
  15162. }
  15163. parseFor(node, init) {
  15164. node.init = init;
  15165. this.semicolon(false);
  15166. node.test = this.match(13) ? null : this.parseExpression();
  15167. this.semicolon(false);
  15168. node.update = this.match(11) ? null : this.parseExpression();
  15169. this.expect(11);
  15170. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15171. this.scope.exit();
  15172. this.state.labels.pop();
  15173. return this.finishNode(node, "ForStatement");
  15174. }
  15175. parseForIn(node, init, awaitAt) {
  15176. const isForIn = this.match(58);
  15177. this.next();
  15178. if (isForIn) {
  15179. if (awaitAt !== null) this.unexpected(awaitAt);
  15180. } else {
  15181. node.await = awaitAt !== null;
  15182. }
  15183. if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || !this.options.annexB || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
  15184. this.raise(Errors.ForInOfLoopInitializer, init, {
  15185. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15186. });
  15187. }
  15188. if (init.type === "AssignmentPattern") {
  15189. this.raise(Errors.InvalidLhs, init, {
  15190. ancestor: {
  15191. type: "ForStatement"
  15192. }
  15193. });
  15194. }
  15195. node.left = init;
  15196. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15197. this.expect(11);
  15198. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15199. this.scope.exit();
  15200. this.state.labels.pop();
  15201. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15202. }
  15203. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15204. const declarations = node.declarations = [];
  15205. node.kind = kind;
  15206. for (;;) {
  15207. const decl = this.startNode();
  15208. this.parseVarId(decl, kind);
  15209. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15210. if (decl.init === null && !allowMissingInitializer) {
  15211. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15212. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15213. kind: "destructuring"
  15214. });
  15215. } else if (kind === "const" && !(this.match(58) || this.isContextual(102))) {
  15216. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15217. kind: "const"
  15218. });
  15219. }
  15220. }
  15221. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15222. if (!this.eat(12)) break;
  15223. }
  15224. return node;
  15225. }
  15226. parseVarId(decl, kind) {
  15227. const id = this.parseBindingAtom();
  15228. this.checkLVal(id, {
  15229. in: {
  15230. type: "VariableDeclarator"
  15231. },
  15232. binding: kind === "var" ? 5 : 8201
  15233. });
  15234. decl.id = id;
  15235. }
  15236. parseAsyncFunctionExpression(node) {
  15237. return this.parseFunction(node, 8);
  15238. }
  15239. parseFunction(node, flags = 0) {
  15240. const hangingDeclaration = flags & 2;
  15241. const isDeclaration = !!(flags & 1);
  15242. const requireId = isDeclaration && !(flags & 4);
  15243. const isAsync = !!(flags & 8);
  15244. this.initFunction(node, isAsync);
  15245. if (this.match(55)) {
  15246. if (hangingDeclaration) {
  15247. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15248. }
  15249. this.next();
  15250. node.generator = true;
  15251. }
  15252. if (isDeclaration) {
  15253. node.id = this.parseFunctionId(requireId);
  15254. }
  15255. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15256. this.state.maybeInArrowParameters = false;
  15257. this.scope.enter(2);
  15258. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15259. if (!isDeclaration) {
  15260. node.id = this.parseFunctionId();
  15261. }
  15262. this.parseFunctionParams(node, false);
  15263. this.withSmartMixTopicForbiddingContext(() => {
  15264. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15265. });
  15266. this.prodParam.exit();
  15267. this.scope.exit();
  15268. if (isDeclaration && !hangingDeclaration) {
  15269. this.registerFunctionStatementId(node);
  15270. }
  15271. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15272. return node;
  15273. }
  15274. parseFunctionId(requireId) {
  15275. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15276. }
  15277. parseFunctionParams(node, isConstructor) {
  15278. this.expect(10);
  15279. this.expressionScope.enter(newParameterDeclarationScope());
  15280. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15281. this.expressionScope.exit();
  15282. }
  15283. registerFunctionStatementId(node) {
  15284. if (!node.id) return;
  15285. this.scope.declareName(node.id.name, !this.options.annexB || this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? 5 : 8201 : 17, node.id.loc.start);
  15286. }
  15287. parseClass(node, isStatement, optionalId) {
  15288. this.next();
  15289. const oldStrict = this.state.strict;
  15290. this.state.strict = true;
  15291. this.parseClassId(node, isStatement, optionalId);
  15292. this.parseClassSuper(node);
  15293. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15294. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15295. }
  15296. isClassProperty() {
  15297. return this.match(29) || this.match(13) || this.match(8);
  15298. }
  15299. isClassMethod() {
  15300. return this.match(10);
  15301. }
  15302. isNonstaticConstructor(method) {
  15303. return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor");
  15304. }
  15305. parseClassBody(hadSuperClass, oldStrict) {
  15306. this.classScope.enter();
  15307. const state = {
  15308. hadConstructor: false,
  15309. hadSuperClass
  15310. };
  15311. let decorators = [];
  15312. const classBody = this.startNode();
  15313. classBody.body = [];
  15314. this.expect(5);
  15315. this.withSmartMixTopicForbiddingContext(() => {
  15316. while (!this.match(8)) {
  15317. if (this.eat(13)) {
  15318. if (decorators.length > 0) {
  15319. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15320. }
  15321. continue;
  15322. }
  15323. if (this.match(26)) {
  15324. decorators.push(this.parseDecorator());
  15325. continue;
  15326. }
  15327. const member = this.startNode();
  15328. if (decorators.length) {
  15329. member.decorators = decorators;
  15330. this.resetStartLocationFromNode(member, decorators[0]);
  15331. decorators = [];
  15332. }
  15333. this.parseClassMember(classBody, member, state);
  15334. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15335. this.raise(Errors.DecoratorConstructor, member);
  15336. }
  15337. }
  15338. });
  15339. this.state.strict = oldStrict;
  15340. this.next();
  15341. if (decorators.length) {
  15342. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15343. }
  15344. this.classScope.exit();
  15345. return this.finishNode(classBody, "ClassBody");
  15346. }
  15347. parseClassMemberFromModifier(classBody, member) {
  15348. const key = this.parseIdentifier(true);
  15349. if (this.isClassMethod()) {
  15350. const method = member;
  15351. method.kind = "method";
  15352. method.computed = false;
  15353. method.key = key;
  15354. method.static = false;
  15355. this.pushClassMethod(classBody, method, false, false, false, false);
  15356. return true;
  15357. } else if (this.isClassProperty()) {
  15358. const prop = member;
  15359. prop.computed = false;
  15360. prop.key = key;
  15361. prop.static = false;
  15362. classBody.body.push(this.parseClassProperty(prop));
  15363. return true;
  15364. }
  15365. this.resetPreviousNodeTrailingComments(key);
  15366. return false;
  15367. }
  15368. parseClassMember(classBody, member, state) {
  15369. const isStatic = this.isContextual(106);
  15370. if (isStatic) {
  15371. if (this.parseClassMemberFromModifier(classBody, member)) {
  15372. return;
  15373. }
  15374. if (this.eat(5)) {
  15375. this.parseClassStaticBlock(classBody, member);
  15376. return;
  15377. }
  15378. }
  15379. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15380. }
  15381. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15382. const publicMethod = member;
  15383. const privateMethod = member;
  15384. const publicProp = member;
  15385. const privateProp = member;
  15386. const accessorProp = member;
  15387. const method = publicMethod;
  15388. const publicMember = publicMethod;
  15389. member.static = isStatic;
  15390. this.parsePropertyNamePrefixOperator(member);
  15391. if (this.eat(55)) {
  15392. method.kind = "method";
  15393. const isPrivateName = this.match(138);
  15394. this.parseClassElementName(method);
  15395. if (isPrivateName) {
  15396. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  15397. return;
  15398. }
  15399. if (this.isNonstaticConstructor(publicMethod)) {
  15400. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  15401. }
  15402. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  15403. return;
  15404. }
  15405. const isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
  15406. const isPrivate = this.match(138);
  15407. const key = this.parseClassElementName(member);
  15408. const maybeQuestionTokenStartLoc = this.state.startLoc;
  15409. this.parsePostMemberNameModifiers(publicMember);
  15410. if (this.isClassMethod()) {
  15411. method.kind = "method";
  15412. if (isPrivate) {
  15413. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15414. return;
  15415. }
  15416. const isConstructor = this.isNonstaticConstructor(publicMethod);
  15417. let allowsDirectSuper = false;
  15418. if (isConstructor) {
  15419. publicMethod.kind = "constructor";
  15420. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  15421. this.raise(Errors.DuplicateConstructor, key);
  15422. }
  15423. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  15424. this.raise(Errors.OverrideOnConstructor, key);
  15425. }
  15426. state.hadConstructor = true;
  15427. allowsDirectSuper = state.hadSuperClass;
  15428. }
  15429. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  15430. } else if (this.isClassProperty()) {
  15431. if (isPrivate) {
  15432. this.pushClassPrivateProperty(classBody, privateProp);
  15433. } else {
  15434. this.pushClassProperty(classBody, publicProp);
  15435. }
  15436. } else if (isContextual && key.name === "async" && !this.isLineTerminator()) {
  15437. this.resetPreviousNodeTrailingComments(key);
  15438. const isGenerator = this.eat(55);
  15439. if (publicMember.optional) {
  15440. this.unexpected(maybeQuestionTokenStartLoc);
  15441. }
  15442. method.kind = "method";
  15443. const isPrivate = this.match(138);
  15444. this.parseClassElementName(method);
  15445. this.parsePostMemberNameModifiers(publicMember);
  15446. if (isPrivate) {
  15447. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  15448. } else {
  15449. if (this.isNonstaticConstructor(publicMethod)) {
  15450. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  15451. }
  15452. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  15453. }
  15454. } else if (isContextual && (key.name === "get" || key.name === "set") && !(this.match(55) && this.isLineTerminator())) {
  15455. this.resetPreviousNodeTrailingComments(key);
  15456. method.kind = key.name;
  15457. const isPrivate = this.match(138);
  15458. this.parseClassElementName(publicMethod);
  15459. if (isPrivate) {
  15460. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15461. } else {
  15462. if (this.isNonstaticConstructor(publicMethod)) {
  15463. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  15464. }
  15465. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  15466. }
  15467. this.checkGetterSetterParams(publicMethod);
  15468. } else if (isContextual && key.name === "accessor" && !this.isLineTerminator()) {
  15469. this.expectPlugin("decoratorAutoAccessors");
  15470. this.resetPreviousNodeTrailingComments(key);
  15471. const isPrivate = this.match(138);
  15472. this.parseClassElementName(publicProp);
  15473. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  15474. } else if (this.isLineTerminator()) {
  15475. if (isPrivate) {
  15476. this.pushClassPrivateProperty(classBody, privateProp);
  15477. } else {
  15478. this.pushClassProperty(classBody, publicProp);
  15479. }
  15480. } else {
  15481. this.unexpected();
  15482. }
  15483. }
  15484. parseClassElementName(member) {
  15485. const {
  15486. type,
  15487. value
  15488. } = this.state;
  15489. if ((type === 132 || type === 133) && member.static && value === "prototype") {
  15490. this.raise(Errors.StaticPrototype, this.state.startLoc);
  15491. }
  15492. if (type === 138) {
  15493. if (value === "constructor") {
  15494. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  15495. }
  15496. const key = this.parsePrivateName();
  15497. member.key = key;
  15498. return key;
  15499. }
  15500. return this.parsePropertyName(member);
  15501. }
  15502. parseClassStaticBlock(classBody, member) {
  15503. var _member$decorators;
  15504. this.scope.enter(64 | 128 | 16);
  15505. const oldLabels = this.state.labels;
  15506. this.state.labels = [];
  15507. this.prodParam.enter(0);
  15508. const body = member.body = [];
  15509. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  15510. this.prodParam.exit();
  15511. this.scope.exit();
  15512. this.state.labels = oldLabels;
  15513. classBody.body.push(this.finishNode(member, "StaticBlock"));
  15514. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  15515. this.raise(Errors.DecoratorStaticBlock, member);
  15516. }
  15517. }
  15518. pushClassProperty(classBody, prop) {
  15519. if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
  15520. this.raise(Errors.ConstructorClassField, prop.key);
  15521. }
  15522. classBody.body.push(this.parseClassProperty(prop));
  15523. }
  15524. pushClassPrivateProperty(classBody, prop) {
  15525. const node = this.parseClassPrivateProperty(prop);
  15526. classBody.body.push(node);
  15527. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15528. }
  15529. pushClassAccessorProperty(classBody, prop, isPrivate) {
  15530. if (!isPrivate && !prop.computed) {
  15531. const key = prop.key;
  15532. if (key.name === "constructor" || key.value === "constructor") {
  15533. this.raise(Errors.ConstructorClassField, key);
  15534. }
  15535. }
  15536. const node = this.parseClassAccessorProperty(prop);
  15537. classBody.body.push(node);
  15538. if (isPrivate) {
  15539. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15540. }
  15541. }
  15542. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  15543. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  15544. }
  15545. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  15546. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  15547. classBody.body.push(node);
  15548. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  15549. this.declareClassPrivateMethodInScope(node, kind);
  15550. }
  15551. declareClassPrivateMethodInScope(node, kind) {
  15552. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  15553. }
  15554. parsePostMemberNameModifiers(methodOrProp) {}
  15555. parseClassPrivateProperty(node) {
  15556. this.parseInitializer(node);
  15557. this.semicolon();
  15558. return this.finishNode(node, "ClassPrivateProperty");
  15559. }
  15560. parseClassProperty(node) {
  15561. this.parseInitializer(node);
  15562. this.semicolon();
  15563. return this.finishNode(node, "ClassProperty");
  15564. }
  15565. parseClassAccessorProperty(node) {
  15566. this.parseInitializer(node);
  15567. this.semicolon();
  15568. return this.finishNode(node, "ClassAccessorProperty");
  15569. }
  15570. parseInitializer(node) {
  15571. this.scope.enter(64 | 16);
  15572. this.expressionScope.enter(newExpressionScope());
  15573. this.prodParam.enter(0);
  15574. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  15575. this.expressionScope.exit();
  15576. this.prodParam.exit();
  15577. this.scope.exit();
  15578. }
  15579. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  15580. if (tokenIsIdentifier(this.state.type)) {
  15581. node.id = this.parseIdentifier();
  15582. if (isStatement) {
  15583. this.declareNameFromIdentifier(node.id, bindingType);
  15584. }
  15585. } else {
  15586. if (optionalId || !isStatement) {
  15587. node.id = null;
  15588. } else {
  15589. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  15590. }
  15591. }
  15592. }
  15593. parseClassSuper(node) {
  15594. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  15595. }
  15596. parseExport(node, decorators) {
  15597. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  15598. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  15599. const parseAfterDefault = !hasDefault || this.eat(12);
  15600. const hasStar = parseAfterDefault && this.eatExportStar(node);
  15601. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  15602. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  15603. const isFromRequired = hasDefault || hasStar;
  15604. if (hasStar && !hasNamespace) {
  15605. if (hasDefault) this.unexpected();
  15606. if (decorators) {
  15607. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15608. }
  15609. this.parseExportFrom(node, true);
  15610. return this.finishNode(node, "ExportAllDeclaration");
  15611. }
  15612. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  15613. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  15614. this.unexpected(null, 5);
  15615. }
  15616. if (hasNamespace && parseAfterNamespace) {
  15617. this.unexpected(null, 98);
  15618. }
  15619. let hasDeclaration;
  15620. if (isFromRequired || hasSpecifiers) {
  15621. hasDeclaration = false;
  15622. if (decorators) {
  15623. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15624. }
  15625. this.parseExportFrom(node, isFromRequired);
  15626. } else {
  15627. hasDeclaration = this.maybeParseExportDeclaration(node);
  15628. }
  15629. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  15630. var _node2$declaration;
  15631. const node2 = node;
  15632. this.checkExport(node2, true, false, !!node2.source);
  15633. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  15634. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  15635. } else if (decorators) {
  15636. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15637. }
  15638. return this.finishNode(node2, "ExportNamedDeclaration");
  15639. }
  15640. if (this.eat(65)) {
  15641. const node2 = node;
  15642. const decl = this.parseExportDefaultExpression();
  15643. node2.declaration = decl;
  15644. if (decl.type === "ClassDeclaration") {
  15645. this.maybeTakeDecorators(decorators, decl, node2);
  15646. } else if (decorators) {
  15647. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15648. }
  15649. this.checkExport(node2, true, true);
  15650. return this.finishNode(node2, "ExportDefaultDeclaration");
  15651. }
  15652. this.unexpected(null, 5);
  15653. }
  15654. eatExportStar(node) {
  15655. return this.eat(55);
  15656. }
  15657. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  15658. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  15659. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  15660. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  15661. const specifier = this.startNodeAtNode(id);
  15662. specifier.exported = id;
  15663. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  15664. return true;
  15665. }
  15666. return false;
  15667. }
  15668. maybeParseExportNamespaceSpecifier(node) {
  15669. if (this.isContextual(93)) {
  15670. if (!node.specifiers) node.specifiers = [];
  15671. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  15672. this.next();
  15673. specifier.exported = this.parseModuleExportName();
  15674. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  15675. return true;
  15676. }
  15677. return false;
  15678. }
  15679. maybeParseExportNamedSpecifiers(node) {
  15680. if (this.match(5)) {
  15681. if (!node.specifiers) node.specifiers = [];
  15682. const isTypeExport = node.exportKind === "type";
  15683. node.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  15684. node.source = null;
  15685. node.declaration = null;
  15686. if (this.hasPlugin("importAssertions")) {
  15687. node.assertions = [];
  15688. }
  15689. return true;
  15690. }
  15691. return false;
  15692. }
  15693. maybeParseExportDeclaration(node) {
  15694. if (this.shouldParseExportDeclaration()) {
  15695. node.specifiers = [];
  15696. node.source = null;
  15697. if (this.hasPlugin("importAssertions")) {
  15698. node.assertions = [];
  15699. }
  15700. node.declaration = this.parseExportDeclaration(node);
  15701. return true;
  15702. }
  15703. return false;
  15704. }
  15705. isAsyncFunction() {
  15706. if (!this.isContextual(95)) return false;
  15707. const next = this.nextTokenInLineStart();
  15708. return this.isUnparsedContextual(next, "function");
  15709. }
  15710. parseExportDefaultExpression() {
  15711. const expr = this.startNode();
  15712. if (this.match(68)) {
  15713. this.next();
  15714. return this.parseFunction(expr, 1 | 4);
  15715. } else if (this.isAsyncFunction()) {
  15716. this.next();
  15717. this.next();
  15718. return this.parseFunction(expr, 1 | 4 | 8);
  15719. }
  15720. if (this.match(80)) {
  15721. return this.parseClass(expr, true, true);
  15722. }
  15723. if (this.match(26)) {
  15724. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15725. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15726. }
  15727. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  15728. }
  15729. if (this.match(75) || this.match(74) || this.isLet()) {
  15730. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  15731. }
  15732. const res = this.parseMaybeAssignAllowIn();
  15733. this.semicolon();
  15734. return res;
  15735. }
  15736. parseExportDeclaration(node) {
  15737. if (this.match(80)) {
  15738. const node = this.parseClass(this.startNode(), true, false);
  15739. return node;
  15740. }
  15741. return this.parseStatementListItem();
  15742. }
  15743. isExportDefaultSpecifier() {
  15744. const {
  15745. type
  15746. } = this.state;
  15747. if (tokenIsIdentifier(type)) {
  15748. if (type === 95 && !this.state.containsEsc || type === 100) {
  15749. return false;
  15750. }
  15751. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  15752. const {
  15753. type: nextType
  15754. } = this.lookahead();
  15755. if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
  15756. this.expectOnePlugin(["flow", "typescript"]);
  15757. return false;
  15758. }
  15759. }
  15760. } else if (!this.match(65)) {
  15761. return false;
  15762. }
  15763. const next = this.nextTokenStart();
  15764. const hasFrom = this.isUnparsedContextual(next, "from");
  15765. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  15766. return true;
  15767. }
  15768. if (this.match(65) && hasFrom) {
  15769. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  15770. return nextAfterFrom === 34 || nextAfterFrom === 39;
  15771. }
  15772. return false;
  15773. }
  15774. parseExportFrom(node, expect) {
  15775. if (this.eatContextual(98)) {
  15776. node.source = this.parseImportSource();
  15777. this.checkExport(node);
  15778. this.maybeParseImportAttributes(node);
  15779. this.checkJSONModuleImport(node);
  15780. } else if (expect) {
  15781. this.unexpected();
  15782. }
  15783. this.semicolon();
  15784. }
  15785. shouldParseExportDeclaration() {
  15786. const {
  15787. type
  15788. } = this.state;
  15789. if (type === 26) {
  15790. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15791. if (this.hasPlugin("decorators")) {
  15792. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15793. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15794. }
  15795. return true;
  15796. }
  15797. }
  15798. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  15799. }
  15800. checkExport(node, checkNames, isDefault, isFrom) {
  15801. if (checkNames) {
  15802. var _node$specifiers;
  15803. if (isDefault) {
  15804. this.checkDuplicateExports(node, "default");
  15805. if (this.hasPlugin("exportDefaultFrom")) {
  15806. var _declaration$extra;
  15807. const declaration = node.declaration;
  15808. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  15809. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  15810. }
  15811. }
  15812. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  15813. for (const specifier of node.specifiers) {
  15814. const {
  15815. exported
  15816. } = specifier;
  15817. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  15818. this.checkDuplicateExports(specifier, exportName);
  15819. if (!isFrom && specifier.local) {
  15820. const {
  15821. local
  15822. } = specifier;
  15823. if (local.type !== "Identifier") {
  15824. this.raise(Errors.ExportBindingIsString, specifier, {
  15825. localName: local.value,
  15826. exportName
  15827. });
  15828. } else {
  15829. this.checkReservedWord(local.name, local.loc.start, true, false);
  15830. this.scope.checkLocalExport(local);
  15831. }
  15832. }
  15833. }
  15834. } else if (node.declaration) {
  15835. if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
  15836. const id = node.declaration.id;
  15837. if (!id) throw new Error("Assertion failure");
  15838. this.checkDuplicateExports(node, id.name);
  15839. } else if (node.declaration.type === "VariableDeclaration") {
  15840. for (const declaration of node.declaration.declarations) {
  15841. this.checkDeclaration(declaration.id);
  15842. }
  15843. }
  15844. }
  15845. }
  15846. }
  15847. checkDeclaration(node) {
  15848. if (node.type === "Identifier") {
  15849. this.checkDuplicateExports(node, node.name);
  15850. } else if (node.type === "ObjectPattern") {
  15851. for (const prop of node.properties) {
  15852. this.checkDeclaration(prop);
  15853. }
  15854. } else if (node.type === "ArrayPattern") {
  15855. for (const elem of node.elements) {
  15856. if (elem) {
  15857. this.checkDeclaration(elem);
  15858. }
  15859. }
  15860. } else if (node.type === "ObjectProperty") {
  15861. this.checkDeclaration(node.value);
  15862. } else if (node.type === "RestElement") {
  15863. this.checkDeclaration(node.argument);
  15864. } else if (node.type === "AssignmentPattern") {
  15865. this.checkDeclaration(node.left);
  15866. }
  15867. }
  15868. checkDuplicateExports(node, exportName) {
  15869. if (this.exportedIdentifiers.has(exportName)) {
  15870. if (exportName === "default") {
  15871. this.raise(Errors.DuplicateDefaultExport, node);
  15872. } else {
  15873. this.raise(Errors.DuplicateExport, node, {
  15874. exportName
  15875. });
  15876. }
  15877. }
  15878. this.exportedIdentifiers.add(exportName);
  15879. }
  15880. parseExportSpecifiers(isInTypeExport) {
  15881. const nodes = [];
  15882. let first = true;
  15883. this.expect(5);
  15884. while (!this.eat(8)) {
  15885. if (first) {
  15886. first = false;
  15887. } else {
  15888. this.expect(12);
  15889. if (this.eat(8)) break;
  15890. }
  15891. const isMaybeTypeOnly = this.isContextual(130);
  15892. const isString = this.match(133);
  15893. const node = this.startNode();
  15894. node.local = this.parseModuleExportName();
  15895. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  15896. }
  15897. return nodes;
  15898. }
  15899. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  15900. if (this.eatContextual(93)) {
  15901. node.exported = this.parseModuleExportName();
  15902. } else if (isString) {
  15903. node.exported = cloneStringLiteral(node.local);
  15904. } else if (!node.exported) {
  15905. node.exported = cloneIdentifier(node.local);
  15906. }
  15907. return this.finishNode(node, "ExportSpecifier");
  15908. }
  15909. parseModuleExportName() {
  15910. if (this.match(133)) {
  15911. const result = this.parseStringLiteral(this.state.value);
  15912. const surrogate = result.value.match(loneSurrogate);
  15913. if (surrogate) {
  15914. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  15915. surrogateCharCode: surrogate[0].charCodeAt(0)
  15916. });
  15917. }
  15918. return result;
  15919. }
  15920. return this.parseIdentifier(true);
  15921. }
  15922. isJSONModuleImport(node) {
  15923. if (node.assertions != null) {
  15924. return node.assertions.some(({
  15925. key,
  15926. value
  15927. }) => {
  15928. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  15929. });
  15930. }
  15931. return false;
  15932. }
  15933. checkImportReflection(node) {
  15934. const {
  15935. specifiers
  15936. } = node;
  15937. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  15938. if (node.phase === "source") {
  15939. if (singleBindingType !== "ImportDefaultSpecifier") {
  15940. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  15941. }
  15942. } else if (node.phase === "defer") {
  15943. if (singleBindingType !== "ImportNamespaceSpecifier") {
  15944. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  15945. }
  15946. } else if (node.module) {
  15947. var _node$assertions;
  15948. if (singleBindingType !== "ImportDefaultSpecifier") {
  15949. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  15950. }
  15951. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  15952. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  15953. }
  15954. }
  15955. }
  15956. checkJSONModuleImport(node) {
  15957. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  15958. const {
  15959. specifiers
  15960. } = node;
  15961. if (specifiers != null) {
  15962. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  15963. let imported;
  15964. if (specifier.type === "ExportSpecifier") {
  15965. imported = specifier.local;
  15966. } else if (specifier.type === "ImportSpecifier") {
  15967. imported = specifier.imported;
  15968. }
  15969. if (imported !== undefined) {
  15970. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  15971. }
  15972. });
  15973. if (nonDefaultNamedSpecifier !== undefined) {
  15974. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  15975. }
  15976. }
  15977. }
  15978. }
  15979. isPotentialImportPhase(isExport) {
  15980. if (isExport) return false;
  15981. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  15982. }
  15983. applyImportPhase(node, isExport, phase, loc) {
  15984. if (isExport) {
  15985. return;
  15986. }
  15987. if (phase === "module") {
  15988. this.expectPlugin("importReflection", loc);
  15989. node.module = true;
  15990. } else if (this.hasPlugin("importReflection")) {
  15991. node.module = false;
  15992. }
  15993. if (phase === "source") {
  15994. this.expectPlugin("sourcePhaseImports", loc);
  15995. node.phase = "source";
  15996. } else if (phase === "defer") {
  15997. this.expectPlugin("deferredImportEvaluation", loc);
  15998. node.phase = "defer";
  15999. } else if (this.hasPlugin("sourcePhaseImports")) {
  16000. node.phase = null;
  16001. }
  16002. }
  16003. parseMaybeImportPhase(node, isExport) {
  16004. if (!this.isPotentialImportPhase(isExport)) {
  16005. this.applyImportPhase(node, isExport, null);
  16006. return null;
  16007. }
  16008. const phaseIdentifier = this.parseIdentifier(true);
  16009. const {
  16010. type
  16011. } = this.state;
  16012. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16013. if (isImportPhase) {
  16014. this.resetPreviousIdentifierLeadingComments(phaseIdentifier);
  16015. this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start);
  16016. return null;
  16017. } else {
  16018. this.applyImportPhase(node, isExport, null);
  16019. return phaseIdentifier;
  16020. }
  16021. }
  16022. isPrecedingIdImportPhase(phase) {
  16023. const {
  16024. type
  16025. } = this.state;
  16026. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16027. }
  16028. parseImport(node) {
  16029. if (this.match(133)) {
  16030. return this.parseImportSourceAndAttributes(node);
  16031. }
  16032. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16033. }
  16034. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16035. node.specifiers = [];
  16036. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16037. const parseNext = !hasDefault || this.eat(12);
  16038. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16039. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16040. this.expectContextual(98);
  16041. return this.parseImportSourceAndAttributes(node);
  16042. }
  16043. parseImportSourceAndAttributes(node) {
  16044. var _node$specifiers2;
  16045. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16046. node.source = this.parseImportSource();
  16047. this.maybeParseImportAttributes(node);
  16048. this.checkImportReflection(node);
  16049. this.checkJSONModuleImport(node);
  16050. this.semicolon();
  16051. return this.finishNode(node, "ImportDeclaration");
  16052. }
  16053. parseImportSource() {
  16054. if (!this.match(133)) this.unexpected();
  16055. return this.parseExprAtom();
  16056. }
  16057. parseImportSpecifierLocal(node, specifier, type) {
  16058. specifier.local = this.parseIdentifier();
  16059. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16060. }
  16061. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16062. this.checkLVal(specifier.local, {
  16063. in: {
  16064. type
  16065. },
  16066. binding: bindingType
  16067. });
  16068. return this.finishNode(specifier, type);
  16069. }
  16070. parseImportAttributes() {
  16071. this.expect(5);
  16072. const attrs = [];
  16073. const attrNames = new Set();
  16074. do {
  16075. if (this.match(8)) {
  16076. break;
  16077. }
  16078. const node = this.startNode();
  16079. const keyName = this.state.value;
  16080. if (attrNames.has(keyName)) {
  16081. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16082. key: keyName
  16083. });
  16084. }
  16085. attrNames.add(keyName);
  16086. if (this.match(133)) {
  16087. node.key = this.parseStringLiteral(keyName);
  16088. } else {
  16089. node.key = this.parseIdentifier(true);
  16090. }
  16091. this.expect(14);
  16092. if (!this.match(133)) {
  16093. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16094. }
  16095. node.value = this.parseStringLiteral(this.state.value);
  16096. attrs.push(this.finishNode(node, "ImportAttribute"));
  16097. } while (this.eat(12));
  16098. this.expect(8);
  16099. return attrs;
  16100. }
  16101. parseModuleAttributes() {
  16102. const attrs = [];
  16103. const attributes = new Set();
  16104. do {
  16105. const node = this.startNode();
  16106. node.key = this.parseIdentifier(true);
  16107. if (node.key.name !== "type") {
  16108. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16109. }
  16110. if (attributes.has(node.key.name)) {
  16111. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16112. key: node.key.name
  16113. });
  16114. }
  16115. attributes.add(node.key.name);
  16116. this.expect(14);
  16117. if (!this.match(133)) {
  16118. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16119. }
  16120. node.value = this.parseStringLiteral(this.state.value);
  16121. attrs.push(this.finishNode(node, "ImportAttribute"));
  16122. } while (this.eat(12));
  16123. return attrs;
  16124. }
  16125. maybeParseImportAttributes(node) {
  16126. let attributes;
  16127. let useWith = false;
  16128. if (this.match(76)) {
  16129. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16130. return;
  16131. }
  16132. this.next();
  16133. {
  16134. if (this.hasPlugin("moduleAttributes")) {
  16135. attributes = this.parseModuleAttributes();
  16136. } else {
  16137. this.expectImportAttributesPlugin();
  16138. attributes = this.parseImportAttributes();
  16139. }
  16140. }
  16141. useWith = true;
  16142. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16143. if (this.hasPlugin("importAttributes")) {
  16144. if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) {
  16145. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16146. }
  16147. this.addExtra(node, "deprecatedAssertSyntax", true);
  16148. } else {
  16149. this.expectOnePlugin(["importAttributes", "importAssertions"]);
  16150. }
  16151. this.next();
  16152. attributes = this.parseImportAttributes();
  16153. } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  16154. attributes = [];
  16155. } else {
  16156. if (this.hasPlugin("moduleAttributes")) {
  16157. attributes = [];
  16158. } else return;
  16159. }
  16160. if (!useWith && this.hasPlugin("importAssertions")) {
  16161. node.assertions = attributes;
  16162. } else {
  16163. node.attributes = attributes;
  16164. }
  16165. }
  16166. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16167. if (maybeDefaultIdentifier) {
  16168. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16169. specifier.local = maybeDefaultIdentifier;
  16170. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16171. return true;
  16172. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16173. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16174. return true;
  16175. }
  16176. return false;
  16177. }
  16178. maybeParseStarImportSpecifier(node) {
  16179. if (this.match(55)) {
  16180. const specifier = this.startNode();
  16181. this.next();
  16182. this.expectContextual(93);
  16183. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16184. return true;
  16185. }
  16186. return false;
  16187. }
  16188. parseNamedImportSpecifiers(node) {
  16189. let first = true;
  16190. this.expect(5);
  16191. while (!this.eat(8)) {
  16192. if (first) {
  16193. first = false;
  16194. } else {
  16195. if (this.eat(14)) {
  16196. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16197. }
  16198. this.expect(12);
  16199. if (this.eat(8)) break;
  16200. }
  16201. const specifier = this.startNode();
  16202. const importedIsString = this.match(133);
  16203. const isMaybeTypeOnly = this.isContextual(130);
  16204. specifier.imported = this.parseModuleExportName();
  16205. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16206. node.specifiers.push(importSpecifier);
  16207. }
  16208. }
  16209. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16210. if (this.eatContextual(93)) {
  16211. specifier.local = this.parseIdentifier();
  16212. } else {
  16213. const {
  16214. imported
  16215. } = specifier;
  16216. if (importedIsString) {
  16217. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16218. importName: imported.value
  16219. });
  16220. }
  16221. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16222. if (!specifier.local) {
  16223. specifier.local = cloneIdentifier(imported);
  16224. }
  16225. }
  16226. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16227. }
  16228. isThisParam(param) {
  16229. return param.type === "Identifier" && param.name === "this";
  16230. }
  16231. }
  16232. let Parser$2 = class Parser extends StatementParser {
  16233. constructor(options, input) {
  16234. options = getOptions(options);
  16235. super(options, input);
  16236. this.options = options;
  16237. this.initializeScopes();
  16238. this.plugins = pluginsMap(this.options.plugins);
  16239. this.filename = options.sourceFilename;
  16240. }
  16241. getScopeHandler() {
  16242. return ScopeHandler;
  16243. }
  16244. parse() {
  16245. this.enterInitialScopes();
  16246. const file = this.startNode();
  16247. const program = this.startNode();
  16248. this.nextToken();
  16249. file.errors = null;
  16250. this.parseTopLevel(file, program);
  16251. file.errors = this.state.errors;
  16252. file.comments.length = this.state.commentsLen;
  16253. return file;
  16254. }
  16255. };
  16256. function pluginsMap(plugins) {
  16257. const pluginMap = new Map();
  16258. for (const plugin of plugins) {
  16259. const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
  16260. if (!pluginMap.has(name)) pluginMap.set(name, options || {});
  16261. }
  16262. return pluginMap;
  16263. }
  16264. function parse$9(input, options) {
  16265. var _options;
  16266. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16267. options = Object.assign({}, options);
  16268. try {
  16269. options.sourceType = "module";
  16270. const parser = getParser(options, input);
  16271. const ast = parser.parse();
  16272. if (parser.sawUnambiguousESM) {
  16273. return ast;
  16274. }
  16275. if (parser.ambiguousScriptDifferentAst) {
  16276. try {
  16277. options.sourceType = "script";
  16278. return getParser(options, input).parse();
  16279. } catch (_unused) {}
  16280. } else {
  16281. ast.program.sourceType = "script";
  16282. }
  16283. return ast;
  16284. } catch (moduleError) {
  16285. try {
  16286. options.sourceType = "script";
  16287. return getParser(options, input).parse();
  16288. } catch (_unused2) {}
  16289. throw moduleError;
  16290. }
  16291. } else {
  16292. return getParser(options, input).parse();
  16293. }
  16294. }
  16295. function parseExpression(input, options) {
  16296. const parser = getParser(options, input);
  16297. if (parser.options.strictMode) {
  16298. parser.state.strict = true;
  16299. }
  16300. return parser.getExpression();
  16301. }
  16302. function generateExportedTokenTypes(internalTokenTypes) {
  16303. const tokenTypes = {};
  16304. for (const typeName of Object.keys(internalTokenTypes)) {
  16305. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16306. }
  16307. return tokenTypes;
  16308. }
  16309. const tokTypes = generateExportedTokenTypes(tt);
  16310. function getParser(options, input) {
  16311. let cls = Parser$2;
  16312. if (options != null && options.plugins) {
  16313. validatePlugins(options.plugins);
  16314. cls = getParserClass(options.plugins);
  16315. }
  16316. return new cls(options, input);
  16317. }
  16318. const parserClassCache = {};
  16319. function getParserClass(pluginsFromOptions) {
  16320. const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
  16321. const key = pluginList.join("/");
  16322. let cls = parserClassCache[key];
  16323. if (!cls) {
  16324. cls = Parser$2;
  16325. for (const plugin of pluginList) {
  16326. cls = mixinPlugins[plugin](cls);
  16327. }
  16328. parserClassCache[key] = cls;
  16329. }
  16330. return cls;
  16331. }
  16332. var parse_1$1 = lib.parse = parse$9;
  16333. var parseExpression_1 = lib.parseExpression = parseExpression;
  16334. lib.tokTypes = tokTypes;
  16335. // @ts-check
  16336. /** @typedef { import('estree').BaseNode} BaseNode */
  16337. /** @typedef {{
  16338. skip: () => void;
  16339. remove: () => void;
  16340. replace: (node: BaseNode) => void;
  16341. }} WalkerContext */
  16342. class WalkerBase {
  16343. constructor() {
  16344. /** @type {boolean} */
  16345. this.should_skip = false;
  16346. /** @type {boolean} */
  16347. this.should_remove = false;
  16348. /** @type {BaseNode | null} */
  16349. this.replacement = null;
  16350. /** @type {WalkerContext} */
  16351. this.context = {
  16352. skip: () => (this.should_skip = true),
  16353. remove: () => (this.should_remove = true),
  16354. replace: (node) => (this.replacement = node)
  16355. };
  16356. }
  16357. /**
  16358. *
  16359. * @param {any} parent
  16360. * @param {string} prop
  16361. * @param {number} index
  16362. * @param {BaseNode} node
  16363. */
  16364. replace(parent, prop, index, node) {
  16365. if (parent) {
  16366. if (index !== null) {
  16367. parent[prop][index] = node;
  16368. } else {
  16369. parent[prop] = node;
  16370. }
  16371. }
  16372. }
  16373. /**
  16374. *
  16375. * @param {any} parent
  16376. * @param {string} prop
  16377. * @param {number} index
  16378. */
  16379. remove(parent, prop, index) {
  16380. if (parent) {
  16381. if (index !== null) {
  16382. parent[prop].splice(index, 1);
  16383. } else {
  16384. delete parent[prop];
  16385. }
  16386. }
  16387. }
  16388. }
  16389. // @ts-check
  16390. /** @typedef { import('estree').BaseNode} BaseNode */
  16391. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  16392. /** @typedef {(
  16393. * this: WalkerContext,
  16394. * node: BaseNode,
  16395. * parent: BaseNode,
  16396. * key: string,
  16397. * index: number
  16398. * ) => void} SyncHandler */
  16399. class SyncWalker extends WalkerBase {
  16400. /**
  16401. *
  16402. * @param {SyncHandler} enter
  16403. * @param {SyncHandler} leave
  16404. */
  16405. constructor(enter, leave) {
  16406. super();
  16407. /** @type {SyncHandler} */
  16408. this.enter = enter;
  16409. /** @type {SyncHandler} */
  16410. this.leave = leave;
  16411. }
  16412. /**
  16413. *
  16414. * @param {BaseNode} node
  16415. * @param {BaseNode} parent
  16416. * @param {string} [prop]
  16417. * @param {number} [index]
  16418. * @returns {BaseNode}
  16419. */
  16420. visit(node, parent, prop, index) {
  16421. if (node) {
  16422. if (this.enter) {
  16423. const _should_skip = this.should_skip;
  16424. const _should_remove = this.should_remove;
  16425. const _replacement = this.replacement;
  16426. this.should_skip = false;
  16427. this.should_remove = false;
  16428. this.replacement = null;
  16429. this.enter.call(this.context, node, parent, prop, index);
  16430. if (this.replacement) {
  16431. node = this.replacement;
  16432. this.replace(parent, prop, index, node);
  16433. }
  16434. if (this.should_remove) {
  16435. this.remove(parent, prop, index);
  16436. }
  16437. const skipped = this.should_skip;
  16438. const removed = this.should_remove;
  16439. this.should_skip = _should_skip;
  16440. this.should_remove = _should_remove;
  16441. this.replacement = _replacement;
  16442. if (skipped) return node;
  16443. if (removed) return null;
  16444. }
  16445. for (const key in node) {
  16446. const value = node[key];
  16447. if (typeof value !== "object") {
  16448. continue;
  16449. } else if (Array.isArray(value)) {
  16450. for (let i = 0; i < value.length; i += 1) {
  16451. if (value[i] !== null && typeof value[i].type === 'string') {
  16452. if (!this.visit(value[i], node, key, i)) {
  16453. // removed
  16454. i--;
  16455. }
  16456. }
  16457. }
  16458. } else if (value !== null && typeof value.type === "string") {
  16459. this.visit(value, node, key, null);
  16460. }
  16461. }
  16462. if (this.leave) {
  16463. const _replacement = this.replacement;
  16464. const _should_remove = this.should_remove;
  16465. this.replacement = null;
  16466. this.should_remove = false;
  16467. this.leave.call(this.context, node, parent, prop, index);
  16468. if (this.replacement) {
  16469. node = this.replacement;
  16470. this.replace(parent, prop, index, node);
  16471. }
  16472. if (this.should_remove) {
  16473. this.remove(parent, prop, index);
  16474. }
  16475. const removed = this.should_remove;
  16476. this.replacement = _replacement;
  16477. this.should_remove = _should_remove;
  16478. if (removed) return null;
  16479. }
  16480. }
  16481. return node;
  16482. }
  16483. }
  16484. // @ts-check
  16485. /** @typedef { import('estree').BaseNode} BaseNode */
  16486. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  16487. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  16488. /**
  16489. *
  16490. * @param {BaseNode} ast
  16491. * @param {{
  16492. * enter?: SyncHandler
  16493. * leave?: SyncHandler
  16494. * }} walker
  16495. * @returns {BaseNode}
  16496. */
  16497. function walk$2(ast, { enter, leave }) {
  16498. const instance = new SyncWalker(enter, leave);
  16499. return instance.visit(ast, null);
  16500. }
  16501. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  16502. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  16503. walk$2(root, {
  16504. enter(node, parent) {
  16505. parent && parentStack.push(parent);
  16506. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  16507. return this.skip();
  16508. }
  16509. if (node.type === "Identifier") {
  16510. const isLocal = !!knownIds[node.name];
  16511. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  16512. if (includeAll || isRefed && !isLocal) {
  16513. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  16514. }
  16515. } else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  16516. node.inPattern = true;
  16517. } else if (isFunctionType(node)) {
  16518. if (node.scopeIds) {
  16519. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16520. } else {
  16521. walkFunctionParams(
  16522. node,
  16523. (id) => markScopeIdentifier(node, id, knownIds)
  16524. );
  16525. }
  16526. } else if (node.type === "BlockStatement") {
  16527. if (node.scopeIds) {
  16528. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16529. } else {
  16530. walkBlockDeclarations(
  16531. node,
  16532. (id) => markScopeIdentifier(node, id, knownIds)
  16533. );
  16534. }
  16535. }
  16536. },
  16537. leave(node, parent) {
  16538. parent && parentStack.pop();
  16539. if (node !== rootExp && node.scopeIds) {
  16540. for (const id of node.scopeIds) {
  16541. knownIds[id]--;
  16542. if (knownIds[id] === 0) {
  16543. delete knownIds[id];
  16544. }
  16545. }
  16546. }
  16547. }
  16548. });
  16549. }
  16550. function isReferencedIdentifier(id, parent, parentStack) {
  16551. if (!parent) {
  16552. return true;
  16553. }
  16554. if (id.name === "arguments") {
  16555. return false;
  16556. }
  16557. if (isReferenced(id, parent)) {
  16558. return true;
  16559. }
  16560. switch (parent.type) {
  16561. case "AssignmentExpression":
  16562. case "AssignmentPattern":
  16563. return true;
  16564. case "ObjectPattern":
  16565. case "ArrayPattern":
  16566. return isInDestructureAssignment(parent, parentStack);
  16567. }
  16568. return false;
  16569. }
  16570. function isInDestructureAssignment(parent, parentStack) {
  16571. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  16572. let i = parentStack.length;
  16573. while (i--) {
  16574. const p = parentStack[i];
  16575. if (p.type === "AssignmentExpression") {
  16576. return true;
  16577. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  16578. break;
  16579. }
  16580. }
  16581. }
  16582. return false;
  16583. }
  16584. function isInNewExpression(parentStack) {
  16585. let i = parentStack.length;
  16586. while (i--) {
  16587. const p = parentStack[i];
  16588. if (p.type === "NewExpression") {
  16589. return true;
  16590. } else if (p.type !== "MemberExpression") {
  16591. break;
  16592. }
  16593. }
  16594. return false;
  16595. }
  16596. function walkFunctionParams(node, onIdent) {
  16597. for (const p of node.params) {
  16598. for (const id of extractIdentifiers$1(p)) {
  16599. onIdent(id);
  16600. }
  16601. }
  16602. }
  16603. function walkBlockDeclarations(block, onIdent) {
  16604. for (const stmt of block.body) {
  16605. if (stmt.type === "VariableDeclaration") {
  16606. if (stmt.declare)
  16607. continue;
  16608. for (const decl of stmt.declarations) {
  16609. for (const id of extractIdentifiers$1(decl.id)) {
  16610. onIdent(id);
  16611. }
  16612. }
  16613. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  16614. if (stmt.declare || !stmt.id)
  16615. continue;
  16616. onIdent(stmt.id);
  16617. } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
  16618. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  16619. if (variable && variable.type === "VariableDeclaration") {
  16620. for (const decl of variable.declarations) {
  16621. for (const id of extractIdentifiers$1(decl.id)) {
  16622. onIdent(id);
  16623. }
  16624. }
  16625. }
  16626. }
  16627. }
  16628. }
  16629. function extractIdentifiers$1(param, nodes = []) {
  16630. switch (param.type) {
  16631. case "Identifier":
  16632. nodes.push(param);
  16633. break;
  16634. case "MemberExpression":
  16635. let object = param;
  16636. while (object.type === "MemberExpression") {
  16637. object = object.object;
  16638. }
  16639. nodes.push(object);
  16640. break;
  16641. case "ObjectPattern":
  16642. for (const prop of param.properties) {
  16643. if (prop.type === "RestElement") {
  16644. extractIdentifiers$1(prop.argument, nodes);
  16645. } else {
  16646. extractIdentifiers$1(prop.value, nodes);
  16647. }
  16648. }
  16649. break;
  16650. case "ArrayPattern":
  16651. param.elements.forEach((element) => {
  16652. if (element)
  16653. extractIdentifiers$1(element, nodes);
  16654. });
  16655. break;
  16656. case "RestElement":
  16657. extractIdentifiers$1(param.argument, nodes);
  16658. break;
  16659. case "AssignmentPattern":
  16660. extractIdentifiers$1(param.left, nodes);
  16661. break;
  16662. }
  16663. return nodes;
  16664. }
  16665. function markKnownIds(name, knownIds) {
  16666. if (name in knownIds) {
  16667. knownIds[name]++;
  16668. } else {
  16669. knownIds[name] = 1;
  16670. }
  16671. }
  16672. function markScopeIdentifier(node, child, knownIds) {
  16673. const { name } = child;
  16674. if (node.scopeIds && node.scopeIds.has(name)) {
  16675. return;
  16676. }
  16677. markKnownIds(name, knownIds);
  16678. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  16679. }
  16680. const isFunctionType = (node) => {
  16681. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  16682. };
  16683. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  16684. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  16685. function isReferenced(node, parent, grandparent) {
  16686. switch (parent.type) {
  16687. case "MemberExpression":
  16688. case "OptionalMemberExpression":
  16689. if (parent.property === node) {
  16690. return !!parent.computed;
  16691. }
  16692. return parent.object === node;
  16693. case "JSXMemberExpression":
  16694. return parent.object === node;
  16695. case "VariableDeclarator":
  16696. return parent.init === node;
  16697. case "ArrowFunctionExpression":
  16698. return parent.body === node;
  16699. case "PrivateName":
  16700. return false;
  16701. case "ClassMethod":
  16702. case "ClassPrivateMethod":
  16703. case "ObjectMethod":
  16704. if (parent.key === node) {
  16705. return !!parent.computed;
  16706. }
  16707. return false;
  16708. case "ObjectProperty":
  16709. if (parent.key === node) {
  16710. return !!parent.computed;
  16711. }
  16712. return !grandparent || grandparent.type !== "ObjectPattern";
  16713. case "ClassProperty":
  16714. if (parent.key === node) {
  16715. return !!parent.computed;
  16716. }
  16717. return true;
  16718. case "ClassPrivateProperty":
  16719. return parent.key !== node;
  16720. case "ClassDeclaration":
  16721. case "ClassExpression":
  16722. return parent.superClass === node;
  16723. case "AssignmentExpression":
  16724. return parent.right === node;
  16725. case "AssignmentPattern":
  16726. return parent.right === node;
  16727. case "LabeledStatement":
  16728. return false;
  16729. case "CatchClause":
  16730. return false;
  16731. case "RestElement":
  16732. return false;
  16733. case "BreakStatement":
  16734. case "ContinueStatement":
  16735. return false;
  16736. case "FunctionDeclaration":
  16737. case "FunctionExpression":
  16738. return false;
  16739. case "ExportNamespaceSpecifier":
  16740. case "ExportDefaultSpecifier":
  16741. return false;
  16742. case "ExportSpecifier":
  16743. if (grandparent == null ? void 0 : grandparent.source) {
  16744. return false;
  16745. }
  16746. return parent.local === node;
  16747. case "ImportDefaultSpecifier":
  16748. case "ImportNamespaceSpecifier":
  16749. case "ImportSpecifier":
  16750. return false;
  16751. case "ImportAttribute":
  16752. return false;
  16753. case "JSXAttribute":
  16754. return false;
  16755. case "ObjectPattern":
  16756. case "ArrayPattern":
  16757. return false;
  16758. case "MetaProperty":
  16759. return false;
  16760. case "ObjectTypeProperty":
  16761. return parent.key !== node;
  16762. case "TSEnumMember":
  16763. return parent.id !== node;
  16764. case "TSPropertySignature":
  16765. if (parent.key === node) {
  16766. return !!parent.computed;
  16767. }
  16768. return true;
  16769. }
  16770. return true;
  16771. }
  16772. const TS_NODE_TYPES = [
  16773. "TSAsExpression",
  16774. // foo as number
  16775. "TSTypeAssertion",
  16776. // (<number>foo)
  16777. "TSNonNullExpression",
  16778. // foo!
  16779. "TSInstantiationExpression",
  16780. // foo<string>
  16781. "TSSatisfiesExpression"
  16782. // foo satisfies T
  16783. ];
  16784. function unwrapTSNode(node) {
  16785. if (TS_NODE_TYPES.includes(node.type)) {
  16786. return unwrapTSNode(node.expression);
  16787. } else {
  16788. return node;
  16789. }
  16790. }
  16791. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  16792. function isCoreComponent(tag) {
  16793. switch (tag) {
  16794. case "Teleport":
  16795. case "teleport":
  16796. return TELEPORT;
  16797. case "Suspense":
  16798. case "suspense":
  16799. return SUSPENSE;
  16800. case "KeepAlive":
  16801. case "keep-alive":
  16802. return KEEP_ALIVE;
  16803. case "BaseTransition":
  16804. case "base-transition":
  16805. return BASE_TRANSITION;
  16806. }
  16807. }
  16808. const nonIdentifierRE = /^\d|[^\$\w]/;
  16809. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  16810. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  16811. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  16812. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  16813. const isMemberExpressionBrowser = (path) => {
  16814. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  16815. let state = 0 /* inMemberExp */;
  16816. let stateStack = [];
  16817. let currentOpenBracketCount = 0;
  16818. let currentOpenParensCount = 0;
  16819. let currentStringType = null;
  16820. for (let i = 0; i < path.length; i++) {
  16821. const char = path.charAt(i);
  16822. switch (state) {
  16823. case 0 /* inMemberExp */:
  16824. if (char === "[") {
  16825. stateStack.push(state);
  16826. state = 1 /* inBrackets */;
  16827. currentOpenBracketCount++;
  16828. } else if (char === "(") {
  16829. stateStack.push(state);
  16830. state = 2 /* inParens */;
  16831. currentOpenParensCount++;
  16832. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  16833. return false;
  16834. }
  16835. break;
  16836. case 1 /* inBrackets */:
  16837. if (char === `'` || char === `"` || char === "`") {
  16838. stateStack.push(state);
  16839. state = 3 /* inString */;
  16840. currentStringType = char;
  16841. } else if (char === `[`) {
  16842. currentOpenBracketCount++;
  16843. } else if (char === `]`) {
  16844. if (!--currentOpenBracketCount) {
  16845. state = stateStack.pop();
  16846. }
  16847. }
  16848. break;
  16849. case 2 /* inParens */:
  16850. if (char === `'` || char === `"` || char === "`") {
  16851. stateStack.push(state);
  16852. state = 3 /* inString */;
  16853. currentStringType = char;
  16854. } else if (char === `(`) {
  16855. currentOpenParensCount++;
  16856. } else if (char === `)`) {
  16857. if (i === path.length - 1) {
  16858. return false;
  16859. }
  16860. if (!--currentOpenParensCount) {
  16861. state = stateStack.pop();
  16862. }
  16863. }
  16864. break;
  16865. case 3 /* inString */:
  16866. if (char === currentStringType) {
  16867. state = stateStack.pop();
  16868. currentStringType = null;
  16869. }
  16870. break;
  16871. }
  16872. }
  16873. return !currentOpenBracketCount && !currentOpenParensCount;
  16874. };
  16875. const isMemberExpressionNode = (path, context) => {
  16876. try {
  16877. let ret = parseExpression_1(path, {
  16878. plugins: context.expressionPlugins
  16879. });
  16880. ret = unwrapTSNode(ret);
  16881. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  16882. } catch (e) {
  16883. return false;
  16884. }
  16885. };
  16886. const isMemberExpression = isMemberExpressionNode;
  16887. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  16888. return advancePositionWithMutation(
  16889. {
  16890. offset: pos.offset,
  16891. line: pos.line,
  16892. column: pos.column
  16893. },
  16894. source,
  16895. numberOfCharacters
  16896. );
  16897. }
  16898. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  16899. let linesCount = 0;
  16900. let lastNewLinePos = -1;
  16901. for (let i = 0; i < numberOfCharacters; i++) {
  16902. if (source.charCodeAt(i) === 10) {
  16903. linesCount++;
  16904. lastNewLinePos = i;
  16905. }
  16906. }
  16907. pos.offset += numberOfCharacters;
  16908. pos.line += linesCount;
  16909. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  16910. return pos;
  16911. }
  16912. function assert(condition, msg) {
  16913. if (!condition) {
  16914. throw new Error(msg || `unexpected compiler condition`);
  16915. }
  16916. }
  16917. function findDir(node, name, allowEmpty = false) {
  16918. for (let i = 0; i < node.props.length; i++) {
  16919. const p = node.props[i];
  16920. if (p.type === 7 && (allowEmpty || p.exp) && (isString$2(name) ? p.name === name : name.test(p.name))) {
  16921. return p;
  16922. }
  16923. }
  16924. }
  16925. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  16926. for (let i = 0; i < node.props.length; i++) {
  16927. const p = node.props[i];
  16928. if (p.type === 6) {
  16929. if (dynamicOnly)
  16930. continue;
  16931. if (p.name === name && (p.value || allowEmpty)) {
  16932. return p;
  16933. }
  16934. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  16935. return p;
  16936. }
  16937. }
  16938. }
  16939. function isStaticArgOf(arg, name) {
  16940. return !!(arg && isStaticExp(arg) && arg.content === name);
  16941. }
  16942. function hasDynamicKeyVBind(node) {
  16943. return node.props.some(
  16944. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  16945. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  16946. !p.arg.isStatic)
  16947. // v-bind:[foo]
  16948. );
  16949. }
  16950. function isText$1(node) {
  16951. return node.type === 5 || node.type === 2;
  16952. }
  16953. function isVSlot(p) {
  16954. return p.type === 7 && p.name === "slot";
  16955. }
  16956. function isTemplateNode(node) {
  16957. return node.type === 1 && node.tagType === 3;
  16958. }
  16959. function isSlotOutlet(node) {
  16960. return node.type === 1 && node.tagType === 2;
  16961. }
  16962. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  16963. function getUnnormalizedProps(props, callPath = []) {
  16964. if (props && !isString$2(props) && props.type === 14) {
  16965. const callee = props.callee;
  16966. if (!isString$2(callee) && propsHelperSet.has(callee)) {
  16967. return getUnnormalizedProps(
  16968. props.arguments[0],
  16969. callPath.concat(props)
  16970. );
  16971. }
  16972. }
  16973. return [props, callPath];
  16974. }
  16975. function injectProp(node, prop, context) {
  16976. let propsWithInjection;
  16977. let props = node.type === 13 ? node.props : node.arguments[2];
  16978. let callPath = [];
  16979. let parentCall;
  16980. if (props && !isString$2(props) && props.type === 14) {
  16981. const ret = getUnnormalizedProps(props);
  16982. props = ret[0];
  16983. callPath = ret[1];
  16984. parentCall = callPath[callPath.length - 1];
  16985. }
  16986. if (props == null || isString$2(props)) {
  16987. propsWithInjection = createObjectExpression([prop]);
  16988. } else if (props.type === 14) {
  16989. const first = props.arguments[0];
  16990. if (!isString$2(first) && first.type === 15) {
  16991. if (!hasProp(prop, first)) {
  16992. first.properties.unshift(prop);
  16993. }
  16994. } else {
  16995. if (props.callee === TO_HANDLERS) {
  16996. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  16997. createObjectExpression([prop]),
  16998. props
  16999. ]);
  17000. } else {
  17001. props.arguments.unshift(createObjectExpression([prop]));
  17002. }
  17003. }
  17004. !propsWithInjection && (propsWithInjection = props);
  17005. } else if (props.type === 15) {
  17006. if (!hasProp(prop, props)) {
  17007. props.properties.unshift(prop);
  17008. }
  17009. propsWithInjection = props;
  17010. } else {
  17011. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17012. createObjectExpression([prop]),
  17013. props
  17014. ]);
  17015. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17016. parentCall = callPath[callPath.length - 2];
  17017. }
  17018. }
  17019. if (node.type === 13) {
  17020. if (parentCall) {
  17021. parentCall.arguments[0] = propsWithInjection;
  17022. } else {
  17023. node.props = propsWithInjection;
  17024. }
  17025. } else {
  17026. if (parentCall) {
  17027. parentCall.arguments[0] = propsWithInjection;
  17028. } else {
  17029. node.arguments[2] = propsWithInjection;
  17030. }
  17031. }
  17032. }
  17033. function hasProp(prop, props) {
  17034. let result = false;
  17035. if (prop.key.type === 4) {
  17036. const propKeyName = prop.key.content;
  17037. result = props.properties.some(
  17038. (p) => p.key.type === 4 && p.key.content === propKeyName
  17039. );
  17040. }
  17041. return result;
  17042. }
  17043. function toValidAssetId(name, type) {
  17044. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17045. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17046. })}`;
  17047. }
  17048. function hasScopeRef(node, ids) {
  17049. if (!node || Object.keys(ids).length === 0) {
  17050. return false;
  17051. }
  17052. switch (node.type) {
  17053. case 1:
  17054. for (let i = 0; i < node.props.length; i++) {
  17055. const p = node.props[i];
  17056. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17057. return true;
  17058. }
  17059. }
  17060. return node.children.some((c) => hasScopeRef(c, ids));
  17061. case 11:
  17062. if (hasScopeRef(node.source, ids)) {
  17063. return true;
  17064. }
  17065. return node.children.some((c) => hasScopeRef(c, ids));
  17066. case 9:
  17067. return node.branches.some((b) => hasScopeRef(b, ids));
  17068. case 10:
  17069. if (hasScopeRef(node.condition, ids)) {
  17070. return true;
  17071. }
  17072. return node.children.some((c) => hasScopeRef(c, ids));
  17073. case 4:
  17074. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17075. case 8:
  17076. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17077. case 5:
  17078. case 12:
  17079. return hasScopeRef(node.content, ids);
  17080. case 2:
  17081. case 3:
  17082. return false;
  17083. default:
  17084. return false;
  17085. }
  17086. }
  17087. function getMemoedVNodeCall(node) {
  17088. if (node.type === 14 && node.callee === WITH_MEMO) {
  17089. return node.arguments[1].returns;
  17090. } else {
  17091. return node;
  17092. }
  17093. }
  17094. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  17095. const defaultParserOptions = {
  17096. parseMode: "base",
  17097. ns: 0,
  17098. delimiters: [`{{`, `}}`],
  17099. getNamespace: () => 0,
  17100. isVoidTag: NO,
  17101. isPreTag: NO,
  17102. isCustomElement: NO,
  17103. onError: defaultOnError,
  17104. onWarn: defaultOnWarn,
  17105. comments: true,
  17106. prefixIdentifiers: false
  17107. };
  17108. let currentOptions = defaultParserOptions;
  17109. let currentRoot = null;
  17110. let currentInput = "";
  17111. let currentOpenTag = null;
  17112. let currentProp = null;
  17113. let currentAttrValue = "";
  17114. let currentAttrStartIndex = -1;
  17115. let currentAttrEndIndex = -1;
  17116. let inPre = 0;
  17117. let inVPre = false;
  17118. let currentVPreBoundary = null;
  17119. const stack = [];
  17120. const tokenizer$2 = new Tokenizer$1(stack, {
  17121. onerr: emitError,
  17122. ontext(start, end) {
  17123. onText(getSlice(start, end), start, end);
  17124. },
  17125. ontextentity(char, start, end) {
  17126. onText(char, start, end);
  17127. },
  17128. oninterpolation(start, end) {
  17129. if (inVPre) {
  17130. return onText(getSlice(start, end), start, end);
  17131. }
  17132. let innerStart = start + tokenizer$2.delimiterOpen.length;
  17133. let innerEnd = end - tokenizer$2.delimiterClose.length;
  17134. while (isWhitespace$1(currentInput.charCodeAt(innerStart))) {
  17135. innerStart++;
  17136. }
  17137. while (isWhitespace$1(currentInput.charCodeAt(innerEnd - 1))) {
  17138. innerEnd--;
  17139. }
  17140. let exp = getSlice(innerStart, innerEnd);
  17141. if (exp.includes("&")) {
  17142. {
  17143. exp = decodeHTML(exp);
  17144. }
  17145. }
  17146. addNode({
  17147. type: 5,
  17148. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17149. loc: getLoc(start, end)
  17150. });
  17151. },
  17152. onopentagname(start, end) {
  17153. const name = getSlice(start, end);
  17154. currentOpenTag = {
  17155. type: 1,
  17156. tag: name,
  17157. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17158. tagType: 0,
  17159. // will be refined on tag close
  17160. props: [],
  17161. children: [],
  17162. loc: getLoc(start - 1, end),
  17163. codegenNode: void 0
  17164. };
  17165. },
  17166. onopentagend(end) {
  17167. endOpenTag(end);
  17168. },
  17169. onclosetag(start, end) {
  17170. const name = getSlice(start, end);
  17171. if (!currentOptions.isVoidTag(name)) {
  17172. let found = false;
  17173. for (let i = 0; i < stack.length; i++) {
  17174. const e = stack[i];
  17175. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17176. found = true;
  17177. if (i > 0) {
  17178. emitError(24, stack[0].loc.start.offset);
  17179. }
  17180. for (let j = 0; j <= i; j++) {
  17181. const el = stack.shift();
  17182. onCloseTag(el, end, j < i);
  17183. }
  17184. break;
  17185. }
  17186. }
  17187. if (!found) {
  17188. emitError(23, backTrack(start, 60));
  17189. }
  17190. }
  17191. },
  17192. onselfclosingtag(end) {
  17193. var _a;
  17194. const name = currentOpenTag.tag;
  17195. currentOpenTag.isSelfClosing = true;
  17196. endOpenTag(end);
  17197. if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
  17198. onCloseTag(stack.shift(), end);
  17199. }
  17200. },
  17201. onattribname(start, end) {
  17202. currentProp = {
  17203. type: 6,
  17204. name: getSlice(start, end),
  17205. nameLoc: getLoc(start, end),
  17206. value: void 0,
  17207. loc: getLoc(start)
  17208. };
  17209. },
  17210. ondirname(start, end) {
  17211. const raw = getSlice(start, end);
  17212. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  17213. if (!inVPre && name === "") {
  17214. emitError(26, start);
  17215. }
  17216. if (inVPre || name === "") {
  17217. currentProp = {
  17218. type: 6,
  17219. name: raw,
  17220. nameLoc: getLoc(start, end),
  17221. value: void 0,
  17222. loc: getLoc(start)
  17223. };
  17224. } else {
  17225. currentProp = {
  17226. type: 7,
  17227. name,
  17228. rawName: raw,
  17229. exp: void 0,
  17230. arg: void 0,
  17231. modifiers: raw === "." ? ["prop"] : [],
  17232. loc: getLoc(start)
  17233. };
  17234. if (name === "pre") {
  17235. inVPre = tokenizer$2.inVPre = true;
  17236. currentVPreBoundary = currentOpenTag;
  17237. const props = currentOpenTag.props;
  17238. for (let i = 0; i < props.length; i++) {
  17239. if (props[i].type === 7) {
  17240. props[i] = dirToAttr(props[i]);
  17241. }
  17242. }
  17243. }
  17244. }
  17245. },
  17246. ondirarg(start, end) {
  17247. if (start === end)
  17248. return;
  17249. const arg = getSlice(start, end);
  17250. if (inVPre) {
  17251. currentProp.name += arg;
  17252. setLocEnd(currentProp.nameLoc, end);
  17253. } else {
  17254. const isStatic = arg[0] !== `[`;
  17255. currentProp.arg = createExp(
  17256. isStatic ? arg : arg.slice(1, -1),
  17257. isStatic,
  17258. getLoc(start, end),
  17259. isStatic ? 3 : 0
  17260. );
  17261. }
  17262. },
  17263. ondirmodifier(start, end) {
  17264. const mod = getSlice(start, end);
  17265. if (inVPre) {
  17266. currentProp.name += "." + mod;
  17267. setLocEnd(currentProp.nameLoc, end);
  17268. } else if (currentProp.name === "slot") {
  17269. const arg = currentProp.arg;
  17270. if (arg) {
  17271. arg.content += "." + mod;
  17272. setLocEnd(arg.loc, end);
  17273. }
  17274. } else {
  17275. currentProp.modifiers.push(mod);
  17276. }
  17277. },
  17278. onattribdata(start, end) {
  17279. currentAttrValue += getSlice(start, end);
  17280. if (currentAttrStartIndex < 0)
  17281. currentAttrStartIndex = start;
  17282. currentAttrEndIndex = end;
  17283. },
  17284. onattribentity(char, start, end) {
  17285. currentAttrValue += char;
  17286. if (currentAttrStartIndex < 0)
  17287. currentAttrStartIndex = start;
  17288. currentAttrEndIndex = end;
  17289. },
  17290. onattribnameend(end) {
  17291. const start = currentProp.loc.start.offset;
  17292. const name = getSlice(start, end);
  17293. if (currentProp.type === 7) {
  17294. currentProp.rawName = name;
  17295. }
  17296. if (currentOpenTag.props.some(
  17297. (p) => (p.type === 7 ? p.rawName : p.name) === name
  17298. )) {
  17299. emitError(2, start);
  17300. }
  17301. },
  17302. onattribend(quote, end) {
  17303. if (currentOpenTag && currentProp) {
  17304. setLocEnd(currentProp.loc, end);
  17305. if (quote !== 0) {
  17306. if (currentProp.type === 6) {
  17307. if (currentProp.name === "class") {
  17308. currentAttrValue = condense(currentAttrValue).trim();
  17309. }
  17310. if (quote === 1 && !currentAttrValue) {
  17311. emitError(13, end);
  17312. }
  17313. currentProp.value = {
  17314. type: 2,
  17315. content: currentAttrValue,
  17316. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  17317. };
  17318. if (tokenizer$2.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  17319. tokenizer$2.enterRCDATA(toCharCodes(`</template`), 0);
  17320. }
  17321. } else {
  17322. let expParseMode = 0 /* Normal */;
  17323. {
  17324. if (currentProp.name === "for") {
  17325. expParseMode = 3 /* Skip */;
  17326. } else if (currentProp.name === "slot") {
  17327. expParseMode = 1 /* Params */;
  17328. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  17329. expParseMode = 2 /* Statements */;
  17330. }
  17331. }
  17332. currentProp.exp = createExp(
  17333. currentAttrValue,
  17334. false,
  17335. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  17336. 0,
  17337. expParseMode
  17338. );
  17339. if (currentProp.name === "for") {
  17340. currentProp.forParseResult = parseForExpression(currentProp.exp);
  17341. }
  17342. }
  17343. }
  17344. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  17345. currentOpenTag.props.push(currentProp);
  17346. }
  17347. }
  17348. currentAttrValue = "";
  17349. currentAttrStartIndex = currentAttrEndIndex = -1;
  17350. },
  17351. oncomment(start, end) {
  17352. if (currentOptions.comments) {
  17353. addNode({
  17354. type: 3,
  17355. content: getSlice(start, end),
  17356. loc: getLoc(start - 4, end + 3)
  17357. });
  17358. }
  17359. },
  17360. onend() {
  17361. const end = currentInput.length;
  17362. if (tokenizer$2.state !== 1) {
  17363. switch (tokenizer$2.state) {
  17364. case 5:
  17365. case 8:
  17366. emitError(5, end);
  17367. break;
  17368. case 3:
  17369. case 4:
  17370. emitError(
  17371. 25,
  17372. tokenizer$2.sectionStart
  17373. );
  17374. break;
  17375. case 28:
  17376. if (tokenizer$2.currentSequence === Sequences.CdataEnd) {
  17377. emitError(6, end);
  17378. } else {
  17379. emitError(7, end);
  17380. }
  17381. break;
  17382. case 6:
  17383. case 7:
  17384. case 9:
  17385. case 11:
  17386. case 12:
  17387. case 13:
  17388. case 14:
  17389. case 15:
  17390. case 16:
  17391. case 17:
  17392. case 18:
  17393. case 19:
  17394. case 20:
  17395. case 21:
  17396. emitError(9, end);
  17397. break;
  17398. }
  17399. }
  17400. for (let index = 0; index < stack.length; index++) {
  17401. onCloseTag(stack[index], end - 1);
  17402. emitError(24, stack[index].loc.start.offset);
  17403. }
  17404. },
  17405. oncdata(start, end) {
  17406. if (stack[0].ns !== 0) {
  17407. onText(getSlice(start, end), start, end);
  17408. } else {
  17409. emitError(1, start - 9);
  17410. }
  17411. },
  17412. onprocessinginstruction(start) {
  17413. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17414. emitError(
  17415. 21,
  17416. start - 1
  17417. );
  17418. }
  17419. }
  17420. });
  17421. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  17422. const stripParensRE = /^\(|\)$/g;
  17423. function parseForExpression(input) {
  17424. const loc = input.loc;
  17425. const exp = input.content;
  17426. const inMatch = exp.match(forAliasRE);
  17427. if (!inMatch)
  17428. return;
  17429. const [, LHS, RHS] = inMatch;
  17430. const createAliasExpression = (content, offset, asParam = false) => {
  17431. const start = loc.start.offset + offset;
  17432. const end = start + content.length;
  17433. return createExp(
  17434. content,
  17435. false,
  17436. getLoc(start, end),
  17437. 0,
  17438. asParam ? 1 /* Params */ : 0 /* Normal */
  17439. );
  17440. };
  17441. const result = {
  17442. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  17443. value: void 0,
  17444. key: void 0,
  17445. index: void 0,
  17446. finalized: false
  17447. };
  17448. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  17449. const trimmedOffset = LHS.indexOf(valueContent);
  17450. const iteratorMatch = valueContent.match(forIteratorRE);
  17451. if (iteratorMatch) {
  17452. valueContent = valueContent.replace(forIteratorRE, "").trim();
  17453. const keyContent = iteratorMatch[1].trim();
  17454. let keyOffset;
  17455. if (keyContent) {
  17456. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  17457. result.key = createAliasExpression(keyContent, keyOffset, true);
  17458. }
  17459. if (iteratorMatch[2]) {
  17460. const indexContent = iteratorMatch[2].trim();
  17461. if (indexContent) {
  17462. result.index = createAliasExpression(
  17463. indexContent,
  17464. exp.indexOf(
  17465. indexContent,
  17466. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  17467. ),
  17468. true
  17469. );
  17470. }
  17471. }
  17472. }
  17473. if (valueContent) {
  17474. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  17475. }
  17476. return result;
  17477. }
  17478. function getSlice(start, end) {
  17479. return currentInput.slice(start, end);
  17480. }
  17481. function endOpenTag(end) {
  17482. if (tokenizer$2.inSFCRoot) {
  17483. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  17484. }
  17485. addNode(currentOpenTag);
  17486. const { tag, ns } = currentOpenTag;
  17487. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17488. inPre++;
  17489. }
  17490. if (currentOptions.isVoidTag(tag)) {
  17491. onCloseTag(currentOpenTag, end);
  17492. } else {
  17493. stack.unshift(currentOpenTag);
  17494. if (ns === 1 || ns === 2) {
  17495. tokenizer$2.inXML = true;
  17496. }
  17497. }
  17498. currentOpenTag = null;
  17499. }
  17500. function onText(content, start, end) {
  17501. const parent = stack[0] || currentRoot;
  17502. const lastNode = parent.children[parent.children.length - 1];
  17503. if ((lastNode == null ? void 0 : lastNode.type) === 2) {
  17504. lastNode.content += content;
  17505. setLocEnd(lastNode.loc, end);
  17506. } else {
  17507. parent.children.push({
  17508. type: 2,
  17509. content,
  17510. loc: getLoc(start, end)
  17511. });
  17512. }
  17513. }
  17514. function onCloseTag(el, end, isImplied = false) {
  17515. if (isImplied) {
  17516. setLocEnd(el.loc, backTrack(end, 60));
  17517. } else {
  17518. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  17519. }
  17520. if (tokenizer$2.inSFCRoot) {
  17521. if (el.children.length) {
  17522. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  17523. } else {
  17524. el.innerLoc.end = extend({}, el.innerLoc.start);
  17525. }
  17526. el.innerLoc.source = getSlice(
  17527. el.innerLoc.start.offset,
  17528. el.innerLoc.end.offset
  17529. );
  17530. }
  17531. const { tag, ns } = el;
  17532. if (!inVPre) {
  17533. if (tag === "slot") {
  17534. el.tagType = 2;
  17535. } else if (isFragmentTemplate(el)) {
  17536. el.tagType = 3;
  17537. } else if (isComponent(el)) {
  17538. el.tagType = 1;
  17539. }
  17540. }
  17541. if (!tokenizer$2.inRCDATA) {
  17542. el.children = condenseWhitespace(el.children, el.tag);
  17543. }
  17544. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17545. inPre--;
  17546. }
  17547. if (currentVPreBoundary === el) {
  17548. inVPre = tokenizer$2.inVPre = false;
  17549. currentVPreBoundary = null;
  17550. }
  17551. if (tokenizer$2.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17552. tokenizer$2.inXML = false;
  17553. }
  17554. }
  17555. function lookAhead(index, c) {
  17556. let i = index;
  17557. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
  17558. i++;
  17559. return i;
  17560. }
  17561. function backTrack(index, c) {
  17562. let i = index;
  17563. while (currentInput.charCodeAt(i) !== c && i >= 0)
  17564. i--;
  17565. return i;
  17566. }
  17567. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  17568. function isFragmentTemplate({ tag, props }) {
  17569. if (tag === "template") {
  17570. for (let i = 0; i < props.length; i++) {
  17571. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  17572. return true;
  17573. }
  17574. }
  17575. }
  17576. return false;
  17577. }
  17578. function isComponent({ tag, props }) {
  17579. var _a;
  17580. if (currentOptions.isCustomElement(tag)) {
  17581. return false;
  17582. }
  17583. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  17584. return true;
  17585. }
  17586. for (let i = 0; i < props.length; i++) {
  17587. const p = props[i];
  17588. if (p.type === 6) {
  17589. if (p.name === "is" && p.value) {
  17590. if (p.value.content.startsWith("vue:")) {
  17591. return true;
  17592. }
  17593. }
  17594. }
  17595. }
  17596. return false;
  17597. }
  17598. function isUpperCase(c) {
  17599. return c > 64 && c < 91;
  17600. }
  17601. const windowsNewlineRE = /\r\n/g;
  17602. function condenseWhitespace(nodes, tag) {
  17603. var _a, _b;
  17604. const shouldCondense = currentOptions.whitespace !== "preserve";
  17605. let removedWhitespace = false;
  17606. for (let i = 0; i < nodes.length; i++) {
  17607. const node = nodes[i];
  17608. if (node.type === 2) {
  17609. if (!inPre) {
  17610. if (isAllWhitespace(node.content)) {
  17611. const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
  17612. const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
  17613. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  17614. removedWhitespace = true;
  17615. nodes[i] = null;
  17616. } else {
  17617. node.content = " ";
  17618. }
  17619. } else if (shouldCondense) {
  17620. node.content = condense(node.content);
  17621. }
  17622. } else {
  17623. node.content = node.content.replace(windowsNewlineRE, "\n");
  17624. }
  17625. }
  17626. }
  17627. if (inPre && tag && currentOptions.isPreTag(tag)) {
  17628. const first = nodes[0];
  17629. if (first && first.type === 2) {
  17630. first.content = first.content.replace(/^\r?\n/, "");
  17631. }
  17632. }
  17633. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  17634. }
  17635. function isAllWhitespace(str) {
  17636. for (let i = 0; i < str.length; i++) {
  17637. if (!isWhitespace$1(str.charCodeAt(i))) {
  17638. return false;
  17639. }
  17640. }
  17641. return true;
  17642. }
  17643. function hasNewlineChar(str) {
  17644. for (let i = 0; i < str.length; i++) {
  17645. const c = str.charCodeAt(i);
  17646. if (c === 10 || c === 13) {
  17647. return true;
  17648. }
  17649. }
  17650. return false;
  17651. }
  17652. function condense(str) {
  17653. let ret = "";
  17654. let prevCharIsWhitespace = false;
  17655. for (let i = 0; i < str.length; i++) {
  17656. if (isWhitespace$1(str.charCodeAt(i))) {
  17657. if (!prevCharIsWhitespace) {
  17658. ret += " ";
  17659. prevCharIsWhitespace = true;
  17660. }
  17661. } else {
  17662. ret += str[i];
  17663. prevCharIsWhitespace = false;
  17664. }
  17665. }
  17666. return ret;
  17667. }
  17668. function addNode(node) {
  17669. (stack[0] || currentRoot).children.push(node);
  17670. }
  17671. function getLoc(start, end) {
  17672. return {
  17673. start: tokenizer$2.getPos(start),
  17674. // @ts-expect-error allow late attachment
  17675. end: end == null ? end : tokenizer$2.getPos(end),
  17676. // @ts-expect-error allow late attachment
  17677. source: end == null ? end : getSlice(start, end)
  17678. };
  17679. }
  17680. function setLocEnd(loc, end) {
  17681. loc.end = tokenizer$2.getPos(end);
  17682. loc.source = getSlice(loc.start.offset, end);
  17683. }
  17684. function dirToAttr(dir) {
  17685. const attr = {
  17686. type: 6,
  17687. name: dir.rawName,
  17688. nameLoc: getLoc(
  17689. dir.loc.start.offset,
  17690. dir.loc.start.offset + dir.rawName.length
  17691. ),
  17692. value: void 0,
  17693. loc: dir.loc
  17694. };
  17695. if (dir.exp) {
  17696. const loc = dir.exp.loc;
  17697. if (loc.end.offset < dir.loc.end.offset) {
  17698. loc.start.offset--;
  17699. loc.start.column--;
  17700. loc.end.offset++;
  17701. loc.end.column++;
  17702. }
  17703. attr.value = {
  17704. type: 2,
  17705. content: dir.exp.content,
  17706. loc
  17707. };
  17708. }
  17709. return attr;
  17710. }
  17711. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  17712. const exp = createSimpleExpression(content, isStatic, loc, constType);
  17713. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  17714. if (isSimpleIdentifier(content)) {
  17715. exp.ast = null;
  17716. return exp;
  17717. }
  17718. try {
  17719. const plugins = currentOptions.expressionPlugins;
  17720. const options = {
  17721. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  17722. };
  17723. if (parseMode === 2 /* Statements */) {
  17724. exp.ast = parse_1$1(` ${content} `, options).program;
  17725. } else if (parseMode === 1 /* Params */) {
  17726. exp.ast = parseExpression_1(`(${content})=>{}`, options);
  17727. } else {
  17728. exp.ast = parseExpression_1(`(${content})`, options);
  17729. }
  17730. } catch (e) {
  17731. exp.ast = false;
  17732. emitError(45, loc.start.offset, e.message);
  17733. }
  17734. }
  17735. return exp;
  17736. }
  17737. function emitError(code, index, message) {
  17738. currentOptions.onError(
  17739. createCompilerError(code, getLoc(index, index), void 0, message)
  17740. );
  17741. }
  17742. function reset() {
  17743. tokenizer$2.reset();
  17744. currentOpenTag = null;
  17745. currentProp = null;
  17746. currentAttrValue = "";
  17747. currentAttrStartIndex = -1;
  17748. currentAttrEndIndex = -1;
  17749. stack.length = 0;
  17750. }
  17751. function baseParse(input, options) {
  17752. reset();
  17753. currentInput = input;
  17754. currentOptions = extend({}, defaultParserOptions);
  17755. if (options) {
  17756. let key;
  17757. for (key in options) {
  17758. if (options[key] != null) {
  17759. currentOptions[key] = options[key];
  17760. }
  17761. }
  17762. }
  17763. {
  17764. if (currentOptions.decodeEntities) {
  17765. console.warn(
  17766. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  17767. );
  17768. }
  17769. }
  17770. tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  17771. tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  17772. const delimiters = options == null ? void 0 : options.delimiters;
  17773. if (delimiters) {
  17774. tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
  17775. tokenizer$2.delimiterClose = toCharCodes(delimiters[1]);
  17776. }
  17777. const root = currentRoot = createRoot([], input);
  17778. tokenizer$2.parse(currentInput);
  17779. root.loc = getLoc(0, input.length);
  17780. root.children = condenseWhitespace(root.children);
  17781. currentRoot = null;
  17782. return root;
  17783. }
  17784. function hoistStatic(root, context) {
  17785. walk$1(
  17786. root,
  17787. context,
  17788. // Root node is unfortunately non-hoistable due to potential parent
  17789. // fallthrough attributes.
  17790. isSingleElementRoot(root, root.children[0])
  17791. );
  17792. }
  17793. function isSingleElementRoot(root, child) {
  17794. const { children } = root;
  17795. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  17796. }
  17797. function walk$1(node, context, doNotHoistNode = false) {
  17798. const { children } = node;
  17799. const originalCount = children.length;
  17800. let hoistedCount = 0;
  17801. for (let i = 0; i < children.length; i++) {
  17802. const child = children[i];
  17803. if (child.type === 1 && child.tagType === 0) {
  17804. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17805. if (constantType > 0) {
  17806. if (constantType >= 2) {
  17807. child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
  17808. child.codegenNode = context.hoist(child.codegenNode);
  17809. hoistedCount++;
  17810. continue;
  17811. }
  17812. } else {
  17813. const codegenNode = child.codegenNode;
  17814. if (codegenNode.type === 13) {
  17815. const flag = getPatchFlag(codegenNode);
  17816. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  17817. const props = getNodeProps(child);
  17818. if (props) {
  17819. codegenNode.props = context.hoist(props);
  17820. }
  17821. }
  17822. if (codegenNode.dynamicProps) {
  17823. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  17824. }
  17825. }
  17826. }
  17827. }
  17828. if (child.type === 1) {
  17829. const isComponent = child.tagType === 1;
  17830. if (isComponent) {
  17831. context.scopes.vSlot++;
  17832. }
  17833. walk$1(child, context);
  17834. if (isComponent) {
  17835. context.scopes.vSlot--;
  17836. }
  17837. } else if (child.type === 11) {
  17838. walk$1(child, context, child.children.length === 1);
  17839. } else if (child.type === 9) {
  17840. for (let i2 = 0; i2 < child.branches.length; i2++) {
  17841. walk$1(
  17842. child.branches[i2],
  17843. context,
  17844. child.branches[i2].children.length === 1
  17845. );
  17846. }
  17847. }
  17848. }
  17849. if (hoistedCount && context.transformHoist) {
  17850. context.transformHoist(children, context, node);
  17851. }
  17852. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  17853. const hoisted = context.hoist(
  17854. createArrayExpression(node.codegenNode.children)
  17855. );
  17856. if (context.hmr) {
  17857. hoisted.content = `[...${hoisted.content}]`;
  17858. }
  17859. node.codegenNode.children = hoisted;
  17860. }
  17861. }
  17862. function getConstantType(node, context) {
  17863. const { constantCache } = context;
  17864. switch (node.type) {
  17865. case 1:
  17866. if (node.tagType !== 0) {
  17867. return 0;
  17868. }
  17869. const cached = constantCache.get(node);
  17870. if (cached !== void 0) {
  17871. return cached;
  17872. }
  17873. const codegenNode = node.codegenNode;
  17874. if (codegenNode.type !== 13) {
  17875. return 0;
  17876. }
  17877. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  17878. return 0;
  17879. }
  17880. const flag = getPatchFlag(codegenNode);
  17881. if (!flag) {
  17882. let returnType2 = 3;
  17883. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  17884. if (generatedPropsType === 0) {
  17885. constantCache.set(node, 0);
  17886. return 0;
  17887. }
  17888. if (generatedPropsType < returnType2) {
  17889. returnType2 = generatedPropsType;
  17890. }
  17891. for (let i = 0; i < node.children.length; i++) {
  17892. const childType = getConstantType(node.children[i], context);
  17893. if (childType === 0) {
  17894. constantCache.set(node, 0);
  17895. return 0;
  17896. }
  17897. if (childType < returnType2) {
  17898. returnType2 = childType;
  17899. }
  17900. }
  17901. if (returnType2 > 1) {
  17902. for (let i = 0; i < node.props.length; i++) {
  17903. const p = node.props[i];
  17904. if (p.type === 7 && p.name === "bind" && p.exp) {
  17905. const expType = getConstantType(p.exp, context);
  17906. if (expType === 0) {
  17907. constantCache.set(node, 0);
  17908. return 0;
  17909. }
  17910. if (expType < returnType2) {
  17911. returnType2 = expType;
  17912. }
  17913. }
  17914. }
  17915. }
  17916. if (codegenNode.isBlock) {
  17917. for (let i = 0; i < node.props.length; i++) {
  17918. const p = node.props[i];
  17919. if (p.type === 7) {
  17920. constantCache.set(node, 0);
  17921. return 0;
  17922. }
  17923. }
  17924. context.removeHelper(OPEN_BLOCK);
  17925. context.removeHelper(
  17926. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  17927. );
  17928. codegenNode.isBlock = false;
  17929. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  17930. }
  17931. constantCache.set(node, returnType2);
  17932. return returnType2;
  17933. } else {
  17934. constantCache.set(node, 0);
  17935. return 0;
  17936. }
  17937. case 2:
  17938. case 3:
  17939. return 3;
  17940. case 9:
  17941. case 11:
  17942. case 10:
  17943. return 0;
  17944. case 5:
  17945. case 12:
  17946. return getConstantType(node.content, context);
  17947. case 4:
  17948. return node.constType;
  17949. case 8:
  17950. let returnType = 3;
  17951. for (let i = 0; i < node.children.length; i++) {
  17952. const child = node.children[i];
  17953. if (isString$2(child) || isSymbol$1(child)) {
  17954. continue;
  17955. }
  17956. const childType = getConstantType(child, context);
  17957. if (childType === 0) {
  17958. return 0;
  17959. } else if (childType < returnType) {
  17960. returnType = childType;
  17961. }
  17962. }
  17963. return returnType;
  17964. default:
  17965. return 0;
  17966. }
  17967. }
  17968. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  17969. NORMALIZE_CLASS,
  17970. NORMALIZE_STYLE,
  17971. NORMALIZE_PROPS,
  17972. GUARD_REACTIVE_PROPS
  17973. ]);
  17974. function getConstantTypeOfHelperCall(value, context) {
  17975. if (value.type === 14 && !isString$2(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  17976. const arg = value.arguments[0];
  17977. if (arg.type === 4) {
  17978. return getConstantType(arg, context);
  17979. } else if (arg.type === 14) {
  17980. return getConstantTypeOfHelperCall(arg, context);
  17981. }
  17982. }
  17983. return 0;
  17984. }
  17985. function getGeneratedPropsConstantType(node, context) {
  17986. let returnType = 3;
  17987. const props = getNodeProps(node);
  17988. if (props && props.type === 15) {
  17989. const { properties } = props;
  17990. for (let i = 0; i < properties.length; i++) {
  17991. const { key, value } = properties[i];
  17992. const keyType = getConstantType(key, context);
  17993. if (keyType === 0) {
  17994. return keyType;
  17995. }
  17996. if (keyType < returnType) {
  17997. returnType = keyType;
  17998. }
  17999. let valueType;
  18000. if (value.type === 4) {
  18001. valueType = getConstantType(value, context);
  18002. } else if (value.type === 14) {
  18003. valueType = getConstantTypeOfHelperCall(value, context);
  18004. } else {
  18005. valueType = 0;
  18006. }
  18007. if (valueType === 0) {
  18008. return valueType;
  18009. }
  18010. if (valueType < returnType) {
  18011. returnType = valueType;
  18012. }
  18013. }
  18014. }
  18015. return returnType;
  18016. }
  18017. function getNodeProps(node) {
  18018. const codegenNode = node.codegenNode;
  18019. if (codegenNode.type === 13) {
  18020. return codegenNode.props;
  18021. }
  18022. }
  18023. function getPatchFlag(node) {
  18024. const flag = node.patchFlag;
  18025. return flag ? parseInt(flag, 10) : void 0;
  18026. }
  18027. function createTransformContext(root, {
  18028. filename = "",
  18029. prefixIdentifiers = false,
  18030. hoistStatic: hoistStatic2 = false,
  18031. hmr = false,
  18032. cacheHandlers = false,
  18033. nodeTransforms = [],
  18034. directiveTransforms = {},
  18035. transformHoist = null,
  18036. isBuiltInComponent = NOOP,
  18037. isCustomElement = NOOP,
  18038. expressionPlugins = [],
  18039. scopeId = null,
  18040. slotted = true,
  18041. ssr = false,
  18042. inSSR = false,
  18043. ssrCssVars = ``,
  18044. bindingMetadata = EMPTY_OBJ,
  18045. inline = false,
  18046. isTS = false,
  18047. onError = defaultOnError,
  18048. onWarn = defaultOnWarn,
  18049. compatConfig
  18050. }) {
  18051. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18052. const context = {
  18053. // options
  18054. filename,
  18055. selfName: nameMatch && capitalize$1(camelize(nameMatch[1])),
  18056. prefixIdentifiers,
  18057. hoistStatic: hoistStatic2,
  18058. hmr,
  18059. cacheHandlers,
  18060. nodeTransforms,
  18061. directiveTransforms,
  18062. transformHoist,
  18063. isBuiltInComponent,
  18064. isCustomElement,
  18065. expressionPlugins,
  18066. scopeId,
  18067. slotted,
  18068. ssr,
  18069. inSSR,
  18070. ssrCssVars,
  18071. bindingMetadata,
  18072. inline,
  18073. isTS,
  18074. onError,
  18075. onWarn,
  18076. compatConfig,
  18077. // state
  18078. root,
  18079. helpers: /* @__PURE__ */ new Map(),
  18080. components: /* @__PURE__ */ new Set(),
  18081. directives: /* @__PURE__ */ new Set(),
  18082. hoists: [],
  18083. imports: [],
  18084. constantCache: /* @__PURE__ */ new WeakMap(),
  18085. temps: 0,
  18086. cached: 0,
  18087. identifiers: /* @__PURE__ */ Object.create(null),
  18088. scopes: {
  18089. vFor: 0,
  18090. vSlot: 0,
  18091. vPre: 0,
  18092. vOnce: 0
  18093. },
  18094. parent: null,
  18095. currentNode: root,
  18096. childIndex: 0,
  18097. inVOnce: false,
  18098. // methods
  18099. helper(name) {
  18100. const count = context.helpers.get(name) || 0;
  18101. context.helpers.set(name, count + 1);
  18102. return name;
  18103. },
  18104. removeHelper(name) {
  18105. const count = context.helpers.get(name);
  18106. if (count) {
  18107. const currentCount = count - 1;
  18108. if (!currentCount) {
  18109. context.helpers.delete(name);
  18110. } else {
  18111. context.helpers.set(name, currentCount);
  18112. }
  18113. }
  18114. },
  18115. helperString(name) {
  18116. return `_${helperNameMap[context.helper(name)]}`;
  18117. },
  18118. replaceNode(node) {
  18119. {
  18120. if (!context.currentNode) {
  18121. throw new Error(`Node being replaced is already removed.`);
  18122. }
  18123. if (!context.parent) {
  18124. throw new Error(`Cannot replace root node.`);
  18125. }
  18126. }
  18127. context.parent.children[context.childIndex] = context.currentNode = node;
  18128. },
  18129. removeNode(node) {
  18130. if (!context.parent) {
  18131. throw new Error(`Cannot remove root node.`);
  18132. }
  18133. const list = context.parent.children;
  18134. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18135. if (removalIndex < 0) {
  18136. throw new Error(`node being removed is not a child of current parent`);
  18137. }
  18138. if (!node || node === context.currentNode) {
  18139. context.currentNode = null;
  18140. context.onNodeRemoved();
  18141. } else {
  18142. if (context.childIndex > removalIndex) {
  18143. context.childIndex--;
  18144. context.onNodeRemoved();
  18145. }
  18146. }
  18147. context.parent.children.splice(removalIndex, 1);
  18148. },
  18149. onNodeRemoved: NOOP,
  18150. addIdentifiers(exp) {
  18151. {
  18152. if (isString$2(exp)) {
  18153. addId(exp);
  18154. } else if (exp.identifiers) {
  18155. exp.identifiers.forEach(addId);
  18156. } else if (exp.type === 4) {
  18157. addId(exp.content);
  18158. }
  18159. }
  18160. },
  18161. removeIdentifiers(exp) {
  18162. {
  18163. if (isString$2(exp)) {
  18164. removeId(exp);
  18165. } else if (exp.identifiers) {
  18166. exp.identifiers.forEach(removeId);
  18167. } else if (exp.type === 4) {
  18168. removeId(exp.content);
  18169. }
  18170. }
  18171. },
  18172. hoist(exp) {
  18173. if (isString$2(exp))
  18174. exp = createSimpleExpression(exp);
  18175. context.hoists.push(exp);
  18176. const identifier = createSimpleExpression(
  18177. `_hoisted_${context.hoists.length}`,
  18178. false,
  18179. exp.loc,
  18180. 2
  18181. );
  18182. identifier.hoisted = exp;
  18183. return identifier;
  18184. },
  18185. cache(exp, isVNode = false) {
  18186. return createCacheExpression(context.cached++, exp, isVNode);
  18187. }
  18188. };
  18189. function addId(id) {
  18190. const { identifiers } = context;
  18191. if (identifiers[id] === void 0) {
  18192. identifiers[id] = 0;
  18193. }
  18194. identifiers[id]++;
  18195. }
  18196. function removeId(id) {
  18197. context.identifiers[id]--;
  18198. }
  18199. return context;
  18200. }
  18201. function transform(root, options) {
  18202. const context = createTransformContext(root, options);
  18203. traverseNode(root, context);
  18204. if (options.hoistStatic) {
  18205. hoistStatic(root, context);
  18206. }
  18207. if (!options.ssr) {
  18208. createRootCodegen(root, context);
  18209. }
  18210. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  18211. root.components = [...context.components];
  18212. root.directives = [...context.directives];
  18213. root.imports = context.imports;
  18214. root.hoists = context.hoists;
  18215. root.temps = context.temps;
  18216. root.cached = context.cached;
  18217. root.transformed = true;
  18218. }
  18219. function createRootCodegen(root, context) {
  18220. const { helper } = context;
  18221. const { children } = root;
  18222. if (children.length === 1) {
  18223. const child = children[0];
  18224. if (isSingleElementRoot(root, child) && child.codegenNode) {
  18225. const codegenNode = child.codegenNode;
  18226. if (codegenNode.type === 13) {
  18227. convertToBlock(codegenNode, context);
  18228. }
  18229. root.codegenNode = codegenNode;
  18230. } else {
  18231. root.codegenNode = child;
  18232. }
  18233. } else if (children.length > 1) {
  18234. let patchFlag = 64;
  18235. let patchFlagText = PatchFlagNames[64];
  18236. if (children.filter((c) => c.type !== 3).length === 1) {
  18237. patchFlag |= 2048;
  18238. patchFlagText += `, ${PatchFlagNames[2048]}`;
  18239. }
  18240. root.codegenNode = createVNodeCall(
  18241. context,
  18242. helper(FRAGMENT),
  18243. void 0,
  18244. root.children,
  18245. patchFlag + (` /* ${patchFlagText} */` ),
  18246. void 0,
  18247. void 0,
  18248. true,
  18249. void 0,
  18250. false
  18251. );
  18252. } else ;
  18253. }
  18254. function traverseChildren(parent, context) {
  18255. let i = 0;
  18256. const nodeRemoved = () => {
  18257. i--;
  18258. };
  18259. for (; i < parent.children.length; i++) {
  18260. const child = parent.children[i];
  18261. if (isString$2(child))
  18262. continue;
  18263. context.parent = parent;
  18264. context.childIndex = i;
  18265. context.onNodeRemoved = nodeRemoved;
  18266. traverseNode(child, context);
  18267. }
  18268. }
  18269. function traverseNode(node, context) {
  18270. context.currentNode = node;
  18271. const { nodeTransforms } = context;
  18272. const exitFns = [];
  18273. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  18274. const onExit = nodeTransforms[i2](node, context);
  18275. if (onExit) {
  18276. if (isArray$3(onExit)) {
  18277. exitFns.push(...onExit);
  18278. } else {
  18279. exitFns.push(onExit);
  18280. }
  18281. }
  18282. if (!context.currentNode) {
  18283. return;
  18284. } else {
  18285. node = context.currentNode;
  18286. }
  18287. }
  18288. switch (node.type) {
  18289. case 3:
  18290. if (!context.ssr) {
  18291. context.helper(CREATE_COMMENT);
  18292. }
  18293. break;
  18294. case 5:
  18295. if (!context.ssr) {
  18296. context.helper(TO_DISPLAY_STRING);
  18297. }
  18298. break;
  18299. case 9:
  18300. for (let i2 = 0; i2 < node.branches.length; i2++) {
  18301. traverseNode(node.branches[i2], context);
  18302. }
  18303. break;
  18304. case 10:
  18305. case 11:
  18306. case 1:
  18307. case 0:
  18308. traverseChildren(node, context);
  18309. break;
  18310. }
  18311. context.currentNode = node;
  18312. let i = exitFns.length;
  18313. while (i--) {
  18314. exitFns[i]();
  18315. }
  18316. }
  18317. function createStructuralDirectiveTransform(name, fn) {
  18318. const matches = isString$2(name) ? (n) => n === name : (n) => name.test(n);
  18319. return (node, context) => {
  18320. if (node.type === 1) {
  18321. const { props } = node;
  18322. if (node.tagType === 3 && props.some(isVSlot)) {
  18323. return;
  18324. }
  18325. const exitFns = [];
  18326. for (let i = 0; i < props.length; i++) {
  18327. const prop = props[i];
  18328. if (prop.type === 7 && matches(prop.name)) {
  18329. props.splice(i, 1);
  18330. i--;
  18331. const onExit = fn(node, prop, context);
  18332. if (onExit)
  18333. exitFns.push(onExit);
  18334. }
  18335. }
  18336. return exitFns;
  18337. }
  18338. };
  18339. }
  18340. var sourceMap$2 = {};
  18341. var sourceMapGenerator$1 = {};
  18342. var base64Vlq$1 = {};
  18343. var base64$3 = {};
  18344. /* -*- Mode: js; js-indent-level: 2; -*- */
  18345. /*
  18346. * Copyright 2011 Mozilla Foundation and contributors
  18347. * Licensed under the New BSD license. See LICENSE or:
  18348. * http://opensource.org/licenses/BSD-3-Clause
  18349. */
  18350. var intToCharMap$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  18351. /**
  18352. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  18353. */
  18354. base64$3.encode = function (number) {
  18355. if (0 <= number && number < intToCharMap$1.length) {
  18356. return intToCharMap$1[number];
  18357. }
  18358. throw new TypeError("Must be between 0 and 63: " + number);
  18359. };
  18360. /**
  18361. * Decode a single base 64 character code digit to an integer. Returns -1 on
  18362. * failure.
  18363. */
  18364. base64$3.decode = function (charCode) {
  18365. var bigA = 65; // 'A'
  18366. var bigZ = 90; // 'Z'
  18367. var littleA = 97; // 'a'
  18368. var littleZ = 122; // 'z'
  18369. var zero = 48; // '0'
  18370. var nine = 57; // '9'
  18371. var plus = 43; // '+'
  18372. var slash = 47; // '/'
  18373. var littleOffset = 26;
  18374. var numberOffset = 52;
  18375. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  18376. if (bigA <= charCode && charCode <= bigZ) {
  18377. return (charCode - bigA);
  18378. }
  18379. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  18380. if (littleA <= charCode && charCode <= littleZ) {
  18381. return (charCode - littleA + littleOffset);
  18382. }
  18383. // 52 - 61: 0123456789
  18384. if (zero <= charCode && charCode <= nine) {
  18385. return (charCode - zero + numberOffset);
  18386. }
  18387. // 62: +
  18388. if (charCode == plus) {
  18389. return 62;
  18390. }
  18391. // 63: /
  18392. if (charCode == slash) {
  18393. return 63;
  18394. }
  18395. // Invalid base64 digit.
  18396. return -1;
  18397. };
  18398. /* -*- Mode: js; js-indent-level: 2; -*- */
  18399. /*
  18400. * Copyright 2011 Mozilla Foundation and contributors
  18401. * Licensed under the New BSD license. See LICENSE or:
  18402. * http://opensource.org/licenses/BSD-3-Clause
  18403. *
  18404. * Based on the Base 64 VLQ implementation in Closure Compiler:
  18405. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  18406. *
  18407. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  18408. * Redistribution and use in source and binary forms, with or without
  18409. * modification, are permitted provided that the following conditions are
  18410. * met:
  18411. *
  18412. * * Redistributions of source code must retain the above copyright
  18413. * notice, this list of conditions and the following disclaimer.
  18414. * * Redistributions in binary form must reproduce the above
  18415. * copyright notice, this list of conditions and the following
  18416. * disclaimer in the documentation and/or other materials provided
  18417. * with the distribution.
  18418. * * Neither the name of Google Inc. nor the names of its
  18419. * contributors may be used to endorse or promote products derived
  18420. * from this software without specific prior written permission.
  18421. *
  18422. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18423. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18424. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18425. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18426. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18427. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18428. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18429. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18430. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18431. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18432. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18433. */
  18434. var base64$2 = base64$3;
  18435. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  18436. // length quantities we use in the source map spec, the first bit is the sign,
  18437. // the next four bits are the actual value, and the 6th bit is the
  18438. // continuation bit. The continuation bit tells us whether there are more
  18439. // digits in this value following this digit.
  18440. //
  18441. // Continuation
  18442. // | Sign
  18443. // | |
  18444. // V V
  18445. // 101011
  18446. var VLQ_BASE_SHIFT$1 = 5;
  18447. // binary: 100000
  18448. var VLQ_BASE$1 = 1 << VLQ_BASE_SHIFT$1;
  18449. // binary: 011111
  18450. var VLQ_BASE_MASK$1 = VLQ_BASE$1 - 1;
  18451. // binary: 100000
  18452. var VLQ_CONTINUATION_BIT$1 = VLQ_BASE$1;
  18453. /**
  18454. * Converts from a two-complement value to a value where the sign bit is
  18455. * placed in the least significant bit. For example, as decimals:
  18456. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  18457. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  18458. */
  18459. function toVLQSigned$1(aValue) {
  18460. return aValue < 0
  18461. ? ((-aValue) << 1) + 1
  18462. : (aValue << 1) + 0;
  18463. }
  18464. /**
  18465. * Converts to a two-complement value from a value where the sign bit is
  18466. * placed in the least significant bit. For example, as decimals:
  18467. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  18468. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  18469. */
  18470. function fromVLQSigned$1(aValue) {
  18471. var isNegative = (aValue & 1) === 1;
  18472. var shifted = aValue >> 1;
  18473. return isNegative
  18474. ? -shifted
  18475. : shifted;
  18476. }
  18477. /**
  18478. * Returns the base 64 VLQ encoded value.
  18479. */
  18480. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  18481. var encoded = "";
  18482. var digit;
  18483. var vlq = toVLQSigned$1(aValue);
  18484. do {
  18485. digit = vlq & VLQ_BASE_MASK$1;
  18486. vlq >>>= VLQ_BASE_SHIFT$1;
  18487. if (vlq > 0) {
  18488. // There are still more digits in this value, so we must make sure the
  18489. // continuation bit is marked.
  18490. digit |= VLQ_CONTINUATION_BIT$1;
  18491. }
  18492. encoded += base64$2.encode(digit);
  18493. } while (vlq > 0);
  18494. return encoded;
  18495. };
  18496. /**
  18497. * Decodes the next base 64 VLQ value from the given string and returns the
  18498. * value and the rest of the string via the out parameter.
  18499. */
  18500. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  18501. var strLen = aStr.length;
  18502. var result = 0;
  18503. var shift = 0;
  18504. var continuation, digit;
  18505. do {
  18506. if (aIndex >= strLen) {
  18507. throw new Error("Expected more digits in base 64 VLQ value.");
  18508. }
  18509. digit = base64$2.decode(aStr.charCodeAt(aIndex++));
  18510. if (digit === -1) {
  18511. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  18512. }
  18513. continuation = !!(digit & VLQ_CONTINUATION_BIT$1);
  18514. digit &= VLQ_BASE_MASK$1;
  18515. result = result + (digit << shift);
  18516. shift += VLQ_BASE_SHIFT$1;
  18517. } while (continuation);
  18518. aOutParam.value = fromVLQSigned$1(result);
  18519. aOutParam.rest = aIndex;
  18520. };
  18521. var util$c = {};
  18522. /* -*- Mode: js; js-indent-level: 2; -*- */
  18523. (function (exports) {
  18524. /*
  18525. * Copyright 2011 Mozilla Foundation and contributors
  18526. * Licensed under the New BSD license. See LICENSE or:
  18527. * http://opensource.org/licenses/BSD-3-Clause
  18528. */
  18529. /**
  18530. * This is a helper function for getting values from parameter/options
  18531. * objects.
  18532. *
  18533. * @param args The object we are extracting values from
  18534. * @param name The name of the property we are getting.
  18535. * @param defaultValue An optional value to return if the property is missing
  18536. * from the object. If this is not specified and the property is missing, an
  18537. * error will be thrown.
  18538. */
  18539. function getArg(aArgs, aName, aDefaultValue) {
  18540. if (aName in aArgs) {
  18541. return aArgs[aName];
  18542. } else if (arguments.length === 3) {
  18543. return aDefaultValue;
  18544. } else {
  18545. throw new Error('"' + aName + '" is a required argument.');
  18546. }
  18547. }
  18548. exports.getArg = getArg;
  18549. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  18550. var dataUrlRegexp = /^data:.+\,.+$/;
  18551. function urlParse(aUrl) {
  18552. var match = aUrl.match(urlRegexp);
  18553. if (!match) {
  18554. return null;
  18555. }
  18556. return {
  18557. scheme: match[1],
  18558. auth: match[2],
  18559. host: match[3],
  18560. port: match[4],
  18561. path: match[5]
  18562. };
  18563. }
  18564. exports.urlParse = urlParse;
  18565. function urlGenerate(aParsedUrl) {
  18566. var url = '';
  18567. if (aParsedUrl.scheme) {
  18568. url += aParsedUrl.scheme + ':';
  18569. }
  18570. url += '//';
  18571. if (aParsedUrl.auth) {
  18572. url += aParsedUrl.auth + '@';
  18573. }
  18574. if (aParsedUrl.host) {
  18575. url += aParsedUrl.host;
  18576. }
  18577. if (aParsedUrl.port) {
  18578. url += ":" + aParsedUrl.port;
  18579. }
  18580. if (aParsedUrl.path) {
  18581. url += aParsedUrl.path;
  18582. }
  18583. return url;
  18584. }
  18585. exports.urlGenerate = urlGenerate;
  18586. var MAX_CACHED_INPUTS = 32;
  18587. /**
  18588. * Takes some function `f(input) -> result` and returns a memoized version of
  18589. * `f`.
  18590. *
  18591. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  18592. * memoization is a dumb-simple, linear least-recently-used cache.
  18593. */
  18594. function lruMemoize(f) {
  18595. var cache = [];
  18596. return function(input) {
  18597. for (var i = 0; i < cache.length; i++) {
  18598. if (cache[i].input === input) {
  18599. var temp = cache[0];
  18600. cache[0] = cache[i];
  18601. cache[i] = temp;
  18602. return cache[0].result;
  18603. }
  18604. }
  18605. var result = f(input);
  18606. cache.unshift({
  18607. input,
  18608. result,
  18609. });
  18610. if (cache.length > MAX_CACHED_INPUTS) {
  18611. cache.pop();
  18612. }
  18613. return result;
  18614. };
  18615. }
  18616. /**
  18617. * Normalizes a path, or the path portion of a URL:
  18618. *
  18619. * - Replaces consecutive slashes with one slash.
  18620. * - Removes unnecessary '.' parts.
  18621. * - Removes unnecessary '<dir>/..' parts.
  18622. *
  18623. * Based on code in the Node.js 'path' core module.
  18624. *
  18625. * @param aPath The path or url to normalize.
  18626. */
  18627. var normalize = lruMemoize(function normalize(aPath) {
  18628. var path = aPath;
  18629. var url = urlParse(aPath);
  18630. if (url) {
  18631. if (!url.path) {
  18632. return aPath;
  18633. }
  18634. path = url.path;
  18635. }
  18636. var isAbsolute = exports.isAbsolute(path);
  18637. // Split the path into parts between `/` characters. This is much faster than
  18638. // using `.split(/\/+/g)`.
  18639. var parts = [];
  18640. var start = 0;
  18641. var i = 0;
  18642. while (true) {
  18643. start = i;
  18644. i = path.indexOf("/", start);
  18645. if (i === -1) {
  18646. parts.push(path.slice(start));
  18647. break;
  18648. } else {
  18649. parts.push(path.slice(start, i));
  18650. while (i < path.length && path[i] === "/") {
  18651. i++;
  18652. }
  18653. }
  18654. }
  18655. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  18656. part = parts[i];
  18657. if (part === '.') {
  18658. parts.splice(i, 1);
  18659. } else if (part === '..') {
  18660. up++;
  18661. } else if (up > 0) {
  18662. if (part === '') {
  18663. // The first part is blank if the path is absolute. Trying to go
  18664. // above the root is a no-op. Therefore we can remove all '..' parts
  18665. // directly after the root.
  18666. parts.splice(i + 1, up);
  18667. up = 0;
  18668. } else {
  18669. parts.splice(i, 2);
  18670. up--;
  18671. }
  18672. }
  18673. }
  18674. path = parts.join('/');
  18675. if (path === '') {
  18676. path = isAbsolute ? '/' : '.';
  18677. }
  18678. if (url) {
  18679. url.path = path;
  18680. return urlGenerate(url);
  18681. }
  18682. return path;
  18683. });
  18684. exports.normalize = normalize;
  18685. /**
  18686. * Joins two paths/URLs.
  18687. *
  18688. * @param aRoot The root path or URL.
  18689. * @param aPath The path or URL to be joined with the root.
  18690. *
  18691. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  18692. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  18693. * first.
  18694. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  18695. * is updated with the result and aRoot is returned. Otherwise the result
  18696. * is returned.
  18697. * - If aPath is absolute, the result is aPath.
  18698. * - Otherwise the two paths are joined with a slash.
  18699. * - Joining for example 'http://' and 'www.example.com' is also supported.
  18700. */
  18701. function join(aRoot, aPath) {
  18702. if (aRoot === "") {
  18703. aRoot = ".";
  18704. }
  18705. if (aPath === "") {
  18706. aPath = ".";
  18707. }
  18708. var aPathUrl = urlParse(aPath);
  18709. var aRootUrl = urlParse(aRoot);
  18710. if (aRootUrl) {
  18711. aRoot = aRootUrl.path || '/';
  18712. }
  18713. // `join(foo, '//www.example.org')`
  18714. if (aPathUrl && !aPathUrl.scheme) {
  18715. if (aRootUrl) {
  18716. aPathUrl.scheme = aRootUrl.scheme;
  18717. }
  18718. return urlGenerate(aPathUrl);
  18719. }
  18720. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  18721. return aPath;
  18722. }
  18723. // `join('http://', 'www.example.com')`
  18724. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  18725. aRootUrl.host = aPath;
  18726. return urlGenerate(aRootUrl);
  18727. }
  18728. var joined = aPath.charAt(0) === '/'
  18729. ? aPath
  18730. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  18731. if (aRootUrl) {
  18732. aRootUrl.path = joined;
  18733. return urlGenerate(aRootUrl);
  18734. }
  18735. return joined;
  18736. }
  18737. exports.join = join;
  18738. exports.isAbsolute = function (aPath) {
  18739. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  18740. };
  18741. /**
  18742. * Make a path relative to a URL or another path.
  18743. *
  18744. * @param aRoot The root path or URL.
  18745. * @param aPath The path or URL to be made relative to aRoot.
  18746. */
  18747. function relative(aRoot, aPath) {
  18748. if (aRoot === "") {
  18749. aRoot = ".";
  18750. }
  18751. aRoot = aRoot.replace(/\/$/, '');
  18752. // It is possible for the path to be above the root. In this case, simply
  18753. // checking whether the root is a prefix of the path won't work. Instead, we
  18754. // need to remove components from the root one by one, until either we find
  18755. // a prefix that fits, or we run out of components to remove.
  18756. var level = 0;
  18757. while (aPath.indexOf(aRoot + '/') !== 0) {
  18758. var index = aRoot.lastIndexOf("/");
  18759. if (index < 0) {
  18760. return aPath;
  18761. }
  18762. // If the only part of the root that is left is the scheme (i.e. http://,
  18763. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  18764. // have exhausted all components, so the path is not relative to the root.
  18765. aRoot = aRoot.slice(0, index);
  18766. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  18767. return aPath;
  18768. }
  18769. ++level;
  18770. }
  18771. // Make sure we add a "../" for each component we removed from the root.
  18772. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  18773. }
  18774. exports.relative = relative;
  18775. var supportsNullProto = (function () {
  18776. var obj = Object.create(null);
  18777. return !('__proto__' in obj);
  18778. }());
  18779. function identity (s) {
  18780. return s;
  18781. }
  18782. /**
  18783. * Because behavior goes wacky when you set `__proto__` on objects, we
  18784. * have to prefix all the strings in our set with an arbitrary character.
  18785. *
  18786. * See https://github.com/mozilla/source-map/pull/31 and
  18787. * https://github.com/mozilla/source-map/issues/30
  18788. *
  18789. * @param String aStr
  18790. */
  18791. function toSetString(aStr) {
  18792. if (isProtoString(aStr)) {
  18793. return '$' + aStr;
  18794. }
  18795. return aStr;
  18796. }
  18797. exports.toSetString = supportsNullProto ? identity : toSetString;
  18798. function fromSetString(aStr) {
  18799. if (isProtoString(aStr)) {
  18800. return aStr.slice(1);
  18801. }
  18802. return aStr;
  18803. }
  18804. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  18805. function isProtoString(s) {
  18806. if (!s) {
  18807. return false;
  18808. }
  18809. var length = s.length;
  18810. if (length < 9 /* "__proto__".length */) {
  18811. return false;
  18812. }
  18813. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  18814. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  18815. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  18816. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  18817. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  18818. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  18819. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  18820. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  18821. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  18822. return false;
  18823. }
  18824. for (var i = length - 10; i >= 0; i--) {
  18825. if (s.charCodeAt(i) !== 36 /* '$' */) {
  18826. return false;
  18827. }
  18828. }
  18829. return true;
  18830. }
  18831. /**
  18832. * Comparator between two mappings where the original positions are compared.
  18833. *
  18834. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18835. * mappings with the same original source/line/column, but different generated
  18836. * line and column the same. Useful when searching for a mapping with a
  18837. * stubbed out mapping.
  18838. */
  18839. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  18840. var cmp = strcmp(mappingA.source, mappingB.source);
  18841. if (cmp !== 0) {
  18842. return cmp;
  18843. }
  18844. cmp = mappingA.originalLine - mappingB.originalLine;
  18845. if (cmp !== 0) {
  18846. return cmp;
  18847. }
  18848. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18849. if (cmp !== 0 || onlyCompareOriginal) {
  18850. return cmp;
  18851. }
  18852. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18853. if (cmp !== 0) {
  18854. return cmp;
  18855. }
  18856. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18857. if (cmp !== 0) {
  18858. return cmp;
  18859. }
  18860. return strcmp(mappingA.name, mappingB.name);
  18861. }
  18862. exports.compareByOriginalPositions = compareByOriginalPositions;
  18863. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  18864. var cmp;
  18865. cmp = mappingA.originalLine - mappingB.originalLine;
  18866. if (cmp !== 0) {
  18867. return cmp;
  18868. }
  18869. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18870. if (cmp !== 0 || onlyCompareOriginal) {
  18871. return cmp;
  18872. }
  18873. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18874. if (cmp !== 0) {
  18875. return cmp;
  18876. }
  18877. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18878. if (cmp !== 0) {
  18879. return cmp;
  18880. }
  18881. return strcmp(mappingA.name, mappingB.name);
  18882. }
  18883. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  18884. /**
  18885. * Comparator between two mappings with deflated source and name indices where
  18886. * the generated positions are compared.
  18887. *
  18888. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18889. * mappings with the same generated line and column, but different
  18890. * source/name/original line and column the same. Useful when searching for a
  18891. * mapping with a stubbed out mapping.
  18892. */
  18893. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  18894. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18895. if (cmp !== 0) {
  18896. return cmp;
  18897. }
  18898. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18899. if (cmp !== 0 || onlyCompareGenerated) {
  18900. return cmp;
  18901. }
  18902. cmp = strcmp(mappingA.source, mappingB.source);
  18903. if (cmp !== 0) {
  18904. return cmp;
  18905. }
  18906. cmp = mappingA.originalLine - mappingB.originalLine;
  18907. if (cmp !== 0) {
  18908. return cmp;
  18909. }
  18910. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18911. if (cmp !== 0) {
  18912. return cmp;
  18913. }
  18914. return strcmp(mappingA.name, mappingB.name);
  18915. }
  18916. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  18917. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  18918. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18919. if (cmp !== 0 || onlyCompareGenerated) {
  18920. return cmp;
  18921. }
  18922. cmp = strcmp(mappingA.source, mappingB.source);
  18923. if (cmp !== 0) {
  18924. return cmp;
  18925. }
  18926. cmp = mappingA.originalLine - mappingB.originalLine;
  18927. if (cmp !== 0) {
  18928. return cmp;
  18929. }
  18930. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18931. if (cmp !== 0) {
  18932. return cmp;
  18933. }
  18934. return strcmp(mappingA.name, mappingB.name);
  18935. }
  18936. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  18937. function strcmp(aStr1, aStr2) {
  18938. if (aStr1 === aStr2) {
  18939. return 0;
  18940. }
  18941. if (aStr1 === null) {
  18942. return 1; // aStr2 !== null
  18943. }
  18944. if (aStr2 === null) {
  18945. return -1; // aStr1 !== null
  18946. }
  18947. if (aStr1 > aStr2) {
  18948. return 1;
  18949. }
  18950. return -1;
  18951. }
  18952. /**
  18953. * Comparator between two mappings with inflated source and name strings where
  18954. * the generated positions are compared.
  18955. */
  18956. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  18957. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18958. if (cmp !== 0) {
  18959. return cmp;
  18960. }
  18961. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18962. if (cmp !== 0) {
  18963. return cmp;
  18964. }
  18965. cmp = strcmp(mappingA.source, mappingB.source);
  18966. if (cmp !== 0) {
  18967. return cmp;
  18968. }
  18969. cmp = mappingA.originalLine - mappingB.originalLine;
  18970. if (cmp !== 0) {
  18971. return cmp;
  18972. }
  18973. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18974. if (cmp !== 0) {
  18975. return cmp;
  18976. }
  18977. return strcmp(mappingA.name, mappingB.name);
  18978. }
  18979. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  18980. /**
  18981. * Strip any JSON XSSI avoidance prefix from the string (as documented
  18982. * in the source maps specification), and then parse the string as
  18983. * JSON.
  18984. */
  18985. function parseSourceMapInput(str) {
  18986. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  18987. }
  18988. exports.parseSourceMapInput = parseSourceMapInput;
  18989. /**
  18990. * Compute the URL of a source given the the source root, the source's
  18991. * URL, and the source map's URL.
  18992. */
  18993. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  18994. sourceURL = sourceURL || '';
  18995. if (sourceRoot) {
  18996. // This follows what Chrome does.
  18997. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  18998. sourceRoot += '/';
  18999. }
  19000. // The spec says:
  19001. // Line 4: An optional source root, useful for relocating source
  19002. // files on a server or removing repeated values in the
  19003. // “sources” entry. This value is prepended to the individual
  19004. // entries in the “source” field.
  19005. sourceURL = sourceRoot + sourceURL;
  19006. }
  19007. // Historically, SourceMapConsumer did not take the sourceMapURL as
  19008. // a parameter. This mode is still somewhat supported, which is why
  19009. // this code block is conditional. However, it's preferable to pass
  19010. // the source map URL to SourceMapConsumer, so that this function
  19011. // can implement the source URL resolution algorithm as outlined in
  19012. // the spec. This block is basically the equivalent of:
  19013. // new URL(sourceURL, sourceMapURL).toString()
  19014. // ... except it avoids using URL, which wasn't available in the
  19015. // older releases of node still supported by this library.
  19016. //
  19017. // The spec says:
  19018. // If the sources are not absolute URLs after prepending of the
  19019. // “sourceRoot”, the sources are resolved relative to the
  19020. // SourceMap (like resolving script src in a html document).
  19021. if (sourceMapURL) {
  19022. var parsed = urlParse(sourceMapURL);
  19023. if (!parsed) {
  19024. throw new Error("sourceMapURL could not be parsed");
  19025. }
  19026. if (parsed.path) {
  19027. // Strip the last path component, but keep the "/".
  19028. var index = parsed.path.lastIndexOf('/');
  19029. if (index >= 0) {
  19030. parsed.path = parsed.path.substring(0, index + 1);
  19031. }
  19032. }
  19033. sourceURL = join(urlGenerate(parsed), sourceURL);
  19034. }
  19035. return normalize(sourceURL);
  19036. }
  19037. exports.computeSourceURL = computeSourceURL;
  19038. } (util$c));
  19039. var arraySet$1 = {};
  19040. /* -*- Mode: js; js-indent-level: 2; -*- */
  19041. /*
  19042. * Copyright 2011 Mozilla Foundation and contributors
  19043. * Licensed under the New BSD license. See LICENSE or:
  19044. * http://opensource.org/licenses/BSD-3-Clause
  19045. */
  19046. var util$b = util$c;
  19047. var has$1 = Object.prototype.hasOwnProperty;
  19048. var hasNativeMap$1 = typeof Map !== "undefined";
  19049. /**
  19050. * A data structure which is a combination of an array and a set. Adding a new
  19051. * member is O(1), testing for membership is O(1), and finding the index of an
  19052. * element is O(1). Removing elements from the set is not supported. Only
  19053. * strings are supported for membership.
  19054. */
  19055. function ArraySet$5() {
  19056. this._array = [];
  19057. this._set = hasNativeMap$1 ? new Map() : Object.create(null);
  19058. }
  19059. /**
  19060. * Static method for creating ArraySet instances from an existing array.
  19061. */
  19062. ArraySet$5.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19063. var set = new ArraySet$5();
  19064. for (var i = 0, len = aArray.length; i < len; i++) {
  19065. set.add(aArray[i], aAllowDuplicates);
  19066. }
  19067. return set;
  19068. };
  19069. /**
  19070. * Return how many unique items are in this ArraySet. If duplicates have been
  19071. * added, than those do not count towards the size.
  19072. *
  19073. * @returns Number
  19074. */
  19075. ArraySet$5.prototype.size = function ArraySet_size() {
  19076. return hasNativeMap$1 ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19077. };
  19078. /**
  19079. * Add the given string to this set.
  19080. *
  19081. * @param String aStr
  19082. */
  19083. ArraySet$5.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19084. var sStr = hasNativeMap$1 ? aStr : util$b.toSetString(aStr);
  19085. var isDuplicate = hasNativeMap$1 ? this.has(aStr) : has$1.call(this._set, sStr);
  19086. var idx = this._array.length;
  19087. if (!isDuplicate || aAllowDuplicates) {
  19088. this._array.push(aStr);
  19089. }
  19090. if (!isDuplicate) {
  19091. if (hasNativeMap$1) {
  19092. this._set.set(aStr, idx);
  19093. } else {
  19094. this._set[sStr] = idx;
  19095. }
  19096. }
  19097. };
  19098. /**
  19099. * Is the given string a member of this set?
  19100. *
  19101. * @param String aStr
  19102. */
  19103. ArraySet$5.prototype.has = function ArraySet_has(aStr) {
  19104. if (hasNativeMap$1) {
  19105. return this._set.has(aStr);
  19106. } else {
  19107. var sStr = util$b.toSetString(aStr);
  19108. return has$1.call(this._set, sStr);
  19109. }
  19110. };
  19111. /**
  19112. * What is the index of the given string in the array?
  19113. *
  19114. * @param String aStr
  19115. */
  19116. ArraySet$5.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19117. if (hasNativeMap$1) {
  19118. var idx = this._set.get(aStr);
  19119. if (idx >= 0) {
  19120. return idx;
  19121. }
  19122. } else {
  19123. var sStr = util$b.toSetString(aStr);
  19124. if (has$1.call(this._set, sStr)) {
  19125. return this._set[sStr];
  19126. }
  19127. }
  19128. throw new Error('"' + aStr + '" is not in the set.');
  19129. };
  19130. /**
  19131. * What is the element at the given index?
  19132. *
  19133. * @param Number aIdx
  19134. */
  19135. ArraySet$5.prototype.at = function ArraySet_at(aIdx) {
  19136. if (aIdx >= 0 && aIdx < this._array.length) {
  19137. return this._array[aIdx];
  19138. }
  19139. throw new Error('No element indexed by ' + aIdx);
  19140. };
  19141. /**
  19142. * Returns the array representation of this set (which has the proper indices
  19143. * indicated by indexOf). Note that this is a copy of the internal array used
  19144. * for storing the members so that no one can mess with internal state.
  19145. */
  19146. ArraySet$5.prototype.toArray = function ArraySet_toArray() {
  19147. return this._array.slice();
  19148. };
  19149. arraySet$1.ArraySet = ArraySet$5;
  19150. var mappingList$1 = {};
  19151. /* -*- Mode: js; js-indent-level: 2; -*- */
  19152. /*
  19153. * Copyright 2014 Mozilla Foundation and contributors
  19154. * Licensed under the New BSD license. See LICENSE or:
  19155. * http://opensource.org/licenses/BSD-3-Clause
  19156. */
  19157. var util$a = util$c;
  19158. /**
  19159. * Determine whether mappingB is after mappingA with respect to generated
  19160. * position.
  19161. */
  19162. function generatedPositionAfter$1(mappingA, mappingB) {
  19163. // Optimized for most common case
  19164. var lineA = mappingA.generatedLine;
  19165. var lineB = mappingB.generatedLine;
  19166. var columnA = mappingA.generatedColumn;
  19167. var columnB = mappingB.generatedColumn;
  19168. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  19169. util$a.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  19170. }
  19171. /**
  19172. * A data structure to provide a sorted view of accumulated mappings in a
  19173. * performance conscious manner. It trades a neglibable overhead in general
  19174. * case for a large speedup in case of mappings being added in order.
  19175. */
  19176. function MappingList$3() {
  19177. this._array = [];
  19178. this._sorted = true;
  19179. // Serves as infimum
  19180. this._last = {generatedLine: -1, generatedColumn: 0};
  19181. }
  19182. /**
  19183. * Iterate through internal items. This method takes the same arguments that
  19184. * `Array.prototype.forEach` takes.
  19185. *
  19186. * NOTE: The order of the mappings is NOT guaranteed.
  19187. */
  19188. MappingList$3.prototype.unsortedForEach =
  19189. function MappingList_forEach(aCallback, aThisArg) {
  19190. this._array.forEach(aCallback, aThisArg);
  19191. };
  19192. /**
  19193. * Add the given source mapping.
  19194. *
  19195. * @param Object aMapping
  19196. */
  19197. MappingList$3.prototype.add = function MappingList_add(aMapping) {
  19198. if (generatedPositionAfter$1(this._last, aMapping)) {
  19199. this._last = aMapping;
  19200. this._array.push(aMapping);
  19201. } else {
  19202. this._sorted = false;
  19203. this._array.push(aMapping);
  19204. }
  19205. };
  19206. /**
  19207. * Returns the flat, sorted array of mappings. The mappings are sorted by
  19208. * generated position.
  19209. *
  19210. * WARNING: This method returns internal data without copying, for
  19211. * performance. The return value must NOT be mutated, and should be treated as
  19212. * an immutable borrow. If you want to take ownership, you must make your own
  19213. * copy.
  19214. */
  19215. MappingList$3.prototype.toArray = function MappingList_toArray() {
  19216. if (!this._sorted) {
  19217. this._array.sort(util$a.compareByGeneratedPositionsInflated);
  19218. this._sorted = true;
  19219. }
  19220. return this._array;
  19221. };
  19222. mappingList$1.MappingList = MappingList$3;
  19223. /* -*- Mode: js; js-indent-level: 2; -*- */
  19224. /*
  19225. * Copyright 2011 Mozilla Foundation and contributors
  19226. * Licensed under the New BSD license. See LICENSE or:
  19227. * http://opensource.org/licenses/BSD-3-Clause
  19228. */
  19229. var base64VLQ$3 = base64Vlq$1;
  19230. var util$9 = util$c;
  19231. var ArraySet$4 = arraySet$1.ArraySet;
  19232. var MappingList$2 = mappingList$1.MappingList;
  19233. /**
  19234. * An instance of the SourceMapGenerator represents a source map which is
  19235. * being built incrementally. You may pass an object with the following
  19236. * properties:
  19237. *
  19238. * - file: The filename of the generated source.
  19239. * - sourceRoot: A root for all relative URLs in this source map.
  19240. */
  19241. function SourceMapGenerator$8(aArgs) {
  19242. if (!aArgs) {
  19243. aArgs = {};
  19244. }
  19245. this._file = util$9.getArg(aArgs, 'file', null);
  19246. this._sourceRoot = util$9.getArg(aArgs, 'sourceRoot', null);
  19247. this._skipValidation = util$9.getArg(aArgs, 'skipValidation', false);
  19248. this._ignoreInvalidMapping = util$9.getArg(aArgs, 'ignoreInvalidMapping', false);
  19249. this._sources = new ArraySet$4();
  19250. this._names = new ArraySet$4();
  19251. this._mappings = new MappingList$2();
  19252. this._sourcesContents = null;
  19253. }
  19254. SourceMapGenerator$8.prototype._version = 3;
  19255. /**
  19256. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  19257. *
  19258. * @param aSourceMapConsumer The SourceMap.
  19259. */
  19260. SourceMapGenerator$8.fromSourceMap =
  19261. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  19262. var sourceRoot = aSourceMapConsumer.sourceRoot;
  19263. var generator = new SourceMapGenerator$8(Object.assign(generatorOps || {}, {
  19264. file: aSourceMapConsumer.file,
  19265. sourceRoot: sourceRoot
  19266. }));
  19267. aSourceMapConsumer.eachMapping(function (mapping) {
  19268. var newMapping = {
  19269. generated: {
  19270. line: mapping.generatedLine,
  19271. column: mapping.generatedColumn
  19272. }
  19273. };
  19274. if (mapping.source != null) {
  19275. newMapping.source = mapping.source;
  19276. if (sourceRoot != null) {
  19277. newMapping.source = util$9.relative(sourceRoot, newMapping.source);
  19278. }
  19279. newMapping.original = {
  19280. line: mapping.originalLine,
  19281. column: mapping.originalColumn
  19282. };
  19283. if (mapping.name != null) {
  19284. newMapping.name = mapping.name;
  19285. }
  19286. }
  19287. generator.addMapping(newMapping);
  19288. });
  19289. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19290. var sourceRelative = sourceFile;
  19291. if (sourceRoot !== null) {
  19292. sourceRelative = util$9.relative(sourceRoot, sourceFile);
  19293. }
  19294. if (!generator._sources.has(sourceRelative)) {
  19295. generator._sources.add(sourceRelative);
  19296. }
  19297. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19298. if (content != null) {
  19299. generator.setSourceContent(sourceFile, content);
  19300. }
  19301. });
  19302. return generator;
  19303. };
  19304. /**
  19305. * Add a single mapping from original source line and column to the generated
  19306. * source's line and column for this source map being created. The mapping
  19307. * object should have the following properties:
  19308. *
  19309. * - generated: An object with the generated line and column positions.
  19310. * - original: An object with the original line and column positions.
  19311. * - source: The original source file (relative to the sourceRoot).
  19312. * - name: An optional original token name for this mapping.
  19313. */
  19314. SourceMapGenerator$8.prototype.addMapping =
  19315. function SourceMapGenerator_addMapping(aArgs) {
  19316. var generated = util$9.getArg(aArgs, 'generated');
  19317. var original = util$9.getArg(aArgs, 'original', null);
  19318. var source = util$9.getArg(aArgs, 'source', null);
  19319. var name = util$9.getArg(aArgs, 'name', null);
  19320. if (!this._skipValidation) {
  19321. if (this._validateMapping(generated, original, source, name) === false) {
  19322. return;
  19323. }
  19324. }
  19325. if (source != null) {
  19326. source = String(source);
  19327. if (!this._sources.has(source)) {
  19328. this._sources.add(source);
  19329. }
  19330. }
  19331. if (name != null) {
  19332. name = String(name);
  19333. if (!this._names.has(name)) {
  19334. this._names.add(name);
  19335. }
  19336. }
  19337. this._mappings.add({
  19338. generatedLine: generated.line,
  19339. generatedColumn: generated.column,
  19340. originalLine: original != null && original.line,
  19341. originalColumn: original != null && original.column,
  19342. source: source,
  19343. name: name
  19344. });
  19345. };
  19346. /**
  19347. * Set the source content for a source file.
  19348. */
  19349. SourceMapGenerator$8.prototype.setSourceContent =
  19350. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  19351. var source = aSourceFile;
  19352. if (this._sourceRoot != null) {
  19353. source = util$9.relative(this._sourceRoot, source);
  19354. }
  19355. if (aSourceContent != null) {
  19356. // Add the source content to the _sourcesContents map.
  19357. // Create a new _sourcesContents map if the property is null.
  19358. if (!this._sourcesContents) {
  19359. this._sourcesContents = Object.create(null);
  19360. }
  19361. this._sourcesContents[util$9.toSetString(source)] = aSourceContent;
  19362. } else if (this._sourcesContents) {
  19363. // Remove the source file from the _sourcesContents map.
  19364. // If the _sourcesContents map is empty, set the property to null.
  19365. delete this._sourcesContents[util$9.toSetString(source)];
  19366. if (Object.keys(this._sourcesContents).length === 0) {
  19367. this._sourcesContents = null;
  19368. }
  19369. }
  19370. };
  19371. /**
  19372. * Applies the mappings of a sub-source-map for a specific source file to the
  19373. * source map being generated. Each mapping to the supplied source file is
  19374. * rewritten using the supplied source map. Note: The resolution for the
  19375. * resulting mappings is the minimium of this map and the supplied map.
  19376. *
  19377. * @param aSourceMapConsumer The source map to be applied.
  19378. * @param aSourceFile Optional. The filename of the source file.
  19379. * If omitted, SourceMapConsumer's file property will be used.
  19380. * @param aSourceMapPath Optional. The dirname of the path to the source map
  19381. * to be applied. If relative, it is relative to the SourceMapConsumer.
  19382. * This parameter is needed when the two source maps aren't in the same
  19383. * directory, and the source map to be applied contains relative source
  19384. * paths. If so, those relative source paths need to be rewritten
  19385. * relative to the SourceMapGenerator.
  19386. */
  19387. SourceMapGenerator$8.prototype.applySourceMap =
  19388. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  19389. var sourceFile = aSourceFile;
  19390. // If aSourceFile is omitted, we will use the file property of the SourceMap
  19391. if (aSourceFile == null) {
  19392. if (aSourceMapConsumer.file == null) {
  19393. throw new Error(
  19394. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  19395. 'or the source map\'s "file" property. Both were omitted.'
  19396. );
  19397. }
  19398. sourceFile = aSourceMapConsumer.file;
  19399. }
  19400. var sourceRoot = this._sourceRoot;
  19401. // Make "sourceFile" relative if an absolute Url is passed.
  19402. if (sourceRoot != null) {
  19403. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19404. }
  19405. // Applying the SourceMap can add and remove items from the sources and
  19406. // the names array.
  19407. var newSources = new ArraySet$4();
  19408. var newNames = new ArraySet$4();
  19409. // Find mappings for the "sourceFile"
  19410. this._mappings.unsortedForEach(function (mapping) {
  19411. if (mapping.source === sourceFile && mapping.originalLine != null) {
  19412. // Check if it can be mapped by the source map, then update the mapping.
  19413. var original = aSourceMapConsumer.originalPositionFor({
  19414. line: mapping.originalLine,
  19415. column: mapping.originalColumn
  19416. });
  19417. if (original.source != null) {
  19418. // Copy mapping
  19419. mapping.source = original.source;
  19420. if (aSourceMapPath != null) {
  19421. mapping.source = util$9.join(aSourceMapPath, mapping.source);
  19422. }
  19423. if (sourceRoot != null) {
  19424. mapping.source = util$9.relative(sourceRoot, mapping.source);
  19425. }
  19426. mapping.originalLine = original.line;
  19427. mapping.originalColumn = original.column;
  19428. if (original.name != null) {
  19429. mapping.name = original.name;
  19430. }
  19431. }
  19432. }
  19433. var source = mapping.source;
  19434. if (source != null && !newSources.has(source)) {
  19435. newSources.add(source);
  19436. }
  19437. var name = mapping.name;
  19438. if (name != null && !newNames.has(name)) {
  19439. newNames.add(name);
  19440. }
  19441. }, this);
  19442. this._sources = newSources;
  19443. this._names = newNames;
  19444. // Copy sourcesContents of applied map.
  19445. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19446. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19447. if (content != null) {
  19448. if (aSourceMapPath != null) {
  19449. sourceFile = util$9.join(aSourceMapPath, sourceFile);
  19450. }
  19451. if (sourceRoot != null) {
  19452. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19453. }
  19454. this.setSourceContent(sourceFile, content);
  19455. }
  19456. }, this);
  19457. };
  19458. /**
  19459. * A mapping can have one of the three levels of data:
  19460. *
  19461. * 1. Just the generated position.
  19462. * 2. The Generated position, original position, and original source.
  19463. * 3. Generated and original position, original source, as well as a name
  19464. * token.
  19465. *
  19466. * To maintain consistency, we validate that any new mapping being added falls
  19467. * in to one of these categories.
  19468. */
  19469. SourceMapGenerator$8.prototype._validateMapping =
  19470. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  19471. aName) {
  19472. // When aOriginal is truthy but has empty values for .line and .column,
  19473. // it is most likely a programmer error. In this case we throw a very
  19474. // specific error message to try to guide them the right way.
  19475. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  19476. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  19477. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  19478. 'the original mapping entirely and only map the generated position. If so, pass ' +
  19479. 'null for the original mapping instead of an object with empty or null values.';
  19480. if (this._ignoreInvalidMapping) {
  19481. if (typeof console !== 'undefined' && console.warn) {
  19482. console.warn(message);
  19483. }
  19484. return false;
  19485. } else {
  19486. throw new Error(message);
  19487. }
  19488. }
  19489. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19490. && aGenerated.line > 0 && aGenerated.column >= 0
  19491. && !aOriginal && !aSource && !aName) {
  19492. // Case 1.
  19493. return;
  19494. }
  19495. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19496. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  19497. && aGenerated.line > 0 && aGenerated.column >= 0
  19498. && aOriginal.line > 0 && aOriginal.column >= 0
  19499. && aSource) {
  19500. // Cases 2 and 3.
  19501. return;
  19502. }
  19503. else {
  19504. var message = 'Invalid mapping: ' + JSON.stringify({
  19505. generated: aGenerated,
  19506. source: aSource,
  19507. original: aOriginal,
  19508. name: aName
  19509. });
  19510. if (this._ignoreInvalidMapping) {
  19511. if (typeof console !== 'undefined' && console.warn) {
  19512. console.warn(message);
  19513. }
  19514. return false;
  19515. } else {
  19516. throw new Error(message)
  19517. }
  19518. }
  19519. };
  19520. /**
  19521. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  19522. * specified by the source map format.
  19523. */
  19524. SourceMapGenerator$8.prototype._serializeMappings =
  19525. function SourceMapGenerator_serializeMappings() {
  19526. var previousGeneratedColumn = 0;
  19527. var previousGeneratedLine = 1;
  19528. var previousOriginalColumn = 0;
  19529. var previousOriginalLine = 0;
  19530. var previousName = 0;
  19531. var previousSource = 0;
  19532. var result = '';
  19533. var next;
  19534. var mapping;
  19535. var nameIdx;
  19536. var sourceIdx;
  19537. var mappings = this._mappings.toArray();
  19538. for (var i = 0, len = mappings.length; i < len; i++) {
  19539. mapping = mappings[i];
  19540. next = '';
  19541. if (mapping.generatedLine !== previousGeneratedLine) {
  19542. previousGeneratedColumn = 0;
  19543. while (mapping.generatedLine !== previousGeneratedLine) {
  19544. next += ';';
  19545. previousGeneratedLine++;
  19546. }
  19547. }
  19548. else {
  19549. if (i > 0) {
  19550. if (!util$9.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  19551. continue;
  19552. }
  19553. next += ',';
  19554. }
  19555. }
  19556. next += base64VLQ$3.encode(mapping.generatedColumn
  19557. - previousGeneratedColumn);
  19558. previousGeneratedColumn = mapping.generatedColumn;
  19559. if (mapping.source != null) {
  19560. sourceIdx = this._sources.indexOf(mapping.source);
  19561. next += base64VLQ$3.encode(sourceIdx - previousSource);
  19562. previousSource = sourceIdx;
  19563. // lines are stored 0-based in SourceMap spec version 3
  19564. next += base64VLQ$3.encode(mapping.originalLine - 1
  19565. - previousOriginalLine);
  19566. previousOriginalLine = mapping.originalLine - 1;
  19567. next += base64VLQ$3.encode(mapping.originalColumn
  19568. - previousOriginalColumn);
  19569. previousOriginalColumn = mapping.originalColumn;
  19570. if (mapping.name != null) {
  19571. nameIdx = this._names.indexOf(mapping.name);
  19572. next += base64VLQ$3.encode(nameIdx - previousName);
  19573. previousName = nameIdx;
  19574. }
  19575. }
  19576. result += next;
  19577. }
  19578. return result;
  19579. };
  19580. SourceMapGenerator$8.prototype._generateSourcesContent =
  19581. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  19582. return aSources.map(function (source) {
  19583. if (!this._sourcesContents) {
  19584. return null;
  19585. }
  19586. if (aSourceRoot != null) {
  19587. source = util$9.relative(aSourceRoot, source);
  19588. }
  19589. var key = util$9.toSetString(source);
  19590. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  19591. ? this._sourcesContents[key]
  19592. : null;
  19593. }, this);
  19594. };
  19595. /**
  19596. * Externalize the source map.
  19597. */
  19598. SourceMapGenerator$8.prototype.toJSON =
  19599. function SourceMapGenerator_toJSON() {
  19600. var map = {
  19601. version: this._version,
  19602. sources: this._sources.toArray(),
  19603. names: this._names.toArray(),
  19604. mappings: this._serializeMappings()
  19605. };
  19606. if (this._file != null) {
  19607. map.file = this._file;
  19608. }
  19609. if (this._sourceRoot != null) {
  19610. map.sourceRoot = this._sourceRoot;
  19611. }
  19612. if (this._sourcesContents) {
  19613. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  19614. }
  19615. return map;
  19616. };
  19617. /**
  19618. * Render the source map being generated to a string.
  19619. */
  19620. SourceMapGenerator$8.prototype.toString =
  19621. function SourceMapGenerator_toString() {
  19622. return JSON.stringify(this.toJSON());
  19623. };
  19624. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator$8;
  19625. var sourceMapConsumer$1 = {};
  19626. var binarySearch$3 = {};
  19627. /* -*- Mode: js; js-indent-level: 2; -*- */
  19628. (function (exports) {
  19629. /*
  19630. * Copyright 2011 Mozilla Foundation and contributors
  19631. * Licensed under the New BSD license. See LICENSE or:
  19632. * http://opensource.org/licenses/BSD-3-Clause
  19633. */
  19634. exports.GREATEST_LOWER_BOUND = 1;
  19635. exports.LEAST_UPPER_BOUND = 2;
  19636. /**
  19637. * Recursive implementation of binary search.
  19638. *
  19639. * @param aLow Indices here and lower do not contain the needle.
  19640. * @param aHigh Indices here and higher do not contain the needle.
  19641. * @param aNeedle The element being searched for.
  19642. * @param aHaystack The non-empty array being searched.
  19643. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  19644. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19645. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19646. * closest element that is smaller than or greater than the one we are
  19647. * searching for, respectively, if the exact element cannot be found.
  19648. */
  19649. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  19650. // This function terminates when one of the following is true:
  19651. //
  19652. // 1. We find the exact element we are looking for.
  19653. //
  19654. // 2. We did not find the exact element, but we can return the index of
  19655. // the next-closest element.
  19656. //
  19657. // 3. We did not find the exact element, and there is no next-closest
  19658. // element than the one we are searching for, so we return -1.
  19659. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  19660. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  19661. if (cmp === 0) {
  19662. // Found the element we are looking for.
  19663. return mid;
  19664. }
  19665. else if (cmp > 0) {
  19666. // Our needle is greater than aHaystack[mid].
  19667. if (aHigh - mid > 1) {
  19668. // The element is in the upper half.
  19669. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  19670. }
  19671. // The exact needle element was not found in this haystack. Determine if
  19672. // we are in termination case (3) or (2) and return the appropriate thing.
  19673. if (aBias == exports.LEAST_UPPER_BOUND) {
  19674. return aHigh < aHaystack.length ? aHigh : -1;
  19675. } else {
  19676. return mid;
  19677. }
  19678. }
  19679. else {
  19680. // Our needle is less than aHaystack[mid].
  19681. if (mid - aLow > 1) {
  19682. // The element is in the lower half.
  19683. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  19684. }
  19685. // we are in termination case (3) or (2) and return the appropriate thing.
  19686. if (aBias == exports.LEAST_UPPER_BOUND) {
  19687. return mid;
  19688. } else {
  19689. return aLow < 0 ? -1 : aLow;
  19690. }
  19691. }
  19692. }
  19693. /**
  19694. * This is an implementation of binary search which will always try and return
  19695. * the index of the closest element if there is no exact hit. This is because
  19696. * mappings between original and generated line/col pairs are single points,
  19697. * and there is an implicit region between each of them, so a miss just means
  19698. * that you aren't on the very start of a region.
  19699. *
  19700. * @param aNeedle The element you are looking for.
  19701. * @param aHaystack The array that is being searched.
  19702. * @param aCompare A function which takes the needle and an element in the
  19703. * array and returns -1, 0, or 1 depending on whether the needle is less
  19704. * than, equal to, or greater than the element, respectively.
  19705. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19706. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19707. * closest element that is smaller than or greater than the one we are
  19708. * searching for, respectively, if the exact element cannot be found.
  19709. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  19710. */
  19711. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  19712. if (aHaystack.length === 0) {
  19713. return -1;
  19714. }
  19715. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  19716. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  19717. if (index < 0) {
  19718. return -1;
  19719. }
  19720. // We have found either the exact element, or the next-closest element than
  19721. // the one we are searching for. However, there may be more than one such
  19722. // element. Make sure we always return the smallest of these.
  19723. while (index - 1 >= 0) {
  19724. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  19725. break;
  19726. }
  19727. --index;
  19728. }
  19729. return index;
  19730. };
  19731. } (binarySearch$3));
  19732. var quickSort$3 = {};
  19733. /* -*- Mode: js; js-indent-level: 2; -*- */
  19734. /*
  19735. * Copyright 2011 Mozilla Foundation and contributors
  19736. * Licensed under the New BSD license. See LICENSE or:
  19737. * http://opensource.org/licenses/BSD-3-Clause
  19738. */
  19739. // It turns out that some (most?) JavaScript engines don't self-host
  19740. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  19741. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  19742. // custom comparator function, calling back and forth between the VM's C++ and
  19743. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  19744. // worse generated code for the comparator function than would be optimal. In
  19745. // fact, when sorting with a comparator, these costs outweigh the benefits of
  19746. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  19747. // a ~3500ms mean speed-up in `bench/bench.html`.
  19748. function SortTemplate(comparator) {
  19749. /**
  19750. * Swap the elements indexed by `x` and `y` in the array `ary`.
  19751. *
  19752. * @param {Array} ary
  19753. * The array.
  19754. * @param {Number} x
  19755. * The index of the first item.
  19756. * @param {Number} y
  19757. * The index of the second item.
  19758. */
  19759. function swap(ary, x, y) {
  19760. var temp = ary[x];
  19761. ary[x] = ary[y];
  19762. ary[y] = temp;
  19763. }
  19764. /**
  19765. * Returns a random integer within the range `low .. high` inclusive.
  19766. *
  19767. * @param {Number} low
  19768. * The lower bound on the range.
  19769. * @param {Number} high
  19770. * The upper bound on the range.
  19771. */
  19772. function randomIntInRange(low, high) {
  19773. return Math.round(low + (Math.random() * (high - low)));
  19774. }
  19775. /**
  19776. * The Quick Sort algorithm.
  19777. *
  19778. * @param {Array} ary
  19779. * An array to sort.
  19780. * @param {function} comparator
  19781. * Function to use to compare two items.
  19782. * @param {Number} p
  19783. * Start index of the array
  19784. * @param {Number} r
  19785. * End index of the array
  19786. */
  19787. function doQuickSort(ary, comparator, p, r) {
  19788. // If our lower bound is less than our upper bound, we (1) partition the
  19789. // array into two pieces and (2) recurse on each half. If it is not, this is
  19790. // the empty array and our base case.
  19791. if (p < r) {
  19792. // (1) Partitioning.
  19793. //
  19794. // The partitioning chooses a pivot between `p` and `r` and moves all
  19795. // elements that are less than or equal to the pivot to the before it, and
  19796. // all the elements that are greater than it after it. The effect is that
  19797. // once partition is done, the pivot is in the exact place it will be when
  19798. // the array is put in sorted order, and it will not need to be moved
  19799. // again. This runs in O(n) time.
  19800. // Always choose a random pivot so that an input array which is reverse
  19801. // sorted does not cause O(n^2) running time.
  19802. var pivotIndex = randomIntInRange(p, r);
  19803. var i = p - 1;
  19804. swap(ary, pivotIndex, r);
  19805. var pivot = ary[r];
  19806. // Immediately after `j` is incremented in this loop, the following hold
  19807. // true:
  19808. //
  19809. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  19810. //
  19811. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  19812. for (var j = p; j < r; j++) {
  19813. if (comparator(ary[j], pivot, false) <= 0) {
  19814. i += 1;
  19815. swap(ary, i, j);
  19816. }
  19817. }
  19818. swap(ary, i + 1, j);
  19819. var q = i + 1;
  19820. // (2) Recurse on each half.
  19821. doQuickSort(ary, comparator, p, q - 1);
  19822. doQuickSort(ary, comparator, q + 1, r);
  19823. }
  19824. }
  19825. return doQuickSort;
  19826. }
  19827. function cloneSort(comparator) {
  19828. let template = SortTemplate.toString();
  19829. let templateFn = new Function(`return ${template}`)();
  19830. return templateFn(comparator);
  19831. }
  19832. /**
  19833. * Sort the given array in-place with the given comparator function.
  19834. *
  19835. * @param {Array} ary
  19836. * An array to sort.
  19837. * @param {function} comparator
  19838. * Function to use to compare two items.
  19839. */
  19840. let sortCache = new WeakMap();
  19841. quickSort$3.quickSort = function (ary, comparator, start = 0) {
  19842. let doQuickSort = sortCache.get(comparator);
  19843. if (doQuickSort === void 0) {
  19844. doQuickSort = cloneSort(comparator);
  19845. sortCache.set(comparator, doQuickSort);
  19846. }
  19847. doQuickSort(ary, comparator, start, ary.length - 1);
  19848. };
  19849. /* -*- Mode: js; js-indent-level: 2; -*- */
  19850. /*
  19851. * Copyright 2011 Mozilla Foundation and contributors
  19852. * Licensed under the New BSD license. See LICENSE or:
  19853. * http://opensource.org/licenses/BSD-3-Clause
  19854. */
  19855. var util$8 = util$c;
  19856. var binarySearch$2 = binarySearch$3;
  19857. var ArraySet$3 = arraySet$1.ArraySet;
  19858. var base64VLQ$2 = base64Vlq$1;
  19859. var quickSort$2 = quickSort$3.quickSort;
  19860. function SourceMapConsumer$6(aSourceMap, aSourceMapURL) {
  19861. var sourceMap = aSourceMap;
  19862. if (typeof aSourceMap === 'string') {
  19863. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  19864. }
  19865. return sourceMap.sections != null
  19866. ? new IndexedSourceMapConsumer$1(sourceMap, aSourceMapURL)
  19867. : new BasicSourceMapConsumer$1(sourceMap, aSourceMapURL);
  19868. }
  19869. SourceMapConsumer$6.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  19870. return BasicSourceMapConsumer$1.fromSourceMap(aSourceMap, aSourceMapURL);
  19871. };
  19872. /**
  19873. * The version of the source mapping spec that we are consuming.
  19874. */
  19875. SourceMapConsumer$6.prototype._version = 3;
  19876. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  19877. // parsed mapping coordinates from the source map's "mappings" attribute. They
  19878. // are lazily instantiated, accessed via the `_generatedMappings` and
  19879. // `_originalMappings` getters respectively, and we only parse the mappings
  19880. // and create these arrays once queried for a source location. We jump through
  19881. // these hoops because there can be many thousands of mappings, and parsing
  19882. // them is expensive, so we only want to do it if we must.
  19883. //
  19884. // Each object in the arrays is of the form:
  19885. //
  19886. // {
  19887. // generatedLine: The line number in the generated code,
  19888. // generatedColumn: The column number in the generated code,
  19889. // source: The path to the original source file that generated this
  19890. // chunk of code,
  19891. // originalLine: The line number in the original source that
  19892. // corresponds to this chunk of generated code,
  19893. // originalColumn: The column number in the original source that
  19894. // corresponds to this chunk of generated code,
  19895. // name: The name of the original symbol which generated this chunk of
  19896. // code.
  19897. // }
  19898. //
  19899. // All properties except for `generatedLine` and `generatedColumn` can be
  19900. // `null`.
  19901. //
  19902. // `_generatedMappings` is ordered by the generated positions.
  19903. //
  19904. // `_originalMappings` is ordered by the original positions.
  19905. SourceMapConsumer$6.prototype.__generatedMappings = null;
  19906. Object.defineProperty(SourceMapConsumer$6.prototype, '_generatedMappings', {
  19907. configurable: true,
  19908. enumerable: true,
  19909. get: function () {
  19910. if (!this.__generatedMappings) {
  19911. this._parseMappings(this._mappings, this.sourceRoot);
  19912. }
  19913. return this.__generatedMappings;
  19914. }
  19915. });
  19916. SourceMapConsumer$6.prototype.__originalMappings = null;
  19917. Object.defineProperty(SourceMapConsumer$6.prototype, '_originalMappings', {
  19918. configurable: true,
  19919. enumerable: true,
  19920. get: function () {
  19921. if (!this.__originalMappings) {
  19922. this._parseMappings(this._mappings, this.sourceRoot);
  19923. }
  19924. return this.__originalMappings;
  19925. }
  19926. });
  19927. SourceMapConsumer$6.prototype._charIsMappingSeparator =
  19928. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  19929. var c = aStr.charAt(index);
  19930. return c === ";" || c === ",";
  19931. };
  19932. /**
  19933. * Parse the mappings in a string in to a data structure which we can easily
  19934. * query (the ordered arrays in the `this.__generatedMappings` and
  19935. * `this.__originalMappings` properties).
  19936. */
  19937. SourceMapConsumer$6.prototype._parseMappings =
  19938. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  19939. throw new Error("Subclasses must implement _parseMappings");
  19940. };
  19941. SourceMapConsumer$6.GENERATED_ORDER = 1;
  19942. SourceMapConsumer$6.ORIGINAL_ORDER = 2;
  19943. SourceMapConsumer$6.GREATEST_LOWER_BOUND = 1;
  19944. SourceMapConsumer$6.LEAST_UPPER_BOUND = 2;
  19945. /**
  19946. * Iterate over each mapping between an original source/line/column and a
  19947. * generated line/column in this source map.
  19948. *
  19949. * @param Function aCallback
  19950. * The function that is called with each mapping.
  19951. * @param Object aContext
  19952. * Optional. If specified, this object will be the value of `this` every
  19953. * time that `aCallback` is called.
  19954. * @param aOrder
  19955. * Either `SourceMapConsumer.GENERATED_ORDER` or
  19956. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  19957. * iterate over the mappings sorted by the generated file's line/column
  19958. * order or the original's source/line/column order, respectively. Defaults to
  19959. * `SourceMapConsumer.GENERATED_ORDER`.
  19960. */
  19961. SourceMapConsumer$6.prototype.eachMapping =
  19962. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  19963. var context = aContext || null;
  19964. var order = aOrder || SourceMapConsumer$6.GENERATED_ORDER;
  19965. var mappings;
  19966. switch (order) {
  19967. case SourceMapConsumer$6.GENERATED_ORDER:
  19968. mappings = this._generatedMappings;
  19969. break;
  19970. case SourceMapConsumer$6.ORIGINAL_ORDER:
  19971. mappings = this._originalMappings;
  19972. break;
  19973. default:
  19974. throw new Error("Unknown order of iteration.");
  19975. }
  19976. var sourceRoot = this.sourceRoot;
  19977. var boundCallback = aCallback.bind(context);
  19978. var names = this._names;
  19979. var sources = this._sources;
  19980. var sourceMapURL = this._sourceMapURL;
  19981. for (var i = 0, n = mappings.length; i < n; i++) {
  19982. var mapping = mappings[i];
  19983. var source = mapping.source === null ? null : sources.at(mapping.source);
  19984. source = util$8.computeSourceURL(sourceRoot, source, sourceMapURL);
  19985. boundCallback({
  19986. source: source,
  19987. generatedLine: mapping.generatedLine,
  19988. generatedColumn: mapping.generatedColumn,
  19989. originalLine: mapping.originalLine,
  19990. originalColumn: mapping.originalColumn,
  19991. name: mapping.name === null ? null : names.at(mapping.name)
  19992. });
  19993. }
  19994. };
  19995. /**
  19996. * Returns all generated line and column information for the original source,
  19997. * line, and column provided. If no column is provided, returns all mappings
  19998. * corresponding to a either the line we are searching for or the next
  19999. * closest line that has any mappings. Otherwise, returns all mappings
  20000. * corresponding to the given line and either the column we are searching for
  20001. * or the next closest column that has any offsets.
  20002. *
  20003. * The only argument is an object with the following properties:
  20004. *
  20005. * - source: The filename of the original source.
  20006. * - line: The line number in the original source. The line number is 1-based.
  20007. * - column: Optional. the column number in the original source.
  20008. * The column number is 0-based.
  20009. *
  20010. * and an array of objects is returned, each with the following properties:
  20011. *
  20012. * - line: The line number in the generated source, or null. The
  20013. * line number is 1-based.
  20014. * - column: The column number in the generated source, or null.
  20015. * The column number is 0-based.
  20016. */
  20017. SourceMapConsumer$6.prototype.allGeneratedPositionsFor =
  20018. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  20019. var line = util$8.getArg(aArgs, 'line');
  20020. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  20021. // returns the index of the closest mapping less than the needle. By
  20022. // setting needle.originalColumn to 0, we thus find the last mapping for
  20023. // the given line, provided such a mapping exists.
  20024. var needle = {
  20025. source: util$8.getArg(aArgs, 'source'),
  20026. originalLine: line,
  20027. originalColumn: util$8.getArg(aArgs, 'column', 0)
  20028. };
  20029. needle.source = this._findSourceIndex(needle.source);
  20030. if (needle.source < 0) {
  20031. return [];
  20032. }
  20033. var mappings = [];
  20034. var index = this._findMapping(needle,
  20035. this._originalMappings,
  20036. "originalLine",
  20037. "originalColumn",
  20038. util$8.compareByOriginalPositions,
  20039. binarySearch$2.LEAST_UPPER_BOUND);
  20040. if (index >= 0) {
  20041. var mapping = this._originalMappings[index];
  20042. if (aArgs.column === undefined) {
  20043. var originalLine = mapping.originalLine;
  20044. // Iterate until either we run out of mappings, or we run into
  20045. // a mapping for a different line than the one we found. Since
  20046. // mappings are sorted, this is guaranteed to find all mappings for
  20047. // the line we found.
  20048. while (mapping && mapping.originalLine === originalLine) {
  20049. mappings.push({
  20050. line: util$8.getArg(mapping, 'generatedLine', null),
  20051. column: util$8.getArg(mapping, 'generatedColumn', null),
  20052. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20053. });
  20054. mapping = this._originalMappings[++index];
  20055. }
  20056. } else {
  20057. var originalColumn = mapping.originalColumn;
  20058. // Iterate until either we run out of mappings, or we run into
  20059. // a mapping for a different line than the one we were searching for.
  20060. // Since mappings are sorted, this is guaranteed to find all mappings for
  20061. // the line we are searching for.
  20062. while (mapping &&
  20063. mapping.originalLine === line &&
  20064. mapping.originalColumn == originalColumn) {
  20065. mappings.push({
  20066. line: util$8.getArg(mapping, 'generatedLine', null),
  20067. column: util$8.getArg(mapping, 'generatedColumn', null),
  20068. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20069. });
  20070. mapping = this._originalMappings[++index];
  20071. }
  20072. }
  20073. }
  20074. return mappings;
  20075. };
  20076. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer$6;
  20077. /**
  20078. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20079. * query for information about the original file positions by giving it a file
  20080. * position in the generated source.
  20081. *
  20082. * The first parameter is the raw source map (either as a JSON string, or
  20083. * already parsed to an object). According to the spec, source maps have the
  20084. * following attributes:
  20085. *
  20086. * - version: Which version of the source map spec this map is following.
  20087. * - sources: An array of URLs to the original source files.
  20088. * - names: An array of identifiers which can be referrenced by individual mappings.
  20089. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20090. * - sourcesContent: Optional. An array of contents of the original source files.
  20091. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20092. * - file: Optional. The generated file this source map is associated with.
  20093. *
  20094. * Here is an example source map, taken from the source map spec[0]:
  20095. *
  20096. * {
  20097. * version : 3,
  20098. * file: "out.js",
  20099. * sourceRoot : "",
  20100. * sources: ["foo.js", "bar.js"],
  20101. * names: ["src", "maps", "are", "fun"],
  20102. * mappings: "AA,AB;;ABCDE;"
  20103. * }
  20104. *
  20105. * The second parameter, if given, is a string whose value is the URL
  20106. * at which the source map was found. This URL is used to compute the
  20107. * sources array.
  20108. *
  20109. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  20110. */
  20111. function BasicSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20112. var sourceMap = aSourceMap;
  20113. if (typeof aSourceMap === 'string') {
  20114. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20115. }
  20116. var version = util$8.getArg(sourceMap, 'version');
  20117. var sources = util$8.getArg(sourceMap, 'sources');
  20118. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  20119. // requires the array) to play nice here.
  20120. var names = util$8.getArg(sourceMap, 'names', []);
  20121. var sourceRoot = util$8.getArg(sourceMap, 'sourceRoot', null);
  20122. var sourcesContent = util$8.getArg(sourceMap, 'sourcesContent', null);
  20123. var mappings = util$8.getArg(sourceMap, 'mappings');
  20124. var file = util$8.getArg(sourceMap, 'file', null);
  20125. // Once again, Sass deviates from the spec and supplies the version as a
  20126. // string rather than a number, so we use loose equality checking here.
  20127. if (version != this._version) {
  20128. throw new Error('Unsupported version: ' + version);
  20129. }
  20130. if (sourceRoot) {
  20131. sourceRoot = util$8.normalize(sourceRoot);
  20132. }
  20133. sources = sources
  20134. .map(String)
  20135. // Some source maps produce relative source paths like "./foo.js" instead of
  20136. // "foo.js". Normalize these first so that future comparisons will succeed.
  20137. // See bugzil.la/1090768.
  20138. .map(util$8.normalize)
  20139. // Always ensure that absolute sources are internally stored relative to
  20140. // the source root, if the source root is absolute. Not doing this would
  20141. // be particularly problematic when the source root is a prefix of the
  20142. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  20143. .map(function (source) {
  20144. return sourceRoot && util$8.isAbsolute(sourceRoot) && util$8.isAbsolute(source)
  20145. ? util$8.relative(sourceRoot, source)
  20146. : source;
  20147. });
  20148. // Pass `true` below to allow duplicate names and sources. While source maps
  20149. // are intended to be compressed and deduplicated, the TypeScript compiler
  20150. // sometimes generates source maps with duplicates in them. See Github issue
  20151. // #72 and bugzil.la/889492.
  20152. this._names = ArraySet$3.fromArray(names.map(String), true);
  20153. this._sources = ArraySet$3.fromArray(sources, true);
  20154. this._absoluteSources = this._sources.toArray().map(function (s) {
  20155. return util$8.computeSourceURL(sourceRoot, s, aSourceMapURL);
  20156. });
  20157. this.sourceRoot = sourceRoot;
  20158. this.sourcesContent = sourcesContent;
  20159. this._mappings = mappings;
  20160. this._sourceMapURL = aSourceMapURL;
  20161. this.file = file;
  20162. }
  20163. BasicSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20164. BasicSourceMapConsumer$1.prototype.consumer = SourceMapConsumer$6;
  20165. /**
  20166. * Utility function to find the index of a source. Returns -1 if not
  20167. * found.
  20168. */
  20169. BasicSourceMapConsumer$1.prototype._findSourceIndex = function(aSource) {
  20170. var relativeSource = aSource;
  20171. if (this.sourceRoot != null) {
  20172. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20173. }
  20174. if (this._sources.has(relativeSource)) {
  20175. return this._sources.indexOf(relativeSource);
  20176. }
  20177. // Maybe aSource is an absolute URL as returned by |sources|. In
  20178. // this case we can't simply undo the transform.
  20179. var i;
  20180. for (i = 0; i < this._absoluteSources.length; ++i) {
  20181. if (this._absoluteSources[i] == aSource) {
  20182. return i;
  20183. }
  20184. }
  20185. return -1;
  20186. };
  20187. /**
  20188. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  20189. *
  20190. * @param SourceMapGenerator aSourceMap
  20191. * The source map that will be consumed.
  20192. * @param String aSourceMapURL
  20193. * The URL at which the source map can be found (optional)
  20194. * @returns BasicSourceMapConsumer
  20195. */
  20196. BasicSourceMapConsumer$1.fromSourceMap =
  20197. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  20198. var smc = Object.create(BasicSourceMapConsumer$1.prototype);
  20199. var names = smc._names = ArraySet$3.fromArray(aSourceMap._names.toArray(), true);
  20200. var sources = smc._sources = ArraySet$3.fromArray(aSourceMap._sources.toArray(), true);
  20201. smc.sourceRoot = aSourceMap._sourceRoot;
  20202. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  20203. smc.sourceRoot);
  20204. smc.file = aSourceMap._file;
  20205. smc._sourceMapURL = aSourceMapURL;
  20206. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  20207. return util$8.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  20208. });
  20209. // Because we are modifying the entries (by converting string sources and
  20210. // names to indices into the sources and names ArraySets), we have to make
  20211. // a copy of the entry or else bad things happen. Shared mutable state
  20212. // strikes again! See github issue #191.
  20213. var generatedMappings = aSourceMap._mappings.toArray().slice();
  20214. var destGeneratedMappings = smc.__generatedMappings = [];
  20215. var destOriginalMappings = smc.__originalMappings = [];
  20216. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  20217. var srcMapping = generatedMappings[i];
  20218. var destMapping = new Mapping$1;
  20219. destMapping.generatedLine = srcMapping.generatedLine;
  20220. destMapping.generatedColumn = srcMapping.generatedColumn;
  20221. if (srcMapping.source) {
  20222. destMapping.source = sources.indexOf(srcMapping.source);
  20223. destMapping.originalLine = srcMapping.originalLine;
  20224. destMapping.originalColumn = srcMapping.originalColumn;
  20225. if (srcMapping.name) {
  20226. destMapping.name = names.indexOf(srcMapping.name);
  20227. }
  20228. destOriginalMappings.push(destMapping);
  20229. }
  20230. destGeneratedMappings.push(destMapping);
  20231. }
  20232. quickSort$2(smc.__originalMappings, util$8.compareByOriginalPositions);
  20233. return smc;
  20234. };
  20235. /**
  20236. * The version of the source mapping spec that we are consuming.
  20237. */
  20238. BasicSourceMapConsumer$1.prototype._version = 3;
  20239. /**
  20240. * The list of original sources.
  20241. */
  20242. Object.defineProperty(BasicSourceMapConsumer$1.prototype, 'sources', {
  20243. get: function () {
  20244. return this._absoluteSources.slice();
  20245. }
  20246. });
  20247. /**
  20248. * Provide the JIT with a nice shape / hidden class.
  20249. */
  20250. function Mapping$1() {
  20251. this.generatedLine = 0;
  20252. this.generatedColumn = 0;
  20253. this.source = null;
  20254. this.originalLine = null;
  20255. this.originalColumn = null;
  20256. this.name = null;
  20257. }
  20258. /**
  20259. * Parse the mappings in a string in to a data structure which we can easily
  20260. * query (the ordered arrays in the `this.__generatedMappings` and
  20261. * `this.__originalMappings` properties).
  20262. */
  20263. const compareGenerated = util$8.compareByGeneratedPositionsDeflatedNoLine;
  20264. function sortGenerated(array, start) {
  20265. let l = array.length;
  20266. let n = array.length - start;
  20267. if (n <= 1) {
  20268. return;
  20269. } else if (n == 2) {
  20270. let a = array[start];
  20271. let b = array[start + 1];
  20272. if (compareGenerated(a, b) > 0) {
  20273. array[start] = b;
  20274. array[start + 1] = a;
  20275. }
  20276. } else if (n < 20) {
  20277. for (let i = start; i < l; i++) {
  20278. for (let j = i; j > start; j--) {
  20279. let a = array[j - 1];
  20280. let b = array[j];
  20281. if (compareGenerated(a, b) <= 0) {
  20282. break;
  20283. }
  20284. array[j - 1] = b;
  20285. array[j] = a;
  20286. }
  20287. }
  20288. } else {
  20289. quickSort$2(array, compareGenerated, start);
  20290. }
  20291. }
  20292. BasicSourceMapConsumer$1.prototype._parseMappings =
  20293. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20294. var generatedLine = 1;
  20295. var previousGeneratedColumn = 0;
  20296. var previousOriginalLine = 0;
  20297. var previousOriginalColumn = 0;
  20298. var previousSource = 0;
  20299. var previousName = 0;
  20300. var length = aStr.length;
  20301. var index = 0;
  20302. var temp = {};
  20303. var originalMappings = [];
  20304. var generatedMappings = [];
  20305. var mapping, segment, end, value;
  20306. let subarrayStart = 0;
  20307. while (index < length) {
  20308. if (aStr.charAt(index) === ';') {
  20309. generatedLine++;
  20310. index++;
  20311. previousGeneratedColumn = 0;
  20312. sortGenerated(generatedMappings, subarrayStart);
  20313. subarrayStart = generatedMappings.length;
  20314. }
  20315. else if (aStr.charAt(index) === ',') {
  20316. index++;
  20317. }
  20318. else {
  20319. mapping = new Mapping$1();
  20320. mapping.generatedLine = generatedLine;
  20321. for (end = index; end < length; end++) {
  20322. if (this._charIsMappingSeparator(aStr, end)) {
  20323. break;
  20324. }
  20325. }
  20326. aStr.slice(index, end);
  20327. segment = [];
  20328. while (index < end) {
  20329. base64VLQ$2.decode(aStr, index, temp);
  20330. value = temp.value;
  20331. index = temp.rest;
  20332. segment.push(value);
  20333. }
  20334. if (segment.length === 2) {
  20335. throw new Error('Found a source, but no line and column');
  20336. }
  20337. if (segment.length === 3) {
  20338. throw new Error('Found a source and line, but no column');
  20339. }
  20340. // Generated column.
  20341. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  20342. previousGeneratedColumn = mapping.generatedColumn;
  20343. if (segment.length > 1) {
  20344. // Original source.
  20345. mapping.source = previousSource + segment[1];
  20346. previousSource += segment[1];
  20347. // Original line.
  20348. mapping.originalLine = previousOriginalLine + segment[2];
  20349. previousOriginalLine = mapping.originalLine;
  20350. // Lines are stored 0-based
  20351. mapping.originalLine += 1;
  20352. // Original column.
  20353. mapping.originalColumn = previousOriginalColumn + segment[3];
  20354. previousOriginalColumn = mapping.originalColumn;
  20355. if (segment.length > 4) {
  20356. // Original name.
  20357. mapping.name = previousName + segment[4];
  20358. previousName += segment[4];
  20359. }
  20360. }
  20361. generatedMappings.push(mapping);
  20362. if (typeof mapping.originalLine === 'number') {
  20363. let currentSource = mapping.source;
  20364. while (originalMappings.length <= currentSource) {
  20365. originalMappings.push(null);
  20366. }
  20367. if (originalMappings[currentSource] === null) {
  20368. originalMappings[currentSource] = [];
  20369. }
  20370. originalMappings[currentSource].push(mapping);
  20371. }
  20372. }
  20373. }
  20374. sortGenerated(generatedMappings, subarrayStart);
  20375. this.__generatedMappings = generatedMappings;
  20376. for (var i = 0; i < originalMappings.length; i++) {
  20377. if (originalMappings[i] != null) {
  20378. quickSort$2(originalMappings[i], util$8.compareByOriginalPositionsNoSource);
  20379. }
  20380. }
  20381. this.__originalMappings = [].concat(...originalMappings);
  20382. };
  20383. /**
  20384. * Find the mapping that best matches the hypothetical "needle" mapping that
  20385. * we are searching for in the given "haystack" of mappings.
  20386. */
  20387. BasicSourceMapConsumer$1.prototype._findMapping =
  20388. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  20389. aColumnName, aComparator, aBias) {
  20390. // To return the position we are searching for, we must first find the
  20391. // mapping for the given position and then return the opposite position it
  20392. // points to. Because the mappings are sorted, we can use binary search to
  20393. // find the best mapping.
  20394. if (aNeedle[aLineName] <= 0) {
  20395. throw new TypeError('Line must be greater than or equal to 1, got '
  20396. + aNeedle[aLineName]);
  20397. }
  20398. if (aNeedle[aColumnName] < 0) {
  20399. throw new TypeError('Column must be greater than or equal to 0, got '
  20400. + aNeedle[aColumnName]);
  20401. }
  20402. return binarySearch$2.search(aNeedle, aMappings, aComparator, aBias);
  20403. };
  20404. /**
  20405. * Compute the last column for each generated mapping. The last column is
  20406. * inclusive.
  20407. */
  20408. BasicSourceMapConsumer$1.prototype.computeColumnSpans =
  20409. function SourceMapConsumer_computeColumnSpans() {
  20410. for (var index = 0; index < this._generatedMappings.length; ++index) {
  20411. var mapping = this._generatedMappings[index];
  20412. // Mappings do not contain a field for the last generated columnt. We
  20413. // can come up with an optimistic estimate, however, by assuming that
  20414. // mappings are contiguous (i.e. given two consecutive mappings, the
  20415. // first mapping ends where the second one starts).
  20416. if (index + 1 < this._generatedMappings.length) {
  20417. var nextMapping = this._generatedMappings[index + 1];
  20418. if (mapping.generatedLine === nextMapping.generatedLine) {
  20419. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  20420. continue;
  20421. }
  20422. }
  20423. // The last mapping for each line spans the entire line.
  20424. mapping.lastGeneratedColumn = Infinity;
  20425. }
  20426. };
  20427. /**
  20428. * Returns the original source, line, and column information for the generated
  20429. * source's line and column positions provided. The only argument is an object
  20430. * with the following properties:
  20431. *
  20432. * - line: The line number in the generated source. The line number
  20433. * is 1-based.
  20434. * - column: The column number in the generated source. The column
  20435. * number is 0-based.
  20436. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20437. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20438. * closest element that is smaller than or greater than the one we are
  20439. * searching for, respectively, if the exact element cannot be found.
  20440. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20441. *
  20442. * and an object is returned with the following properties:
  20443. *
  20444. * - source: The original source file, or null.
  20445. * - line: The line number in the original source, or null. The
  20446. * line number is 1-based.
  20447. * - column: The column number in the original source, or null. The
  20448. * column number is 0-based.
  20449. * - name: The original identifier, or null.
  20450. */
  20451. BasicSourceMapConsumer$1.prototype.originalPositionFor =
  20452. function SourceMapConsumer_originalPositionFor(aArgs) {
  20453. var needle = {
  20454. generatedLine: util$8.getArg(aArgs, 'line'),
  20455. generatedColumn: util$8.getArg(aArgs, 'column')
  20456. };
  20457. var index = this._findMapping(
  20458. needle,
  20459. this._generatedMappings,
  20460. "generatedLine",
  20461. "generatedColumn",
  20462. util$8.compareByGeneratedPositionsDeflated,
  20463. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20464. );
  20465. if (index >= 0) {
  20466. var mapping = this._generatedMappings[index];
  20467. if (mapping.generatedLine === needle.generatedLine) {
  20468. var source = util$8.getArg(mapping, 'source', null);
  20469. if (source !== null) {
  20470. source = this._sources.at(source);
  20471. source = util$8.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  20472. }
  20473. var name = util$8.getArg(mapping, 'name', null);
  20474. if (name !== null) {
  20475. name = this._names.at(name);
  20476. }
  20477. return {
  20478. source: source,
  20479. line: util$8.getArg(mapping, 'originalLine', null),
  20480. column: util$8.getArg(mapping, 'originalColumn', null),
  20481. name: name
  20482. };
  20483. }
  20484. }
  20485. return {
  20486. source: null,
  20487. line: null,
  20488. column: null,
  20489. name: null
  20490. };
  20491. };
  20492. /**
  20493. * Return true if we have the source content for every source in the source
  20494. * map, false otherwise.
  20495. */
  20496. BasicSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20497. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  20498. if (!this.sourcesContent) {
  20499. return false;
  20500. }
  20501. return this.sourcesContent.length >= this._sources.size() &&
  20502. !this.sourcesContent.some(function (sc) { return sc == null; });
  20503. };
  20504. /**
  20505. * Returns the original source content. The only argument is the url of the
  20506. * original source file. Returns null if no original source content is
  20507. * available.
  20508. */
  20509. BasicSourceMapConsumer$1.prototype.sourceContentFor =
  20510. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20511. if (!this.sourcesContent) {
  20512. return null;
  20513. }
  20514. var index = this._findSourceIndex(aSource);
  20515. if (index >= 0) {
  20516. return this.sourcesContent[index];
  20517. }
  20518. var relativeSource = aSource;
  20519. if (this.sourceRoot != null) {
  20520. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20521. }
  20522. var url;
  20523. if (this.sourceRoot != null
  20524. && (url = util$8.urlParse(this.sourceRoot))) {
  20525. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  20526. // many users. We can help them out when they expect file:// URIs to
  20527. // behave like it would if they were running a local HTTP server. See
  20528. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  20529. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  20530. if (url.scheme == "file"
  20531. && this._sources.has(fileUriAbsPath)) {
  20532. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  20533. }
  20534. if ((!url.path || url.path == "/")
  20535. && this._sources.has("/" + relativeSource)) {
  20536. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  20537. }
  20538. }
  20539. // This function is used recursively from
  20540. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  20541. // don't want to throw if we can't find the source - we just want to
  20542. // return null, so we provide a flag to exit gracefully.
  20543. if (nullOnMissing) {
  20544. return null;
  20545. }
  20546. else {
  20547. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  20548. }
  20549. };
  20550. /**
  20551. * Returns the generated line and column information for the original source,
  20552. * line, and column positions provided. The only argument is an object with
  20553. * the following properties:
  20554. *
  20555. * - source: The filename of the original source.
  20556. * - line: The line number in the original source. The line number
  20557. * is 1-based.
  20558. * - column: The column number in the original source. The column
  20559. * number is 0-based.
  20560. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20561. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20562. * closest element that is smaller than or greater than the one we are
  20563. * searching for, respectively, if the exact element cannot be found.
  20564. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20565. *
  20566. * and an object is returned with the following properties:
  20567. *
  20568. * - line: The line number in the generated source, or null. The
  20569. * line number is 1-based.
  20570. * - column: The column number in the generated source, or null.
  20571. * The column number is 0-based.
  20572. */
  20573. BasicSourceMapConsumer$1.prototype.generatedPositionFor =
  20574. function SourceMapConsumer_generatedPositionFor(aArgs) {
  20575. var source = util$8.getArg(aArgs, 'source');
  20576. source = this._findSourceIndex(source);
  20577. if (source < 0) {
  20578. return {
  20579. line: null,
  20580. column: null,
  20581. lastColumn: null
  20582. };
  20583. }
  20584. var needle = {
  20585. source: source,
  20586. originalLine: util$8.getArg(aArgs, 'line'),
  20587. originalColumn: util$8.getArg(aArgs, 'column')
  20588. };
  20589. var index = this._findMapping(
  20590. needle,
  20591. this._originalMappings,
  20592. "originalLine",
  20593. "originalColumn",
  20594. util$8.compareByOriginalPositions,
  20595. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20596. );
  20597. if (index >= 0) {
  20598. var mapping = this._originalMappings[index];
  20599. if (mapping.source === needle.source) {
  20600. return {
  20601. line: util$8.getArg(mapping, 'generatedLine', null),
  20602. column: util$8.getArg(mapping, 'generatedColumn', null),
  20603. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20604. };
  20605. }
  20606. }
  20607. return {
  20608. line: null,
  20609. column: null,
  20610. lastColumn: null
  20611. };
  20612. };
  20613. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer$1;
  20614. /**
  20615. * An IndexedSourceMapConsumer instance represents a parsed source map which
  20616. * we can query for information. It differs from BasicSourceMapConsumer in
  20617. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  20618. * input.
  20619. *
  20620. * The first parameter is a raw source map (either as a JSON string, or already
  20621. * parsed to an object). According to the spec for indexed source maps, they
  20622. * have the following attributes:
  20623. *
  20624. * - version: Which version of the source map spec this map is following.
  20625. * - file: Optional. The generated file this source map is associated with.
  20626. * - sections: A list of section definitions.
  20627. *
  20628. * Each value under the "sections" field has two fields:
  20629. * - offset: The offset into the original specified at which this section
  20630. * begins to apply, defined as an object with a "line" and "column"
  20631. * field.
  20632. * - map: A source map definition. This source map could also be indexed,
  20633. * but doesn't have to be.
  20634. *
  20635. * Instead of the "map" field, it's also possible to have a "url" field
  20636. * specifying a URL to retrieve a source map from, but that's currently
  20637. * unsupported.
  20638. *
  20639. * Here's an example source map, taken from the source map spec[0], but
  20640. * modified to omit a section which uses the "url" field.
  20641. *
  20642. * {
  20643. * version : 3,
  20644. * file: "app.js",
  20645. * sections: [{
  20646. * offset: {line:100, column:10},
  20647. * map: {
  20648. * version : 3,
  20649. * file: "section.js",
  20650. * sources: ["foo.js", "bar.js"],
  20651. * names: ["src", "maps", "are", "fun"],
  20652. * mappings: "AAAA,E;;ABCDE;"
  20653. * }
  20654. * }],
  20655. * }
  20656. *
  20657. * The second parameter, if given, is a string whose value is the URL
  20658. * at which the source map was found. This URL is used to compute the
  20659. * sources array.
  20660. *
  20661. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  20662. */
  20663. function IndexedSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20664. var sourceMap = aSourceMap;
  20665. if (typeof aSourceMap === 'string') {
  20666. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20667. }
  20668. var version = util$8.getArg(sourceMap, 'version');
  20669. var sections = util$8.getArg(sourceMap, 'sections');
  20670. if (version != this._version) {
  20671. throw new Error('Unsupported version: ' + version);
  20672. }
  20673. this._sources = new ArraySet$3();
  20674. this._names = new ArraySet$3();
  20675. var lastOffset = {
  20676. line: -1,
  20677. column: 0
  20678. };
  20679. this._sections = sections.map(function (s) {
  20680. if (s.url) {
  20681. // The url field will require support for asynchronicity.
  20682. // See https://github.com/mozilla/source-map/issues/16
  20683. throw new Error('Support for url field in sections not implemented.');
  20684. }
  20685. var offset = util$8.getArg(s, 'offset');
  20686. var offsetLine = util$8.getArg(offset, 'line');
  20687. var offsetColumn = util$8.getArg(offset, 'column');
  20688. if (offsetLine < lastOffset.line ||
  20689. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  20690. throw new Error('Section offsets must be ordered and non-overlapping.');
  20691. }
  20692. lastOffset = offset;
  20693. return {
  20694. generatedOffset: {
  20695. // The offset fields are 0-based, but we use 1-based indices when
  20696. // encoding/decoding from VLQ.
  20697. generatedLine: offsetLine + 1,
  20698. generatedColumn: offsetColumn + 1
  20699. },
  20700. consumer: new SourceMapConsumer$6(util$8.getArg(s, 'map'), aSourceMapURL)
  20701. }
  20702. });
  20703. }
  20704. IndexedSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20705. IndexedSourceMapConsumer$1.prototype.constructor = SourceMapConsumer$6;
  20706. /**
  20707. * The version of the source mapping spec that we are consuming.
  20708. */
  20709. IndexedSourceMapConsumer$1.prototype._version = 3;
  20710. /**
  20711. * The list of original sources.
  20712. */
  20713. Object.defineProperty(IndexedSourceMapConsumer$1.prototype, 'sources', {
  20714. get: function () {
  20715. var sources = [];
  20716. for (var i = 0; i < this._sections.length; i++) {
  20717. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  20718. sources.push(this._sections[i].consumer.sources[j]);
  20719. }
  20720. }
  20721. return sources;
  20722. }
  20723. });
  20724. /**
  20725. * Returns the original source, line, and column information for the generated
  20726. * source's line and column positions provided. The only argument is an object
  20727. * with the following properties:
  20728. *
  20729. * - line: The line number in the generated source. The line number
  20730. * is 1-based.
  20731. * - column: The column number in the generated source. The column
  20732. * number is 0-based.
  20733. *
  20734. * and an object is returned with the following properties:
  20735. *
  20736. * - source: The original source file, or null.
  20737. * - line: The line number in the original source, or null. The
  20738. * line number is 1-based.
  20739. * - column: The column number in the original source, or null. The
  20740. * column number is 0-based.
  20741. * - name: The original identifier, or null.
  20742. */
  20743. IndexedSourceMapConsumer$1.prototype.originalPositionFor =
  20744. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  20745. var needle = {
  20746. generatedLine: util$8.getArg(aArgs, 'line'),
  20747. generatedColumn: util$8.getArg(aArgs, 'column')
  20748. };
  20749. // Find the section containing the generated position we're trying to map
  20750. // to an original position.
  20751. var sectionIndex = binarySearch$2.search(needle, this._sections,
  20752. function(needle, section) {
  20753. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  20754. if (cmp) {
  20755. return cmp;
  20756. }
  20757. return (needle.generatedColumn -
  20758. section.generatedOffset.generatedColumn);
  20759. });
  20760. var section = this._sections[sectionIndex];
  20761. if (!section) {
  20762. return {
  20763. source: null,
  20764. line: null,
  20765. column: null,
  20766. name: null
  20767. };
  20768. }
  20769. return section.consumer.originalPositionFor({
  20770. line: needle.generatedLine -
  20771. (section.generatedOffset.generatedLine - 1),
  20772. column: needle.generatedColumn -
  20773. (section.generatedOffset.generatedLine === needle.generatedLine
  20774. ? section.generatedOffset.generatedColumn - 1
  20775. : 0),
  20776. bias: aArgs.bias
  20777. });
  20778. };
  20779. /**
  20780. * Return true if we have the source content for every source in the source
  20781. * map, false otherwise.
  20782. */
  20783. IndexedSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20784. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  20785. return this._sections.every(function (s) {
  20786. return s.consumer.hasContentsOfAllSources();
  20787. });
  20788. };
  20789. /**
  20790. * Returns the original source content. The only argument is the url of the
  20791. * original source file. Returns null if no original source content is
  20792. * available.
  20793. */
  20794. IndexedSourceMapConsumer$1.prototype.sourceContentFor =
  20795. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20796. for (var i = 0; i < this._sections.length; i++) {
  20797. var section = this._sections[i];
  20798. var content = section.consumer.sourceContentFor(aSource, true);
  20799. if (content || content === '') {
  20800. return content;
  20801. }
  20802. }
  20803. if (nullOnMissing) {
  20804. return null;
  20805. }
  20806. else {
  20807. throw new Error('"' + aSource + '" is not in the SourceMap.');
  20808. }
  20809. };
  20810. /**
  20811. * Returns the generated line and column information for the original source,
  20812. * line, and column positions provided. The only argument is an object with
  20813. * the following properties:
  20814. *
  20815. * - source: The filename of the original source.
  20816. * - line: The line number in the original source. The line number
  20817. * is 1-based.
  20818. * - column: The column number in the original source. The column
  20819. * number is 0-based.
  20820. *
  20821. * and an object is returned with the following properties:
  20822. *
  20823. * - line: The line number in the generated source, or null. The
  20824. * line number is 1-based.
  20825. * - column: The column number in the generated source, or null.
  20826. * The column number is 0-based.
  20827. */
  20828. IndexedSourceMapConsumer$1.prototype.generatedPositionFor =
  20829. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  20830. for (var i = 0; i < this._sections.length; i++) {
  20831. var section = this._sections[i];
  20832. // Only consider this section if the requested source is in the list of
  20833. // sources of the consumer.
  20834. if (section.consumer._findSourceIndex(util$8.getArg(aArgs, 'source')) === -1) {
  20835. continue;
  20836. }
  20837. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  20838. if (generatedPosition) {
  20839. var ret = {
  20840. line: generatedPosition.line +
  20841. (section.generatedOffset.generatedLine - 1),
  20842. column: generatedPosition.column +
  20843. (section.generatedOffset.generatedLine === generatedPosition.line
  20844. ? section.generatedOffset.generatedColumn - 1
  20845. : 0)
  20846. };
  20847. return ret;
  20848. }
  20849. }
  20850. return {
  20851. line: null,
  20852. column: null
  20853. };
  20854. };
  20855. /**
  20856. * Parse the mappings in a string in to a data structure which we can easily
  20857. * query (the ordered arrays in the `this.__generatedMappings` and
  20858. * `this.__originalMappings` properties).
  20859. */
  20860. IndexedSourceMapConsumer$1.prototype._parseMappings =
  20861. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20862. this.__generatedMappings = [];
  20863. this.__originalMappings = [];
  20864. for (var i = 0; i < this._sections.length; i++) {
  20865. var section = this._sections[i];
  20866. var sectionMappings = section.consumer._generatedMappings;
  20867. for (var j = 0; j < sectionMappings.length; j++) {
  20868. var mapping = sectionMappings[j];
  20869. var source = section.consumer._sources.at(mapping.source);
  20870. source = util$8.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  20871. this._sources.add(source);
  20872. source = this._sources.indexOf(source);
  20873. var name = null;
  20874. if (mapping.name) {
  20875. name = section.consumer._names.at(mapping.name);
  20876. this._names.add(name);
  20877. name = this._names.indexOf(name);
  20878. }
  20879. // The mappings coming from the consumer for the section have
  20880. // generated positions relative to the start of the section, so we
  20881. // need to offset them to be relative to the start of the concatenated
  20882. // generated file.
  20883. var adjustedMapping = {
  20884. source: source,
  20885. generatedLine: mapping.generatedLine +
  20886. (section.generatedOffset.generatedLine - 1),
  20887. generatedColumn: mapping.generatedColumn +
  20888. (section.generatedOffset.generatedLine === mapping.generatedLine
  20889. ? section.generatedOffset.generatedColumn - 1
  20890. : 0),
  20891. originalLine: mapping.originalLine,
  20892. originalColumn: mapping.originalColumn,
  20893. name: name
  20894. };
  20895. this.__generatedMappings.push(adjustedMapping);
  20896. if (typeof adjustedMapping.originalLine === 'number') {
  20897. this.__originalMappings.push(adjustedMapping);
  20898. }
  20899. }
  20900. }
  20901. quickSort$2(this.__generatedMappings, util$8.compareByGeneratedPositionsDeflated);
  20902. quickSort$2(this.__originalMappings, util$8.compareByOriginalPositions);
  20903. };
  20904. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer$1;
  20905. var sourceNode$1 = {};
  20906. /* -*- Mode: js; js-indent-level: 2; -*- */
  20907. /*
  20908. * Copyright 2011 Mozilla Foundation and contributors
  20909. * Licensed under the New BSD license. See LICENSE or:
  20910. * http://opensource.org/licenses/BSD-3-Clause
  20911. */
  20912. var SourceMapGenerator$7 = sourceMapGenerator$1.SourceMapGenerator;
  20913. var util$7 = util$c;
  20914. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  20915. // operating systems these days (capturing the result).
  20916. var REGEX_NEWLINE$1 = /(\r?\n)/;
  20917. // Newline character code for charCodeAt() comparisons
  20918. var NEWLINE_CODE$1 = 10;
  20919. // Private symbol for identifying `SourceNode`s when multiple versions of
  20920. // the source-map library are loaded. This MUST NOT CHANGE across
  20921. // versions!
  20922. var isSourceNode$1 = "$$$isSourceNode$$$";
  20923. /**
  20924. * SourceNodes provide a way to abstract over interpolating/concatenating
  20925. * snippets of generated JavaScript source code while maintaining the line and
  20926. * column information associated with the original source code.
  20927. *
  20928. * @param aLine The original line number.
  20929. * @param aColumn The original column number.
  20930. * @param aSource The original source's filename.
  20931. * @param aChunks Optional. An array of strings which are snippets of
  20932. * generated JS, or other SourceNodes.
  20933. * @param aName The original identifier.
  20934. */
  20935. function SourceNode$1(aLine, aColumn, aSource, aChunks, aName) {
  20936. this.children = [];
  20937. this.sourceContents = {};
  20938. this.line = aLine == null ? null : aLine;
  20939. this.column = aColumn == null ? null : aColumn;
  20940. this.source = aSource == null ? null : aSource;
  20941. this.name = aName == null ? null : aName;
  20942. this[isSourceNode$1] = true;
  20943. if (aChunks != null) this.add(aChunks);
  20944. }
  20945. /**
  20946. * Creates a SourceNode from generated code and a SourceMapConsumer.
  20947. *
  20948. * @param aGeneratedCode The generated code
  20949. * @param aSourceMapConsumer The SourceMap for the generated code
  20950. * @param aRelativePath Optional. The path that relative sources in the
  20951. * SourceMapConsumer should be relative to.
  20952. */
  20953. SourceNode$1.fromStringWithSourceMap =
  20954. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  20955. // The SourceNode we want to fill with the generated code
  20956. // and the SourceMap
  20957. var node = new SourceNode$1();
  20958. // All even indices of this array are one line of the generated code,
  20959. // while all odd indices are the newlines between two adjacent lines
  20960. // (since `REGEX_NEWLINE` captures its match).
  20961. // Processed fragments are accessed by calling `shiftNextLine`.
  20962. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE$1);
  20963. var remainingLinesIndex = 0;
  20964. var shiftNextLine = function() {
  20965. var lineContents = getNextLine();
  20966. // The last line of a file might not have a newline.
  20967. var newLine = getNextLine() || "";
  20968. return lineContents + newLine;
  20969. function getNextLine() {
  20970. return remainingLinesIndex < remainingLines.length ?
  20971. remainingLines[remainingLinesIndex++] : undefined;
  20972. }
  20973. };
  20974. // We need to remember the position of "remainingLines"
  20975. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  20976. // The generate SourceNodes we need a code range.
  20977. // To extract it current and last mapping is used.
  20978. // Here we store the last mapping.
  20979. var lastMapping = null;
  20980. aSourceMapConsumer.eachMapping(function (mapping) {
  20981. if (lastMapping !== null) {
  20982. // We add the code from "lastMapping" to "mapping":
  20983. // First check if there is a new line in between.
  20984. if (lastGeneratedLine < mapping.generatedLine) {
  20985. // Associate first line with "lastMapping"
  20986. addMappingWithCode(lastMapping, shiftNextLine());
  20987. lastGeneratedLine++;
  20988. lastGeneratedColumn = 0;
  20989. // The remaining code is added without mapping
  20990. } else {
  20991. // There is no new line in between.
  20992. // Associate the code between "lastGeneratedColumn" and
  20993. // "mapping.generatedColumn" with "lastMapping"
  20994. var nextLine = remainingLines[remainingLinesIndex] || '';
  20995. var code = nextLine.substr(0, mapping.generatedColumn -
  20996. lastGeneratedColumn);
  20997. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  20998. lastGeneratedColumn);
  20999. lastGeneratedColumn = mapping.generatedColumn;
  21000. addMappingWithCode(lastMapping, code);
  21001. // No more remaining code, continue
  21002. lastMapping = mapping;
  21003. return;
  21004. }
  21005. }
  21006. // We add the generated code until the first mapping
  21007. // to the SourceNode without any mapping.
  21008. // Each line is added as separate string.
  21009. while (lastGeneratedLine < mapping.generatedLine) {
  21010. node.add(shiftNextLine());
  21011. lastGeneratedLine++;
  21012. }
  21013. if (lastGeneratedColumn < mapping.generatedColumn) {
  21014. var nextLine = remainingLines[remainingLinesIndex] || '';
  21015. node.add(nextLine.substr(0, mapping.generatedColumn));
  21016. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  21017. lastGeneratedColumn = mapping.generatedColumn;
  21018. }
  21019. lastMapping = mapping;
  21020. }, this);
  21021. // We have processed all mappings.
  21022. if (remainingLinesIndex < remainingLines.length) {
  21023. if (lastMapping) {
  21024. // Associate the remaining code in the current line with "lastMapping"
  21025. addMappingWithCode(lastMapping, shiftNextLine());
  21026. }
  21027. // and add the remaining lines without any mapping
  21028. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  21029. }
  21030. // Copy sourcesContent into SourceNode
  21031. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  21032. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  21033. if (content != null) {
  21034. if (aRelativePath != null) {
  21035. sourceFile = util$7.join(aRelativePath, sourceFile);
  21036. }
  21037. node.setSourceContent(sourceFile, content);
  21038. }
  21039. });
  21040. return node;
  21041. function addMappingWithCode(mapping, code) {
  21042. if (mapping === null || mapping.source === undefined) {
  21043. node.add(code);
  21044. } else {
  21045. var source = aRelativePath
  21046. ? util$7.join(aRelativePath, mapping.source)
  21047. : mapping.source;
  21048. node.add(new SourceNode$1(mapping.originalLine,
  21049. mapping.originalColumn,
  21050. source,
  21051. code,
  21052. mapping.name));
  21053. }
  21054. }
  21055. };
  21056. /**
  21057. * Add a chunk of generated JS to this source node.
  21058. *
  21059. * @param aChunk A string snippet of generated JS code, another instance of
  21060. * SourceNode, or an array where each member is one of those things.
  21061. */
  21062. SourceNode$1.prototype.add = function SourceNode_add(aChunk) {
  21063. if (Array.isArray(aChunk)) {
  21064. aChunk.forEach(function (chunk) {
  21065. this.add(chunk);
  21066. }, this);
  21067. }
  21068. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21069. if (aChunk) {
  21070. this.children.push(aChunk);
  21071. }
  21072. }
  21073. else {
  21074. throw new TypeError(
  21075. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21076. );
  21077. }
  21078. return this;
  21079. };
  21080. /**
  21081. * Add a chunk of generated JS to the beginning of this source node.
  21082. *
  21083. * @param aChunk A string snippet of generated JS code, another instance of
  21084. * SourceNode, or an array where each member is one of those things.
  21085. */
  21086. SourceNode$1.prototype.prepend = function SourceNode_prepend(aChunk) {
  21087. if (Array.isArray(aChunk)) {
  21088. for (var i = aChunk.length-1; i >= 0; i--) {
  21089. this.prepend(aChunk[i]);
  21090. }
  21091. }
  21092. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21093. this.children.unshift(aChunk);
  21094. }
  21095. else {
  21096. throw new TypeError(
  21097. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21098. );
  21099. }
  21100. return this;
  21101. };
  21102. /**
  21103. * Walk over the tree of JS snippets in this node and its children. The
  21104. * walking function is called once for each snippet of JS and is passed that
  21105. * snippet and the its original associated source's line/column location.
  21106. *
  21107. * @param aFn The traversal function.
  21108. */
  21109. SourceNode$1.prototype.walk = function SourceNode_walk(aFn) {
  21110. var chunk;
  21111. for (var i = 0, len = this.children.length; i < len; i++) {
  21112. chunk = this.children[i];
  21113. if (chunk[isSourceNode$1]) {
  21114. chunk.walk(aFn);
  21115. }
  21116. else {
  21117. if (chunk !== '') {
  21118. aFn(chunk, { source: this.source,
  21119. line: this.line,
  21120. column: this.column,
  21121. name: this.name });
  21122. }
  21123. }
  21124. }
  21125. };
  21126. /**
  21127. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  21128. * each of `this.children`.
  21129. *
  21130. * @param aSep The separator.
  21131. */
  21132. SourceNode$1.prototype.join = function SourceNode_join(aSep) {
  21133. var newChildren;
  21134. var i;
  21135. var len = this.children.length;
  21136. if (len > 0) {
  21137. newChildren = [];
  21138. for (i = 0; i < len-1; i++) {
  21139. newChildren.push(this.children[i]);
  21140. newChildren.push(aSep);
  21141. }
  21142. newChildren.push(this.children[i]);
  21143. this.children = newChildren;
  21144. }
  21145. return this;
  21146. };
  21147. /**
  21148. * Call String.prototype.replace on the very right-most source snippet. Useful
  21149. * for trimming whitespace from the end of a source node, etc.
  21150. *
  21151. * @param aPattern The pattern to replace.
  21152. * @param aReplacement The thing to replace the pattern with.
  21153. */
  21154. SourceNode$1.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  21155. var lastChild = this.children[this.children.length - 1];
  21156. if (lastChild[isSourceNode$1]) {
  21157. lastChild.replaceRight(aPattern, aReplacement);
  21158. }
  21159. else if (typeof lastChild === 'string') {
  21160. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  21161. }
  21162. else {
  21163. this.children.push(''.replace(aPattern, aReplacement));
  21164. }
  21165. return this;
  21166. };
  21167. /**
  21168. * Set the source content for a source file. This will be added to the SourceMapGenerator
  21169. * in the sourcesContent field.
  21170. *
  21171. * @param aSourceFile The filename of the source file
  21172. * @param aSourceContent The content of the source file
  21173. */
  21174. SourceNode$1.prototype.setSourceContent =
  21175. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  21176. this.sourceContents[util$7.toSetString(aSourceFile)] = aSourceContent;
  21177. };
  21178. /**
  21179. * Walk over the tree of SourceNodes. The walking function is called for each
  21180. * source file content and is passed the filename and source content.
  21181. *
  21182. * @param aFn The traversal function.
  21183. */
  21184. SourceNode$1.prototype.walkSourceContents =
  21185. function SourceNode_walkSourceContents(aFn) {
  21186. for (var i = 0, len = this.children.length; i < len; i++) {
  21187. if (this.children[i][isSourceNode$1]) {
  21188. this.children[i].walkSourceContents(aFn);
  21189. }
  21190. }
  21191. var sources = Object.keys(this.sourceContents);
  21192. for (var i = 0, len = sources.length; i < len; i++) {
  21193. aFn(util$7.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  21194. }
  21195. };
  21196. /**
  21197. * Return the string representation of this source node. Walks over the tree
  21198. * and concatenates all the various snippets together to one string.
  21199. */
  21200. SourceNode$1.prototype.toString = function SourceNode_toString() {
  21201. var str = "";
  21202. this.walk(function (chunk) {
  21203. str += chunk;
  21204. });
  21205. return str;
  21206. };
  21207. /**
  21208. * Returns the string representation of this source node along with a source
  21209. * map.
  21210. */
  21211. SourceNode$1.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  21212. var generated = {
  21213. code: "",
  21214. line: 1,
  21215. column: 0
  21216. };
  21217. var map = new SourceMapGenerator$7(aArgs);
  21218. var sourceMappingActive = false;
  21219. var lastOriginalSource = null;
  21220. var lastOriginalLine = null;
  21221. var lastOriginalColumn = null;
  21222. var lastOriginalName = null;
  21223. this.walk(function (chunk, original) {
  21224. generated.code += chunk;
  21225. if (original.source !== null
  21226. && original.line !== null
  21227. && original.column !== null) {
  21228. if(lastOriginalSource !== original.source
  21229. || lastOriginalLine !== original.line
  21230. || lastOriginalColumn !== original.column
  21231. || lastOriginalName !== original.name) {
  21232. map.addMapping({
  21233. source: original.source,
  21234. original: {
  21235. line: original.line,
  21236. column: original.column
  21237. },
  21238. generated: {
  21239. line: generated.line,
  21240. column: generated.column
  21241. },
  21242. name: original.name
  21243. });
  21244. }
  21245. lastOriginalSource = original.source;
  21246. lastOriginalLine = original.line;
  21247. lastOriginalColumn = original.column;
  21248. lastOriginalName = original.name;
  21249. sourceMappingActive = true;
  21250. } else if (sourceMappingActive) {
  21251. map.addMapping({
  21252. generated: {
  21253. line: generated.line,
  21254. column: generated.column
  21255. }
  21256. });
  21257. lastOriginalSource = null;
  21258. sourceMappingActive = false;
  21259. }
  21260. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  21261. if (chunk.charCodeAt(idx) === NEWLINE_CODE$1) {
  21262. generated.line++;
  21263. generated.column = 0;
  21264. // Mappings end at eol
  21265. if (idx + 1 === length) {
  21266. lastOriginalSource = null;
  21267. sourceMappingActive = false;
  21268. } else if (sourceMappingActive) {
  21269. map.addMapping({
  21270. source: original.source,
  21271. original: {
  21272. line: original.line,
  21273. column: original.column
  21274. },
  21275. generated: {
  21276. line: generated.line,
  21277. column: generated.column
  21278. },
  21279. name: original.name
  21280. });
  21281. }
  21282. } else {
  21283. generated.column++;
  21284. }
  21285. }
  21286. });
  21287. this.walkSourceContents(function (sourceFile, sourceContent) {
  21288. map.setSourceContent(sourceFile, sourceContent);
  21289. });
  21290. return { code: generated.code, map: map };
  21291. };
  21292. sourceNode$1.SourceNode = SourceNode$1;
  21293. /*
  21294. * Copyright 2009-2011 Mozilla Foundation and contributors
  21295. * Licensed under the New BSD license. See LICENSE.txt or:
  21296. * http://opensource.org/licenses/BSD-3-Clause
  21297. */
  21298. var SourceMapGenerator$6 = sourceMap$2.SourceMapGenerator = sourceMapGenerator$1.SourceMapGenerator;
  21299. var SourceMapConsumer$5 = sourceMap$2.SourceMapConsumer = sourceMapConsumer$1.SourceMapConsumer;
  21300. sourceMap$2.SourceNode = sourceNode$1.SourceNode;
  21301. const PURE_ANNOTATION = `/*#__PURE__*/`;
  21302. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  21303. function createCodegenContext(ast, {
  21304. mode = "function",
  21305. prefixIdentifiers = mode === "module",
  21306. sourceMap = false,
  21307. filename = `template.vue.html`,
  21308. scopeId = null,
  21309. optimizeImports = false,
  21310. runtimeGlobalName = `Vue`,
  21311. runtimeModuleName = `vue`,
  21312. ssrRuntimeModuleName = "vue/server-renderer",
  21313. ssr = false,
  21314. isTS = false,
  21315. inSSR = false
  21316. }) {
  21317. const context = {
  21318. mode,
  21319. prefixIdentifiers,
  21320. sourceMap,
  21321. filename,
  21322. scopeId,
  21323. optimizeImports,
  21324. runtimeGlobalName,
  21325. runtimeModuleName,
  21326. ssrRuntimeModuleName,
  21327. ssr,
  21328. isTS,
  21329. inSSR,
  21330. source: ast.source,
  21331. code: ``,
  21332. column: 1,
  21333. line: 1,
  21334. offset: 0,
  21335. indentLevel: 0,
  21336. pure: false,
  21337. map: void 0,
  21338. helper(key) {
  21339. return `_${helperNameMap[key]}`;
  21340. },
  21341. push(code, newlineIndex = -2 /* None */, node) {
  21342. context.code += code;
  21343. if (context.map) {
  21344. if (node) {
  21345. let name;
  21346. if (node.type === 4 && !node.isStatic) {
  21347. const content = node.content.replace(/^_ctx\./, "");
  21348. if (content !== node.content && isSimpleIdentifier(content)) {
  21349. name = content;
  21350. }
  21351. }
  21352. addMapping(node.loc.start, name);
  21353. }
  21354. if (newlineIndex === -3 /* Unknown */) {
  21355. advancePositionWithMutation(context, code);
  21356. } else {
  21357. context.offset += code.length;
  21358. if (newlineIndex === -2 /* None */) {
  21359. context.column += code.length;
  21360. } else {
  21361. if (newlineIndex === -1 /* End */) {
  21362. newlineIndex = code.length - 1;
  21363. }
  21364. context.line++;
  21365. context.column = code.length - newlineIndex;
  21366. }
  21367. }
  21368. if (node && node.loc !== locStub) {
  21369. addMapping(node.loc.end);
  21370. }
  21371. }
  21372. },
  21373. indent() {
  21374. newline(++context.indentLevel);
  21375. },
  21376. deindent(withoutNewLine = false) {
  21377. if (withoutNewLine) {
  21378. --context.indentLevel;
  21379. } else {
  21380. newline(--context.indentLevel);
  21381. }
  21382. },
  21383. newline() {
  21384. newline(context.indentLevel);
  21385. }
  21386. };
  21387. function newline(n) {
  21388. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  21389. }
  21390. function addMapping(loc, name = null) {
  21391. const { _names, _mappings } = context.map;
  21392. if (name !== null && !_names.has(name))
  21393. _names.add(name);
  21394. _mappings.add({
  21395. originalLine: loc.line,
  21396. originalColumn: loc.column - 1,
  21397. // source-map column is 0 based
  21398. generatedLine: context.line,
  21399. generatedColumn: context.column - 1,
  21400. source: filename,
  21401. name
  21402. });
  21403. }
  21404. if (sourceMap) {
  21405. context.map = new SourceMapGenerator$6();
  21406. context.map.setSourceContent(filename, context.source);
  21407. context.map._sources.add(filename);
  21408. }
  21409. return context;
  21410. }
  21411. function generate(ast, options = {}) {
  21412. const context = createCodegenContext(ast, options);
  21413. if (options.onContextCreated)
  21414. options.onContextCreated(context);
  21415. const {
  21416. mode,
  21417. push,
  21418. prefixIdentifiers,
  21419. indent,
  21420. deindent,
  21421. newline,
  21422. scopeId,
  21423. ssr
  21424. } = context;
  21425. const helpers = Array.from(ast.helpers);
  21426. const hasHelpers = helpers.length > 0;
  21427. const useWithBlock = !prefixIdentifiers && mode !== "module";
  21428. const genScopeId = scopeId != null && mode === "module";
  21429. const isSetupInlined = !!options.inline;
  21430. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  21431. if (mode === "module") {
  21432. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  21433. } else {
  21434. genFunctionPreamble(ast, preambleContext);
  21435. }
  21436. const functionName = ssr ? `ssrRender` : `render`;
  21437. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  21438. if (options.bindingMetadata && !options.inline) {
  21439. args.push("$props", "$setup", "$data", "$options");
  21440. }
  21441. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  21442. if (isSetupInlined) {
  21443. push(`(${signature}) => {`);
  21444. } else {
  21445. push(`function ${functionName}(${signature}) {`);
  21446. }
  21447. indent();
  21448. if (useWithBlock) {
  21449. push(`with (_ctx) {`);
  21450. indent();
  21451. if (hasHelpers) {
  21452. push(
  21453. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  21454. `,
  21455. -1 /* End */
  21456. );
  21457. newline();
  21458. }
  21459. }
  21460. if (ast.components.length) {
  21461. genAssets(ast.components, "component", context);
  21462. if (ast.directives.length || ast.temps > 0) {
  21463. newline();
  21464. }
  21465. }
  21466. if (ast.directives.length) {
  21467. genAssets(ast.directives, "directive", context);
  21468. if (ast.temps > 0) {
  21469. newline();
  21470. }
  21471. }
  21472. if (ast.temps > 0) {
  21473. push(`let `);
  21474. for (let i = 0; i < ast.temps; i++) {
  21475. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  21476. }
  21477. }
  21478. if (ast.components.length || ast.directives.length || ast.temps) {
  21479. push(`
  21480. `, 0 /* Start */);
  21481. newline();
  21482. }
  21483. if (!ssr) {
  21484. push(`return `);
  21485. }
  21486. if (ast.codegenNode) {
  21487. genNode(ast.codegenNode, context);
  21488. } else {
  21489. push(`null`);
  21490. }
  21491. if (useWithBlock) {
  21492. deindent();
  21493. push(`}`);
  21494. }
  21495. deindent();
  21496. push(`}`);
  21497. return {
  21498. ast,
  21499. code: context.code,
  21500. preamble: isSetupInlined ? preambleContext.code : ``,
  21501. map: context.map ? context.map.toJSON() : void 0
  21502. };
  21503. }
  21504. function genFunctionPreamble(ast, context) {
  21505. const {
  21506. ssr,
  21507. prefixIdentifiers,
  21508. push,
  21509. newline,
  21510. runtimeModuleName,
  21511. runtimeGlobalName,
  21512. ssrRuntimeModuleName
  21513. } = context;
  21514. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  21515. const helpers = Array.from(ast.helpers);
  21516. if (helpers.length > 0) {
  21517. if (prefixIdentifiers) {
  21518. push(
  21519. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  21520. `,
  21521. -1 /* End */
  21522. );
  21523. } else {
  21524. push(`const _Vue = ${VueBinding}
  21525. `, -1 /* End */);
  21526. if (ast.hoists.length) {
  21527. const staticHelpers = [
  21528. CREATE_VNODE,
  21529. CREATE_ELEMENT_VNODE,
  21530. CREATE_COMMENT,
  21531. CREATE_TEXT,
  21532. CREATE_STATIC
  21533. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  21534. push(`const { ${staticHelpers} } = _Vue
  21535. `, -1 /* End */);
  21536. }
  21537. }
  21538. }
  21539. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21540. push(
  21541. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  21542. `,
  21543. -1 /* End */
  21544. );
  21545. }
  21546. genHoists(ast.hoists, context);
  21547. newline();
  21548. push(`return `);
  21549. }
  21550. function genModulePreamble(ast, context, genScopeId, inline) {
  21551. const {
  21552. push,
  21553. newline,
  21554. optimizeImports,
  21555. runtimeModuleName,
  21556. ssrRuntimeModuleName
  21557. } = context;
  21558. if (genScopeId && ast.hoists.length) {
  21559. ast.helpers.add(PUSH_SCOPE_ID);
  21560. ast.helpers.add(POP_SCOPE_ID);
  21561. }
  21562. if (ast.helpers.size) {
  21563. const helpers = Array.from(ast.helpers);
  21564. if (optimizeImports) {
  21565. push(
  21566. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21567. `,
  21568. -1 /* End */
  21569. );
  21570. push(
  21571. `
  21572. // Binding optimization for webpack code-split
  21573. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  21574. `,
  21575. -1 /* End */
  21576. );
  21577. } else {
  21578. push(
  21579. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21580. `,
  21581. -1 /* End */
  21582. );
  21583. }
  21584. }
  21585. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21586. push(
  21587. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  21588. `,
  21589. -1 /* End */
  21590. );
  21591. }
  21592. if (ast.imports.length) {
  21593. genImports(ast.imports, context);
  21594. newline();
  21595. }
  21596. genHoists(ast.hoists, context);
  21597. newline();
  21598. if (!inline) {
  21599. push(`export `);
  21600. }
  21601. }
  21602. function genAssets(assets, type, { helper, push, newline, isTS }) {
  21603. const resolver = helper(
  21604. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  21605. );
  21606. for (let i = 0; i < assets.length; i++) {
  21607. let id = assets[i];
  21608. const maybeSelfReference = id.endsWith("__self");
  21609. if (maybeSelfReference) {
  21610. id = id.slice(0, -6);
  21611. }
  21612. push(
  21613. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  21614. );
  21615. if (i < assets.length - 1) {
  21616. newline();
  21617. }
  21618. }
  21619. }
  21620. function genHoists(hoists, context) {
  21621. if (!hoists.length) {
  21622. return;
  21623. }
  21624. context.pure = true;
  21625. const { push, newline, helper, scopeId, mode } = context;
  21626. const genScopeId = scopeId != null && mode !== "function";
  21627. newline();
  21628. if (genScopeId) {
  21629. push(
  21630. `const _withScopeId = n => (${helper(
  21631. PUSH_SCOPE_ID
  21632. )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
  21633. );
  21634. newline();
  21635. }
  21636. for (let i = 0; i < hoists.length; i++) {
  21637. const exp = hoists[i];
  21638. if (exp) {
  21639. const needScopeIdWrapper = genScopeId && exp.type === 13;
  21640. push(
  21641. `const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
  21642. );
  21643. genNode(exp, context);
  21644. if (needScopeIdWrapper) {
  21645. push(`)`);
  21646. }
  21647. newline();
  21648. }
  21649. }
  21650. context.pure = false;
  21651. }
  21652. function genImports(importsOptions, context) {
  21653. if (!importsOptions.length) {
  21654. return;
  21655. }
  21656. importsOptions.forEach((imports) => {
  21657. context.push(`import `);
  21658. genNode(imports.exp, context);
  21659. context.push(` from '${imports.path}'`);
  21660. context.newline();
  21661. });
  21662. }
  21663. function isText(n) {
  21664. return isString$2(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  21665. }
  21666. function genNodeListAsArray(nodes, context) {
  21667. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  21668. context.push(`[`);
  21669. multilines && context.indent();
  21670. genNodeList(nodes, context, multilines);
  21671. multilines && context.deindent();
  21672. context.push(`]`);
  21673. }
  21674. function genNodeList(nodes, context, multilines = false, comma = true) {
  21675. const { push, newline } = context;
  21676. for (let i = 0; i < nodes.length; i++) {
  21677. const node = nodes[i];
  21678. if (isString$2(node)) {
  21679. push(node, -3 /* Unknown */);
  21680. } else if (isArray$3(node)) {
  21681. genNodeListAsArray(node, context);
  21682. } else {
  21683. genNode(node, context);
  21684. }
  21685. if (i < nodes.length - 1) {
  21686. if (multilines) {
  21687. comma && push(",");
  21688. newline();
  21689. } else {
  21690. comma && push(", ");
  21691. }
  21692. }
  21693. }
  21694. }
  21695. function genNode(node, context) {
  21696. if (isString$2(node)) {
  21697. context.push(node, -3 /* Unknown */);
  21698. return;
  21699. }
  21700. if (isSymbol$1(node)) {
  21701. context.push(context.helper(node));
  21702. return;
  21703. }
  21704. switch (node.type) {
  21705. case 1:
  21706. case 9:
  21707. case 11:
  21708. assert(
  21709. node.codegenNode != null,
  21710. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  21711. );
  21712. genNode(node.codegenNode, context);
  21713. break;
  21714. case 2:
  21715. genText(node, context);
  21716. break;
  21717. case 4:
  21718. genExpression(node, context);
  21719. break;
  21720. case 5:
  21721. genInterpolation(node, context);
  21722. break;
  21723. case 12:
  21724. genNode(node.codegenNode, context);
  21725. break;
  21726. case 8:
  21727. genCompoundExpression(node, context);
  21728. break;
  21729. case 3:
  21730. genComment(node, context);
  21731. break;
  21732. case 13:
  21733. genVNodeCall(node, context);
  21734. break;
  21735. case 14:
  21736. genCallExpression(node, context);
  21737. break;
  21738. case 15:
  21739. genObjectExpression(node, context);
  21740. break;
  21741. case 17:
  21742. genArrayExpression(node, context);
  21743. break;
  21744. case 18:
  21745. genFunctionExpression(node, context);
  21746. break;
  21747. case 19:
  21748. genConditionalExpression(node, context);
  21749. break;
  21750. case 20:
  21751. genCacheExpression(node, context);
  21752. break;
  21753. case 21:
  21754. genNodeList(node.body, context, true, false);
  21755. break;
  21756. case 22:
  21757. genTemplateLiteral(node, context);
  21758. break;
  21759. case 23:
  21760. genIfStatement(node, context);
  21761. break;
  21762. case 24:
  21763. genAssignmentExpression(node, context);
  21764. break;
  21765. case 25:
  21766. genSequenceExpression(node, context);
  21767. break;
  21768. case 26:
  21769. genReturnStatement(node, context);
  21770. break;
  21771. case 10:
  21772. break;
  21773. default:
  21774. {
  21775. assert(false, `unhandled codegen node type: ${node.type}`);
  21776. const exhaustiveCheck = node;
  21777. return exhaustiveCheck;
  21778. }
  21779. }
  21780. }
  21781. function genText(node, context) {
  21782. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  21783. }
  21784. function genExpression(node, context) {
  21785. const { content, isStatic } = node;
  21786. context.push(
  21787. isStatic ? JSON.stringify(content) : content,
  21788. -3 /* Unknown */,
  21789. node
  21790. );
  21791. }
  21792. function genInterpolation(node, context) {
  21793. const { push, helper, pure } = context;
  21794. if (pure)
  21795. push(PURE_ANNOTATION);
  21796. push(`${helper(TO_DISPLAY_STRING)}(`);
  21797. genNode(node.content, context);
  21798. push(`)`);
  21799. }
  21800. function genCompoundExpression(node, context) {
  21801. for (let i = 0; i < node.children.length; i++) {
  21802. const child = node.children[i];
  21803. if (isString$2(child)) {
  21804. context.push(child, -3 /* Unknown */);
  21805. } else {
  21806. genNode(child, context);
  21807. }
  21808. }
  21809. }
  21810. function genExpressionAsPropertyKey(node, context) {
  21811. const { push } = context;
  21812. if (node.type === 8) {
  21813. push(`[`);
  21814. genCompoundExpression(node, context);
  21815. push(`]`);
  21816. } else if (node.isStatic) {
  21817. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  21818. push(text, -2 /* None */, node);
  21819. } else {
  21820. push(`[${node.content}]`, -3 /* Unknown */, node);
  21821. }
  21822. }
  21823. function genComment(node, context) {
  21824. const { push, helper, pure } = context;
  21825. if (pure) {
  21826. push(PURE_ANNOTATION);
  21827. }
  21828. push(
  21829. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  21830. -3 /* Unknown */,
  21831. node
  21832. );
  21833. }
  21834. function genVNodeCall(node, context) {
  21835. const { push, helper, pure } = context;
  21836. const {
  21837. tag,
  21838. props,
  21839. children,
  21840. patchFlag,
  21841. dynamicProps,
  21842. directives,
  21843. isBlock,
  21844. disableTracking,
  21845. isComponent
  21846. } = node;
  21847. if (directives) {
  21848. push(helper(WITH_DIRECTIVES) + `(`);
  21849. }
  21850. if (isBlock) {
  21851. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  21852. }
  21853. if (pure) {
  21854. push(PURE_ANNOTATION);
  21855. }
  21856. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  21857. push(helper(callHelper) + `(`, -2 /* None */, node);
  21858. genNodeList(
  21859. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  21860. context
  21861. );
  21862. push(`)`);
  21863. if (isBlock) {
  21864. push(`)`);
  21865. }
  21866. if (directives) {
  21867. push(`, `);
  21868. genNode(directives, context);
  21869. push(`)`);
  21870. }
  21871. }
  21872. function genNullableArgs(args) {
  21873. let i = args.length;
  21874. while (i--) {
  21875. if (args[i] != null)
  21876. break;
  21877. }
  21878. return args.slice(0, i + 1).map((arg) => arg || `null`);
  21879. }
  21880. function genCallExpression(node, context) {
  21881. const { push, helper, pure } = context;
  21882. const callee = isString$2(node.callee) ? node.callee : helper(node.callee);
  21883. if (pure) {
  21884. push(PURE_ANNOTATION);
  21885. }
  21886. push(callee + `(`, -2 /* None */, node);
  21887. genNodeList(node.arguments, context);
  21888. push(`)`);
  21889. }
  21890. function genObjectExpression(node, context) {
  21891. const { push, indent, deindent, newline } = context;
  21892. const { properties } = node;
  21893. if (!properties.length) {
  21894. push(`{}`, -2 /* None */, node);
  21895. return;
  21896. }
  21897. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  21898. push(multilines ? `{` : `{ `);
  21899. multilines && indent();
  21900. for (let i = 0; i < properties.length; i++) {
  21901. const { key, value } = properties[i];
  21902. genExpressionAsPropertyKey(key, context);
  21903. push(`: `);
  21904. genNode(value, context);
  21905. if (i < properties.length - 1) {
  21906. push(`,`);
  21907. newline();
  21908. }
  21909. }
  21910. multilines && deindent();
  21911. push(multilines ? `}` : ` }`);
  21912. }
  21913. function genArrayExpression(node, context) {
  21914. genNodeListAsArray(node.elements, context);
  21915. }
  21916. function genFunctionExpression(node, context) {
  21917. const { push, indent, deindent } = context;
  21918. const { params, returns, body, newline, isSlot } = node;
  21919. if (isSlot) {
  21920. push(`_${helperNameMap[WITH_CTX]}(`);
  21921. }
  21922. push(`(`, -2 /* None */, node);
  21923. if (isArray$3(params)) {
  21924. genNodeList(params, context);
  21925. } else if (params) {
  21926. genNode(params, context);
  21927. }
  21928. push(`) => `);
  21929. if (newline || body) {
  21930. push(`{`);
  21931. indent();
  21932. }
  21933. if (returns) {
  21934. if (newline) {
  21935. push(`return `);
  21936. }
  21937. if (isArray$3(returns)) {
  21938. genNodeListAsArray(returns, context);
  21939. } else {
  21940. genNode(returns, context);
  21941. }
  21942. } else if (body) {
  21943. genNode(body, context);
  21944. }
  21945. if (newline || body) {
  21946. deindent();
  21947. push(`}`);
  21948. }
  21949. if (isSlot) {
  21950. push(`)`);
  21951. }
  21952. }
  21953. function genConditionalExpression(node, context) {
  21954. const { test, consequent, alternate, newline: needNewline } = node;
  21955. const { push, indent, deindent, newline } = context;
  21956. if (test.type === 4) {
  21957. const needsParens = !isSimpleIdentifier(test.content);
  21958. needsParens && push(`(`);
  21959. genExpression(test, context);
  21960. needsParens && push(`)`);
  21961. } else {
  21962. push(`(`);
  21963. genNode(test, context);
  21964. push(`)`);
  21965. }
  21966. needNewline && indent();
  21967. context.indentLevel++;
  21968. needNewline || push(` `);
  21969. push(`? `);
  21970. genNode(consequent, context);
  21971. context.indentLevel--;
  21972. needNewline && newline();
  21973. needNewline || push(` `);
  21974. push(`: `);
  21975. const isNested = alternate.type === 19;
  21976. if (!isNested) {
  21977. context.indentLevel++;
  21978. }
  21979. genNode(alternate, context);
  21980. if (!isNested) {
  21981. context.indentLevel--;
  21982. }
  21983. needNewline && deindent(
  21984. true
  21985. /* without newline */
  21986. );
  21987. }
  21988. function genCacheExpression(node, context) {
  21989. const { push, helper, indent, deindent, newline } = context;
  21990. push(`_cache[${node.index}] || (`);
  21991. if (node.isVNode) {
  21992. indent();
  21993. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  21994. newline();
  21995. }
  21996. push(`_cache[${node.index}] = `);
  21997. genNode(node.value, context);
  21998. if (node.isVNode) {
  21999. push(`,`);
  22000. newline();
  22001. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  22002. newline();
  22003. push(`_cache[${node.index}]`);
  22004. deindent();
  22005. }
  22006. push(`)`);
  22007. }
  22008. function genTemplateLiteral(node, context) {
  22009. const { push, indent, deindent } = context;
  22010. push("`");
  22011. const l = node.elements.length;
  22012. const multilines = l > 3;
  22013. for (let i = 0; i < l; i++) {
  22014. const e = node.elements[i];
  22015. if (isString$2(e)) {
  22016. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  22017. } else {
  22018. push("${");
  22019. if (multilines)
  22020. indent();
  22021. genNode(e, context);
  22022. if (multilines)
  22023. deindent();
  22024. push("}");
  22025. }
  22026. }
  22027. push("`");
  22028. }
  22029. function genIfStatement(node, context) {
  22030. const { push, indent, deindent } = context;
  22031. const { test, consequent, alternate } = node;
  22032. push(`if (`);
  22033. genNode(test, context);
  22034. push(`) {`);
  22035. indent();
  22036. genNode(consequent, context);
  22037. deindent();
  22038. push(`}`);
  22039. if (alternate) {
  22040. push(` else `);
  22041. if (alternate.type === 23) {
  22042. genIfStatement(alternate, context);
  22043. } else {
  22044. push(`{`);
  22045. indent();
  22046. genNode(alternate, context);
  22047. deindent();
  22048. push(`}`);
  22049. }
  22050. }
  22051. }
  22052. function genAssignmentExpression(node, context) {
  22053. genNode(node.left, context);
  22054. context.push(` = `);
  22055. genNode(node.right, context);
  22056. }
  22057. function genSequenceExpression(node, context) {
  22058. context.push(`(`);
  22059. genNodeList(node.expressions, context);
  22060. context.push(`)`);
  22061. }
  22062. function genReturnStatement({ returns }, context) {
  22063. context.push(`return `);
  22064. if (isArray$3(returns)) {
  22065. genNodeListAsArray(returns, context);
  22066. } else {
  22067. genNode(returns, context);
  22068. }
  22069. }
  22070. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22071. const constantBailRE = /\w\s*\(|\.[^\d]/;
  22072. const transformExpression = (node, context) => {
  22073. if (node.type === 5) {
  22074. node.content = processExpression(
  22075. node.content,
  22076. context
  22077. );
  22078. } else if (node.type === 1) {
  22079. for (let i = 0; i < node.props.length; i++) {
  22080. const dir = node.props[i];
  22081. if (dir.type === 7 && dir.name !== "for") {
  22082. const exp = dir.exp;
  22083. const arg = dir.arg;
  22084. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  22085. dir.exp = processExpression(
  22086. exp,
  22087. context,
  22088. // slot args must be processed as function params
  22089. dir.name === "slot"
  22090. );
  22091. }
  22092. if (arg && arg.type === 4 && !arg.isStatic) {
  22093. dir.arg = processExpression(arg, context);
  22094. }
  22095. }
  22096. }
  22097. }
  22098. };
  22099. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  22100. if (!context.prefixIdentifiers || !node.content.trim()) {
  22101. return node;
  22102. }
  22103. const { inline, bindingMetadata } = context;
  22104. const rewriteIdentifier = (raw, parent, id) => {
  22105. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  22106. if (inline) {
  22107. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  22108. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  22109. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  22110. const isNewExpression = parent && isInNewExpression(parentStack);
  22111. const wrapWithUnref = (raw2) => {
  22112. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  22113. return isNewExpression ? `(${wrapped})` : wrapped;
  22114. };
  22115. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  22116. return raw;
  22117. } else if (type === "setup-ref") {
  22118. return `${raw}.value`;
  22119. } else if (type === "setup-maybe-ref") {
  22120. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  22121. } else if (type === "setup-let") {
  22122. if (isAssignmentLVal) {
  22123. const { right: rVal, operator } = parent;
  22124. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  22125. const rExpString = stringifyExpression(
  22126. processExpression(
  22127. createSimpleExpression(rExp, false),
  22128. context,
  22129. false,
  22130. false,
  22131. knownIds
  22132. )
  22133. );
  22134. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22135. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  22136. } else if (isUpdateArg) {
  22137. id.start = parent.start;
  22138. id.end = parent.end;
  22139. const { prefix: isPrefix, operator } = parent;
  22140. const prefix = isPrefix ? operator : ``;
  22141. const postfix = isPrefix ? `` : operator;
  22142. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22143. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  22144. } else if (isDestructureAssignment) {
  22145. return raw;
  22146. } else {
  22147. return wrapWithUnref(raw);
  22148. }
  22149. } else if (type === "props") {
  22150. return genPropsAccessExp(raw);
  22151. } else if (type === "props-aliased") {
  22152. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  22153. }
  22154. } else {
  22155. if (type && type.startsWith("setup") || type === "literal-const") {
  22156. return `$setup.${raw}`;
  22157. } else if (type === "props-aliased") {
  22158. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  22159. } else if (type) {
  22160. return `$${type}.${raw}`;
  22161. }
  22162. }
  22163. return `_ctx.${raw}`;
  22164. };
  22165. const rawExp = node.content;
  22166. const bailConstant = constantBailRE.test(rawExp);
  22167. let ast = node.ast;
  22168. if (ast === false) {
  22169. return node;
  22170. }
  22171. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  22172. const isScopeVarReference = context.identifiers[rawExp];
  22173. const isAllowedGlobal = isGloballyAllowed(rawExp);
  22174. const isLiteral = isLiteralWhitelisted(rawExp);
  22175. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  22176. if (isConst(bindingMetadata[rawExp])) {
  22177. node.constType = 1;
  22178. }
  22179. node.content = rewriteIdentifier(rawExp);
  22180. } else if (!isScopeVarReference) {
  22181. if (isLiteral) {
  22182. node.constType = 3;
  22183. } else {
  22184. node.constType = 2;
  22185. }
  22186. }
  22187. return node;
  22188. }
  22189. if (!ast) {
  22190. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  22191. try {
  22192. ast = parse_1$1(source, {
  22193. plugins: context.expressionPlugins
  22194. }).program;
  22195. } catch (e) {
  22196. context.onError(
  22197. createCompilerError(
  22198. 45,
  22199. node.loc,
  22200. void 0,
  22201. e.message
  22202. )
  22203. );
  22204. return node;
  22205. }
  22206. }
  22207. const ids = [];
  22208. const parentStack = [];
  22209. const knownIds = Object.create(context.identifiers);
  22210. walkIdentifiers(
  22211. ast,
  22212. (node2, parent, _, isReferenced, isLocal) => {
  22213. if (isStaticPropertyKey(node2, parent)) {
  22214. return;
  22215. }
  22216. const needPrefix = isReferenced && canPrefix(node2);
  22217. if (needPrefix && !isLocal) {
  22218. if (isStaticProperty(parent) && parent.shorthand) {
  22219. node2.prefix = `${node2.name}: `;
  22220. }
  22221. node2.name = rewriteIdentifier(node2.name, parent, node2);
  22222. ids.push(node2);
  22223. } else {
  22224. if (!(needPrefix && isLocal) && !bailConstant) {
  22225. node2.isConstant = true;
  22226. }
  22227. ids.push(node2);
  22228. }
  22229. },
  22230. true,
  22231. // invoke on ALL identifiers
  22232. parentStack,
  22233. knownIds
  22234. );
  22235. const children = [];
  22236. ids.sort((a, b) => a.start - b.start);
  22237. ids.forEach((id, i) => {
  22238. const start = id.start - 1;
  22239. const end = id.end - 1;
  22240. const last = ids[i - 1];
  22241. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  22242. if (leadingText.length || id.prefix) {
  22243. children.push(leadingText + (id.prefix || ``));
  22244. }
  22245. const source = rawExp.slice(start, end);
  22246. children.push(
  22247. createSimpleExpression(
  22248. id.name,
  22249. false,
  22250. {
  22251. start: advancePositionWithClone(node.loc.start, source, start),
  22252. end: advancePositionWithClone(node.loc.start, source, end),
  22253. source
  22254. },
  22255. id.isConstant ? 3 : 0
  22256. )
  22257. );
  22258. if (i === ids.length - 1 && end < rawExp.length) {
  22259. children.push(rawExp.slice(end));
  22260. }
  22261. });
  22262. let ret;
  22263. if (children.length) {
  22264. ret = createCompoundExpression(children, node.loc);
  22265. ret.ast = ast;
  22266. } else {
  22267. ret = node;
  22268. ret.constType = bailConstant ? 0 : 3;
  22269. }
  22270. ret.identifiers = Object.keys(knownIds);
  22271. return ret;
  22272. }
  22273. function canPrefix(id) {
  22274. if (isGloballyAllowed(id.name)) {
  22275. return false;
  22276. }
  22277. if (id.name === "require") {
  22278. return false;
  22279. }
  22280. return true;
  22281. }
  22282. function stringifyExpression(exp) {
  22283. if (isString$2(exp)) {
  22284. return exp;
  22285. } else if (exp.type === 4) {
  22286. return exp.content;
  22287. } else {
  22288. return exp.children.map(stringifyExpression).join("");
  22289. }
  22290. }
  22291. function isConst(type) {
  22292. return type === "setup-const" || type === "literal-const";
  22293. }
  22294. const transformIf = createStructuralDirectiveTransform(
  22295. /^(if|else|else-if)$/,
  22296. (node, dir, context) => {
  22297. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  22298. const siblings = context.parent.children;
  22299. let i = siblings.indexOf(ifNode);
  22300. let key = 0;
  22301. while (i-- >= 0) {
  22302. const sibling = siblings[i];
  22303. if (sibling && sibling.type === 9) {
  22304. key += sibling.branches.length;
  22305. }
  22306. }
  22307. return () => {
  22308. if (isRoot) {
  22309. ifNode.codegenNode = createCodegenNodeForBranch(
  22310. branch,
  22311. key,
  22312. context
  22313. );
  22314. } else {
  22315. const parentCondition = getParentCondition(ifNode.codegenNode);
  22316. parentCondition.alternate = createCodegenNodeForBranch(
  22317. branch,
  22318. key + ifNode.branches.length - 1,
  22319. context
  22320. );
  22321. }
  22322. };
  22323. });
  22324. }
  22325. );
  22326. function processIf(node, dir, context, processCodegen) {
  22327. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  22328. const loc = dir.exp ? dir.exp.loc : node.loc;
  22329. context.onError(
  22330. createCompilerError(28, dir.loc)
  22331. );
  22332. dir.exp = createSimpleExpression(`true`, false, loc);
  22333. }
  22334. if (context.prefixIdentifiers && dir.exp) {
  22335. dir.exp = processExpression(dir.exp, context);
  22336. }
  22337. if (dir.name === "if") {
  22338. const branch = createIfBranch(node, dir);
  22339. const ifNode = {
  22340. type: 9,
  22341. loc: node.loc,
  22342. branches: [branch]
  22343. };
  22344. context.replaceNode(ifNode);
  22345. if (processCodegen) {
  22346. return processCodegen(ifNode, branch, true);
  22347. }
  22348. } else {
  22349. const siblings = context.parent.children;
  22350. const comments = [];
  22351. let i = siblings.indexOf(node);
  22352. while (i-- >= -1) {
  22353. const sibling = siblings[i];
  22354. if (sibling && sibling.type === 3) {
  22355. context.removeNode(sibling);
  22356. comments.unshift(sibling);
  22357. continue;
  22358. }
  22359. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  22360. context.removeNode(sibling);
  22361. continue;
  22362. }
  22363. if (sibling && sibling.type === 9) {
  22364. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  22365. context.onError(
  22366. createCompilerError(30, node.loc)
  22367. );
  22368. }
  22369. context.removeNode();
  22370. const branch = createIfBranch(node, dir);
  22371. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  22372. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  22373. branch.children = [...comments, ...branch.children];
  22374. }
  22375. {
  22376. const key = branch.userKey;
  22377. if (key) {
  22378. sibling.branches.forEach(({ userKey }) => {
  22379. if (isSameKey(userKey, key)) {
  22380. context.onError(
  22381. createCompilerError(
  22382. 29,
  22383. branch.userKey.loc
  22384. )
  22385. );
  22386. }
  22387. });
  22388. }
  22389. }
  22390. sibling.branches.push(branch);
  22391. const onExit = processCodegen && processCodegen(sibling, branch, false);
  22392. traverseNode(branch, context);
  22393. if (onExit)
  22394. onExit();
  22395. context.currentNode = null;
  22396. } else {
  22397. context.onError(
  22398. createCompilerError(30, node.loc)
  22399. );
  22400. }
  22401. break;
  22402. }
  22403. }
  22404. }
  22405. function createIfBranch(node, dir) {
  22406. const isTemplateIf = node.tagType === 3;
  22407. return {
  22408. type: 10,
  22409. loc: node.loc,
  22410. condition: dir.name === "else" ? void 0 : dir.exp,
  22411. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  22412. userKey: findProp(node, `key`),
  22413. isTemplateIf
  22414. };
  22415. }
  22416. function createCodegenNodeForBranch(branch, keyIndex, context) {
  22417. if (branch.condition) {
  22418. return createConditionalExpression(
  22419. branch.condition,
  22420. createChildrenCodegenNode(branch, keyIndex, context),
  22421. // make sure to pass in asBlock: true so that the comment node call
  22422. // closes the current block.
  22423. createCallExpression(context.helper(CREATE_COMMENT), [
  22424. '"v-if"' ,
  22425. "true"
  22426. ])
  22427. );
  22428. } else {
  22429. return createChildrenCodegenNode(branch, keyIndex, context);
  22430. }
  22431. }
  22432. function createChildrenCodegenNode(branch, keyIndex, context) {
  22433. const { helper } = context;
  22434. const keyProperty = createObjectProperty(
  22435. `key`,
  22436. createSimpleExpression(
  22437. `${keyIndex}`,
  22438. false,
  22439. locStub,
  22440. 2
  22441. )
  22442. );
  22443. const { children } = branch;
  22444. const firstChild = children[0];
  22445. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  22446. if (needFragmentWrapper) {
  22447. if (children.length === 1 && firstChild.type === 11) {
  22448. const vnodeCall = firstChild.codegenNode;
  22449. injectProp(vnodeCall, keyProperty, context);
  22450. return vnodeCall;
  22451. } else {
  22452. let patchFlag = 64;
  22453. let patchFlagText = PatchFlagNames[64];
  22454. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  22455. patchFlag |= 2048;
  22456. patchFlagText += `, ${PatchFlagNames[2048]}`;
  22457. }
  22458. return createVNodeCall(
  22459. context,
  22460. helper(FRAGMENT),
  22461. createObjectExpression([keyProperty]),
  22462. children,
  22463. patchFlag + (` /* ${patchFlagText} */` ),
  22464. void 0,
  22465. void 0,
  22466. true,
  22467. false,
  22468. false,
  22469. branch.loc
  22470. );
  22471. }
  22472. } else {
  22473. const ret = firstChild.codegenNode;
  22474. const vnodeCall = getMemoedVNodeCall(ret);
  22475. if (vnodeCall.type === 13) {
  22476. convertToBlock(vnodeCall, context);
  22477. }
  22478. injectProp(vnodeCall, keyProperty, context);
  22479. return ret;
  22480. }
  22481. }
  22482. function isSameKey(a, b) {
  22483. if (!a || a.type !== b.type) {
  22484. return false;
  22485. }
  22486. if (a.type === 6) {
  22487. if (a.value.content !== b.value.content) {
  22488. return false;
  22489. }
  22490. } else {
  22491. const exp = a.exp;
  22492. const branchExp = b.exp;
  22493. if (exp.type !== branchExp.type) {
  22494. return false;
  22495. }
  22496. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  22497. return false;
  22498. }
  22499. }
  22500. return true;
  22501. }
  22502. function getParentCondition(node) {
  22503. while (true) {
  22504. if (node.type === 19) {
  22505. if (node.alternate.type === 19) {
  22506. node = node.alternate;
  22507. } else {
  22508. return node;
  22509. }
  22510. } else if (node.type === 20) {
  22511. node = node.value;
  22512. }
  22513. }
  22514. }
  22515. const transformFor = createStructuralDirectiveTransform(
  22516. "for",
  22517. (node, dir, context) => {
  22518. const { helper, removeHelper } = context;
  22519. return processFor(node, dir, context, (forNode) => {
  22520. const renderExp = createCallExpression(helper(RENDER_LIST), [
  22521. forNode.source
  22522. ]);
  22523. const isTemplate = isTemplateNode(node);
  22524. const memo = findDir(node, "memo");
  22525. const keyProp = findProp(node, `key`);
  22526. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  22527. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  22528. if (isTemplate) {
  22529. if (memo) {
  22530. memo.exp = processExpression(
  22531. memo.exp,
  22532. context
  22533. );
  22534. }
  22535. if (keyProperty && keyProp.type !== 6) {
  22536. keyProperty.value = processExpression(
  22537. keyProperty.value,
  22538. context
  22539. );
  22540. }
  22541. }
  22542. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  22543. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  22544. forNode.codegenNode = createVNodeCall(
  22545. context,
  22546. helper(FRAGMENT),
  22547. void 0,
  22548. renderExp,
  22549. fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
  22550. void 0,
  22551. void 0,
  22552. true,
  22553. !isStableFragment,
  22554. false,
  22555. node.loc
  22556. );
  22557. return () => {
  22558. let childBlock;
  22559. const { children } = forNode;
  22560. if (isTemplate) {
  22561. node.children.some((c) => {
  22562. if (c.type === 1) {
  22563. const key = findProp(c, "key");
  22564. if (key) {
  22565. context.onError(
  22566. createCompilerError(
  22567. 33,
  22568. key.loc
  22569. )
  22570. );
  22571. return true;
  22572. }
  22573. }
  22574. });
  22575. }
  22576. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  22577. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  22578. if (slotOutlet) {
  22579. childBlock = slotOutlet.codegenNode;
  22580. if (isTemplate && keyProperty) {
  22581. injectProp(childBlock, keyProperty, context);
  22582. }
  22583. } else if (needFragmentWrapper) {
  22584. childBlock = createVNodeCall(
  22585. context,
  22586. helper(FRAGMENT),
  22587. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  22588. node.children,
  22589. 64 + (` /* ${PatchFlagNames[64]} */` ),
  22590. void 0,
  22591. void 0,
  22592. true,
  22593. void 0,
  22594. false
  22595. );
  22596. } else {
  22597. childBlock = children[0].codegenNode;
  22598. if (isTemplate && keyProperty) {
  22599. injectProp(childBlock, keyProperty, context);
  22600. }
  22601. if (childBlock.isBlock !== !isStableFragment) {
  22602. if (childBlock.isBlock) {
  22603. removeHelper(OPEN_BLOCK);
  22604. removeHelper(
  22605. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  22606. );
  22607. } else {
  22608. removeHelper(
  22609. getVNodeHelper(context.inSSR, childBlock.isComponent)
  22610. );
  22611. }
  22612. }
  22613. childBlock.isBlock = !isStableFragment;
  22614. if (childBlock.isBlock) {
  22615. helper(OPEN_BLOCK);
  22616. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  22617. } else {
  22618. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  22619. }
  22620. }
  22621. if (memo) {
  22622. const loop = createFunctionExpression(
  22623. createForLoopParams(forNode.parseResult, [
  22624. createSimpleExpression(`_cached`)
  22625. ])
  22626. );
  22627. loop.body = createBlockStatement([
  22628. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  22629. createCompoundExpression([
  22630. `if (_cached`,
  22631. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  22632. ` && ${context.helperString(
  22633. IS_MEMO_SAME
  22634. )}(_cached, _memo)) return _cached`
  22635. ]),
  22636. createCompoundExpression([`const _item = `, childBlock]),
  22637. createSimpleExpression(`_item.memo = _memo`),
  22638. createSimpleExpression(`return _item`)
  22639. ]);
  22640. renderExp.arguments.push(
  22641. loop,
  22642. createSimpleExpression(`_cache`),
  22643. createSimpleExpression(String(context.cached++))
  22644. );
  22645. } else {
  22646. renderExp.arguments.push(
  22647. createFunctionExpression(
  22648. createForLoopParams(forNode.parseResult),
  22649. childBlock,
  22650. true
  22651. )
  22652. );
  22653. }
  22654. };
  22655. });
  22656. }
  22657. );
  22658. function processFor(node, dir, context, processCodegen) {
  22659. if (!dir.exp) {
  22660. context.onError(
  22661. createCompilerError(31, dir.loc)
  22662. );
  22663. return;
  22664. }
  22665. const parseResult = dir.forParseResult;
  22666. if (!parseResult) {
  22667. context.onError(
  22668. createCompilerError(32, dir.loc)
  22669. );
  22670. return;
  22671. }
  22672. finalizeForParseResult(parseResult, context);
  22673. const { addIdentifiers, removeIdentifiers, scopes } = context;
  22674. const { source, value, key, index } = parseResult;
  22675. const forNode = {
  22676. type: 11,
  22677. loc: dir.loc,
  22678. source,
  22679. valueAlias: value,
  22680. keyAlias: key,
  22681. objectIndexAlias: index,
  22682. parseResult,
  22683. children: isTemplateNode(node) ? node.children : [node]
  22684. };
  22685. context.replaceNode(forNode);
  22686. scopes.vFor++;
  22687. if (context.prefixIdentifiers) {
  22688. value && addIdentifiers(value);
  22689. key && addIdentifiers(key);
  22690. index && addIdentifiers(index);
  22691. }
  22692. const onExit = processCodegen && processCodegen(forNode);
  22693. return () => {
  22694. scopes.vFor--;
  22695. if (context.prefixIdentifiers) {
  22696. value && removeIdentifiers(value);
  22697. key && removeIdentifiers(key);
  22698. index && removeIdentifiers(index);
  22699. }
  22700. if (onExit)
  22701. onExit();
  22702. };
  22703. }
  22704. function finalizeForParseResult(result, context) {
  22705. if (result.finalized)
  22706. return;
  22707. if (context.prefixIdentifiers) {
  22708. result.source = processExpression(
  22709. result.source,
  22710. context
  22711. );
  22712. if (result.key) {
  22713. result.key = processExpression(
  22714. result.key,
  22715. context,
  22716. true
  22717. );
  22718. }
  22719. if (result.index) {
  22720. result.index = processExpression(
  22721. result.index,
  22722. context,
  22723. true
  22724. );
  22725. }
  22726. if (result.value) {
  22727. result.value = processExpression(
  22728. result.value,
  22729. context,
  22730. true
  22731. );
  22732. }
  22733. }
  22734. result.finalized = true;
  22735. }
  22736. function createForLoopParams({ value, key, index }, memoArgs = []) {
  22737. return createParamsList([value, key, index, ...memoArgs]);
  22738. }
  22739. function createParamsList(args) {
  22740. let i = args.length;
  22741. while (i--) {
  22742. if (args[i])
  22743. break;
  22744. }
  22745. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  22746. }
  22747. const defaultFallback = createSimpleExpression(`undefined`, false);
  22748. const trackSlotScopes = (node, context) => {
  22749. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  22750. const vSlot = findDir(node, "slot");
  22751. if (vSlot) {
  22752. const slotProps = vSlot.exp;
  22753. if (context.prefixIdentifiers) {
  22754. slotProps && context.addIdentifiers(slotProps);
  22755. }
  22756. context.scopes.vSlot++;
  22757. return () => {
  22758. if (context.prefixIdentifiers) {
  22759. slotProps && context.removeIdentifiers(slotProps);
  22760. }
  22761. context.scopes.vSlot--;
  22762. };
  22763. }
  22764. }
  22765. };
  22766. const trackVForSlotScopes = (node, context) => {
  22767. let vFor;
  22768. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  22769. const result = vFor.forParseResult;
  22770. if (result) {
  22771. finalizeForParseResult(result, context);
  22772. const { value, key, index } = result;
  22773. const { addIdentifiers, removeIdentifiers } = context;
  22774. value && addIdentifiers(value);
  22775. key && addIdentifiers(key);
  22776. index && addIdentifiers(index);
  22777. return () => {
  22778. value && removeIdentifiers(value);
  22779. key && removeIdentifiers(key);
  22780. index && removeIdentifiers(index);
  22781. };
  22782. }
  22783. }
  22784. };
  22785. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  22786. props,
  22787. children,
  22788. false,
  22789. true,
  22790. children.length ? children[0].loc : loc
  22791. );
  22792. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  22793. context.helper(WITH_CTX);
  22794. const { children, loc } = node;
  22795. const slotsProperties = [];
  22796. const dynamicSlots = [];
  22797. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  22798. if (!context.ssr && context.prefixIdentifiers) {
  22799. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  22800. }
  22801. const onComponentSlot = findDir(node, "slot", true);
  22802. if (onComponentSlot) {
  22803. const { arg, exp } = onComponentSlot;
  22804. if (arg && !isStaticExp(arg)) {
  22805. hasDynamicSlots = true;
  22806. }
  22807. slotsProperties.push(
  22808. createObjectProperty(
  22809. arg || createSimpleExpression("default", true),
  22810. buildSlotFn(exp, void 0, children, loc)
  22811. )
  22812. );
  22813. }
  22814. let hasTemplateSlots = false;
  22815. let hasNamedDefaultSlot = false;
  22816. const implicitDefaultChildren = [];
  22817. const seenSlotNames = /* @__PURE__ */ new Set();
  22818. let conditionalBranchIndex = 0;
  22819. for (let i = 0; i < children.length; i++) {
  22820. const slotElement = children[i];
  22821. let slotDir;
  22822. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  22823. if (slotElement.type !== 3) {
  22824. implicitDefaultChildren.push(slotElement);
  22825. }
  22826. continue;
  22827. }
  22828. if (onComponentSlot) {
  22829. context.onError(
  22830. createCompilerError(37, slotDir.loc)
  22831. );
  22832. break;
  22833. }
  22834. hasTemplateSlots = true;
  22835. const { children: slotChildren, loc: slotLoc } = slotElement;
  22836. const {
  22837. arg: slotName = createSimpleExpression(`default`, true),
  22838. exp: slotProps,
  22839. loc: dirLoc
  22840. } = slotDir;
  22841. let staticSlotName;
  22842. if (isStaticExp(slotName)) {
  22843. staticSlotName = slotName ? slotName.content : `default`;
  22844. } else {
  22845. hasDynamicSlots = true;
  22846. }
  22847. const vFor = findDir(slotElement, "for");
  22848. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  22849. let vIf;
  22850. let vElse;
  22851. if (vIf = findDir(slotElement, "if")) {
  22852. hasDynamicSlots = true;
  22853. dynamicSlots.push(
  22854. createConditionalExpression(
  22855. vIf.exp,
  22856. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  22857. defaultFallback
  22858. )
  22859. );
  22860. } else if (vElse = findDir(
  22861. slotElement,
  22862. /^else(-if)?$/,
  22863. true
  22864. /* allowEmpty */
  22865. )) {
  22866. let j = i;
  22867. let prev;
  22868. while (j--) {
  22869. prev = children[j];
  22870. if (prev.type !== 3) {
  22871. break;
  22872. }
  22873. }
  22874. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  22875. children.splice(i, 1);
  22876. i--;
  22877. let conditional = dynamicSlots[dynamicSlots.length - 1];
  22878. while (conditional.alternate.type === 19) {
  22879. conditional = conditional.alternate;
  22880. }
  22881. conditional.alternate = vElse.exp ? createConditionalExpression(
  22882. vElse.exp,
  22883. buildDynamicSlot(
  22884. slotName,
  22885. slotFunction,
  22886. conditionalBranchIndex++
  22887. ),
  22888. defaultFallback
  22889. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  22890. } else {
  22891. context.onError(
  22892. createCompilerError(30, vElse.loc)
  22893. );
  22894. }
  22895. } else if (vFor) {
  22896. hasDynamicSlots = true;
  22897. const parseResult = vFor.forParseResult;
  22898. if (parseResult) {
  22899. finalizeForParseResult(parseResult, context);
  22900. dynamicSlots.push(
  22901. createCallExpression(context.helper(RENDER_LIST), [
  22902. parseResult.source,
  22903. createFunctionExpression(
  22904. createForLoopParams(parseResult),
  22905. buildDynamicSlot(slotName, slotFunction),
  22906. true
  22907. )
  22908. ])
  22909. );
  22910. } else {
  22911. context.onError(
  22912. createCompilerError(
  22913. 32,
  22914. vFor.loc
  22915. )
  22916. );
  22917. }
  22918. } else {
  22919. if (staticSlotName) {
  22920. if (seenSlotNames.has(staticSlotName)) {
  22921. context.onError(
  22922. createCompilerError(
  22923. 38,
  22924. dirLoc
  22925. )
  22926. );
  22927. continue;
  22928. }
  22929. seenSlotNames.add(staticSlotName);
  22930. if (staticSlotName === "default") {
  22931. hasNamedDefaultSlot = true;
  22932. }
  22933. }
  22934. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  22935. }
  22936. }
  22937. if (!onComponentSlot) {
  22938. const buildDefaultSlotProperty = (props, children2) => {
  22939. const fn = buildSlotFn(props, void 0, children2, loc);
  22940. return createObjectProperty(`default`, fn);
  22941. };
  22942. if (!hasTemplateSlots) {
  22943. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  22944. } else if (implicitDefaultChildren.length && // #3766
  22945. // with whitespace: 'preserve', whitespaces between slots will end up in
  22946. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  22947. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  22948. if (hasNamedDefaultSlot) {
  22949. context.onError(
  22950. createCompilerError(
  22951. 39,
  22952. implicitDefaultChildren[0].loc
  22953. )
  22954. );
  22955. } else {
  22956. slotsProperties.push(
  22957. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  22958. );
  22959. }
  22960. }
  22961. }
  22962. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  22963. let slots = createObjectExpression(
  22964. slotsProperties.concat(
  22965. createObjectProperty(
  22966. `_`,
  22967. // 2 = compiled but dynamic = can skip normalization, but must run diff
  22968. // 1 = compiled and static = can skip normalization AND diff as optimized
  22969. createSimpleExpression(
  22970. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  22971. false
  22972. )
  22973. )
  22974. ),
  22975. loc
  22976. );
  22977. if (dynamicSlots.length) {
  22978. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  22979. slots,
  22980. createArrayExpression(dynamicSlots)
  22981. ]);
  22982. }
  22983. return {
  22984. slots,
  22985. hasDynamicSlots
  22986. };
  22987. }
  22988. function buildDynamicSlot(name, fn, index) {
  22989. const props = [
  22990. createObjectProperty(`name`, name),
  22991. createObjectProperty(`fn`, fn)
  22992. ];
  22993. if (index != null) {
  22994. props.push(
  22995. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  22996. );
  22997. }
  22998. return createObjectExpression(props);
  22999. }
  23000. function hasForwardedSlots(children) {
  23001. for (let i = 0; i < children.length; i++) {
  23002. const child = children[i];
  23003. switch (child.type) {
  23004. case 1:
  23005. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  23006. return true;
  23007. }
  23008. break;
  23009. case 9:
  23010. if (hasForwardedSlots(child.branches))
  23011. return true;
  23012. break;
  23013. case 10:
  23014. case 11:
  23015. if (hasForwardedSlots(child.children))
  23016. return true;
  23017. break;
  23018. }
  23019. }
  23020. return false;
  23021. }
  23022. function isNonWhitespaceContent(node) {
  23023. if (node.type !== 2 && node.type !== 12)
  23024. return true;
  23025. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  23026. }
  23027. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  23028. const transformElement = (node, context) => {
  23029. return function postTransformElement() {
  23030. node = context.currentNode;
  23031. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  23032. return;
  23033. }
  23034. const { tag, props } = node;
  23035. const isComponent = node.tagType === 1;
  23036. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  23037. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23038. let vnodeProps;
  23039. let vnodeChildren;
  23040. let vnodePatchFlag;
  23041. let patchFlag = 0;
  23042. let vnodeDynamicProps;
  23043. let dynamicPropNames;
  23044. let vnodeDirectives;
  23045. let shouldUseBlock = (
  23046. // dynamic component may resolve to plain elements
  23047. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23048. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23049. // This is technically web-specific, but splitting the logic out of core
  23050. // leads to too much unnecessary complexity.
  23051. (tag === "svg" || tag === "foreignObject")
  23052. );
  23053. if (props.length > 0) {
  23054. const propsBuildResult = buildProps(
  23055. node,
  23056. context,
  23057. void 0,
  23058. isComponent,
  23059. isDynamicComponent
  23060. );
  23061. vnodeProps = propsBuildResult.props;
  23062. patchFlag = propsBuildResult.patchFlag;
  23063. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23064. const directives = propsBuildResult.directives;
  23065. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23066. directives.map((dir) => buildDirectiveArgs(dir, context))
  23067. ) : void 0;
  23068. if (propsBuildResult.shouldUseBlock) {
  23069. shouldUseBlock = true;
  23070. }
  23071. }
  23072. if (node.children.length > 0) {
  23073. if (vnodeTag === KEEP_ALIVE) {
  23074. shouldUseBlock = true;
  23075. patchFlag |= 1024;
  23076. if (node.children.length > 1) {
  23077. context.onError(
  23078. createCompilerError(46, {
  23079. start: node.children[0].loc.start,
  23080. end: node.children[node.children.length - 1].loc.end,
  23081. source: ""
  23082. })
  23083. );
  23084. }
  23085. }
  23086. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  23087. vnodeTag !== TELEPORT && // explained above.
  23088. vnodeTag !== KEEP_ALIVE;
  23089. if (shouldBuildAsSlots) {
  23090. const { slots, hasDynamicSlots } = buildSlots(node, context);
  23091. vnodeChildren = slots;
  23092. if (hasDynamicSlots) {
  23093. patchFlag |= 1024;
  23094. }
  23095. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  23096. const child = node.children[0];
  23097. const type = child.type;
  23098. const hasDynamicTextChild = type === 5 || type === 8;
  23099. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  23100. patchFlag |= 1;
  23101. }
  23102. if (hasDynamicTextChild || type === 2) {
  23103. vnodeChildren = child;
  23104. } else {
  23105. vnodeChildren = node.children;
  23106. }
  23107. } else {
  23108. vnodeChildren = node.children;
  23109. }
  23110. }
  23111. if (patchFlag !== 0) {
  23112. {
  23113. if (patchFlag < 0) {
  23114. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  23115. } else {
  23116. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  23117. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  23118. }
  23119. }
  23120. if (dynamicPropNames && dynamicPropNames.length) {
  23121. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  23122. }
  23123. }
  23124. node.codegenNode = createVNodeCall(
  23125. context,
  23126. vnodeTag,
  23127. vnodeProps,
  23128. vnodeChildren,
  23129. vnodePatchFlag,
  23130. vnodeDynamicProps,
  23131. vnodeDirectives,
  23132. !!shouldUseBlock,
  23133. false,
  23134. isComponent,
  23135. node.loc
  23136. );
  23137. };
  23138. };
  23139. function resolveComponentType(node, context, ssr = false) {
  23140. let { tag } = node;
  23141. const isExplicitDynamic = isComponentTag(tag);
  23142. const isProp = findProp(
  23143. node,
  23144. "is",
  23145. false,
  23146. true
  23147. /* allow empty */
  23148. );
  23149. if (isProp) {
  23150. if (isExplicitDynamic || false) {
  23151. let exp;
  23152. if (isProp.type === 6) {
  23153. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  23154. } else {
  23155. exp = isProp.exp;
  23156. if (!exp) {
  23157. exp = createSimpleExpression(`is`, false, isProp.loc);
  23158. {
  23159. exp = isProp.exp = processExpression(exp, context);
  23160. }
  23161. }
  23162. }
  23163. if (exp) {
  23164. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  23165. exp
  23166. ]);
  23167. }
  23168. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  23169. tag = isProp.value.content.slice(4);
  23170. }
  23171. }
  23172. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  23173. if (builtIn) {
  23174. if (!ssr)
  23175. context.helper(builtIn);
  23176. return builtIn;
  23177. }
  23178. {
  23179. const fromSetup = resolveSetupReference(tag, context);
  23180. if (fromSetup) {
  23181. return fromSetup;
  23182. }
  23183. const dotIndex = tag.indexOf(".");
  23184. if (dotIndex > 0) {
  23185. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  23186. if (ns) {
  23187. return ns + tag.slice(dotIndex);
  23188. }
  23189. }
  23190. }
  23191. if (context.selfName && capitalize$1(camelize(tag)) === context.selfName) {
  23192. context.helper(RESOLVE_COMPONENT);
  23193. context.components.add(tag + `__self`);
  23194. return toValidAssetId(tag, `component`);
  23195. }
  23196. context.helper(RESOLVE_COMPONENT);
  23197. context.components.add(tag);
  23198. return toValidAssetId(tag, `component`);
  23199. }
  23200. function resolveSetupReference(name, context) {
  23201. const bindings = context.bindingMetadata;
  23202. if (!bindings || bindings.__isScriptSetup === false) {
  23203. return;
  23204. }
  23205. const camelName = camelize(name);
  23206. const PascalName = capitalize$1(camelName);
  23207. const checkType = (type) => {
  23208. if (bindings[name] === type) {
  23209. return name;
  23210. }
  23211. if (bindings[camelName] === type) {
  23212. return camelName;
  23213. }
  23214. if (bindings[PascalName] === type) {
  23215. return PascalName;
  23216. }
  23217. };
  23218. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  23219. if (fromConst) {
  23220. return context.inline ? (
  23221. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  23222. fromConst
  23223. ) : `$setup[${JSON.stringify(fromConst)}]`;
  23224. }
  23225. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  23226. if (fromMaybeRef) {
  23227. return context.inline ? (
  23228. // setup scope bindings that may be refs need to be unrefed
  23229. `${context.helperString(UNREF)}(${fromMaybeRef})`
  23230. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  23231. }
  23232. const fromProps = checkType("props");
  23233. if (fromProps) {
  23234. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  23235. }
  23236. }
  23237. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  23238. const { tag, loc: elementLoc, children } = node;
  23239. let properties = [];
  23240. const mergeArgs = [];
  23241. const runtimeDirectives = [];
  23242. const hasChildren = children.length > 0;
  23243. let shouldUseBlock = false;
  23244. let patchFlag = 0;
  23245. let hasRef = false;
  23246. let hasClassBinding = false;
  23247. let hasStyleBinding = false;
  23248. let hasHydrationEventBinding = false;
  23249. let hasDynamicKeys = false;
  23250. let hasVnodeHook = false;
  23251. const dynamicPropNames = [];
  23252. const pushMergeArg = (arg) => {
  23253. if (properties.length) {
  23254. mergeArgs.push(
  23255. createObjectExpression(dedupeProperties(properties), elementLoc)
  23256. );
  23257. properties = [];
  23258. }
  23259. if (arg)
  23260. mergeArgs.push(arg);
  23261. };
  23262. const analyzePatchFlag = ({ key, value }) => {
  23263. if (isStaticExp(key)) {
  23264. const name = key.content;
  23265. const isEventHandler = isOn(name);
  23266. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  23267. // dedicated fast path.
  23268. name.toLowerCase() !== "onclick" && // omit v-model handlers
  23269. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  23270. !isReservedProp(name)) {
  23271. hasHydrationEventBinding = true;
  23272. }
  23273. if (isEventHandler && isReservedProp(name)) {
  23274. hasVnodeHook = true;
  23275. }
  23276. if (isEventHandler && value.type === 14) {
  23277. value = value.arguments[0];
  23278. }
  23279. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  23280. return;
  23281. }
  23282. if (name === "ref") {
  23283. hasRef = true;
  23284. } else if (name === "class") {
  23285. hasClassBinding = true;
  23286. } else if (name === "style") {
  23287. hasStyleBinding = true;
  23288. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  23289. dynamicPropNames.push(name);
  23290. }
  23291. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  23292. dynamicPropNames.push(name);
  23293. }
  23294. } else {
  23295. hasDynamicKeys = true;
  23296. }
  23297. };
  23298. for (let i = 0; i < props.length; i++) {
  23299. const prop = props[i];
  23300. if (prop.type === 6) {
  23301. const { loc, name, nameLoc, value } = prop;
  23302. let isStatic = true;
  23303. if (name === "ref") {
  23304. hasRef = true;
  23305. if (context.scopes.vFor > 0) {
  23306. properties.push(
  23307. createObjectProperty(
  23308. createSimpleExpression("ref_for", true),
  23309. createSimpleExpression("true")
  23310. )
  23311. );
  23312. }
  23313. if (value && context.inline) {
  23314. const binding = context.bindingMetadata[value.content];
  23315. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  23316. isStatic = false;
  23317. properties.push(
  23318. createObjectProperty(
  23319. createSimpleExpression("ref_key", true),
  23320. createSimpleExpression(value.content, true, value.loc)
  23321. )
  23322. );
  23323. }
  23324. }
  23325. }
  23326. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  23327. continue;
  23328. }
  23329. properties.push(
  23330. createObjectProperty(
  23331. createSimpleExpression(name, true, nameLoc),
  23332. createSimpleExpression(
  23333. value ? value.content : "",
  23334. isStatic,
  23335. value ? value.loc : loc
  23336. )
  23337. )
  23338. );
  23339. } else {
  23340. const { name, arg, exp, loc, modifiers } = prop;
  23341. const isVBind = name === "bind";
  23342. const isVOn = name === "on";
  23343. if (name === "slot") {
  23344. if (!isComponent) {
  23345. context.onError(
  23346. createCompilerError(40, loc)
  23347. );
  23348. }
  23349. continue;
  23350. }
  23351. if (name === "once" || name === "memo") {
  23352. continue;
  23353. }
  23354. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  23355. continue;
  23356. }
  23357. if (isVOn && ssr) {
  23358. continue;
  23359. }
  23360. if (
  23361. // #938: elements with dynamic keys should be forced into blocks
  23362. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  23363. // before children
  23364. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  23365. ) {
  23366. shouldUseBlock = true;
  23367. }
  23368. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  23369. properties.push(
  23370. createObjectProperty(
  23371. createSimpleExpression("ref_for", true),
  23372. createSimpleExpression("true")
  23373. )
  23374. );
  23375. }
  23376. if (!arg && (isVBind || isVOn)) {
  23377. hasDynamicKeys = true;
  23378. if (exp) {
  23379. if (isVBind) {
  23380. pushMergeArg();
  23381. mergeArgs.push(exp);
  23382. } else {
  23383. pushMergeArg({
  23384. type: 14,
  23385. loc,
  23386. callee: context.helper(TO_HANDLERS),
  23387. arguments: isComponent ? [exp] : [exp, `true`]
  23388. });
  23389. }
  23390. } else {
  23391. context.onError(
  23392. createCompilerError(
  23393. isVBind ? 34 : 35,
  23394. loc
  23395. )
  23396. );
  23397. }
  23398. continue;
  23399. }
  23400. if (isVBind && modifiers.includes("prop")) {
  23401. patchFlag |= 32;
  23402. }
  23403. const directiveTransform = context.directiveTransforms[name];
  23404. if (directiveTransform) {
  23405. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  23406. !ssr && props2.forEach(analyzePatchFlag);
  23407. if (isVOn && arg && !isStaticExp(arg)) {
  23408. pushMergeArg(createObjectExpression(props2, elementLoc));
  23409. } else {
  23410. properties.push(...props2);
  23411. }
  23412. if (needRuntime) {
  23413. runtimeDirectives.push(prop);
  23414. if (isSymbol$1(needRuntime)) {
  23415. directiveImportMap.set(prop, needRuntime);
  23416. }
  23417. }
  23418. } else if (!isBuiltInDirective(name)) {
  23419. runtimeDirectives.push(prop);
  23420. if (hasChildren) {
  23421. shouldUseBlock = true;
  23422. }
  23423. }
  23424. }
  23425. }
  23426. let propsExpression = void 0;
  23427. if (mergeArgs.length) {
  23428. pushMergeArg();
  23429. if (mergeArgs.length > 1) {
  23430. propsExpression = createCallExpression(
  23431. context.helper(MERGE_PROPS),
  23432. mergeArgs,
  23433. elementLoc
  23434. );
  23435. } else {
  23436. propsExpression = mergeArgs[0];
  23437. }
  23438. } else if (properties.length) {
  23439. propsExpression = createObjectExpression(
  23440. dedupeProperties(properties),
  23441. elementLoc
  23442. );
  23443. }
  23444. if (hasDynamicKeys) {
  23445. patchFlag |= 16;
  23446. } else {
  23447. if (hasClassBinding && !isComponent) {
  23448. patchFlag |= 2;
  23449. }
  23450. if (hasStyleBinding && !isComponent) {
  23451. patchFlag |= 4;
  23452. }
  23453. if (dynamicPropNames.length) {
  23454. patchFlag |= 8;
  23455. }
  23456. if (hasHydrationEventBinding) {
  23457. patchFlag |= 32;
  23458. }
  23459. }
  23460. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  23461. patchFlag |= 512;
  23462. }
  23463. if (!context.inSSR && propsExpression) {
  23464. switch (propsExpression.type) {
  23465. case 15:
  23466. let classKeyIndex = -1;
  23467. let styleKeyIndex = -1;
  23468. let hasDynamicKey = false;
  23469. for (let i = 0; i < propsExpression.properties.length; i++) {
  23470. const key = propsExpression.properties[i].key;
  23471. if (isStaticExp(key)) {
  23472. if (key.content === "class") {
  23473. classKeyIndex = i;
  23474. } else if (key.content === "style") {
  23475. styleKeyIndex = i;
  23476. }
  23477. } else if (!key.isHandlerKey) {
  23478. hasDynamicKey = true;
  23479. }
  23480. }
  23481. const classProp = propsExpression.properties[classKeyIndex];
  23482. const styleProp = propsExpression.properties[styleKeyIndex];
  23483. if (!hasDynamicKey) {
  23484. if (classProp && !isStaticExp(classProp.value)) {
  23485. classProp.value = createCallExpression(
  23486. context.helper(NORMALIZE_CLASS),
  23487. [classProp.value]
  23488. );
  23489. }
  23490. if (styleProp && // the static style is compiled into an object,
  23491. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  23492. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  23493. // v-bind:style with static literal object
  23494. styleProp.value.type === 17)) {
  23495. styleProp.value = createCallExpression(
  23496. context.helper(NORMALIZE_STYLE),
  23497. [styleProp.value]
  23498. );
  23499. }
  23500. } else {
  23501. propsExpression = createCallExpression(
  23502. context.helper(NORMALIZE_PROPS),
  23503. [propsExpression]
  23504. );
  23505. }
  23506. break;
  23507. case 14:
  23508. break;
  23509. default:
  23510. propsExpression = createCallExpression(
  23511. context.helper(NORMALIZE_PROPS),
  23512. [
  23513. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  23514. propsExpression
  23515. ])
  23516. ]
  23517. );
  23518. break;
  23519. }
  23520. }
  23521. return {
  23522. props: propsExpression,
  23523. directives: runtimeDirectives,
  23524. patchFlag,
  23525. dynamicPropNames,
  23526. shouldUseBlock
  23527. };
  23528. }
  23529. function dedupeProperties(properties) {
  23530. const knownProps = /* @__PURE__ */ new Map();
  23531. const deduped = [];
  23532. for (let i = 0; i < properties.length; i++) {
  23533. const prop = properties[i];
  23534. if (prop.key.type === 8 || !prop.key.isStatic) {
  23535. deduped.push(prop);
  23536. continue;
  23537. }
  23538. const name = prop.key.content;
  23539. const existing = knownProps.get(name);
  23540. if (existing) {
  23541. if (name === "style" || name === "class" || isOn(name)) {
  23542. mergeAsArray(existing, prop);
  23543. }
  23544. } else {
  23545. knownProps.set(name, prop);
  23546. deduped.push(prop);
  23547. }
  23548. }
  23549. return deduped;
  23550. }
  23551. function mergeAsArray(existing, incoming) {
  23552. if (existing.value.type === 17) {
  23553. existing.value.elements.push(incoming.value);
  23554. } else {
  23555. existing.value = createArrayExpression(
  23556. [existing.value, incoming.value],
  23557. existing.loc
  23558. );
  23559. }
  23560. }
  23561. function buildDirectiveArgs(dir, context) {
  23562. const dirArgs = [];
  23563. const runtime = directiveImportMap.get(dir);
  23564. if (runtime) {
  23565. dirArgs.push(context.helperString(runtime));
  23566. } else {
  23567. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  23568. if (fromSetup) {
  23569. dirArgs.push(fromSetup);
  23570. } else {
  23571. context.helper(RESOLVE_DIRECTIVE);
  23572. context.directives.add(dir.name);
  23573. dirArgs.push(toValidAssetId(dir.name, `directive`));
  23574. }
  23575. }
  23576. const { loc } = dir;
  23577. if (dir.exp)
  23578. dirArgs.push(dir.exp);
  23579. if (dir.arg) {
  23580. if (!dir.exp) {
  23581. dirArgs.push(`void 0`);
  23582. }
  23583. dirArgs.push(dir.arg);
  23584. }
  23585. if (Object.keys(dir.modifiers).length) {
  23586. if (!dir.arg) {
  23587. if (!dir.exp) {
  23588. dirArgs.push(`void 0`);
  23589. }
  23590. dirArgs.push(`void 0`);
  23591. }
  23592. const trueExpression = createSimpleExpression(`true`, false, loc);
  23593. dirArgs.push(
  23594. createObjectExpression(
  23595. dir.modifiers.map(
  23596. (modifier) => createObjectProperty(modifier, trueExpression)
  23597. ),
  23598. loc
  23599. )
  23600. );
  23601. }
  23602. return createArrayExpression(dirArgs, dir.loc);
  23603. }
  23604. function stringifyDynamicPropNames(props) {
  23605. let propsNamesString = `[`;
  23606. for (let i = 0, l = props.length; i < l; i++) {
  23607. propsNamesString += JSON.stringify(props[i]);
  23608. if (i < l - 1)
  23609. propsNamesString += ", ";
  23610. }
  23611. return propsNamesString + `]`;
  23612. }
  23613. function isComponentTag(tag) {
  23614. return tag === "component" || tag === "Component";
  23615. }
  23616. const transformSlotOutlet = (node, context) => {
  23617. if (isSlotOutlet(node)) {
  23618. const { children, loc } = node;
  23619. const { slotName, slotProps } = processSlotOutlet(node, context);
  23620. const slotArgs = [
  23621. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  23622. slotName,
  23623. "{}",
  23624. "undefined",
  23625. "true"
  23626. ];
  23627. let expectedLen = 2;
  23628. if (slotProps) {
  23629. slotArgs[2] = slotProps;
  23630. expectedLen = 3;
  23631. }
  23632. if (children.length) {
  23633. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  23634. expectedLen = 4;
  23635. }
  23636. if (context.scopeId && !context.slotted) {
  23637. expectedLen = 5;
  23638. }
  23639. slotArgs.splice(expectedLen);
  23640. node.codegenNode = createCallExpression(
  23641. context.helper(RENDER_SLOT),
  23642. slotArgs,
  23643. loc
  23644. );
  23645. }
  23646. };
  23647. function processSlotOutlet(node, context) {
  23648. let slotName = `"default"`;
  23649. let slotProps = void 0;
  23650. const nonNameProps = [];
  23651. for (let i = 0; i < node.props.length; i++) {
  23652. const p = node.props[i];
  23653. if (p.type === 6) {
  23654. if (p.value) {
  23655. if (p.name === "name") {
  23656. slotName = JSON.stringify(p.value.content);
  23657. } else {
  23658. p.name = camelize(p.name);
  23659. nonNameProps.push(p);
  23660. }
  23661. }
  23662. } else {
  23663. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  23664. if (p.exp) {
  23665. slotName = p.exp;
  23666. } else if (p.arg && p.arg.type === 4) {
  23667. const name = camelize(p.arg.content);
  23668. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  23669. {
  23670. slotName = p.exp = processExpression(p.exp, context);
  23671. }
  23672. }
  23673. } else {
  23674. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  23675. p.arg.content = camelize(p.arg.content);
  23676. }
  23677. nonNameProps.push(p);
  23678. }
  23679. }
  23680. }
  23681. if (nonNameProps.length > 0) {
  23682. const { props, directives } = buildProps(
  23683. node,
  23684. context,
  23685. nonNameProps,
  23686. false,
  23687. false
  23688. );
  23689. slotProps = props;
  23690. if (directives.length) {
  23691. context.onError(
  23692. createCompilerError(
  23693. 36,
  23694. directives[0].loc
  23695. )
  23696. );
  23697. }
  23698. }
  23699. return {
  23700. slotName,
  23701. slotProps
  23702. };
  23703. }
  23704. const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  23705. const transformOn$1 = (dir, node, context, augmentor) => {
  23706. const { loc, modifiers, arg } = dir;
  23707. if (!dir.exp && !modifiers.length) {
  23708. context.onError(createCompilerError(35, loc));
  23709. }
  23710. let eventName;
  23711. if (arg.type === 4) {
  23712. if (arg.isStatic) {
  23713. let rawName = arg.content;
  23714. if (rawName.startsWith("vnode")) {
  23715. context.onError(createCompilerError(51, arg.loc));
  23716. }
  23717. if (rawName.startsWith("vue:")) {
  23718. rawName = `vnode-${rawName.slice(4)}`;
  23719. }
  23720. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  23721. // for non-element and vnode lifecycle event listeners, auto convert
  23722. // it to camelCase. See issue #2249
  23723. toHandlerKey(camelize(rawName))
  23724. ) : (
  23725. // preserve case for plain element listeners that have uppercase
  23726. // letters, as these may be custom elements' custom events
  23727. `on:${rawName}`
  23728. );
  23729. eventName = createSimpleExpression(eventString, true, arg.loc);
  23730. } else {
  23731. eventName = createCompoundExpression([
  23732. `${context.helperString(TO_HANDLER_KEY)}(`,
  23733. arg,
  23734. `)`
  23735. ]);
  23736. }
  23737. } else {
  23738. eventName = arg;
  23739. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  23740. eventName.children.push(`)`);
  23741. }
  23742. let exp = dir.exp;
  23743. if (exp && !exp.content.trim()) {
  23744. exp = void 0;
  23745. }
  23746. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  23747. if (exp) {
  23748. const isMemberExp = isMemberExpression(exp.content, context);
  23749. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  23750. const hasMultipleStatements = exp.content.includes(`;`);
  23751. if (context.prefixIdentifiers) {
  23752. isInlineStatement && context.addIdentifiers(`$event`);
  23753. exp = dir.exp = processExpression(
  23754. exp,
  23755. context,
  23756. false,
  23757. hasMultipleStatements
  23758. );
  23759. isInlineStatement && context.removeIdentifiers(`$event`);
  23760. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  23761. !context.inVOnce && // runtime constants don't need to be cached
  23762. // (this is analyzed by compileScript in SFC <script setup>)
  23763. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  23764. // we need to use the original function to preserve arity,
  23765. // e.g. <transition> relies on checking cb.length to determine
  23766. // transition end handling. Inline function is ok since its arity
  23767. // is preserved even when cached.
  23768. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  23769. // it must be passed fresh to avoid stale values.
  23770. !hasScopeRef(exp, context.identifiers);
  23771. if (shouldCache && isMemberExp) {
  23772. if (exp.type === 4) {
  23773. exp.content = `${exp.content} && ${exp.content}(...args)`;
  23774. } else {
  23775. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  23776. }
  23777. }
  23778. }
  23779. if (isInlineStatement || shouldCache && isMemberExp) {
  23780. exp = createCompoundExpression([
  23781. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  23782. //@ts-ignore
  23783. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  23784. exp,
  23785. hasMultipleStatements ? `}` : `)`
  23786. ]);
  23787. }
  23788. }
  23789. let ret = {
  23790. props: [
  23791. createObjectProperty(
  23792. eventName,
  23793. exp || createSimpleExpression(`() => {}`, false, loc)
  23794. )
  23795. ]
  23796. };
  23797. if (augmentor) {
  23798. ret = augmentor(ret);
  23799. }
  23800. if (shouldCache) {
  23801. ret.props[0].value = context.cache(ret.props[0].value);
  23802. }
  23803. ret.props.forEach((p) => p.key.isHandlerKey = true);
  23804. return ret;
  23805. };
  23806. const transformBind = (dir, _node, context) => {
  23807. const { modifiers, loc } = dir;
  23808. const arg = dir.arg;
  23809. let { exp } = dir;
  23810. if (exp && exp.type === 4 && !exp.content.trim()) {
  23811. {
  23812. context.onError(
  23813. createCompilerError(34, loc)
  23814. );
  23815. return {
  23816. props: [
  23817. createObjectProperty(arg, createSimpleExpression("", true, loc))
  23818. ]
  23819. };
  23820. }
  23821. }
  23822. if (!exp) {
  23823. if (arg.type !== 4 || !arg.isStatic) {
  23824. context.onError(
  23825. createCompilerError(
  23826. 52,
  23827. arg.loc
  23828. )
  23829. );
  23830. return {
  23831. props: [
  23832. createObjectProperty(arg, createSimpleExpression("", true, loc))
  23833. ]
  23834. };
  23835. }
  23836. const propName = camelize(arg.content);
  23837. exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
  23838. {
  23839. exp = dir.exp = processExpression(exp, context);
  23840. }
  23841. }
  23842. if (arg.type !== 4) {
  23843. arg.children.unshift(`(`);
  23844. arg.children.push(`) || ""`);
  23845. } else if (!arg.isStatic) {
  23846. arg.content = `${arg.content} || ""`;
  23847. }
  23848. if (modifiers.includes("camel")) {
  23849. if (arg.type === 4) {
  23850. if (arg.isStatic) {
  23851. arg.content = camelize(arg.content);
  23852. } else {
  23853. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  23854. }
  23855. } else {
  23856. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  23857. arg.children.push(`)`);
  23858. }
  23859. }
  23860. if (!context.inSSR) {
  23861. if (modifiers.includes("prop")) {
  23862. injectPrefix(arg, ".");
  23863. }
  23864. if (modifiers.includes("attr")) {
  23865. injectPrefix(arg, "^");
  23866. }
  23867. }
  23868. return {
  23869. props: [createObjectProperty(arg, exp)]
  23870. };
  23871. };
  23872. const injectPrefix = (arg, prefix) => {
  23873. if (arg.type === 4) {
  23874. if (arg.isStatic) {
  23875. arg.content = prefix + arg.content;
  23876. } else {
  23877. arg.content = `\`${prefix}\${${arg.content}}\``;
  23878. }
  23879. } else {
  23880. arg.children.unshift(`'${prefix}' + (`);
  23881. arg.children.push(`)`);
  23882. }
  23883. };
  23884. const transformText = (node, context) => {
  23885. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  23886. return () => {
  23887. const children = node.children;
  23888. let currentContainer = void 0;
  23889. let hasText = false;
  23890. for (let i = 0; i < children.length; i++) {
  23891. const child = children[i];
  23892. if (isText$1(child)) {
  23893. hasText = true;
  23894. for (let j = i + 1; j < children.length; j++) {
  23895. const next = children[j];
  23896. if (isText$1(next)) {
  23897. if (!currentContainer) {
  23898. currentContainer = children[i] = createCompoundExpression(
  23899. [child],
  23900. child.loc
  23901. );
  23902. }
  23903. currentContainer.children.push(` + `, next);
  23904. children.splice(j, 1);
  23905. j--;
  23906. } else {
  23907. currentContainer = void 0;
  23908. break;
  23909. }
  23910. }
  23911. }
  23912. }
  23913. if (!hasText || // if this is a plain element with a single text child, leave it
  23914. // as-is since the runtime has dedicated fast path for this by directly
  23915. // setting textContent of the element.
  23916. // for component root it's always normalized anyway.
  23917. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  23918. // custom directives can potentially add DOM elements arbitrarily,
  23919. // we need to avoid setting textContent of the element at runtime
  23920. // to avoid accidentally overwriting the DOM elements added
  23921. // by the user through custom directives.
  23922. !node.props.find(
  23923. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  23924. ) && // in compat mode, <template> tags with no special directives
  23925. // will be rendered as a fragment so its children must be
  23926. // converted into vnodes.
  23927. true)) {
  23928. return;
  23929. }
  23930. for (let i = 0; i < children.length; i++) {
  23931. const child = children[i];
  23932. if (isText$1(child) || child.type === 8) {
  23933. const callArgs = [];
  23934. if (child.type !== 2 || child.content !== " ") {
  23935. callArgs.push(child);
  23936. }
  23937. if (!context.ssr && getConstantType(child, context) === 0) {
  23938. callArgs.push(
  23939. 1 + (` /* ${PatchFlagNames[1]} */` )
  23940. );
  23941. }
  23942. children[i] = {
  23943. type: 12,
  23944. content: child,
  23945. loc: child.loc,
  23946. codegenNode: createCallExpression(
  23947. context.helper(CREATE_TEXT),
  23948. callArgs
  23949. )
  23950. };
  23951. }
  23952. }
  23953. };
  23954. }
  23955. };
  23956. const seen$1 = /* @__PURE__ */ new WeakSet();
  23957. const transformOnce = (node, context) => {
  23958. if (node.type === 1 && findDir(node, "once", true)) {
  23959. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  23960. return;
  23961. }
  23962. seen$1.add(node);
  23963. context.inVOnce = true;
  23964. context.helper(SET_BLOCK_TRACKING);
  23965. return () => {
  23966. context.inVOnce = false;
  23967. const cur = context.currentNode;
  23968. if (cur.codegenNode) {
  23969. cur.codegenNode = context.cache(
  23970. cur.codegenNode,
  23971. true
  23972. /* isVNode */
  23973. );
  23974. }
  23975. };
  23976. }
  23977. };
  23978. const transformModel$1 = (dir, node, context) => {
  23979. const { exp, arg } = dir;
  23980. if (!exp) {
  23981. context.onError(
  23982. createCompilerError(41, dir.loc)
  23983. );
  23984. return createTransformProps();
  23985. }
  23986. const rawExp = exp.loc.source;
  23987. const expString = exp.type === 4 ? exp.content : rawExp;
  23988. const bindingType = context.bindingMetadata[rawExp];
  23989. if (bindingType === "props" || bindingType === "props-aliased") {
  23990. context.onError(createCompilerError(44, exp.loc));
  23991. return createTransformProps();
  23992. }
  23993. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  23994. if (!expString.trim() || !isMemberExpression(expString, context) && !maybeRef) {
  23995. context.onError(
  23996. createCompilerError(42, exp.loc)
  23997. );
  23998. return createTransformProps();
  23999. }
  24000. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  24001. context.onError(
  24002. createCompilerError(43, exp.loc)
  24003. );
  24004. return createTransformProps();
  24005. }
  24006. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  24007. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  24008. let assignmentExp;
  24009. const eventArg = context.isTS ? `($event: any)` : `$event`;
  24010. if (maybeRef) {
  24011. if (bindingType === "setup-ref") {
  24012. assignmentExp = createCompoundExpression([
  24013. `${eventArg} => ((`,
  24014. createSimpleExpression(rawExp, false, exp.loc),
  24015. `).value = $event)`
  24016. ]);
  24017. } else {
  24018. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  24019. assignmentExp = createCompoundExpression([
  24020. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  24021. createSimpleExpression(rawExp, false, exp.loc),
  24022. `).value = $event : ${altAssignment})`
  24023. ]);
  24024. }
  24025. } else {
  24026. assignmentExp = createCompoundExpression([
  24027. `${eventArg} => ((`,
  24028. exp,
  24029. `) = $event)`
  24030. ]);
  24031. }
  24032. const props = [
  24033. // modelValue: foo
  24034. createObjectProperty(propName, dir.exp),
  24035. // "onUpdate:modelValue": $event => (foo = $event)
  24036. createObjectProperty(eventName, assignmentExp)
  24037. ];
  24038. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  24039. props[1].value = context.cache(props[1].value);
  24040. }
  24041. if (dir.modifiers.length && node.tagType === 1) {
  24042. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  24043. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  24044. props.push(
  24045. createObjectProperty(
  24046. modifiersKey,
  24047. createSimpleExpression(
  24048. `{ ${modifiers} }`,
  24049. false,
  24050. dir.loc,
  24051. 2
  24052. )
  24053. )
  24054. );
  24055. }
  24056. return createTransformProps(props);
  24057. };
  24058. function createTransformProps(props = []) {
  24059. return { props };
  24060. }
  24061. const seen = /* @__PURE__ */ new WeakSet();
  24062. const transformMemo = (node, context) => {
  24063. if (node.type === 1) {
  24064. const dir = findDir(node, "memo");
  24065. if (!dir || seen.has(node)) {
  24066. return;
  24067. }
  24068. seen.add(node);
  24069. return () => {
  24070. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24071. if (codegenNode && codegenNode.type === 13) {
  24072. if (node.tagType !== 1) {
  24073. convertToBlock(codegenNode, context);
  24074. }
  24075. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24076. dir.exp,
  24077. createFunctionExpression(void 0, codegenNode),
  24078. `_cache`,
  24079. String(context.cached++)
  24080. ]);
  24081. }
  24082. };
  24083. }
  24084. };
  24085. function getBaseTransformPreset(prefixIdentifiers) {
  24086. return [
  24087. [
  24088. transformOnce,
  24089. transformIf,
  24090. transformMemo,
  24091. transformFor,
  24092. ...[],
  24093. ...prefixIdentifiers ? [
  24094. // order is important
  24095. trackVForSlotScopes,
  24096. transformExpression
  24097. ] : [],
  24098. transformSlotOutlet,
  24099. transformElement,
  24100. trackSlotScopes,
  24101. transformText
  24102. ],
  24103. {
  24104. on: transformOn$1,
  24105. bind: transformBind,
  24106. model: transformModel$1
  24107. }
  24108. ];
  24109. }
  24110. function baseCompile(source, options = {}) {
  24111. const onError = options.onError || defaultOnError;
  24112. const isModuleMode = options.mode === "module";
  24113. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  24114. if (!prefixIdentifiers && options.cacheHandlers) {
  24115. onError(createCompilerError(49));
  24116. }
  24117. if (options.scopeId && !isModuleMode) {
  24118. onError(createCompilerError(50));
  24119. }
  24120. const resolvedOptions = extend({}, options, {
  24121. prefixIdentifiers
  24122. });
  24123. const ast = isString$2(source) ? baseParse(source, resolvedOptions) : source;
  24124. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  24125. if (options.isTS) {
  24126. const { expressionPlugins } = options;
  24127. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  24128. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  24129. }
  24130. }
  24131. transform(
  24132. ast,
  24133. extend({}, resolvedOptions, {
  24134. nodeTransforms: [
  24135. ...nodeTransforms,
  24136. ...options.nodeTransforms || []
  24137. // user transforms
  24138. ],
  24139. directiveTransforms: extend(
  24140. {},
  24141. directiveTransforms,
  24142. options.directiveTransforms || {}
  24143. // user transforms
  24144. )
  24145. })
  24146. );
  24147. return generate(ast, resolvedOptions);
  24148. }
  24149. const BindingTypes = {
  24150. "DATA": "data",
  24151. "PROPS": "props",
  24152. "PROPS_ALIASED": "props-aliased",
  24153. "SETUP_LET": "setup-let",
  24154. "SETUP_CONST": "setup-const",
  24155. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  24156. "SETUP_MAYBE_REF": "setup-maybe-ref",
  24157. "SETUP_REF": "setup-ref",
  24158. "OPTIONS": "options",
  24159. "LITERAL_CONST": "literal-const"
  24160. };
  24161. const noopDirectiveTransform = () => ({ props: [] });
  24162. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  24163. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  24164. const V_MODEL_TEXT = Symbol(`vModelText` );
  24165. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  24166. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  24167. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  24168. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  24169. const V_SHOW = Symbol(`vShow` );
  24170. const TRANSITION = Symbol(`Transition` );
  24171. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  24172. registerRuntimeHelpers({
  24173. [V_MODEL_RADIO]: `vModelRadio`,
  24174. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  24175. [V_MODEL_TEXT]: `vModelText`,
  24176. [V_MODEL_SELECT]: `vModelSelect`,
  24177. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  24178. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  24179. [V_ON_WITH_KEYS]: `withKeys`,
  24180. [V_SHOW]: `vShow`,
  24181. [TRANSITION]: `Transition`,
  24182. [TRANSITION_GROUP]: `TransitionGroup`
  24183. });
  24184. const parserOptions = {
  24185. parseMode: "html",
  24186. isVoidTag,
  24187. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  24188. isPreTag: (tag) => tag === "pre",
  24189. decodeEntities: void 0,
  24190. isBuiltInComponent: (tag) => {
  24191. if (tag === "Transition" || tag === "transition") {
  24192. return TRANSITION;
  24193. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  24194. return TRANSITION_GROUP;
  24195. }
  24196. },
  24197. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  24198. getNamespace(tag, parent, rootNamespace) {
  24199. let ns = parent ? parent.ns : rootNamespace;
  24200. if (parent && ns === 2) {
  24201. if (parent.tag === "annotation-xml") {
  24202. if (tag === "svg") {
  24203. return 1;
  24204. }
  24205. if (parent.props.some(
  24206. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  24207. )) {
  24208. ns = 0;
  24209. }
  24210. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  24211. ns = 0;
  24212. }
  24213. } else if (parent && ns === 1) {
  24214. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  24215. ns = 0;
  24216. }
  24217. }
  24218. if (ns === 0) {
  24219. if (tag === "svg") {
  24220. return 1;
  24221. }
  24222. if (tag === "math") {
  24223. return 2;
  24224. }
  24225. }
  24226. return ns;
  24227. }
  24228. };
  24229. const transformStyle = (node) => {
  24230. if (node.type === 1) {
  24231. node.props.forEach((p, i) => {
  24232. if (p.type === 6 && p.name === "style" && p.value) {
  24233. node.props[i] = {
  24234. type: 7,
  24235. name: `bind`,
  24236. arg: createSimpleExpression(`style`, true, p.loc),
  24237. exp: parseInlineCSS(p.value.content, p.loc),
  24238. modifiers: [],
  24239. loc: p.loc
  24240. };
  24241. }
  24242. });
  24243. }
  24244. };
  24245. const parseInlineCSS = (cssText, loc) => {
  24246. const normalized = parseStringStyle(cssText);
  24247. return createSimpleExpression(
  24248. JSON.stringify(normalized),
  24249. false,
  24250. loc,
  24251. 3
  24252. );
  24253. };
  24254. function createDOMCompilerError(code, loc) {
  24255. return createCompilerError(
  24256. code,
  24257. loc,
  24258. DOMErrorMessages
  24259. );
  24260. }
  24261. const DOMErrorCodes = {
  24262. "X_V_HTML_NO_EXPRESSION": 53,
  24263. "53": "X_V_HTML_NO_EXPRESSION",
  24264. "X_V_HTML_WITH_CHILDREN": 54,
  24265. "54": "X_V_HTML_WITH_CHILDREN",
  24266. "X_V_TEXT_NO_EXPRESSION": 55,
  24267. "55": "X_V_TEXT_NO_EXPRESSION",
  24268. "X_V_TEXT_WITH_CHILDREN": 56,
  24269. "56": "X_V_TEXT_WITH_CHILDREN",
  24270. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  24271. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  24272. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  24273. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  24274. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  24275. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  24276. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  24277. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  24278. "X_V_SHOW_NO_EXPRESSION": 61,
  24279. "61": "X_V_SHOW_NO_EXPRESSION",
  24280. "X_TRANSITION_INVALID_CHILDREN": 62,
  24281. "62": "X_TRANSITION_INVALID_CHILDREN",
  24282. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  24283. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  24284. "__EXTEND_POINT__": 64,
  24285. "64": "__EXTEND_POINT__"
  24286. };
  24287. const DOMErrorMessages = {
  24288. [53]: `v-html is missing expression.`,
  24289. [54]: `v-html will override element children.`,
  24290. [55]: `v-text is missing expression.`,
  24291. [56]: `v-text will override element children.`,
  24292. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  24293. [58]: `v-model argument is not supported on plain elements.`,
  24294. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  24295. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  24296. [61]: `v-show is missing expression.`,
  24297. [62]: `<Transition> expects exactly one child element or component.`,
  24298. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  24299. };
  24300. const transformVHtml = (dir, node, context) => {
  24301. const { exp, loc } = dir;
  24302. if (!exp) {
  24303. context.onError(
  24304. createDOMCompilerError(53, loc)
  24305. );
  24306. }
  24307. if (node.children.length) {
  24308. context.onError(
  24309. createDOMCompilerError(54, loc)
  24310. );
  24311. node.children.length = 0;
  24312. }
  24313. return {
  24314. props: [
  24315. createObjectProperty(
  24316. createSimpleExpression(`innerHTML`, true, loc),
  24317. exp || createSimpleExpression("", true)
  24318. )
  24319. ]
  24320. };
  24321. };
  24322. const transformVText = (dir, node, context) => {
  24323. const { exp, loc } = dir;
  24324. if (!exp) {
  24325. context.onError(
  24326. createDOMCompilerError(55, loc)
  24327. );
  24328. }
  24329. if (node.children.length) {
  24330. context.onError(
  24331. createDOMCompilerError(56, loc)
  24332. );
  24333. node.children.length = 0;
  24334. }
  24335. return {
  24336. props: [
  24337. createObjectProperty(
  24338. createSimpleExpression(`textContent`, true),
  24339. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  24340. context.helperString(TO_DISPLAY_STRING),
  24341. [exp],
  24342. loc
  24343. ) : createSimpleExpression("", true)
  24344. )
  24345. ]
  24346. };
  24347. };
  24348. const transformModel = (dir, node, context) => {
  24349. const baseResult = transformModel$1(dir, node, context);
  24350. if (!baseResult.props.length || node.tagType === 1) {
  24351. return baseResult;
  24352. }
  24353. if (dir.arg) {
  24354. context.onError(
  24355. createDOMCompilerError(
  24356. 58,
  24357. dir.arg.loc
  24358. )
  24359. );
  24360. }
  24361. function checkDuplicatedValue() {
  24362. const value = findDir(node, "bind");
  24363. if (value && isStaticArgOf(value.arg, "value")) {
  24364. context.onError(
  24365. createDOMCompilerError(
  24366. 60,
  24367. value.loc
  24368. )
  24369. );
  24370. }
  24371. }
  24372. const { tag } = node;
  24373. const isCustomElement = context.isCustomElement(tag);
  24374. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  24375. let directiveToUse = V_MODEL_TEXT;
  24376. let isInvalidType = false;
  24377. if (tag === "input" || isCustomElement) {
  24378. const type = findProp(node, `type`);
  24379. if (type) {
  24380. if (type.type === 7) {
  24381. directiveToUse = V_MODEL_DYNAMIC;
  24382. } else if (type.value) {
  24383. switch (type.value.content) {
  24384. case "radio":
  24385. directiveToUse = V_MODEL_RADIO;
  24386. break;
  24387. case "checkbox":
  24388. directiveToUse = V_MODEL_CHECKBOX;
  24389. break;
  24390. case "file":
  24391. isInvalidType = true;
  24392. context.onError(
  24393. createDOMCompilerError(
  24394. 59,
  24395. dir.loc
  24396. )
  24397. );
  24398. break;
  24399. default:
  24400. checkDuplicatedValue();
  24401. break;
  24402. }
  24403. }
  24404. } else if (hasDynamicKeyVBind(node)) {
  24405. directiveToUse = V_MODEL_DYNAMIC;
  24406. } else {
  24407. checkDuplicatedValue();
  24408. }
  24409. } else if (tag === "select") {
  24410. directiveToUse = V_MODEL_SELECT;
  24411. } else {
  24412. checkDuplicatedValue();
  24413. }
  24414. if (!isInvalidType) {
  24415. baseResult.needRuntime = context.helper(directiveToUse);
  24416. }
  24417. } else {
  24418. context.onError(
  24419. createDOMCompilerError(
  24420. 57,
  24421. dir.loc
  24422. )
  24423. );
  24424. }
  24425. baseResult.props = baseResult.props.filter(
  24426. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  24427. );
  24428. return baseResult;
  24429. };
  24430. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  24431. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  24432. // event propagation management
  24433. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  24434. );
  24435. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  24436. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  24437. `onkeyup,onkeydown,onkeypress`,
  24438. true
  24439. );
  24440. const resolveModifiers = (key, modifiers, context, loc) => {
  24441. const keyModifiers = [];
  24442. const nonKeyModifiers = [];
  24443. const eventOptionModifiers = [];
  24444. for (let i = 0; i < modifiers.length; i++) {
  24445. const modifier = modifiers[i];
  24446. if (isEventOptionModifier(modifier)) {
  24447. eventOptionModifiers.push(modifier);
  24448. } else {
  24449. if (maybeKeyModifier(modifier)) {
  24450. if (isStaticExp(key)) {
  24451. if (isKeyboardEvent(key.content)) {
  24452. keyModifiers.push(modifier);
  24453. } else {
  24454. nonKeyModifiers.push(modifier);
  24455. }
  24456. } else {
  24457. keyModifiers.push(modifier);
  24458. nonKeyModifiers.push(modifier);
  24459. }
  24460. } else {
  24461. if (isNonKeyModifier(modifier)) {
  24462. nonKeyModifiers.push(modifier);
  24463. } else {
  24464. keyModifiers.push(modifier);
  24465. }
  24466. }
  24467. }
  24468. }
  24469. return {
  24470. keyModifiers,
  24471. nonKeyModifiers,
  24472. eventOptionModifiers
  24473. };
  24474. };
  24475. const transformClick = (key, event) => {
  24476. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  24477. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  24478. `(`,
  24479. key,
  24480. `) === "onClick" ? "${event}" : (`,
  24481. key,
  24482. `)`
  24483. ]) : key;
  24484. };
  24485. const transformOn = (dir, node, context) => {
  24486. return transformOn$1(dir, node, context, (baseResult) => {
  24487. const { modifiers } = dir;
  24488. if (!modifiers.length)
  24489. return baseResult;
  24490. let { key, value: handlerExp } = baseResult.props[0];
  24491. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  24492. if (nonKeyModifiers.includes("right")) {
  24493. key = transformClick(key, `onContextmenu`);
  24494. }
  24495. if (nonKeyModifiers.includes("middle")) {
  24496. key = transformClick(key, `onMouseup`);
  24497. }
  24498. if (nonKeyModifiers.length) {
  24499. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  24500. handlerExp,
  24501. JSON.stringify(nonKeyModifiers)
  24502. ]);
  24503. }
  24504. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  24505. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  24506. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  24507. handlerExp,
  24508. JSON.stringify(keyModifiers)
  24509. ]);
  24510. }
  24511. if (eventOptionModifiers.length) {
  24512. const modifierPostfix = eventOptionModifiers.map(capitalize$1).join("");
  24513. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  24514. }
  24515. return {
  24516. props: [createObjectProperty(key, handlerExp)]
  24517. };
  24518. });
  24519. };
  24520. const transformShow = (dir, node, context) => {
  24521. const { exp, loc } = dir;
  24522. if (!exp) {
  24523. context.onError(
  24524. createDOMCompilerError(61, loc)
  24525. );
  24526. }
  24527. return {
  24528. props: [],
  24529. needRuntime: context.helper(V_SHOW)
  24530. };
  24531. };
  24532. const transformTransition = (node, context) => {
  24533. if (node.type === 1 && node.tagType === 1) {
  24534. const component = context.isBuiltInComponent(node.tag);
  24535. if (component === TRANSITION) {
  24536. return () => {
  24537. if (!node.children.length) {
  24538. return;
  24539. }
  24540. if (hasMultipleChildren(node)) {
  24541. context.onError(
  24542. createDOMCompilerError(
  24543. 62,
  24544. {
  24545. start: node.children[0].loc.start,
  24546. end: node.children[node.children.length - 1].loc.end,
  24547. source: ""
  24548. }
  24549. )
  24550. );
  24551. }
  24552. const child = node.children[0];
  24553. if (child.type === 1) {
  24554. for (const p of child.props) {
  24555. if (p.type === 7 && p.name === "show") {
  24556. node.props.push({
  24557. type: 6,
  24558. name: "persisted",
  24559. nameLoc: node.loc,
  24560. value: void 0,
  24561. loc: node.loc
  24562. });
  24563. }
  24564. }
  24565. }
  24566. };
  24567. }
  24568. }
  24569. };
  24570. function hasMultipleChildren(node) {
  24571. const children = node.children = node.children.filter(
  24572. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  24573. );
  24574. const child = children[0];
  24575. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  24576. }
  24577. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  24578. const stringifyStatic = (children, context, parent) => {
  24579. if (context.scopes.vSlot > 0) {
  24580. return;
  24581. }
  24582. let nc = 0;
  24583. let ec = 0;
  24584. const currentChunk = [];
  24585. const stringifyCurrentChunk = (currentIndex) => {
  24586. if (nc >= 20 || ec >= 5) {
  24587. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  24588. JSON.stringify(
  24589. currentChunk.map((node) => stringifyNode(node, context)).join("")
  24590. ).replace(expReplaceRE, `" + $1 + "`),
  24591. // the 2nd argument indicates the number of DOM nodes this static vnode
  24592. // will insert / hydrate
  24593. String(currentChunk.length)
  24594. ]);
  24595. replaceHoist(currentChunk[0], staticCall, context);
  24596. if (currentChunk.length > 1) {
  24597. for (let i2 = 1; i2 < currentChunk.length; i2++) {
  24598. replaceHoist(currentChunk[i2], null, context);
  24599. }
  24600. const deleteCount = currentChunk.length - 1;
  24601. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  24602. return deleteCount;
  24603. }
  24604. }
  24605. return 0;
  24606. };
  24607. let i = 0;
  24608. for (; i < children.length; i++) {
  24609. const child = children[i];
  24610. const hoisted = getHoistedNode(child);
  24611. if (hoisted) {
  24612. const node = child;
  24613. const result = analyzeNode(node);
  24614. if (result) {
  24615. nc += result[0];
  24616. ec += result[1];
  24617. currentChunk.push(node);
  24618. continue;
  24619. }
  24620. }
  24621. i -= stringifyCurrentChunk(i);
  24622. nc = 0;
  24623. ec = 0;
  24624. currentChunk.length = 0;
  24625. }
  24626. stringifyCurrentChunk(i);
  24627. };
  24628. const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
  24629. const dataAriaRE = /^(data|aria)-/;
  24630. const isStringifiableAttr = (name, ns) => {
  24631. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
  24632. };
  24633. const replaceHoist = (node, replacement, context) => {
  24634. const hoistToReplace = node.codegenNode.hoisted;
  24635. context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
  24636. };
  24637. const isNonStringifiable = /* @__PURE__ */ makeMap(
  24638. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  24639. );
  24640. function analyzeNode(node) {
  24641. if (node.type === 1 && isNonStringifiable(node.tag)) {
  24642. return false;
  24643. }
  24644. if (node.type === 12) {
  24645. return [1, 0];
  24646. }
  24647. let nc = 1;
  24648. let ec = node.props.length > 0 ? 1 : 0;
  24649. let bailed = false;
  24650. const bail = () => {
  24651. bailed = true;
  24652. return false;
  24653. };
  24654. function walk(node2) {
  24655. for (let i = 0; i < node2.props.length; i++) {
  24656. const p = node2.props[i];
  24657. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  24658. return bail();
  24659. }
  24660. if (p.type === 7 && p.name === "bind") {
  24661. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  24662. return bail();
  24663. }
  24664. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  24665. return bail();
  24666. }
  24667. }
  24668. }
  24669. for (let i = 0; i < node2.children.length; i++) {
  24670. nc++;
  24671. const child = node2.children[i];
  24672. if (child.type === 1) {
  24673. if (child.props.length > 0) {
  24674. ec++;
  24675. }
  24676. walk(child);
  24677. if (bailed) {
  24678. return false;
  24679. }
  24680. }
  24681. }
  24682. return true;
  24683. }
  24684. return walk(node) ? [nc, ec] : false;
  24685. }
  24686. function stringifyNode(node, context) {
  24687. if (isString$2(node)) {
  24688. return node;
  24689. }
  24690. if (isSymbol$1(node)) {
  24691. return ``;
  24692. }
  24693. switch (node.type) {
  24694. case 1:
  24695. return stringifyElement(node, context);
  24696. case 2:
  24697. return escapeHtml(node.content);
  24698. case 3:
  24699. return `<!--${escapeHtml(node.content)}-->`;
  24700. case 5:
  24701. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  24702. case 8:
  24703. return escapeHtml(evaluateConstant(node));
  24704. case 12:
  24705. return stringifyNode(node.content, context);
  24706. default:
  24707. return "";
  24708. }
  24709. }
  24710. function stringifyElement(node, context) {
  24711. let res = `<${node.tag}`;
  24712. let innerHTML = "";
  24713. for (let i = 0; i < node.props.length; i++) {
  24714. const p = node.props[i];
  24715. if (p.type === 6) {
  24716. res += ` ${p.name}`;
  24717. if (p.value) {
  24718. res += `="${escapeHtml(p.value.content)}"`;
  24719. }
  24720. } else if (p.type === 7) {
  24721. if (p.name === "bind") {
  24722. const exp = p.exp;
  24723. if (exp.content[0] === "_") {
  24724. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  24725. continue;
  24726. }
  24727. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  24728. continue;
  24729. }
  24730. let evaluated = evaluateConstant(exp);
  24731. if (evaluated != null) {
  24732. const arg = p.arg && p.arg.content;
  24733. if (arg === "class") {
  24734. evaluated = normalizeClass(evaluated);
  24735. } else if (arg === "style") {
  24736. evaluated = stringifyStyle(normalizeStyle(evaluated));
  24737. }
  24738. res += ` ${p.arg.content}="${escapeHtml(
  24739. evaluated
  24740. )}"`;
  24741. }
  24742. } else if (p.name === "html") {
  24743. innerHTML = evaluateConstant(p.exp);
  24744. } else if (p.name === "text") {
  24745. innerHTML = escapeHtml(
  24746. toDisplayString(evaluateConstant(p.exp))
  24747. );
  24748. }
  24749. }
  24750. }
  24751. if (context.scopeId) {
  24752. res += ` ${context.scopeId}`;
  24753. }
  24754. res += `>`;
  24755. if (innerHTML) {
  24756. res += innerHTML;
  24757. } else {
  24758. for (let i = 0; i < node.children.length; i++) {
  24759. res += stringifyNode(node.children[i], context);
  24760. }
  24761. }
  24762. if (!isVoidTag(node.tag)) {
  24763. res += `</${node.tag}>`;
  24764. }
  24765. return res;
  24766. }
  24767. function evaluateConstant(exp) {
  24768. if (exp.type === 4) {
  24769. return new Function(`return (${exp.content})`)();
  24770. } else {
  24771. let res = ``;
  24772. exp.children.forEach((c) => {
  24773. if (isString$2(c) || isSymbol$1(c)) {
  24774. return;
  24775. }
  24776. if (c.type === 2) {
  24777. res += c.content;
  24778. } else if (c.type === 5) {
  24779. res += toDisplayString(evaluateConstant(c.content));
  24780. } else {
  24781. res += evaluateConstant(c);
  24782. }
  24783. });
  24784. return res;
  24785. }
  24786. }
  24787. const ignoreSideEffectTags = (node, context) => {
  24788. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  24789. context.onError(
  24790. createDOMCompilerError(
  24791. 63,
  24792. node.loc
  24793. )
  24794. );
  24795. context.removeNode();
  24796. }
  24797. };
  24798. const DOMNodeTransforms = [
  24799. transformStyle,
  24800. ...[transformTransition]
  24801. ];
  24802. const DOMDirectiveTransforms = {
  24803. cloak: noopDirectiveTransform,
  24804. html: transformVHtml,
  24805. text: transformVText,
  24806. model: transformModel,
  24807. // override compiler-core
  24808. on: transformOn,
  24809. // override compiler-core
  24810. show: transformShow
  24811. };
  24812. function compile$1(src, options = {}) {
  24813. return baseCompile(
  24814. src,
  24815. extend({}, parserOptions, options, {
  24816. nodeTransforms: [
  24817. // ignore <script> and <tag>
  24818. // this is not put inside DOMNodeTransforms because that list is used
  24819. // by compiler-ssr to generate vnode fallback branches
  24820. ignoreSideEffectTags,
  24821. ...DOMNodeTransforms,
  24822. ...options.nodeTransforms || []
  24823. ],
  24824. directiveTransforms: extend(
  24825. {},
  24826. DOMDirectiveTransforms,
  24827. options.directiveTransforms || {}
  24828. ),
  24829. transformHoist: stringifyStatic
  24830. })
  24831. );
  24832. }
  24833. function parse$8(template, options = {}) {
  24834. return baseParse(template, extend({}, parserOptions, options));
  24835. }
  24836. var CompilerDOM = /*#__PURE__*/Object.freeze({
  24837. __proto__: null,
  24838. BASE_TRANSITION: BASE_TRANSITION,
  24839. BindingTypes: BindingTypes,
  24840. CAMELIZE: CAMELIZE,
  24841. CAPITALIZE: CAPITALIZE,
  24842. CREATE_BLOCK: CREATE_BLOCK,
  24843. CREATE_COMMENT: CREATE_COMMENT,
  24844. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  24845. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  24846. CREATE_SLOTS: CREATE_SLOTS,
  24847. CREATE_STATIC: CREATE_STATIC,
  24848. CREATE_TEXT: CREATE_TEXT,
  24849. CREATE_VNODE: CREATE_VNODE,
  24850. CompilerDeprecationTypes: CompilerDeprecationTypes,
  24851. ConstantTypes: ConstantTypes,
  24852. DOMDirectiveTransforms: DOMDirectiveTransforms,
  24853. DOMErrorCodes: DOMErrorCodes,
  24854. DOMErrorMessages: DOMErrorMessages,
  24855. DOMNodeTransforms: DOMNodeTransforms,
  24856. ElementTypes: ElementTypes,
  24857. ErrorCodes: ErrorCodes,
  24858. FRAGMENT: FRAGMENT,
  24859. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  24860. IS_MEMO_SAME: IS_MEMO_SAME,
  24861. IS_REF: IS_REF,
  24862. KEEP_ALIVE: KEEP_ALIVE,
  24863. MERGE_PROPS: MERGE_PROPS,
  24864. NORMALIZE_CLASS: NORMALIZE_CLASS,
  24865. NORMALIZE_PROPS: NORMALIZE_PROPS,
  24866. NORMALIZE_STYLE: NORMALIZE_STYLE,
  24867. Namespaces: Namespaces,
  24868. NodeTypes: NodeTypes,
  24869. OPEN_BLOCK: OPEN_BLOCK,
  24870. POP_SCOPE_ID: POP_SCOPE_ID,
  24871. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  24872. RENDER_LIST: RENDER_LIST,
  24873. RENDER_SLOT: RENDER_SLOT,
  24874. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  24875. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  24876. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  24877. RESOLVE_FILTER: RESOLVE_FILTER,
  24878. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  24879. SUSPENSE: SUSPENSE,
  24880. TELEPORT: TELEPORT,
  24881. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  24882. TO_HANDLERS: TO_HANDLERS,
  24883. TO_HANDLER_KEY: TO_HANDLER_KEY,
  24884. TRANSITION: TRANSITION,
  24885. TRANSITION_GROUP: TRANSITION_GROUP,
  24886. TS_NODE_TYPES: TS_NODE_TYPES,
  24887. UNREF: UNREF,
  24888. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  24889. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  24890. V_MODEL_RADIO: V_MODEL_RADIO,
  24891. V_MODEL_SELECT: V_MODEL_SELECT,
  24892. V_MODEL_TEXT: V_MODEL_TEXT,
  24893. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  24894. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  24895. V_SHOW: V_SHOW,
  24896. WITH_CTX: WITH_CTX,
  24897. WITH_DIRECTIVES: WITH_DIRECTIVES,
  24898. WITH_MEMO: WITH_MEMO,
  24899. advancePositionWithClone: advancePositionWithClone,
  24900. advancePositionWithMutation: advancePositionWithMutation,
  24901. assert: assert,
  24902. baseCompile: baseCompile,
  24903. baseParse: baseParse,
  24904. buildDirectiveArgs: buildDirectiveArgs,
  24905. buildProps: buildProps,
  24906. buildSlots: buildSlots,
  24907. checkCompatEnabled: checkCompatEnabled,
  24908. compile: compile$1,
  24909. convertToBlock: convertToBlock,
  24910. createArrayExpression: createArrayExpression,
  24911. createAssignmentExpression: createAssignmentExpression,
  24912. createBlockStatement: createBlockStatement,
  24913. createCacheExpression: createCacheExpression,
  24914. createCallExpression: createCallExpression,
  24915. createCompilerError: createCompilerError,
  24916. createCompoundExpression: createCompoundExpression,
  24917. createConditionalExpression: createConditionalExpression,
  24918. createDOMCompilerError: createDOMCompilerError,
  24919. createForLoopParams: createForLoopParams,
  24920. createFunctionExpression: createFunctionExpression,
  24921. createIfStatement: createIfStatement,
  24922. createInterpolation: createInterpolation,
  24923. createObjectExpression: createObjectExpression,
  24924. createObjectProperty: createObjectProperty,
  24925. createReturnStatement: createReturnStatement,
  24926. createRoot: createRoot,
  24927. createSequenceExpression: createSequenceExpression,
  24928. createSimpleExpression: createSimpleExpression,
  24929. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  24930. createTemplateLiteral: createTemplateLiteral,
  24931. createTransformContext: createTransformContext,
  24932. createVNodeCall: createVNodeCall,
  24933. errorMessages: errorMessages$1,
  24934. extractIdentifiers: extractIdentifiers$1,
  24935. findDir: findDir,
  24936. findProp: findProp,
  24937. forAliasRE: forAliasRE,
  24938. generate: generate,
  24939. generateCodeFrame: generateCodeFrame,
  24940. getBaseTransformPreset: getBaseTransformPreset,
  24941. getConstantType: getConstantType,
  24942. getMemoedVNodeCall: getMemoedVNodeCall,
  24943. getVNodeBlockHelper: getVNodeBlockHelper,
  24944. getVNodeHelper: getVNodeHelper,
  24945. hasDynamicKeyVBind: hasDynamicKeyVBind,
  24946. hasScopeRef: hasScopeRef,
  24947. helperNameMap: helperNameMap,
  24948. injectProp: injectProp,
  24949. isCoreComponent: isCoreComponent,
  24950. isFunctionType: isFunctionType,
  24951. isInDestructureAssignment: isInDestructureAssignment,
  24952. isInNewExpression: isInNewExpression,
  24953. isMemberExpression: isMemberExpression,
  24954. isMemberExpressionBrowser: isMemberExpressionBrowser,
  24955. isMemberExpressionNode: isMemberExpressionNode,
  24956. isReferencedIdentifier: isReferencedIdentifier,
  24957. isSimpleIdentifier: isSimpleIdentifier,
  24958. isSlotOutlet: isSlotOutlet,
  24959. isStaticArgOf: isStaticArgOf,
  24960. isStaticExp: isStaticExp,
  24961. isStaticProperty: isStaticProperty,
  24962. isStaticPropertyKey: isStaticPropertyKey,
  24963. isTemplateNode: isTemplateNode,
  24964. isText: isText$1,
  24965. isVSlot: isVSlot,
  24966. locStub: locStub,
  24967. noopDirectiveTransform: noopDirectiveTransform,
  24968. parse: parse$8,
  24969. parserOptions: parserOptions,
  24970. processExpression: processExpression,
  24971. processFor: processFor,
  24972. processIf: processIf,
  24973. processSlotOutlet: processSlotOutlet,
  24974. registerRuntimeHelpers: registerRuntimeHelpers,
  24975. resolveComponentType: resolveComponentType,
  24976. stringifyExpression: stringifyExpression,
  24977. toValidAssetId: toValidAssetId,
  24978. trackSlotScopes: trackSlotScopes,
  24979. trackVForSlotScopes: trackVForSlotScopes,
  24980. transform: transform,
  24981. transformBind: transformBind,
  24982. transformElement: transformElement,
  24983. transformExpression: transformExpression,
  24984. transformModel: transformModel$1,
  24985. transformOn: transformOn$1,
  24986. transformStyle: transformStyle,
  24987. traverseNode: traverseNode,
  24988. unwrapTSNode: unwrapTSNode,
  24989. walkBlockDeclarations: walkBlockDeclarations,
  24990. walkFunctionParams: walkFunctionParams,
  24991. walkIdentifiers: walkIdentifiers,
  24992. warnDeprecation: warnDeprecation
  24993. });
  24994. // Copyright Joyent, Inc. and other Node contributors.
  24995. //
  24996. // Permission is hereby granted, free of charge, to any person obtaining a
  24997. // copy of this software and associated documentation files (the
  24998. // "Software"), to deal in the Software without restriction, including
  24999. // without limitation the rights to use, copy, modify, merge, publish,
  25000. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25001. // persons to whom the Software is furnished to do so, subject to the
  25002. // following conditions:
  25003. //
  25004. // The above copyright notice and this permission notice shall be included
  25005. // in all copies or substantial portions of the Software.
  25006. //
  25007. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25008. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25009. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25010. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25011. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25012. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25013. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25014. // resolves . and .. elements in a path array with directory names there
  25015. // must be no slashes, empty elements, or device names (c:\) in the array
  25016. // (so also no leading and trailing slashes - it does not distinguish
  25017. // relative and absolute paths)
  25018. function normalizeArray(parts, allowAboveRoot) {
  25019. // if the path tries to go above the root, `up` ends up > 0
  25020. var up = 0;
  25021. for (var i = parts.length - 1; i >= 0; i--) {
  25022. var last = parts[i];
  25023. if (last === '.') {
  25024. parts.splice(i, 1);
  25025. } else if (last === '..') {
  25026. parts.splice(i, 1);
  25027. up++;
  25028. } else if (up) {
  25029. parts.splice(i, 1);
  25030. up--;
  25031. }
  25032. }
  25033. // if the path is allowed to go above the root, restore leading ..s
  25034. if (allowAboveRoot) {
  25035. for (; up--; up) {
  25036. parts.unshift('..');
  25037. }
  25038. }
  25039. return parts;
  25040. }
  25041. // Split a filename into [root, dir, basename, ext], unix version
  25042. // 'root' is just a slash, or nothing.
  25043. var splitPathRe =
  25044. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  25045. var splitPath = function(filename) {
  25046. return splitPathRe.exec(filename).slice(1);
  25047. };
  25048. // path.resolve([from ...], to)
  25049. // posix version
  25050. function resolve$2() {
  25051. var resolvedPath = '',
  25052. resolvedAbsolute = false;
  25053. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  25054. var path = (i >= 0) ? arguments[i] : '/';
  25055. // Skip empty and invalid entries
  25056. if (typeof path !== 'string') {
  25057. throw new TypeError('Arguments to path.resolve must be strings');
  25058. } else if (!path) {
  25059. continue;
  25060. }
  25061. resolvedPath = path + '/' + resolvedPath;
  25062. resolvedAbsolute = path.charAt(0) === '/';
  25063. }
  25064. // At this point the path should be resolved to a full absolute path, but
  25065. // handle relative paths to be safe (might happen when process.cwd() fails)
  25066. // Normalize the path
  25067. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  25068. return !!p;
  25069. }), !resolvedAbsolute).join('/');
  25070. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  25071. }
  25072. // path.normalize(path)
  25073. // posix version
  25074. function normalize$1(path) {
  25075. var isPathAbsolute = isAbsolute$1(path),
  25076. trailingSlash = substr(path, -1) === '/';
  25077. // Normalize the path
  25078. path = normalizeArray(filter(path.split('/'), function(p) {
  25079. return !!p;
  25080. }), !isPathAbsolute).join('/');
  25081. if (!path && !isPathAbsolute) {
  25082. path = '.';
  25083. }
  25084. if (path && trailingSlash) {
  25085. path += '/';
  25086. }
  25087. return (isPathAbsolute ? '/' : '') + path;
  25088. }
  25089. // posix version
  25090. function isAbsolute$1(path) {
  25091. return path.charAt(0) === '/';
  25092. }
  25093. // posix version
  25094. function join$1() {
  25095. var paths = Array.prototype.slice.call(arguments, 0);
  25096. return normalize$1(filter(paths, function(p, index) {
  25097. if (typeof p !== 'string') {
  25098. throw new TypeError('Arguments to path.join must be strings');
  25099. }
  25100. return p;
  25101. }).join('/'));
  25102. }
  25103. // path.relative(from, to)
  25104. // posix version
  25105. function relative$1(from, to) {
  25106. from = resolve$2(from).substr(1);
  25107. to = resolve$2(to).substr(1);
  25108. function trim(arr) {
  25109. var start = 0;
  25110. for (; start < arr.length; start++) {
  25111. if (arr[start] !== '') break;
  25112. }
  25113. var end = arr.length - 1;
  25114. for (; end >= 0; end--) {
  25115. if (arr[end] !== '') break;
  25116. }
  25117. if (start > end) return [];
  25118. return arr.slice(start, end - start + 1);
  25119. }
  25120. var fromParts = trim(from.split('/'));
  25121. var toParts = trim(to.split('/'));
  25122. var length = Math.min(fromParts.length, toParts.length);
  25123. var samePartsLength = length;
  25124. for (var i = 0; i < length; i++) {
  25125. if (fromParts[i] !== toParts[i]) {
  25126. samePartsLength = i;
  25127. break;
  25128. }
  25129. }
  25130. var outputParts = [];
  25131. for (var i = samePartsLength; i < fromParts.length; i++) {
  25132. outputParts.push('..');
  25133. }
  25134. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  25135. return outputParts.join('/');
  25136. }
  25137. var sep$1 = '/';
  25138. var delimiter$1 = ':';
  25139. function dirname$2(path) {
  25140. var result = splitPath(path),
  25141. root = result[0],
  25142. dir = result[1];
  25143. if (!root && !dir) {
  25144. // No dirname whatsoever
  25145. return '.';
  25146. }
  25147. if (dir) {
  25148. // It has a dirname, strip trailing slash
  25149. dir = dir.substr(0, dir.length - 1);
  25150. }
  25151. return root + dir;
  25152. }
  25153. function basename(path, ext) {
  25154. var f = splitPath(path)[2];
  25155. // TODO: make this comparison case-insensitive on windows?
  25156. if (ext && f.substr(-1 * ext.length) === ext) {
  25157. f = f.substr(0, f.length - ext.length);
  25158. }
  25159. return f;
  25160. }
  25161. function extname(path) {
  25162. return splitPath(path)[3];
  25163. }
  25164. var path = {
  25165. extname: extname,
  25166. basename: basename,
  25167. dirname: dirname$2,
  25168. sep: sep$1,
  25169. delimiter: delimiter$1,
  25170. relative: relative$1,
  25171. join: join$1,
  25172. isAbsolute: isAbsolute$1,
  25173. normalize: normalize$1,
  25174. resolve: resolve$2
  25175. };
  25176. function filter (xs, f) {
  25177. if (xs.filter) return xs.filter(f);
  25178. var res = [];
  25179. for (var i = 0; i < xs.length; i++) {
  25180. if (f(xs[i], i, xs)) res.push(xs[i]);
  25181. }
  25182. return res;
  25183. }
  25184. // String.prototype.substr - negative index don't work in IE8
  25185. var substr = 'ab'.substr(-1) === 'b' ?
  25186. function (str, start, len) { return str.substr(start, len) } :
  25187. function (str, start, len) {
  25188. if (start < 0) start = str.length + start;
  25189. return str.substr(start, len);
  25190. }
  25191. ;
  25192. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  25193. __proto__: null,
  25194. basename: basename,
  25195. default: path,
  25196. delimiter: delimiter$1,
  25197. dirname: dirname$2,
  25198. extname: extname,
  25199. isAbsolute: isAbsolute$1,
  25200. join: join$1,
  25201. normalize: normalize$1,
  25202. relative: relative$1,
  25203. resolve: resolve$2,
  25204. sep: sep$1
  25205. });
  25206. const UNKNOWN_TYPE = "Unknown";
  25207. function resolveObjectKey(node, computed) {
  25208. switch (node.type) {
  25209. case "StringLiteral":
  25210. case "NumericLiteral":
  25211. return String(node.value);
  25212. case "Identifier":
  25213. if (!computed)
  25214. return node.name;
  25215. }
  25216. return void 0;
  25217. }
  25218. function concatStrings(strs) {
  25219. return strs.filter((s) => !!s).join(", ");
  25220. }
  25221. function isLiteralNode(node) {
  25222. return node.type.endsWith("Literal");
  25223. }
  25224. function isCallOf(node, test) {
  25225. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  25226. }
  25227. function toRuntimeTypeString(types) {
  25228. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  25229. }
  25230. function getImportedName(specifier) {
  25231. if (specifier.type === "ImportSpecifier")
  25232. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  25233. else if (specifier.type === "ImportNamespaceSpecifier")
  25234. return "*";
  25235. return "default";
  25236. }
  25237. function getId(node) {
  25238. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  25239. }
  25240. const normalize = (path.posix || path).normalize;
  25241. const windowsSlashRE = /\\/g;
  25242. function normalizePath(p) {
  25243. return normalize(p.replace(windowsSlashRE, "/"));
  25244. }
  25245. const joinPaths = (path.posix || path).join;
  25246. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  25247. function getEscapedPropName(key) {
  25248. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  25249. }
  25250. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  25251. function getEscapedCssVarName(key, doubleEscape) {
  25252. return key.replace(
  25253. cssVarNameEscapeSymbolsRE,
  25254. (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
  25255. );
  25256. }
  25257. function pad$1 (hash, len) {
  25258. while (hash.length < len) {
  25259. hash = '0' + hash;
  25260. }
  25261. return hash;
  25262. }
  25263. function fold (hash, text) {
  25264. var i;
  25265. var chr;
  25266. var len;
  25267. if (text.length === 0) {
  25268. return hash;
  25269. }
  25270. for (i = 0, len = text.length; i < len; i++) {
  25271. chr = text.charCodeAt(i);
  25272. hash = ((hash << 5) - hash) + chr;
  25273. hash |= 0;
  25274. }
  25275. return hash < 0 ? hash * -2 : hash;
  25276. }
  25277. function foldObject (hash, o, seen) {
  25278. return Object.keys(o).sort().reduce(foldKey, hash);
  25279. function foldKey (hash, key) {
  25280. return foldValue(hash, o[key], key, seen);
  25281. }
  25282. }
  25283. function foldValue (input, value, key, seen) {
  25284. var hash = fold(fold(fold(input, key), toString$2(value)), typeof value);
  25285. if (value === null) {
  25286. return fold(hash, 'null');
  25287. }
  25288. if (value === undefined) {
  25289. return fold(hash, 'undefined');
  25290. }
  25291. if (typeof value === 'object' || typeof value === 'function') {
  25292. if (seen.indexOf(value) !== -1) {
  25293. return fold(hash, '[Circular]' + key);
  25294. }
  25295. seen.push(value);
  25296. var objHash = foldObject(hash, value, seen);
  25297. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  25298. return objHash;
  25299. }
  25300. try {
  25301. return fold(objHash, String(value.valueOf()))
  25302. } catch (err) {
  25303. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  25304. }
  25305. }
  25306. return fold(hash, value.toString());
  25307. }
  25308. function toString$2 (o) {
  25309. return Object.prototype.toString.call(o);
  25310. }
  25311. function sum (o) {
  25312. return pad$1(foldValue(0, o, '', []).toString(16), 8);
  25313. }
  25314. var hashSum = sum;
  25315. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSum);
  25316. const CSS_VARS_HELPER = `useCssVars`;
  25317. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  25318. return `{
  25319. ${vars.map(
  25320. (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  25321. ).join(",\n ")}
  25322. }`;
  25323. }
  25324. function genVarName(id, raw, isProd, isSSR = false) {
  25325. if (isProd) {
  25326. return hash(id + raw);
  25327. } else {
  25328. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  25329. }
  25330. }
  25331. function normalizeExpression(exp) {
  25332. exp = exp.trim();
  25333. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  25334. return exp.slice(1, -1);
  25335. }
  25336. return exp;
  25337. }
  25338. const vBindRE = /v-bind\s*\(/g;
  25339. function parseCssVars(sfc) {
  25340. const vars = [];
  25341. sfc.styles.forEach((style) => {
  25342. let match;
  25343. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  25344. while (match = vBindRE.exec(content)) {
  25345. const start = match.index + match[0].length;
  25346. const end = lexBinding(content, start);
  25347. if (end !== null) {
  25348. const variable = normalizeExpression(content.slice(start, end));
  25349. if (!vars.includes(variable)) {
  25350. vars.push(variable);
  25351. }
  25352. }
  25353. }
  25354. });
  25355. return vars;
  25356. }
  25357. function lexBinding(content, start) {
  25358. let state = 0 /* inParens */;
  25359. let parenDepth = 0;
  25360. for (let i = start; i < content.length; i++) {
  25361. const char = content.charAt(i);
  25362. switch (state) {
  25363. case 0 /* inParens */:
  25364. if (char === `'`) {
  25365. state = 1 /* inSingleQuoteString */;
  25366. } else if (char === `"`) {
  25367. state = 2 /* inDoubleQuoteString */;
  25368. } else if (char === `(`) {
  25369. parenDepth++;
  25370. } else if (char === `)`) {
  25371. if (parenDepth > 0) {
  25372. parenDepth--;
  25373. } else {
  25374. return i;
  25375. }
  25376. }
  25377. break;
  25378. case 1 /* inSingleQuoteString */:
  25379. if (char === `'`) {
  25380. state = 0 /* inParens */;
  25381. }
  25382. break;
  25383. case 2 /* inDoubleQuoteString */:
  25384. if (char === `"`) {
  25385. state = 0 /* inParens */;
  25386. }
  25387. break;
  25388. }
  25389. }
  25390. return null;
  25391. }
  25392. const cssVarsPlugin = (opts) => {
  25393. const { id, isProd } = opts;
  25394. return {
  25395. postcssPlugin: "vue-sfc-vars",
  25396. Declaration(decl) {
  25397. const value = decl.value;
  25398. if (vBindRE.test(value)) {
  25399. vBindRE.lastIndex = 0;
  25400. let transformed = "";
  25401. let lastIndex = 0;
  25402. let match;
  25403. while (match = vBindRE.exec(value)) {
  25404. const start = match.index + match[0].length;
  25405. const end = lexBinding(value, start);
  25406. if (end !== null) {
  25407. const variable = normalizeExpression(value.slice(start, end));
  25408. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  25409. lastIndex = end + 1;
  25410. }
  25411. }
  25412. decl.value = transformed + value.slice(lastIndex);
  25413. }
  25414. }
  25415. };
  25416. };
  25417. cssVarsPlugin.postcss = true;
  25418. function genCssVarsCode(vars, bindings, id, isProd) {
  25419. const varsExp = genCssVarsFromList(vars, id, isProd);
  25420. const exp = createSimpleExpression(varsExp, false);
  25421. const context = createTransformContext(createRoot([]), {
  25422. prefixIdentifiers: true,
  25423. inline: true,
  25424. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  25425. });
  25426. const transformed = processExpression(exp, context);
  25427. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  25428. return typeof c === "string" ? c : c.content;
  25429. }).join("");
  25430. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  25431. }
  25432. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  25433. return `
  25434. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  25435. const __injectCSSVars__ = () => {
  25436. ${genCssVarsCode(
  25437. cssVars,
  25438. bindings,
  25439. id,
  25440. isProd
  25441. )}}
  25442. const __setup__ = ${defaultVar}.setup
  25443. ${defaultVar}.setup = __setup__
  25444. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  25445. : __injectCSSVars__
  25446. `;
  25447. }
  25448. var global$1 = (typeof global !== "undefined" ? global :
  25449. typeof self !== "undefined" ? self :
  25450. typeof window !== "undefined" ? window : {});
  25451. // shim for using process in browser
  25452. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  25453. function defaultSetTimout() {
  25454. throw new Error('setTimeout has not been defined');
  25455. }
  25456. function defaultClearTimeout () {
  25457. throw new Error('clearTimeout has not been defined');
  25458. }
  25459. var cachedSetTimeout = defaultSetTimout;
  25460. var cachedClearTimeout = defaultClearTimeout;
  25461. if (typeof global$1.setTimeout === 'function') {
  25462. cachedSetTimeout = setTimeout;
  25463. }
  25464. if (typeof global$1.clearTimeout === 'function') {
  25465. cachedClearTimeout = clearTimeout;
  25466. }
  25467. function runTimeout(fun) {
  25468. if (cachedSetTimeout === setTimeout) {
  25469. //normal enviroments in sane situations
  25470. return setTimeout(fun, 0);
  25471. }
  25472. // if setTimeout wasn't available but was latter defined
  25473. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  25474. cachedSetTimeout = setTimeout;
  25475. return setTimeout(fun, 0);
  25476. }
  25477. try {
  25478. // when when somebody has screwed with setTimeout but no I.E. maddness
  25479. return cachedSetTimeout(fun, 0);
  25480. } catch(e){
  25481. try {
  25482. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25483. return cachedSetTimeout.call(null, fun, 0);
  25484. } catch(e){
  25485. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  25486. return cachedSetTimeout.call(this, fun, 0);
  25487. }
  25488. }
  25489. }
  25490. function runClearTimeout(marker) {
  25491. if (cachedClearTimeout === clearTimeout) {
  25492. //normal enviroments in sane situations
  25493. return clearTimeout(marker);
  25494. }
  25495. // if clearTimeout wasn't available but was latter defined
  25496. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  25497. cachedClearTimeout = clearTimeout;
  25498. return clearTimeout(marker);
  25499. }
  25500. try {
  25501. // when when somebody has screwed with setTimeout but no I.E. maddness
  25502. return cachedClearTimeout(marker);
  25503. } catch (e){
  25504. try {
  25505. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25506. return cachedClearTimeout.call(null, marker);
  25507. } catch (e){
  25508. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  25509. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  25510. return cachedClearTimeout.call(this, marker);
  25511. }
  25512. }
  25513. }
  25514. var queue = [];
  25515. var draining = false;
  25516. var currentQueue;
  25517. var queueIndex = -1;
  25518. function cleanUpNextTick() {
  25519. if (!draining || !currentQueue) {
  25520. return;
  25521. }
  25522. draining = false;
  25523. if (currentQueue.length) {
  25524. queue = currentQueue.concat(queue);
  25525. } else {
  25526. queueIndex = -1;
  25527. }
  25528. if (queue.length) {
  25529. drainQueue();
  25530. }
  25531. }
  25532. function drainQueue() {
  25533. if (draining) {
  25534. return;
  25535. }
  25536. var timeout = runTimeout(cleanUpNextTick);
  25537. draining = true;
  25538. var len = queue.length;
  25539. while(len) {
  25540. currentQueue = queue;
  25541. queue = [];
  25542. while (++queueIndex < len) {
  25543. if (currentQueue) {
  25544. currentQueue[queueIndex].run();
  25545. }
  25546. }
  25547. queueIndex = -1;
  25548. len = queue.length;
  25549. }
  25550. currentQueue = null;
  25551. draining = false;
  25552. runClearTimeout(timeout);
  25553. }
  25554. function nextTick(fun) {
  25555. var args = new Array(arguments.length - 1);
  25556. if (arguments.length > 1) {
  25557. for (var i = 1; i < arguments.length; i++) {
  25558. args[i - 1] = arguments[i];
  25559. }
  25560. }
  25561. queue.push(new Item(fun, args));
  25562. if (queue.length === 1 && !draining) {
  25563. runTimeout(drainQueue);
  25564. }
  25565. }
  25566. // v8 likes predictible objects
  25567. function Item(fun, array) {
  25568. this.fun = fun;
  25569. this.array = array;
  25570. }
  25571. Item.prototype.run = function () {
  25572. this.fun.apply(null, this.array);
  25573. };
  25574. var title = 'browser';
  25575. var platform = 'browser';
  25576. var browser = true;
  25577. var env = {};
  25578. var argv = [];
  25579. var version$1 = ''; // empty string to avoid regexp issues
  25580. var versions = {};
  25581. var release = {};
  25582. var config = {};
  25583. function noop() {}
  25584. var on = noop;
  25585. var addListener = noop;
  25586. var once = noop;
  25587. var off = noop;
  25588. var removeListener = noop;
  25589. var removeAllListeners = noop;
  25590. var emit = noop;
  25591. function binding(name) {
  25592. throw new Error('process.binding is not supported');
  25593. }
  25594. function cwd () { return '/' }
  25595. function chdir (dir) {
  25596. throw new Error('process.chdir is not supported');
  25597. }function umask() { return 0; }
  25598. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  25599. var performance = global$1.performance || {};
  25600. var performanceNow =
  25601. performance.now ||
  25602. performance.mozNow ||
  25603. performance.msNow ||
  25604. performance.oNow ||
  25605. performance.webkitNow ||
  25606. function(){ return (new Date()).getTime() };
  25607. // generate timestamp or delta
  25608. // see http://nodejs.org/api/process.html#process_process_hrtime
  25609. function hrtime(previousTimestamp){
  25610. var clocktime = performanceNow.call(performance)*1e-3;
  25611. var seconds = Math.floor(clocktime);
  25612. var nanoseconds = Math.floor((clocktime%1)*1e9);
  25613. if (previousTimestamp) {
  25614. seconds = seconds - previousTimestamp[0];
  25615. nanoseconds = nanoseconds - previousTimestamp[1];
  25616. if (nanoseconds<0) {
  25617. seconds--;
  25618. nanoseconds += 1e9;
  25619. }
  25620. }
  25621. return [seconds,nanoseconds]
  25622. }
  25623. var startTime = new Date();
  25624. function uptime() {
  25625. var currentTime = new Date();
  25626. var dif = currentTime - startTime;
  25627. return dif / 1000;
  25628. }
  25629. var browser$1 = {
  25630. nextTick: nextTick,
  25631. title: title,
  25632. browser: browser,
  25633. env: env,
  25634. argv: argv,
  25635. version: version$1,
  25636. versions: versions,
  25637. on: on,
  25638. addListener: addListener,
  25639. once: once,
  25640. off: off,
  25641. removeListener: removeListener,
  25642. removeAllListeners: removeAllListeners,
  25643. emit: emit,
  25644. binding: binding,
  25645. cwd: cwd,
  25646. chdir: chdir,
  25647. umask: umask,
  25648. hrtime: hrtime,
  25649. platform: platform,
  25650. release: release,
  25651. config: config,
  25652. uptime: uptime
  25653. };
  25654. function createCache(max = 500) {
  25655. {
  25656. return /* @__PURE__ */ new Map();
  25657. }
  25658. }
  25659. function isImportUsed(local, sfc) {
  25660. return resolveTemplateUsedIdentifiers(sfc).has(local);
  25661. }
  25662. const templateUsageCheckCache = createCache();
  25663. function resolveTemplateUsedIdentifiers(sfc) {
  25664. const { content, ast } = sfc.template;
  25665. const cached = templateUsageCheckCache.get(content);
  25666. if (cached) {
  25667. return cached;
  25668. }
  25669. const ids = /* @__PURE__ */ new Set();
  25670. ast.children.forEach(walk);
  25671. function walk(node) {
  25672. var _a;
  25673. switch (node.type) {
  25674. case 1:
  25675. let tag = node.tag;
  25676. if (tag.includes("."))
  25677. tag = tag.split(".")[0].trim();
  25678. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  25679. ids.add(camelize(tag));
  25680. ids.add(capitalize$1(camelize(tag)));
  25681. }
  25682. for (let i = 0; i < node.props.length; i++) {
  25683. const prop = node.props[i];
  25684. if (prop.type === 7) {
  25685. if (!isBuiltInDirective(prop.name)) {
  25686. ids.add(`v${capitalize$1(camelize(prop.name))}`);
  25687. }
  25688. if (prop.arg && !prop.arg.isStatic) {
  25689. extractIdentifiers(ids, prop.arg);
  25690. }
  25691. if (prop.name === "for") {
  25692. extractIdentifiers(ids, prop.forParseResult.source);
  25693. } else if (prop.exp) {
  25694. extractIdentifiers(ids, prop.exp);
  25695. } else if (prop.name === "bind" && !prop.exp) {
  25696. ids.add(prop.arg.content);
  25697. }
  25698. }
  25699. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  25700. ids.add(prop.value.content);
  25701. }
  25702. }
  25703. node.children.forEach(walk);
  25704. break;
  25705. case 5:
  25706. extractIdentifiers(ids, node.content);
  25707. break;
  25708. }
  25709. }
  25710. templateUsageCheckCache.set(content, ids);
  25711. return ids;
  25712. }
  25713. function extractIdentifiers(ids, node) {
  25714. if (node.ast) {
  25715. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  25716. } else if (node.ast === null) {
  25717. ids.add(node.content);
  25718. }
  25719. }
  25720. var __defProp$a = Object.defineProperty;
  25721. var __defProps$9 = Object.defineProperties;
  25722. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  25723. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  25724. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  25725. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  25726. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  25727. var __spreadValues$a = (a, b) => {
  25728. for (var prop in b || (b = {}))
  25729. if (__hasOwnProp$a.call(b, prop))
  25730. __defNormalProp$a(a, prop, b[prop]);
  25731. if (__getOwnPropSymbols$a)
  25732. for (var prop of __getOwnPropSymbols$a(b)) {
  25733. if (__propIsEnum$a.call(b, prop))
  25734. __defNormalProp$a(a, prop, b[prop]);
  25735. }
  25736. return a;
  25737. };
  25738. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  25739. const DEFAULT_FILENAME = "anonymous.vue";
  25740. const parseCache$1 = createCache();
  25741. function genCacheKey(source, options) {
  25742. var _a;
  25743. return source + JSON.stringify(
  25744. __spreadProps$9(__spreadValues$a({}, options), {
  25745. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  25746. }),
  25747. (_, val) => typeof val === "function" ? val.toString() : val
  25748. );
  25749. }
  25750. function parse$7(source, options = {}) {
  25751. const sourceKey = genCacheKey(source, options);
  25752. const cache = parseCache$1.get(sourceKey);
  25753. if (cache) {
  25754. return cache;
  25755. }
  25756. const {
  25757. sourceMap = true,
  25758. filename = DEFAULT_FILENAME,
  25759. sourceRoot = "",
  25760. pad = false,
  25761. ignoreEmpty = true,
  25762. compiler = CompilerDOM,
  25763. templateParseOptions = {},
  25764. parseExpressions = true
  25765. } = options;
  25766. const descriptor = {
  25767. filename,
  25768. source,
  25769. template: null,
  25770. script: null,
  25771. scriptSetup: null,
  25772. styles: [],
  25773. customBlocks: [],
  25774. cssVars: [],
  25775. slotted: false,
  25776. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  25777. };
  25778. const errors = [];
  25779. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  25780. parseMode: "sfc",
  25781. prefixIdentifiers: parseExpressions
  25782. }, templateParseOptions), {
  25783. onError: (e) => {
  25784. errors.push(e);
  25785. }
  25786. }));
  25787. ast.children.forEach((node) => {
  25788. if (node.type !== 1) {
  25789. return;
  25790. }
  25791. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  25792. return;
  25793. }
  25794. switch (node.tag) {
  25795. case "template":
  25796. if (!descriptor.template) {
  25797. const templateBlock = descriptor.template = createBlock(
  25798. node,
  25799. source,
  25800. false
  25801. );
  25802. if (!templateBlock.attrs.src) {
  25803. templateBlock.ast = createRoot(node.children, source);
  25804. }
  25805. if (templateBlock.attrs.functional) {
  25806. const err = new SyntaxError(
  25807. `<template functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal <template> instead.`
  25808. );
  25809. err.loc = node.props.find(
  25810. (p) => p.type === 6 && p.name === "functional"
  25811. ).loc;
  25812. errors.push(err);
  25813. }
  25814. } else {
  25815. errors.push(createDuplicateBlockError(node));
  25816. }
  25817. break;
  25818. case "script":
  25819. const scriptBlock = createBlock(node, source, pad);
  25820. const isSetup = !!scriptBlock.attrs.setup;
  25821. if (isSetup && !descriptor.scriptSetup) {
  25822. descriptor.scriptSetup = scriptBlock;
  25823. break;
  25824. }
  25825. if (!isSetup && !descriptor.script) {
  25826. descriptor.script = scriptBlock;
  25827. break;
  25828. }
  25829. errors.push(createDuplicateBlockError(node, isSetup));
  25830. break;
  25831. case "style":
  25832. const styleBlock = createBlock(node, source, pad);
  25833. if (styleBlock.attrs.vars) {
  25834. errors.push(
  25835. new SyntaxError(
  25836. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  25837. )
  25838. );
  25839. }
  25840. descriptor.styles.push(styleBlock);
  25841. break;
  25842. default:
  25843. descriptor.customBlocks.push(createBlock(node, source, pad));
  25844. break;
  25845. }
  25846. });
  25847. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  25848. errors.push(
  25849. new SyntaxError(
  25850. `At least one <template> or <script> is required in a single file component.`
  25851. )
  25852. );
  25853. }
  25854. if (descriptor.scriptSetup) {
  25855. if (descriptor.scriptSetup.src) {
  25856. errors.push(
  25857. new SyntaxError(
  25858. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  25859. )
  25860. );
  25861. descriptor.scriptSetup = null;
  25862. }
  25863. if (descriptor.script && descriptor.script.src) {
  25864. errors.push(
  25865. new SyntaxError(
  25866. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  25867. )
  25868. );
  25869. descriptor.script = null;
  25870. }
  25871. }
  25872. let templateColumnOffset = 0;
  25873. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  25874. [descriptor.template.content, templateColumnOffset] = dedent(
  25875. descriptor.template.content
  25876. );
  25877. }
  25878. if (sourceMap) {
  25879. const genMap = (block, columnOffset = 0) => {
  25880. if (block && !block.src) {
  25881. block.map = generateSourceMap(
  25882. filename,
  25883. source,
  25884. block.content,
  25885. sourceRoot,
  25886. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  25887. columnOffset
  25888. );
  25889. }
  25890. };
  25891. genMap(descriptor.template, templateColumnOffset);
  25892. genMap(descriptor.script);
  25893. descriptor.styles.forEach((s) => genMap(s));
  25894. descriptor.customBlocks.forEach((s) => genMap(s));
  25895. }
  25896. descriptor.cssVars = parseCssVars(descriptor);
  25897. const slottedRE = /(?:::v-|:)slotted\(/;
  25898. descriptor.slotted = descriptor.styles.some(
  25899. (s) => s.scoped && slottedRE.test(s.content)
  25900. );
  25901. const result = {
  25902. descriptor,
  25903. errors
  25904. };
  25905. parseCache$1.set(sourceKey, result);
  25906. return result;
  25907. }
  25908. function createDuplicateBlockError(node, isScriptSetup = false) {
  25909. const err = new SyntaxError(
  25910. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  25911. );
  25912. err.loc = node.loc;
  25913. return err;
  25914. }
  25915. function createBlock(node, source, pad) {
  25916. const type = node.tag;
  25917. const loc = node.innerLoc;
  25918. const attrs = {};
  25919. const block = {
  25920. type,
  25921. content: source.slice(loc.start.offset, loc.end.offset),
  25922. loc,
  25923. attrs
  25924. };
  25925. if (pad) {
  25926. block.content = padContent(source, block, pad) + block.content;
  25927. }
  25928. node.props.forEach((p) => {
  25929. if (p.type === 6) {
  25930. const name = p.name;
  25931. attrs[name] = p.value ? p.value.content || true : true;
  25932. if (name === "lang") {
  25933. block.lang = p.value && p.value.content;
  25934. } else if (name === "src") {
  25935. block.src = p.value && p.value.content;
  25936. } else if (type === "style") {
  25937. if (name === "scoped") {
  25938. block.scoped = true;
  25939. } else if (name === "module") {
  25940. block.module = attrs[name];
  25941. }
  25942. } else if (type === "script" && name === "setup") {
  25943. block.setup = attrs.setup;
  25944. }
  25945. }
  25946. });
  25947. return block;
  25948. }
  25949. const splitRE = /\r?\n/g;
  25950. const emptyRE = /^(?:\/\/)?\s*$/;
  25951. const replaceRE = /./g;
  25952. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  25953. const map = new SourceMapGenerator$6({
  25954. file: filename.replace(/\\/g, "/"),
  25955. sourceRoot: sourceRoot.replace(/\\/g, "/")
  25956. });
  25957. map.setSourceContent(filename, source);
  25958. map._sources.add(filename);
  25959. generated.split(splitRE).forEach((line, index) => {
  25960. if (!emptyRE.test(line)) {
  25961. const originalLine = index + 1 + lineOffset;
  25962. const generatedLine = index + 1;
  25963. for (let i = 0; i < line.length; i++) {
  25964. if (!/\s/.test(line[i])) {
  25965. map._mappings.add({
  25966. originalLine,
  25967. originalColumn: i + columnOffset,
  25968. generatedLine,
  25969. generatedColumn: i,
  25970. source: filename,
  25971. name: null
  25972. });
  25973. }
  25974. }
  25975. }
  25976. });
  25977. return map.toJSON();
  25978. }
  25979. function padContent(content, block, pad) {
  25980. content = content.slice(0, block.loc.start.offset);
  25981. if (pad === "space") {
  25982. return content.replace(replaceRE, " ");
  25983. } else {
  25984. const offset = content.split(splitRE).length;
  25985. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  25986. return Array(offset).join(padChar);
  25987. }
  25988. }
  25989. function hasSrc(node) {
  25990. return node.props.some((p) => {
  25991. if (p.type !== 6) {
  25992. return false;
  25993. }
  25994. return p.name === "src";
  25995. });
  25996. }
  25997. function isEmpty(node) {
  25998. for (let i = 0; i < node.children.length; i++) {
  25999. const child = node.children[i];
  26000. if (child.type !== 2 || child.content.trim() !== "") {
  26001. return false;
  26002. }
  26003. }
  26004. return true;
  26005. }
  26006. function hmrShouldReload(prevImports, next) {
  26007. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  26008. return false;
  26009. }
  26010. for (const key in prevImports) {
  26011. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  26012. return true;
  26013. }
  26014. }
  26015. return false;
  26016. }
  26017. function dedent(s) {
  26018. const lines = s.split("\n");
  26019. const minIndent = lines.reduce(function(minIndent2, line) {
  26020. var _a, _b;
  26021. if (line.trim() === "") {
  26022. return minIndent2;
  26023. }
  26024. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  26025. return Math.min(indent, minIndent2);
  26026. }, Infinity);
  26027. if (minIndent === 0) {
  26028. return [s, minIndent];
  26029. }
  26030. return [
  26031. lines.map(function(line) {
  26032. return line.slice(minIndent);
  26033. }).join("\n"),
  26034. minIndent
  26035. ];
  26036. }
  26037. /*! https://mths.be/punycode v1.4.1 by @mathias */
  26038. /** Highest positive signed 32-bit float value */
  26039. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  26040. /** Bootstring parameters */
  26041. var base = 36;
  26042. var tMin = 1;
  26043. var tMax = 26;
  26044. var skew = 38;
  26045. var damp = 700;
  26046. var initialBias = 72;
  26047. var initialN = 128; // 0x80
  26048. var delimiter = '-'; // '\x2D'
  26049. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  26050. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  26051. /** Error messages */
  26052. var errors = {
  26053. 'overflow': 'Overflow: input needs wider integers to process',
  26054. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  26055. 'invalid-input': 'Invalid input'
  26056. };
  26057. /** Convenience shortcuts */
  26058. var baseMinusTMin = base - tMin;
  26059. var floor = Math.floor;
  26060. var stringFromCharCode = String.fromCharCode;
  26061. /*--------------------------------------------------------------------------*/
  26062. /**
  26063. * A generic error utility function.
  26064. * @private
  26065. * @param {String} type The error type.
  26066. * @returns {Error} Throws a `RangeError` with the applicable error message.
  26067. */
  26068. function error(type) {
  26069. throw new RangeError(errors[type]);
  26070. }
  26071. /**
  26072. * A generic `Array#map` utility function.
  26073. * @private
  26074. * @param {Array} array The array to iterate over.
  26075. * @param {Function} callback The function that gets called for every array
  26076. * item.
  26077. * @returns {Array} A new array of values returned by the callback function.
  26078. */
  26079. function map$1(array, fn) {
  26080. var length = array.length;
  26081. var result = [];
  26082. while (length--) {
  26083. result[length] = fn(array[length]);
  26084. }
  26085. return result;
  26086. }
  26087. /**
  26088. * A simple `Array#map`-like wrapper to work with domain name strings or email
  26089. * addresses.
  26090. * @private
  26091. * @param {String} domain The domain name or email address.
  26092. * @param {Function} callback The function that gets called for every
  26093. * character.
  26094. * @returns {Array} A new string of characters returned by the callback
  26095. * function.
  26096. */
  26097. function mapDomain(string, fn) {
  26098. var parts = string.split('@');
  26099. var result = '';
  26100. if (parts.length > 1) {
  26101. // In email addresses, only the domain name should be punycoded. Leave
  26102. // the local part (i.e. everything up to `@`) intact.
  26103. result = parts[0] + '@';
  26104. string = parts[1];
  26105. }
  26106. // Avoid `split(regex)` for IE8 compatibility. See #17.
  26107. string = string.replace(regexSeparators, '\x2E');
  26108. var labels = string.split('.');
  26109. var encoded = map$1(labels, fn).join('.');
  26110. return result + encoded;
  26111. }
  26112. /**
  26113. * Creates an array containing the numeric code points of each Unicode
  26114. * character in the string. While JavaScript uses UCS-2 internally,
  26115. * this function will convert a pair of surrogate halves (each of which
  26116. * UCS-2 exposes as separate characters) into a single code point,
  26117. * matching UTF-16.
  26118. * @see `punycode.ucs2.encode`
  26119. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  26120. * @memberOf punycode.ucs2
  26121. * @name decode
  26122. * @param {String} string The Unicode input string (UCS-2).
  26123. * @returns {Array} The new array of code points.
  26124. */
  26125. function ucs2decode(string) {
  26126. var output = [],
  26127. counter = 0,
  26128. length = string.length,
  26129. value,
  26130. extra;
  26131. while (counter < length) {
  26132. value = string.charCodeAt(counter++);
  26133. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  26134. // high surrogate, and there is a next character
  26135. extra = string.charCodeAt(counter++);
  26136. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  26137. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  26138. } else {
  26139. // unmatched surrogate; only append this code unit, in case the next
  26140. // code unit is the high surrogate of a surrogate pair
  26141. output.push(value);
  26142. counter--;
  26143. }
  26144. } else {
  26145. output.push(value);
  26146. }
  26147. }
  26148. return output;
  26149. }
  26150. /**
  26151. * Converts a digit/integer into a basic code point.
  26152. * @see `basicToDigit()`
  26153. * @private
  26154. * @param {Number} digit The numeric value of a basic code point.
  26155. * @returns {Number} The basic code point whose value (when used for
  26156. * representing integers) is `digit`, which needs to be in the range
  26157. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  26158. * used; else, the lowercase form is used. The behavior is undefined
  26159. * if `flag` is non-zero and `digit` has no uppercase form.
  26160. */
  26161. function digitToBasic(digit, flag) {
  26162. // 0..25 map to ASCII a..z or A..Z
  26163. // 26..35 map to ASCII 0..9
  26164. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  26165. }
  26166. /**
  26167. * Bias adaptation function as per section 3.4 of RFC 3492.
  26168. * https://tools.ietf.org/html/rfc3492#section-3.4
  26169. * @private
  26170. */
  26171. function adapt(delta, numPoints, firstTime) {
  26172. var k = 0;
  26173. delta = firstTime ? floor(delta / damp) : delta >> 1;
  26174. delta += floor(delta / numPoints);
  26175. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  26176. delta = floor(delta / baseMinusTMin);
  26177. }
  26178. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  26179. }
  26180. /**
  26181. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  26182. * Punycode string of ASCII-only symbols.
  26183. * @memberOf punycode
  26184. * @param {String} input The string of Unicode symbols.
  26185. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  26186. */
  26187. function encode$1(input) {
  26188. var n,
  26189. delta,
  26190. handledCPCount,
  26191. basicLength,
  26192. bias,
  26193. j,
  26194. m,
  26195. q,
  26196. k,
  26197. t,
  26198. currentValue,
  26199. output = [],
  26200. /** `inputLength` will hold the number of code points in `input`. */
  26201. inputLength,
  26202. /** Cached calculation results */
  26203. handledCPCountPlusOne,
  26204. baseMinusT,
  26205. qMinusT;
  26206. // Convert the input in UCS-2 to Unicode
  26207. input = ucs2decode(input);
  26208. // Cache the length
  26209. inputLength = input.length;
  26210. // Initialize the state
  26211. n = initialN;
  26212. delta = 0;
  26213. bias = initialBias;
  26214. // Handle the basic code points
  26215. for (j = 0; j < inputLength; ++j) {
  26216. currentValue = input[j];
  26217. if (currentValue < 0x80) {
  26218. output.push(stringFromCharCode(currentValue));
  26219. }
  26220. }
  26221. handledCPCount = basicLength = output.length;
  26222. // `handledCPCount` is the number of code points that have been handled;
  26223. // `basicLength` is the number of basic code points.
  26224. // Finish the basic string - if it is not empty - with a delimiter
  26225. if (basicLength) {
  26226. output.push(delimiter);
  26227. }
  26228. // Main encoding loop:
  26229. while (handledCPCount < inputLength) {
  26230. // All non-basic code points < n have been handled already. Find the next
  26231. // larger one:
  26232. for (m = maxInt, j = 0; j < inputLength; ++j) {
  26233. currentValue = input[j];
  26234. if (currentValue >= n && currentValue < m) {
  26235. m = currentValue;
  26236. }
  26237. }
  26238. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  26239. // but guard against overflow
  26240. handledCPCountPlusOne = handledCPCount + 1;
  26241. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  26242. error('overflow');
  26243. }
  26244. delta += (m - n) * handledCPCountPlusOne;
  26245. n = m;
  26246. for (j = 0; j < inputLength; ++j) {
  26247. currentValue = input[j];
  26248. if (currentValue < n && ++delta > maxInt) {
  26249. error('overflow');
  26250. }
  26251. if (currentValue == n) {
  26252. // Represent delta as a generalized variable-length integer
  26253. for (q = delta, k = base; /* no condition */ ; k += base) {
  26254. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  26255. if (q < t) {
  26256. break;
  26257. }
  26258. qMinusT = q - t;
  26259. baseMinusT = base - t;
  26260. output.push(
  26261. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  26262. );
  26263. q = floor(qMinusT / baseMinusT);
  26264. }
  26265. output.push(stringFromCharCode(digitToBasic(q, 0)));
  26266. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  26267. delta = 0;
  26268. ++handledCPCount;
  26269. }
  26270. }
  26271. ++delta;
  26272. ++n;
  26273. }
  26274. return output.join('');
  26275. }
  26276. /**
  26277. * Converts a Unicode string representing a domain name or an email address to
  26278. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  26279. * i.e. it doesn't matter if you call it with a domain that's already in
  26280. * ASCII.
  26281. * @memberOf punycode
  26282. * @param {String} input The domain name or email address to convert, as a
  26283. * Unicode string.
  26284. * @returns {String} The Punycode representation of the given domain name or
  26285. * email address.
  26286. */
  26287. function toASCII(input) {
  26288. return mapDomain(input, function(string) {
  26289. return regexNonASCII.test(string) ?
  26290. 'xn--' + encode$1(string) :
  26291. string;
  26292. });
  26293. }
  26294. var lookup = [];
  26295. var revLookup = [];
  26296. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26297. var inited = false;
  26298. function init () {
  26299. inited = true;
  26300. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26301. for (var i = 0, len = code.length; i < len; ++i) {
  26302. lookup[i] = code[i];
  26303. revLookup[code.charCodeAt(i)] = i;
  26304. }
  26305. revLookup['-'.charCodeAt(0)] = 62;
  26306. revLookup['_'.charCodeAt(0)] = 63;
  26307. }
  26308. function toByteArray (b64) {
  26309. if (!inited) {
  26310. init();
  26311. }
  26312. var i, j, l, tmp, placeHolders, arr;
  26313. var len = b64.length;
  26314. if (len % 4 > 0) {
  26315. throw new Error('Invalid string. Length must be a multiple of 4')
  26316. }
  26317. // the number of equal signs (place holders)
  26318. // if there are two placeholders, than the two characters before it
  26319. // represent one byte
  26320. // if there is only one, then the three characters before it represent 2 bytes
  26321. // this is just a cheap hack to not do indexOf twice
  26322. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  26323. // base64 is 4/3 + up to two characters of the original data
  26324. arr = new Arr(len * 3 / 4 - placeHolders);
  26325. // if there are placeholders, only get up to the last complete 4 chars
  26326. l = placeHolders > 0 ? len - 4 : len;
  26327. var L = 0;
  26328. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  26329. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  26330. arr[L++] = (tmp >> 16) & 0xFF;
  26331. arr[L++] = (tmp >> 8) & 0xFF;
  26332. arr[L++] = tmp & 0xFF;
  26333. }
  26334. if (placeHolders === 2) {
  26335. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  26336. arr[L++] = tmp & 0xFF;
  26337. } else if (placeHolders === 1) {
  26338. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  26339. arr[L++] = (tmp >> 8) & 0xFF;
  26340. arr[L++] = tmp & 0xFF;
  26341. }
  26342. return arr
  26343. }
  26344. function tripletToBase64 (num) {
  26345. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  26346. }
  26347. function encodeChunk (uint8, start, end) {
  26348. var tmp;
  26349. var output = [];
  26350. for (var i = start; i < end; i += 3) {
  26351. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  26352. output.push(tripletToBase64(tmp));
  26353. }
  26354. return output.join('')
  26355. }
  26356. function fromByteArray (uint8) {
  26357. if (!inited) {
  26358. init();
  26359. }
  26360. var tmp;
  26361. var len = uint8.length;
  26362. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26363. var output = '';
  26364. var parts = [];
  26365. var maxChunkLength = 16383; // must be multiple of 3
  26366. // go through the array every three bytes, we'll deal with trailing stuff later
  26367. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26368. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  26369. }
  26370. // pad the end with zeros, but make sure to not forget the extra bytes
  26371. if (extraBytes === 1) {
  26372. tmp = uint8[len - 1];
  26373. output += lookup[tmp >> 2];
  26374. output += lookup[(tmp << 4) & 0x3F];
  26375. output += '==';
  26376. } else if (extraBytes === 2) {
  26377. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  26378. output += lookup[tmp >> 10];
  26379. output += lookup[(tmp >> 4) & 0x3F];
  26380. output += lookup[(tmp << 2) & 0x3F];
  26381. output += '=';
  26382. }
  26383. parts.push(output);
  26384. return parts.join('')
  26385. }
  26386. function read (buffer, offset, isLE, mLen, nBytes) {
  26387. var e, m;
  26388. var eLen = nBytes * 8 - mLen - 1;
  26389. var eMax = (1 << eLen) - 1;
  26390. var eBias = eMax >> 1;
  26391. var nBits = -7;
  26392. var i = isLE ? (nBytes - 1) : 0;
  26393. var d = isLE ? -1 : 1;
  26394. var s = buffer[offset + i];
  26395. i += d;
  26396. e = s & ((1 << (-nBits)) - 1);
  26397. s >>= (-nBits);
  26398. nBits += eLen;
  26399. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26400. m = e & ((1 << (-nBits)) - 1);
  26401. e >>= (-nBits);
  26402. nBits += mLen;
  26403. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26404. if (e === 0) {
  26405. e = 1 - eBias;
  26406. } else if (e === eMax) {
  26407. return m ? NaN : ((s ? -1 : 1) * Infinity)
  26408. } else {
  26409. m = m + Math.pow(2, mLen);
  26410. e = e - eBias;
  26411. }
  26412. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  26413. }
  26414. function write (buffer, value, offset, isLE, mLen, nBytes) {
  26415. var e, m, c;
  26416. var eLen = nBytes * 8 - mLen - 1;
  26417. var eMax = (1 << eLen) - 1;
  26418. var eBias = eMax >> 1;
  26419. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  26420. var i = isLE ? 0 : (nBytes - 1);
  26421. var d = isLE ? 1 : -1;
  26422. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  26423. value = Math.abs(value);
  26424. if (isNaN(value) || value === Infinity) {
  26425. m = isNaN(value) ? 1 : 0;
  26426. e = eMax;
  26427. } else {
  26428. e = Math.floor(Math.log(value) / Math.LN2);
  26429. if (value * (c = Math.pow(2, -e)) < 1) {
  26430. e--;
  26431. c *= 2;
  26432. }
  26433. if (e + eBias >= 1) {
  26434. value += rt / c;
  26435. } else {
  26436. value += rt * Math.pow(2, 1 - eBias);
  26437. }
  26438. if (value * c >= 2) {
  26439. e++;
  26440. c /= 2;
  26441. }
  26442. if (e + eBias >= eMax) {
  26443. m = 0;
  26444. e = eMax;
  26445. } else if (e + eBias >= 1) {
  26446. m = (value * c - 1) * Math.pow(2, mLen);
  26447. e = e + eBias;
  26448. } else {
  26449. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  26450. e = 0;
  26451. }
  26452. }
  26453. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  26454. e = (e << mLen) | m;
  26455. eLen += mLen;
  26456. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  26457. buffer[offset + i - d] |= s * 128;
  26458. }
  26459. var toString$1 = {}.toString;
  26460. var isArray$2 = Array.isArray || function (arr) {
  26461. return toString$1.call(arr) == '[object Array]';
  26462. };
  26463. /*!
  26464. * The buffer module from node.js, for the browser.
  26465. *
  26466. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  26467. * @license MIT
  26468. */
  26469. /* eslint-disable no-proto */
  26470. var INSPECT_MAX_BYTES = 50;
  26471. /**
  26472. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  26473. * === true Use Uint8Array implementation (fastest)
  26474. * === false Use Object implementation (most compatible, even IE6)
  26475. *
  26476. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  26477. * Opera 11.6+, iOS 4.2+.
  26478. *
  26479. * Due to various browser bugs, sometimes the Object implementation will be used even
  26480. * when the browser supports typed arrays.
  26481. *
  26482. * Note:
  26483. *
  26484. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  26485. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  26486. *
  26487. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  26488. *
  26489. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  26490. * incorrect length in some situations.
  26491. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  26492. * get the Object implementation, which is slower but behaves correctly.
  26493. */
  26494. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  26495. ? global$1.TYPED_ARRAY_SUPPORT
  26496. : true;
  26497. /*
  26498. * Export kMaxLength after typed array support is determined.
  26499. */
  26500. kMaxLength();
  26501. function kMaxLength () {
  26502. return Buffer$1.TYPED_ARRAY_SUPPORT
  26503. ? 0x7fffffff
  26504. : 0x3fffffff
  26505. }
  26506. function createBuffer (that, length) {
  26507. if (kMaxLength() < length) {
  26508. throw new RangeError('Invalid typed array length')
  26509. }
  26510. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26511. // Return an augmented `Uint8Array` instance, for best performance
  26512. that = new Uint8Array(length);
  26513. that.__proto__ = Buffer$1.prototype;
  26514. } else {
  26515. // Fallback: Return an object instance of the Buffer class
  26516. if (that === null) {
  26517. that = new Buffer$1(length);
  26518. }
  26519. that.length = length;
  26520. }
  26521. return that
  26522. }
  26523. /**
  26524. * The Buffer constructor returns instances of `Uint8Array` that have their
  26525. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  26526. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  26527. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  26528. * returns a single octet.
  26529. *
  26530. * The `Uint8Array` prototype remains unmodified.
  26531. */
  26532. function Buffer$1 (arg, encodingOrOffset, length) {
  26533. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  26534. return new Buffer$1(arg, encodingOrOffset, length)
  26535. }
  26536. // Common case.
  26537. if (typeof arg === 'number') {
  26538. if (typeof encodingOrOffset === 'string') {
  26539. throw new Error(
  26540. 'If encoding is specified then the first argument must be a string'
  26541. )
  26542. }
  26543. return allocUnsafe(this, arg)
  26544. }
  26545. return from(this, arg, encodingOrOffset, length)
  26546. }
  26547. Buffer$1.poolSize = 8192; // not used by this implementation
  26548. // TODO: Legacy, not needed anymore. Remove in next major version.
  26549. Buffer$1._augment = function (arr) {
  26550. arr.__proto__ = Buffer$1.prototype;
  26551. return arr
  26552. };
  26553. function from (that, value, encodingOrOffset, length) {
  26554. if (typeof value === 'number') {
  26555. throw new TypeError('"value" argument must not be a number')
  26556. }
  26557. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  26558. return fromArrayBuffer(that, value, encodingOrOffset, length)
  26559. }
  26560. if (typeof value === 'string') {
  26561. return fromString(that, value, encodingOrOffset)
  26562. }
  26563. return fromObject(that, value)
  26564. }
  26565. /**
  26566. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  26567. * if value is a number.
  26568. * Buffer.from(str[, encoding])
  26569. * Buffer.from(array)
  26570. * Buffer.from(buffer)
  26571. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  26572. **/
  26573. Buffer$1.from = function (value, encodingOrOffset, length) {
  26574. return from(null, value, encodingOrOffset, length)
  26575. };
  26576. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26577. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  26578. Buffer$1.__proto__ = Uint8Array;
  26579. if (typeof Symbol !== 'undefined' && Symbol.species &&
  26580. Buffer$1[Symbol.species] === Buffer$1) ;
  26581. }
  26582. function assertSize (size) {
  26583. if (typeof size !== 'number') {
  26584. throw new TypeError('"size" argument must be a number')
  26585. } else if (size < 0) {
  26586. throw new RangeError('"size" argument must not be negative')
  26587. }
  26588. }
  26589. function alloc (that, size, fill, encoding) {
  26590. assertSize(size);
  26591. if (size <= 0) {
  26592. return createBuffer(that, size)
  26593. }
  26594. if (fill !== undefined) {
  26595. // Only pay attention to encoding if it's a string. This
  26596. // prevents accidentally sending in a number that would
  26597. // be interpretted as a start offset.
  26598. return typeof encoding === 'string'
  26599. ? createBuffer(that, size).fill(fill, encoding)
  26600. : createBuffer(that, size).fill(fill)
  26601. }
  26602. return createBuffer(that, size)
  26603. }
  26604. /**
  26605. * Creates a new filled Buffer instance.
  26606. * alloc(size[, fill[, encoding]])
  26607. **/
  26608. Buffer$1.alloc = function (size, fill, encoding) {
  26609. return alloc(null, size, fill, encoding)
  26610. };
  26611. function allocUnsafe (that, size) {
  26612. assertSize(size);
  26613. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  26614. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  26615. for (var i = 0; i < size; ++i) {
  26616. that[i] = 0;
  26617. }
  26618. }
  26619. return that
  26620. }
  26621. /**
  26622. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  26623. * */
  26624. Buffer$1.allocUnsafe = function (size) {
  26625. return allocUnsafe(null, size)
  26626. };
  26627. /**
  26628. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  26629. */
  26630. Buffer$1.allocUnsafeSlow = function (size) {
  26631. return allocUnsafe(null, size)
  26632. };
  26633. function fromString (that, string, encoding) {
  26634. if (typeof encoding !== 'string' || encoding === '') {
  26635. encoding = 'utf8';
  26636. }
  26637. if (!Buffer$1.isEncoding(encoding)) {
  26638. throw new TypeError('"encoding" must be a valid string encoding')
  26639. }
  26640. var length = byteLength(string, encoding) | 0;
  26641. that = createBuffer(that, length);
  26642. var actual = that.write(string, encoding);
  26643. if (actual !== length) {
  26644. // Writing a hex string, for example, that contains invalid characters will
  26645. // cause everything after the first invalid character to be ignored. (e.g.
  26646. // 'abxxcd' will be treated as 'ab')
  26647. that = that.slice(0, actual);
  26648. }
  26649. return that
  26650. }
  26651. function fromArrayLike (that, array) {
  26652. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  26653. that = createBuffer(that, length);
  26654. for (var i = 0; i < length; i += 1) {
  26655. that[i] = array[i] & 255;
  26656. }
  26657. return that
  26658. }
  26659. function fromArrayBuffer (that, array, byteOffset, length) {
  26660. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  26661. if (byteOffset < 0 || array.byteLength < byteOffset) {
  26662. throw new RangeError('\'offset\' is out of bounds')
  26663. }
  26664. if (array.byteLength < byteOffset + (length || 0)) {
  26665. throw new RangeError('\'length\' is out of bounds')
  26666. }
  26667. if (byteOffset === undefined && length === undefined) {
  26668. array = new Uint8Array(array);
  26669. } else if (length === undefined) {
  26670. array = new Uint8Array(array, byteOffset);
  26671. } else {
  26672. array = new Uint8Array(array, byteOffset, length);
  26673. }
  26674. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26675. // Return an augmented `Uint8Array` instance, for best performance
  26676. that = array;
  26677. that.__proto__ = Buffer$1.prototype;
  26678. } else {
  26679. // Fallback: Return an object instance of the Buffer class
  26680. that = fromArrayLike(that, array);
  26681. }
  26682. return that
  26683. }
  26684. function fromObject (that, obj) {
  26685. if (internalIsBuffer(obj)) {
  26686. var len = checked(obj.length) | 0;
  26687. that = createBuffer(that, len);
  26688. if (that.length === 0) {
  26689. return that
  26690. }
  26691. obj.copy(that, 0, 0, len);
  26692. return that
  26693. }
  26694. if (obj) {
  26695. if ((typeof ArrayBuffer !== 'undefined' &&
  26696. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  26697. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  26698. return createBuffer(that, 0)
  26699. }
  26700. return fromArrayLike(that, obj)
  26701. }
  26702. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  26703. return fromArrayLike(that, obj.data)
  26704. }
  26705. }
  26706. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  26707. }
  26708. function checked (length) {
  26709. // Note: cannot use `length < kMaxLength()` here because that fails when
  26710. // length is NaN (which is otherwise coerced to zero.)
  26711. if (length >= kMaxLength()) {
  26712. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  26713. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  26714. }
  26715. return length | 0
  26716. }
  26717. Buffer$1.isBuffer = isBuffer$1;
  26718. function internalIsBuffer (b) {
  26719. return !!(b != null && b._isBuffer)
  26720. }
  26721. Buffer$1.compare = function compare (a, b) {
  26722. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  26723. throw new TypeError('Arguments must be Buffers')
  26724. }
  26725. if (a === b) return 0
  26726. var x = a.length;
  26727. var y = b.length;
  26728. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  26729. if (a[i] !== b[i]) {
  26730. x = a[i];
  26731. y = b[i];
  26732. break
  26733. }
  26734. }
  26735. if (x < y) return -1
  26736. if (y < x) return 1
  26737. return 0
  26738. };
  26739. Buffer$1.isEncoding = function isEncoding (encoding) {
  26740. switch (String(encoding).toLowerCase()) {
  26741. case 'hex':
  26742. case 'utf8':
  26743. case 'utf-8':
  26744. case 'ascii':
  26745. case 'latin1':
  26746. case 'binary':
  26747. case 'base64':
  26748. case 'ucs2':
  26749. case 'ucs-2':
  26750. case 'utf16le':
  26751. case 'utf-16le':
  26752. return true
  26753. default:
  26754. return false
  26755. }
  26756. };
  26757. Buffer$1.concat = function concat (list, length) {
  26758. if (!isArray$2(list)) {
  26759. throw new TypeError('"list" argument must be an Array of Buffers')
  26760. }
  26761. if (list.length === 0) {
  26762. return Buffer$1.alloc(0)
  26763. }
  26764. var i;
  26765. if (length === undefined) {
  26766. length = 0;
  26767. for (i = 0; i < list.length; ++i) {
  26768. length += list[i].length;
  26769. }
  26770. }
  26771. var buffer = Buffer$1.allocUnsafe(length);
  26772. var pos = 0;
  26773. for (i = 0; i < list.length; ++i) {
  26774. var buf = list[i];
  26775. if (!internalIsBuffer(buf)) {
  26776. throw new TypeError('"list" argument must be an Array of Buffers')
  26777. }
  26778. buf.copy(buffer, pos);
  26779. pos += buf.length;
  26780. }
  26781. return buffer
  26782. };
  26783. function byteLength (string, encoding) {
  26784. if (internalIsBuffer(string)) {
  26785. return string.length
  26786. }
  26787. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  26788. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  26789. return string.byteLength
  26790. }
  26791. if (typeof string !== 'string') {
  26792. string = '' + string;
  26793. }
  26794. var len = string.length;
  26795. if (len === 0) return 0
  26796. // Use a for loop to avoid recursion
  26797. var loweredCase = false;
  26798. for (;;) {
  26799. switch (encoding) {
  26800. case 'ascii':
  26801. case 'latin1':
  26802. case 'binary':
  26803. return len
  26804. case 'utf8':
  26805. case 'utf-8':
  26806. case undefined:
  26807. return utf8ToBytes(string).length
  26808. case 'ucs2':
  26809. case 'ucs-2':
  26810. case 'utf16le':
  26811. case 'utf-16le':
  26812. return len * 2
  26813. case 'hex':
  26814. return len >>> 1
  26815. case 'base64':
  26816. return base64ToBytes(string).length
  26817. default:
  26818. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  26819. encoding = ('' + encoding).toLowerCase();
  26820. loweredCase = true;
  26821. }
  26822. }
  26823. }
  26824. Buffer$1.byteLength = byteLength;
  26825. function slowToString (encoding, start, end) {
  26826. var loweredCase = false;
  26827. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  26828. // property of a typed array.
  26829. // This behaves neither like String nor Uint8Array in that we set start/end
  26830. // to their upper/lower bounds if the value passed is out of range.
  26831. // undefined is handled specially as per ECMA-262 6th Edition,
  26832. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  26833. if (start === undefined || start < 0) {
  26834. start = 0;
  26835. }
  26836. // Return early if start > this.length. Done here to prevent potential uint32
  26837. // coercion fail below.
  26838. if (start > this.length) {
  26839. return ''
  26840. }
  26841. if (end === undefined || end > this.length) {
  26842. end = this.length;
  26843. }
  26844. if (end <= 0) {
  26845. return ''
  26846. }
  26847. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  26848. end >>>= 0;
  26849. start >>>= 0;
  26850. if (end <= start) {
  26851. return ''
  26852. }
  26853. if (!encoding) encoding = 'utf8';
  26854. while (true) {
  26855. switch (encoding) {
  26856. case 'hex':
  26857. return hexSlice(this, start, end)
  26858. case 'utf8':
  26859. case 'utf-8':
  26860. return utf8Slice(this, start, end)
  26861. case 'ascii':
  26862. return asciiSlice(this, start, end)
  26863. case 'latin1':
  26864. case 'binary':
  26865. return latin1Slice(this, start, end)
  26866. case 'base64':
  26867. return base64Slice(this, start, end)
  26868. case 'ucs2':
  26869. case 'ucs-2':
  26870. case 'utf16le':
  26871. case 'utf-16le':
  26872. return utf16leSlice(this, start, end)
  26873. default:
  26874. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  26875. encoding = (encoding + '').toLowerCase();
  26876. loweredCase = true;
  26877. }
  26878. }
  26879. }
  26880. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  26881. // Buffer instances.
  26882. Buffer$1.prototype._isBuffer = true;
  26883. function swap$1 (b, n, m) {
  26884. var i = b[n];
  26885. b[n] = b[m];
  26886. b[m] = i;
  26887. }
  26888. Buffer$1.prototype.swap16 = function swap16 () {
  26889. var len = this.length;
  26890. if (len % 2 !== 0) {
  26891. throw new RangeError('Buffer size must be a multiple of 16-bits')
  26892. }
  26893. for (var i = 0; i < len; i += 2) {
  26894. swap$1(this, i, i + 1);
  26895. }
  26896. return this
  26897. };
  26898. Buffer$1.prototype.swap32 = function swap32 () {
  26899. var len = this.length;
  26900. if (len % 4 !== 0) {
  26901. throw new RangeError('Buffer size must be a multiple of 32-bits')
  26902. }
  26903. for (var i = 0; i < len; i += 4) {
  26904. swap$1(this, i, i + 3);
  26905. swap$1(this, i + 1, i + 2);
  26906. }
  26907. return this
  26908. };
  26909. Buffer$1.prototype.swap64 = function swap64 () {
  26910. var len = this.length;
  26911. if (len % 8 !== 0) {
  26912. throw new RangeError('Buffer size must be a multiple of 64-bits')
  26913. }
  26914. for (var i = 0; i < len; i += 8) {
  26915. swap$1(this, i, i + 7);
  26916. swap$1(this, i + 1, i + 6);
  26917. swap$1(this, i + 2, i + 5);
  26918. swap$1(this, i + 3, i + 4);
  26919. }
  26920. return this
  26921. };
  26922. Buffer$1.prototype.toString = function toString () {
  26923. var length = this.length | 0;
  26924. if (length === 0) return ''
  26925. if (arguments.length === 0) return utf8Slice(this, 0, length)
  26926. return slowToString.apply(this, arguments)
  26927. };
  26928. Buffer$1.prototype.equals = function equals (b) {
  26929. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  26930. if (this === b) return true
  26931. return Buffer$1.compare(this, b) === 0
  26932. };
  26933. Buffer$1.prototype.inspect = function inspect () {
  26934. var str = '';
  26935. var max = INSPECT_MAX_BYTES;
  26936. if (this.length > 0) {
  26937. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  26938. if (this.length > max) str += ' ... ';
  26939. }
  26940. return '<Buffer ' + str + '>'
  26941. };
  26942. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  26943. if (!internalIsBuffer(target)) {
  26944. throw new TypeError('Argument must be a Buffer')
  26945. }
  26946. if (start === undefined) {
  26947. start = 0;
  26948. }
  26949. if (end === undefined) {
  26950. end = target ? target.length : 0;
  26951. }
  26952. if (thisStart === undefined) {
  26953. thisStart = 0;
  26954. }
  26955. if (thisEnd === undefined) {
  26956. thisEnd = this.length;
  26957. }
  26958. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  26959. throw new RangeError('out of range index')
  26960. }
  26961. if (thisStart >= thisEnd && start >= end) {
  26962. return 0
  26963. }
  26964. if (thisStart >= thisEnd) {
  26965. return -1
  26966. }
  26967. if (start >= end) {
  26968. return 1
  26969. }
  26970. start >>>= 0;
  26971. end >>>= 0;
  26972. thisStart >>>= 0;
  26973. thisEnd >>>= 0;
  26974. if (this === target) return 0
  26975. var x = thisEnd - thisStart;
  26976. var y = end - start;
  26977. var len = Math.min(x, y);
  26978. var thisCopy = this.slice(thisStart, thisEnd);
  26979. var targetCopy = target.slice(start, end);
  26980. for (var i = 0; i < len; ++i) {
  26981. if (thisCopy[i] !== targetCopy[i]) {
  26982. x = thisCopy[i];
  26983. y = targetCopy[i];
  26984. break
  26985. }
  26986. }
  26987. if (x < y) return -1
  26988. if (y < x) return 1
  26989. return 0
  26990. };
  26991. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  26992. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  26993. //
  26994. // Arguments:
  26995. // - buffer - a Buffer to search
  26996. // - val - a string, Buffer, or number
  26997. // - byteOffset - an index into `buffer`; will be clamped to an int32
  26998. // - encoding - an optional encoding, relevant is val is a string
  26999. // - dir - true for indexOf, false for lastIndexOf
  27000. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  27001. // Empty buffer means no match
  27002. if (buffer.length === 0) return -1
  27003. // Normalize byteOffset
  27004. if (typeof byteOffset === 'string') {
  27005. encoding = byteOffset;
  27006. byteOffset = 0;
  27007. } else if (byteOffset > 0x7fffffff) {
  27008. byteOffset = 0x7fffffff;
  27009. } else if (byteOffset < -0x80000000) {
  27010. byteOffset = -0x80000000;
  27011. }
  27012. byteOffset = +byteOffset; // Coerce to Number.
  27013. if (isNaN(byteOffset)) {
  27014. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  27015. byteOffset = dir ? 0 : (buffer.length - 1);
  27016. }
  27017. // Normalize byteOffset: negative offsets start from the end of the buffer
  27018. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  27019. if (byteOffset >= buffer.length) {
  27020. if (dir) return -1
  27021. else byteOffset = buffer.length - 1;
  27022. } else if (byteOffset < 0) {
  27023. if (dir) byteOffset = 0;
  27024. else return -1
  27025. }
  27026. // Normalize val
  27027. if (typeof val === 'string') {
  27028. val = Buffer$1.from(val, encoding);
  27029. }
  27030. // Finally, search either indexOf (if dir is true) or lastIndexOf
  27031. if (internalIsBuffer(val)) {
  27032. // Special case: looking for empty string/buffer always fails
  27033. if (val.length === 0) {
  27034. return -1
  27035. }
  27036. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  27037. } else if (typeof val === 'number') {
  27038. val = val & 0xFF; // Search for a byte value [0-255]
  27039. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  27040. typeof Uint8Array.prototype.indexOf === 'function') {
  27041. if (dir) {
  27042. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  27043. } else {
  27044. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  27045. }
  27046. }
  27047. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  27048. }
  27049. throw new TypeError('val must be string, number or Buffer')
  27050. }
  27051. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  27052. var indexSize = 1;
  27053. var arrLength = arr.length;
  27054. var valLength = val.length;
  27055. if (encoding !== undefined) {
  27056. encoding = String(encoding).toLowerCase();
  27057. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  27058. encoding === 'utf16le' || encoding === 'utf-16le') {
  27059. if (arr.length < 2 || val.length < 2) {
  27060. return -1
  27061. }
  27062. indexSize = 2;
  27063. arrLength /= 2;
  27064. valLength /= 2;
  27065. byteOffset /= 2;
  27066. }
  27067. }
  27068. function read (buf, i) {
  27069. if (indexSize === 1) {
  27070. return buf[i]
  27071. } else {
  27072. return buf.readUInt16BE(i * indexSize)
  27073. }
  27074. }
  27075. var i;
  27076. if (dir) {
  27077. var foundIndex = -1;
  27078. for (i = byteOffset; i < arrLength; i++) {
  27079. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  27080. if (foundIndex === -1) foundIndex = i;
  27081. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  27082. } else {
  27083. if (foundIndex !== -1) i -= i - foundIndex;
  27084. foundIndex = -1;
  27085. }
  27086. }
  27087. } else {
  27088. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  27089. for (i = byteOffset; i >= 0; i--) {
  27090. var found = true;
  27091. for (var j = 0; j < valLength; j++) {
  27092. if (read(arr, i + j) !== read(val, j)) {
  27093. found = false;
  27094. break
  27095. }
  27096. }
  27097. if (found) return i
  27098. }
  27099. }
  27100. return -1
  27101. }
  27102. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  27103. return this.indexOf(val, byteOffset, encoding) !== -1
  27104. };
  27105. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  27106. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  27107. };
  27108. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  27109. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  27110. };
  27111. function hexWrite (buf, string, offset, length) {
  27112. offset = Number(offset) || 0;
  27113. var remaining = buf.length - offset;
  27114. if (!length) {
  27115. length = remaining;
  27116. } else {
  27117. length = Number(length);
  27118. if (length > remaining) {
  27119. length = remaining;
  27120. }
  27121. }
  27122. // must be an even number of digits
  27123. var strLen = string.length;
  27124. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  27125. if (length > strLen / 2) {
  27126. length = strLen / 2;
  27127. }
  27128. for (var i = 0; i < length; ++i) {
  27129. var parsed = parseInt(string.substr(i * 2, 2), 16);
  27130. if (isNaN(parsed)) return i
  27131. buf[offset + i] = parsed;
  27132. }
  27133. return i
  27134. }
  27135. function utf8Write (buf, string, offset, length) {
  27136. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  27137. }
  27138. function asciiWrite (buf, string, offset, length) {
  27139. return blitBuffer(asciiToBytes(string), buf, offset, length)
  27140. }
  27141. function latin1Write (buf, string, offset, length) {
  27142. return asciiWrite(buf, string, offset, length)
  27143. }
  27144. function base64Write (buf, string, offset, length) {
  27145. return blitBuffer(base64ToBytes(string), buf, offset, length)
  27146. }
  27147. function ucs2Write (buf, string, offset, length) {
  27148. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  27149. }
  27150. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  27151. // Buffer#write(string)
  27152. if (offset === undefined) {
  27153. encoding = 'utf8';
  27154. length = this.length;
  27155. offset = 0;
  27156. // Buffer#write(string, encoding)
  27157. } else if (length === undefined && typeof offset === 'string') {
  27158. encoding = offset;
  27159. length = this.length;
  27160. offset = 0;
  27161. // Buffer#write(string, offset[, length][, encoding])
  27162. } else if (isFinite(offset)) {
  27163. offset = offset | 0;
  27164. if (isFinite(length)) {
  27165. length = length | 0;
  27166. if (encoding === undefined) encoding = 'utf8';
  27167. } else {
  27168. encoding = length;
  27169. length = undefined;
  27170. }
  27171. // legacy write(string, encoding, offset, length) - remove in v0.13
  27172. } else {
  27173. throw new Error(
  27174. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  27175. )
  27176. }
  27177. var remaining = this.length - offset;
  27178. if (length === undefined || length > remaining) length = remaining;
  27179. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  27180. throw new RangeError('Attempt to write outside buffer bounds')
  27181. }
  27182. if (!encoding) encoding = 'utf8';
  27183. var loweredCase = false;
  27184. for (;;) {
  27185. switch (encoding) {
  27186. case 'hex':
  27187. return hexWrite(this, string, offset, length)
  27188. case 'utf8':
  27189. case 'utf-8':
  27190. return utf8Write(this, string, offset, length)
  27191. case 'ascii':
  27192. return asciiWrite(this, string, offset, length)
  27193. case 'latin1':
  27194. case 'binary':
  27195. return latin1Write(this, string, offset, length)
  27196. case 'base64':
  27197. // Warning: maxLength not taken into account in base64Write
  27198. return base64Write(this, string, offset, length)
  27199. case 'ucs2':
  27200. case 'ucs-2':
  27201. case 'utf16le':
  27202. case 'utf-16le':
  27203. return ucs2Write(this, string, offset, length)
  27204. default:
  27205. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27206. encoding = ('' + encoding).toLowerCase();
  27207. loweredCase = true;
  27208. }
  27209. }
  27210. };
  27211. Buffer$1.prototype.toJSON = function toJSON () {
  27212. return {
  27213. type: 'Buffer',
  27214. data: Array.prototype.slice.call(this._arr || this, 0)
  27215. }
  27216. };
  27217. function base64Slice (buf, start, end) {
  27218. if (start === 0 && end === buf.length) {
  27219. return fromByteArray(buf)
  27220. } else {
  27221. return fromByteArray(buf.slice(start, end))
  27222. }
  27223. }
  27224. function utf8Slice (buf, start, end) {
  27225. end = Math.min(buf.length, end);
  27226. var res = [];
  27227. var i = start;
  27228. while (i < end) {
  27229. var firstByte = buf[i];
  27230. var codePoint = null;
  27231. var bytesPerSequence = (firstByte > 0xEF) ? 4
  27232. : (firstByte > 0xDF) ? 3
  27233. : (firstByte > 0xBF) ? 2
  27234. : 1;
  27235. if (i + bytesPerSequence <= end) {
  27236. var secondByte, thirdByte, fourthByte, tempCodePoint;
  27237. switch (bytesPerSequence) {
  27238. case 1:
  27239. if (firstByte < 0x80) {
  27240. codePoint = firstByte;
  27241. }
  27242. break
  27243. case 2:
  27244. secondByte = buf[i + 1];
  27245. if ((secondByte & 0xC0) === 0x80) {
  27246. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  27247. if (tempCodePoint > 0x7F) {
  27248. codePoint = tempCodePoint;
  27249. }
  27250. }
  27251. break
  27252. case 3:
  27253. secondByte = buf[i + 1];
  27254. thirdByte = buf[i + 2];
  27255. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  27256. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  27257. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  27258. codePoint = tempCodePoint;
  27259. }
  27260. }
  27261. break
  27262. case 4:
  27263. secondByte = buf[i + 1];
  27264. thirdByte = buf[i + 2];
  27265. fourthByte = buf[i + 3];
  27266. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  27267. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  27268. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  27269. codePoint = tempCodePoint;
  27270. }
  27271. }
  27272. }
  27273. }
  27274. if (codePoint === null) {
  27275. // we did not generate a valid codePoint so insert a
  27276. // replacement char (U+FFFD) and advance only 1 byte
  27277. codePoint = 0xFFFD;
  27278. bytesPerSequence = 1;
  27279. } else if (codePoint > 0xFFFF) {
  27280. // encode to utf16 (surrogate pair dance)
  27281. codePoint -= 0x10000;
  27282. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  27283. codePoint = 0xDC00 | codePoint & 0x3FF;
  27284. }
  27285. res.push(codePoint);
  27286. i += bytesPerSequence;
  27287. }
  27288. return decodeCodePointsArray(res)
  27289. }
  27290. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  27291. // the lowest limit is Chrome, with 0x10000 args.
  27292. // We go 1 magnitude less, for safety
  27293. var MAX_ARGUMENTS_LENGTH = 0x1000;
  27294. function decodeCodePointsArray (codePoints) {
  27295. var len = codePoints.length;
  27296. if (len <= MAX_ARGUMENTS_LENGTH) {
  27297. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  27298. }
  27299. // Decode in chunks to avoid "call stack size exceeded".
  27300. var res = '';
  27301. var i = 0;
  27302. while (i < len) {
  27303. res += String.fromCharCode.apply(
  27304. String,
  27305. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  27306. );
  27307. }
  27308. return res
  27309. }
  27310. function asciiSlice (buf, start, end) {
  27311. var ret = '';
  27312. end = Math.min(buf.length, end);
  27313. for (var i = start; i < end; ++i) {
  27314. ret += String.fromCharCode(buf[i] & 0x7F);
  27315. }
  27316. return ret
  27317. }
  27318. function latin1Slice (buf, start, end) {
  27319. var ret = '';
  27320. end = Math.min(buf.length, end);
  27321. for (var i = start; i < end; ++i) {
  27322. ret += String.fromCharCode(buf[i]);
  27323. }
  27324. return ret
  27325. }
  27326. function hexSlice (buf, start, end) {
  27327. var len = buf.length;
  27328. if (!start || start < 0) start = 0;
  27329. if (!end || end < 0 || end > len) end = len;
  27330. var out = '';
  27331. for (var i = start; i < end; ++i) {
  27332. out += toHex(buf[i]);
  27333. }
  27334. return out
  27335. }
  27336. function utf16leSlice (buf, start, end) {
  27337. var bytes = buf.slice(start, end);
  27338. var res = '';
  27339. for (var i = 0; i < bytes.length; i += 2) {
  27340. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  27341. }
  27342. return res
  27343. }
  27344. Buffer$1.prototype.slice = function slice (start, end) {
  27345. var len = this.length;
  27346. start = ~~start;
  27347. end = end === undefined ? len : ~~end;
  27348. if (start < 0) {
  27349. start += len;
  27350. if (start < 0) start = 0;
  27351. } else if (start > len) {
  27352. start = len;
  27353. }
  27354. if (end < 0) {
  27355. end += len;
  27356. if (end < 0) end = 0;
  27357. } else if (end > len) {
  27358. end = len;
  27359. }
  27360. if (end < start) end = start;
  27361. var newBuf;
  27362. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27363. newBuf = this.subarray(start, end);
  27364. newBuf.__proto__ = Buffer$1.prototype;
  27365. } else {
  27366. var sliceLen = end - start;
  27367. newBuf = new Buffer$1(sliceLen, undefined);
  27368. for (var i = 0; i < sliceLen; ++i) {
  27369. newBuf[i] = this[i + start];
  27370. }
  27371. }
  27372. return newBuf
  27373. };
  27374. /*
  27375. * Need to make sure that buffer isn't trying to write out of bounds.
  27376. */
  27377. function checkOffset (offset, ext, length) {
  27378. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  27379. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  27380. }
  27381. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  27382. offset = offset | 0;
  27383. byteLength = byteLength | 0;
  27384. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27385. var val = this[offset];
  27386. var mul = 1;
  27387. var i = 0;
  27388. while (++i < byteLength && (mul *= 0x100)) {
  27389. val += this[offset + i] * mul;
  27390. }
  27391. return val
  27392. };
  27393. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  27394. offset = offset | 0;
  27395. byteLength = byteLength | 0;
  27396. if (!noAssert) {
  27397. checkOffset(offset, byteLength, this.length);
  27398. }
  27399. var val = this[offset + --byteLength];
  27400. var mul = 1;
  27401. while (byteLength > 0 && (mul *= 0x100)) {
  27402. val += this[offset + --byteLength] * mul;
  27403. }
  27404. return val
  27405. };
  27406. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  27407. if (!noAssert) checkOffset(offset, 1, this.length);
  27408. return this[offset]
  27409. };
  27410. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  27411. if (!noAssert) checkOffset(offset, 2, this.length);
  27412. return this[offset] | (this[offset + 1] << 8)
  27413. };
  27414. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  27415. if (!noAssert) checkOffset(offset, 2, this.length);
  27416. return (this[offset] << 8) | this[offset + 1]
  27417. };
  27418. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  27419. if (!noAssert) checkOffset(offset, 4, this.length);
  27420. return ((this[offset]) |
  27421. (this[offset + 1] << 8) |
  27422. (this[offset + 2] << 16)) +
  27423. (this[offset + 3] * 0x1000000)
  27424. };
  27425. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  27426. if (!noAssert) checkOffset(offset, 4, this.length);
  27427. return (this[offset] * 0x1000000) +
  27428. ((this[offset + 1] << 16) |
  27429. (this[offset + 2] << 8) |
  27430. this[offset + 3])
  27431. };
  27432. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  27433. offset = offset | 0;
  27434. byteLength = byteLength | 0;
  27435. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27436. var val = this[offset];
  27437. var mul = 1;
  27438. var i = 0;
  27439. while (++i < byteLength && (mul *= 0x100)) {
  27440. val += this[offset + i] * mul;
  27441. }
  27442. mul *= 0x80;
  27443. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27444. return val
  27445. };
  27446. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  27447. offset = offset | 0;
  27448. byteLength = byteLength | 0;
  27449. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27450. var i = byteLength;
  27451. var mul = 1;
  27452. var val = this[offset + --i];
  27453. while (i > 0 && (mul *= 0x100)) {
  27454. val += this[offset + --i] * mul;
  27455. }
  27456. mul *= 0x80;
  27457. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27458. return val
  27459. };
  27460. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  27461. if (!noAssert) checkOffset(offset, 1, this.length);
  27462. if (!(this[offset] & 0x80)) return (this[offset])
  27463. return ((0xff - this[offset] + 1) * -1)
  27464. };
  27465. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  27466. if (!noAssert) checkOffset(offset, 2, this.length);
  27467. var val = this[offset] | (this[offset + 1] << 8);
  27468. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27469. };
  27470. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  27471. if (!noAssert) checkOffset(offset, 2, this.length);
  27472. var val = this[offset + 1] | (this[offset] << 8);
  27473. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27474. };
  27475. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  27476. if (!noAssert) checkOffset(offset, 4, this.length);
  27477. return (this[offset]) |
  27478. (this[offset + 1] << 8) |
  27479. (this[offset + 2] << 16) |
  27480. (this[offset + 3] << 24)
  27481. };
  27482. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  27483. if (!noAssert) checkOffset(offset, 4, this.length);
  27484. return (this[offset] << 24) |
  27485. (this[offset + 1] << 16) |
  27486. (this[offset + 2] << 8) |
  27487. (this[offset + 3])
  27488. };
  27489. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  27490. if (!noAssert) checkOffset(offset, 4, this.length);
  27491. return read(this, offset, true, 23, 4)
  27492. };
  27493. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  27494. if (!noAssert) checkOffset(offset, 4, this.length);
  27495. return read(this, offset, false, 23, 4)
  27496. };
  27497. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  27498. if (!noAssert) checkOffset(offset, 8, this.length);
  27499. return read(this, offset, true, 52, 8)
  27500. };
  27501. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  27502. if (!noAssert) checkOffset(offset, 8, this.length);
  27503. return read(this, offset, false, 52, 8)
  27504. };
  27505. function checkInt (buf, value, offset, ext, max, min) {
  27506. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  27507. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  27508. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27509. }
  27510. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  27511. value = +value;
  27512. offset = offset | 0;
  27513. byteLength = byteLength | 0;
  27514. if (!noAssert) {
  27515. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27516. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27517. }
  27518. var mul = 1;
  27519. var i = 0;
  27520. this[offset] = value & 0xFF;
  27521. while (++i < byteLength && (mul *= 0x100)) {
  27522. this[offset + i] = (value / mul) & 0xFF;
  27523. }
  27524. return offset + byteLength
  27525. };
  27526. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  27527. value = +value;
  27528. offset = offset | 0;
  27529. byteLength = byteLength | 0;
  27530. if (!noAssert) {
  27531. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27532. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27533. }
  27534. var i = byteLength - 1;
  27535. var mul = 1;
  27536. this[offset + i] = value & 0xFF;
  27537. while (--i >= 0 && (mul *= 0x100)) {
  27538. this[offset + i] = (value / mul) & 0xFF;
  27539. }
  27540. return offset + byteLength
  27541. };
  27542. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  27543. value = +value;
  27544. offset = offset | 0;
  27545. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  27546. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27547. this[offset] = (value & 0xff);
  27548. return offset + 1
  27549. };
  27550. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  27551. if (value < 0) value = 0xffff + value + 1;
  27552. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  27553. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  27554. (littleEndian ? i : 1 - i) * 8;
  27555. }
  27556. }
  27557. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  27558. value = +value;
  27559. offset = offset | 0;
  27560. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27561. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27562. this[offset] = (value & 0xff);
  27563. this[offset + 1] = (value >>> 8);
  27564. } else {
  27565. objectWriteUInt16(this, value, offset, true);
  27566. }
  27567. return offset + 2
  27568. };
  27569. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  27570. value = +value;
  27571. offset = offset | 0;
  27572. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27573. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27574. this[offset] = (value >>> 8);
  27575. this[offset + 1] = (value & 0xff);
  27576. } else {
  27577. objectWriteUInt16(this, value, offset, false);
  27578. }
  27579. return offset + 2
  27580. };
  27581. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  27582. if (value < 0) value = 0xffffffff + value + 1;
  27583. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  27584. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  27585. }
  27586. }
  27587. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  27588. value = +value;
  27589. offset = offset | 0;
  27590. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27591. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27592. this[offset + 3] = (value >>> 24);
  27593. this[offset + 2] = (value >>> 16);
  27594. this[offset + 1] = (value >>> 8);
  27595. this[offset] = (value & 0xff);
  27596. } else {
  27597. objectWriteUInt32(this, value, offset, true);
  27598. }
  27599. return offset + 4
  27600. };
  27601. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  27602. value = +value;
  27603. offset = offset | 0;
  27604. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27605. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27606. this[offset] = (value >>> 24);
  27607. this[offset + 1] = (value >>> 16);
  27608. this[offset + 2] = (value >>> 8);
  27609. this[offset + 3] = (value & 0xff);
  27610. } else {
  27611. objectWriteUInt32(this, value, offset, false);
  27612. }
  27613. return offset + 4
  27614. };
  27615. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  27616. value = +value;
  27617. offset = offset | 0;
  27618. if (!noAssert) {
  27619. var limit = Math.pow(2, 8 * byteLength - 1);
  27620. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27621. }
  27622. var i = 0;
  27623. var mul = 1;
  27624. var sub = 0;
  27625. this[offset] = value & 0xFF;
  27626. while (++i < byteLength && (mul *= 0x100)) {
  27627. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  27628. sub = 1;
  27629. }
  27630. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27631. }
  27632. return offset + byteLength
  27633. };
  27634. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  27635. value = +value;
  27636. offset = offset | 0;
  27637. if (!noAssert) {
  27638. var limit = Math.pow(2, 8 * byteLength - 1);
  27639. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27640. }
  27641. var i = byteLength - 1;
  27642. var mul = 1;
  27643. var sub = 0;
  27644. this[offset + i] = value & 0xFF;
  27645. while (--i >= 0 && (mul *= 0x100)) {
  27646. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  27647. sub = 1;
  27648. }
  27649. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27650. }
  27651. return offset + byteLength
  27652. };
  27653. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  27654. value = +value;
  27655. offset = offset | 0;
  27656. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  27657. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27658. if (value < 0) value = 0xff + value + 1;
  27659. this[offset] = (value & 0xff);
  27660. return offset + 1
  27661. };
  27662. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  27663. value = +value;
  27664. offset = offset | 0;
  27665. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27666. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27667. this[offset] = (value & 0xff);
  27668. this[offset + 1] = (value >>> 8);
  27669. } else {
  27670. objectWriteUInt16(this, value, offset, true);
  27671. }
  27672. return offset + 2
  27673. };
  27674. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  27675. value = +value;
  27676. offset = offset | 0;
  27677. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27678. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27679. this[offset] = (value >>> 8);
  27680. this[offset + 1] = (value & 0xff);
  27681. } else {
  27682. objectWriteUInt16(this, value, offset, false);
  27683. }
  27684. return offset + 2
  27685. };
  27686. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  27687. value = +value;
  27688. offset = offset | 0;
  27689. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27690. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27691. this[offset] = (value & 0xff);
  27692. this[offset + 1] = (value >>> 8);
  27693. this[offset + 2] = (value >>> 16);
  27694. this[offset + 3] = (value >>> 24);
  27695. } else {
  27696. objectWriteUInt32(this, value, offset, true);
  27697. }
  27698. return offset + 4
  27699. };
  27700. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  27701. value = +value;
  27702. offset = offset | 0;
  27703. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27704. if (value < 0) value = 0xffffffff + value + 1;
  27705. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27706. this[offset] = (value >>> 24);
  27707. this[offset + 1] = (value >>> 16);
  27708. this[offset + 2] = (value >>> 8);
  27709. this[offset + 3] = (value & 0xff);
  27710. } else {
  27711. objectWriteUInt32(this, value, offset, false);
  27712. }
  27713. return offset + 4
  27714. };
  27715. function checkIEEE754 (buf, value, offset, ext, max, min) {
  27716. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27717. if (offset < 0) throw new RangeError('Index out of range')
  27718. }
  27719. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  27720. if (!noAssert) {
  27721. checkIEEE754(buf, value, offset, 4);
  27722. }
  27723. write(buf, value, offset, littleEndian, 23, 4);
  27724. return offset + 4
  27725. }
  27726. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  27727. return writeFloat(this, value, offset, true, noAssert)
  27728. };
  27729. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  27730. return writeFloat(this, value, offset, false, noAssert)
  27731. };
  27732. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  27733. if (!noAssert) {
  27734. checkIEEE754(buf, value, offset, 8);
  27735. }
  27736. write(buf, value, offset, littleEndian, 52, 8);
  27737. return offset + 8
  27738. }
  27739. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  27740. return writeDouble(this, value, offset, true, noAssert)
  27741. };
  27742. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  27743. return writeDouble(this, value, offset, false, noAssert)
  27744. };
  27745. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  27746. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  27747. if (!start) start = 0;
  27748. if (!end && end !== 0) end = this.length;
  27749. if (targetStart >= target.length) targetStart = target.length;
  27750. if (!targetStart) targetStart = 0;
  27751. if (end > 0 && end < start) end = start;
  27752. // Copy 0 bytes; we're done
  27753. if (end === start) return 0
  27754. if (target.length === 0 || this.length === 0) return 0
  27755. // Fatal error conditions
  27756. if (targetStart < 0) {
  27757. throw new RangeError('targetStart out of bounds')
  27758. }
  27759. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  27760. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  27761. // Are we oob?
  27762. if (end > this.length) end = this.length;
  27763. if (target.length - targetStart < end - start) {
  27764. end = target.length - targetStart + start;
  27765. }
  27766. var len = end - start;
  27767. var i;
  27768. if (this === target && start < targetStart && targetStart < end) {
  27769. // descending copy from end
  27770. for (i = len - 1; i >= 0; --i) {
  27771. target[i + targetStart] = this[i + start];
  27772. }
  27773. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  27774. // ascending copy from start
  27775. for (i = 0; i < len; ++i) {
  27776. target[i + targetStart] = this[i + start];
  27777. }
  27778. } else {
  27779. Uint8Array.prototype.set.call(
  27780. target,
  27781. this.subarray(start, start + len),
  27782. targetStart
  27783. );
  27784. }
  27785. return len
  27786. };
  27787. // Usage:
  27788. // buffer.fill(number[, offset[, end]])
  27789. // buffer.fill(buffer[, offset[, end]])
  27790. // buffer.fill(string[, offset[, end]][, encoding])
  27791. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  27792. // Handle string cases:
  27793. if (typeof val === 'string') {
  27794. if (typeof start === 'string') {
  27795. encoding = start;
  27796. start = 0;
  27797. end = this.length;
  27798. } else if (typeof end === 'string') {
  27799. encoding = end;
  27800. end = this.length;
  27801. }
  27802. if (val.length === 1) {
  27803. var code = val.charCodeAt(0);
  27804. if (code < 256) {
  27805. val = code;
  27806. }
  27807. }
  27808. if (encoding !== undefined && typeof encoding !== 'string') {
  27809. throw new TypeError('encoding must be a string')
  27810. }
  27811. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  27812. throw new TypeError('Unknown encoding: ' + encoding)
  27813. }
  27814. } else if (typeof val === 'number') {
  27815. val = val & 255;
  27816. }
  27817. // Invalid ranges are not set to a default, so can range check early.
  27818. if (start < 0 || this.length < start || this.length < end) {
  27819. throw new RangeError('Out of range index')
  27820. }
  27821. if (end <= start) {
  27822. return this
  27823. }
  27824. start = start >>> 0;
  27825. end = end === undefined ? this.length : end >>> 0;
  27826. if (!val) val = 0;
  27827. var i;
  27828. if (typeof val === 'number') {
  27829. for (i = start; i < end; ++i) {
  27830. this[i] = val;
  27831. }
  27832. } else {
  27833. var bytes = internalIsBuffer(val)
  27834. ? val
  27835. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  27836. var len = bytes.length;
  27837. for (i = 0; i < end - start; ++i) {
  27838. this[i + start] = bytes[i % len];
  27839. }
  27840. }
  27841. return this
  27842. };
  27843. // HELPER FUNCTIONS
  27844. // ================
  27845. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  27846. function base64clean (str) {
  27847. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  27848. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  27849. // Node converts strings with length < 2 to ''
  27850. if (str.length < 2) return ''
  27851. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  27852. while (str.length % 4 !== 0) {
  27853. str = str + '=';
  27854. }
  27855. return str
  27856. }
  27857. function stringtrim (str) {
  27858. if (str.trim) return str.trim()
  27859. return str.replace(/^\s+|\s+$/g, '')
  27860. }
  27861. function toHex (n) {
  27862. if (n < 16) return '0' + n.toString(16)
  27863. return n.toString(16)
  27864. }
  27865. function utf8ToBytes (string, units) {
  27866. units = units || Infinity;
  27867. var codePoint;
  27868. var length = string.length;
  27869. var leadSurrogate = null;
  27870. var bytes = [];
  27871. for (var i = 0; i < length; ++i) {
  27872. codePoint = string.charCodeAt(i);
  27873. // is surrogate component
  27874. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  27875. // last char was a lead
  27876. if (!leadSurrogate) {
  27877. // no lead yet
  27878. if (codePoint > 0xDBFF) {
  27879. // unexpected trail
  27880. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27881. continue
  27882. } else if (i + 1 === length) {
  27883. // unpaired lead
  27884. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27885. continue
  27886. }
  27887. // valid lead
  27888. leadSurrogate = codePoint;
  27889. continue
  27890. }
  27891. // 2 leads in a row
  27892. if (codePoint < 0xDC00) {
  27893. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27894. leadSurrogate = codePoint;
  27895. continue
  27896. }
  27897. // valid surrogate pair
  27898. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  27899. } else if (leadSurrogate) {
  27900. // valid bmp char, but last char was a lead
  27901. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27902. }
  27903. leadSurrogate = null;
  27904. // encode utf8
  27905. if (codePoint < 0x80) {
  27906. if ((units -= 1) < 0) break
  27907. bytes.push(codePoint);
  27908. } else if (codePoint < 0x800) {
  27909. if ((units -= 2) < 0) break
  27910. bytes.push(
  27911. codePoint >> 0x6 | 0xC0,
  27912. codePoint & 0x3F | 0x80
  27913. );
  27914. } else if (codePoint < 0x10000) {
  27915. if ((units -= 3) < 0) break
  27916. bytes.push(
  27917. codePoint >> 0xC | 0xE0,
  27918. codePoint >> 0x6 & 0x3F | 0x80,
  27919. codePoint & 0x3F | 0x80
  27920. );
  27921. } else if (codePoint < 0x110000) {
  27922. if ((units -= 4) < 0) break
  27923. bytes.push(
  27924. codePoint >> 0x12 | 0xF0,
  27925. codePoint >> 0xC & 0x3F | 0x80,
  27926. codePoint >> 0x6 & 0x3F | 0x80,
  27927. codePoint & 0x3F | 0x80
  27928. );
  27929. } else {
  27930. throw new Error('Invalid code point')
  27931. }
  27932. }
  27933. return bytes
  27934. }
  27935. function asciiToBytes (str) {
  27936. var byteArray = [];
  27937. for (var i = 0; i < str.length; ++i) {
  27938. // Node's code seems to be doing this and not & 0x7F..
  27939. byteArray.push(str.charCodeAt(i) & 0xFF);
  27940. }
  27941. return byteArray
  27942. }
  27943. function utf16leToBytes (str, units) {
  27944. var c, hi, lo;
  27945. var byteArray = [];
  27946. for (var i = 0; i < str.length; ++i) {
  27947. if ((units -= 2) < 0) break
  27948. c = str.charCodeAt(i);
  27949. hi = c >> 8;
  27950. lo = c % 256;
  27951. byteArray.push(lo);
  27952. byteArray.push(hi);
  27953. }
  27954. return byteArray
  27955. }
  27956. function base64ToBytes (str) {
  27957. return toByteArray(base64clean(str))
  27958. }
  27959. function blitBuffer (src, dst, offset, length) {
  27960. for (var i = 0; i < length; ++i) {
  27961. if ((i + offset >= dst.length) || (i >= src.length)) break
  27962. dst[i + offset] = src[i];
  27963. }
  27964. return i
  27965. }
  27966. function isnan (val) {
  27967. return val !== val // eslint-disable-line no-self-compare
  27968. }
  27969. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  27970. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27971. // Object.prototype.constructor. Remove this eventually
  27972. function isBuffer$1(obj) {
  27973. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  27974. }
  27975. function isFastBuffer (obj) {
  27976. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27977. }
  27978. // For Node v0.10 support. Remove this eventually.
  27979. function isSlowBuffer (obj) {
  27980. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  27981. }
  27982. var inherits;
  27983. if (typeof Object.create === 'function'){
  27984. inherits = function inherits(ctor, superCtor) {
  27985. // implementation from standard node.js 'util' module
  27986. ctor.super_ = superCtor;
  27987. ctor.prototype = Object.create(superCtor.prototype, {
  27988. constructor: {
  27989. value: ctor,
  27990. enumerable: false,
  27991. writable: true,
  27992. configurable: true
  27993. }
  27994. });
  27995. };
  27996. } else {
  27997. inherits = function inherits(ctor, superCtor) {
  27998. ctor.super_ = superCtor;
  27999. var TempCtor = function () {};
  28000. TempCtor.prototype = superCtor.prototype;
  28001. ctor.prototype = new TempCtor();
  28002. ctor.prototype.constructor = ctor;
  28003. };
  28004. }
  28005. var inherits$1 = inherits;
  28006. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  28007. function getOwnPropertyDescriptors(obj) {
  28008. var keys = Object.keys(obj);
  28009. var descriptors = {};
  28010. for (var i = 0; i < keys.length; i++) {
  28011. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  28012. }
  28013. return descriptors;
  28014. };
  28015. var formatRegExp = /%[sdj%]/g;
  28016. function format$1(f) {
  28017. if (!isString$1(f)) {
  28018. var objects = [];
  28019. for (var i = 0; i < arguments.length; i++) {
  28020. objects.push(inspect(arguments[i]));
  28021. }
  28022. return objects.join(' ');
  28023. }
  28024. var i = 1;
  28025. var args = arguments;
  28026. var len = args.length;
  28027. var str = String(f).replace(formatRegExp, function(x) {
  28028. if (x === '%%') return '%';
  28029. if (i >= len) return x;
  28030. switch (x) {
  28031. case '%s': return String(args[i++]);
  28032. case '%d': return Number(args[i++]);
  28033. case '%j':
  28034. try {
  28035. return JSON.stringify(args[i++]);
  28036. } catch (_) {
  28037. return '[Circular]';
  28038. }
  28039. default:
  28040. return x;
  28041. }
  28042. });
  28043. for (var x = args[i]; i < len; x = args[++i]) {
  28044. if (isNull(x) || !isObject$1(x)) {
  28045. str += ' ' + x;
  28046. } else {
  28047. str += ' ' + inspect(x);
  28048. }
  28049. }
  28050. return str;
  28051. }
  28052. // Mark that a method should not be used.
  28053. // Returns a modified function which warns once by default.
  28054. // If --no-deprecation is set, then it is a no-op.
  28055. function deprecate(fn, msg) {
  28056. // Allow for deprecating things in the process of starting up.
  28057. if (isUndefined(global$1.process)) {
  28058. return function() {
  28059. return deprecate(fn, msg).apply(this, arguments);
  28060. };
  28061. }
  28062. if (browser$1.noDeprecation === true) {
  28063. return fn;
  28064. }
  28065. var warned = false;
  28066. function deprecated() {
  28067. if (!warned) {
  28068. if (browser$1.throwDeprecation) {
  28069. throw new Error(msg);
  28070. } else if (browser$1.traceDeprecation) {
  28071. console.trace(msg);
  28072. } else {
  28073. console.error(msg);
  28074. }
  28075. warned = true;
  28076. }
  28077. return fn.apply(this, arguments);
  28078. }
  28079. return deprecated;
  28080. }
  28081. var debugs = {};
  28082. var debugEnviron;
  28083. function debuglog(set) {
  28084. if (isUndefined(debugEnviron))
  28085. debugEnviron = browser$1.env.NODE_DEBUG || '';
  28086. set = set.toUpperCase();
  28087. if (!debugs[set]) {
  28088. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  28089. var pid = 0;
  28090. debugs[set] = function() {
  28091. var msg = format$1.apply(null, arguments);
  28092. console.error('%s %d: %s', set, pid, msg);
  28093. };
  28094. } else {
  28095. debugs[set] = function() {};
  28096. }
  28097. }
  28098. return debugs[set];
  28099. }
  28100. /**
  28101. * Echos the value of a value. Trys to print the value out
  28102. * in the best way possible given the different types.
  28103. *
  28104. * @param {Object} obj The object to print out.
  28105. * @param {Object} opts Optional options object that alters the output.
  28106. */
  28107. /* legacy: obj, showHidden, depth, colors*/
  28108. function inspect(obj, opts) {
  28109. // default options
  28110. var ctx = {
  28111. seen: [],
  28112. stylize: stylizeNoColor
  28113. };
  28114. // legacy...
  28115. if (arguments.length >= 3) ctx.depth = arguments[2];
  28116. if (arguments.length >= 4) ctx.colors = arguments[3];
  28117. if (isBoolean(opts)) {
  28118. // legacy...
  28119. ctx.showHidden = opts;
  28120. } else if (opts) {
  28121. // got an "options" object
  28122. _extend(ctx, opts);
  28123. }
  28124. // set default options
  28125. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  28126. if (isUndefined(ctx.depth)) ctx.depth = 2;
  28127. if (isUndefined(ctx.colors)) ctx.colors = false;
  28128. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  28129. if (ctx.colors) ctx.stylize = stylizeWithColor;
  28130. return formatValue(ctx, obj, ctx.depth);
  28131. }
  28132. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28133. inspect.colors = {
  28134. 'bold' : [1, 22],
  28135. 'italic' : [3, 23],
  28136. 'underline' : [4, 24],
  28137. 'inverse' : [7, 27],
  28138. 'white' : [37, 39],
  28139. 'grey' : [90, 39],
  28140. 'black' : [30, 39],
  28141. 'blue' : [34, 39],
  28142. 'cyan' : [36, 39],
  28143. 'green' : [32, 39],
  28144. 'magenta' : [35, 39],
  28145. 'red' : [31, 39],
  28146. 'yellow' : [33, 39]
  28147. };
  28148. // Don't use 'blue' not visible on cmd.exe
  28149. inspect.styles = {
  28150. 'special': 'cyan',
  28151. 'number': 'yellow',
  28152. 'boolean': 'yellow',
  28153. 'undefined': 'grey',
  28154. 'null': 'bold',
  28155. 'string': 'green',
  28156. 'date': 'magenta',
  28157. // "name": intentionally not styling
  28158. 'regexp': 'red'
  28159. };
  28160. function stylizeWithColor(str, styleType) {
  28161. var style = inspect.styles[styleType];
  28162. if (style) {
  28163. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  28164. '\u001b[' + inspect.colors[style][1] + 'm';
  28165. } else {
  28166. return str;
  28167. }
  28168. }
  28169. function stylizeNoColor(str, styleType) {
  28170. return str;
  28171. }
  28172. function arrayToHash(array) {
  28173. var hash = {};
  28174. array.forEach(function(val, idx) {
  28175. hash[val] = true;
  28176. });
  28177. return hash;
  28178. }
  28179. function formatValue(ctx, value, recurseTimes) {
  28180. // Provide a hook for user-specified inspect functions.
  28181. // Check that value is an object with an inspect function on it
  28182. if (ctx.customInspect &&
  28183. value &&
  28184. isFunction(value.inspect) &&
  28185. // Filter out the util module, it's inspect function is special
  28186. value.inspect !== inspect &&
  28187. // Also filter out any prototype objects using the circular check.
  28188. !(value.constructor && value.constructor.prototype === value)) {
  28189. var ret = value.inspect(recurseTimes, ctx);
  28190. if (!isString$1(ret)) {
  28191. ret = formatValue(ctx, ret, recurseTimes);
  28192. }
  28193. return ret;
  28194. }
  28195. // Primitive types cannot have properties
  28196. var primitive = formatPrimitive(ctx, value);
  28197. if (primitive) {
  28198. return primitive;
  28199. }
  28200. // Look up the keys of the object.
  28201. var keys = Object.keys(value);
  28202. var visibleKeys = arrayToHash(keys);
  28203. if (ctx.showHidden) {
  28204. keys = Object.getOwnPropertyNames(value);
  28205. }
  28206. // IE doesn't make error fields non-enumerable
  28207. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  28208. if (isError(value)
  28209. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  28210. return formatError(value);
  28211. }
  28212. // Some type of object without properties can be shortcutted.
  28213. if (keys.length === 0) {
  28214. if (isFunction(value)) {
  28215. var name = value.name ? ': ' + value.name : '';
  28216. return ctx.stylize('[Function' + name + ']', 'special');
  28217. }
  28218. if (isRegExp(value)) {
  28219. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28220. }
  28221. if (isDate(value)) {
  28222. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  28223. }
  28224. if (isError(value)) {
  28225. return formatError(value);
  28226. }
  28227. }
  28228. var base = '', array = false, braces = ['{', '}'];
  28229. // Make Array say that they are Array
  28230. if (isArray$1(value)) {
  28231. array = true;
  28232. braces = ['[', ']'];
  28233. }
  28234. // Make functions say that they are functions
  28235. if (isFunction(value)) {
  28236. var n = value.name ? ': ' + value.name : '';
  28237. base = ' [Function' + n + ']';
  28238. }
  28239. // Make RegExps say that they are RegExps
  28240. if (isRegExp(value)) {
  28241. base = ' ' + RegExp.prototype.toString.call(value);
  28242. }
  28243. // Make dates with properties first say the date
  28244. if (isDate(value)) {
  28245. base = ' ' + Date.prototype.toUTCString.call(value);
  28246. }
  28247. // Make error with message first say the error
  28248. if (isError(value)) {
  28249. base = ' ' + formatError(value);
  28250. }
  28251. if (keys.length === 0 && (!array || value.length == 0)) {
  28252. return braces[0] + base + braces[1];
  28253. }
  28254. if (recurseTimes < 0) {
  28255. if (isRegExp(value)) {
  28256. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28257. } else {
  28258. return ctx.stylize('[Object]', 'special');
  28259. }
  28260. }
  28261. ctx.seen.push(value);
  28262. var output;
  28263. if (array) {
  28264. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  28265. } else {
  28266. output = keys.map(function(key) {
  28267. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  28268. });
  28269. }
  28270. ctx.seen.pop();
  28271. return reduceToSingleString(output, base, braces);
  28272. }
  28273. function formatPrimitive(ctx, value) {
  28274. if (isUndefined(value))
  28275. return ctx.stylize('undefined', 'undefined');
  28276. if (isString$1(value)) {
  28277. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  28278. .replace(/'/g, "\\'")
  28279. .replace(/\\"/g, '"') + '\'';
  28280. return ctx.stylize(simple, 'string');
  28281. }
  28282. if (isNumber(value))
  28283. return ctx.stylize('' + value, 'number');
  28284. if (isBoolean(value))
  28285. return ctx.stylize('' + value, 'boolean');
  28286. // For some reason typeof null is "object", so special case here.
  28287. if (isNull(value))
  28288. return ctx.stylize('null', 'null');
  28289. }
  28290. function formatError(value) {
  28291. return '[' + Error.prototype.toString.call(value) + ']';
  28292. }
  28293. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  28294. var output = [];
  28295. for (var i = 0, l = value.length; i < l; ++i) {
  28296. if (hasOwnProperty$3(value, String(i))) {
  28297. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28298. String(i), true));
  28299. } else {
  28300. output.push('');
  28301. }
  28302. }
  28303. keys.forEach(function(key) {
  28304. if (!key.match(/^\d+$/)) {
  28305. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28306. key, true));
  28307. }
  28308. });
  28309. return output;
  28310. }
  28311. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  28312. var name, str, desc;
  28313. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  28314. if (desc.get) {
  28315. if (desc.set) {
  28316. str = ctx.stylize('[Getter/Setter]', 'special');
  28317. } else {
  28318. str = ctx.stylize('[Getter]', 'special');
  28319. }
  28320. } else {
  28321. if (desc.set) {
  28322. str = ctx.stylize('[Setter]', 'special');
  28323. }
  28324. }
  28325. if (!hasOwnProperty$3(visibleKeys, key)) {
  28326. name = '[' + key + ']';
  28327. }
  28328. if (!str) {
  28329. if (ctx.seen.indexOf(desc.value) < 0) {
  28330. if (isNull(recurseTimes)) {
  28331. str = formatValue(ctx, desc.value, null);
  28332. } else {
  28333. str = formatValue(ctx, desc.value, recurseTimes - 1);
  28334. }
  28335. if (str.indexOf('\n') > -1) {
  28336. if (array) {
  28337. str = str.split('\n').map(function(line) {
  28338. return ' ' + line;
  28339. }).join('\n').substr(2);
  28340. } else {
  28341. str = '\n' + str.split('\n').map(function(line) {
  28342. return ' ' + line;
  28343. }).join('\n');
  28344. }
  28345. }
  28346. } else {
  28347. str = ctx.stylize('[Circular]', 'special');
  28348. }
  28349. }
  28350. if (isUndefined(name)) {
  28351. if (array && key.match(/^\d+$/)) {
  28352. return str;
  28353. }
  28354. name = JSON.stringify('' + key);
  28355. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  28356. name = name.substr(1, name.length - 2);
  28357. name = ctx.stylize(name, 'name');
  28358. } else {
  28359. name = name.replace(/'/g, "\\'")
  28360. .replace(/\\"/g, '"')
  28361. .replace(/(^"|"$)/g, "'");
  28362. name = ctx.stylize(name, 'string');
  28363. }
  28364. }
  28365. return name + ': ' + str;
  28366. }
  28367. function reduceToSingleString(output, base, braces) {
  28368. var length = output.reduce(function(prev, cur) {
  28369. if (cur.indexOf('\n') >= 0) ;
  28370. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  28371. }, 0);
  28372. if (length > 60) {
  28373. return braces[0] +
  28374. (base === '' ? '' : base + '\n ') +
  28375. ' ' +
  28376. output.join(',\n ') +
  28377. ' ' +
  28378. braces[1];
  28379. }
  28380. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  28381. }
  28382. // NOTE: These type checking functions intentionally don't use `instanceof`
  28383. // because it is fragile and can be easily faked with `Object.create()`.
  28384. function isArray$1(ar) {
  28385. return Array.isArray(ar);
  28386. }
  28387. function isBoolean(arg) {
  28388. return typeof arg === 'boolean';
  28389. }
  28390. function isNull(arg) {
  28391. return arg === null;
  28392. }
  28393. function isNullOrUndefined(arg) {
  28394. return arg == null;
  28395. }
  28396. function isNumber(arg) {
  28397. return typeof arg === 'number';
  28398. }
  28399. function isString$1(arg) {
  28400. return typeof arg === 'string';
  28401. }
  28402. function isSymbol(arg) {
  28403. return typeof arg === 'symbol';
  28404. }
  28405. function isUndefined(arg) {
  28406. return arg === void 0;
  28407. }
  28408. function isRegExp(re) {
  28409. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  28410. }
  28411. function isObject$1(arg) {
  28412. return typeof arg === 'object' && arg !== null;
  28413. }
  28414. function isDate(d) {
  28415. return isObject$1(d) && objectToString(d) === '[object Date]';
  28416. }
  28417. function isError(e) {
  28418. return isObject$1(e) &&
  28419. (objectToString(e) === '[object Error]' || e instanceof Error);
  28420. }
  28421. function isFunction(arg) {
  28422. return typeof arg === 'function';
  28423. }
  28424. function isPrimitive(arg) {
  28425. return arg === null ||
  28426. typeof arg === 'boolean' ||
  28427. typeof arg === 'number' ||
  28428. typeof arg === 'string' ||
  28429. typeof arg === 'symbol' || // ES6 symbol
  28430. typeof arg === 'undefined';
  28431. }
  28432. function isBuffer(maybeBuf) {
  28433. return Buffer$1.isBuffer(maybeBuf);
  28434. }
  28435. function objectToString(o) {
  28436. return Object.prototype.toString.call(o);
  28437. }
  28438. function pad(n) {
  28439. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  28440. }
  28441. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  28442. 'Oct', 'Nov', 'Dec'];
  28443. // 26 Feb 16:19:34
  28444. function timestamp() {
  28445. var d = new Date();
  28446. var time = [pad(d.getHours()),
  28447. pad(d.getMinutes()),
  28448. pad(d.getSeconds())].join(':');
  28449. return [d.getDate(), months[d.getMonth()], time].join(' ');
  28450. }
  28451. // log is just a thin wrapper to console.log that prepends a timestamp
  28452. function log() {
  28453. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  28454. }
  28455. function _extend(origin, add) {
  28456. // Don't do anything if add isn't an object
  28457. if (!add || !isObject$1(add)) return origin;
  28458. var keys = Object.keys(add);
  28459. var i = keys.length;
  28460. while (i--) {
  28461. origin[keys[i]] = add[keys[i]];
  28462. }
  28463. return origin;
  28464. }
  28465. function hasOwnProperty$3(obj, prop) {
  28466. return Object.prototype.hasOwnProperty.call(obj, prop);
  28467. }
  28468. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  28469. function promisify(original) {
  28470. if (typeof original !== 'function')
  28471. throw new TypeError('The "original" argument must be of type Function');
  28472. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  28473. var fn = original[kCustomPromisifiedSymbol];
  28474. if (typeof fn !== 'function') {
  28475. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  28476. }
  28477. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28478. value: fn, enumerable: false, writable: false, configurable: true
  28479. });
  28480. return fn;
  28481. }
  28482. function fn() {
  28483. var promiseResolve, promiseReject;
  28484. var promise = new Promise(function (resolve, reject) {
  28485. promiseResolve = resolve;
  28486. promiseReject = reject;
  28487. });
  28488. var args = [];
  28489. for (var i = 0; i < arguments.length; i++) {
  28490. args.push(arguments[i]);
  28491. }
  28492. args.push(function (err, value) {
  28493. if (err) {
  28494. promiseReject(err);
  28495. } else {
  28496. promiseResolve(value);
  28497. }
  28498. });
  28499. try {
  28500. original.apply(this, args);
  28501. } catch (err) {
  28502. promiseReject(err);
  28503. }
  28504. return promise;
  28505. }
  28506. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  28507. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28508. value: fn, enumerable: false, writable: false, configurable: true
  28509. });
  28510. return Object.defineProperties(
  28511. fn,
  28512. getOwnPropertyDescriptors(original)
  28513. );
  28514. }
  28515. promisify.custom = kCustomPromisifiedSymbol;
  28516. function callbackifyOnRejected(reason, cb) {
  28517. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  28518. // Because `null` is a special error value in callbacks which means "no error
  28519. // occurred", we error-wrap so the callback consumer can distinguish between
  28520. // "the promise rejected with null" or "the promise fulfilled with undefined".
  28521. if (!reason) {
  28522. var newReason = new Error('Promise was rejected with a falsy value');
  28523. newReason.reason = reason;
  28524. reason = newReason;
  28525. }
  28526. return cb(reason);
  28527. }
  28528. function callbackify(original) {
  28529. if (typeof original !== 'function') {
  28530. throw new TypeError('The "original" argument must be of type Function');
  28531. }
  28532. // We DO NOT return the promise as it gives the user a false sense that
  28533. // the promise is actually somehow related to the callback's execution
  28534. // and that the callback throwing will reject the promise.
  28535. function callbackified() {
  28536. var args = [];
  28537. for (var i = 0; i < arguments.length; i++) {
  28538. args.push(arguments[i]);
  28539. }
  28540. var maybeCb = args.pop();
  28541. if (typeof maybeCb !== 'function') {
  28542. throw new TypeError('The last argument must be of type Function');
  28543. }
  28544. var self = this;
  28545. var cb = function() {
  28546. return maybeCb.apply(self, arguments);
  28547. };
  28548. // In true node style we process the callback on `nextTick` with all the
  28549. // implications (stack, `uncaughtException`, `async_hooks`)
  28550. original.apply(this, args)
  28551. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  28552. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  28553. }
  28554. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  28555. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  28556. return callbackified;
  28557. }
  28558. var _polyfillNode_util = {
  28559. inherits: inherits$1,
  28560. _extend: _extend,
  28561. log: log,
  28562. isBuffer: isBuffer,
  28563. isPrimitive: isPrimitive,
  28564. isFunction: isFunction,
  28565. isError: isError,
  28566. isDate: isDate,
  28567. isObject: isObject$1,
  28568. isRegExp: isRegExp,
  28569. isUndefined: isUndefined,
  28570. isSymbol: isSymbol,
  28571. isString: isString$1,
  28572. isNumber: isNumber,
  28573. isNullOrUndefined: isNullOrUndefined,
  28574. isNull: isNull,
  28575. isBoolean: isBoolean,
  28576. isArray: isArray$1,
  28577. inspect: inspect,
  28578. deprecate: deprecate,
  28579. format: format$1,
  28580. debuglog: debuglog,
  28581. promisify: promisify,
  28582. callbackify: callbackify,
  28583. };
  28584. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  28585. __proto__: null,
  28586. _extend: _extend,
  28587. callbackify: callbackify,
  28588. debuglog: debuglog,
  28589. default: _polyfillNode_util,
  28590. deprecate: deprecate,
  28591. format: format$1,
  28592. inherits: inherits$1,
  28593. inspect: inspect,
  28594. isArray: isArray$1,
  28595. isBoolean: isBoolean,
  28596. isBuffer: isBuffer,
  28597. isDate: isDate,
  28598. isError: isError,
  28599. isFunction: isFunction,
  28600. isNull: isNull,
  28601. isNullOrUndefined: isNullOrUndefined,
  28602. isNumber: isNumber,
  28603. isObject: isObject$1,
  28604. isPrimitive: isPrimitive,
  28605. isRegExp: isRegExp,
  28606. isString: isString$1,
  28607. isSymbol: isSymbol,
  28608. isUndefined: isUndefined,
  28609. log: log,
  28610. promisify: promisify
  28611. });
  28612. // Copyright Joyent, Inc. and other Node contributors.
  28613. //
  28614. // Permission is hereby granted, free of charge, to any person obtaining a
  28615. // copy of this software and associated documentation files (the
  28616. // "Software"), to deal in the Software without restriction, including
  28617. // without limitation the rights to use, copy, modify, merge, publish,
  28618. // distribute, sublicense, and/or sell copies of the Software, and to permit
  28619. // persons to whom the Software is furnished to do so, subject to the
  28620. // following conditions:
  28621. //
  28622. // The above copyright notice and this permission notice shall be included
  28623. // in all copies or substantial portions of the Software.
  28624. //
  28625. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  28626. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28627. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  28628. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  28629. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28630. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  28631. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  28632. // If obj.hasOwnProperty has been overridden, then calling
  28633. // obj.hasOwnProperty(prop) will break.
  28634. // See: https://github.com/joyent/node/issues/1707
  28635. function hasOwnProperty$2(obj, prop) {
  28636. return Object.prototype.hasOwnProperty.call(obj, prop);
  28637. }
  28638. var isArray = Array.isArray || function (xs) {
  28639. return Object.prototype.toString.call(xs) === '[object Array]';
  28640. };
  28641. function stringifyPrimitive(v) {
  28642. switch (typeof v) {
  28643. case 'string':
  28644. return v;
  28645. case 'boolean':
  28646. return v ? 'true' : 'false';
  28647. case 'number':
  28648. return isFinite(v) ? v : '';
  28649. default:
  28650. return '';
  28651. }
  28652. }
  28653. function stringify$5 (obj, sep, eq, name) {
  28654. sep = sep || '&';
  28655. eq = eq || '=';
  28656. if (obj === null) {
  28657. obj = undefined;
  28658. }
  28659. if (typeof obj === 'object') {
  28660. return map(objectKeys(obj), function(k) {
  28661. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  28662. if (isArray(obj[k])) {
  28663. return map(obj[k], function(v) {
  28664. return ks + encodeURIComponent(stringifyPrimitive(v));
  28665. }).join(sep);
  28666. } else {
  28667. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  28668. }
  28669. }).join(sep);
  28670. }
  28671. if (!name) return '';
  28672. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  28673. encodeURIComponent(stringifyPrimitive(obj));
  28674. }
  28675. function map (xs, f) {
  28676. if (xs.map) return xs.map(f);
  28677. var res = [];
  28678. for (var i = 0; i < xs.length; i++) {
  28679. res.push(f(xs[i], i));
  28680. }
  28681. return res;
  28682. }
  28683. var objectKeys = Object.keys || function (obj) {
  28684. var res = [];
  28685. for (var key in obj) {
  28686. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  28687. }
  28688. return res;
  28689. };
  28690. function parse$6(qs, sep, eq, options) {
  28691. sep = sep || '&';
  28692. eq = eq || '=';
  28693. var obj = {};
  28694. if (typeof qs !== 'string' || qs.length === 0) {
  28695. return obj;
  28696. }
  28697. var regexp = /\+/g;
  28698. qs = qs.split(sep);
  28699. var maxKeys = 1000;
  28700. if (options && typeof options.maxKeys === 'number') {
  28701. maxKeys = options.maxKeys;
  28702. }
  28703. var len = qs.length;
  28704. // maxKeys <= 0 means that we should not limit keys count
  28705. if (maxKeys > 0 && len > maxKeys) {
  28706. len = maxKeys;
  28707. }
  28708. for (var i = 0; i < len; ++i) {
  28709. var x = qs[i].replace(regexp, '%20'),
  28710. idx = x.indexOf(eq),
  28711. kstr, vstr, k, v;
  28712. if (idx >= 0) {
  28713. kstr = x.substr(0, idx);
  28714. vstr = x.substr(idx + 1);
  28715. } else {
  28716. kstr = x;
  28717. vstr = '';
  28718. }
  28719. k = decodeURIComponent(kstr);
  28720. v = decodeURIComponent(vstr);
  28721. if (!hasOwnProperty$2(obj, k)) {
  28722. obj[k] = v;
  28723. } else if (isArray(obj[k])) {
  28724. obj[k].push(v);
  28725. } else {
  28726. obj[k] = [obj[k], v];
  28727. }
  28728. }
  28729. return obj;
  28730. }
  28731. // WHATWG API
  28732. const URL$1 = global$1.URL;
  28733. const URLSearchParams = global$1.URLSearchParams;
  28734. var _polyfillNode_url = {
  28735. parse: urlParse,
  28736. resolve: urlResolve,
  28737. resolveObject: urlResolveObject,
  28738. fileURLToPath: urlFileURLToPath,
  28739. format: urlFormat,
  28740. Url: Url,
  28741. // WHATWG API
  28742. URL: URL$1,
  28743. URLSearchParams,
  28744. };
  28745. function Url() {
  28746. this.protocol = null;
  28747. this.slashes = null;
  28748. this.auth = null;
  28749. this.host = null;
  28750. this.port = null;
  28751. this.hostname = null;
  28752. this.hash = null;
  28753. this.search = null;
  28754. this.query = null;
  28755. this.pathname = null;
  28756. this.path = null;
  28757. this.href = null;
  28758. }
  28759. // Reference: RFC 3986, RFC 1808, RFC 2396
  28760. // define these here so at least they only have to be
  28761. // compiled once on the first module load.
  28762. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  28763. portPattern = /:[0-9]*$/,
  28764. // Special case for a simple path URL
  28765. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  28766. // RFC 2396: characters reserved for delimiting URLs.
  28767. // We actually just auto-escape these.
  28768. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  28769. // RFC 2396: characters not allowed for various reasons.
  28770. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  28771. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  28772. autoEscape = ['\''].concat(unwise),
  28773. // Characters that are never ever allowed in a hostname.
  28774. // Note that any invalid chars are also handled, but these
  28775. // are the ones that are *expected* to be seen, so we fast-path
  28776. // them.
  28777. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  28778. hostEndingChars = ['/', '?', '#'],
  28779. hostnameMaxLen = 255,
  28780. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  28781. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  28782. // protocols that can allow "unsafe" and "unwise" chars.
  28783. unsafeProtocol = {
  28784. 'javascript': true,
  28785. 'javascript:': true
  28786. },
  28787. // protocols that never have a hostname.
  28788. hostlessProtocol = {
  28789. 'javascript': true,
  28790. 'javascript:': true
  28791. },
  28792. // protocols that always contain a // bit.
  28793. slashedProtocol = {
  28794. 'http': true,
  28795. 'https': true,
  28796. 'ftp': true,
  28797. 'gopher': true,
  28798. 'file': true,
  28799. 'http:': true,
  28800. 'https:': true,
  28801. 'ftp:': true,
  28802. 'gopher:': true,
  28803. 'file:': true
  28804. };
  28805. function urlParse(url, parseQueryString, slashesDenoteHost) {
  28806. if (url && isObject$1(url) && url instanceof Url) return url;
  28807. var u = new Url;
  28808. u.parse(url, parseQueryString, slashesDenoteHost);
  28809. return u;
  28810. }
  28811. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  28812. return parse$5(this, url, parseQueryString, slashesDenoteHost);
  28813. };
  28814. function parse$5(self, url, parseQueryString, slashesDenoteHost) {
  28815. if (!isString$1(url)) {
  28816. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  28817. }
  28818. // Copy chrome, IE, opera backslash-handling behavior.
  28819. // Back slashes before the query string get converted to forward slashes
  28820. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  28821. var queryIndex = url.indexOf('?'),
  28822. splitter =
  28823. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  28824. uSplit = url.split(splitter),
  28825. slashRegex = /\\/g;
  28826. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  28827. url = uSplit.join(splitter);
  28828. var rest = url;
  28829. // trim before proceeding.
  28830. // This is to support parse stuff like " http://foo.com \n"
  28831. rest = rest.trim();
  28832. if (!slashesDenoteHost && url.split('#').length === 1) {
  28833. // Try fast path regexp
  28834. var simplePath = simplePathPattern.exec(rest);
  28835. if (simplePath) {
  28836. self.path = rest;
  28837. self.href = rest;
  28838. self.pathname = simplePath[1];
  28839. if (simplePath[2]) {
  28840. self.search = simplePath[2];
  28841. if (parseQueryString) {
  28842. self.query = parse$6(self.search.substr(1));
  28843. } else {
  28844. self.query = self.search.substr(1);
  28845. }
  28846. } else if (parseQueryString) {
  28847. self.search = '';
  28848. self.query = {};
  28849. }
  28850. return self;
  28851. }
  28852. }
  28853. var proto = protocolPattern.exec(rest);
  28854. if (proto) {
  28855. proto = proto[0];
  28856. var lowerProto = proto.toLowerCase();
  28857. self.protocol = lowerProto;
  28858. rest = rest.substr(proto.length);
  28859. }
  28860. // figure out if it's got a host
  28861. // user@server is *always* interpreted as a hostname, and url
  28862. // resolution will treat //foo/bar as host=foo,path=bar because that's
  28863. // how the browser resolves relative URLs.
  28864. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  28865. var slashes = rest.substr(0, 2) === '//';
  28866. if (slashes && !(proto && hostlessProtocol[proto])) {
  28867. rest = rest.substr(2);
  28868. self.slashes = true;
  28869. }
  28870. }
  28871. var i, hec, l, p;
  28872. if (!hostlessProtocol[proto] &&
  28873. (slashes || (proto && !slashedProtocol[proto]))) {
  28874. // there's a hostname.
  28875. // the first instance of /, ?, ;, or # ends the host.
  28876. //
  28877. // If there is an @ in the hostname, then non-host chars *are* allowed
  28878. // to the left of the last @ sign, unless some host-ending character
  28879. // comes *before* the @-sign.
  28880. // URLs are obnoxious.
  28881. //
  28882. // ex:
  28883. // http://a@b@c/ => user:a@b host:c
  28884. // http://a@b?@c => user:a host:c path:/?@c
  28885. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  28886. // Review our test case against browsers more comprehensively.
  28887. // find the first instance of any hostEndingChars
  28888. var hostEnd = -1;
  28889. for (i = 0; i < hostEndingChars.length; i++) {
  28890. hec = rest.indexOf(hostEndingChars[i]);
  28891. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28892. hostEnd = hec;
  28893. }
  28894. // at this point, either we have an explicit point where the
  28895. // auth portion cannot go past, or the last @ char is the decider.
  28896. var auth, atSign;
  28897. if (hostEnd === -1) {
  28898. // atSign can be anywhere.
  28899. atSign = rest.lastIndexOf('@');
  28900. } else {
  28901. // atSign must be in auth portion.
  28902. // http://a@b/c@d => host:b auth:a path:/c@d
  28903. atSign = rest.lastIndexOf('@', hostEnd);
  28904. }
  28905. // Now we have a portion which is definitely the auth.
  28906. // Pull that off.
  28907. if (atSign !== -1) {
  28908. auth = rest.slice(0, atSign);
  28909. rest = rest.slice(atSign + 1);
  28910. self.auth = decodeURIComponent(auth);
  28911. }
  28912. // the host is the remaining to the left of the first non-host char
  28913. hostEnd = -1;
  28914. for (i = 0; i < nonHostChars.length; i++) {
  28915. hec = rest.indexOf(nonHostChars[i]);
  28916. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28917. hostEnd = hec;
  28918. }
  28919. // if we still have not hit it, then the entire thing is a host.
  28920. if (hostEnd === -1)
  28921. hostEnd = rest.length;
  28922. self.host = rest.slice(0, hostEnd);
  28923. rest = rest.slice(hostEnd);
  28924. // pull out port.
  28925. parseHost(self);
  28926. // we've indicated that there is a hostname,
  28927. // so even if it's empty, it has to be present.
  28928. self.hostname = self.hostname || '';
  28929. // if hostname begins with [ and ends with ]
  28930. // assume that it's an IPv6 address.
  28931. var ipv6Hostname = self.hostname[0] === '[' &&
  28932. self.hostname[self.hostname.length - 1] === ']';
  28933. // validate a little.
  28934. if (!ipv6Hostname) {
  28935. var hostparts = self.hostname.split(/\./);
  28936. for (i = 0, l = hostparts.length; i < l; i++) {
  28937. var part = hostparts[i];
  28938. if (!part) continue;
  28939. if (!part.match(hostnamePartPattern)) {
  28940. var newpart = '';
  28941. for (var j = 0, k = part.length; j < k; j++) {
  28942. if (part.charCodeAt(j) > 127) {
  28943. // we replace non-ASCII char with a temporary placeholder
  28944. // we need this to make sure size of hostname is not
  28945. // broken by replacing non-ASCII by nothing
  28946. newpart += 'x';
  28947. } else {
  28948. newpart += part[j];
  28949. }
  28950. }
  28951. // we test again with ASCII char only
  28952. if (!newpart.match(hostnamePartPattern)) {
  28953. var validParts = hostparts.slice(0, i);
  28954. var notHost = hostparts.slice(i + 1);
  28955. var bit = part.match(hostnamePartStart);
  28956. if (bit) {
  28957. validParts.push(bit[1]);
  28958. notHost.unshift(bit[2]);
  28959. }
  28960. if (notHost.length) {
  28961. rest = '/' + notHost.join('.') + rest;
  28962. }
  28963. self.hostname = validParts.join('.');
  28964. break;
  28965. }
  28966. }
  28967. }
  28968. }
  28969. if (self.hostname.length > hostnameMaxLen) {
  28970. self.hostname = '';
  28971. } else {
  28972. // hostnames are always lower case.
  28973. self.hostname = self.hostname.toLowerCase();
  28974. }
  28975. if (!ipv6Hostname) {
  28976. // IDNA Support: Returns a punycoded representation of "domain".
  28977. // It only converts parts of the domain name that
  28978. // have non-ASCII characters, i.e. it doesn't matter if
  28979. // you call it with a domain that already is ASCII-only.
  28980. self.hostname = toASCII(self.hostname);
  28981. }
  28982. p = self.port ? ':' + self.port : '';
  28983. var h = self.hostname || '';
  28984. self.host = h + p;
  28985. self.href += self.host;
  28986. // strip [ and ] from the hostname
  28987. // the host field still retains them, though
  28988. if (ipv6Hostname) {
  28989. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  28990. if (rest[0] !== '/') {
  28991. rest = '/' + rest;
  28992. }
  28993. }
  28994. }
  28995. // now rest is set to the post-host stuff.
  28996. // chop off any delim chars.
  28997. if (!unsafeProtocol[lowerProto]) {
  28998. // First, make 100% sure that any "autoEscape" chars get
  28999. // escaped, even if encodeURIComponent doesn't think they
  29000. // need to be.
  29001. for (i = 0, l = autoEscape.length; i < l; i++) {
  29002. var ae = autoEscape[i];
  29003. if (rest.indexOf(ae) === -1)
  29004. continue;
  29005. var esc = encodeURIComponent(ae);
  29006. if (esc === ae) {
  29007. esc = escape(ae);
  29008. }
  29009. rest = rest.split(ae).join(esc);
  29010. }
  29011. }
  29012. // chop off from the tail first.
  29013. var hash = rest.indexOf('#');
  29014. if (hash !== -1) {
  29015. // got a fragment string.
  29016. self.hash = rest.substr(hash);
  29017. rest = rest.slice(0, hash);
  29018. }
  29019. var qm = rest.indexOf('?');
  29020. if (qm !== -1) {
  29021. self.search = rest.substr(qm);
  29022. self.query = rest.substr(qm + 1);
  29023. if (parseQueryString) {
  29024. self.query = parse$6(self.query);
  29025. }
  29026. rest = rest.slice(0, qm);
  29027. } else if (parseQueryString) {
  29028. // no query string, but parseQueryString still requested
  29029. self.search = '';
  29030. self.query = {};
  29031. }
  29032. if (rest) self.pathname = rest;
  29033. if (slashedProtocol[lowerProto] &&
  29034. self.hostname && !self.pathname) {
  29035. self.pathname = '/';
  29036. }
  29037. //to support http.request
  29038. if (self.pathname || self.search) {
  29039. p = self.pathname || '';
  29040. var s = self.search || '';
  29041. self.path = p + s;
  29042. }
  29043. // finally, reconstruct the href based on what has been validated.
  29044. self.href = format(self);
  29045. return self;
  29046. }
  29047. function urlFileURLToPath(path) {
  29048. if (typeof path === 'string')
  29049. path = new Url().parse(path);
  29050. else if (!(path instanceof Url))
  29051. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  29052. if (path.protocol !== 'file:')
  29053. throw new TypeError('The URL must be of scheme file');
  29054. return getPathFromURLPosix(path);
  29055. }
  29056. function getPathFromURLPosix(url) {
  29057. const pathname = url.pathname;
  29058. for (let n = 0; n < pathname.length; n++) {
  29059. if (pathname[n] === '%') {
  29060. const third = pathname.codePointAt(n + 2) | 0x20;
  29061. if (pathname[n + 1] === '2' && third === 102) {
  29062. throw new TypeError(
  29063. 'must not include encoded / characters'
  29064. );
  29065. }
  29066. }
  29067. }
  29068. return decodeURIComponent(pathname);
  29069. }
  29070. // format a parsed object into a url string
  29071. function urlFormat(obj) {
  29072. // ensure it's an object, and not a string url.
  29073. // If it's an obj, this is a no-op.
  29074. // this way, you can call url_format() on strings
  29075. // to clean up potentially wonky urls.
  29076. if (isString$1(obj)) obj = parse$5({}, obj);
  29077. return format(obj);
  29078. }
  29079. function format(self) {
  29080. var auth = self.auth || '';
  29081. if (auth) {
  29082. auth = encodeURIComponent(auth);
  29083. auth = auth.replace(/%3A/i, ':');
  29084. auth += '@';
  29085. }
  29086. var protocol = self.protocol || '',
  29087. pathname = self.pathname || '',
  29088. hash = self.hash || '',
  29089. host = false,
  29090. query = '';
  29091. if (self.host) {
  29092. host = auth + self.host;
  29093. } else if (self.hostname) {
  29094. host = auth + (self.hostname.indexOf(':') === -1 ?
  29095. self.hostname :
  29096. '[' + this.hostname + ']');
  29097. if (self.port) {
  29098. host += ':' + self.port;
  29099. }
  29100. }
  29101. if (self.query &&
  29102. isObject$1(self.query) &&
  29103. Object.keys(self.query).length) {
  29104. query = stringify$5(self.query);
  29105. }
  29106. var search = self.search || (query && ('?' + query)) || '';
  29107. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  29108. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  29109. // unless they had them to begin with.
  29110. if (self.slashes ||
  29111. (!protocol || slashedProtocol[protocol]) && host !== false) {
  29112. host = '//' + (host || '');
  29113. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  29114. } else if (!host) {
  29115. host = '';
  29116. }
  29117. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  29118. if (search && search.charAt(0) !== '?') search = '?' + search;
  29119. pathname = pathname.replace(/[?#]/g, function(match) {
  29120. return encodeURIComponent(match);
  29121. });
  29122. search = search.replace('#', '%23');
  29123. return protocol + host + pathname + search + hash;
  29124. }
  29125. Url.prototype.format = function() {
  29126. return format(this);
  29127. };
  29128. function urlResolve(source, relative) {
  29129. return urlParse(source, false, true).resolve(relative);
  29130. }
  29131. Url.prototype.resolve = function(relative) {
  29132. return this.resolveObject(urlParse(relative, false, true)).format();
  29133. };
  29134. function urlResolveObject(source, relative) {
  29135. if (!source) return relative;
  29136. return urlParse(source, false, true).resolveObject(relative);
  29137. }
  29138. Url.prototype.resolveObject = function(relative) {
  29139. if (isString$1(relative)) {
  29140. var rel = new Url();
  29141. rel.parse(relative, false, true);
  29142. relative = rel;
  29143. }
  29144. var result = new Url();
  29145. var tkeys = Object.keys(this);
  29146. for (var tk = 0; tk < tkeys.length; tk++) {
  29147. var tkey = tkeys[tk];
  29148. result[tkey] = this[tkey];
  29149. }
  29150. // hash is always overridden, no matter what.
  29151. // even href="" will remove it.
  29152. result.hash = relative.hash;
  29153. // if the relative url is empty, then there's nothing left to do here.
  29154. if (relative.href === '') {
  29155. result.href = result.format();
  29156. return result;
  29157. }
  29158. // hrefs like //foo/bar always cut to the protocol.
  29159. if (relative.slashes && !relative.protocol) {
  29160. // take everything except the protocol from relative
  29161. var rkeys = Object.keys(relative);
  29162. for (var rk = 0; rk < rkeys.length; rk++) {
  29163. var rkey = rkeys[rk];
  29164. if (rkey !== 'protocol')
  29165. result[rkey] = relative[rkey];
  29166. }
  29167. //urlParse appends trailing / to urls like http://www.example.com
  29168. if (slashedProtocol[result.protocol] &&
  29169. result.hostname && !result.pathname) {
  29170. result.path = result.pathname = '/';
  29171. }
  29172. result.href = result.format();
  29173. return result;
  29174. }
  29175. var relPath;
  29176. if (relative.protocol && relative.protocol !== result.protocol) {
  29177. // if it's a known url protocol, then changing
  29178. // the protocol does weird things
  29179. // first, if it's not file:, then we MUST have a host,
  29180. // and if there was a path
  29181. // to begin with, then we MUST have a path.
  29182. // if it is file:, then the host is dropped,
  29183. // because that's known to be hostless.
  29184. // anything else is assumed to be absolute.
  29185. if (!slashedProtocol[relative.protocol]) {
  29186. var keys = Object.keys(relative);
  29187. for (var v = 0; v < keys.length; v++) {
  29188. var k = keys[v];
  29189. result[k] = relative[k];
  29190. }
  29191. result.href = result.format();
  29192. return result;
  29193. }
  29194. result.protocol = relative.protocol;
  29195. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  29196. relPath = (relative.pathname || '').split('/');
  29197. while (relPath.length && !(relative.host = relPath.shift()));
  29198. if (!relative.host) relative.host = '';
  29199. if (!relative.hostname) relative.hostname = '';
  29200. if (relPath[0] !== '') relPath.unshift('');
  29201. if (relPath.length < 2) relPath.unshift('');
  29202. result.pathname = relPath.join('/');
  29203. } else {
  29204. result.pathname = relative.pathname;
  29205. }
  29206. result.search = relative.search;
  29207. result.query = relative.query;
  29208. result.host = relative.host || '';
  29209. result.auth = relative.auth;
  29210. result.hostname = relative.hostname || relative.host;
  29211. result.port = relative.port;
  29212. // to support http.request
  29213. if (result.pathname || result.search) {
  29214. var p = result.pathname || '';
  29215. var s = result.search || '';
  29216. result.path = p + s;
  29217. }
  29218. result.slashes = result.slashes || relative.slashes;
  29219. result.href = result.format();
  29220. return result;
  29221. }
  29222. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  29223. isRelAbs = (
  29224. relative.host ||
  29225. relative.pathname && relative.pathname.charAt(0) === '/'
  29226. ),
  29227. mustEndAbs = (isRelAbs || isSourceAbs ||
  29228. (result.host && relative.pathname)),
  29229. removeAllDots = mustEndAbs,
  29230. srcPath = result.pathname && result.pathname.split('/') || [],
  29231. psychotic = result.protocol && !slashedProtocol[result.protocol];
  29232. relPath = relative.pathname && relative.pathname.split('/') || [];
  29233. // if the url is a non-slashed url, then relative
  29234. // links like ../.. should be able
  29235. // to crawl up to the hostname, as well. This is strange.
  29236. // result.protocol has already been set by now.
  29237. // Later on, put the first path part into the host field.
  29238. if (psychotic) {
  29239. result.hostname = '';
  29240. result.port = null;
  29241. if (result.host) {
  29242. if (srcPath[0] === '') srcPath[0] = result.host;
  29243. else srcPath.unshift(result.host);
  29244. }
  29245. result.host = '';
  29246. if (relative.protocol) {
  29247. relative.hostname = null;
  29248. relative.port = null;
  29249. if (relative.host) {
  29250. if (relPath[0] === '') relPath[0] = relative.host;
  29251. else relPath.unshift(relative.host);
  29252. }
  29253. relative.host = null;
  29254. }
  29255. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  29256. }
  29257. var authInHost;
  29258. if (isRelAbs) {
  29259. // it's absolute.
  29260. result.host = (relative.host || relative.host === '') ?
  29261. relative.host : result.host;
  29262. result.hostname = (relative.hostname || relative.hostname === '') ?
  29263. relative.hostname : result.hostname;
  29264. result.search = relative.search;
  29265. result.query = relative.query;
  29266. srcPath = relPath;
  29267. // fall through to the dot-handling below.
  29268. } else if (relPath.length) {
  29269. // it's relative
  29270. // throw away the existing file, and take the new path instead.
  29271. if (!srcPath) srcPath = [];
  29272. srcPath.pop();
  29273. srcPath = srcPath.concat(relPath);
  29274. result.search = relative.search;
  29275. result.query = relative.query;
  29276. } else if (!isNullOrUndefined(relative.search)) {
  29277. // just pull out the search.
  29278. // like href='?foo'.
  29279. // Put this after the other two cases because it simplifies the booleans
  29280. if (psychotic) {
  29281. result.hostname = result.host = srcPath.shift();
  29282. //occationaly the auth can get stuck only in host
  29283. //this especially happens in cases like
  29284. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29285. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29286. result.host.split('@') : false;
  29287. if (authInHost) {
  29288. result.auth = authInHost.shift();
  29289. result.host = result.hostname = authInHost.shift();
  29290. }
  29291. }
  29292. result.search = relative.search;
  29293. result.query = relative.query;
  29294. //to support http.request
  29295. if (!isNull(result.pathname) || !isNull(result.search)) {
  29296. result.path = (result.pathname ? result.pathname : '') +
  29297. (result.search ? result.search : '');
  29298. }
  29299. result.href = result.format();
  29300. return result;
  29301. }
  29302. if (!srcPath.length) {
  29303. // no path at all. easy.
  29304. // we've already handled the other stuff above.
  29305. result.pathname = null;
  29306. //to support http.request
  29307. if (result.search) {
  29308. result.path = '/' + result.search;
  29309. } else {
  29310. result.path = null;
  29311. }
  29312. result.href = result.format();
  29313. return result;
  29314. }
  29315. // if a url ENDs in . or .., then it must get a trailing slash.
  29316. // however, if it ends in anything else non-slashy,
  29317. // then it must NOT get a trailing slash.
  29318. var last = srcPath.slice(-1)[0];
  29319. var hasTrailingSlash = (
  29320. (result.host || relative.host || srcPath.length > 1) &&
  29321. (last === '.' || last === '..') || last === '');
  29322. // strip single dots, resolve double dots to parent dir
  29323. // if the path tries to go above the root, `up` ends up > 0
  29324. var up = 0;
  29325. for (var i = srcPath.length; i >= 0; i--) {
  29326. last = srcPath[i];
  29327. if (last === '.') {
  29328. srcPath.splice(i, 1);
  29329. } else if (last === '..') {
  29330. srcPath.splice(i, 1);
  29331. up++;
  29332. } else if (up) {
  29333. srcPath.splice(i, 1);
  29334. up--;
  29335. }
  29336. }
  29337. // if the path is allowed to go above the root, restore leading ..s
  29338. if (!mustEndAbs && !removeAllDots) {
  29339. for (; up--; up) {
  29340. srcPath.unshift('..');
  29341. }
  29342. }
  29343. if (mustEndAbs && srcPath[0] !== '' &&
  29344. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  29345. srcPath.unshift('');
  29346. }
  29347. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  29348. srcPath.push('');
  29349. }
  29350. var isAbsolute = srcPath[0] === '' ||
  29351. (srcPath[0] && srcPath[0].charAt(0) === '/');
  29352. // put the host back
  29353. if (psychotic) {
  29354. result.hostname = result.host = isAbsolute ? '' :
  29355. srcPath.length ? srcPath.shift() : '';
  29356. //occationaly the auth can get stuck only in host
  29357. //this especially happens in cases like
  29358. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29359. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29360. result.host.split('@') : false;
  29361. if (authInHost) {
  29362. result.auth = authInHost.shift();
  29363. result.host = result.hostname = authInHost.shift();
  29364. }
  29365. }
  29366. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  29367. if (mustEndAbs && !isAbsolute) {
  29368. srcPath.unshift('');
  29369. }
  29370. if (!srcPath.length) {
  29371. result.pathname = null;
  29372. result.path = null;
  29373. } else {
  29374. result.pathname = srcPath.join('/');
  29375. }
  29376. //to support request.http
  29377. if (!isNull(result.pathname) || !isNull(result.search)) {
  29378. result.path = (result.pathname ? result.pathname : '') +
  29379. (result.search ? result.search : '');
  29380. }
  29381. result.auth = relative.auth || result.auth;
  29382. result.slashes = result.slashes || relative.slashes;
  29383. result.href = result.format();
  29384. return result;
  29385. };
  29386. Url.prototype.parseHost = function() {
  29387. return parseHost(this);
  29388. };
  29389. function parseHost(self) {
  29390. var host = self.host;
  29391. var port = portPattern.exec(host);
  29392. if (port) {
  29393. port = port[0];
  29394. if (port !== ':') {
  29395. self.port = port.substr(1);
  29396. }
  29397. host = host.substr(0, host.length - port.length);
  29398. }
  29399. if (host) self.hostname = host;
  29400. }
  29401. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  29402. __proto__: null,
  29403. URL: URL$1,
  29404. URLSearchParams: URLSearchParams,
  29405. Url: Url,
  29406. default: _polyfillNode_url,
  29407. fileURLToPath: urlFileURLToPath,
  29408. format: urlFormat,
  29409. parse: urlParse,
  29410. resolve: urlResolve,
  29411. resolveObject: urlResolveObject
  29412. });
  29413. function isRelativeUrl(url) {
  29414. const firstChar = url.charAt(0);
  29415. return firstChar === "." || firstChar === "~" || firstChar === "@";
  29416. }
  29417. const externalRE = /^(https?:)?\/\//;
  29418. function isExternalUrl(url) {
  29419. return externalRE.test(url);
  29420. }
  29421. const dataUrlRE = /^\s*data:/i;
  29422. function isDataUrl(url) {
  29423. return dataUrlRE.test(url);
  29424. }
  29425. function parseUrl(url) {
  29426. const firstChar = url.charAt(0);
  29427. if (firstChar === "~") {
  29428. const secondChar = url.charAt(1);
  29429. url = url.slice(secondChar === "/" ? 2 : 1);
  29430. }
  29431. return parseUriParts(url);
  29432. }
  29433. function parseUriParts(urlString) {
  29434. return urlParse(isString$2(urlString) ? urlString : "", false, true);
  29435. }
  29436. var __defProp$9 = Object.defineProperty;
  29437. var __defProps$8 = Object.defineProperties;
  29438. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  29439. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  29440. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  29441. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  29442. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  29443. var __spreadValues$9 = (a, b) => {
  29444. for (var prop in b || (b = {}))
  29445. if (__hasOwnProp$9.call(b, prop))
  29446. __defNormalProp$9(a, prop, b[prop]);
  29447. if (__getOwnPropSymbols$9)
  29448. for (var prop of __getOwnPropSymbols$9(b)) {
  29449. if (__propIsEnum$9.call(b, prop))
  29450. __defNormalProp$9(a, prop, b[prop]);
  29451. }
  29452. return a;
  29453. };
  29454. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  29455. const defaultAssetUrlOptions = {
  29456. base: null,
  29457. includeAbsolute: false,
  29458. tags: {
  29459. video: ["src", "poster"],
  29460. source: ["src"],
  29461. img: ["src"],
  29462. image: ["xlink:href", "href"],
  29463. use: ["xlink:href", "href"]
  29464. }
  29465. };
  29466. const normalizeOptions = (options) => {
  29467. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  29468. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  29469. tags: options
  29470. });
  29471. }
  29472. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  29473. };
  29474. const createAssetUrlTransformWithOptions = (options) => {
  29475. return (node, context) => transformAssetUrl(node, context, options);
  29476. };
  29477. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  29478. if (node.type === 1) {
  29479. if (!node.props.length) {
  29480. return;
  29481. }
  29482. const tags = options.tags || defaultAssetUrlOptions.tags;
  29483. const attrs = tags[node.tag];
  29484. const wildCardAttrs = tags["*"];
  29485. if (!attrs && !wildCardAttrs) {
  29486. return;
  29487. }
  29488. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  29489. node.props.forEach((attr, index) => {
  29490. if (attr.type !== 6 || !assetAttrs.includes(attr.name) || !attr.value || isExternalUrl(attr.value.content) || isDataUrl(attr.value.content) || attr.value.content[0] === "#" || !options.includeAbsolute && !isRelativeUrl(attr.value.content)) {
  29491. return;
  29492. }
  29493. const url = parseUrl(attr.value.content);
  29494. if (options.base && attr.value.content[0] === ".") {
  29495. const base = parseUrl(options.base);
  29496. const protocol = base.protocol || "";
  29497. const host = base.host ? protocol + "//" + base.host : "";
  29498. const basePath = base.path || "/";
  29499. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  29500. return;
  29501. }
  29502. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  29503. node.props[index] = {
  29504. type: 7,
  29505. name: "bind",
  29506. arg: createSimpleExpression(attr.name, true, attr.loc),
  29507. exp,
  29508. modifiers: [],
  29509. loc: attr.loc
  29510. };
  29511. });
  29512. }
  29513. };
  29514. function getImportsExpressionExp(path2, hash, loc, context) {
  29515. if (path2) {
  29516. let name;
  29517. let exp;
  29518. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  29519. if (existingIndex > -1) {
  29520. name = `_imports_${existingIndex}`;
  29521. exp = context.imports[existingIndex].exp;
  29522. } else {
  29523. name = `_imports_${context.imports.length}`;
  29524. exp = createSimpleExpression(
  29525. name,
  29526. false,
  29527. loc,
  29528. 3
  29529. );
  29530. context.imports.push({
  29531. exp,
  29532. path: decodeURIComponent(path2)
  29533. });
  29534. }
  29535. if (!hash) {
  29536. return exp;
  29537. }
  29538. const hashExp = `${name} + '${hash}'`;
  29539. const finalExp = createSimpleExpression(
  29540. hashExp,
  29541. false,
  29542. loc,
  29543. 3
  29544. );
  29545. if (!context.hoistStatic) {
  29546. return finalExp;
  29547. }
  29548. const existingHoistIndex = context.hoists.findIndex((h) => {
  29549. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  29550. });
  29551. if (existingHoistIndex > -1) {
  29552. return createSimpleExpression(
  29553. `_hoisted_${existingHoistIndex + 1}`,
  29554. false,
  29555. loc,
  29556. 3
  29557. );
  29558. }
  29559. return context.hoist(finalExp);
  29560. } else {
  29561. return createSimpleExpression(`''`, false, loc, 3);
  29562. }
  29563. }
  29564. const srcsetTags = ["img", "source"];
  29565. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  29566. const createSrcsetTransformWithOptions = (options) => {
  29567. return (node, context) => transformSrcset(node, context, options);
  29568. };
  29569. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  29570. if (node.type === 1) {
  29571. if (srcsetTags.includes(node.tag) && node.props.length) {
  29572. node.props.forEach((attr, index) => {
  29573. if (attr.name === "srcset" && attr.type === 6) {
  29574. if (!attr.value)
  29575. return;
  29576. const value = attr.value.content;
  29577. if (!value)
  29578. return;
  29579. const imageCandidates = value.split(",").map((s) => {
  29580. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  29581. return { url, descriptor };
  29582. });
  29583. for (let i = 0; i < imageCandidates.length; i++) {
  29584. const { url } = imageCandidates[i];
  29585. if (isDataUrl(url)) {
  29586. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  29587. imageCandidates.splice(i, 1);
  29588. }
  29589. }
  29590. const shouldProcessUrl = (url) => {
  29591. return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  29592. };
  29593. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  29594. return;
  29595. }
  29596. if (options.base) {
  29597. const base = options.base;
  29598. const set = [];
  29599. let needImportTransform = false;
  29600. imageCandidates.forEach((candidate) => {
  29601. let { url, descriptor } = candidate;
  29602. descriptor = descriptor ? ` ${descriptor}` : ``;
  29603. if (url[0] === ".") {
  29604. candidate.url = (path.posix || path).join(base, url);
  29605. set.push(candidate.url + descriptor);
  29606. } else if (shouldProcessUrl(url)) {
  29607. needImportTransform = true;
  29608. } else {
  29609. set.push(url + descriptor);
  29610. }
  29611. });
  29612. if (!needImportTransform) {
  29613. attr.value.content = set.join(", ");
  29614. return;
  29615. }
  29616. }
  29617. const compoundExpression = createCompoundExpression([], attr.loc);
  29618. imageCandidates.forEach(({ url, descriptor }, index2) => {
  29619. if (shouldProcessUrl(url)) {
  29620. const { path: path2 } = parseUrl(url);
  29621. let exp2;
  29622. if (path2) {
  29623. const existingImportsIndex = context.imports.findIndex(
  29624. (i) => i.path === path2
  29625. );
  29626. if (existingImportsIndex > -1) {
  29627. exp2 = createSimpleExpression(
  29628. `_imports_${existingImportsIndex}`,
  29629. false,
  29630. attr.loc,
  29631. 3
  29632. );
  29633. } else {
  29634. exp2 = createSimpleExpression(
  29635. `_imports_${context.imports.length}`,
  29636. false,
  29637. attr.loc,
  29638. 3
  29639. );
  29640. context.imports.push({ exp: exp2, path: path2 });
  29641. }
  29642. compoundExpression.children.push(exp2);
  29643. }
  29644. } else {
  29645. const exp2 = createSimpleExpression(
  29646. `"${url}"`,
  29647. false,
  29648. attr.loc,
  29649. 3
  29650. );
  29651. compoundExpression.children.push(exp2);
  29652. }
  29653. const isNotLast = imageCandidates.length - 1 > index2;
  29654. if (descriptor && isNotLast) {
  29655. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  29656. } else if (descriptor) {
  29657. compoundExpression.children.push(` + ' ${descriptor}'`);
  29658. } else if (isNotLast) {
  29659. compoundExpression.children.push(` + ', ' + `);
  29660. }
  29661. });
  29662. let exp = compoundExpression;
  29663. if (context.hoistStatic) {
  29664. exp = context.hoist(compoundExpression);
  29665. exp.constType = 3;
  29666. }
  29667. node.props[index] = {
  29668. type: 7,
  29669. name: "bind",
  29670. arg: createSimpleExpression("srcset", true, attr.loc),
  29671. exp,
  29672. modifiers: [],
  29673. loc: attr.loc
  29674. };
  29675. }
  29676. });
  29677. }
  29678. }
  29679. };
  29680. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  29681. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  29682. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  29683. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  29684. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  29685. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  29686. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  29687. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  29688. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  29689. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  29690. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  29691. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
  29692. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  29693. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  29694. const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
  29695. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
  29696. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  29697. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  29698. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  29699. const ssrHelpers = {
  29700. [SSR_INTERPOLATE]: `ssrInterpolate`,
  29701. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  29702. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  29703. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  29704. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  29705. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  29706. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  29707. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  29708. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  29709. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  29710. [SSR_RENDER_LIST]: `ssrRenderList`,
  29711. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  29712. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  29713. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  29714. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  29715. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  29716. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  29717. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  29718. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  29719. };
  29720. registerRuntimeHelpers(ssrHelpers);
  29721. const ssrTransformIf = createStructuralDirectiveTransform(
  29722. /^(if|else|else-if)$/,
  29723. processIf
  29724. );
  29725. function ssrProcessIf(node, context, disableNestedFragments = false, disableCommentAsIfAlternate = false) {
  29726. const [rootBranch] = node.branches;
  29727. const ifStatement = createIfStatement(
  29728. rootBranch.condition,
  29729. processIfBranch(rootBranch, context, disableNestedFragments)
  29730. );
  29731. context.pushStatement(ifStatement);
  29732. let currentIf = ifStatement;
  29733. for (let i = 1; i < node.branches.length; i++) {
  29734. const branch = node.branches[i];
  29735. const branchBlockStatement = processIfBranch(
  29736. branch,
  29737. context,
  29738. disableNestedFragments
  29739. );
  29740. if (branch.condition) {
  29741. currentIf = currentIf.alternate = createIfStatement(
  29742. branch.condition,
  29743. branchBlockStatement
  29744. );
  29745. } else {
  29746. currentIf.alternate = branchBlockStatement;
  29747. }
  29748. }
  29749. if (!currentIf.alternate && !disableCommentAsIfAlternate) {
  29750. currentIf.alternate = createBlockStatement([
  29751. createCallExpression(`_push`, ["`<!---->`"])
  29752. ]);
  29753. }
  29754. }
  29755. function processIfBranch(branch, context, disableNestedFragments = false) {
  29756. const { children } = branch;
  29757. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  29758. !(children.length === 1 && children[0].type === 11);
  29759. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  29760. }
  29761. const ssrTransformFor = createStructuralDirectiveTransform(
  29762. "for",
  29763. processFor
  29764. );
  29765. function ssrProcessFor(node, context, disableNestedFragments = false) {
  29766. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  29767. const renderLoop = createFunctionExpression(
  29768. createForLoopParams(node.parseResult)
  29769. );
  29770. renderLoop.body = processChildrenAsStatement(
  29771. node,
  29772. context,
  29773. needFragmentWrapper
  29774. );
  29775. if (!disableNestedFragments) {
  29776. context.pushStringPart(`<!--[-->`);
  29777. }
  29778. context.pushStatement(
  29779. createCallExpression(context.helper(SSR_RENDER_LIST), [
  29780. node.source,
  29781. renderLoop
  29782. ])
  29783. );
  29784. if (!disableNestedFragments) {
  29785. context.pushStringPart(`<!--]-->`);
  29786. }
  29787. }
  29788. const ssrTransformSlotOutlet = (node, context) => {
  29789. if (isSlotOutlet(node)) {
  29790. const { slotName, slotProps } = processSlotOutlet(node, context);
  29791. const args = [
  29792. `_ctx.$slots`,
  29793. slotName,
  29794. slotProps || `{}`,
  29795. // fallback content placeholder. will be replaced in the process phase
  29796. `null`,
  29797. `_push`,
  29798. `_parent`
  29799. ];
  29800. if (context.scopeId && context.slotted !== false) {
  29801. args.push(`"${context.scopeId}-s"`);
  29802. }
  29803. let method = SSR_RENDER_SLOT;
  29804. const parent = context.parent;
  29805. let componentType;
  29806. if (parent && parent.type === 1 && parent.tagType === 1 && ((componentType = resolveComponentType(parent, context, true)) === TRANSITION || componentType === TRANSITION_GROUP) && parent.children.filter((c) => c.type === 1).length === 1) {
  29807. method = SSR_RENDER_SLOT_INNER;
  29808. if (!(context.scopeId && context.slotted !== false)) {
  29809. args.push("null");
  29810. }
  29811. args.push("true");
  29812. }
  29813. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  29814. }
  29815. };
  29816. function ssrProcessSlotOutlet(node, context) {
  29817. const renderCall = node.ssrCodegenNode;
  29818. if (node.children.length) {
  29819. const fallbackRenderFn = createFunctionExpression([]);
  29820. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  29821. renderCall.arguments[3] = fallbackRenderFn;
  29822. }
  29823. if (context.withSlotScopeId) {
  29824. const slotScopeId = renderCall.arguments[6];
  29825. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  29826. }
  29827. context.pushStatement(node.ssrCodegenNode);
  29828. }
  29829. function createSSRCompilerError(code, loc) {
  29830. return createCompilerError(code, loc, SSRErrorMessages);
  29831. }
  29832. const SSRErrorMessages = {
  29833. [65]: `Unsafe attribute name for SSR.`,
  29834. [66]: `Missing the 'to' prop on teleport element.`,
  29835. [67]: `Invalid AST node during SSR transform.`
  29836. };
  29837. function ssrProcessTeleport(node, context) {
  29838. const targetProp = findProp(node, "to");
  29839. if (!targetProp) {
  29840. context.onError(
  29841. createSSRCompilerError(66, node.loc)
  29842. );
  29843. return;
  29844. }
  29845. let target;
  29846. if (targetProp.type === 6) {
  29847. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  29848. } else {
  29849. target = targetProp.exp;
  29850. }
  29851. if (!target) {
  29852. context.onError(
  29853. createSSRCompilerError(
  29854. 66,
  29855. targetProp.loc
  29856. )
  29857. );
  29858. return;
  29859. }
  29860. const disabledProp = findProp(
  29861. node,
  29862. "disabled",
  29863. false,
  29864. true
  29865. /* allow empty */
  29866. );
  29867. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  29868. const contentRenderFn = createFunctionExpression(
  29869. [`_push`],
  29870. void 0,
  29871. // Body is added later
  29872. true,
  29873. // newline
  29874. false,
  29875. // isSlot
  29876. node.loc
  29877. );
  29878. contentRenderFn.body = processChildrenAsStatement(node, context);
  29879. context.pushStatement(
  29880. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  29881. `_push`,
  29882. contentRenderFn,
  29883. target,
  29884. disabled,
  29885. `_parent`
  29886. ])
  29887. );
  29888. }
  29889. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  29890. function ssrTransformSuspense(node, context) {
  29891. return () => {
  29892. if (node.children.length) {
  29893. const wipEntry = {
  29894. slotsExp: null,
  29895. // to be immediately set
  29896. wipSlots: []
  29897. };
  29898. wipMap$3.set(node, wipEntry);
  29899. wipEntry.slotsExp = buildSlots(
  29900. node,
  29901. context,
  29902. (_props, _vForExp, children, loc) => {
  29903. const fn = createFunctionExpression(
  29904. [],
  29905. void 0,
  29906. // no return, assign body later
  29907. true,
  29908. // newline
  29909. false,
  29910. // suspense slots are not treated as normal slots
  29911. loc
  29912. );
  29913. wipEntry.wipSlots.push({
  29914. fn,
  29915. children
  29916. });
  29917. return fn;
  29918. }
  29919. ).slots;
  29920. }
  29921. };
  29922. }
  29923. function ssrProcessSuspense(node, context) {
  29924. const wipEntry = wipMap$3.get(node);
  29925. if (!wipEntry) {
  29926. return;
  29927. }
  29928. const { slotsExp, wipSlots } = wipEntry;
  29929. for (let i = 0; i < wipSlots.length; i++) {
  29930. const slot = wipSlots[i];
  29931. slot.fn.body = processChildrenAsStatement(slot, context);
  29932. }
  29933. context.pushStatement(
  29934. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  29935. `_push`,
  29936. slotsExp
  29937. ])
  29938. );
  29939. }
  29940. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  29941. const ssrTransformElement = (node, context) => {
  29942. if (node.type !== 1 || node.tagType !== 0) {
  29943. return;
  29944. }
  29945. return function ssrPostTransformElement() {
  29946. const openTag = [`<${node.tag}`];
  29947. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  29948. const hasDynamicVBind = hasDynamicKeyVBind(node);
  29949. const hasCustomDir = node.props.some(
  29950. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  29951. );
  29952. const needMergeProps = hasDynamicVBind || hasCustomDir;
  29953. if (needMergeProps) {
  29954. const { props, directives } = buildProps(
  29955. node,
  29956. context,
  29957. node.props,
  29958. false,
  29959. false,
  29960. true
  29961. );
  29962. if (props || directives.length) {
  29963. const mergedProps = buildSSRProps(props, directives, context);
  29964. const propsExp = createCallExpression(
  29965. context.helper(SSR_RENDER_ATTRS),
  29966. [mergedProps]
  29967. );
  29968. if (node.tag === "textarea") {
  29969. const existingText = node.children[0];
  29970. if (!existingText || existingText.type !== 5) {
  29971. const tempId = `_temp${context.temps++}`;
  29972. propsExp.arguments = [
  29973. createAssignmentExpression(
  29974. createSimpleExpression(tempId, false),
  29975. mergedProps
  29976. )
  29977. ];
  29978. rawChildrenMap.set(
  29979. node,
  29980. createCallExpression(context.helper(SSR_INTERPOLATE), [
  29981. createConditionalExpression(
  29982. createSimpleExpression(`"value" in ${tempId}`, false),
  29983. createSimpleExpression(`${tempId}.value`, false),
  29984. createSimpleExpression(
  29985. existingText ? existingText.content : ``,
  29986. true
  29987. ),
  29988. false
  29989. )
  29990. ])
  29991. );
  29992. }
  29993. } else if (node.tag === "input") {
  29994. const vModel = findVModel(node);
  29995. if (vModel) {
  29996. const tempId = `_temp${context.temps++}`;
  29997. const tempExp = createSimpleExpression(tempId, false);
  29998. propsExp.arguments = [
  29999. createSequenceExpression([
  30000. createAssignmentExpression(tempExp, mergedProps),
  30001. createCallExpression(context.helper(MERGE_PROPS), [
  30002. tempExp,
  30003. createCallExpression(
  30004. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  30005. [
  30006. tempExp,
  30007. // existing props
  30008. vModel.exp
  30009. // model
  30010. ]
  30011. )
  30012. ])
  30013. ])
  30014. ];
  30015. }
  30016. }
  30017. if (needTagForRuntime) {
  30018. propsExp.arguments.push(`"${node.tag}"`);
  30019. }
  30020. openTag.push(propsExp);
  30021. }
  30022. }
  30023. let dynamicClassBinding = void 0;
  30024. let staticClassBinding = void 0;
  30025. let dynamicStyleBinding = void 0;
  30026. for (let i = 0; i < node.props.length; i++) {
  30027. const prop = node.props[i];
  30028. if (node.tag === "input" && isTrueFalseValue(prop)) {
  30029. continue;
  30030. }
  30031. if (prop.type === 7) {
  30032. if (prop.name === "html" && prop.exp) {
  30033. rawChildrenMap.set(node, prop.exp);
  30034. } else if (prop.name === "text" && prop.exp) {
  30035. node.children = [createInterpolation(prop.exp, prop.loc)];
  30036. } else if (prop.name === "slot") {
  30037. context.onError(
  30038. createCompilerError(40, prop.loc)
  30039. );
  30040. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  30041. if (!needMergeProps) {
  30042. node.children = [createInterpolation(prop.exp, prop.loc)];
  30043. }
  30044. } else if (!needMergeProps && prop.name !== "on") {
  30045. const directiveTransform = context.directiveTransforms[prop.name];
  30046. if (directiveTransform) {
  30047. const { props, ssrTagParts } = directiveTransform(
  30048. prop,
  30049. node,
  30050. context
  30051. );
  30052. if (ssrTagParts) {
  30053. openTag.push(...ssrTagParts);
  30054. }
  30055. for (let j = 0; j < props.length; j++) {
  30056. const { key, value } = props[j];
  30057. if (isStaticExp(key)) {
  30058. let attrName = key.content;
  30059. if (attrName === "key" || attrName === "ref") {
  30060. continue;
  30061. }
  30062. if (attrName === "class") {
  30063. openTag.push(
  30064. ` class="`,
  30065. dynamicClassBinding = createCallExpression(
  30066. context.helper(SSR_RENDER_CLASS),
  30067. [value]
  30068. ),
  30069. `"`
  30070. );
  30071. } else if (attrName === "style") {
  30072. if (dynamicStyleBinding) {
  30073. mergeCall(dynamicStyleBinding, value);
  30074. } else {
  30075. openTag.push(
  30076. ` style="`,
  30077. dynamicStyleBinding = createCallExpression(
  30078. context.helper(SSR_RENDER_STYLE),
  30079. [value]
  30080. ),
  30081. `"`
  30082. );
  30083. }
  30084. } else {
  30085. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  30086. if (isBooleanAttr(attrName)) {
  30087. openTag.push(
  30088. createConditionalExpression(
  30089. createCallExpression(
  30090. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  30091. [value]
  30092. ),
  30093. createSimpleExpression(" " + attrName, true),
  30094. createSimpleExpression("", true),
  30095. false
  30096. )
  30097. );
  30098. } else if (isSSRSafeAttrName(attrName)) {
  30099. openTag.push(
  30100. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  30101. key,
  30102. value
  30103. ])
  30104. );
  30105. } else {
  30106. context.onError(
  30107. createSSRCompilerError(
  30108. 65,
  30109. key.loc
  30110. )
  30111. );
  30112. }
  30113. }
  30114. } else {
  30115. const args = [key, value];
  30116. if (needTagForRuntime) {
  30117. args.push(`"${node.tag}"`);
  30118. }
  30119. openTag.push(
  30120. createCallExpression(
  30121. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  30122. args
  30123. )
  30124. );
  30125. }
  30126. }
  30127. }
  30128. }
  30129. } else {
  30130. const name = prop.name;
  30131. if (node.tag === "textarea" && name === "value" && prop.value) {
  30132. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  30133. } else if (!needMergeProps) {
  30134. if (name === "key" || name === "ref") {
  30135. continue;
  30136. }
  30137. if (name === "class" && prop.value) {
  30138. staticClassBinding = JSON.stringify(prop.value.content);
  30139. }
  30140. openTag.push(
  30141. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  30142. );
  30143. }
  30144. }
  30145. }
  30146. if (dynamicClassBinding && staticClassBinding) {
  30147. mergeCall(dynamicClassBinding, staticClassBinding);
  30148. removeStaticBinding(openTag, "class");
  30149. }
  30150. if (context.scopeId) {
  30151. openTag.push(` ${context.scopeId}`);
  30152. }
  30153. node.ssrCodegenNode = createTemplateLiteral(openTag);
  30154. };
  30155. };
  30156. function buildSSRProps(props, directives, context) {
  30157. let mergePropsArgs = [];
  30158. if (props) {
  30159. if (props.type === 14) {
  30160. mergePropsArgs = props.arguments;
  30161. } else {
  30162. mergePropsArgs.push(props);
  30163. }
  30164. }
  30165. if (directives.length) {
  30166. for (const dir of directives) {
  30167. mergePropsArgs.push(
  30168. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  30169. `_ctx`,
  30170. ...buildDirectiveArgs(dir, context).elements
  30171. ])
  30172. );
  30173. }
  30174. }
  30175. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  30176. }
  30177. function isTrueFalseValue(prop) {
  30178. if (prop.type === 7) {
  30179. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  30180. } else {
  30181. return prop.name === "true-value" || prop.name === "false-value";
  30182. }
  30183. }
  30184. function isTextareaWithValue(node, prop) {
  30185. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  30186. }
  30187. function mergeCall(call, arg) {
  30188. const existing = call.arguments[0];
  30189. if (existing.type === 17) {
  30190. existing.elements.push(arg);
  30191. } else {
  30192. call.arguments[0] = createArrayExpression([existing, arg]);
  30193. }
  30194. }
  30195. function removeStaticBinding(tag, binding) {
  30196. const regExp = new RegExp(`^ ${binding}=".+"$`);
  30197. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  30198. if (i > -1) {
  30199. tag.splice(i, 1);
  30200. }
  30201. }
  30202. function findVModel(node) {
  30203. return node.props.find(
  30204. (p) => p.type === 7 && p.name === "model" && p.exp
  30205. );
  30206. }
  30207. function ssrProcessElement(node, context) {
  30208. const isVoidTag = context.options.isVoidTag || NO;
  30209. const elementsToAdd = node.ssrCodegenNode.elements;
  30210. for (let j = 0; j < elementsToAdd.length; j++) {
  30211. context.pushStringPart(elementsToAdd[j]);
  30212. }
  30213. if (context.withSlotScopeId) {
  30214. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  30215. }
  30216. context.pushStringPart(`>`);
  30217. const rawChildren = rawChildrenMap.get(node);
  30218. if (rawChildren) {
  30219. context.pushStringPart(rawChildren);
  30220. } else if (node.children.length) {
  30221. processChildren(node, context);
  30222. }
  30223. if (!isVoidTag(node.tag)) {
  30224. context.pushStringPart(`</${node.tag}>`);
  30225. }
  30226. }
  30227. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  30228. function ssrTransformTransitionGroup(node, context) {
  30229. return () => {
  30230. const tag = findProp(node, "tag");
  30231. if (tag) {
  30232. const otherProps = node.props.filter((p) => p !== tag);
  30233. const { props, directives } = buildProps(
  30234. node,
  30235. context,
  30236. otherProps,
  30237. true,
  30238. false,
  30239. true
  30240. );
  30241. let propsExp = null;
  30242. if (props || directives.length) {
  30243. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  30244. buildSSRProps(props, directives, context)
  30245. ]);
  30246. }
  30247. wipMap$2.set(node, {
  30248. tag,
  30249. propsExp,
  30250. scopeId: context.scopeId || null
  30251. });
  30252. }
  30253. };
  30254. }
  30255. function ssrProcessTransitionGroup(node, context) {
  30256. const entry = wipMap$2.get(node);
  30257. if (entry) {
  30258. const { tag, propsExp, scopeId } = entry;
  30259. if (tag.type === 7) {
  30260. context.pushStringPart(`<`);
  30261. context.pushStringPart(tag.exp);
  30262. if (propsExp) {
  30263. context.pushStringPart(propsExp);
  30264. }
  30265. if (scopeId) {
  30266. context.pushStringPart(` ${scopeId}`);
  30267. }
  30268. context.pushStringPart(`>`);
  30269. processChildren(
  30270. node,
  30271. context,
  30272. false,
  30273. /**
  30274. * TransitionGroup has the special runtime behavior of flattening and
  30275. * concatenating all children into a single fragment (in order for them to
  30276. * be patched using the same key map) so we need to account for that here
  30277. * by disabling nested fragment wrappers from being generated.
  30278. */
  30279. true,
  30280. /**
  30281. * TransitionGroup filters out comment children at runtime and thus
  30282. * doesn't expect comments to be present during hydration. We need to
  30283. * account for that by disabling the empty comment that is otherwise
  30284. * rendered for a falsy v-if that has no v-else specified. (#6715)
  30285. */
  30286. true
  30287. );
  30288. context.pushStringPart(`</`);
  30289. context.pushStringPart(tag.exp);
  30290. context.pushStringPart(`>`);
  30291. } else {
  30292. context.pushStringPart(`<${tag.value.content}`);
  30293. if (propsExp) {
  30294. context.pushStringPart(propsExp);
  30295. }
  30296. if (scopeId) {
  30297. context.pushStringPart(` ${scopeId}`);
  30298. }
  30299. context.pushStringPart(`>`);
  30300. processChildren(node, context, false, true);
  30301. context.pushStringPart(`</${tag.value.content}>`);
  30302. }
  30303. } else {
  30304. processChildren(node, context, true, true, true);
  30305. }
  30306. }
  30307. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  30308. function ssrTransformTransition(node, context) {
  30309. return () => {
  30310. const appear = findProp(node, "appear", false, true);
  30311. wipMap$1.set(node, !!appear);
  30312. };
  30313. }
  30314. function ssrProcessTransition(node, context) {
  30315. node.children = node.children.filter((c) => c.type !== 3);
  30316. const appear = wipMap$1.get(node);
  30317. if (appear) {
  30318. context.pushStringPart(`<template>`);
  30319. processChildren(node, context, false, true);
  30320. context.pushStringPart(`</template>`);
  30321. } else {
  30322. processChildren(node, context, false, true);
  30323. }
  30324. }
  30325. var __defProp$8 = Object.defineProperty;
  30326. var __defProps$7 = Object.defineProperties;
  30327. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  30328. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  30329. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  30330. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  30331. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30332. var __spreadValues$8 = (a, b) => {
  30333. for (var prop in b || (b = {}))
  30334. if (__hasOwnProp$8.call(b, prop))
  30335. __defNormalProp$8(a, prop, b[prop]);
  30336. if (__getOwnPropSymbols$8)
  30337. for (var prop of __getOwnPropSymbols$8(b)) {
  30338. if (__propIsEnum$8.call(b, prop))
  30339. __defNormalProp$8(a, prop, b[prop]);
  30340. }
  30341. return a;
  30342. };
  30343. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  30344. const wipMap = /* @__PURE__ */ new WeakMap();
  30345. const WIP_SLOT = Symbol();
  30346. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  30347. const ssrTransformComponent = (node, context) => {
  30348. if (node.type !== 1 || node.tagType !== 1) {
  30349. return;
  30350. }
  30351. const component = resolveComponentType(
  30352. node,
  30353. context,
  30354. true
  30355. /* ssr */
  30356. );
  30357. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  30358. componentTypeMap.set(node, component);
  30359. if (isSymbol$1(component)) {
  30360. if (component === SUSPENSE) {
  30361. return ssrTransformSuspense(node, context);
  30362. } else if (component === TRANSITION_GROUP) {
  30363. return ssrTransformTransitionGroup(node, context);
  30364. } else if (component === TRANSITION) {
  30365. return ssrTransformTransition(node);
  30366. }
  30367. return;
  30368. }
  30369. const vnodeBranches = [];
  30370. const clonedNode = clone(node);
  30371. return function ssrPostTransformComponent() {
  30372. if (clonedNode.children.length) {
  30373. buildSlots(clonedNode, context, (props, vFor, children) => {
  30374. vnodeBranches.push(
  30375. createVNodeSlotBranch(props, vFor, children, context)
  30376. );
  30377. return createFunctionExpression(void 0);
  30378. });
  30379. }
  30380. let propsExp = `null`;
  30381. if (node.props.length) {
  30382. const { props, directives } = buildProps(
  30383. node,
  30384. context,
  30385. void 0,
  30386. true,
  30387. isDynamicComponent
  30388. );
  30389. if (props || directives.length) {
  30390. propsExp = buildSSRProps(props, directives, context);
  30391. }
  30392. }
  30393. const wipEntries = [];
  30394. wipMap.set(node, wipEntries);
  30395. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  30396. const param0 = props && stringifyExpression(props) || `_`;
  30397. const fn = createFunctionExpression(
  30398. [param0, `_push`, `_parent`, `_scopeId`],
  30399. void 0,
  30400. // no return, assign body later
  30401. true,
  30402. // newline
  30403. true,
  30404. // isSlot
  30405. loc
  30406. );
  30407. wipEntries.push({
  30408. type: WIP_SLOT,
  30409. fn,
  30410. children,
  30411. // also collect the corresponding vnode branch built earlier
  30412. vnodeBranch: vnodeBranches[wipEntries.length]
  30413. });
  30414. return fn;
  30415. };
  30416. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  30417. if (typeof component !== "string") {
  30418. node.ssrCodegenNode = createCallExpression(
  30419. context.helper(SSR_RENDER_VNODE),
  30420. [
  30421. `_push`,
  30422. createCallExpression(context.helper(CREATE_VNODE), [
  30423. component,
  30424. propsExp,
  30425. slots
  30426. ]),
  30427. `_parent`
  30428. ]
  30429. );
  30430. } else {
  30431. node.ssrCodegenNode = createCallExpression(
  30432. context.helper(SSR_RENDER_COMPONENT),
  30433. [component, propsExp, slots, `_parent`]
  30434. );
  30435. }
  30436. };
  30437. };
  30438. function ssrProcessComponent(node, context, parent) {
  30439. const component = componentTypeMap.get(node);
  30440. if (!node.ssrCodegenNode) {
  30441. if (component === TELEPORT) {
  30442. return ssrProcessTeleport(node, context);
  30443. } else if (component === SUSPENSE) {
  30444. return ssrProcessSuspense(node, context);
  30445. } else if (component === TRANSITION_GROUP) {
  30446. return ssrProcessTransitionGroup(node, context);
  30447. } else {
  30448. if (parent.type === WIP_SLOT) {
  30449. context.pushStringPart(``);
  30450. }
  30451. if (component === TRANSITION) {
  30452. return ssrProcessTransition(node, context);
  30453. }
  30454. processChildren(node, context);
  30455. }
  30456. } else {
  30457. const wipEntries = wipMap.get(node) || [];
  30458. for (let i = 0; i < wipEntries.length; i++) {
  30459. const { fn, vnodeBranch } = wipEntries[i];
  30460. fn.body = createIfStatement(
  30461. createSimpleExpression(`_push`, false),
  30462. processChildrenAsStatement(
  30463. wipEntries[i],
  30464. context,
  30465. false,
  30466. true
  30467. ),
  30468. vnodeBranch
  30469. );
  30470. }
  30471. if (context.withSlotScopeId) {
  30472. node.ssrCodegenNode.arguments.push(`_scopeId`);
  30473. }
  30474. if (typeof component === "string") {
  30475. context.pushStatement(
  30476. createCallExpression(`_push`, [node.ssrCodegenNode])
  30477. );
  30478. } else {
  30479. context.pushStatement(node.ssrCodegenNode);
  30480. }
  30481. }
  30482. }
  30483. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  30484. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  30485. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  30486. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  30487. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  30488. const rawOptions = rawOptionsMap.get(parentContext.root);
  30489. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  30490. // overwrite with vnode-based transforms
  30491. nodeTransforms: [
  30492. ...vnodeNodeTransforms,
  30493. ...rawOptions.nodeTransforms || []
  30494. ],
  30495. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  30496. });
  30497. const wrapperProps = [];
  30498. if (slotProps) {
  30499. wrapperProps.push({
  30500. type: 7,
  30501. name: "slot",
  30502. exp: slotProps,
  30503. arg: void 0,
  30504. modifiers: [],
  30505. loc: locStub
  30506. });
  30507. }
  30508. if (vFor) {
  30509. wrapperProps.push(extend({}, vFor));
  30510. }
  30511. const wrapperNode = {
  30512. type: 1,
  30513. ns: 0,
  30514. tag: "template",
  30515. tagType: 3,
  30516. props: wrapperProps,
  30517. children,
  30518. loc: locStub,
  30519. codegenNode: void 0
  30520. };
  30521. subTransform(wrapperNode, subOptions, parentContext);
  30522. return createReturnStatement(children);
  30523. }
  30524. function subTransform(node, options, parentContext) {
  30525. const childRoot = createRoot([node]);
  30526. const childContext = createTransformContext(childRoot, options);
  30527. childContext.ssr = false;
  30528. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  30529. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  30530. childContext.imports = parentContext.imports;
  30531. traverseNode(childRoot, childContext);
  30532. ["helpers", "components", "directives"].forEach((key) => {
  30533. childContext[key].forEach((value, helperKey) => {
  30534. if (key === "helpers") {
  30535. const parentCount = parentContext.helpers.get(helperKey);
  30536. if (parentCount === void 0) {
  30537. parentContext.helpers.set(helperKey, value);
  30538. } else {
  30539. parentContext.helpers.set(helperKey, value + parentCount);
  30540. }
  30541. } else {
  30542. parentContext[key].add(value);
  30543. }
  30544. });
  30545. });
  30546. }
  30547. function clone(v) {
  30548. if (isArray$3(v)) {
  30549. return v.map(clone);
  30550. } else if (isPlainObject(v)) {
  30551. const res = {};
  30552. for (const key in v) {
  30553. res[key] = clone(v[key]);
  30554. }
  30555. return res;
  30556. } else {
  30557. return v;
  30558. }
  30559. }
  30560. function ssrCodegenTransform(ast, options) {
  30561. const context = createSSRTransformContext(ast, options);
  30562. if (options.ssrCssVars) {
  30563. const cssContext = createTransformContext(createRoot([]), options);
  30564. const varsExp = processExpression(
  30565. createSimpleExpression(options.ssrCssVars, false),
  30566. cssContext
  30567. );
  30568. context.body.push(
  30569. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  30570. );
  30571. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  30572. ast.helpers.add(helper);
  30573. });
  30574. }
  30575. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  30576. processChildren(ast, context, isFragment);
  30577. ast.codegenNode = createBlockStatement(context.body);
  30578. ast.ssrHelpers = Array.from(
  30579. /* @__PURE__ */ new Set([
  30580. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  30581. ...context.helpers
  30582. ])
  30583. );
  30584. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  30585. }
  30586. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  30587. const body = [];
  30588. let currentString = null;
  30589. return {
  30590. root,
  30591. options,
  30592. body,
  30593. helpers,
  30594. withSlotScopeId,
  30595. onError: options.onError || ((e) => {
  30596. throw e;
  30597. }),
  30598. helper(name) {
  30599. helpers.add(name);
  30600. return name;
  30601. },
  30602. pushStringPart(part) {
  30603. if (!currentString) {
  30604. const currentCall = createCallExpression(`_push`);
  30605. body.push(currentCall);
  30606. currentString = createTemplateLiteral([]);
  30607. currentCall.arguments.push(currentString);
  30608. }
  30609. const bufferedElements = currentString.elements;
  30610. const lastItem = bufferedElements[bufferedElements.length - 1];
  30611. if (isString$2(part) && isString$2(lastItem)) {
  30612. bufferedElements[bufferedElements.length - 1] += part;
  30613. } else {
  30614. bufferedElements.push(part);
  30615. }
  30616. },
  30617. pushStatement(statement) {
  30618. currentString = null;
  30619. body.push(statement);
  30620. }
  30621. };
  30622. }
  30623. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  30624. return createSSRTransformContext(
  30625. parent.root,
  30626. parent.options,
  30627. parent.helpers,
  30628. withSlotScopeId
  30629. );
  30630. }
  30631. function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableCommentAsIfAlternate = false) {
  30632. if (asFragment) {
  30633. context.pushStringPart(`<!--[-->`);
  30634. }
  30635. const { children } = parent;
  30636. for (let i = 0; i < children.length; i++) {
  30637. const child = children[i];
  30638. switch (child.type) {
  30639. case 1:
  30640. switch (child.tagType) {
  30641. case 0:
  30642. ssrProcessElement(child, context);
  30643. break;
  30644. case 1:
  30645. ssrProcessComponent(child, context, parent);
  30646. break;
  30647. case 2:
  30648. ssrProcessSlotOutlet(child, context);
  30649. break;
  30650. case 3:
  30651. break;
  30652. default:
  30653. context.onError(
  30654. createSSRCompilerError(
  30655. 67,
  30656. child.loc
  30657. )
  30658. );
  30659. const exhaustiveCheck2 = child;
  30660. return exhaustiveCheck2;
  30661. }
  30662. break;
  30663. case 2:
  30664. context.pushStringPart(escapeHtml(child.content));
  30665. break;
  30666. case 3:
  30667. context.pushStringPart(`<!--${child.content}-->`);
  30668. break;
  30669. case 5:
  30670. context.pushStringPart(
  30671. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30672. child.content
  30673. ])
  30674. );
  30675. break;
  30676. case 9:
  30677. ssrProcessIf(
  30678. child,
  30679. context,
  30680. disableNestedFragments,
  30681. disableCommentAsIfAlternate
  30682. );
  30683. break;
  30684. case 11:
  30685. ssrProcessFor(child, context, disableNestedFragments);
  30686. break;
  30687. case 10:
  30688. break;
  30689. case 12:
  30690. case 8:
  30691. break;
  30692. default:
  30693. context.onError(
  30694. createSSRCompilerError(
  30695. 67,
  30696. child.loc
  30697. )
  30698. );
  30699. const exhaustiveCheck = child;
  30700. return exhaustiveCheck;
  30701. }
  30702. }
  30703. if (asFragment) {
  30704. context.pushStringPart(`<!--]-->`);
  30705. }
  30706. }
  30707. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  30708. const childContext = createChildContext(parentContext, withSlotScopeId);
  30709. processChildren(parent, childContext, asFragment);
  30710. return createBlockStatement(childContext.body);
  30711. }
  30712. const ssrTransformModel = (dir, node, context) => {
  30713. const model = dir.exp;
  30714. function checkDuplicatedValue() {
  30715. const value = findProp(node, "value");
  30716. if (value) {
  30717. context.onError(
  30718. createDOMCompilerError(
  30719. 60,
  30720. value.loc
  30721. )
  30722. );
  30723. }
  30724. }
  30725. function processOption(plainNode) {
  30726. if (plainNode.tag === "option") {
  30727. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  30728. const value = findValueBinding(plainNode);
  30729. plainNode.ssrCodegenNode.elements.push(
  30730. createConditionalExpression(
  30731. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  30732. createConditionalExpression(
  30733. createCallExpression(`Array.isArray`, [model]),
  30734. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30735. model,
  30736. value
  30737. ]),
  30738. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30739. model,
  30740. value
  30741. ])
  30742. )
  30743. ]),
  30744. createSimpleExpression(" selected", true),
  30745. createSimpleExpression("", true),
  30746. false
  30747. )
  30748. );
  30749. }
  30750. } else if (plainNode.tag === "optgroup") {
  30751. plainNode.children.forEach(
  30752. (option) => processOption(option)
  30753. );
  30754. }
  30755. }
  30756. if (node.tagType === 0) {
  30757. const res = { props: [] };
  30758. const defaultProps = [
  30759. // default value binding for text type inputs
  30760. createObjectProperty(`value`, model)
  30761. ];
  30762. if (node.tag === "input") {
  30763. const type = findProp(node, "type");
  30764. if (type) {
  30765. const value = findValueBinding(node);
  30766. if (type.type === 7) {
  30767. res.ssrTagParts = [
  30768. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  30769. type.exp,
  30770. model,
  30771. value
  30772. ])
  30773. ];
  30774. } else if (type.value) {
  30775. switch (type.value.content) {
  30776. case "radio":
  30777. res.props = [
  30778. createObjectProperty(
  30779. `checked`,
  30780. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30781. model,
  30782. value
  30783. ])
  30784. )
  30785. ];
  30786. break;
  30787. case "checkbox":
  30788. const trueValueBinding = findProp(node, "true-value");
  30789. if (trueValueBinding) {
  30790. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  30791. res.props = [
  30792. createObjectProperty(
  30793. `checked`,
  30794. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30795. model,
  30796. trueValue
  30797. ])
  30798. )
  30799. ];
  30800. } else {
  30801. res.props = [
  30802. createObjectProperty(
  30803. `checked`,
  30804. createConditionalExpression(
  30805. createCallExpression(`Array.isArray`, [model]),
  30806. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30807. model,
  30808. value
  30809. ]),
  30810. model
  30811. )
  30812. )
  30813. ];
  30814. }
  30815. break;
  30816. case "file":
  30817. context.onError(
  30818. createDOMCompilerError(
  30819. 59,
  30820. dir.loc
  30821. )
  30822. );
  30823. break;
  30824. default:
  30825. checkDuplicatedValue();
  30826. res.props = defaultProps;
  30827. break;
  30828. }
  30829. }
  30830. } else if (hasDynamicKeyVBind(node)) ; else {
  30831. checkDuplicatedValue();
  30832. res.props = defaultProps;
  30833. }
  30834. } else if (node.tag === "textarea") {
  30835. checkDuplicatedValue();
  30836. node.children = [createInterpolation(model, model.loc)];
  30837. } else if (node.tag === "select") {
  30838. node.children.forEach((child) => {
  30839. if (child.type === 1) {
  30840. processOption(child);
  30841. }
  30842. });
  30843. } else {
  30844. context.onError(
  30845. createDOMCompilerError(
  30846. 57,
  30847. dir.loc
  30848. )
  30849. );
  30850. }
  30851. return res;
  30852. } else {
  30853. return transformModel$1(dir, node, context);
  30854. }
  30855. };
  30856. function findValueBinding(node) {
  30857. const valueBinding = findProp(node, "value");
  30858. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  30859. }
  30860. const ssrTransformShow = (dir, node, context) => {
  30861. if (!dir.exp) {
  30862. context.onError(
  30863. createDOMCompilerError(61)
  30864. );
  30865. }
  30866. return {
  30867. props: [
  30868. createObjectProperty(
  30869. `style`,
  30870. createConditionalExpression(
  30871. dir.exp,
  30872. createSimpleExpression(`null`, false),
  30873. createObjectExpression([
  30874. createObjectProperty(
  30875. `display`,
  30876. createSimpleExpression(`none`, true)
  30877. )
  30878. ]),
  30879. false
  30880. )
  30881. )
  30882. ]
  30883. };
  30884. };
  30885. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  30886. const hasSingleChild = (node) => filterChild(node).length === 1;
  30887. const ssrInjectFallthroughAttrs = (node, context) => {
  30888. if (node.type === 0) {
  30889. context.identifiers._attrs = 1;
  30890. }
  30891. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  30892. const rootChildren = filterChild(context.root);
  30893. if (rootChildren.length === 1 && rootChildren[0] === node) {
  30894. if (hasSingleChild(node)) {
  30895. injectFallthroughAttrs(node.children[0]);
  30896. }
  30897. return;
  30898. }
  30899. }
  30900. const parent = context.parent;
  30901. if (!parent || parent.type !== 0) {
  30902. return;
  30903. }
  30904. if (node.type === 10 && hasSingleChild(node)) {
  30905. let hasEncounteredIf = false;
  30906. for (const c of filterChild(parent)) {
  30907. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  30908. if (hasEncounteredIf)
  30909. return;
  30910. hasEncounteredIf = true;
  30911. } else if (
  30912. // node before v-if
  30913. !hasEncounteredIf || // non else nodes
  30914. !(c.type === 1 && findDir(c, /else/, true))
  30915. ) {
  30916. return;
  30917. }
  30918. }
  30919. injectFallthroughAttrs(node.children[0]);
  30920. } else if (hasSingleChild(parent)) {
  30921. injectFallthroughAttrs(node);
  30922. }
  30923. };
  30924. function injectFallthroughAttrs(node) {
  30925. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30926. node.props.push({
  30927. type: 7,
  30928. name: "bind",
  30929. arg: void 0,
  30930. exp: createSimpleExpression(`_attrs`, false),
  30931. modifiers: [],
  30932. loc: locStub
  30933. });
  30934. }
  30935. }
  30936. const ssrInjectCssVars = (node, context) => {
  30937. if (!context.ssrCssVars) {
  30938. return;
  30939. }
  30940. if (node.type === 0) {
  30941. context.identifiers._cssVars = 1;
  30942. }
  30943. const parent = context.parent;
  30944. if (!parent || parent.type !== 0) {
  30945. return;
  30946. }
  30947. if (node.type === 10) {
  30948. for (const child of node.children) {
  30949. injectCssVars(child);
  30950. }
  30951. } else {
  30952. injectCssVars(node);
  30953. }
  30954. };
  30955. function injectCssVars(node) {
  30956. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30957. if (node.tag === "suspense" || node.tag === "Suspense") {
  30958. for (const child of node.children) {
  30959. if (child.type === 1 && child.tagType === 3) {
  30960. child.children.forEach(injectCssVars);
  30961. } else {
  30962. injectCssVars(child);
  30963. }
  30964. }
  30965. } else {
  30966. node.props.push({
  30967. type: 7,
  30968. name: "bind",
  30969. arg: void 0,
  30970. exp: createSimpleExpression(`_cssVars`, false),
  30971. modifiers: [],
  30972. loc: locStub
  30973. });
  30974. }
  30975. }
  30976. }
  30977. var __defProp$7 = Object.defineProperty;
  30978. var __defProps$6 = Object.defineProperties;
  30979. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  30980. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  30981. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  30982. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  30983. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30984. var __spreadValues$7 = (a, b) => {
  30985. for (var prop in b || (b = {}))
  30986. if (__hasOwnProp$7.call(b, prop))
  30987. __defNormalProp$7(a, prop, b[prop]);
  30988. if (__getOwnPropSymbols$7)
  30989. for (var prop of __getOwnPropSymbols$7(b)) {
  30990. if (__propIsEnum$7.call(b, prop))
  30991. __defNormalProp$7(a, prop, b[prop]);
  30992. }
  30993. return a;
  30994. };
  30995. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  30996. function compile(source, options = {}) {
  30997. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  30998. ssr: true,
  30999. inSSR: true,
  31000. scopeId: options.mode === "function" ? null : options.scopeId,
  31001. // always prefix since compiler-ssr doesn't have size concern
  31002. prefixIdentifiers: true,
  31003. // disable optimizations that are unnecessary for ssr
  31004. cacheHandlers: false,
  31005. hoistStatic: false
  31006. });
  31007. const ast = typeof source === "string" ? baseParse(source, options) : source;
  31008. rawOptionsMap.set(ast, options);
  31009. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  31010. hoistStatic: false,
  31011. nodeTransforms: [
  31012. ssrTransformIf,
  31013. ssrTransformFor,
  31014. trackVForSlotScopes,
  31015. transformExpression,
  31016. ssrTransformSlotOutlet,
  31017. ssrInjectFallthroughAttrs,
  31018. ssrInjectCssVars,
  31019. ssrTransformElement,
  31020. ssrTransformComponent,
  31021. trackSlotScopes,
  31022. transformStyle,
  31023. ...options.nodeTransforms || []
  31024. // user transforms
  31025. ],
  31026. directiveTransforms: __spreadValues$7({
  31027. // reusing core v-bind
  31028. bind: transformBind,
  31029. on: transformOn$1,
  31030. // model and show have dedicated SSR handling
  31031. model: ssrTransformModel,
  31032. show: ssrTransformShow,
  31033. // the following are ignored during SSR
  31034. // on: noopDirectiveTransform,
  31035. cloak: noopDirectiveTransform,
  31036. once: noopDirectiveTransform,
  31037. memo: noopDirectiveTransform
  31038. }, options.directiveTransforms || {})
  31039. }));
  31040. ssrCodegenTransform(ast, options);
  31041. return generate(ast, options);
  31042. }
  31043. var CompilerSSR = /*#__PURE__*/Object.freeze({
  31044. __proto__: null,
  31045. compile: compile
  31046. });
  31047. var _polyfillNode_fs = {};
  31048. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  31049. __proto__: null,
  31050. default: _polyfillNode_fs
  31051. });
  31052. var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  31053. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  31054. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  31055. const hasWarned = {};
  31056. function warnOnce$3(msg) {
  31057. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  31058. if (!isNodeProd && true && !hasWarned[msg]) {
  31059. hasWarned[msg] = true;
  31060. warn(msg);
  31061. }
  31062. }
  31063. function warn(msg) {
  31064. console.warn(
  31065. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  31066. `
  31067. );
  31068. }
  31069. var __defProp$6 = Object.defineProperty;
  31070. var __defProps$5 = Object.defineProperties;
  31071. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  31072. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  31073. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  31074. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  31075. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31076. var __spreadValues$6 = (a, b) => {
  31077. for (var prop in b || (b = {}))
  31078. if (__hasOwnProp$6.call(b, prop))
  31079. __defNormalProp$6(a, prop, b[prop]);
  31080. if (__getOwnPropSymbols$6)
  31081. for (var prop of __getOwnPropSymbols$6(b)) {
  31082. if (__propIsEnum$6.call(b, prop))
  31083. __defNormalProp$6(a, prop, b[prop]);
  31084. }
  31085. return a;
  31086. };
  31087. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  31088. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  31089. let res = "";
  31090. let err = null;
  31091. preprocessor.render(
  31092. source,
  31093. __spreadValues$6({ filename }, preprocessOptions),
  31094. (_err, _res) => {
  31095. if (_err)
  31096. err = _err;
  31097. res = _res;
  31098. }
  31099. );
  31100. if (err)
  31101. throw err;
  31102. return res;
  31103. }
  31104. function compileTemplate(options) {
  31105. const { preprocessLang, preprocessCustomRequire } = options;
  31106. if (preprocessLang && !preprocessCustomRequire) {
  31107. throw new Error(
  31108. `[@vue/compiler-sfc] Template preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor in the shape of { render(): string }.`
  31109. );
  31110. }
  31111. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  31112. if (preprocessor) {
  31113. try {
  31114. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  31115. source: preprocess$1(options, preprocessor),
  31116. ast: void 0
  31117. // invalidate AST if template goes through preprocessor
  31118. }));
  31119. } catch (e) {
  31120. return {
  31121. code: `export default function render() {}`,
  31122. source: options.source,
  31123. tips: [],
  31124. errors: [e]
  31125. };
  31126. }
  31127. } else if (preprocessLang) {
  31128. return {
  31129. code: `export default function render() {}`,
  31130. source: options.source,
  31131. tips: [
  31132. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  31133. ],
  31134. errors: [
  31135. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  31136. ]
  31137. };
  31138. } else {
  31139. return doCompileTemplate(options);
  31140. }
  31141. }
  31142. function doCompileTemplate({
  31143. filename,
  31144. id,
  31145. scoped,
  31146. slotted,
  31147. inMap,
  31148. source,
  31149. ast: inAST,
  31150. ssr = false,
  31151. ssrCssVars,
  31152. isProd = false,
  31153. compiler,
  31154. compilerOptions = {},
  31155. transformAssetUrls
  31156. }) {
  31157. const errors = [];
  31158. const warnings = [];
  31159. let nodeTransforms = [];
  31160. if (isObject$2(transformAssetUrls)) {
  31161. const assetOptions = normalizeOptions(transformAssetUrls);
  31162. nodeTransforms = [
  31163. createAssetUrlTransformWithOptions(assetOptions),
  31164. createSrcsetTransformWithOptions(assetOptions)
  31165. ];
  31166. } else if (transformAssetUrls !== false) {
  31167. nodeTransforms = [transformAssetUrl, transformSrcset];
  31168. }
  31169. if (ssr && !ssrCssVars) {
  31170. warnOnce$3(
  31171. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.\`.`
  31172. );
  31173. }
  31174. if (!id) {
  31175. warnOnce$3(`compileTemplate now requires the \`id\` option.\`.`);
  31176. id = "";
  31177. }
  31178. const shortId = id.replace(/^data-v-/, "");
  31179. const longId = `data-v-${shortId}`;
  31180. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  31181. compiler = compiler || defaultCompiler;
  31182. if (compiler !== defaultCompiler) {
  31183. inAST = void 0;
  31184. }
  31185. if (inAST == null ? void 0 : inAST.transformed) {
  31186. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  31187. prefixIdentifiers: true
  31188. }, compilerOptions), {
  31189. parseMode: "sfc",
  31190. onError: (e) => errors.push(e)
  31191. }));
  31192. const template = newAST.children.find(
  31193. (node) => node.type === 1 && node.tag === "template"
  31194. );
  31195. inAST = createRoot(template.children, inAST.source);
  31196. }
  31197. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  31198. mode: "module",
  31199. prefixIdentifiers: true,
  31200. hoistStatic: true,
  31201. cacheHandlers: true,
  31202. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  31203. scopeId: scoped ? longId : void 0,
  31204. slotted,
  31205. sourceMap: true
  31206. }, compilerOptions), {
  31207. hmr: !isProd,
  31208. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  31209. filename,
  31210. onError: (e) => errors.push(e),
  31211. onWarn: (w) => warnings.push(w)
  31212. }));
  31213. if (inMap && !inAST) {
  31214. if (map) {
  31215. map = mapLines(inMap, map);
  31216. }
  31217. if (errors.length) {
  31218. patchErrors(errors, source, inMap);
  31219. }
  31220. }
  31221. const tips = warnings.map((w) => {
  31222. let msg = w.message;
  31223. if (w.loc) {
  31224. msg += `
  31225. ${generateCodeFrame(
  31226. (inAST == null ? void 0 : inAST.source) || source,
  31227. w.loc.start.offset,
  31228. w.loc.end.offset
  31229. )}`;
  31230. }
  31231. return msg;
  31232. });
  31233. return { code, ast, preamble, source, errors, tips, map };
  31234. }
  31235. function mapLines(oldMap, newMap) {
  31236. if (!oldMap)
  31237. return newMap;
  31238. if (!newMap)
  31239. return oldMap;
  31240. const oldMapConsumer = new SourceMapConsumer$5(oldMap);
  31241. const newMapConsumer = new SourceMapConsumer$5(newMap);
  31242. const mergedMapGenerator = new SourceMapGenerator$6();
  31243. newMapConsumer.eachMapping((m) => {
  31244. if (m.originalLine == null) {
  31245. return;
  31246. }
  31247. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  31248. line: m.originalLine,
  31249. column: m.originalColumn
  31250. });
  31251. if (origPosInOldMap.source == null) {
  31252. return;
  31253. }
  31254. mergedMapGenerator.addMapping({
  31255. generated: {
  31256. line: m.generatedLine,
  31257. column: m.generatedColumn
  31258. },
  31259. original: {
  31260. line: origPosInOldMap.line,
  31261. // map line
  31262. // use current column, since the oldMap produced by @vue/compiler-sfc
  31263. // does not
  31264. column: m.originalColumn
  31265. },
  31266. source: origPosInOldMap.source,
  31267. name: origPosInOldMap.name
  31268. });
  31269. });
  31270. const generator = mergedMapGenerator;
  31271. oldMapConsumer.sources.forEach((sourceFile) => {
  31272. generator._sources.add(sourceFile);
  31273. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  31274. if (sourceContent != null) {
  31275. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  31276. }
  31277. });
  31278. generator._sourceRoot = oldMap.sourceRoot;
  31279. generator._file = oldMap.file;
  31280. return generator.toJSON();
  31281. }
  31282. function patchErrors(errors, source, inMap) {
  31283. const originalSource = inMap.sourcesContent[0];
  31284. const offset = originalSource.indexOf(source);
  31285. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  31286. errors.forEach((err) => {
  31287. if (err.loc) {
  31288. err.loc.start.line += lineOffset;
  31289. err.loc.start.offset += offset;
  31290. if (err.loc.end !== err.loc.start) {
  31291. err.loc.end.line += lineOffset;
  31292. err.loc.end.offset += offset;
  31293. }
  31294. }
  31295. });
  31296. }
  31297. var picocolors = {exports: {}};
  31298. // MIT lisence
  31299. // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
  31300. function isatty() {
  31301. return false;
  31302. }
  31303. function ReadStream() {
  31304. throw new Error('tty.ReadStream is not implemented');
  31305. }
  31306. function WriteStream() {
  31307. throw new Error('tty.ReadStream is not implemented');
  31308. }
  31309. var _polyfillNode_tty = {
  31310. isatty: isatty,
  31311. ReadStream: ReadStream,
  31312. WriteStream: WriteStream
  31313. };
  31314. var _polyfillNode_tty$1 = /*#__PURE__*/Object.freeze({
  31315. __proto__: null,
  31316. ReadStream: ReadStream,
  31317. WriteStream: WriteStream,
  31318. default: _polyfillNode_tty,
  31319. isatty: isatty
  31320. });
  31321. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_tty$1);
  31322. let tty = require$$0;
  31323. let isColorSupported =
  31324. !("NO_COLOR" in ({}) || browser$1.argv.includes("--no-color")) &&
  31325. ("FORCE_COLOR" in ({}) ||
  31326. browser$1.argv.includes("--color") ||
  31327. "" === "win32" ||
  31328. (tty.isatty(1) && browser$1.env.TERM !== "dumb") ||
  31329. "CI" in ({}));
  31330. let formatter =
  31331. (open, close, replace = open) =>
  31332. input => {
  31333. let string = "" + input;
  31334. let index = string.indexOf(close, open.length);
  31335. return ~index
  31336. ? open + replaceClose(string, close, replace, index) + close
  31337. : open + string + close
  31338. };
  31339. let replaceClose = (string, close, replace, index) => {
  31340. let start = string.substring(0, index) + replace;
  31341. let end = string.substring(index + close.length);
  31342. let nextIndex = end.indexOf(close);
  31343. return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
  31344. };
  31345. let createColors = (enabled = isColorSupported) => ({
  31346. isColorSupported: enabled,
  31347. reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
  31348. bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
  31349. dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
  31350. italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
  31351. underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
  31352. inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
  31353. hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
  31354. strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
  31355. black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
  31356. red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
  31357. green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
  31358. yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
  31359. blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
  31360. magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
  31361. cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
  31362. white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
  31363. gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
  31364. bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
  31365. bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
  31366. bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
  31367. bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
  31368. bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
  31369. bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
  31370. bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
  31371. bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
  31372. });
  31373. picocolors.exports = createColors();
  31374. picocolors.exports.createColors = createColors;
  31375. var picocolorsExports = picocolors.exports;
  31376. const SINGLE_QUOTE = "'".charCodeAt(0);
  31377. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  31378. const BACKSLASH = '\\'.charCodeAt(0);
  31379. const SLASH = '/'.charCodeAt(0);
  31380. const NEWLINE = '\n'.charCodeAt(0);
  31381. const SPACE = ' '.charCodeAt(0);
  31382. const FEED = '\f'.charCodeAt(0);
  31383. const TAB = '\t'.charCodeAt(0);
  31384. const CR = '\r'.charCodeAt(0);
  31385. const OPEN_SQUARE = '['.charCodeAt(0);
  31386. const CLOSE_SQUARE = ']'.charCodeAt(0);
  31387. const OPEN_PARENTHESES = '('.charCodeAt(0);
  31388. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  31389. const OPEN_CURLY = '{'.charCodeAt(0);
  31390. const CLOSE_CURLY = '}'.charCodeAt(0);
  31391. const SEMICOLON = ';'.charCodeAt(0);
  31392. const ASTERISK = '*'.charCodeAt(0);
  31393. const COLON = ':'.charCodeAt(0);
  31394. const AT = '@'.charCodeAt(0);
  31395. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  31396. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  31397. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  31398. const RE_HEX_ESCAPE = /[\da-f]/i;
  31399. var tokenize$1 = function tokenizer(input, options = {}) {
  31400. let css = input.css.valueOf();
  31401. let ignore = options.ignoreErrors;
  31402. let code, next, quote, content, escape;
  31403. let escaped, escapePos, prev, n, currentToken;
  31404. let length = css.length;
  31405. let pos = 0;
  31406. let buffer = [];
  31407. let returned = [];
  31408. function position() {
  31409. return pos
  31410. }
  31411. function unclosed(what) {
  31412. throw input.error('Unclosed ' + what, pos)
  31413. }
  31414. function endOfFile() {
  31415. return returned.length === 0 && pos >= length
  31416. }
  31417. function nextToken(opts) {
  31418. if (returned.length) return returned.pop()
  31419. if (pos >= length) return
  31420. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  31421. code = css.charCodeAt(pos);
  31422. switch (code) {
  31423. case NEWLINE:
  31424. case SPACE:
  31425. case TAB:
  31426. case CR:
  31427. case FEED: {
  31428. next = pos;
  31429. do {
  31430. next += 1;
  31431. code = css.charCodeAt(next);
  31432. } while (
  31433. code === SPACE ||
  31434. code === NEWLINE ||
  31435. code === TAB ||
  31436. code === CR ||
  31437. code === FEED
  31438. )
  31439. currentToken = ['space', css.slice(pos, next)];
  31440. pos = next - 1;
  31441. break
  31442. }
  31443. case OPEN_SQUARE:
  31444. case CLOSE_SQUARE:
  31445. case OPEN_CURLY:
  31446. case CLOSE_CURLY:
  31447. case COLON:
  31448. case SEMICOLON:
  31449. case CLOSE_PARENTHESES: {
  31450. let controlChar = String.fromCharCode(code);
  31451. currentToken = [controlChar, controlChar, pos];
  31452. break
  31453. }
  31454. case OPEN_PARENTHESES: {
  31455. prev = buffer.length ? buffer.pop()[1] : '';
  31456. n = css.charCodeAt(pos + 1);
  31457. if (
  31458. prev === 'url' &&
  31459. n !== SINGLE_QUOTE &&
  31460. n !== DOUBLE_QUOTE &&
  31461. n !== SPACE &&
  31462. n !== NEWLINE &&
  31463. n !== TAB &&
  31464. n !== FEED &&
  31465. n !== CR
  31466. ) {
  31467. next = pos;
  31468. do {
  31469. escaped = false;
  31470. next = css.indexOf(')', next + 1);
  31471. if (next === -1) {
  31472. if (ignore || ignoreUnclosed) {
  31473. next = pos;
  31474. break
  31475. } else {
  31476. unclosed('bracket');
  31477. }
  31478. }
  31479. escapePos = next;
  31480. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31481. escapePos -= 1;
  31482. escaped = !escaped;
  31483. }
  31484. } while (escaped)
  31485. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  31486. pos = next;
  31487. } else {
  31488. next = css.indexOf(')', pos + 1);
  31489. content = css.slice(pos, next + 1);
  31490. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  31491. currentToken = ['(', '(', pos];
  31492. } else {
  31493. currentToken = ['brackets', content, pos, next];
  31494. pos = next;
  31495. }
  31496. }
  31497. break
  31498. }
  31499. case SINGLE_QUOTE:
  31500. case DOUBLE_QUOTE: {
  31501. quote = code === SINGLE_QUOTE ? "'" : '"';
  31502. next = pos;
  31503. do {
  31504. escaped = false;
  31505. next = css.indexOf(quote, next + 1);
  31506. if (next === -1) {
  31507. if (ignore || ignoreUnclosed) {
  31508. next = pos + 1;
  31509. break
  31510. } else {
  31511. unclosed('string');
  31512. }
  31513. }
  31514. escapePos = next;
  31515. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31516. escapePos -= 1;
  31517. escaped = !escaped;
  31518. }
  31519. } while (escaped)
  31520. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  31521. pos = next;
  31522. break
  31523. }
  31524. case AT: {
  31525. RE_AT_END.lastIndex = pos + 1;
  31526. RE_AT_END.test(css);
  31527. if (RE_AT_END.lastIndex === 0) {
  31528. next = css.length - 1;
  31529. } else {
  31530. next = RE_AT_END.lastIndex - 2;
  31531. }
  31532. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  31533. pos = next;
  31534. break
  31535. }
  31536. case BACKSLASH: {
  31537. next = pos;
  31538. escape = true;
  31539. while (css.charCodeAt(next + 1) === BACKSLASH) {
  31540. next += 1;
  31541. escape = !escape;
  31542. }
  31543. code = css.charCodeAt(next + 1);
  31544. if (
  31545. escape &&
  31546. code !== SLASH &&
  31547. code !== SPACE &&
  31548. code !== NEWLINE &&
  31549. code !== TAB &&
  31550. code !== CR &&
  31551. code !== FEED
  31552. ) {
  31553. next += 1;
  31554. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  31555. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  31556. next += 1;
  31557. }
  31558. if (css.charCodeAt(next + 1) === SPACE) {
  31559. next += 1;
  31560. }
  31561. }
  31562. }
  31563. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31564. pos = next;
  31565. break
  31566. }
  31567. default: {
  31568. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  31569. next = css.indexOf('*/', pos + 2) + 1;
  31570. if (next === 0) {
  31571. if (ignore || ignoreUnclosed) {
  31572. next = css.length;
  31573. } else {
  31574. unclosed('comment');
  31575. }
  31576. }
  31577. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  31578. pos = next;
  31579. } else {
  31580. RE_WORD_END.lastIndex = pos + 1;
  31581. RE_WORD_END.test(css);
  31582. if (RE_WORD_END.lastIndex === 0) {
  31583. next = css.length - 1;
  31584. } else {
  31585. next = RE_WORD_END.lastIndex - 2;
  31586. }
  31587. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31588. buffer.push(currentToken);
  31589. pos = next;
  31590. }
  31591. break
  31592. }
  31593. }
  31594. pos++;
  31595. return currentToken
  31596. }
  31597. function back(token) {
  31598. returned.push(token);
  31599. }
  31600. return {
  31601. back,
  31602. endOfFile,
  31603. nextToken,
  31604. position
  31605. }
  31606. };
  31607. let pico$1 = picocolorsExports;
  31608. let tokenizer$1 = tokenize$1;
  31609. let Input$5;
  31610. function registerInput(dependant) {
  31611. Input$5 = dependant;
  31612. }
  31613. const HIGHLIGHT_THEME = {
  31614. ';': pico$1.yellow,
  31615. ':': pico$1.yellow,
  31616. '(': pico$1.cyan,
  31617. ')': pico$1.cyan,
  31618. '[': pico$1.yellow,
  31619. ']': pico$1.yellow,
  31620. '{': pico$1.yellow,
  31621. '}': pico$1.yellow,
  31622. 'at-word': pico$1.cyan,
  31623. 'brackets': pico$1.cyan,
  31624. 'call': pico$1.cyan,
  31625. 'class': pico$1.yellow,
  31626. 'comment': pico$1.gray,
  31627. 'hash': pico$1.magenta,
  31628. 'string': pico$1.green
  31629. };
  31630. function getTokenType([type, value], processor) {
  31631. if (type === 'word') {
  31632. if (value[0] === '.') {
  31633. return 'class'
  31634. }
  31635. if (value[0] === '#') {
  31636. return 'hash'
  31637. }
  31638. }
  31639. if (!processor.endOfFile()) {
  31640. let next = processor.nextToken();
  31641. processor.back(next);
  31642. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  31643. }
  31644. return type
  31645. }
  31646. function terminalHighlight$2(css) {
  31647. let processor = tokenizer$1(new Input$5(css), { ignoreErrors: true });
  31648. let result = '';
  31649. while (!processor.endOfFile()) {
  31650. let token = processor.nextToken();
  31651. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  31652. if (color) {
  31653. result += token[1]
  31654. .split(/\r?\n/)
  31655. .map(i => color(i))
  31656. .join('\n');
  31657. } else {
  31658. result += token[1];
  31659. }
  31660. }
  31661. return result
  31662. }
  31663. terminalHighlight$2.registerInput = registerInput;
  31664. var terminalHighlight_1 = terminalHighlight$2;
  31665. let pico = picocolorsExports;
  31666. let terminalHighlight$1 = terminalHighlight_1;
  31667. let CssSyntaxError$3 = class CssSyntaxError extends Error {
  31668. constructor(message, line, column, source, file, plugin) {
  31669. super(message);
  31670. this.name = 'CssSyntaxError';
  31671. this.reason = message;
  31672. if (file) {
  31673. this.file = file;
  31674. }
  31675. if (source) {
  31676. this.source = source;
  31677. }
  31678. if (plugin) {
  31679. this.plugin = plugin;
  31680. }
  31681. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  31682. if (typeof line === 'number') {
  31683. this.line = line;
  31684. this.column = column;
  31685. } else {
  31686. this.line = line.line;
  31687. this.column = line.column;
  31688. this.endLine = column.line;
  31689. this.endColumn = column.column;
  31690. }
  31691. }
  31692. this.setMessage();
  31693. if (Error.captureStackTrace) {
  31694. Error.captureStackTrace(this, CssSyntaxError);
  31695. }
  31696. }
  31697. setMessage() {
  31698. this.message = this.plugin ? this.plugin + ': ' : '';
  31699. this.message += this.file ? this.file : '<css input>';
  31700. if (typeof this.line !== 'undefined') {
  31701. this.message += ':' + this.line + ':' + this.column;
  31702. }
  31703. this.message += ': ' + this.reason;
  31704. }
  31705. showSourceCode(color) {
  31706. if (!this.source) return ''
  31707. let css = this.source;
  31708. if (color == null) color = pico.isColorSupported;
  31709. if (terminalHighlight$1) {
  31710. if (color) css = terminalHighlight$1(css);
  31711. }
  31712. let lines = css.split(/\r?\n/);
  31713. let start = Math.max(this.line - 3, 0);
  31714. let end = Math.min(this.line + 2, lines.length);
  31715. let maxWidth = String(end).length;
  31716. let mark, aside;
  31717. if (color) {
  31718. let { bold, gray, red } = pico.createColors(true);
  31719. mark = text => bold(red(text));
  31720. aside = text => gray(text);
  31721. } else {
  31722. mark = aside = str => str;
  31723. }
  31724. return lines
  31725. .slice(start, end)
  31726. .map((line, index) => {
  31727. let number = start + 1 + index;
  31728. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  31729. if (number === this.line) {
  31730. let spacing =
  31731. aside(gutter.replace(/\d/g, ' ')) +
  31732. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  31733. return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
  31734. }
  31735. return ' ' + aside(gutter) + line
  31736. })
  31737. .join('\n')
  31738. }
  31739. toString() {
  31740. let code = this.showSourceCode();
  31741. if (code) {
  31742. code = '\n\n' + code + '\n';
  31743. }
  31744. return this.name + ': ' + this.message + code
  31745. }
  31746. };
  31747. var cssSyntaxError = CssSyntaxError$3;
  31748. CssSyntaxError$3.default = CssSyntaxError$3;
  31749. var symbols = {};
  31750. symbols.isClean = Symbol('isClean');
  31751. symbols.my = Symbol('my');
  31752. const DEFAULT_RAW = {
  31753. after: '\n',
  31754. beforeClose: '\n',
  31755. beforeComment: '\n',
  31756. beforeDecl: '\n',
  31757. beforeOpen: ' ',
  31758. beforeRule: '\n',
  31759. colon: ': ',
  31760. commentLeft: ' ',
  31761. commentRight: ' ',
  31762. emptyBody: '',
  31763. indent: ' ',
  31764. semicolon: false
  31765. };
  31766. function capitalize(str) {
  31767. return str[0].toUpperCase() + str.slice(1)
  31768. }
  31769. let Stringifier$2 = class Stringifier {
  31770. constructor(builder) {
  31771. this.builder = builder;
  31772. }
  31773. atrule(node, semicolon) {
  31774. let name = '@' + node.name;
  31775. let params = node.params ? this.rawValue(node, 'params') : '';
  31776. if (typeof node.raws.afterName !== 'undefined') {
  31777. name += node.raws.afterName;
  31778. } else if (params) {
  31779. name += ' ';
  31780. }
  31781. if (node.nodes) {
  31782. this.block(node, name + params);
  31783. } else {
  31784. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  31785. this.builder(name + params + end, node);
  31786. }
  31787. }
  31788. beforeAfter(node, detect) {
  31789. let value;
  31790. if (node.type === 'decl') {
  31791. value = this.raw(node, null, 'beforeDecl');
  31792. } else if (node.type === 'comment') {
  31793. value = this.raw(node, null, 'beforeComment');
  31794. } else if (detect === 'before') {
  31795. value = this.raw(node, null, 'beforeRule');
  31796. } else {
  31797. value = this.raw(node, null, 'beforeClose');
  31798. }
  31799. let buf = node.parent;
  31800. let depth = 0;
  31801. while (buf && buf.type !== 'root') {
  31802. depth += 1;
  31803. buf = buf.parent;
  31804. }
  31805. if (value.includes('\n')) {
  31806. let indent = this.raw(node, null, 'indent');
  31807. if (indent.length) {
  31808. for (let step = 0; step < depth; step++) value += indent;
  31809. }
  31810. }
  31811. return value
  31812. }
  31813. block(node, start) {
  31814. let between = this.raw(node, 'between', 'beforeOpen');
  31815. this.builder(start + between + '{', node, 'start');
  31816. let after;
  31817. if (node.nodes && node.nodes.length) {
  31818. this.body(node);
  31819. after = this.raw(node, 'after');
  31820. } else {
  31821. after = this.raw(node, 'after', 'emptyBody');
  31822. }
  31823. if (after) this.builder(after);
  31824. this.builder('}', node, 'end');
  31825. }
  31826. body(node) {
  31827. let last = node.nodes.length - 1;
  31828. while (last > 0) {
  31829. if (node.nodes[last].type !== 'comment') break
  31830. last -= 1;
  31831. }
  31832. let semicolon = this.raw(node, 'semicolon');
  31833. for (let i = 0; i < node.nodes.length; i++) {
  31834. let child = node.nodes[i];
  31835. let before = this.raw(child, 'before');
  31836. if (before) this.builder(before);
  31837. this.stringify(child, last !== i || semicolon);
  31838. }
  31839. }
  31840. comment(node) {
  31841. let left = this.raw(node, 'left', 'commentLeft');
  31842. let right = this.raw(node, 'right', 'commentRight');
  31843. this.builder('/*' + left + node.text + right + '*/', node);
  31844. }
  31845. decl(node, semicolon) {
  31846. let between = this.raw(node, 'between', 'colon');
  31847. let string = node.prop + between + this.rawValue(node, 'value');
  31848. if (node.important) {
  31849. string += node.raws.important || ' !important';
  31850. }
  31851. if (semicolon) string += ';';
  31852. this.builder(string, node);
  31853. }
  31854. document(node) {
  31855. this.body(node);
  31856. }
  31857. raw(node, own, detect) {
  31858. let value;
  31859. if (!detect) detect = own;
  31860. // Already had
  31861. if (own) {
  31862. value = node.raws[own];
  31863. if (typeof value !== 'undefined') return value
  31864. }
  31865. let parent = node.parent;
  31866. if (detect === 'before') {
  31867. // Hack for first rule in CSS
  31868. if (!parent || (parent.type === 'root' && parent.first === node)) {
  31869. return ''
  31870. }
  31871. // `root` nodes in `document` should use only their own raws
  31872. if (parent && parent.type === 'document') {
  31873. return ''
  31874. }
  31875. }
  31876. // Floating child without parent
  31877. if (!parent) return DEFAULT_RAW[detect]
  31878. // Detect style by other nodes
  31879. let root = node.root();
  31880. if (!root.rawCache) root.rawCache = {};
  31881. if (typeof root.rawCache[detect] !== 'undefined') {
  31882. return root.rawCache[detect]
  31883. }
  31884. if (detect === 'before' || detect === 'after') {
  31885. return this.beforeAfter(node, detect)
  31886. } else {
  31887. let method = 'raw' + capitalize(detect);
  31888. if (this[method]) {
  31889. value = this[method](root, node);
  31890. } else {
  31891. root.walk(i => {
  31892. value = i.raws[own];
  31893. if (typeof value !== 'undefined') return false
  31894. });
  31895. }
  31896. }
  31897. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  31898. root.rawCache[detect] = value;
  31899. return value
  31900. }
  31901. rawBeforeClose(root) {
  31902. let value;
  31903. root.walk(i => {
  31904. if (i.nodes && i.nodes.length > 0) {
  31905. if (typeof i.raws.after !== 'undefined') {
  31906. value = i.raws.after;
  31907. if (value.includes('\n')) {
  31908. value = value.replace(/[^\n]+$/, '');
  31909. }
  31910. return false
  31911. }
  31912. }
  31913. });
  31914. if (value) value = value.replace(/\S/g, '');
  31915. return value
  31916. }
  31917. rawBeforeComment(root, node) {
  31918. let value;
  31919. root.walkComments(i => {
  31920. if (typeof i.raws.before !== 'undefined') {
  31921. value = i.raws.before;
  31922. if (value.includes('\n')) {
  31923. value = value.replace(/[^\n]+$/, '');
  31924. }
  31925. return false
  31926. }
  31927. });
  31928. if (typeof value === 'undefined') {
  31929. value = this.raw(node, null, 'beforeDecl');
  31930. } else if (value) {
  31931. value = value.replace(/\S/g, '');
  31932. }
  31933. return value
  31934. }
  31935. rawBeforeDecl(root, node) {
  31936. let value;
  31937. root.walkDecls(i => {
  31938. if (typeof i.raws.before !== 'undefined') {
  31939. value = i.raws.before;
  31940. if (value.includes('\n')) {
  31941. value = value.replace(/[^\n]+$/, '');
  31942. }
  31943. return false
  31944. }
  31945. });
  31946. if (typeof value === 'undefined') {
  31947. value = this.raw(node, null, 'beforeRule');
  31948. } else if (value) {
  31949. value = value.replace(/\S/g, '');
  31950. }
  31951. return value
  31952. }
  31953. rawBeforeOpen(root) {
  31954. let value;
  31955. root.walk(i => {
  31956. if (i.type !== 'decl') {
  31957. value = i.raws.between;
  31958. if (typeof value !== 'undefined') return false
  31959. }
  31960. });
  31961. return value
  31962. }
  31963. rawBeforeRule(root) {
  31964. let value;
  31965. root.walk(i => {
  31966. if (i.nodes && (i.parent !== root || root.first !== i)) {
  31967. if (typeof i.raws.before !== 'undefined') {
  31968. value = i.raws.before;
  31969. if (value.includes('\n')) {
  31970. value = value.replace(/[^\n]+$/, '');
  31971. }
  31972. return false
  31973. }
  31974. }
  31975. });
  31976. if (value) value = value.replace(/\S/g, '');
  31977. return value
  31978. }
  31979. rawColon(root) {
  31980. let value;
  31981. root.walkDecls(i => {
  31982. if (typeof i.raws.between !== 'undefined') {
  31983. value = i.raws.between.replace(/[^\s:]/g, '');
  31984. return false
  31985. }
  31986. });
  31987. return value
  31988. }
  31989. rawEmptyBody(root) {
  31990. let value;
  31991. root.walk(i => {
  31992. if (i.nodes && i.nodes.length === 0) {
  31993. value = i.raws.after;
  31994. if (typeof value !== 'undefined') return false
  31995. }
  31996. });
  31997. return value
  31998. }
  31999. rawIndent(root) {
  32000. if (root.raws.indent) return root.raws.indent
  32001. let value;
  32002. root.walk(i => {
  32003. let p = i.parent;
  32004. if (p && p !== root && p.parent && p.parent === root) {
  32005. if (typeof i.raws.before !== 'undefined') {
  32006. let parts = i.raws.before.split('\n');
  32007. value = parts[parts.length - 1];
  32008. value = value.replace(/\S/g, '');
  32009. return false
  32010. }
  32011. }
  32012. });
  32013. return value
  32014. }
  32015. rawSemicolon(root) {
  32016. let value;
  32017. root.walk(i => {
  32018. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  32019. value = i.raws.semicolon;
  32020. if (typeof value !== 'undefined') return false
  32021. }
  32022. });
  32023. return value
  32024. }
  32025. rawValue(node, prop) {
  32026. let value = node[prop];
  32027. let raw = node.raws[prop];
  32028. if (raw && raw.value === value) {
  32029. return raw.raw
  32030. }
  32031. return value
  32032. }
  32033. root(node) {
  32034. this.body(node);
  32035. if (node.raws.after) this.builder(node.raws.after);
  32036. }
  32037. rule(node) {
  32038. this.block(node, this.rawValue(node, 'selector'));
  32039. if (node.raws.ownSemicolon) {
  32040. this.builder(node.raws.ownSemicolon, node, 'end');
  32041. }
  32042. }
  32043. stringify(node, semicolon) {
  32044. /* c8 ignore start */
  32045. if (!this[node.type]) {
  32046. throw new Error(
  32047. 'Unknown AST node type ' +
  32048. node.type +
  32049. '. ' +
  32050. 'Maybe you need to change PostCSS stringifier.'
  32051. )
  32052. }
  32053. /* c8 ignore stop */
  32054. this[node.type](node, semicolon);
  32055. }
  32056. };
  32057. var stringifier = Stringifier$2;
  32058. Stringifier$2.default = Stringifier$2;
  32059. let Stringifier$1 = stringifier;
  32060. function stringify$4(node, builder) {
  32061. let str = new Stringifier$1(builder);
  32062. str.stringify(node);
  32063. }
  32064. var stringify_1 = stringify$4;
  32065. stringify$4.default = stringify$4;
  32066. let { isClean: isClean$2, my: my$2 } = symbols;
  32067. let CssSyntaxError$2 = cssSyntaxError;
  32068. let Stringifier = stringifier;
  32069. let stringify$3 = stringify_1;
  32070. function cloneNode(obj, parent) {
  32071. let cloned = new obj.constructor();
  32072. for (let i in obj) {
  32073. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  32074. /* c8 ignore next 2 */
  32075. continue
  32076. }
  32077. if (i === 'proxyCache') continue
  32078. let value = obj[i];
  32079. let type = typeof value;
  32080. if (i === 'parent' && type === 'object') {
  32081. if (parent) cloned[i] = parent;
  32082. } else if (i === 'source') {
  32083. cloned[i] = value;
  32084. } else if (Array.isArray(value)) {
  32085. cloned[i] = value.map(j => cloneNode(j, cloned));
  32086. } else {
  32087. if (type === 'object' && value !== null) value = cloneNode(value);
  32088. cloned[i] = value;
  32089. }
  32090. }
  32091. return cloned
  32092. }
  32093. let Node$4 = class Node {
  32094. constructor(defaults = {}) {
  32095. this.raws = {};
  32096. this[isClean$2] = false;
  32097. this[my$2] = true;
  32098. for (let name in defaults) {
  32099. if (name === 'nodes') {
  32100. this.nodes = [];
  32101. for (let node of defaults[name]) {
  32102. if (typeof node.clone === 'function') {
  32103. this.append(node.clone());
  32104. } else {
  32105. this.append(node);
  32106. }
  32107. }
  32108. } else {
  32109. this[name] = defaults[name];
  32110. }
  32111. }
  32112. }
  32113. addToError(error) {
  32114. error.postcssNode = this;
  32115. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  32116. let s = this.source;
  32117. error.stack = error.stack.replace(
  32118. /\n\s{4}at /,
  32119. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  32120. );
  32121. }
  32122. return error
  32123. }
  32124. after(add) {
  32125. this.parent.insertAfter(this, add);
  32126. return this
  32127. }
  32128. assign(overrides = {}) {
  32129. for (let name in overrides) {
  32130. this[name] = overrides[name];
  32131. }
  32132. return this
  32133. }
  32134. before(add) {
  32135. this.parent.insertBefore(this, add);
  32136. return this
  32137. }
  32138. cleanRaws(keepBetween) {
  32139. delete this.raws.before;
  32140. delete this.raws.after;
  32141. if (!keepBetween) delete this.raws.between;
  32142. }
  32143. clone(overrides = {}) {
  32144. let cloned = cloneNode(this);
  32145. for (let name in overrides) {
  32146. cloned[name] = overrides[name];
  32147. }
  32148. return cloned
  32149. }
  32150. cloneAfter(overrides = {}) {
  32151. let cloned = this.clone(overrides);
  32152. this.parent.insertAfter(this, cloned);
  32153. return cloned
  32154. }
  32155. cloneBefore(overrides = {}) {
  32156. let cloned = this.clone(overrides);
  32157. this.parent.insertBefore(this, cloned);
  32158. return cloned
  32159. }
  32160. error(message, opts = {}) {
  32161. if (this.source) {
  32162. let { end, start } = this.rangeBy(opts);
  32163. return this.source.input.error(
  32164. message,
  32165. { column: start.column, line: start.line },
  32166. { column: end.column, line: end.line },
  32167. opts
  32168. )
  32169. }
  32170. return new CssSyntaxError$2(message)
  32171. }
  32172. getProxyProcessor() {
  32173. return {
  32174. get(node, prop) {
  32175. if (prop === 'proxyOf') {
  32176. return node
  32177. } else if (prop === 'root') {
  32178. return () => node.root().toProxy()
  32179. } else {
  32180. return node[prop]
  32181. }
  32182. },
  32183. set(node, prop, value) {
  32184. if (node[prop] === value) return true
  32185. node[prop] = value;
  32186. if (
  32187. prop === 'prop' ||
  32188. prop === 'value' ||
  32189. prop === 'name' ||
  32190. prop === 'params' ||
  32191. prop === 'important' ||
  32192. /* c8 ignore next */
  32193. prop === 'text'
  32194. ) {
  32195. node.markDirty();
  32196. }
  32197. return true
  32198. }
  32199. }
  32200. }
  32201. markDirty() {
  32202. if (this[isClean$2]) {
  32203. this[isClean$2] = false;
  32204. let next = this;
  32205. while ((next = next.parent)) {
  32206. next[isClean$2] = false;
  32207. }
  32208. }
  32209. }
  32210. next() {
  32211. if (!this.parent) return undefined
  32212. let index = this.parent.index(this);
  32213. return this.parent.nodes[index + 1]
  32214. }
  32215. positionBy(opts, stringRepresentation) {
  32216. let pos = this.source.start;
  32217. if (opts.index) {
  32218. pos = this.positionInside(opts.index, stringRepresentation);
  32219. } else if (opts.word) {
  32220. stringRepresentation = this.toString();
  32221. let index = stringRepresentation.indexOf(opts.word);
  32222. if (index !== -1) pos = this.positionInside(index, stringRepresentation);
  32223. }
  32224. return pos
  32225. }
  32226. positionInside(index, stringRepresentation) {
  32227. let string = stringRepresentation || this.toString();
  32228. let column = this.source.start.column;
  32229. let line = this.source.start.line;
  32230. for (let i = 0; i < index; i++) {
  32231. if (string[i] === '\n') {
  32232. column = 1;
  32233. line += 1;
  32234. } else {
  32235. column += 1;
  32236. }
  32237. }
  32238. return { column, line }
  32239. }
  32240. prev() {
  32241. if (!this.parent) return undefined
  32242. let index = this.parent.index(this);
  32243. return this.parent.nodes[index - 1]
  32244. }
  32245. rangeBy(opts) {
  32246. let start = {
  32247. column: this.source.start.column,
  32248. line: this.source.start.line
  32249. };
  32250. let end = this.source.end
  32251. ? {
  32252. column: this.source.end.column + 1,
  32253. line: this.source.end.line
  32254. }
  32255. : {
  32256. column: start.column + 1,
  32257. line: start.line
  32258. };
  32259. if (opts.word) {
  32260. let stringRepresentation = this.toString();
  32261. let index = stringRepresentation.indexOf(opts.word);
  32262. if (index !== -1) {
  32263. start = this.positionInside(index, stringRepresentation);
  32264. end = this.positionInside(index + opts.word.length, stringRepresentation);
  32265. }
  32266. } else {
  32267. if (opts.start) {
  32268. start = {
  32269. column: opts.start.column,
  32270. line: opts.start.line
  32271. };
  32272. } else if (opts.index) {
  32273. start = this.positionInside(opts.index);
  32274. }
  32275. if (opts.end) {
  32276. end = {
  32277. column: opts.end.column,
  32278. line: opts.end.line
  32279. };
  32280. } else if (typeof opts.endIndex === 'number') {
  32281. end = this.positionInside(opts.endIndex);
  32282. } else if (opts.index) {
  32283. end = this.positionInside(opts.index + 1);
  32284. }
  32285. }
  32286. if (
  32287. end.line < start.line ||
  32288. (end.line === start.line && end.column <= start.column)
  32289. ) {
  32290. end = { column: start.column + 1, line: start.line };
  32291. }
  32292. return { end, start }
  32293. }
  32294. raw(prop, defaultType) {
  32295. let str = new Stringifier();
  32296. return str.raw(this, prop, defaultType)
  32297. }
  32298. remove() {
  32299. if (this.parent) {
  32300. this.parent.removeChild(this);
  32301. }
  32302. this.parent = undefined;
  32303. return this
  32304. }
  32305. replaceWith(...nodes) {
  32306. if (this.parent) {
  32307. let bookmark = this;
  32308. let foundSelf = false;
  32309. for (let node of nodes) {
  32310. if (node === this) {
  32311. foundSelf = true;
  32312. } else if (foundSelf) {
  32313. this.parent.insertAfter(bookmark, node);
  32314. bookmark = node;
  32315. } else {
  32316. this.parent.insertBefore(bookmark, node);
  32317. }
  32318. }
  32319. if (!foundSelf) {
  32320. this.remove();
  32321. }
  32322. }
  32323. return this
  32324. }
  32325. root() {
  32326. let result = this;
  32327. while (result.parent && result.parent.type !== 'document') {
  32328. result = result.parent;
  32329. }
  32330. return result
  32331. }
  32332. toJSON(_, inputs) {
  32333. let fixed = {};
  32334. let emitInputs = inputs == null;
  32335. inputs = inputs || new Map();
  32336. let inputsNextIndex = 0;
  32337. for (let name in this) {
  32338. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  32339. /* c8 ignore next 2 */
  32340. continue
  32341. }
  32342. if (name === 'parent' || name === 'proxyCache') continue
  32343. let value = this[name];
  32344. if (Array.isArray(value)) {
  32345. fixed[name] = value.map(i => {
  32346. if (typeof i === 'object' && i.toJSON) {
  32347. return i.toJSON(null, inputs)
  32348. } else {
  32349. return i
  32350. }
  32351. });
  32352. } else if (typeof value === 'object' && value.toJSON) {
  32353. fixed[name] = value.toJSON(null, inputs);
  32354. } else if (name === 'source') {
  32355. let inputId = inputs.get(value.input);
  32356. if (inputId == null) {
  32357. inputId = inputsNextIndex;
  32358. inputs.set(value.input, inputsNextIndex);
  32359. inputsNextIndex++;
  32360. }
  32361. fixed[name] = {
  32362. end: value.end,
  32363. inputId,
  32364. start: value.start
  32365. };
  32366. } else {
  32367. fixed[name] = value;
  32368. }
  32369. }
  32370. if (emitInputs) {
  32371. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  32372. }
  32373. return fixed
  32374. }
  32375. toProxy() {
  32376. if (!this.proxyCache) {
  32377. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  32378. }
  32379. return this.proxyCache
  32380. }
  32381. toString(stringifier = stringify$3) {
  32382. if (stringifier.stringify) stringifier = stringifier.stringify;
  32383. let result = '';
  32384. stringifier(this, i => {
  32385. result += i;
  32386. });
  32387. return result
  32388. }
  32389. warn(result, text, opts) {
  32390. let data = { node: this };
  32391. for (let i in opts) data[i] = opts[i];
  32392. return result.warn(text, data)
  32393. }
  32394. get proxyOf() {
  32395. return this
  32396. }
  32397. };
  32398. var node$2 = Node$4;
  32399. Node$4.default = Node$4;
  32400. let Node$3 = node$2;
  32401. let Declaration$4 = class Declaration extends Node$3 {
  32402. constructor(defaults) {
  32403. if (
  32404. defaults &&
  32405. typeof defaults.value !== 'undefined' &&
  32406. typeof defaults.value !== 'string'
  32407. ) {
  32408. defaults = { ...defaults, value: String(defaults.value) };
  32409. }
  32410. super(defaults);
  32411. this.type = 'decl';
  32412. }
  32413. get variable() {
  32414. return this.prop.startsWith('--') || this.prop[0] === '$'
  32415. }
  32416. };
  32417. var declaration = Declaration$4;
  32418. Declaration$4.default = Declaration$4;
  32419. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  32420. let urlAlphabet =
  32421. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  32422. let customAlphabet = (alphabet, defaultSize = 21) => {
  32423. return (size = defaultSize) => {
  32424. let id = '';
  32425. let i = size;
  32426. while (i--) {
  32427. id += alphabet[(Math.random() * alphabet.length) | 0];
  32428. }
  32429. return id
  32430. }
  32431. };
  32432. let nanoid$1 = (size = 21) => {
  32433. let id = '';
  32434. let i = size;
  32435. while (i--) {
  32436. id += urlAlphabet[(Math.random() * 64) | 0];
  32437. }
  32438. return id
  32439. };
  32440. var nonSecure = { nanoid: nanoid$1, customAlphabet };
  32441. let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
  32442. let { existsSync, readFileSync } = require$$0$2;
  32443. let { dirname: dirname$1, join } = require$$1;
  32444. function fromBase64(str) {
  32445. if (Buffer$1) {
  32446. return Buffer$1.from(str, 'base64').toString()
  32447. } else {
  32448. /* c8 ignore next 2 */
  32449. return window.atob(str)
  32450. }
  32451. }
  32452. let PreviousMap$2 = class PreviousMap {
  32453. constructor(css, opts) {
  32454. if (opts.map === false) return
  32455. this.loadAnnotation(css);
  32456. this.inline = this.startWith(this.annotation, 'data:');
  32457. let prev = opts.map ? opts.map.prev : undefined;
  32458. let text = this.loadMap(opts.from, prev);
  32459. if (!this.mapFile && opts.from) {
  32460. this.mapFile = opts.from;
  32461. }
  32462. if (this.mapFile) this.root = dirname$1(this.mapFile);
  32463. if (text) this.text = text;
  32464. }
  32465. consumer() {
  32466. if (!this.consumerCache) {
  32467. this.consumerCache = new SourceMapConsumer$4(this.text);
  32468. }
  32469. return this.consumerCache
  32470. }
  32471. decodeInline(text) {
  32472. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  32473. let baseUri = /^data:application\/json;base64,/;
  32474. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  32475. let uri = /^data:application\/json,/;
  32476. if (charsetUri.test(text) || uri.test(text)) {
  32477. return decodeURIComponent(text.substr(RegExp.lastMatch.length))
  32478. }
  32479. if (baseCharsetUri.test(text) || baseUri.test(text)) {
  32480. return fromBase64(text.substr(RegExp.lastMatch.length))
  32481. }
  32482. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  32483. throw new Error('Unsupported source map encoding ' + encoding)
  32484. }
  32485. getAnnotationURL(sourceMapString) {
  32486. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  32487. }
  32488. isMap(map) {
  32489. if (typeof map !== 'object') return false
  32490. return (
  32491. typeof map.mappings === 'string' ||
  32492. typeof map._mappings === 'string' ||
  32493. Array.isArray(map.sections)
  32494. )
  32495. }
  32496. loadAnnotation(css) {
  32497. let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
  32498. if (!comments) return
  32499. // sourceMappingURLs from comments, strings, etc.
  32500. let start = css.lastIndexOf(comments.pop());
  32501. let end = css.indexOf('*/', start);
  32502. if (start > -1 && end > -1) {
  32503. // Locate the last sourceMappingURL to avoid pickin
  32504. this.annotation = this.getAnnotationURL(css.substring(start, end));
  32505. }
  32506. }
  32507. loadFile(path) {
  32508. this.root = dirname$1(path);
  32509. if (existsSync(path)) {
  32510. this.mapFile = path;
  32511. return readFileSync(path, 'utf-8').toString().trim()
  32512. }
  32513. }
  32514. loadMap(file, prev) {
  32515. if (prev === false) return false
  32516. if (prev) {
  32517. if (typeof prev === 'string') {
  32518. return prev
  32519. } else if (typeof prev === 'function') {
  32520. let prevPath = prev(file);
  32521. if (prevPath) {
  32522. let map = this.loadFile(prevPath);
  32523. if (!map) {
  32524. throw new Error(
  32525. 'Unable to load previous source map: ' + prevPath.toString()
  32526. )
  32527. }
  32528. return map
  32529. }
  32530. } else if (prev instanceof SourceMapConsumer$4) {
  32531. return SourceMapGenerator$5.fromSourceMap(prev).toString()
  32532. } else if (prev instanceof SourceMapGenerator$5) {
  32533. return prev.toString()
  32534. } else if (this.isMap(prev)) {
  32535. return JSON.stringify(prev)
  32536. } else {
  32537. throw new Error(
  32538. 'Unsupported previous source map format: ' + prev.toString()
  32539. )
  32540. }
  32541. } else if (this.inline) {
  32542. return this.decodeInline(this.annotation)
  32543. } else if (this.annotation) {
  32544. let map = this.annotation;
  32545. if (file) map = join(dirname$1(file), map);
  32546. return this.loadFile(map)
  32547. }
  32548. }
  32549. startWith(string, start) {
  32550. if (!string) return false
  32551. return string.substr(0, start.length) === start
  32552. }
  32553. withContent() {
  32554. return !!(
  32555. this.consumer().sourcesContent &&
  32556. this.consumer().sourcesContent.length > 0
  32557. )
  32558. }
  32559. };
  32560. var previousMap = PreviousMap$2;
  32561. PreviousMap$2.default = PreviousMap$2;
  32562. let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
  32563. let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
  32564. let { isAbsolute, resolve: resolve$1 } = require$$1;
  32565. let { nanoid } = nonSecure;
  32566. let terminalHighlight = terminalHighlight_1;
  32567. let CssSyntaxError$1 = cssSyntaxError;
  32568. let PreviousMap$1 = previousMap;
  32569. let fromOffsetCache = Symbol('fromOffsetCache');
  32570. let sourceMapAvailable$1 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$4);
  32571. let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
  32572. let Input$4 = class Input {
  32573. constructor(css, opts = {}) {
  32574. if (
  32575. css === null ||
  32576. typeof css === 'undefined' ||
  32577. (typeof css === 'object' && !css.toString)
  32578. ) {
  32579. throw new Error(`PostCSS received ${css} instead of CSS string`)
  32580. }
  32581. this.css = css.toString();
  32582. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  32583. this.hasBOM = true;
  32584. this.css = this.css.slice(1);
  32585. } else {
  32586. this.hasBOM = false;
  32587. }
  32588. if (opts.from) {
  32589. if (
  32590. !pathAvailable$1 ||
  32591. /^\w+:\/\//.test(opts.from) ||
  32592. isAbsolute(opts.from)
  32593. ) {
  32594. this.file = opts.from;
  32595. } else {
  32596. this.file = resolve$1(opts.from);
  32597. }
  32598. }
  32599. if (pathAvailable$1 && sourceMapAvailable$1) {
  32600. let map = new PreviousMap$1(this.css, opts);
  32601. if (map.text) {
  32602. this.map = map;
  32603. let file = map.consumer().file;
  32604. if (!this.file && file) this.file = this.mapResolve(file);
  32605. }
  32606. }
  32607. if (!this.file) {
  32608. this.id = '<input css ' + nanoid(6) + '>';
  32609. }
  32610. if (this.map) this.map.file = this.from;
  32611. }
  32612. error(message, line, column, opts = {}) {
  32613. let result, endLine, endColumn;
  32614. if (line && typeof line === 'object') {
  32615. let start = line;
  32616. let end = column;
  32617. if (typeof start.offset === 'number') {
  32618. let pos = this.fromOffset(start.offset);
  32619. line = pos.line;
  32620. column = pos.col;
  32621. } else {
  32622. line = start.line;
  32623. column = start.column;
  32624. }
  32625. if (typeof end.offset === 'number') {
  32626. let pos = this.fromOffset(end.offset);
  32627. endLine = pos.line;
  32628. endColumn = pos.col;
  32629. } else {
  32630. endLine = end.line;
  32631. endColumn = end.column;
  32632. }
  32633. } else if (!column) {
  32634. let pos = this.fromOffset(line);
  32635. line = pos.line;
  32636. column = pos.col;
  32637. }
  32638. let origin = this.origin(line, column, endLine, endColumn);
  32639. if (origin) {
  32640. result = new CssSyntaxError$1(
  32641. message,
  32642. origin.endLine === undefined
  32643. ? origin.line
  32644. : { column: origin.column, line: origin.line },
  32645. origin.endLine === undefined
  32646. ? origin.column
  32647. : { column: origin.endColumn, line: origin.endLine },
  32648. origin.source,
  32649. origin.file,
  32650. opts.plugin
  32651. );
  32652. } else {
  32653. result = new CssSyntaxError$1(
  32654. message,
  32655. endLine === undefined ? line : { column, line },
  32656. endLine === undefined ? column : { column: endColumn, line: endLine },
  32657. this.css,
  32658. this.file,
  32659. opts.plugin
  32660. );
  32661. }
  32662. result.input = { column, endColumn, endLine, line, source: this.css };
  32663. if (this.file) {
  32664. if (pathToFileURL$1) {
  32665. result.input.url = pathToFileURL$1(this.file).toString();
  32666. }
  32667. result.input.file = this.file;
  32668. }
  32669. return result
  32670. }
  32671. fromOffset(offset) {
  32672. let lastLine, lineToIndex;
  32673. if (!this[fromOffsetCache]) {
  32674. let lines = this.css.split('\n');
  32675. lineToIndex = new Array(lines.length);
  32676. let prevIndex = 0;
  32677. for (let i = 0, l = lines.length; i < l; i++) {
  32678. lineToIndex[i] = prevIndex;
  32679. prevIndex += lines[i].length + 1;
  32680. }
  32681. this[fromOffsetCache] = lineToIndex;
  32682. } else {
  32683. lineToIndex = this[fromOffsetCache];
  32684. }
  32685. lastLine = lineToIndex[lineToIndex.length - 1];
  32686. let min = 0;
  32687. if (offset >= lastLine) {
  32688. min = lineToIndex.length - 1;
  32689. } else {
  32690. let max = lineToIndex.length - 2;
  32691. let mid;
  32692. while (min < max) {
  32693. mid = min + ((max - min) >> 1);
  32694. if (offset < lineToIndex[mid]) {
  32695. max = mid - 1;
  32696. } else if (offset >= lineToIndex[mid + 1]) {
  32697. min = mid + 1;
  32698. } else {
  32699. min = mid;
  32700. break
  32701. }
  32702. }
  32703. }
  32704. return {
  32705. col: offset - lineToIndex[min] + 1,
  32706. line: min + 1
  32707. }
  32708. }
  32709. mapResolve(file) {
  32710. if (/^\w+:\/\//.test(file)) {
  32711. return file
  32712. }
  32713. return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
  32714. }
  32715. origin(line, column, endLine, endColumn) {
  32716. if (!this.map) return false
  32717. let consumer = this.map.consumer();
  32718. let from = consumer.originalPositionFor({ column, line });
  32719. if (!from.source) return false
  32720. let to;
  32721. if (typeof endLine === 'number') {
  32722. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  32723. }
  32724. let fromUrl;
  32725. if (isAbsolute(from.source)) {
  32726. fromUrl = pathToFileURL$1(from.source);
  32727. } else {
  32728. fromUrl = new URL(
  32729. from.source,
  32730. this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
  32731. );
  32732. }
  32733. let result = {
  32734. column: from.column,
  32735. endColumn: to && to.column,
  32736. endLine: to && to.line,
  32737. line: from.line,
  32738. url: fromUrl.toString()
  32739. };
  32740. if (fromUrl.protocol === 'file:') {
  32741. if (fileURLToPath) {
  32742. result.file = fileURLToPath(fromUrl);
  32743. } else {
  32744. /* c8 ignore next 2 */
  32745. throw new Error(`file: protocol is not available in this PostCSS build`)
  32746. }
  32747. }
  32748. let source = consumer.sourceContentFor(from.source);
  32749. if (source) result.source = source;
  32750. return result
  32751. }
  32752. toJSON() {
  32753. let json = {};
  32754. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  32755. if (this[name] != null) {
  32756. json[name] = this[name];
  32757. }
  32758. }
  32759. if (this.map) {
  32760. json.map = { ...this.map };
  32761. if (json.map.consumerCache) {
  32762. json.map.consumerCache = undefined;
  32763. }
  32764. }
  32765. return json
  32766. }
  32767. get from() {
  32768. return this.file || this.id
  32769. }
  32770. };
  32771. var input = Input$4;
  32772. Input$4.default = Input$4;
  32773. if (terminalHighlight && terminalHighlight.registerInput) {
  32774. terminalHighlight.registerInput(Input$4);
  32775. }
  32776. let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
  32777. let { dirname, relative, resolve, sep } = require$$1;
  32778. let { pathToFileURL } = require$$2;
  32779. let Input$3 = input;
  32780. let sourceMapAvailable = Boolean(SourceMapConsumer$2 && SourceMapGenerator$3);
  32781. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  32782. let MapGenerator$2 = class MapGenerator {
  32783. constructor(stringify, root, opts, cssString) {
  32784. this.stringify = stringify;
  32785. this.mapOpts = opts.map || {};
  32786. this.root = root;
  32787. this.opts = opts;
  32788. this.css = cssString;
  32789. this.originalCSS = cssString;
  32790. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  32791. this.memoizedFileURLs = new Map();
  32792. this.memoizedPaths = new Map();
  32793. this.memoizedURLs = new Map();
  32794. }
  32795. addAnnotation() {
  32796. let content;
  32797. if (this.isInline()) {
  32798. content =
  32799. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  32800. } else if (typeof this.mapOpts.annotation === 'string') {
  32801. content = this.mapOpts.annotation;
  32802. } else if (typeof this.mapOpts.annotation === 'function') {
  32803. content = this.mapOpts.annotation(this.opts.to, this.root);
  32804. } else {
  32805. content = this.outputFile() + '.map';
  32806. }
  32807. let eol = '\n';
  32808. if (this.css.includes('\r\n')) eol = '\r\n';
  32809. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  32810. }
  32811. applyPrevMaps() {
  32812. for (let prev of this.previous()) {
  32813. let from = this.toUrl(this.path(prev.file));
  32814. let root = prev.root || dirname(prev.file);
  32815. let map;
  32816. if (this.mapOpts.sourcesContent === false) {
  32817. map = new SourceMapConsumer$2(prev.text);
  32818. if (map.sourcesContent) {
  32819. map.sourcesContent = null;
  32820. }
  32821. } else {
  32822. map = prev.consumer();
  32823. }
  32824. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  32825. }
  32826. }
  32827. clearAnnotation() {
  32828. if (this.mapOpts.annotation === false) return
  32829. if (this.root) {
  32830. let node;
  32831. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  32832. node = this.root.nodes[i];
  32833. if (node.type !== 'comment') continue
  32834. if (node.text.indexOf('# sourceMappingURL=') === 0) {
  32835. this.root.removeChild(i);
  32836. }
  32837. }
  32838. } else if (this.css) {
  32839. this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '');
  32840. }
  32841. }
  32842. generate() {
  32843. this.clearAnnotation();
  32844. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  32845. return this.generateMap()
  32846. } else {
  32847. let result = '';
  32848. this.stringify(this.root, i => {
  32849. result += i;
  32850. });
  32851. return [result]
  32852. }
  32853. }
  32854. generateMap() {
  32855. if (this.root) {
  32856. this.generateString();
  32857. } else if (this.previous().length === 1) {
  32858. let prev = this.previous()[0].consumer();
  32859. prev.file = this.outputFile();
  32860. this.map = SourceMapGenerator$3.fromSourceMap(prev, {
  32861. ignoreInvalidMapping: true
  32862. });
  32863. } else {
  32864. this.map = new SourceMapGenerator$3({
  32865. file: this.outputFile(),
  32866. ignoreInvalidMapping: true
  32867. });
  32868. this.map.addMapping({
  32869. generated: { column: 0, line: 1 },
  32870. original: { column: 0, line: 1 },
  32871. source: this.opts.from
  32872. ? this.toUrl(this.path(this.opts.from))
  32873. : '<no source>'
  32874. });
  32875. }
  32876. if (this.isSourcesContent()) this.setSourcesContent();
  32877. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  32878. if (this.isAnnotation()) this.addAnnotation();
  32879. if (this.isInline()) {
  32880. return [this.css]
  32881. } else {
  32882. return [this.css, this.map]
  32883. }
  32884. }
  32885. generateString() {
  32886. this.css = '';
  32887. this.map = new SourceMapGenerator$3({
  32888. file: this.outputFile(),
  32889. ignoreInvalidMapping: true
  32890. });
  32891. let line = 1;
  32892. let column = 1;
  32893. let noSource = '<no source>';
  32894. let mapping = {
  32895. generated: { column: 0, line: 0 },
  32896. original: { column: 0, line: 0 },
  32897. source: ''
  32898. };
  32899. let lines, last;
  32900. this.stringify(this.root, (str, node, type) => {
  32901. this.css += str;
  32902. if (node && type !== 'end') {
  32903. mapping.generated.line = line;
  32904. mapping.generated.column = column - 1;
  32905. if (node.source && node.source.start) {
  32906. mapping.source = this.sourcePath(node);
  32907. mapping.original.line = node.source.start.line;
  32908. mapping.original.column = node.source.start.column - 1;
  32909. this.map.addMapping(mapping);
  32910. } else {
  32911. mapping.source = noSource;
  32912. mapping.original.line = 1;
  32913. mapping.original.column = 0;
  32914. this.map.addMapping(mapping);
  32915. }
  32916. }
  32917. lines = str.match(/\n/g);
  32918. if (lines) {
  32919. line += lines.length;
  32920. last = str.lastIndexOf('\n');
  32921. column = str.length - last;
  32922. } else {
  32923. column += str.length;
  32924. }
  32925. if (node && type !== 'start') {
  32926. let p = node.parent || { raws: {} };
  32927. let childless =
  32928. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  32929. if (!childless || node !== p.last || p.raws.semicolon) {
  32930. if (node.source && node.source.end) {
  32931. mapping.source = this.sourcePath(node);
  32932. mapping.original.line = node.source.end.line;
  32933. mapping.original.column = node.source.end.column - 1;
  32934. mapping.generated.line = line;
  32935. mapping.generated.column = column - 2;
  32936. this.map.addMapping(mapping);
  32937. } else {
  32938. mapping.source = noSource;
  32939. mapping.original.line = 1;
  32940. mapping.original.column = 0;
  32941. mapping.generated.line = line;
  32942. mapping.generated.column = column - 1;
  32943. this.map.addMapping(mapping);
  32944. }
  32945. }
  32946. }
  32947. });
  32948. }
  32949. isAnnotation() {
  32950. if (this.isInline()) {
  32951. return true
  32952. }
  32953. if (typeof this.mapOpts.annotation !== 'undefined') {
  32954. return this.mapOpts.annotation
  32955. }
  32956. if (this.previous().length) {
  32957. return this.previous().some(i => i.annotation)
  32958. }
  32959. return true
  32960. }
  32961. isInline() {
  32962. if (typeof this.mapOpts.inline !== 'undefined') {
  32963. return this.mapOpts.inline
  32964. }
  32965. let annotation = this.mapOpts.annotation;
  32966. if (typeof annotation !== 'undefined' && annotation !== true) {
  32967. return false
  32968. }
  32969. if (this.previous().length) {
  32970. return this.previous().some(i => i.inline)
  32971. }
  32972. return true
  32973. }
  32974. isMap() {
  32975. if (typeof this.opts.map !== 'undefined') {
  32976. return !!this.opts.map
  32977. }
  32978. return this.previous().length > 0
  32979. }
  32980. isSourcesContent() {
  32981. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  32982. return this.mapOpts.sourcesContent
  32983. }
  32984. if (this.previous().length) {
  32985. return this.previous().some(i => i.withContent())
  32986. }
  32987. return true
  32988. }
  32989. outputFile() {
  32990. if (this.opts.to) {
  32991. return this.path(this.opts.to)
  32992. } else if (this.opts.from) {
  32993. return this.path(this.opts.from)
  32994. } else {
  32995. return 'to.css'
  32996. }
  32997. }
  32998. path(file) {
  32999. if (this.mapOpts.absolute) return file
  33000. if (file.charCodeAt(0) === 60 /* `<` */) return file
  33001. if (/^\w+:\/\//.test(file)) return file
  33002. let cached = this.memoizedPaths.get(file);
  33003. if (cached) return cached
  33004. let from = this.opts.to ? dirname(this.opts.to) : '.';
  33005. if (typeof this.mapOpts.annotation === 'string') {
  33006. from = dirname(resolve(from, this.mapOpts.annotation));
  33007. }
  33008. let path = relative(from, file);
  33009. this.memoizedPaths.set(file, path);
  33010. return path
  33011. }
  33012. previous() {
  33013. if (!this.previousMaps) {
  33014. this.previousMaps = [];
  33015. if (this.root) {
  33016. this.root.walk(node => {
  33017. if (node.source && node.source.input.map) {
  33018. let map = node.source.input.map;
  33019. if (!this.previousMaps.includes(map)) {
  33020. this.previousMaps.push(map);
  33021. }
  33022. }
  33023. });
  33024. } else {
  33025. let input = new Input$3(this.originalCSS, this.opts);
  33026. if (input.map) this.previousMaps.push(input.map);
  33027. }
  33028. }
  33029. return this.previousMaps
  33030. }
  33031. setSourcesContent() {
  33032. let already = {};
  33033. if (this.root) {
  33034. this.root.walk(node => {
  33035. if (node.source) {
  33036. let from = node.source.input.from;
  33037. if (from && !already[from]) {
  33038. already[from] = true;
  33039. let fromUrl = this.usesFileUrls
  33040. ? this.toFileUrl(from)
  33041. : this.toUrl(this.path(from));
  33042. this.map.setSourceContent(fromUrl, node.source.input.css);
  33043. }
  33044. }
  33045. });
  33046. } else if (this.css) {
  33047. let from = this.opts.from
  33048. ? this.toUrl(this.path(this.opts.from))
  33049. : '<no source>';
  33050. this.map.setSourceContent(from, this.css);
  33051. }
  33052. }
  33053. sourcePath(node) {
  33054. if (this.mapOpts.from) {
  33055. return this.toUrl(this.mapOpts.from)
  33056. } else if (this.usesFileUrls) {
  33057. return this.toFileUrl(node.source.input.from)
  33058. } else {
  33059. return this.toUrl(this.path(node.source.input.from))
  33060. }
  33061. }
  33062. toBase64(str) {
  33063. if (Buffer$1) {
  33064. return Buffer$1.from(str).toString('base64')
  33065. } else {
  33066. return window.btoa(unescape(encodeURIComponent(str)))
  33067. }
  33068. }
  33069. toFileUrl(path) {
  33070. let cached = this.memoizedFileURLs.get(path);
  33071. if (cached) return cached
  33072. if (pathToFileURL) {
  33073. let fileURL = pathToFileURL(path).toString();
  33074. this.memoizedFileURLs.set(path, fileURL);
  33075. return fileURL
  33076. } else {
  33077. throw new Error(
  33078. '`map.absolute` option is not available in this PostCSS build'
  33079. )
  33080. }
  33081. }
  33082. toUrl(path) {
  33083. let cached = this.memoizedURLs.get(path);
  33084. if (cached) return cached
  33085. if (sep === '\\') {
  33086. path = path.replace(/\\/g, '/');
  33087. }
  33088. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  33089. this.memoizedURLs.set(path, url);
  33090. return url
  33091. }
  33092. };
  33093. var mapGenerator = MapGenerator$2;
  33094. let Node$2 = node$2;
  33095. let Comment$4 = class Comment extends Node$2 {
  33096. constructor(defaults) {
  33097. super(defaults);
  33098. this.type = 'comment';
  33099. }
  33100. };
  33101. var comment$3 = Comment$4;
  33102. Comment$4.default = Comment$4;
  33103. let { isClean: isClean$1, my: my$1 } = symbols;
  33104. let Declaration$3 = declaration;
  33105. let Comment$3 = comment$3;
  33106. let Node$1 = node$2;
  33107. let parse$4, Rule$4, AtRule$4, Root$6;
  33108. function cleanSource(nodes) {
  33109. return nodes.map(i => {
  33110. if (i.nodes) i.nodes = cleanSource(i.nodes);
  33111. delete i.source;
  33112. return i
  33113. })
  33114. }
  33115. function markDirtyUp(node) {
  33116. node[isClean$1] = false;
  33117. if (node.proxyOf.nodes) {
  33118. for (let i of node.proxyOf.nodes) {
  33119. markDirtyUp(i);
  33120. }
  33121. }
  33122. }
  33123. let Container$7 = class Container extends Node$1 {
  33124. append(...children) {
  33125. for (let child of children) {
  33126. let nodes = this.normalize(child, this.last);
  33127. for (let node of nodes) this.proxyOf.nodes.push(node);
  33128. }
  33129. this.markDirty();
  33130. return this
  33131. }
  33132. cleanRaws(keepBetween) {
  33133. super.cleanRaws(keepBetween);
  33134. if (this.nodes) {
  33135. for (let node of this.nodes) node.cleanRaws(keepBetween);
  33136. }
  33137. }
  33138. each(callback) {
  33139. if (!this.proxyOf.nodes) return undefined
  33140. let iterator = this.getIterator();
  33141. let index, result;
  33142. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33143. index = this.indexes[iterator];
  33144. result = callback(this.proxyOf.nodes[index], index);
  33145. if (result === false) break
  33146. this.indexes[iterator] += 1;
  33147. }
  33148. delete this.indexes[iterator];
  33149. return result
  33150. }
  33151. every(condition) {
  33152. return this.nodes.every(condition)
  33153. }
  33154. getIterator() {
  33155. if (!this.lastEach) this.lastEach = 0;
  33156. if (!this.indexes) this.indexes = {};
  33157. this.lastEach += 1;
  33158. let iterator = this.lastEach;
  33159. this.indexes[iterator] = 0;
  33160. return iterator
  33161. }
  33162. getProxyProcessor() {
  33163. return {
  33164. get(node, prop) {
  33165. if (prop === 'proxyOf') {
  33166. return node
  33167. } else if (!node[prop]) {
  33168. return node[prop]
  33169. } else if (
  33170. prop === 'each' ||
  33171. (typeof prop === 'string' && prop.startsWith('walk'))
  33172. ) {
  33173. return (...args) => {
  33174. return node[prop](
  33175. ...args.map(i => {
  33176. if (typeof i === 'function') {
  33177. return (child, index) => i(child.toProxy(), index)
  33178. } else {
  33179. return i
  33180. }
  33181. })
  33182. )
  33183. }
  33184. } else if (prop === 'every' || prop === 'some') {
  33185. return cb => {
  33186. return node[prop]((child, ...other) =>
  33187. cb(child.toProxy(), ...other)
  33188. )
  33189. }
  33190. } else if (prop === 'root') {
  33191. return () => node.root().toProxy()
  33192. } else if (prop === 'nodes') {
  33193. return node.nodes.map(i => i.toProxy())
  33194. } else if (prop === 'first' || prop === 'last') {
  33195. return node[prop].toProxy()
  33196. } else {
  33197. return node[prop]
  33198. }
  33199. },
  33200. set(node, prop, value) {
  33201. if (node[prop] === value) return true
  33202. node[prop] = value;
  33203. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33204. node.markDirty();
  33205. }
  33206. return true
  33207. }
  33208. }
  33209. }
  33210. index(child) {
  33211. if (typeof child === 'number') return child
  33212. if (child.proxyOf) child = child.proxyOf;
  33213. return this.proxyOf.nodes.indexOf(child)
  33214. }
  33215. insertAfter(exist, add) {
  33216. let existIndex = this.index(exist);
  33217. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33218. existIndex = this.index(exist);
  33219. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33220. let index;
  33221. for (let id in this.indexes) {
  33222. index = this.indexes[id];
  33223. if (existIndex < index) {
  33224. this.indexes[id] = index + nodes.length;
  33225. }
  33226. }
  33227. this.markDirty();
  33228. return this
  33229. }
  33230. insertBefore(exist, add) {
  33231. let existIndex = this.index(exist);
  33232. let type = existIndex === 0 ? 'prepend' : false;
  33233. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
  33234. existIndex = this.index(exist);
  33235. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33236. let index;
  33237. for (let id in this.indexes) {
  33238. index = this.indexes[id];
  33239. if (existIndex <= index) {
  33240. this.indexes[id] = index + nodes.length;
  33241. }
  33242. }
  33243. this.markDirty();
  33244. return this
  33245. }
  33246. normalize(nodes, sample) {
  33247. if (typeof nodes === 'string') {
  33248. nodes = cleanSource(parse$4(nodes).nodes);
  33249. } else if (typeof nodes === 'undefined') {
  33250. nodes = [];
  33251. } else if (Array.isArray(nodes)) {
  33252. nodes = nodes.slice(0);
  33253. for (let i of nodes) {
  33254. if (i.parent) i.parent.removeChild(i, 'ignore');
  33255. }
  33256. } else if (nodes.type === 'root' && this.type !== 'document') {
  33257. nodes = nodes.nodes.slice(0);
  33258. for (let i of nodes) {
  33259. if (i.parent) i.parent.removeChild(i, 'ignore');
  33260. }
  33261. } else if (nodes.type) {
  33262. nodes = [nodes];
  33263. } else if (nodes.prop) {
  33264. if (typeof nodes.value === 'undefined') {
  33265. throw new Error('Value field is missed in node creation')
  33266. } else if (typeof nodes.value !== 'string') {
  33267. nodes.value = String(nodes.value);
  33268. }
  33269. nodes = [new Declaration$3(nodes)];
  33270. } else if (nodes.selector) {
  33271. nodes = [new Rule$4(nodes)];
  33272. } else if (nodes.name) {
  33273. nodes = [new AtRule$4(nodes)];
  33274. } else if (nodes.text) {
  33275. nodes = [new Comment$3(nodes)];
  33276. } else {
  33277. throw new Error('Unknown node type in node creation')
  33278. }
  33279. let processed = nodes.map(i => {
  33280. /* c8 ignore next */
  33281. if (!i[my$1]) Container.rebuild(i);
  33282. i = i.proxyOf;
  33283. if (i.parent) i.parent.removeChild(i);
  33284. if (i[isClean$1]) markDirtyUp(i);
  33285. if (typeof i.raws.before === 'undefined') {
  33286. if (sample && typeof sample.raws.before !== 'undefined') {
  33287. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33288. }
  33289. }
  33290. i.parent = this.proxyOf;
  33291. return i
  33292. });
  33293. return processed
  33294. }
  33295. prepend(...children) {
  33296. children = children.reverse();
  33297. for (let child of children) {
  33298. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33299. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33300. for (let id in this.indexes) {
  33301. this.indexes[id] = this.indexes[id] + nodes.length;
  33302. }
  33303. }
  33304. this.markDirty();
  33305. return this
  33306. }
  33307. push(child) {
  33308. child.parent = this;
  33309. this.proxyOf.nodes.push(child);
  33310. return this
  33311. }
  33312. removeAll() {
  33313. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33314. this.proxyOf.nodes = [];
  33315. this.markDirty();
  33316. return this
  33317. }
  33318. removeChild(child) {
  33319. child = this.index(child);
  33320. this.proxyOf.nodes[child].parent = undefined;
  33321. this.proxyOf.nodes.splice(child, 1);
  33322. let index;
  33323. for (let id in this.indexes) {
  33324. index = this.indexes[id];
  33325. if (index >= child) {
  33326. this.indexes[id] = index - 1;
  33327. }
  33328. }
  33329. this.markDirty();
  33330. return this
  33331. }
  33332. replaceValues(pattern, opts, callback) {
  33333. if (!callback) {
  33334. callback = opts;
  33335. opts = {};
  33336. }
  33337. this.walkDecls(decl => {
  33338. if (opts.props && !opts.props.includes(decl.prop)) return
  33339. if (opts.fast && !decl.value.includes(opts.fast)) return
  33340. decl.value = decl.value.replace(pattern, callback);
  33341. });
  33342. this.markDirty();
  33343. return this
  33344. }
  33345. some(condition) {
  33346. return this.nodes.some(condition)
  33347. }
  33348. walk(callback) {
  33349. return this.each((child, i) => {
  33350. let result;
  33351. try {
  33352. result = callback(child, i);
  33353. } catch (e) {
  33354. throw child.addToError(e)
  33355. }
  33356. if (result !== false && child.walk) {
  33357. result = child.walk(callback);
  33358. }
  33359. return result
  33360. })
  33361. }
  33362. walkAtRules(name, callback) {
  33363. if (!callback) {
  33364. callback = name;
  33365. return this.walk((child, i) => {
  33366. if (child.type === 'atrule') {
  33367. return callback(child, i)
  33368. }
  33369. })
  33370. }
  33371. if (name instanceof RegExp) {
  33372. return this.walk((child, i) => {
  33373. if (child.type === 'atrule' && name.test(child.name)) {
  33374. return callback(child, i)
  33375. }
  33376. })
  33377. }
  33378. return this.walk((child, i) => {
  33379. if (child.type === 'atrule' && child.name === name) {
  33380. return callback(child, i)
  33381. }
  33382. })
  33383. }
  33384. walkComments(callback) {
  33385. return this.walk((child, i) => {
  33386. if (child.type === 'comment') {
  33387. return callback(child, i)
  33388. }
  33389. })
  33390. }
  33391. walkDecls(prop, callback) {
  33392. if (!callback) {
  33393. callback = prop;
  33394. return this.walk((child, i) => {
  33395. if (child.type === 'decl') {
  33396. return callback(child, i)
  33397. }
  33398. })
  33399. }
  33400. if (prop instanceof RegExp) {
  33401. return this.walk((child, i) => {
  33402. if (child.type === 'decl' && prop.test(child.prop)) {
  33403. return callback(child, i)
  33404. }
  33405. })
  33406. }
  33407. return this.walk((child, i) => {
  33408. if (child.type === 'decl' && child.prop === prop) {
  33409. return callback(child, i)
  33410. }
  33411. })
  33412. }
  33413. walkRules(selector, callback) {
  33414. if (!callback) {
  33415. callback = selector;
  33416. return this.walk((child, i) => {
  33417. if (child.type === 'rule') {
  33418. return callback(child, i)
  33419. }
  33420. })
  33421. }
  33422. if (selector instanceof RegExp) {
  33423. return this.walk((child, i) => {
  33424. if (child.type === 'rule' && selector.test(child.selector)) {
  33425. return callback(child, i)
  33426. }
  33427. })
  33428. }
  33429. return this.walk((child, i) => {
  33430. if (child.type === 'rule' && child.selector === selector) {
  33431. return callback(child, i)
  33432. }
  33433. })
  33434. }
  33435. get first() {
  33436. if (!this.proxyOf.nodes) return undefined
  33437. return this.proxyOf.nodes[0]
  33438. }
  33439. get last() {
  33440. if (!this.proxyOf.nodes) return undefined
  33441. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33442. }
  33443. };
  33444. Container$7.registerParse = dependant => {
  33445. parse$4 = dependant;
  33446. };
  33447. Container$7.registerRule = dependant => {
  33448. Rule$4 = dependant;
  33449. };
  33450. Container$7.registerAtRule = dependant => {
  33451. AtRule$4 = dependant;
  33452. };
  33453. Container$7.registerRoot = dependant => {
  33454. Root$6 = dependant;
  33455. };
  33456. var container$1 = Container$7;
  33457. Container$7.default = Container$7;
  33458. /* c8 ignore start */
  33459. Container$7.rebuild = node => {
  33460. if (node.type === 'atrule') {
  33461. Object.setPrototypeOf(node, AtRule$4.prototype);
  33462. } else if (node.type === 'rule') {
  33463. Object.setPrototypeOf(node, Rule$4.prototype);
  33464. } else if (node.type === 'decl') {
  33465. Object.setPrototypeOf(node, Declaration$3.prototype);
  33466. } else if (node.type === 'comment') {
  33467. Object.setPrototypeOf(node, Comment$3.prototype);
  33468. } else if (node.type === 'root') {
  33469. Object.setPrototypeOf(node, Root$6.prototype);
  33470. }
  33471. node[my$1] = true;
  33472. if (node.nodes) {
  33473. node.nodes.forEach(child => {
  33474. Container$7.rebuild(child);
  33475. });
  33476. }
  33477. };
  33478. let Container$6 = container$1;
  33479. let LazyResult$4, Processor$3;
  33480. let Document$3 = class Document extends Container$6 {
  33481. constructor(defaults) {
  33482. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  33483. super({ type: 'document', ...defaults });
  33484. if (!this.nodes) {
  33485. this.nodes = [];
  33486. }
  33487. }
  33488. toResult(opts = {}) {
  33489. let lazy = new LazyResult$4(new Processor$3(), this, opts);
  33490. return lazy.stringify()
  33491. }
  33492. };
  33493. Document$3.registerLazyResult = dependant => {
  33494. LazyResult$4 = dependant;
  33495. };
  33496. Document$3.registerProcessor = dependant => {
  33497. Processor$3 = dependant;
  33498. };
  33499. var document = Document$3;
  33500. Document$3.default = Document$3;
  33501. /* eslint-disable no-console */
  33502. let printed = {};
  33503. var warnOnce$2 = function warnOnce(message) {
  33504. if (printed[message]) return
  33505. printed[message] = true;
  33506. if (typeof console !== 'undefined' && console.warn) {
  33507. console.warn(message);
  33508. }
  33509. };
  33510. let Warning$2 = class Warning {
  33511. constructor(text, opts = {}) {
  33512. this.type = 'warning';
  33513. this.text = text;
  33514. if (opts.node && opts.node.source) {
  33515. let range = opts.node.rangeBy(opts);
  33516. this.line = range.start.line;
  33517. this.column = range.start.column;
  33518. this.endLine = range.end.line;
  33519. this.endColumn = range.end.column;
  33520. }
  33521. for (let opt in opts) this[opt] = opts[opt];
  33522. }
  33523. toString() {
  33524. if (this.node) {
  33525. return this.node.error(this.text, {
  33526. index: this.index,
  33527. plugin: this.plugin,
  33528. word: this.word
  33529. }).message
  33530. }
  33531. if (this.plugin) {
  33532. return this.plugin + ': ' + this.text
  33533. }
  33534. return this.text
  33535. }
  33536. };
  33537. var warning = Warning$2;
  33538. Warning$2.default = Warning$2;
  33539. let Warning$1 = warning;
  33540. let Result$3 = class Result {
  33541. constructor(processor, root, opts) {
  33542. this.processor = processor;
  33543. this.messages = [];
  33544. this.root = root;
  33545. this.opts = opts;
  33546. this.css = undefined;
  33547. this.map = undefined;
  33548. }
  33549. toString() {
  33550. return this.css
  33551. }
  33552. warn(text, opts = {}) {
  33553. if (!opts.plugin) {
  33554. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  33555. opts.plugin = this.lastPlugin.postcssPlugin;
  33556. }
  33557. }
  33558. let warning = new Warning$1(text, opts);
  33559. this.messages.push(warning);
  33560. return warning
  33561. }
  33562. warnings() {
  33563. return this.messages.filter(i => i.type === 'warning')
  33564. }
  33565. get content() {
  33566. return this.css
  33567. }
  33568. };
  33569. var result = Result$3;
  33570. Result$3.default = Result$3;
  33571. let Container$5 = container$1;
  33572. let AtRule$3 = class AtRule extends Container$5 {
  33573. constructor(defaults) {
  33574. super(defaults);
  33575. this.type = 'atrule';
  33576. }
  33577. append(...children) {
  33578. if (!this.proxyOf.nodes) this.nodes = [];
  33579. return super.append(...children)
  33580. }
  33581. prepend(...children) {
  33582. if (!this.proxyOf.nodes) this.nodes = [];
  33583. return super.prepend(...children)
  33584. }
  33585. };
  33586. var atRule = AtRule$3;
  33587. AtRule$3.default = AtRule$3;
  33588. Container$5.registerAtRule(AtRule$3);
  33589. let Container$4 = container$1;
  33590. let LazyResult$3, Processor$2;
  33591. let Root$5 = class Root extends Container$4 {
  33592. constructor(defaults) {
  33593. super(defaults);
  33594. this.type = 'root';
  33595. if (!this.nodes) this.nodes = [];
  33596. }
  33597. normalize(child, sample, type) {
  33598. let nodes = super.normalize(child);
  33599. if (sample) {
  33600. if (type === 'prepend') {
  33601. if (this.nodes.length > 1) {
  33602. sample.raws.before = this.nodes[1].raws.before;
  33603. } else {
  33604. delete sample.raws.before;
  33605. }
  33606. } else if (this.first !== sample) {
  33607. for (let node of nodes) {
  33608. node.raws.before = sample.raws.before;
  33609. }
  33610. }
  33611. }
  33612. return nodes
  33613. }
  33614. removeChild(child, ignore) {
  33615. let index = this.index(child);
  33616. if (!ignore && index === 0 && this.nodes.length > 1) {
  33617. this.nodes[1].raws.before = this.nodes[index].raws.before;
  33618. }
  33619. return super.removeChild(child)
  33620. }
  33621. toResult(opts = {}) {
  33622. let lazy = new LazyResult$3(new Processor$2(), this, opts);
  33623. return lazy.stringify()
  33624. }
  33625. };
  33626. Root$5.registerLazyResult = dependant => {
  33627. LazyResult$3 = dependant;
  33628. };
  33629. Root$5.registerProcessor = dependant => {
  33630. Processor$2 = dependant;
  33631. };
  33632. var root$2 = Root$5;
  33633. Root$5.default = Root$5;
  33634. Container$4.registerRoot(Root$5);
  33635. let list$2 = {
  33636. comma(string) {
  33637. return list$2.split(string, [','], true)
  33638. },
  33639. space(string) {
  33640. let spaces = [' ', '\n', '\t'];
  33641. return list$2.split(string, spaces)
  33642. },
  33643. split(string, separators, last) {
  33644. let array = [];
  33645. let current = '';
  33646. let split = false;
  33647. let func = 0;
  33648. let inQuote = false;
  33649. let prevQuote = '';
  33650. let escape = false;
  33651. for (let letter of string) {
  33652. if (escape) {
  33653. escape = false;
  33654. } else if (letter === '\\') {
  33655. escape = true;
  33656. } else if (inQuote) {
  33657. if (letter === prevQuote) {
  33658. inQuote = false;
  33659. }
  33660. } else if (letter === '"' || letter === "'") {
  33661. inQuote = true;
  33662. prevQuote = letter;
  33663. } else if (letter === '(') {
  33664. func += 1;
  33665. } else if (letter === ')') {
  33666. if (func > 0) func -= 1;
  33667. } else if (func === 0) {
  33668. if (separators.includes(letter)) split = true;
  33669. }
  33670. if (split) {
  33671. if (current !== '') array.push(current.trim());
  33672. current = '';
  33673. split = false;
  33674. } else {
  33675. current += letter;
  33676. }
  33677. }
  33678. if (last || current !== '') array.push(current.trim());
  33679. return array
  33680. }
  33681. };
  33682. var list_1 = list$2;
  33683. list$2.default = list$2;
  33684. let Container$3 = container$1;
  33685. let list$1 = list_1;
  33686. let Rule$3 = class Rule extends Container$3 {
  33687. constructor(defaults) {
  33688. super(defaults);
  33689. this.type = 'rule';
  33690. if (!this.nodes) this.nodes = [];
  33691. }
  33692. get selectors() {
  33693. return list$1.comma(this.selector)
  33694. }
  33695. set selectors(values) {
  33696. let match = this.selector ? this.selector.match(/,\s*/) : null;
  33697. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  33698. this.selector = values.join(sep);
  33699. }
  33700. };
  33701. var rule = Rule$3;
  33702. Rule$3.default = Rule$3;
  33703. Container$3.registerRule(Rule$3);
  33704. let Declaration$2 = declaration;
  33705. let tokenizer = tokenize$1;
  33706. let Comment$2 = comment$3;
  33707. let AtRule$2 = atRule;
  33708. let Root$4 = root$2;
  33709. let Rule$2 = rule;
  33710. const SAFE_COMMENT_NEIGHBOR = {
  33711. empty: true,
  33712. space: true
  33713. };
  33714. function findLastWithPosition(tokens) {
  33715. for (let i = tokens.length - 1; i >= 0; i--) {
  33716. let token = tokens[i];
  33717. let pos = token[3] || token[2];
  33718. if (pos) return pos
  33719. }
  33720. }
  33721. let Parser$1 = class Parser {
  33722. constructor(input) {
  33723. this.input = input;
  33724. this.root = new Root$4();
  33725. this.current = this.root;
  33726. this.spaces = '';
  33727. this.semicolon = false;
  33728. this.createTokenizer();
  33729. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  33730. }
  33731. atrule(token) {
  33732. let node = new AtRule$2();
  33733. node.name = token[1].slice(1);
  33734. if (node.name === '') {
  33735. this.unnamedAtrule(node, token);
  33736. }
  33737. this.init(node, token[2]);
  33738. let type;
  33739. let prev;
  33740. let shift;
  33741. let last = false;
  33742. let open = false;
  33743. let params = [];
  33744. let brackets = [];
  33745. while (!this.tokenizer.endOfFile()) {
  33746. token = this.tokenizer.nextToken();
  33747. type = token[0];
  33748. if (type === '(' || type === '[') {
  33749. brackets.push(type === '(' ? ')' : ']');
  33750. } else if (type === '{' && brackets.length > 0) {
  33751. brackets.push('}');
  33752. } else if (type === brackets[brackets.length - 1]) {
  33753. brackets.pop();
  33754. }
  33755. if (brackets.length === 0) {
  33756. if (type === ';') {
  33757. node.source.end = this.getPosition(token[2]);
  33758. node.source.end.offset++;
  33759. this.semicolon = true;
  33760. break
  33761. } else if (type === '{') {
  33762. open = true;
  33763. break
  33764. } else if (type === '}') {
  33765. if (params.length > 0) {
  33766. shift = params.length - 1;
  33767. prev = params[shift];
  33768. while (prev && prev[0] === 'space') {
  33769. prev = params[--shift];
  33770. }
  33771. if (prev) {
  33772. node.source.end = this.getPosition(prev[3] || prev[2]);
  33773. node.source.end.offset++;
  33774. }
  33775. }
  33776. this.end(token);
  33777. break
  33778. } else {
  33779. params.push(token);
  33780. }
  33781. } else {
  33782. params.push(token);
  33783. }
  33784. if (this.tokenizer.endOfFile()) {
  33785. last = true;
  33786. break
  33787. }
  33788. }
  33789. node.raws.between = this.spacesAndCommentsFromEnd(params);
  33790. if (params.length) {
  33791. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  33792. this.raw(node, 'params', params);
  33793. if (last) {
  33794. token = params[params.length - 1];
  33795. node.source.end = this.getPosition(token[3] || token[2]);
  33796. node.source.end.offset++;
  33797. this.spaces = node.raws.between;
  33798. node.raws.between = '';
  33799. }
  33800. } else {
  33801. node.raws.afterName = '';
  33802. node.params = '';
  33803. }
  33804. if (open) {
  33805. node.nodes = [];
  33806. this.current = node;
  33807. }
  33808. }
  33809. checkMissedSemicolon(tokens) {
  33810. let colon = this.colon(tokens);
  33811. if (colon === false) return
  33812. let founded = 0;
  33813. let token;
  33814. for (let j = colon - 1; j >= 0; j--) {
  33815. token = tokens[j];
  33816. if (token[0] !== 'space') {
  33817. founded += 1;
  33818. if (founded === 2) break
  33819. }
  33820. }
  33821. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  33822. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  33823. // And because we need it after that one we do +1 to get the next one.
  33824. throw this.input.error(
  33825. 'Missed semicolon',
  33826. token[0] === 'word' ? token[3] + 1 : token[2]
  33827. )
  33828. }
  33829. colon(tokens) {
  33830. let brackets = 0;
  33831. let token, type, prev;
  33832. for (let [i, element] of tokens.entries()) {
  33833. token = element;
  33834. type = token[0];
  33835. if (type === '(') {
  33836. brackets += 1;
  33837. }
  33838. if (type === ')') {
  33839. brackets -= 1;
  33840. }
  33841. if (brackets === 0 && type === ':') {
  33842. if (!prev) {
  33843. this.doubleColon(token);
  33844. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  33845. continue
  33846. } else {
  33847. return i
  33848. }
  33849. }
  33850. prev = token;
  33851. }
  33852. return false
  33853. }
  33854. comment(token) {
  33855. let node = new Comment$2();
  33856. this.init(node, token[2]);
  33857. node.source.end = this.getPosition(token[3] || token[2]);
  33858. node.source.end.offset++;
  33859. let text = token[1].slice(2, -2);
  33860. if (/^\s*$/.test(text)) {
  33861. node.text = '';
  33862. node.raws.left = text;
  33863. node.raws.right = '';
  33864. } else {
  33865. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  33866. node.text = match[2];
  33867. node.raws.left = match[1];
  33868. node.raws.right = match[3];
  33869. }
  33870. }
  33871. createTokenizer() {
  33872. this.tokenizer = tokenizer(this.input);
  33873. }
  33874. decl(tokens, customProperty) {
  33875. let node = new Declaration$2();
  33876. this.init(node, tokens[0][2]);
  33877. let last = tokens[tokens.length - 1];
  33878. if (last[0] === ';') {
  33879. this.semicolon = true;
  33880. tokens.pop();
  33881. }
  33882. node.source.end = this.getPosition(
  33883. last[3] || last[2] || findLastWithPosition(tokens)
  33884. );
  33885. node.source.end.offset++;
  33886. while (tokens[0][0] !== 'word') {
  33887. if (tokens.length === 1) this.unknownWord(tokens);
  33888. node.raws.before += tokens.shift()[1];
  33889. }
  33890. node.source.start = this.getPosition(tokens[0][2]);
  33891. node.prop = '';
  33892. while (tokens.length) {
  33893. let type = tokens[0][0];
  33894. if (type === ':' || type === 'space' || type === 'comment') {
  33895. break
  33896. }
  33897. node.prop += tokens.shift()[1];
  33898. }
  33899. node.raws.between = '';
  33900. let token;
  33901. while (tokens.length) {
  33902. token = tokens.shift();
  33903. if (token[0] === ':') {
  33904. node.raws.between += token[1];
  33905. break
  33906. } else {
  33907. if (token[0] === 'word' && /\w/.test(token[1])) {
  33908. this.unknownWord([token]);
  33909. }
  33910. node.raws.between += token[1];
  33911. }
  33912. }
  33913. if (node.prop[0] === '_' || node.prop[0] === '*') {
  33914. node.raws.before += node.prop[0];
  33915. node.prop = node.prop.slice(1);
  33916. }
  33917. let firstSpaces = [];
  33918. let next;
  33919. while (tokens.length) {
  33920. next = tokens[0][0];
  33921. if (next !== 'space' && next !== 'comment') break
  33922. firstSpaces.push(tokens.shift());
  33923. }
  33924. this.precheckMissedSemicolon(tokens);
  33925. for (let i = tokens.length - 1; i >= 0; i--) {
  33926. token = tokens[i];
  33927. if (token[1].toLowerCase() === '!important') {
  33928. node.important = true;
  33929. let string = this.stringFrom(tokens, i);
  33930. string = this.spacesFromEnd(tokens) + string;
  33931. if (string !== ' !important') node.raws.important = string;
  33932. break
  33933. } else if (token[1].toLowerCase() === 'important') {
  33934. let cache = tokens.slice(0);
  33935. let str = '';
  33936. for (let j = i; j > 0; j--) {
  33937. let type = cache[j][0];
  33938. if (str.trim().indexOf('!') === 0 && type !== 'space') {
  33939. break
  33940. }
  33941. str = cache.pop()[1] + str;
  33942. }
  33943. if (str.trim().indexOf('!') === 0) {
  33944. node.important = true;
  33945. node.raws.important = str;
  33946. tokens = cache;
  33947. }
  33948. }
  33949. if (token[0] !== 'space' && token[0] !== 'comment') {
  33950. break
  33951. }
  33952. }
  33953. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  33954. if (hasWord) {
  33955. node.raws.between += firstSpaces.map(i => i[1]).join('');
  33956. firstSpaces = [];
  33957. }
  33958. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  33959. if (node.value.includes(':') && !customProperty) {
  33960. this.checkMissedSemicolon(tokens);
  33961. }
  33962. }
  33963. doubleColon(token) {
  33964. throw this.input.error(
  33965. 'Double colon',
  33966. { offset: token[2] },
  33967. { offset: token[2] + token[1].length }
  33968. )
  33969. }
  33970. emptyRule(token) {
  33971. let node = new Rule$2();
  33972. this.init(node, token[2]);
  33973. node.selector = '';
  33974. node.raws.between = '';
  33975. this.current = node;
  33976. }
  33977. end(token) {
  33978. if (this.current.nodes && this.current.nodes.length) {
  33979. this.current.raws.semicolon = this.semicolon;
  33980. }
  33981. this.semicolon = false;
  33982. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  33983. this.spaces = '';
  33984. if (this.current.parent) {
  33985. this.current.source.end = this.getPosition(token[2]);
  33986. this.current.source.end.offset++;
  33987. this.current = this.current.parent;
  33988. } else {
  33989. this.unexpectedClose(token);
  33990. }
  33991. }
  33992. endFile() {
  33993. if (this.current.parent) this.unclosedBlock();
  33994. if (this.current.nodes && this.current.nodes.length) {
  33995. this.current.raws.semicolon = this.semicolon;
  33996. }
  33997. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  33998. this.root.source.end = this.getPosition(this.tokenizer.position());
  33999. }
  34000. freeSemicolon(token) {
  34001. this.spaces += token[1];
  34002. if (this.current.nodes) {
  34003. let prev = this.current.nodes[this.current.nodes.length - 1];
  34004. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  34005. prev.raws.ownSemicolon = this.spaces;
  34006. this.spaces = '';
  34007. }
  34008. }
  34009. }
  34010. // Helpers
  34011. getPosition(offset) {
  34012. let pos = this.input.fromOffset(offset);
  34013. return {
  34014. column: pos.col,
  34015. line: pos.line,
  34016. offset
  34017. }
  34018. }
  34019. init(node, offset) {
  34020. this.current.push(node);
  34021. node.source = {
  34022. input: this.input,
  34023. start: this.getPosition(offset)
  34024. };
  34025. node.raws.before = this.spaces;
  34026. this.spaces = '';
  34027. if (node.type !== 'comment') this.semicolon = false;
  34028. }
  34029. other(start) {
  34030. let end = false;
  34031. let type = null;
  34032. let colon = false;
  34033. let bracket = null;
  34034. let brackets = [];
  34035. let customProperty = start[1].startsWith('--');
  34036. let tokens = [];
  34037. let token = start;
  34038. while (token) {
  34039. type = token[0];
  34040. tokens.push(token);
  34041. if (type === '(' || type === '[') {
  34042. if (!bracket) bracket = token;
  34043. brackets.push(type === '(' ? ')' : ']');
  34044. } else if (customProperty && colon && type === '{') {
  34045. if (!bracket) bracket = token;
  34046. brackets.push('}');
  34047. } else if (brackets.length === 0) {
  34048. if (type === ';') {
  34049. if (colon) {
  34050. this.decl(tokens, customProperty);
  34051. return
  34052. } else {
  34053. break
  34054. }
  34055. } else if (type === '{') {
  34056. this.rule(tokens);
  34057. return
  34058. } else if (type === '}') {
  34059. this.tokenizer.back(tokens.pop());
  34060. end = true;
  34061. break
  34062. } else if (type === ':') {
  34063. colon = true;
  34064. }
  34065. } else if (type === brackets[brackets.length - 1]) {
  34066. brackets.pop();
  34067. if (brackets.length === 0) bracket = null;
  34068. }
  34069. token = this.tokenizer.nextToken();
  34070. }
  34071. if (this.tokenizer.endOfFile()) end = true;
  34072. if (brackets.length > 0) this.unclosedBracket(bracket);
  34073. if (end && colon) {
  34074. if (!customProperty) {
  34075. while (tokens.length) {
  34076. token = tokens[tokens.length - 1][0];
  34077. if (token !== 'space' && token !== 'comment') break
  34078. this.tokenizer.back(tokens.pop());
  34079. }
  34080. }
  34081. this.decl(tokens, customProperty);
  34082. } else {
  34083. this.unknownWord(tokens);
  34084. }
  34085. }
  34086. parse() {
  34087. let token;
  34088. while (!this.tokenizer.endOfFile()) {
  34089. token = this.tokenizer.nextToken();
  34090. switch (token[0]) {
  34091. case 'space':
  34092. this.spaces += token[1];
  34093. break
  34094. case ';':
  34095. this.freeSemicolon(token);
  34096. break
  34097. case '}':
  34098. this.end(token);
  34099. break
  34100. case 'comment':
  34101. this.comment(token);
  34102. break
  34103. case 'at-word':
  34104. this.atrule(token);
  34105. break
  34106. case '{':
  34107. this.emptyRule(token);
  34108. break
  34109. default:
  34110. this.other(token);
  34111. break
  34112. }
  34113. }
  34114. this.endFile();
  34115. }
  34116. precheckMissedSemicolon(/* tokens */) {
  34117. // Hook for Safe Parser
  34118. }
  34119. raw(node, prop, tokens, customProperty) {
  34120. let token, type;
  34121. let length = tokens.length;
  34122. let value = '';
  34123. let clean = true;
  34124. let next, prev;
  34125. for (let i = 0; i < length; i += 1) {
  34126. token = tokens[i];
  34127. type = token[0];
  34128. if (type === 'space' && i === length - 1 && !customProperty) {
  34129. clean = false;
  34130. } else if (type === 'comment') {
  34131. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  34132. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  34133. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  34134. if (value.slice(-1) === ',') {
  34135. clean = false;
  34136. } else {
  34137. value += token[1];
  34138. }
  34139. } else {
  34140. clean = false;
  34141. }
  34142. } else {
  34143. value += token[1];
  34144. }
  34145. }
  34146. if (!clean) {
  34147. let raw = tokens.reduce((all, i) => all + i[1], '');
  34148. node.raws[prop] = { raw, value };
  34149. }
  34150. node[prop] = value;
  34151. }
  34152. rule(tokens) {
  34153. tokens.pop();
  34154. let node = new Rule$2();
  34155. this.init(node, tokens[0][2]);
  34156. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  34157. this.raw(node, 'selector', tokens);
  34158. this.current = node;
  34159. }
  34160. spacesAndCommentsFromEnd(tokens) {
  34161. let lastTokenType;
  34162. let spaces = '';
  34163. while (tokens.length) {
  34164. lastTokenType = tokens[tokens.length - 1][0];
  34165. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  34166. spaces = tokens.pop()[1] + spaces;
  34167. }
  34168. return spaces
  34169. }
  34170. // Errors
  34171. spacesAndCommentsFromStart(tokens) {
  34172. let next;
  34173. let spaces = '';
  34174. while (tokens.length) {
  34175. next = tokens[0][0];
  34176. if (next !== 'space' && next !== 'comment') break
  34177. spaces += tokens.shift()[1];
  34178. }
  34179. return spaces
  34180. }
  34181. spacesFromEnd(tokens) {
  34182. let lastTokenType;
  34183. let spaces = '';
  34184. while (tokens.length) {
  34185. lastTokenType = tokens[tokens.length - 1][0];
  34186. if (lastTokenType !== 'space') break
  34187. spaces = tokens.pop()[1] + spaces;
  34188. }
  34189. return spaces
  34190. }
  34191. stringFrom(tokens, from) {
  34192. let result = '';
  34193. for (let i = from; i < tokens.length; i++) {
  34194. result += tokens[i][1];
  34195. }
  34196. tokens.splice(from, tokens.length - from);
  34197. return result
  34198. }
  34199. unclosedBlock() {
  34200. let pos = this.current.source.start;
  34201. throw this.input.error('Unclosed block', pos.line, pos.column)
  34202. }
  34203. unclosedBracket(bracket) {
  34204. throw this.input.error(
  34205. 'Unclosed bracket',
  34206. { offset: bracket[2] },
  34207. { offset: bracket[2] + 1 }
  34208. )
  34209. }
  34210. unexpectedClose(token) {
  34211. throw this.input.error(
  34212. 'Unexpected }',
  34213. { offset: token[2] },
  34214. { offset: token[2] + 1 }
  34215. )
  34216. }
  34217. unknownWord(tokens) {
  34218. throw this.input.error(
  34219. 'Unknown word',
  34220. { offset: tokens[0][2] },
  34221. { offset: tokens[0][2] + tokens[0][1].length }
  34222. )
  34223. }
  34224. unnamedAtrule(node, token) {
  34225. throw this.input.error(
  34226. 'At-rule without name',
  34227. { offset: token[2] },
  34228. { offset: token[2] + token[1].length }
  34229. )
  34230. }
  34231. };
  34232. var parser$1 = Parser$1;
  34233. let Container$2 = container$1;
  34234. let Parser = parser$1;
  34235. let Input$2 = input;
  34236. function parse$3(css, opts) {
  34237. let input = new Input$2(css, opts);
  34238. let parser = new Parser(input);
  34239. try {
  34240. parser.parse();
  34241. } catch (e) {
  34242. if (browser$1.env.NODE_ENV !== 'production') {
  34243. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  34244. if (/\.scss$/i.test(opts.from)) {
  34245. e.message +=
  34246. '\nYou tried to parse SCSS with ' +
  34247. 'the standard CSS parser; ' +
  34248. 'try again with the postcss-scss parser';
  34249. } else if (/\.sass/i.test(opts.from)) {
  34250. e.message +=
  34251. '\nYou tried to parse Sass with ' +
  34252. 'the standard CSS parser; ' +
  34253. 'try again with the postcss-sass parser';
  34254. } else if (/\.less$/i.test(opts.from)) {
  34255. e.message +=
  34256. '\nYou tried to parse Less with ' +
  34257. 'the standard CSS parser; ' +
  34258. 'try again with the postcss-less parser';
  34259. }
  34260. }
  34261. }
  34262. throw e
  34263. }
  34264. return parser.root
  34265. }
  34266. var parse_1 = parse$3;
  34267. parse$3.default = parse$3;
  34268. Container$2.registerParse(parse$3);
  34269. let { isClean, my } = symbols;
  34270. let MapGenerator$1 = mapGenerator;
  34271. let stringify$2 = stringify_1;
  34272. let Container$1 = container$1;
  34273. let Document$2 = document;
  34274. let warnOnce$1 = warnOnce$2;
  34275. let Result$2 = result;
  34276. let parse$2 = parse_1;
  34277. let Root$3 = root$2;
  34278. const TYPE_TO_CLASS_NAME = {
  34279. atrule: 'AtRule',
  34280. comment: 'Comment',
  34281. decl: 'Declaration',
  34282. document: 'Document',
  34283. root: 'Root',
  34284. rule: 'Rule'
  34285. };
  34286. const PLUGIN_PROPS = {
  34287. AtRule: true,
  34288. AtRuleExit: true,
  34289. Comment: true,
  34290. CommentExit: true,
  34291. Declaration: true,
  34292. DeclarationExit: true,
  34293. Document: true,
  34294. DocumentExit: true,
  34295. Once: true,
  34296. OnceExit: true,
  34297. postcssPlugin: true,
  34298. prepare: true,
  34299. Root: true,
  34300. RootExit: true,
  34301. Rule: true,
  34302. RuleExit: true
  34303. };
  34304. const NOT_VISITORS = {
  34305. Once: true,
  34306. postcssPlugin: true,
  34307. prepare: true
  34308. };
  34309. const CHILDREN = 0;
  34310. function isPromise(obj) {
  34311. return typeof obj === 'object' && typeof obj.then === 'function'
  34312. }
  34313. function getEvents(node) {
  34314. let key = false;
  34315. let type = TYPE_TO_CLASS_NAME[node.type];
  34316. if (node.type === 'decl') {
  34317. key = node.prop.toLowerCase();
  34318. } else if (node.type === 'atrule') {
  34319. key = node.name.toLowerCase();
  34320. }
  34321. if (key && node.append) {
  34322. return [
  34323. type,
  34324. type + '-' + key,
  34325. CHILDREN,
  34326. type + 'Exit',
  34327. type + 'Exit-' + key
  34328. ]
  34329. } else if (key) {
  34330. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  34331. } else if (node.append) {
  34332. return [type, CHILDREN, type + 'Exit']
  34333. } else {
  34334. return [type, type + 'Exit']
  34335. }
  34336. }
  34337. function toStack(node) {
  34338. let events;
  34339. if (node.type === 'document') {
  34340. events = ['Document', CHILDREN, 'DocumentExit'];
  34341. } else if (node.type === 'root') {
  34342. events = ['Root', CHILDREN, 'RootExit'];
  34343. } else {
  34344. events = getEvents(node);
  34345. }
  34346. return {
  34347. eventIndex: 0,
  34348. events,
  34349. iterator: 0,
  34350. node,
  34351. visitorIndex: 0,
  34352. visitors: []
  34353. }
  34354. }
  34355. function cleanMarks(node) {
  34356. node[isClean] = false;
  34357. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  34358. return node
  34359. }
  34360. let postcss$2 = {};
  34361. let LazyResult$2 = class LazyResult {
  34362. constructor(processor, css, opts) {
  34363. this.stringified = false;
  34364. this.processed = false;
  34365. let root;
  34366. if (
  34367. typeof css === 'object' &&
  34368. css !== null &&
  34369. (css.type === 'root' || css.type === 'document')
  34370. ) {
  34371. root = cleanMarks(css);
  34372. } else if (css instanceof LazyResult || css instanceof Result$2) {
  34373. root = cleanMarks(css.root);
  34374. if (css.map) {
  34375. if (typeof opts.map === 'undefined') opts.map = {};
  34376. if (!opts.map.inline) opts.map.inline = false;
  34377. opts.map.prev = css.map;
  34378. }
  34379. } else {
  34380. let parser = parse$2;
  34381. if (opts.syntax) parser = opts.syntax.parse;
  34382. if (opts.parser) parser = opts.parser;
  34383. if (parser.parse) parser = parser.parse;
  34384. try {
  34385. root = parser(css, opts);
  34386. } catch (error) {
  34387. this.processed = true;
  34388. this.error = error;
  34389. }
  34390. if (root && !root[my]) {
  34391. /* c8 ignore next 2 */
  34392. Container$1.rebuild(root);
  34393. }
  34394. }
  34395. this.result = new Result$2(processor, root, opts);
  34396. this.helpers = { ...postcss$2, postcss: postcss$2, result: this.result };
  34397. this.plugins = this.processor.plugins.map(plugin => {
  34398. if (typeof plugin === 'object' && plugin.prepare) {
  34399. return { ...plugin, ...plugin.prepare(this.result) }
  34400. } else {
  34401. return plugin
  34402. }
  34403. });
  34404. }
  34405. async() {
  34406. if (this.error) return Promise.reject(this.error)
  34407. if (this.processed) return Promise.resolve(this.result)
  34408. if (!this.processing) {
  34409. this.processing = this.runAsync();
  34410. }
  34411. return this.processing
  34412. }
  34413. catch(onRejected) {
  34414. return this.async().catch(onRejected)
  34415. }
  34416. finally(onFinally) {
  34417. return this.async().then(onFinally, onFinally)
  34418. }
  34419. getAsyncError() {
  34420. throw new Error('Use process(css).then(cb) to work with async plugins')
  34421. }
  34422. handleError(error, node) {
  34423. let plugin = this.result.lastPlugin;
  34424. try {
  34425. if (node) node.addToError(error);
  34426. this.error = error;
  34427. if (error.name === 'CssSyntaxError' && !error.plugin) {
  34428. error.plugin = plugin.postcssPlugin;
  34429. error.setMessage();
  34430. } else if (plugin.postcssVersion) {
  34431. if (browser$1.env.NODE_ENV !== 'production') {
  34432. let pluginName = plugin.postcssPlugin;
  34433. let pluginVer = plugin.postcssVersion;
  34434. let runtimeVer = this.result.processor.version;
  34435. let a = pluginVer.split('.');
  34436. let b = runtimeVer.split('.');
  34437. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  34438. // eslint-disable-next-line no-console
  34439. console.error(
  34440. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  34441. 'version is ' +
  34442. runtimeVer +
  34443. ', but ' +
  34444. pluginName +
  34445. ' uses ' +
  34446. pluginVer +
  34447. '. Perhaps this is the source of the error below.'
  34448. );
  34449. }
  34450. }
  34451. }
  34452. } catch (err) {
  34453. /* c8 ignore next 3 */
  34454. // eslint-disable-next-line no-console
  34455. if (console && console.error) console.error(err);
  34456. }
  34457. return error
  34458. }
  34459. prepareVisitors() {
  34460. this.listeners = {};
  34461. let add = (plugin, type, cb) => {
  34462. if (!this.listeners[type]) this.listeners[type] = [];
  34463. this.listeners[type].push([plugin, cb]);
  34464. };
  34465. for (let plugin of this.plugins) {
  34466. if (typeof plugin === 'object') {
  34467. for (let event in plugin) {
  34468. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  34469. throw new Error(
  34470. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  34471. `Try to update PostCSS (${this.processor.version} now).`
  34472. )
  34473. }
  34474. if (!NOT_VISITORS[event]) {
  34475. if (typeof plugin[event] === 'object') {
  34476. for (let filter in plugin[event]) {
  34477. if (filter === '*') {
  34478. add(plugin, event, plugin[event][filter]);
  34479. } else {
  34480. add(
  34481. plugin,
  34482. event + '-' + filter.toLowerCase(),
  34483. plugin[event][filter]
  34484. );
  34485. }
  34486. }
  34487. } else if (typeof plugin[event] === 'function') {
  34488. add(plugin, event, plugin[event]);
  34489. }
  34490. }
  34491. }
  34492. }
  34493. }
  34494. this.hasListener = Object.keys(this.listeners).length > 0;
  34495. }
  34496. async runAsync() {
  34497. this.plugin = 0;
  34498. for (let i = 0; i < this.plugins.length; i++) {
  34499. let plugin = this.plugins[i];
  34500. let promise = this.runOnRoot(plugin);
  34501. if (isPromise(promise)) {
  34502. try {
  34503. await promise;
  34504. } catch (error) {
  34505. throw this.handleError(error)
  34506. }
  34507. }
  34508. }
  34509. this.prepareVisitors();
  34510. if (this.hasListener) {
  34511. let root = this.result.root;
  34512. while (!root[isClean]) {
  34513. root[isClean] = true;
  34514. let stack = [toStack(root)];
  34515. while (stack.length > 0) {
  34516. let promise = this.visitTick(stack);
  34517. if (isPromise(promise)) {
  34518. try {
  34519. await promise;
  34520. } catch (e) {
  34521. let node = stack[stack.length - 1].node;
  34522. throw this.handleError(e, node)
  34523. }
  34524. }
  34525. }
  34526. }
  34527. if (this.listeners.OnceExit) {
  34528. for (let [plugin, visitor] of this.listeners.OnceExit) {
  34529. this.result.lastPlugin = plugin;
  34530. try {
  34531. if (root.type === 'document') {
  34532. let roots = root.nodes.map(subRoot =>
  34533. visitor(subRoot, this.helpers)
  34534. );
  34535. await Promise.all(roots);
  34536. } else {
  34537. await visitor(root, this.helpers);
  34538. }
  34539. } catch (e) {
  34540. throw this.handleError(e)
  34541. }
  34542. }
  34543. }
  34544. }
  34545. this.processed = true;
  34546. return this.stringify()
  34547. }
  34548. runOnRoot(plugin) {
  34549. this.result.lastPlugin = plugin;
  34550. try {
  34551. if (typeof plugin === 'object' && plugin.Once) {
  34552. if (this.result.root.type === 'document') {
  34553. let roots = this.result.root.nodes.map(root =>
  34554. plugin.Once(root, this.helpers)
  34555. );
  34556. if (isPromise(roots[0])) {
  34557. return Promise.all(roots)
  34558. }
  34559. return roots
  34560. }
  34561. return plugin.Once(this.result.root, this.helpers)
  34562. } else if (typeof plugin === 'function') {
  34563. return plugin(this.result.root, this.result)
  34564. }
  34565. } catch (error) {
  34566. throw this.handleError(error)
  34567. }
  34568. }
  34569. stringify() {
  34570. if (this.error) throw this.error
  34571. if (this.stringified) return this.result
  34572. this.stringified = true;
  34573. this.sync();
  34574. let opts = this.result.opts;
  34575. let str = stringify$2;
  34576. if (opts.syntax) str = opts.syntax.stringify;
  34577. if (opts.stringifier) str = opts.stringifier;
  34578. if (str.stringify) str = str.stringify;
  34579. let map = new MapGenerator$1(str, this.result.root, this.result.opts);
  34580. let data = map.generate();
  34581. this.result.css = data[0];
  34582. this.result.map = data[1];
  34583. return this.result
  34584. }
  34585. sync() {
  34586. if (this.error) throw this.error
  34587. if (this.processed) return this.result
  34588. this.processed = true;
  34589. if (this.processing) {
  34590. throw this.getAsyncError()
  34591. }
  34592. for (let plugin of this.plugins) {
  34593. let promise = this.runOnRoot(plugin);
  34594. if (isPromise(promise)) {
  34595. throw this.getAsyncError()
  34596. }
  34597. }
  34598. this.prepareVisitors();
  34599. if (this.hasListener) {
  34600. let root = this.result.root;
  34601. while (!root[isClean]) {
  34602. root[isClean] = true;
  34603. this.walkSync(root);
  34604. }
  34605. if (this.listeners.OnceExit) {
  34606. if (root.type === 'document') {
  34607. for (let subRoot of root.nodes) {
  34608. this.visitSync(this.listeners.OnceExit, subRoot);
  34609. }
  34610. } else {
  34611. this.visitSync(this.listeners.OnceExit, root);
  34612. }
  34613. }
  34614. }
  34615. return this.result
  34616. }
  34617. then(onFulfilled, onRejected) {
  34618. if (browser$1.env.NODE_ENV !== 'production') {
  34619. if (!('from' in this.opts)) {
  34620. warnOnce$1(
  34621. 'Without `from` option PostCSS could generate wrong source map ' +
  34622. 'and will not find Browserslist config. Set it to CSS file path ' +
  34623. 'or to `undefined` to prevent this warning.'
  34624. );
  34625. }
  34626. }
  34627. return this.async().then(onFulfilled, onRejected)
  34628. }
  34629. toString() {
  34630. return this.css
  34631. }
  34632. visitSync(visitors, node) {
  34633. for (let [plugin, visitor] of visitors) {
  34634. this.result.lastPlugin = plugin;
  34635. let promise;
  34636. try {
  34637. promise = visitor(node, this.helpers);
  34638. } catch (e) {
  34639. throw this.handleError(e, node.proxyOf)
  34640. }
  34641. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34642. return true
  34643. }
  34644. if (isPromise(promise)) {
  34645. throw this.getAsyncError()
  34646. }
  34647. }
  34648. }
  34649. visitTick(stack) {
  34650. let visit = stack[stack.length - 1];
  34651. let { node, visitors } = visit;
  34652. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34653. stack.pop();
  34654. return
  34655. }
  34656. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  34657. let [plugin, visitor] = visitors[visit.visitorIndex];
  34658. visit.visitorIndex += 1;
  34659. if (visit.visitorIndex === visitors.length) {
  34660. visit.visitors = [];
  34661. visit.visitorIndex = 0;
  34662. }
  34663. this.result.lastPlugin = plugin;
  34664. try {
  34665. return visitor(node.toProxy(), this.helpers)
  34666. } catch (e) {
  34667. throw this.handleError(e, node)
  34668. }
  34669. }
  34670. if (visit.iterator !== 0) {
  34671. let iterator = visit.iterator;
  34672. let child;
  34673. while ((child = node.nodes[node.indexes[iterator]])) {
  34674. node.indexes[iterator] += 1;
  34675. if (!child[isClean]) {
  34676. child[isClean] = true;
  34677. stack.push(toStack(child));
  34678. return
  34679. }
  34680. }
  34681. visit.iterator = 0;
  34682. delete node.indexes[iterator];
  34683. }
  34684. let events = visit.events;
  34685. while (visit.eventIndex < events.length) {
  34686. let event = events[visit.eventIndex];
  34687. visit.eventIndex += 1;
  34688. if (event === CHILDREN) {
  34689. if (node.nodes && node.nodes.length) {
  34690. node[isClean] = true;
  34691. visit.iterator = node.getIterator();
  34692. }
  34693. return
  34694. } else if (this.listeners[event]) {
  34695. visit.visitors = this.listeners[event];
  34696. return
  34697. }
  34698. }
  34699. stack.pop();
  34700. }
  34701. walkSync(node) {
  34702. node[isClean] = true;
  34703. let events = getEvents(node);
  34704. for (let event of events) {
  34705. if (event === CHILDREN) {
  34706. if (node.nodes) {
  34707. node.each(child => {
  34708. if (!child[isClean]) this.walkSync(child);
  34709. });
  34710. }
  34711. } else {
  34712. let visitors = this.listeners[event];
  34713. if (visitors) {
  34714. if (this.visitSync(visitors, node.toProxy())) return
  34715. }
  34716. }
  34717. }
  34718. }
  34719. warnings() {
  34720. return this.sync().warnings()
  34721. }
  34722. get content() {
  34723. return this.stringify().content
  34724. }
  34725. get css() {
  34726. return this.stringify().css
  34727. }
  34728. get map() {
  34729. return this.stringify().map
  34730. }
  34731. get messages() {
  34732. return this.sync().messages
  34733. }
  34734. get opts() {
  34735. return this.result.opts
  34736. }
  34737. get processor() {
  34738. return this.result.processor
  34739. }
  34740. get root() {
  34741. return this.sync().root
  34742. }
  34743. get [Symbol.toStringTag]() {
  34744. return 'LazyResult'
  34745. }
  34746. };
  34747. LazyResult$2.registerPostcss = dependant => {
  34748. postcss$2 = dependant;
  34749. };
  34750. var lazyResult = LazyResult$2;
  34751. LazyResult$2.default = LazyResult$2;
  34752. Root$3.registerLazyResult(LazyResult$2);
  34753. Document$2.registerLazyResult(LazyResult$2);
  34754. let MapGenerator = mapGenerator;
  34755. let stringify$1 = stringify_1;
  34756. let warnOnce = warnOnce$2;
  34757. let parse$1 = parse_1;
  34758. const Result$1 = result;
  34759. let NoWorkResult$1 = class NoWorkResult {
  34760. constructor(processor, css, opts) {
  34761. css = css.toString();
  34762. this.stringified = false;
  34763. this._processor = processor;
  34764. this._css = css;
  34765. this._opts = opts;
  34766. this._map = undefined;
  34767. let root;
  34768. let str = stringify$1;
  34769. this.result = new Result$1(this._processor, root, this._opts);
  34770. this.result.css = css;
  34771. let self = this;
  34772. Object.defineProperty(this.result, 'root', {
  34773. get() {
  34774. return self.root
  34775. }
  34776. });
  34777. let map = new MapGenerator(str, root, this._opts, css);
  34778. if (map.isMap()) {
  34779. let [generatedCSS, generatedMap] = map.generate();
  34780. if (generatedCSS) {
  34781. this.result.css = generatedCSS;
  34782. }
  34783. if (generatedMap) {
  34784. this.result.map = generatedMap;
  34785. }
  34786. } else {
  34787. map.clearAnnotation();
  34788. this.result.css = map.css;
  34789. }
  34790. }
  34791. async() {
  34792. if (this.error) return Promise.reject(this.error)
  34793. return Promise.resolve(this.result)
  34794. }
  34795. catch(onRejected) {
  34796. return this.async().catch(onRejected)
  34797. }
  34798. finally(onFinally) {
  34799. return this.async().then(onFinally, onFinally)
  34800. }
  34801. sync() {
  34802. if (this.error) throw this.error
  34803. return this.result
  34804. }
  34805. then(onFulfilled, onRejected) {
  34806. if (browser$1.env.NODE_ENV !== 'production') {
  34807. if (!('from' in this._opts)) {
  34808. warnOnce(
  34809. 'Without `from` option PostCSS could generate wrong source map ' +
  34810. 'and will not find Browserslist config. Set it to CSS file path ' +
  34811. 'or to `undefined` to prevent this warning.'
  34812. );
  34813. }
  34814. }
  34815. return this.async().then(onFulfilled, onRejected)
  34816. }
  34817. toString() {
  34818. return this._css
  34819. }
  34820. warnings() {
  34821. return []
  34822. }
  34823. get content() {
  34824. return this.result.css
  34825. }
  34826. get css() {
  34827. return this.result.css
  34828. }
  34829. get map() {
  34830. return this.result.map
  34831. }
  34832. get messages() {
  34833. return []
  34834. }
  34835. get opts() {
  34836. return this.result.opts
  34837. }
  34838. get processor() {
  34839. return this.result.processor
  34840. }
  34841. get root() {
  34842. if (this._root) {
  34843. return this._root
  34844. }
  34845. let root;
  34846. let parser = parse$1;
  34847. try {
  34848. root = parser(this._css, this._opts);
  34849. } catch (error) {
  34850. this.error = error;
  34851. }
  34852. if (this.error) {
  34853. throw this.error
  34854. } else {
  34855. this._root = root;
  34856. return root
  34857. }
  34858. }
  34859. get [Symbol.toStringTag]() {
  34860. return 'NoWorkResult'
  34861. }
  34862. };
  34863. var noWorkResult = NoWorkResult$1;
  34864. NoWorkResult$1.default = NoWorkResult$1;
  34865. let NoWorkResult = noWorkResult;
  34866. let LazyResult$1 = lazyResult;
  34867. let Document$1 = document;
  34868. let Root$2 = root$2;
  34869. let Processor$1 = class Processor {
  34870. constructor(plugins = []) {
  34871. this.version = '8.4.38';
  34872. this.plugins = this.normalize(plugins);
  34873. }
  34874. normalize(plugins) {
  34875. let normalized = [];
  34876. for (let i of plugins) {
  34877. if (i.postcss === true) {
  34878. i = i();
  34879. } else if (i.postcss) {
  34880. i = i.postcss;
  34881. }
  34882. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  34883. normalized = normalized.concat(i.plugins);
  34884. } else if (typeof i === 'object' && i.postcssPlugin) {
  34885. normalized.push(i);
  34886. } else if (typeof i === 'function') {
  34887. normalized.push(i);
  34888. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  34889. if (browser$1.env.NODE_ENV !== 'production') {
  34890. throw new Error(
  34891. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  34892. 'one of the syntax/parser/stringifier options as outlined ' +
  34893. 'in your PostCSS runner documentation.'
  34894. )
  34895. }
  34896. } else {
  34897. throw new Error(i + ' is not a PostCSS plugin')
  34898. }
  34899. }
  34900. return normalized
  34901. }
  34902. process(css, opts = {}) {
  34903. if (
  34904. !this.plugins.length &&
  34905. !opts.parser &&
  34906. !opts.stringifier &&
  34907. !opts.syntax
  34908. ) {
  34909. return new NoWorkResult(this, css, opts)
  34910. } else {
  34911. return new LazyResult$1(this, css, opts)
  34912. }
  34913. }
  34914. use(plugin) {
  34915. this.plugins = this.plugins.concat(this.normalize([plugin]));
  34916. return this
  34917. }
  34918. };
  34919. var processor$1 = Processor$1;
  34920. Processor$1.default = Processor$1;
  34921. Root$2.registerProcessor(Processor$1);
  34922. Document$1.registerProcessor(Processor$1);
  34923. let Declaration$1 = declaration;
  34924. let PreviousMap = previousMap;
  34925. let Comment$1 = comment$3;
  34926. let AtRule$1 = atRule;
  34927. let Input$1 = input;
  34928. let Root$1 = root$2;
  34929. let Rule$1 = rule;
  34930. function fromJSON$1(json, inputs) {
  34931. if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
  34932. let { inputs: ownInputs, ...defaults } = json;
  34933. if (ownInputs) {
  34934. inputs = [];
  34935. for (let input of ownInputs) {
  34936. let inputHydrated = { ...input, __proto__: Input$1.prototype };
  34937. if (inputHydrated.map) {
  34938. inputHydrated.map = {
  34939. ...inputHydrated.map,
  34940. __proto__: PreviousMap.prototype
  34941. };
  34942. }
  34943. inputs.push(inputHydrated);
  34944. }
  34945. }
  34946. if (defaults.nodes) {
  34947. defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
  34948. }
  34949. if (defaults.source) {
  34950. let { inputId, ...source } = defaults.source;
  34951. defaults.source = source;
  34952. if (inputId != null) {
  34953. defaults.source.input = inputs[inputId];
  34954. }
  34955. }
  34956. if (defaults.type === 'root') {
  34957. return new Root$1(defaults)
  34958. } else if (defaults.type === 'decl') {
  34959. return new Declaration$1(defaults)
  34960. } else if (defaults.type === 'rule') {
  34961. return new Rule$1(defaults)
  34962. } else if (defaults.type === 'comment') {
  34963. return new Comment$1(defaults)
  34964. } else if (defaults.type === 'atrule') {
  34965. return new AtRule$1(defaults)
  34966. } else {
  34967. throw new Error('Unknown node type: ' + json.type)
  34968. }
  34969. }
  34970. var fromJSON_1 = fromJSON$1;
  34971. fromJSON$1.default = fromJSON$1;
  34972. let CssSyntaxError = cssSyntaxError;
  34973. let Declaration = declaration;
  34974. let LazyResult = lazyResult;
  34975. let Container = container$1;
  34976. let Processor = processor$1;
  34977. let stringify = stringify_1;
  34978. let fromJSON = fromJSON_1;
  34979. let Document = document;
  34980. let Warning = warning;
  34981. let Comment = comment$3;
  34982. let AtRule = atRule;
  34983. let Result = result;
  34984. let Input = input;
  34985. let parse = parse_1;
  34986. let list = list_1;
  34987. let Rule = rule;
  34988. let Root = root$2;
  34989. let Node = node$2;
  34990. function postcss(...plugins) {
  34991. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  34992. plugins = plugins[0];
  34993. }
  34994. return new Processor(plugins)
  34995. }
  34996. postcss.plugin = function plugin(name, initializer) {
  34997. let warningPrinted = false;
  34998. function creator(...args) {
  34999. // eslint-disable-next-line no-console
  35000. if (console && console.warn && !warningPrinted) {
  35001. warningPrinted = true;
  35002. // eslint-disable-next-line no-console
  35003. console.warn(
  35004. name +
  35005. ': postcss.plugin was deprecated. Migration guide:\n' +
  35006. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  35007. );
  35008. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  35009. /* c8 ignore next 7 */
  35010. // eslint-disable-next-line no-console
  35011. console.warn(
  35012. name +
  35013. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  35014. 'https://www.w3ctech.com/topic/2226'
  35015. );
  35016. }
  35017. }
  35018. let transformer = initializer(...args);
  35019. transformer.postcssPlugin = name;
  35020. transformer.postcssVersion = new Processor().version;
  35021. return transformer
  35022. }
  35023. let cache;
  35024. Object.defineProperty(creator, 'postcss', {
  35025. get() {
  35026. if (!cache) cache = creator();
  35027. return cache
  35028. }
  35029. });
  35030. creator.process = function (css, processOpts, pluginOpts) {
  35031. return postcss([creator(pluginOpts)]).process(css, processOpts)
  35032. };
  35033. return creator
  35034. };
  35035. postcss.stringify = stringify;
  35036. postcss.parse = parse;
  35037. postcss.fromJSON = fromJSON;
  35038. postcss.list = list;
  35039. postcss.comment = defaults => new Comment(defaults);
  35040. postcss.atRule = defaults => new AtRule(defaults);
  35041. postcss.decl = defaults => new Declaration(defaults);
  35042. postcss.rule = defaults => new Rule(defaults);
  35043. postcss.root = defaults => new Root(defaults);
  35044. postcss.document = defaults => new Document(defaults);
  35045. postcss.CssSyntaxError = CssSyntaxError;
  35046. postcss.Declaration = Declaration;
  35047. postcss.Container = Container;
  35048. postcss.Processor = Processor;
  35049. postcss.Document = Document;
  35050. postcss.Comment = Comment;
  35051. postcss.Warning = Warning;
  35052. postcss.AtRule = AtRule;
  35053. postcss.Result = Result;
  35054. postcss.Input = Input;
  35055. postcss.Rule = Rule;
  35056. postcss.Root = Root;
  35057. postcss.Node = Node;
  35058. LazyResult.registerPostcss(postcss);
  35059. var postcss_1 = postcss;
  35060. postcss.default = postcss;
  35061. var postcss$1 = /*@__PURE__*/getDefaultExportFromCjs(postcss_1);
  35062. postcss$1.stringify;
  35063. postcss$1.fromJSON;
  35064. postcss$1.plugin;
  35065. postcss$1.parse;
  35066. postcss$1.list;
  35067. postcss$1.document;
  35068. postcss$1.comment;
  35069. postcss$1.atRule;
  35070. postcss$1.rule;
  35071. postcss$1.decl;
  35072. postcss$1.root;
  35073. postcss$1.CssSyntaxError;
  35074. postcss$1.Declaration;
  35075. postcss$1.Container;
  35076. postcss$1.Processor;
  35077. postcss$1.Document;
  35078. postcss$1.Comment;
  35079. postcss$1.Warning;
  35080. postcss$1.AtRule;
  35081. postcss$1.Result;
  35082. postcss$1.Input;
  35083. postcss$1.Rule;
  35084. postcss$1.Root;
  35085. postcss$1.Node;
  35086. const trimPlugin = () => {
  35087. return {
  35088. postcssPlugin: "vue-sfc-trim",
  35089. Once(root) {
  35090. root.walk(({ type, raws }) => {
  35091. if (type === "rule" || type === "atrule") {
  35092. if (raws.before)
  35093. raws.before = "\n";
  35094. if ("after" in raws && raws.after)
  35095. raws.after = "\n";
  35096. }
  35097. });
  35098. }
  35099. };
  35100. };
  35101. trimPlugin.postcss = true;
  35102. var dist = {exports: {}};
  35103. var processor = {exports: {}};
  35104. var parser = {exports: {}};
  35105. var root$1 = {exports: {}};
  35106. var container = {exports: {}};
  35107. var node$1 = {exports: {}};
  35108. var util$6 = {};
  35109. var unesc = {exports: {}};
  35110. (function (module, exports) {
  35111. exports.__esModule = true;
  35112. exports["default"] = unesc;
  35113. // Many thanks for this post which made this migration much easier.
  35114. // https://mathiasbynens.be/notes/css-escapes
  35115. /**
  35116. *
  35117. * @param {string} str
  35118. * @returns {[string, number]|undefined}
  35119. */
  35120. function gobbleHex(str) {
  35121. var lower = str.toLowerCase();
  35122. var hex = '';
  35123. var spaceTerminated = false;
  35124. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  35125. var code = lower.charCodeAt(i);
  35126. // check to see if we are dealing with a valid hex char [a-f|0-9]
  35127. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  35128. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  35129. spaceTerminated = code === 32;
  35130. if (!valid) {
  35131. break;
  35132. }
  35133. hex += lower[i];
  35134. }
  35135. if (hex.length === 0) {
  35136. return undefined;
  35137. }
  35138. var codePoint = parseInt(hex, 16);
  35139. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  35140. // Add special case for
  35141. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  35142. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  35143. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  35144. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  35145. }
  35146. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  35147. }
  35148. var CONTAINS_ESCAPE = /\\/;
  35149. function unesc(str) {
  35150. var needToProcess = CONTAINS_ESCAPE.test(str);
  35151. if (!needToProcess) {
  35152. return str;
  35153. }
  35154. var ret = "";
  35155. for (var i = 0; i < str.length; i++) {
  35156. if (str[i] === "\\") {
  35157. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  35158. if (gobbled !== undefined) {
  35159. ret += gobbled[0];
  35160. i += gobbled[1];
  35161. continue;
  35162. }
  35163. // Retain a pair of \\ if double escaped `\\\\`
  35164. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  35165. if (str[i + 1] === "\\") {
  35166. ret += "\\";
  35167. i++;
  35168. continue;
  35169. }
  35170. // if \\ is at the end of the string retain it
  35171. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  35172. if (str.length === i + 1) {
  35173. ret += str[i];
  35174. }
  35175. continue;
  35176. }
  35177. ret += str[i];
  35178. }
  35179. return ret;
  35180. }
  35181. module.exports = exports.default;
  35182. } (unesc, unesc.exports));
  35183. var unescExports = unesc.exports;
  35184. var getProp = {exports: {}};
  35185. (function (module, exports) {
  35186. exports.__esModule = true;
  35187. exports["default"] = getProp;
  35188. function getProp(obj) {
  35189. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35190. props[_key - 1] = arguments[_key];
  35191. }
  35192. while (props.length > 0) {
  35193. var prop = props.shift();
  35194. if (!obj[prop]) {
  35195. return undefined;
  35196. }
  35197. obj = obj[prop];
  35198. }
  35199. return obj;
  35200. }
  35201. module.exports = exports.default;
  35202. } (getProp, getProp.exports));
  35203. var getPropExports = getProp.exports;
  35204. var ensureObject = {exports: {}};
  35205. (function (module, exports) {
  35206. exports.__esModule = true;
  35207. exports["default"] = ensureObject;
  35208. function ensureObject(obj) {
  35209. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35210. props[_key - 1] = arguments[_key];
  35211. }
  35212. while (props.length > 0) {
  35213. var prop = props.shift();
  35214. if (!obj[prop]) {
  35215. obj[prop] = {};
  35216. }
  35217. obj = obj[prop];
  35218. }
  35219. }
  35220. module.exports = exports.default;
  35221. } (ensureObject, ensureObject.exports));
  35222. var ensureObjectExports = ensureObject.exports;
  35223. var stripComments = {exports: {}};
  35224. (function (module, exports) {
  35225. exports.__esModule = true;
  35226. exports["default"] = stripComments;
  35227. function stripComments(str) {
  35228. var s = "";
  35229. var commentStart = str.indexOf("/*");
  35230. var lastEnd = 0;
  35231. while (commentStart >= 0) {
  35232. s = s + str.slice(lastEnd, commentStart);
  35233. var commentEnd = str.indexOf("*/", commentStart + 2);
  35234. if (commentEnd < 0) {
  35235. return s;
  35236. }
  35237. lastEnd = commentEnd + 2;
  35238. commentStart = str.indexOf("/*", lastEnd);
  35239. }
  35240. s = s + str.slice(lastEnd);
  35241. return s;
  35242. }
  35243. module.exports = exports.default;
  35244. } (stripComments, stripComments.exports));
  35245. var stripCommentsExports = stripComments.exports;
  35246. util$6.__esModule = true;
  35247. util$6.unesc = util$6.stripComments = util$6.getProp = util$6.ensureObject = void 0;
  35248. var _unesc = _interopRequireDefault$1(unescExports);
  35249. util$6.unesc = _unesc["default"];
  35250. var _getProp = _interopRequireDefault$1(getPropExports);
  35251. util$6.getProp = _getProp["default"];
  35252. var _ensureObject = _interopRequireDefault$1(ensureObjectExports);
  35253. util$6.ensureObject = _ensureObject["default"];
  35254. var _stripComments = _interopRequireDefault$1(stripCommentsExports);
  35255. util$6.stripComments = _stripComments["default"];
  35256. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35257. (function (module, exports) {
  35258. exports.__esModule = true;
  35259. exports["default"] = void 0;
  35260. var _util = util$6;
  35261. 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); } }
  35262. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35263. var cloneNode = function cloneNode(obj, parent) {
  35264. if (typeof obj !== 'object' || obj === null) {
  35265. return obj;
  35266. }
  35267. var cloned = new obj.constructor();
  35268. for (var i in obj) {
  35269. if (!obj.hasOwnProperty(i)) {
  35270. continue;
  35271. }
  35272. var value = obj[i];
  35273. var type = typeof value;
  35274. if (i === 'parent' && type === 'object') {
  35275. if (parent) {
  35276. cloned[i] = parent;
  35277. }
  35278. } else if (value instanceof Array) {
  35279. cloned[i] = value.map(function (j) {
  35280. return cloneNode(j, cloned);
  35281. });
  35282. } else {
  35283. cloned[i] = cloneNode(value, cloned);
  35284. }
  35285. }
  35286. return cloned;
  35287. };
  35288. var Node = /*#__PURE__*/function () {
  35289. function Node(opts) {
  35290. if (opts === void 0) {
  35291. opts = {};
  35292. }
  35293. Object.assign(this, opts);
  35294. this.spaces = this.spaces || {};
  35295. this.spaces.before = this.spaces.before || '';
  35296. this.spaces.after = this.spaces.after || '';
  35297. }
  35298. var _proto = Node.prototype;
  35299. _proto.remove = function remove() {
  35300. if (this.parent) {
  35301. this.parent.removeChild(this);
  35302. }
  35303. this.parent = undefined;
  35304. return this;
  35305. };
  35306. _proto.replaceWith = function replaceWith() {
  35307. if (this.parent) {
  35308. for (var index in arguments) {
  35309. this.parent.insertBefore(this, arguments[index]);
  35310. }
  35311. this.remove();
  35312. }
  35313. return this;
  35314. };
  35315. _proto.next = function next() {
  35316. return this.parent.at(this.parent.index(this) + 1);
  35317. };
  35318. _proto.prev = function prev() {
  35319. return this.parent.at(this.parent.index(this) - 1);
  35320. };
  35321. _proto.clone = function clone(overrides) {
  35322. if (overrides === void 0) {
  35323. overrides = {};
  35324. }
  35325. var cloned = cloneNode(this);
  35326. for (var name in overrides) {
  35327. cloned[name] = overrides[name];
  35328. }
  35329. return cloned;
  35330. }
  35331. /**
  35332. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35333. * This allows non standard syntax to be appended to an existing property
  35334. * by specifying the escaped value. By specifying the escaped value,
  35335. * illegal characters are allowed to be directly inserted into css output.
  35336. * @param {string} name the property to set
  35337. * @param {any} value the unescaped value of the property
  35338. * @param {string} valueEscaped optional. the escaped value of the property.
  35339. */;
  35340. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  35341. if (!this.raws) {
  35342. this.raws = {};
  35343. }
  35344. var originalValue = this[name];
  35345. var originalEscaped = this.raws[name];
  35346. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  35347. if (originalEscaped || valueEscaped !== value) {
  35348. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  35349. } else {
  35350. delete this.raws[name]; // delete any escaped value that was created by the setter.
  35351. }
  35352. }
  35353. /**
  35354. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35355. * This allows the escaped value to be specified directly, allowing illegal
  35356. * characters to be directly inserted into css output.
  35357. * @param {string} name the property to set
  35358. * @param {any} value the unescaped value of the property
  35359. * @param {string} valueEscaped the escaped value of the property.
  35360. */;
  35361. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  35362. if (!this.raws) {
  35363. this.raws = {};
  35364. }
  35365. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35366. this.raws[name] = valueEscaped;
  35367. }
  35368. /**
  35369. * When you want a value to passed through to CSS directly. This method
  35370. * deletes the corresponding raw value causing the stringifier to fallback
  35371. * to the unescaped value.
  35372. * @param {string} name the property to set.
  35373. * @param {any} value The value that is both escaped and unescaped.
  35374. */;
  35375. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  35376. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35377. if (this.raws) {
  35378. delete this.raws[name];
  35379. }
  35380. }
  35381. /**
  35382. *
  35383. * @param {number} line The number (starting with 1)
  35384. * @param {number} column The column number (starting with 1)
  35385. */;
  35386. _proto.isAtPosition = function isAtPosition(line, column) {
  35387. if (this.source && this.source.start && this.source.end) {
  35388. if (this.source.start.line > line) {
  35389. return false;
  35390. }
  35391. if (this.source.end.line < line) {
  35392. return false;
  35393. }
  35394. if (this.source.start.line === line && this.source.start.column > column) {
  35395. return false;
  35396. }
  35397. if (this.source.end.line === line && this.source.end.column < column) {
  35398. return false;
  35399. }
  35400. return true;
  35401. }
  35402. return undefined;
  35403. };
  35404. _proto.stringifyProperty = function stringifyProperty(name) {
  35405. return this.raws && this.raws[name] || this[name];
  35406. };
  35407. _proto.valueToString = function valueToString() {
  35408. return String(this.stringifyProperty("value"));
  35409. };
  35410. _proto.toString = function toString() {
  35411. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  35412. };
  35413. _createClass(Node, [{
  35414. key: "rawSpaceBefore",
  35415. get: function get() {
  35416. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  35417. if (rawSpace === undefined) {
  35418. rawSpace = this.spaces && this.spaces.before;
  35419. }
  35420. return rawSpace || "";
  35421. },
  35422. set: function set(raw) {
  35423. (0, _util.ensureObject)(this, "raws", "spaces");
  35424. this.raws.spaces.before = raw;
  35425. }
  35426. }, {
  35427. key: "rawSpaceAfter",
  35428. get: function get() {
  35429. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  35430. if (rawSpace === undefined) {
  35431. rawSpace = this.spaces.after;
  35432. }
  35433. return rawSpace || "";
  35434. },
  35435. set: function set(raw) {
  35436. (0, _util.ensureObject)(this, "raws", "spaces");
  35437. this.raws.spaces.after = raw;
  35438. }
  35439. }]);
  35440. return Node;
  35441. }();
  35442. exports["default"] = Node;
  35443. module.exports = exports.default;
  35444. } (node$1, node$1.exports));
  35445. var nodeExports = node$1.exports;
  35446. var types = {};
  35447. types.__esModule = true;
  35448. types.UNIVERSAL = types.TAG = types.STRING = types.SELECTOR = types.ROOT = types.PSEUDO = types.NESTING = types.ID = types.COMMENT = types.COMBINATOR = types.CLASS = types.ATTRIBUTE = void 0;
  35449. var TAG = 'tag';
  35450. types.TAG = TAG;
  35451. var STRING = 'string';
  35452. types.STRING = STRING;
  35453. var SELECTOR = 'selector';
  35454. types.SELECTOR = SELECTOR;
  35455. var ROOT = 'root';
  35456. types.ROOT = ROOT;
  35457. var PSEUDO = 'pseudo';
  35458. types.PSEUDO = PSEUDO;
  35459. var NESTING = 'nesting';
  35460. types.NESTING = NESTING;
  35461. var ID = 'id';
  35462. types.ID = ID;
  35463. var COMMENT = 'comment';
  35464. types.COMMENT = COMMENT;
  35465. var COMBINATOR = 'combinator';
  35466. types.COMBINATOR = COMBINATOR;
  35467. var CLASS = 'class';
  35468. types.CLASS = CLASS;
  35469. var ATTRIBUTE = 'attribute';
  35470. types.ATTRIBUTE = ATTRIBUTE;
  35471. var UNIVERSAL = 'universal';
  35472. types.UNIVERSAL = UNIVERSAL;
  35473. (function (module, exports) {
  35474. exports.__esModule = true;
  35475. exports["default"] = void 0;
  35476. var _node = _interopRequireDefault(nodeExports);
  35477. var types$1 = _interopRequireWildcard(types);
  35478. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  35479. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
  35480. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35481. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); 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."); }
  35482. 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); }
  35483. 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; }
  35484. 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); } }
  35485. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35486. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35487. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35488. var Container = /*#__PURE__*/function (_Node) {
  35489. _inheritsLoose(Container, _Node);
  35490. function Container(opts) {
  35491. var _this;
  35492. _this = _Node.call(this, opts) || this;
  35493. if (!_this.nodes) {
  35494. _this.nodes = [];
  35495. }
  35496. return _this;
  35497. }
  35498. var _proto = Container.prototype;
  35499. _proto.append = function append(selector) {
  35500. selector.parent = this;
  35501. this.nodes.push(selector);
  35502. return this;
  35503. };
  35504. _proto.prepend = function prepend(selector) {
  35505. selector.parent = this;
  35506. this.nodes.unshift(selector);
  35507. return this;
  35508. };
  35509. _proto.at = function at(index) {
  35510. return this.nodes[index];
  35511. };
  35512. _proto.index = function index(child) {
  35513. if (typeof child === 'number') {
  35514. return child;
  35515. }
  35516. return this.nodes.indexOf(child);
  35517. };
  35518. _proto.removeChild = function removeChild(child) {
  35519. child = this.index(child);
  35520. this.at(child).parent = undefined;
  35521. this.nodes.splice(child, 1);
  35522. var index;
  35523. for (var id in this.indexes) {
  35524. index = this.indexes[id];
  35525. if (index >= child) {
  35526. this.indexes[id] = index - 1;
  35527. }
  35528. }
  35529. return this;
  35530. };
  35531. _proto.removeAll = function removeAll() {
  35532. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  35533. var node = _step.value;
  35534. node.parent = undefined;
  35535. }
  35536. this.nodes = [];
  35537. return this;
  35538. };
  35539. _proto.empty = function empty() {
  35540. return this.removeAll();
  35541. };
  35542. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  35543. newNode.parent = this;
  35544. var oldIndex = this.index(oldNode);
  35545. this.nodes.splice(oldIndex + 1, 0, newNode);
  35546. newNode.parent = this;
  35547. var index;
  35548. for (var id in this.indexes) {
  35549. index = this.indexes[id];
  35550. if (oldIndex <= index) {
  35551. this.indexes[id] = index + 1;
  35552. }
  35553. }
  35554. return this;
  35555. };
  35556. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  35557. newNode.parent = this;
  35558. var oldIndex = this.index(oldNode);
  35559. this.nodes.splice(oldIndex, 0, newNode);
  35560. newNode.parent = this;
  35561. var index;
  35562. for (var id in this.indexes) {
  35563. index = this.indexes[id];
  35564. if (index <= oldIndex) {
  35565. this.indexes[id] = index + 1;
  35566. }
  35567. }
  35568. return this;
  35569. };
  35570. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  35571. var found = undefined;
  35572. this.each(function (node) {
  35573. if (node.atPosition) {
  35574. var foundChild = node.atPosition(line, col);
  35575. if (foundChild) {
  35576. found = foundChild;
  35577. return false;
  35578. }
  35579. } else if (node.isAtPosition(line, col)) {
  35580. found = node;
  35581. return false;
  35582. }
  35583. });
  35584. return found;
  35585. }
  35586. /**
  35587. * Return the most specific node at the line and column number given.
  35588. * The source location is based on the original parsed location, locations aren't
  35589. * updated as selector nodes are mutated.
  35590. *
  35591. * Note that this location is relative to the location of the first character
  35592. * of the selector, and not the location of the selector in the overall document
  35593. * when used in conjunction with postcss.
  35594. *
  35595. * If not found, returns undefined.
  35596. * @param {number} line The line number of the node to find. (1-based index)
  35597. * @param {number} col The column number of the node to find. (1-based index)
  35598. */;
  35599. _proto.atPosition = function atPosition(line, col) {
  35600. if (this.isAtPosition(line, col)) {
  35601. return this._findChildAtPosition(line, col) || this;
  35602. } else {
  35603. return undefined;
  35604. }
  35605. };
  35606. _proto._inferEndPosition = function _inferEndPosition() {
  35607. if (this.last && this.last.source && this.last.source.end) {
  35608. this.source = this.source || {};
  35609. this.source.end = this.source.end || {};
  35610. Object.assign(this.source.end, this.last.source.end);
  35611. }
  35612. };
  35613. _proto.each = function each(callback) {
  35614. if (!this.lastEach) {
  35615. this.lastEach = 0;
  35616. }
  35617. if (!this.indexes) {
  35618. this.indexes = {};
  35619. }
  35620. this.lastEach++;
  35621. var id = this.lastEach;
  35622. this.indexes[id] = 0;
  35623. if (!this.length) {
  35624. return undefined;
  35625. }
  35626. var index, result;
  35627. while (this.indexes[id] < this.length) {
  35628. index = this.indexes[id];
  35629. result = callback(this.at(index), index);
  35630. if (result === false) {
  35631. break;
  35632. }
  35633. this.indexes[id] += 1;
  35634. }
  35635. delete this.indexes[id];
  35636. if (result === false) {
  35637. return false;
  35638. }
  35639. };
  35640. _proto.walk = function walk(callback) {
  35641. return this.each(function (node, i) {
  35642. var result = callback(node, i);
  35643. if (result !== false && node.length) {
  35644. result = node.walk(callback);
  35645. }
  35646. if (result === false) {
  35647. return false;
  35648. }
  35649. });
  35650. };
  35651. _proto.walkAttributes = function walkAttributes(callback) {
  35652. var _this2 = this;
  35653. return this.walk(function (selector) {
  35654. if (selector.type === types$1.ATTRIBUTE) {
  35655. return callback.call(_this2, selector);
  35656. }
  35657. });
  35658. };
  35659. _proto.walkClasses = function walkClasses(callback) {
  35660. var _this3 = this;
  35661. return this.walk(function (selector) {
  35662. if (selector.type === types$1.CLASS) {
  35663. return callback.call(_this3, selector);
  35664. }
  35665. });
  35666. };
  35667. _proto.walkCombinators = function walkCombinators(callback) {
  35668. var _this4 = this;
  35669. return this.walk(function (selector) {
  35670. if (selector.type === types$1.COMBINATOR) {
  35671. return callback.call(_this4, selector);
  35672. }
  35673. });
  35674. };
  35675. _proto.walkComments = function walkComments(callback) {
  35676. var _this5 = this;
  35677. return this.walk(function (selector) {
  35678. if (selector.type === types$1.COMMENT) {
  35679. return callback.call(_this5, selector);
  35680. }
  35681. });
  35682. };
  35683. _proto.walkIds = function walkIds(callback) {
  35684. var _this6 = this;
  35685. return this.walk(function (selector) {
  35686. if (selector.type === types$1.ID) {
  35687. return callback.call(_this6, selector);
  35688. }
  35689. });
  35690. };
  35691. _proto.walkNesting = function walkNesting(callback) {
  35692. var _this7 = this;
  35693. return this.walk(function (selector) {
  35694. if (selector.type === types$1.NESTING) {
  35695. return callback.call(_this7, selector);
  35696. }
  35697. });
  35698. };
  35699. _proto.walkPseudos = function walkPseudos(callback) {
  35700. var _this8 = this;
  35701. return this.walk(function (selector) {
  35702. if (selector.type === types$1.PSEUDO) {
  35703. return callback.call(_this8, selector);
  35704. }
  35705. });
  35706. };
  35707. _proto.walkTags = function walkTags(callback) {
  35708. var _this9 = this;
  35709. return this.walk(function (selector) {
  35710. if (selector.type === types$1.TAG) {
  35711. return callback.call(_this9, selector);
  35712. }
  35713. });
  35714. };
  35715. _proto.walkUniversals = function walkUniversals(callback) {
  35716. var _this10 = this;
  35717. return this.walk(function (selector) {
  35718. if (selector.type === types$1.UNIVERSAL) {
  35719. return callback.call(_this10, selector);
  35720. }
  35721. });
  35722. };
  35723. _proto.split = function split(callback) {
  35724. var _this11 = this;
  35725. var current = [];
  35726. return this.reduce(function (memo, node, index) {
  35727. var split = callback.call(_this11, node);
  35728. current.push(node);
  35729. if (split) {
  35730. memo.push(current);
  35731. current = [];
  35732. } else if (index === _this11.length - 1) {
  35733. memo.push(current);
  35734. }
  35735. return memo;
  35736. }, []);
  35737. };
  35738. _proto.map = function map(callback) {
  35739. return this.nodes.map(callback);
  35740. };
  35741. _proto.reduce = function reduce(callback, memo) {
  35742. return this.nodes.reduce(callback, memo);
  35743. };
  35744. _proto.every = function every(callback) {
  35745. return this.nodes.every(callback);
  35746. };
  35747. _proto.some = function some(callback) {
  35748. return this.nodes.some(callback);
  35749. };
  35750. _proto.filter = function filter(callback) {
  35751. return this.nodes.filter(callback);
  35752. };
  35753. _proto.sort = function sort(callback) {
  35754. return this.nodes.sort(callback);
  35755. };
  35756. _proto.toString = function toString() {
  35757. return this.map(String).join('');
  35758. };
  35759. _createClass(Container, [{
  35760. key: "first",
  35761. get: function get() {
  35762. return this.at(0);
  35763. }
  35764. }, {
  35765. key: "last",
  35766. get: function get() {
  35767. return this.at(this.length - 1);
  35768. }
  35769. }, {
  35770. key: "length",
  35771. get: function get() {
  35772. return this.nodes.length;
  35773. }
  35774. }]);
  35775. return Container;
  35776. }(_node["default"]);
  35777. exports["default"] = Container;
  35778. module.exports = exports.default;
  35779. } (container, container.exports));
  35780. var containerExports = container.exports;
  35781. (function (module, exports) {
  35782. exports.__esModule = true;
  35783. exports["default"] = void 0;
  35784. var _container = _interopRequireDefault(containerExports);
  35785. var _types = types;
  35786. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35787. 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); } }
  35788. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35789. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35790. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35791. var Root = /*#__PURE__*/function (_Container) {
  35792. _inheritsLoose(Root, _Container);
  35793. function Root(opts) {
  35794. var _this;
  35795. _this = _Container.call(this, opts) || this;
  35796. _this.type = _types.ROOT;
  35797. return _this;
  35798. }
  35799. var _proto = Root.prototype;
  35800. _proto.toString = function toString() {
  35801. var str = this.reduce(function (memo, selector) {
  35802. memo.push(String(selector));
  35803. return memo;
  35804. }, []).join(',');
  35805. return this.trailingComma ? str + ',' : str;
  35806. };
  35807. _proto.error = function error(message, options) {
  35808. if (this._error) {
  35809. return this._error(message, options);
  35810. } else {
  35811. return new Error(message);
  35812. }
  35813. };
  35814. _createClass(Root, [{
  35815. key: "errorGenerator",
  35816. set: function set(handler) {
  35817. this._error = handler;
  35818. }
  35819. }]);
  35820. return Root;
  35821. }(_container["default"]);
  35822. exports["default"] = Root;
  35823. module.exports = exports.default;
  35824. } (root$1, root$1.exports));
  35825. var rootExports = root$1.exports;
  35826. var selector$1 = {exports: {}};
  35827. (function (module, exports) {
  35828. exports.__esModule = true;
  35829. exports["default"] = void 0;
  35830. var _container = _interopRequireDefault(containerExports);
  35831. var _types = types;
  35832. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35833. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35834. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35835. var Selector = /*#__PURE__*/function (_Container) {
  35836. _inheritsLoose(Selector, _Container);
  35837. function Selector(opts) {
  35838. var _this;
  35839. _this = _Container.call(this, opts) || this;
  35840. _this.type = _types.SELECTOR;
  35841. return _this;
  35842. }
  35843. return Selector;
  35844. }(_container["default"]);
  35845. exports["default"] = Selector;
  35846. module.exports = exports.default;
  35847. } (selector$1, selector$1.exports));
  35848. var selectorExports = selector$1.exports;
  35849. var className$1 = {exports: {}};
  35850. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  35851. var object = {};
  35852. var hasOwnProperty$1 = object.hasOwnProperty;
  35853. var merge$2 = function merge(options, defaults) {
  35854. if (!options) {
  35855. return defaults;
  35856. }
  35857. var result = {};
  35858. for (var key in defaults) {
  35859. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  35860. // only recognized option names are used.
  35861. result[key] = hasOwnProperty$1.call(options, key) ? options[key] : defaults[key];
  35862. }
  35863. return result;
  35864. };
  35865. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  35866. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  35867. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  35868. // https://mathiasbynens.be/notes/css-escapes#css
  35869. var cssesc = function cssesc(string, options) {
  35870. options = merge$2(options, cssesc.options);
  35871. if (options.quotes != 'single' && options.quotes != 'double') {
  35872. options.quotes = 'single';
  35873. }
  35874. var quote = options.quotes == 'double' ? '"' : '\'';
  35875. var isIdentifier = options.isIdentifier;
  35876. var firstChar = string.charAt(0);
  35877. var output = '';
  35878. var counter = 0;
  35879. var length = string.length;
  35880. while (counter < length) {
  35881. var character = string.charAt(counter++);
  35882. var codePoint = character.charCodeAt();
  35883. var value = void 0;
  35884. // If it’s not a printable ASCII character…
  35885. if (codePoint < 0x20 || codePoint > 0x7E) {
  35886. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  35887. // It’s a high surrogate, and there is a next character.
  35888. var extra = string.charCodeAt(counter++);
  35889. if ((extra & 0xFC00) == 0xDC00) {
  35890. // next character is low surrogate
  35891. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  35892. } else {
  35893. // It’s an unmatched surrogate; only append this code unit, in case
  35894. // the next code unit is the high surrogate of a surrogate pair.
  35895. counter--;
  35896. }
  35897. }
  35898. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35899. } else {
  35900. if (options.escapeEverything) {
  35901. if (regexAnySingleEscape.test(character)) {
  35902. value = '\\' + character;
  35903. } else {
  35904. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35905. }
  35906. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  35907. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35908. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  35909. value = '\\' + character;
  35910. } else {
  35911. value = character;
  35912. }
  35913. }
  35914. output += value;
  35915. }
  35916. if (isIdentifier) {
  35917. if (/^-[-\d]/.test(output)) {
  35918. output = '\\-' + output.slice(1);
  35919. } else if (/\d/.test(firstChar)) {
  35920. output = '\\3' + firstChar + ' ' + output.slice(1);
  35921. }
  35922. }
  35923. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  35924. // since they’re redundant. Note that this is only possible if the escape
  35925. // sequence isn’t preceded by an odd number of backslashes.
  35926. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  35927. if ($1 && $1.length % 2) {
  35928. // It’s not safe to remove the space, so don’t.
  35929. return $0;
  35930. }
  35931. // Strip the space.
  35932. return ($1 || '') + $2;
  35933. });
  35934. if (!isIdentifier && options.wrap) {
  35935. return quote + output + quote;
  35936. }
  35937. return output;
  35938. };
  35939. // Expose default options (so they can be overridden globally).
  35940. cssesc.options = {
  35941. 'escapeEverything': false,
  35942. 'isIdentifier': false,
  35943. 'quotes': 'single',
  35944. 'wrap': false
  35945. };
  35946. cssesc.version = '3.0.0';
  35947. var cssesc_1 = cssesc;
  35948. (function (module, exports) {
  35949. exports.__esModule = true;
  35950. exports["default"] = void 0;
  35951. var _cssesc = _interopRequireDefault(cssesc_1);
  35952. var _util = util$6;
  35953. var _node = _interopRequireDefault(nodeExports);
  35954. var _types = types;
  35955. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35956. 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); } }
  35957. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35958. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35959. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35960. var ClassName = /*#__PURE__*/function (_Node) {
  35961. _inheritsLoose(ClassName, _Node);
  35962. function ClassName(opts) {
  35963. var _this;
  35964. _this = _Node.call(this, opts) || this;
  35965. _this.type = _types.CLASS;
  35966. _this._constructed = true;
  35967. return _this;
  35968. }
  35969. var _proto = ClassName.prototype;
  35970. _proto.valueToString = function valueToString() {
  35971. return '.' + _Node.prototype.valueToString.call(this);
  35972. };
  35973. _createClass(ClassName, [{
  35974. key: "value",
  35975. get: function get() {
  35976. return this._value;
  35977. },
  35978. set: function set(v) {
  35979. if (this._constructed) {
  35980. var escaped = (0, _cssesc["default"])(v, {
  35981. isIdentifier: true
  35982. });
  35983. if (escaped !== v) {
  35984. (0, _util.ensureObject)(this, "raws");
  35985. this.raws.value = escaped;
  35986. } else if (this.raws) {
  35987. delete this.raws.value;
  35988. }
  35989. }
  35990. this._value = v;
  35991. }
  35992. }]);
  35993. return ClassName;
  35994. }(_node["default"]);
  35995. exports["default"] = ClassName;
  35996. module.exports = exports.default;
  35997. } (className$1, className$1.exports));
  35998. var classNameExports = className$1.exports;
  35999. var comment$2 = {exports: {}};
  36000. (function (module, exports) {
  36001. exports.__esModule = true;
  36002. exports["default"] = void 0;
  36003. var _node = _interopRequireDefault(nodeExports);
  36004. var _types = types;
  36005. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36006. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36007. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36008. var Comment = /*#__PURE__*/function (_Node) {
  36009. _inheritsLoose(Comment, _Node);
  36010. function Comment(opts) {
  36011. var _this;
  36012. _this = _Node.call(this, opts) || this;
  36013. _this.type = _types.COMMENT;
  36014. return _this;
  36015. }
  36016. return Comment;
  36017. }(_node["default"]);
  36018. exports["default"] = Comment;
  36019. module.exports = exports.default;
  36020. } (comment$2, comment$2.exports));
  36021. var commentExports = comment$2.exports;
  36022. var id$1 = {exports: {}};
  36023. (function (module, exports) {
  36024. exports.__esModule = true;
  36025. exports["default"] = void 0;
  36026. var _node = _interopRequireDefault(nodeExports);
  36027. var _types = types;
  36028. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36029. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36030. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36031. var ID = /*#__PURE__*/function (_Node) {
  36032. _inheritsLoose(ID, _Node);
  36033. function ID(opts) {
  36034. var _this;
  36035. _this = _Node.call(this, opts) || this;
  36036. _this.type = _types.ID;
  36037. return _this;
  36038. }
  36039. var _proto = ID.prototype;
  36040. _proto.valueToString = function valueToString() {
  36041. return '#' + _Node.prototype.valueToString.call(this);
  36042. };
  36043. return ID;
  36044. }(_node["default"]);
  36045. exports["default"] = ID;
  36046. module.exports = exports.default;
  36047. } (id$1, id$1.exports));
  36048. var idExports = id$1.exports;
  36049. var tag$1 = {exports: {}};
  36050. var namespace = {exports: {}};
  36051. (function (module, exports) {
  36052. exports.__esModule = true;
  36053. exports["default"] = void 0;
  36054. var _cssesc = _interopRequireDefault(cssesc_1);
  36055. var _util = util$6;
  36056. var _node = _interopRequireDefault(nodeExports);
  36057. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36058. 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); } }
  36059. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36060. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36061. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36062. var Namespace = /*#__PURE__*/function (_Node) {
  36063. _inheritsLoose(Namespace, _Node);
  36064. function Namespace() {
  36065. return _Node.apply(this, arguments) || this;
  36066. }
  36067. var _proto = Namespace.prototype;
  36068. _proto.qualifiedName = function qualifiedName(value) {
  36069. if (this.namespace) {
  36070. return this.namespaceString + "|" + value;
  36071. } else {
  36072. return value;
  36073. }
  36074. };
  36075. _proto.valueToString = function valueToString() {
  36076. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  36077. };
  36078. _createClass(Namespace, [{
  36079. key: "namespace",
  36080. get: function get() {
  36081. return this._namespace;
  36082. },
  36083. set: function set(namespace) {
  36084. if (namespace === true || namespace === "*" || namespace === "&") {
  36085. this._namespace = namespace;
  36086. if (this.raws) {
  36087. delete this.raws.namespace;
  36088. }
  36089. return;
  36090. }
  36091. var escaped = (0, _cssesc["default"])(namespace, {
  36092. isIdentifier: true
  36093. });
  36094. this._namespace = namespace;
  36095. if (escaped !== namespace) {
  36096. (0, _util.ensureObject)(this, "raws");
  36097. this.raws.namespace = escaped;
  36098. } else if (this.raws) {
  36099. delete this.raws.namespace;
  36100. }
  36101. }
  36102. }, {
  36103. key: "ns",
  36104. get: function get() {
  36105. return this._namespace;
  36106. },
  36107. set: function set(namespace) {
  36108. this.namespace = namespace;
  36109. }
  36110. }, {
  36111. key: "namespaceString",
  36112. get: function get() {
  36113. if (this.namespace) {
  36114. var ns = this.stringifyProperty("namespace");
  36115. if (ns === true) {
  36116. return '';
  36117. } else {
  36118. return ns;
  36119. }
  36120. } else {
  36121. return '';
  36122. }
  36123. }
  36124. }]);
  36125. return Namespace;
  36126. }(_node["default"]);
  36127. exports["default"] = Namespace;
  36128. module.exports = exports.default;
  36129. } (namespace, namespace.exports));
  36130. var namespaceExports = namespace.exports;
  36131. (function (module, exports) {
  36132. exports.__esModule = true;
  36133. exports["default"] = void 0;
  36134. var _namespace = _interopRequireDefault(namespaceExports);
  36135. var _types = types;
  36136. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36137. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36138. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36139. var Tag = /*#__PURE__*/function (_Namespace) {
  36140. _inheritsLoose(Tag, _Namespace);
  36141. function Tag(opts) {
  36142. var _this;
  36143. _this = _Namespace.call(this, opts) || this;
  36144. _this.type = _types.TAG;
  36145. return _this;
  36146. }
  36147. return Tag;
  36148. }(_namespace["default"]);
  36149. exports["default"] = Tag;
  36150. module.exports = exports.default;
  36151. } (tag$1, tag$1.exports));
  36152. var tagExports = tag$1.exports;
  36153. var string$1 = {exports: {}};
  36154. (function (module, exports) {
  36155. exports.__esModule = true;
  36156. exports["default"] = void 0;
  36157. var _node = _interopRequireDefault(nodeExports);
  36158. var _types = types;
  36159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36160. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36161. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36162. var String = /*#__PURE__*/function (_Node) {
  36163. _inheritsLoose(String, _Node);
  36164. function String(opts) {
  36165. var _this;
  36166. _this = _Node.call(this, opts) || this;
  36167. _this.type = _types.STRING;
  36168. return _this;
  36169. }
  36170. return String;
  36171. }(_node["default"]);
  36172. exports["default"] = String;
  36173. module.exports = exports.default;
  36174. } (string$1, string$1.exports));
  36175. var stringExports = string$1.exports;
  36176. var pseudo$1 = {exports: {}};
  36177. (function (module, exports) {
  36178. exports.__esModule = true;
  36179. exports["default"] = void 0;
  36180. var _container = _interopRequireDefault(containerExports);
  36181. var _types = types;
  36182. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36183. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36184. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36185. var Pseudo = /*#__PURE__*/function (_Container) {
  36186. _inheritsLoose(Pseudo, _Container);
  36187. function Pseudo(opts) {
  36188. var _this;
  36189. _this = _Container.call(this, opts) || this;
  36190. _this.type = _types.PSEUDO;
  36191. return _this;
  36192. }
  36193. var _proto = Pseudo.prototype;
  36194. _proto.toString = function toString() {
  36195. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  36196. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  36197. };
  36198. return Pseudo;
  36199. }(_container["default"]);
  36200. exports["default"] = Pseudo;
  36201. module.exports = exports.default;
  36202. } (pseudo$1, pseudo$1.exports));
  36203. var pseudoExports = pseudo$1.exports;
  36204. var attribute$1 = {};
  36205. /**
  36206. * For Node.js, simply re-export the core `util.deprecate` function.
  36207. */
  36208. var node = require$$0$1.deprecate;
  36209. (function (exports) {
  36210. exports.__esModule = true;
  36211. exports["default"] = void 0;
  36212. exports.unescapeValue = unescapeValue;
  36213. var _cssesc = _interopRequireDefault(cssesc_1);
  36214. var _unesc = _interopRequireDefault(unescExports);
  36215. var _namespace = _interopRequireDefault(namespaceExports);
  36216. var _types = types;
  36217. var _CSSESC_QUOTE_OPTIONS;
  36218. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36219. 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); } }
  36220. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36221. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36222. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36223. var deprecate = node;
  36224. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  36225. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  36226. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  36227. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  36228. function unescapeValue(value) {
  36229. var deprecatedUsage = false;
  36230. var quoteMark = null;
  36231. var unescaped = value;
  36232. var m = unescaped.match(WRAPPED_IN_QUOTES);
  36233. if (m) {
  36234. quoteMark = m[1];
  36235. unescaped = m[2];
  36236. }
  36237. unescaped = (0, _unesc["default"])(unescaped);
  36238. if (unescaped !== value) {
  36239. deprecatedUsage = true;
  36240. }
  36241. return {
  36242. deprecatedUsage: deprecatedUsage,
  36243. unescaped: unescaped,
  36244. quoteMark: quoteMark
  36245. };
  36246. }
  36247. function handleDeprecatedContructorOpts(opts) {
  36248. if (opts.quoteMark !== undefined) {
  36249. return opts;
  36250. }
  36251. if (opts.value === undefined) {
  36252. return opts;
  36253. }
  36254. warnOfDeprecatedConstructor();
  36255. var _unescapeValue = unescapeValue(opts.value),
  36256. quoteMark = _unescapeValue.quoteMark,
  36257. unescaped = _unescapeValue.unescaped;
  36258. if (!opts.raws) {
  36259. opts.raws = {};
  36260. }
  36261. if (opts.raws.value === undefined) {
  36262. opts.raws.value = opts.value;
  36263. }
  36264. opts.value = unescaped;
  36265. opts.quoteMark = quoteMark;
  36266. return opts;
  36267. }
  36268. var Attribute = /*#__PURE__*/function (_Namespace) {
  36269. _inheritsLoose(Attribute, _Namespace);
  36270. function Attribute(opts) {
  36271. var _this;
  36272. if (opts === void 0) {
  36273. opts = {};
  36274. }
  36275. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  36276. _this.type = _types.ATTRIBUTE;
  36277. _this.raws = _this.raws || {};
  36278. Object.defineProperty(_this.raws, 'unquoted', {
  36279. get: deprecate(function () {
  36280. return _this.value;
  36281. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  36282. set: deprecate(function () {
  36283. return _this.value;
  36284. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  36285. });
  36286. _this._constructed = true;
  36287. return _this;
  36288. }
  36289. /**
  36290. * Returns the Attribute's value quoted such that it would be legal to use
  36291. * in the value of a css file. The original value's quotation setting
  36292. * used for stringification is left unchanged. See `setValue(value, options)`
  36293. * if you want to control the quote settings of a new value for the attribute.
  36294. *
  36295. * You can also change the quotation used for the current value by setting quoteMark.
  36296. *
  36297. * Options:
  36298. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  36299. * option is not set, the original value for quoteMark will be used. If
  36300. * indeterminate, a double quote is used. The legal values are:
  36301. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  36302. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  36303. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  36304. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  36305. * over the quoteMark option value.
  36306. * * smart {boolean} - if true, will select a quote mark based on the value
  36307. * and the other options specified here. See the `smartQuoteMark()`
  36308. * method.
  36309. **/
  36310. var _proto = Attribute.prototype;
  36311. _proto.getQuotedValue = function getQuotedValue(options) {
  36312. if (options === void 0) {
  36313. options = {};
  36314. }
  36315. var quoteMark = this._determineQuoteMark(options);
  36316. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  36317. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  36318. return escaped;
  36319. };
  36320. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  36321. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  36322. }
  36323. /**
  36324. * Set the unescaped value with the specified quotation options. The value
  36325. * provided must not include any wrapping quote marks -- those quotes will
  36326. * be interpreted as part of the value and escaped accordingly.
  36327. */;
  36328. _proto.setValue = function setValue(value, options) {
  36329. if (options === void 0) {
  36330. options = {};
  36331. }
  36332. this._value = value;
  36333. this._quoteMark = this._determineQuoteMark(options);
  36334. this._syncRawValue();
  36335. }
  36336. /**
  36337. * Intelligently select a quoteMark value based on the value's contents. If
  36338. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  36339. * mark will be picked that minimizes the number of escapes.
  36340. *
  36341. * If there's no clear winner, the quote mark from these options is used,
  36342. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  36343. * true). If the quoteMark is unspecified, a double quote is used.
  36344. *
  36345. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  36346. * from the quoteValue method.
  36347. */;
  36348. _proto.smartQuoteMark = function smartQuoteMark(options) {
  36349. var v = this.value;
  36350. var numSingleQuotes = v.replace(/[^']/g, '').length;
  36351. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  36352. if (numSingleQuotes + numDoubleQuotes === 0) {
  36353. var escaped = (0, _cssesc["default"])(v, {
  36354. isIdentifier: true
  36355. });
  36356. if (escaped === v) {
  36357. return Attribute.NO_QUOTE;
  36358. } else {
  36359. var pref = this.preferredQuoteMark(options);
  36360. if (pref === Attribute.NO_QUOTE) {
  36361. // pick a quote mark that isn't none and see if it's smaller
  36362. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  36363. var opts = CSSESC_QUOTE_OPTIONS[quote];
  36364. var quoteValue = (0, _cssesc["default"])(v, opts);
  36365. if (quoteValue.length < escaped.length) {
  36366. return quote;
  36367. }
  36368. }
  36369. return pref;
  36370. }
  36371. } else if (numDoubleQuotes === numSingleQuotes) {
  36372. return this.preferredQuoteMark(options);
  36373. } else if (numDoubleQuotes < numSingleQuotes) {
  36374. return Attribute.DOUBLE_QUOTE;
  36375. } else {
  36376. return Attribute.SINGLE_QUOTE;
  36377. }
  36378. }
  36379. /**
  36380. * Selects the preferred quote mark based on the options and the current quote mark value.
  36381. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  36382. * instead.
  36383. */;
  36384. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  36385. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  36386. if (quoteMark === undefined) {
  36387. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  36388. }
  36389. if (quoteMark === undefined) {
  36390. quoteMark = Attribute.DOUBLE_QUOTE;
  36391. }
  36392. return quoteMark;
  36393. };
  36394. _proto._syncRawValue = function _syncRawValue() {
  36395. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  36396. if (rawValue === this._value) {
  36397. if (this.raws) {
  36398. delete this.raws.value;
  36399. }
  36400. } else {
  36401. this.raws.value = rawValue;
  36402. }
  36403. };
  36404. _proto._handleEscapes = function _handleEscapes(prop, value) {
  36405. if (this._constructed) {
  36406. var escaped = (0, _cssesc["default"])(value, {
  36407. isIdentifier: true
  36408. });
  36409. if (escaped !== value) {
  36410. this.raws[prop] = escaped;
  36411. } else {
  36412. delete this.raws[prop];
  36413. }
  36414. }
  36415. };
  36416. _proto._spacesFor = function _spacesFor(name) {
  36417. var attrSpaces = {
  36418. before: '',
  36419. after: ''
  36420. };
  36421. var spaces = this.spaces[name] || {};
  36422. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  36423. return Object.assign(attrSpaces, spaces, rawSpaces);
  36424. };
  36425. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  36426. if (spaceName === void 0) {
  36427. spaceName = name;
  36428. }
  36429. if (concat === void 0) {
  36430. concat = defaultAttrConcat;
  36431. }
  36432. var attrSpaces = this._spacesFor(spaceName);
  36433. return concat(this.stringifyProperty(name), attrSpaces);
  36434. }
  36435. /**
  36436. * returns the offset of the attribute part specified relative to the
  36437. * start of the node of the output string.
  36438. *
  36439. * * "ns" - alias for "namespace"
  36440. * * "namespace" - the namespace if it exists.
  36441. * * "attribute" - the attribute name
  36442. * * "attributeNS" - the start of the attribute or its namespace
  36443. * * "operator" - the match operator of the attribute
  36444. * * "value" - The value (string or identifier)
  36445. * * "insensitive" - the case insensitivity flag;
  36446. * @param part One of the possible values inside an attribute.
  36447. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  36448. */;
  36449. _proto.offsetOf = function offsetOf(name) {
  36450. var count = 1;
  36451. var attributeSpaces = this._spacesFor("attribute");
  36452. count += attributeSpaces.before.length;
  36453. if (name === "namespace" || name === "ns") {
  36454. return this.namespace ? count : -1;
  36455. }
  36456. if (name === "attributeNS") {
  36457. return count;
  36458. }
  36459. count += this.namespaceString.length;
  36460. if (this.namespace) {
  36461. count += 1;
  36462. }
  36463. if (name === "attribute") {
  36464. return count;
  36465. }
  36466. count += this.stringifyProperty("attribute").length;
  36467. count += attributeSpaces.after.length;
  36468. var operatorSpaces = this._spacesFor("operator");
  36469. count += operatorSpaces.before.length;
  36470. var operator = this.stringifyProperty("operator");
  36471. if (name === "operator") {
  36472. return operator ? count : -1;
  36473. }
  36474. count += operator.length;
  36475. count += operatorSpaces.after.length;
  36476. var valueSpaces = this._spacesFor("value");
  36477. count += valueSpaces.before.length;
  36478. var value = this.stringifyProperty("value");
  36479. if (name === "value") {
  36480. return value ? count : -1;
  36481. }
  36482. count += value.length;
  36483. count += valueSpaces.after.length;
  36484. var insensitiveSpaces = this._spacesFor("insensitive");
  36485. count += insensitiveSpaces.before.length;
  36486. if (name === "insensitive") {
  36487. return this.insensitive ? count : -1;
  36488. }
  36489. return -1;
  36490. };
  36491. _proto.toString = function toString() {
  36492. var _this2 = this;
  36493. var selector = [this.rawSpaceBefore, '['];
  36494. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  36495. if (this.operator && (this.value || this.value === '')) {
  36496. selector.push(this._stringFor('operator'));
  36497. selector.push(this._stringFor('value'));
  36498. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  36499. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  36500. attrSpaces.before = " ";
  36501. }
  36502. return defaultAttrConcat(attrValue, attrSpaces);
  36503. }));
  36504. }
  36505. selector.push(']');
  36506. selector.push(this.rawSpaceAfter);
  36507. return selector.join('');
  36508. };
  36509. _createClass(Attribute, [{
  36510. key: "quoted",
  36511. get: function get() {
  36512. var qm = this.quoteMark;
  36513. return qm === "'" || qm === '"';
  36514. },
  36515. set: function set(value) {
  36516. warnOfDeprecatedQuotedAssignment();
  36517. }
  36518. /**
  36519. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  36520. * returns `null` if the value is not quoted.
  36521. * returns `undefined` if the quotation state is unknown (this can happen when
  36522. * the attribute is constructed without specifying a quote mark.)
  36523. */
  36524. }, {
  36525. key: "quoteMark",
  36526. get: function get() {
  36527. return this._quoteMark;
  36528. }
  36529. /**
  36530. * Set the quote mark to be used by this attribute's value.
  36531. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  36532. * value is updated accordingly.
  36533. *
  36534. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  36535. */,
  36536. set: function set(quoteMark) {
  36537. if (!this._constructed) {
  36538. this._quoteMark = quoteMark;
  36539. return;
  36540. }
  36541. if (this._quoteMark !== quoteMark) {
  36542. this._quoteMark = quoteMark;
  36543. this._syncRawValue();
  36544. }
  36545. }
  36546. }, {
  36547. key: "qualifiedAttribute",
  36548. get: function get() {
  36549. return this.qualifiedName(this.raws.attribute || this.attribute);
  36550. }
  36551. }, {
  36552. key: "insensitiveFlag",
  36553. get: function get() {
  36554. return this.insensitive ? 'i' : '';
  36555. }
  36556. }, {
  36557. key: "value",
  36558. get: function get() {
  36559. return this._value;
  36560. },
  36561. set:
  36562. /**
  36563. * Before 3.0, the value had to be set to an escaped value including any wrapped
  36564. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  36565. * is unescaped during parsing and any quote marks are removed.
  36566. *
  36567. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  36568. * a deprecation warning is raised when the new value contains any characters that would
  36569. * require escaping (including if it contains wrapped quotes).
  36570. *
  36571. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  36572. * how the new value is quoted.
  36573. */
  36574. function set(v) {
  36575. if (this._constructed) {
  36576. var _unescapeValue2 = unescapeValue(v),
  36577. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  36578. unescaped = _unescapeValue2.unescaped,
  36579. quoteMark = _unescapeValue2.quoteMark;
  36580. if (deprecatedUsage) {
  36581. warnOfDeprecatedValueAssignment();
  36582. }
  36583. if (unescaped === this._value && quoteMark === this._quoteMark) {
  36584. return;
  36585. }
  36586. this._value = unescaped;
  36587. this._quoteMark = quoteMark;
  36588. this._syncRawValue();
  36589. } else {
  36590. this._value = v;
  36591. }
  36592. }
  36593. }, {
  36594. key: "insensitive",
  36595. get: function get() {
  36596. return this._insensitive;
  36597. }
  36598. /**
  36599. * Set the case insensitive flag.
  36600. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  36601. * of the attribute is updated accordingly.
  36602. *
  36603. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  36604. */,
  36605. set: function set(insensitive) {
  36606. if (!insensitive) {
  36607. this._insensitive = false;
  36608. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  36609. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  36610. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  36611. this.raws.insensitiveFlag = undefined;
  36612. }
  36613. }
  36614. this._insensitive = insensitive;
  36615. }
  36616. }, {
  36617. key: "attribute",
  36618. get: function get() {
  36619. return this._attribute;
  36620. },
  36621. set: function set(name) {
  36622. this._handleEscapes("attribute", name);
  36623. this._attribute = name;
  36624. }
  36625. }]);
  36626. return Attribute;
  36627. }(_namespace["default"]);
  36628. exports["default"] = Attribute;
  36629. Attribute.NO_QUOTE = null;
  36630. Attribute.SINGLE_QUOTE = "'";
  36631. Attribute.DOUBLE_QUOTE = '"';
  36632. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  36633. "'": {
  36634. quotes: 'single',
  36635. wrap: true
  36636. },
  36637. '"': {
  36638. quotes: 'double',
  36639. wrap: true
  36640. }
  36641. }, _CSSESC_QUOTE_OPTIONS[null] = {
  36642. isIdentifier: true
  36643. }, _CSSESC_QUOTE_OPTIONS);
  36644. function defaultAttrConcat(attrValue, attrSpaces) {
  36645. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  36646. }
  36647. } (attribute$1));
  36648. var universal$1 = {exports: {}};
  36649. (function (module, exports) {
  36650. exports.__esModule = true;
  36651. exports["default"] = void 0;
  36652. var _namespace = _interopRequireDefault(namespaceExports);
  36653. var _types = types;
  36654. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36655. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36656. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36657. var Universal = /*#__PURE__*/function (_Namespace) {
  36658. _inheritsLoose(Universal, _Namespace);
  36659. function Universal(opts) {
  36660. var _this;
  36661. _this = _Namespace.call(this, opts) || this;
  36662. _this.type = _types.UNIVERSAL;
  36663. _this.value = '*';
  36664. return _this;
  36665. }
  36666. return Universal;
  36667. }(_namespace["default"]);
  36668. exports["default"] = Universal;
  36669. module.exports = exports.default;
  36670. } (universal$1, universal$1.exports));
  36671. var universalExports = universal$1.exports;
  36672. var combinator$2 = {exports: {}};
  36673. (function (module, exports) {
  36674. exports.__esModule = true;
  36675. exports["default"] = void 0;
  36676. var _node = _interopRequireDefault(nodeExports);
  36677. var _types = types;
  36678. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36679. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36680. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36681. var Combinator = /*#__PURE__*/function (_Node) {
  36682. _inheritsLoose(Combinator, _Node);
  36683. function Combinator(opts) {
  36684. var _this;
  36685. _this = _Node.call(this, opts) || this;
  36686. _this.type = _types.COMBINATOR;
  36687. return _this;
  36688. }
  36689. return Combinator;
  36690. }(_node["default"]);
  36691. exports["default"] = Combinator;
  36692. module.exports = exports.default;
  36693. } (combinator$2, combinator$2.exports));
  36694. var combinatorExports = combinator$2.exports;
  36695. var nesting$1 = {exports: {}};
  36696. (function (module, exports) {
  36697. exports.__esModule = true;
  36698. exports["default"] = void 0;
  36699. var _node = _interopRequireDefault(nodeExports);
  36700. var _types = types;
  36701. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36702. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36703. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36704. var Nesting = /*#__PURE__*/function (_Node) {
  36705. _inheritsLoose(Nesting, _Node);
  36706. function Nesting(opts) {
  36707. var _this;
  36708. _this = _Node.call(this, opts) || this;
  36709. _this.type = _types.NESTING;
  36710. _this.value = '&';
  36711. return _this;
  36712. }
  36713. return Nesting;
  36714. }(_node["default"]);
  36715. exports["default"] = Nesting;
  36716. module.exports = exports.default;
  36717. } (nesting$1, nesting$1.exports));
  36718. var nestingExports = nesting$1.exports;
  36719. var sortAscending = {exports: {}};
  36720. (function (module, exports) {
  36721. exports.__esModule = true;
  36722. exports["default"] = sortAscending;
  36723. function sortAscending(list) {
  36724. return list.sort(function (a, b) {
  36725. return a - b;
  36726. });
  36727. }
  36728. module.exports = exports.default;
  36729. } (sortAscending, sortAscending.exports));
  36730. var sortAscendingExports = sortAscending.exports;
  36731. var tokenize = {};
  36732. var tokenTypes = {};
  36733. tokenTypes.__esModule = true;
  36734. tokenTypes.word = tokenTypes.tilde = tokenTypes.tab = tokenTypes.str = tokenTypes.space = tokenTypes.slash = tokenTypes.singleQuote = tokenTypes.semicolon = tokenTypes.plus = tokenTypes.pipe = tokenTypes.openSquare = tokenTypes.openParenthesis = tokenTypes.newline = tokenTypes.greaterThan = tokenTypes.feed = tokenTypes.equals = tokenTypes.doubleQuote = tokenTypes.dollar = tokenTypes.cr = tokenTypes.comment = tokenTypes.comma = tokenTypes.combinator = tokenTypes.colon = tokenTypes.closeSquare = tokenTypes.closeParenthesis = tokenTypes.caret = tokenTypes.bang = tokenTypes.backslash = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  36735. var ampersand = 38; // `&`.charCodeAt(0);
  36736. tokenTypes.ampersand = ampersand;
  36737. var asterisk = 42; // `*`.charCodeAt(0);
  36738. tokenTypes.asterisk = asterisk;
  36739. var at = 64; // `@`.charCodeAt(0);
  36740. tokenTypes.at = at;
  36741. var comma$1 = 44; // `,`.charCodeAt(0);
  36742. tokenTypes.comma = comma$1;
  36743. var colon = 58; // `:`.charCodeAt(0);
  36744. tokenTypes.colon = colon;
  36745. var semicolon$1 = 59; // `;`.charCodeAt(0);
  36746. tokenTypes.semicolon = semicolon$1;
  36747. var openParenthesis = 40; // `(`.charCodeAt(0);
  36748. tokenTypes.openParenthesis = openParenthesis;
  36749. var closeParenthesis = 41; // `)`.charCodeAt(0);
  36750. tokenTypes.closeParenthesis = closeParenthesis;
  36751. var openSquare = 91; // `[`.charCodeAt(0);
  36752. tokenTypes.openSquare = openSquare;
  36753. var closeSquare = 93; // `]`.charCodeAt(0);
  36754. tokenTypes.closeSquare = closeSquare;
  36755. var dollar = 36; // `$`.charCodeAt(0);
  36756. tokenTypes.dollar = dollar;
  36757. var tilde = 126; // `~`.charCodeAt(0);
  36758. tokenTypes.tilde = tilde;
  36759. var caret = 94; // `^`.charCodeAt(0);
  36760. tokenTypes.caret = caret;
  36761. var plus = 43; // `+`.charCodeAt(0);
  36762. tokenTypes.plus = plus;
  36763. var equals = 61; // `=`.charCodeAt(0);
  36764. tokenTypes.equals = equals;
  36765. var pipe = 124; // `|`.charCodeAt(0);
  36766. tokenTypes.pipe = pipe;
  36767. var greaterThan = 62; // `>`.charCodeAt(0);
  36768. tokenTypes.greaterThan = greaterThan;
  36769. var space = 32; // ` `.charCodeAt(0);
  36770. tokenTypes.space = space;
  36771. var singleQuote = 39; // `'`.charCodeAt(0);
  36772. tokenTypes.singleQuote = singleQuote;
  36773. var doubleQuote = 34; // `"`.charCodeAt(0);
  36774. tokenTypes.doubleQuote = doubleQuote;
  36775. var slash = 47; // `/`.charCodeAt(0);
  36776. tokenTypes.slash = slash;
  36777. var bang = 33; // `!`.charCodeAt(0);
  36778. tokenTypes.bang = bang;
  36779. var backslash = 92; // '\\'.charCodeAt(0);
  36780. tokenTypes.backslash = backslash;
  36781. var cr = 13; // '\r'.charCodeAt(0);
  36782. tokenTypes.cr = cr;
  36783. var feed = 12; // '\f'.charCodeAt(0);
  36784. tokenTypes.feed = feed;
  36785. var newline = 10; // '\n'.charCodeAt(0);
  36786. tokenTypes.newline = newline;
  36787. var tab = 9; // '\t'.charCodeAt(0);
  36788. // Expose aliases primarily for readability.
  36789. tokenTypes.tab = tab;
  36790. var str = singleQuote;
  36791. // No good single character representation!
  36792. tokenTypes.str = str;
  36793. var comment$1 = -1;
  36794. tokenTypes.comment = comment$1;
  36795. var word = -2;
  36796. tokenTypes.word = word;
  36797. var combinator$1 = -3;
  36798. tokenTypes.combinator = combinator$1;
  36799. (function (exports) {
  36800. exports.__esModule = true;
  36801. exports.FIELDS = void 0;
  36802. exports["default"] = tokenize;
  36803. var t = _interopRequireWildcard(tokenTypes);
  36804. var _unescapable, _wordDelimiters;
  36805. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  36806. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
  36807. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  36808. 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);
  36809. var hex = {};
  36810. var hexChars = "0123456789abcdefABCDEF";
  36811. for (var i = 0; i < hexChars.length; i++) {
  36812. hex[hexChars.charCodeAt(i)] = true;
  36813. }
  36814. /**
  36815. * Returns the last index of the bar css word
  36816. * @param {string} css The string in which the word begins
  36817. * @param {number} start The index into the string where word's first letter occurs
  36818. */
  36819. function consumeWord(css, start) {
  36820. var next = start;
  36821. var code;
  36822. do {
  36823. code = css.charCodeAt(next);
  36824. if (wordDelimiters[code]) {
  36825. return next - 1;
  36826. } else if (code === t.backslash) {
  36827. next = consumeEscape(css, next) + 1;
  36828. } else {
  36829. // All other characters are part of the word
  36830. next++;
  36831. }
  36832. } while (next < css.length);
  36833. return next - 1;
  36834. }
  36835. /**
  36836. * Returns the last index of the escape sequence
  36837. * @param {string} css The string in which the sequence begins
  36838. * @param {number} start The index into the string where escape character (`\`) occurs.
  36839. */
  36840. function consumeEscape(css, start) {
  36841. var next = start;
  36842. var code = css.charCodeAt(next + 1);
  36843. if (unescapable[code]) ; else if (hex[code]) {
  36844. var hexDigits = 0;
  36845. // consume up to 6 hex chars
  36846. do {
  36847. next++;
  36848. hexDigits++;
  36849. code = css.charCodeAt(next + 1);
  36850. } while (hex[code] && hexDigits < 6);
  36851. // if fewer than 6 hex chars, a trailing space ends the escape
  36852. if (hexDigits < 6 && code === t.space) {
  36853. next++;
  36854. }
  36855. } else {
  36856. // the next char is part of the current word
  36857. next++;
  36858. }
  36859. return next;
  36860. }
  36861. var FIELDS = {
  36862. TYPE: 0,
  36863. START_LINE: 1,
  36864. START_COL: 2,
  36865. END_LINE: 3,
  36866. END_COL: 4,
  36867. START_POS: 5,
  36868. END_POS: 6
  36869. };
  36870. exports.FIELDS = FIELDS;
  36871. function tokenize(input) {
  36872. var tokens = [];
  36873. var css = input.css.valueOf();
  36874. var _css = css,
  36875. length = _css.length;
  36876. var offset = -1;
  36877. var line = 1;
  36878. var start = 0;
  36879. var end = 0;
  36880. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  36881. function unclosed(what, fix) {
  36882. if (input.safe) {
  36883. // fyi: this is never set to true.
  36884. css += fix;
  36885. next = css.length - 1;
  36886. } else {
  36887. throw input.error('Unclosed ' + what, line, start - offset, start);
  36888. }
  36889. }
  36890. while (start < length) {
  36891. code = css.charCodeAt(start);
  36892. if (code === t.newline) {
  36893. offset = start;
  36894. line += 1;
  36895. }
  36896. switch (code) {
  36897. case t.space:
  36898. case t.tab:
  36899. case t.newline:
  36900. case t.cr:
  36901. case t.feed:
  36902. next = start;
  36903. do {
  36904. next += 1;
  36905. code = css.charCodeAt(next);
  36906. if (code === t.newline) {
  36907. offset = next;
  36908. line += 1;
  36909. }
  36910. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  36911. tokenType = t.space;
  36912. endLine = line;
  36913. endColumn = next - offset - 1;
  36914. end = next;
  36915. break;
  36916. case t.plus:
  36917. case t.greaterThan:
  36918. case t.tilde:
  36919. case t.pipe:
  36920. next = start;
  36921. do {
  36922. next += 1;
  36923. code = css.charCodeAt(next);
  36924. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  36925. tokenType = t.combinator;
  36926. endLine = line;
  36927. endColumn = start - offset;
  36928. end = next;
  36929. break;
  36930. // Consume these characters as single tokens.
  36931. case t.asterisk:
  36932. case t.ampersand:
  36933. case t.bang:
  36934. case t.comma:
  36935. case t.equals:
  36936. case t.dollar:
  36937. case t.caret:
  36938. case t.openSquare:
  36939. case t.closeSquare:
  36940. case t.colon:
  36941. case t.semicolon:
  36942. case t.openParenthesis:
  36943. case t.closeParenthesis:
  36944. next = start;
  36945. tokenType = code;
  36946. endLine = line;
  36947. endColumn = start - offset;
  36948. end = next + 1;
  36949. break;
  36950. case t.singleQuote:
  36951. case t.doubleQuote:
  36952. quote = code === t.singleQuote ? "'" : '"';
  36953. next = start;
  36954. do {
  36955. escaped = false;
  36956. next = css.indexOf(quote, next + 1);
  36957. if (next === -1) {
  36958. unclosed('quote', quote);
  36959. }
  36960. escapePos = next;
  36961. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  36962. escapePos -= 1;
  36963. escaped = !escaped;
  36964. }
  36965. } while (escaped);
  36966. tokenType = t.str;
  36967. endLine = line;
  36968. endColumn = start - offset;
  36969. end = next + 1;
  36970. break;
  36971. default:
  36972. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  36973. next = css.indexOf('*/', start + 2) + 1;
  36974. if (next === 0) {
  36975. unclosed('comment', '*/');
  36976. }
  36977. content = css.slice(start, next + 1);
  36978. lines = content.split('\n');
  36979. last = lines.length - 1;
  36980. if (last > 0) {
  36981. nextLine = line + last;
  36982. nextOffset = next - lines[last].length;
  36983. } else {
  36984. nextLine = line;
  36985. nextOffset = offset;
  36986. }
  36987. tokenType = t.comment;
  36988. line = nextLine;
  36989. endLine = nextLine;
  36990. endColumn = next - nextOffset;
  36991. } else if (code === t.slash) {
  36992. next = start;
  36993. tokenType = code;
  36994. endLine = line;
  36995. endColumn = start - offset;
  36996. end = next + 1;
  36997. } else {
  36998. next = consumeWord(css, start);
  36999. tokenType = t.word;
  37000. endLine = line;
  37001. endColumn = next - offset;
  37002. }
  37003. end = next + 1;
  37004. break;
  37005. }
  37006. // Ensure that the token structure remains consistent
  37007. tokens.push([tokenType,
  37008. // [0] Token type
  37009. line,
  37010. // [1] Starting line
  37011. start - offset,
  37012. // [2] Starting column
  37013. endLine,
  37014. // [3] Ending line
  37015. endColumn,
  37016. // [4] Ending column
  37017. start,
  37018. // [5] Start position / Source index
  37019. end // [6] End position
  37020. ]);
  37021. // Reset offset for the next token
  37022. if (nextOffset) {
  37023. offset = nextOffset;
  37024. nextOffset = null;
  37025. }
  37026. start = end;
  37027. }
  37028. return tokens;
  37029. }
  37030. } (tokenize));
  37031. (function (module, exports) {
  37032. exports.__esModule = true;
  37033. exports["default"] = void 0;
  37034. var _root = _interopRequireDefault(rootExports);
  37035. var _selector = _interopRequireDefault(selectorExports);
  37036. var _className = _interopRequireDefault(classNameExports);
  37037. var _comment = _interopRequireDefault(commentExports);
  37038. var _id = _interopRequireDefault(idExports);
  37039. var _tag = _interopRequireDefault(tagExports);
  37040. var _string = _interopRequireDefault(stringExports);
  37041. var _pseudo = _interopRequireDefault(pseudoExports);
  37042. var _attribute = _interopRequireWildcard(attribute$1);
  37043. var _universal = _interopRequireDefault(universalExports);
  37044. var _combinator = _interopRequireDefault(combinatorExports);
  37045. var _nesting = _interopRequireDefault(nestingExports);
  37046. var _sortAscending = _interopRequireDefault(sortAscendingExports);
  37047. var _tokenize = _interopRequireWildcard(tokenize);
  37048. var tokens = _interopRequireWildcard(tokenTypes);
  37049. var types$1 = _interopRequireWildcard(types);
  37050. var _util = util$6;
  37051. var _WHITESPACE_TOKENS, _Object$assign;
  37052. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  37053. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
  37054. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37055. 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); } }
  37056. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37057. 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);
  37058. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  37059. function tokenStart(token) {
  37060. return {
  37061. line: token[_tokenize.FIELDS.START_LINE],
  37062. column: token[_tokenize.FIELDS.START_COL]
  37063. };
  37064. }
  37065. function tokenEnd(token) {
  37066. return {
  37067. line: token[_tokenize.FIELDS.END_LINE],
  37068. column: token[_tokenize.FIELDS.END_COL]
  37069. };
  37070. }
  37071. function getSource(startLine, startColumn, endLine, endColumn) {
  37072. return {
  37073. start: {
  37074. line: startLine,
  37075. column: startColumn
  37076. },
  37077. end: {
  37078. line: endLine,
  37079. column: endColumn
  37080. }
  37081. };
  37082. }
  37083. function getTokenSource(token) {
  37084. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  37085. }
  37086. function getTokenSourceSpan(startToken, endToken) {
  37087. if (!startToken) {
  37088. return undefined;
  37089. }
  37090. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  37091. }
  37092. function unescapeProp(node, prop) {
  37093. var value = node[prop];
  37094. if (typeof value !== "string") {
  37095. return;
  37096. }
  37097. if (value.indexOf("\\") !== -1) {
  37098. (0, _util.ensureObject)(node, 'raws');
  37099. node[prop] = (0, _util.unesc)(value);
  37100. if (node.raws[prop] === undefined) {
  37101. node.raws[prop] = value;
  37102. }
  37103. }
  37104. return node;
  37105. }
  37106. function indexesOf(array, item) {
  37107. var i = -1;
  37108. var indexes = [];
  37109. while ((i = array.indexOf(item, i + 1)) !== -1) {
  37110. indexes.push(i);
  37111. }
  37112. return indexes;
  37113. }
  37114. function uniqs() {
  37115. var list = Array.prototype.concat.apply([], arguments);
  37116. return list.filter(function (item, i) {
  37117. return i === list.indexOf(item);
  37118. });
  37119. }
  37120. var Parser = /*#__PURE__*/function () {
  37121. function Parser(rule, options) {
  37122. if (options === void 0) {
  37123. options = {};
  37124. }
  37125. this.rule = rule;
  37126. this.options = Object.assign({
  37127. lossy: false,
  37128. safe: false
  37129. }, options);
  37130. this.position = 0;
  37131. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  37132. this.tokens = (0, _tokenize["default"])({
  37133. css: this.css,
  37134. error: this._errorGenerator(),
  37135. safe: this.options.safe
  37136. });
  37137. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  37138. this.root = new _root["default"]({
  37139. source: rootSource
  37140. });
  37141. this.root.errorGenerator = this._errorGenerator();
  37142. var selector = new _selector["default"]({
  37143. source: {
  37144. start: {
  37145. line: 1,
  37146. column: 1
  37147. }
  37148. }
  37149. });
  37150. this.root.append(selector);
  37151. this.current = selector;
  37152. this.loop();
  37153. }
  37154. var _proto = Parser.prototype;
  37155. _proto._errorGenerator = function _errorGenerator() {
  37156. var _this = this;
  37157. return function (message, errorOptions) {
  37158. if (typeof _this.rule === 'string') {
  37159. return new Error(message);
  37160. }
  37161. return _this.rule.error(message, errorOptions);
  37162. };
  37163. };
  37164. _proto.attribute = function attribute() {
  37165. var attr = [];
  37166. var startingToken = this.currToken;
  37167. this.position++;
  37168. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37169. attr.push(this.currToken);
  37170. this.position++;
  37171. }
  37172. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37173. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37174. }
  37175. var len = attr.length;
  37176. var node = {
  37177. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  37178. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37179. };
  37180. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  37181. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  37182. }
  37183. var pos = 0;
  37184. var spaceBefore = '';
  37185. var commentBefore = '';
  37186. var lastAdded = null;
  37187. var spaceAfterMeaningfulToken = false;
  37188. while (pos < len) {
  37189. var token = attr[pos];
  37190. var content = this.content(token);
  37191. var next = attr[pos + 1];
  37192. switch (token[_tokenize.FIELDS.TYPE]) {
  37193. case tokens.space:
  37194. // if (
  37195. // len === 1 ||
  37196. // pos === 0 && this.content(next) === '|'
  37197. // ) {
  37198. // return this.expected('attribute', token[TOKEN.START_POS], content);
  37199. // }
  37200. spaceAfterMeaningfulToken = true;
  37201. if (this.options.lossy) {
  37202. break;
  37203. }
  37204. if (lastAdded) {
  37205. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  37206. var prevContent = node.spaces[lastAdded].after || '';
  37207. node.spaces[lastAdded].after = prevContent + content;
  37208. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  37209. if (existingComment) {
  37210. node.raws.spaces[lastAdded].after = existingComment + content;
  37211. }
  37212. } else {
  37213. spaceBefore = spaceBefore + content;
  37214. commentBefore = commentBefore + content;
  37215. }
  37216. break;
  37217. case tokens.asterisk:
  37218. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37219. node.operator = content;
  37220. lastAdded = 'operator';
  37221. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  37222. if (spaceBefore) {
  37223. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37224. node.spaces.attribute.before = spaceBefore;
  37225. spaceBefore = '';
  37226. }
  37227. if (commentBefore) {
  37228. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37229. node.raws.spaces.attribute.before = spaceBefore;
  37230. commentBefore = '';
  37231. }
  37232. node.namespace = (node.namespace || "") + content;
  37233. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  37234. if (rawValue) {
  37235. node.raws.namespace += content;
  37236. }
  37237. lastAdded = 'namespace';
  37238. }
  37239. spaceAfterMeaningfulToken = false;
  37240. break;
  37241. case tokens.dollar:
  37242. if (lastAdded === "value") {
  37243. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  37244. node.value += "$";
  37245. if (oldRawValue) {
  37246. node.raws.value = oldRawValue + "$";
  37247. }
  37248. break;
  37249. }
  37250. // Falls through
  37251. case tokens.caret:
  37252. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37253. node.operator = content;
  37254. lastAdded = 'operator';
  37255. }
  37256. spaceAfterMeaningfulToken = false;
  37257. break;
  37258. case tokens.combinator:
  37259. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37260. node.operator = content;
  37261. lastAdded = 'operator';
  37262. }
  37263. if (content !== '|') {
  37264. spaceAfterMeaningfulToken = false;
  37265. break;
  37266. }
  37267. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37268. node.operator = content;
  37269. lastAdded = 'operator';
  37270. } else if (!node.namespace && !node.attribute) {
  37271. node.namespace = true;
  37272. }
  37273. spaceAfterMeaningfulToken = false;
  37274. break;
  37275. case tokens.word:
  37276. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  37277. // this look-ahead probably fails with comment nodes involved.
  37278. !node.operator && !node.namespace) {
  37279. node.namespace = content;
  37280. lastAdded = 'namespace';
  37281. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  37282. if (spaceBefore) {
  37283. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37284. node.spaces.attribute.before = spaceBefore;
  37285. spaceBefore = '';
  37286. }
  37287. if (commentBefore) {
  37288. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37289. node.raws.spaces.attribute.before = commentBefore;
  37290. commentBefore = '';
  37291. }
  37292. node.attribute = (node.attribute || "") + content;
  37293. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  37294. if (_rawValue) {
  37295. node.raws.attribute += content;
  37296. }
  37297. lastAdded = 'attribute';
  37298. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  37299. var _unescaped = (0, _util.unesc)(content);
  37300. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  37301. var oldValue = node.value || '';
  37302. node.value = oldValue + _unescaped;
  37303. node.quoteMark = null;
  37304. if (_unescaped !== content || _oldRawValue) {
  37305. (0, _util.ensureObject)(node, 'raws');
  37306. node.raws.value = (_oldRawValue || oldValue) + content;
  37307. }
  37308. lastAdded = 'value';
  37309. } else {
  37310. var insensitive = content === 'i' || content === "I";
  37311. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  37312. node.insensitive = insensitive;
  37313. if (!insensitive || content === "I") {
  37314. (0, _util.ensureObject)(node, 'raws');
  37315. node.raws.insensitiveFlag = content;
  37316. }
  37317. lastAdded = 'insensitive';
  37318. if (spaceBefore) {
  37319. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  37320. node.spaces.insensitive.before = spaceBefore;
  37321. spaceBefore = '';
  37322. }
  37323. if (commentBefore) {
  37324. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  37325. node.raws.spaces.insensitive.before = commentBefore;
  37326. commentBefore = '';
  37327. }
  37328. } else if (node.value || node.value === '') {
  37329. lastAdded = 'value';
  37330. node.value += content;
  37331. if (node.raws.value) {
  37332. node.raws.value += content;
  37333. }
  37334. }
  37335. }
  37336. spaceAfterMeaningfulToken = false;
  37337. break;
  37338. case tokens.str:
  37339. if (!node.attribute || !node.operator) {
  37340. return this.error("Expected an attribute followed by an operator preceding the string.", {
  37341. index: token[_tokenize.FIELDS.START_POS]
  37342. });
  37343. }
  37344. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  37345. unescaped = _unescapeValue.unescaped,
  37346. quoteMark = _unescapeValue.quoteMark;
  37347. node.value = unescaped;
  37348. node.quoteMark = quoteMark;
  37349. lastAdded = 'value';
  37350. (0, _util.ensureObject)(node, 'raws');
  37351. node.raws.value = content;
  37352. spaceAfterMeaningfulToken = false;
  37353. break;
  37354. case tokens.equals:
  37355. if (!node.attribute) {
  37356. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  37357. }
  37358. if (node.value) {
  37359. return this.error('Unexpected "=" found; an operator was already defined.', {
  37360. index: token[_tokenize.FIELDS.START_POS]
  37361. });
  37362. }
  37363. node.operator = node.operator ? node.operator + content : content;
  37364. lastAdded = 'operator';
  37365. spaceAfterMeaningfulToken = false;
  37366. break;
  37367. case tokens.comment:
  37368. if (lastAdded) {
  37369. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  37370. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  37371. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  37372. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  37373. node.raws.spaces[lastAdded].after = rawLastComment + content;
  37374. } else {
  37375. var lastValue = node[lastAdded] || '';
  37376. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  37377. (0, _util.ensureObject)(node, 'raws');
  37378. node.raws[lastAdded] = rawLastValue + content;
  37379. }
  37380. } else {
  37381. commentBefore = commentBefore + content;
  37382. }
  37383. break;
  37384. default:
  37385. return this.error("Unexpected \"" + content + "\" found.", {
  37386. index: token[_tokenize.FIELDS.START_POS]
  37387. });
  37388. }
  37389. pos++;
  37390. }
  37391. unescapeProp(node, "attribute");
  37392. unescapeProp(node, "namespace");
  37393. this.newNode(new _attribute["default"](node));
  37394. this.position++;
  37395. }
  37396. /**
  37397. * return a node containing meaningless garbage up to (but not including) the specified token position.
  37398. * if the token position is negative, all remaining tokens are consumed.
  37399. *
  37400. * This returns an array containing a single string node if all whitespace,
  37401. * otherwise an array of comment nodes with space before and after.
  37402. *
  37403. * These tokens are not added to the current selector, the caller can add them or use them to amend
  37404. * a previous node's space metadata.
  37405. *
  37406. * In lossy mode, this returns only comments.
  37407. */;
  37408. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  37409. if (stopPosition < 0) {
  37410. stopPosition = this.tokens.length;
  37411. }
  37412. var startPosition = this.position;
  37413. var nodes = [];
  37414. var space = "";
  37415. var lastComment = undefined;
  37416. do {
  37417. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  37418. if (!this.options.lossy) {
  37419. space += this.content();
  37420. }
  37421. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  37422. var spaces = {};
  37423. if (space) {
  37424. spaces.before = space;
  37425. space = "";
  37426. }
  37427. lastComment = new _comment["default"]({
  37428. value: this.content(),
  37429. source: getTokenSource(this.currToken),
  37430. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37431. spaces: spaces
  37432. });
  37433. nodes.push(lastComment);
  37434. }
  37435. } while (++this.position < stopPosition);
  37436. if (space) {
  37437. if (lastComment) {
  37438. lastComment.spaces.after = space;
  37439. } else if (!this.options.lossy) {
  37440. var firstToken = this.tokens[startPosition];
  37441. var lastToken = this.tokens[this.position - 1];
  37442. nodes.push(new _string["default"]({
  37443. value: '',
  37444. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  37445. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37446. spaces: {
  37447. before: space,
  37448. after: ''
  37449. }
  37450. }));
  37451. }
  37452. }
  37453. return nodes;
  37454. }
  37455. /**
  37456. *
  37457. * @param {*} nodes
  37458. */;
  37459. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  37460. var _this2 = this;
  37461. if (requiredSpace === void 0) {
  37462. requiredSpace = false;
  37463. }
  37464. var space = "";
  37465. var rawSpace = "";
  37466. nodes.forEach(function (n) {
  37467. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  37468. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  37469. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  37470. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  37471. });
  37472. if (rawSpace === space) {
  37473. rawSpace = undefined;
  37474. }
  37475. var result = {
  37476. space: space,
  37477. rawSpace: rawSpace
  37478. };
  37479. return result;
  37480. };
  37481. _proto.isNamedCombinator = function isNamedCombinator(position) {
  37482. if (position === void 0) {
  37483. position = this.position;
  37484. }
  37485. 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;
  37486. };
  37487. _proto.namedCombinator = function namedCombinator() {
  37488. if (this.isNamedCombinator()) {
  37489. var nameRaw = this.content(this.tokens[this.position + 1]);
  37490. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  37491. var raws = {};
  37492. if (name !== nameRaw) {
  37493. raws.value = "/" + nameRaw + "/";
  37494. }
  37495. var node = new _combinator["default"]({
  37496. value: "/" + name + "/",
  37497. 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]),
  37498. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37499. raws: raws
  37500. });
  37501. this.position = this.position + 3;
  37502. return node;
  37503. } else {
  37504. this.unexpected();
  37505. }
  37506. };
  37507. _proto.combinator = function combinator() {
  37508. var _this3 = this;
  37509. if (this.content() === '|') {
  37510. return this.namespace();
  37511. }
  37512. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  37513. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  37514. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  37515. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37516. if (nodes.length > 0) {
  37517. var last = this.current.last;
  37518. if (last) {
  37519. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  37520. space = _this$convertWhitespa.space,
  37521. rawSpace = _this$convertWhitespa.rawSpace;
  37522. if (rawSpace !== undefined) {
  37523. last.rawSpaceAfter += rawSpace;
  37524. }
  37525. last.spaces.after += space;
  37526. } else {
  37527. nodes.forEach(function (n) {
  37528. return _this3.newNode(n);
  37529. });
  37530. }
  37531. }
  37532. return;
  37533. }
  37534. var firstToken = this.currToken;
  37535. var spaceOrDescendantSelectorNodes = undefined;
  37536. if (nextSigTokenPos > this.position) {
  37537. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37538. }
  37539. var node;
  37540. if (this.isNamedCombinator()) {
  37541. node = this.namedCombinator();
  37542. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  37543. node = new _combinator["default"]({
  37544. value: this.content(),
  37545. source: getTokenSource(this.currToken),
  37546. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  37547. });
  37548. this.position++;
  37549. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  37550. this.unexpected();
  37551. }
  37552. if (node) {
  37553. if (spaceOrDescendantSelectorNodes) {
  37554. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  37555. _space = _this$convertWhitespa2.space,
  37556. _rawSpace = _this$convertWhitespa2.rawSpace;
  37557. node.spaces.before = _space;
  37558. node.rawSpaceBefore = _rawSpace;
  37559. }
  37560. } else {
  37561. // descendant combinator
  37562. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  37563. _space2 = _this$convertWhitespa3.space,
  37564. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  37565. if (!_rawSpace2) {
  37566. _rawSpace2 = _space2;
  37567. }
  37568. var spaces = {};
  37569. var raws = {
  37570. spaces: {}
  37571. };
  37572. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  37573. spaces.before = _space2.slice(0, _space2.length - 1);
  37574. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  37575. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  37576. spaces.after = _space2.slice(1);
  37577. raws.spaces.after = _rawSpace2.slice(1);
  37578. } else {
  37579. raws.value = _rawSpace2;
  37580. }
  37581. node = new _combinator["default"]({
  37582. value: ' ',
  37583. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  37584. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37585. spaces: spaces,
  37586. raws: raws
  37587. });
  37588. }
  37589. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  37590. node.spaces.after = this.optionalSpace(this.content());
  37591. this.position++;
  37592. }
  37593. return this.newNode(node);
  37594. };
  37595. _proto.comma = function comma() {
  37596. if (this.position === this.tokens.length - 1) {
  37597. this.root.trailingComma = true;
  37598. this.position++;
  37599. return;
  37600. }
  37601. this.current._inferEndPosition();
  37602. var selector = new _selector["default"]({
  37603. source: {
  37604. start: tokenStart(this.tokens[this.position + 1])
  37605. }
  37606. });
  37607. this.current.parent.append(selector);
  37608. this.current = selector;
  37609. this.position++;
  37610. };
  37611. _proto.comment = function comment() {
  37612. var current = this.currToken;
  37613. this.newNode(new _comment["default"]({
  37614. value: this.content(),
  37615. source: getTokenSource(current),
  37616. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37617. }));
  37618. this.position++;
  37619. };
  37620. _proto.error = function error(message, opts) {
  37621. throw this.root.error(message, opts);
  37622. };
  37623. _proto.missingBackslash = function missingBackslash() {
  37624. return this.error('Expected a backslash preceding the semicolon.', {
  37625. index: this.currToken[_tokenize.FIELDS.START_POS]
  37626. });
  37627. };
  37628. _proto.missingParenthesis = function missingParenthesis() {
  37629. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37630. };
  37631. _proto.missingSquareBracket = function missingSquareBracket() {
  37632. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37633. };
  37634. _proto.unexpected = function unexpected() {
  37635. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  37636. };
  37637. _proto.unexpectedPipe = function unexpectedPipe() {
  37638. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  37639. };
  37640. _proto.namespace = function namespace() {
  37641. var before = this.prevToken && this.content(this.prevToken) || true;
  37642. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37643. this.position++;
  37644. return this.word(before);
  37645. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  37646. this.position++;
  37647. return this.universal(before);
  37648. }
  37649. this.unexpectedPipe();
  37650. };
  37651. _proto.nesting = function nesting() {
  37652. if (this.nextToken) {
  37653. var nextContent = this.content(this.nextToken);
  37654. if (nextContent === "|") {
  37655. this.position++;
  37656. return;
  37657. }
  37658. }
  37659. var current = this.currToken;
  37660. this.newNode(new _nesting["default"]({
  37661. value: this.content(),
  37662. source: getTokenSource(current),
  37663. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37664. }));
  37665. this.position++;
  37666. };
  37667. _proto.parentheses = function parentheses() {
  37668. var last = this.current.last;
  37669. var unbalanced = 1;
  37670. this.position++;
  37671. if (last && last.type === types$1.PSEUDO) {
  37672. var selector = new _selector["default"]({
  37673. source: {
  37674. start: tokenStart(this.tokens[this.position - 1])
  37675. }
  37676. });
  37677. var cache = this.current;
  37678. last.append(selector);
  37679. this.current = selector;
  37680. while (this.position < this.tokens.length && unbalanced) {
  37681. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37682. unbalanced++;
  37683. }
  37684. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37685. unbalanced--;
  37686. }
  37687. if (unbalanced) {
  37688. this.parse();
  37689. } else {
  37690. this.current.source.end = tokenEnd(this.currToken);
  37691. this.current.parent.source.end = tokenEnd(this.currToken);
  37692. this.position++;
  37693. }
  37694. }
  37695. this.current = cache;
  37696. } else {
  37697. // I think this case should be an error. It's used to implement a basic parse of media queries
  37698. // but I don't think it's a good idea.
  37699. var parenStart = this.currToken;
  37700. var parenValue = "(";
  37701. var parenEnd;
  37702. while (this.position < this.tokens.length && unbalanced) {
  37703. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37704. unbalanced++;
  37705. }
  37706. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37707. unbalanced--;
  37708. }
  37709. parenEnd = this.currToken;
  37710. parenValue += this.parseParenthesisToken(this.currToken);
  37711. this.position++;
  37712. }
  37713. if (last) {
  37714. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  37715. } else {
  37716. this.newNode(new _string["default"]({
  37717. value: parenValue,
  37718. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  37719. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  37720. }));
  37721. }
  37722. }
  37723. if (unbalanced) {
  37724. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37725. }
  37726. };
  37727. _proto.pseudo = function pseudo() {
  37728. var _this4 = this;
  37729. var pseudoStr = '';
  37730. var startingToken = this.currToken;
  37731. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  37732. pseudoStr += this.content();
  37733. this.position++;
  37734. }
  37735. if (!this.currToken) {
  37736. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  37737. }
  37738. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37739. this.splitWord(false, function (first, length) {
  37740. pseudoStr += first;
  37741. _this4.newNode(new _pseudo["default"]({
  37742. value: pseudoStr,
  37743. source: getTokenSourceSpan(startingToken, _this4.currToken),
  37744. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37745. }));
  37746. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37747. _this4.error('Misplaced parenthesis.', {
  37748. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  37749. });
  37750. }
  37751. });
  37752. } else {
  37753. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  37754. }
  37755. };
  37756. _proto.space = function space() {
  37757. var content = this.content();
  37758. // Handle space before and after the selector
  37759. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  37760. return node.type === 'comment';
  37761. })) {
  37762. this.spaces = this.optionalSpace(content);
  37763. this.position++;
  37764. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37765. this.current.last.spaces.after = this.optionalSpace(content);
  37766. this.position++;
  37767. } else {
  37768. this.combinator();
  37769. }
  37770. };
  37771. _proto.string = function string() {
  37772. var current = this.currToken;
  37773. this.newNode(new _string["default"]({
  37774. value: this.content(),
  37775. source: getTokenSource(current),
  37776. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37777. }));
  37778. this.position++;
  37779. };
  37780. _proto.universal = function universal(namespace) {
  37781. var nextToken = this.nextToken;
  37782. if (nextToken && this.content(nextToken) === '|') {
  37783. this.position++;
  37784. return this.namespace();
  37785. }
  37786. var current = this.currToken;
  37787. this.newNode(new _universal["default"]({
  37788. value: this.content(),
  37789. source: getTokenSource(current),
  37790. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37791. }), namespace);
  37792. this.position++;
  37793. };
  37794. _proto.splitWord = function splitWord(namespace, firstCallback) {
  37795. var _this5 = this;
  37796. var nextToken = this.nextToken;
  37797. var word = this.content();
  37798. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  37799. this.position++;
  37800. var current = this.content();
  37801. word += current;
  37802. if (current.lastIndexOf('\\') === current.length - 1) {
  37803. var next = this.nextToken;
  37804. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  37805. word += this.requiredSpace(this.content(next));
  37806. this.position++;
  37807. }
  37808. }
  37809. nextToken = this.nextToken;
  37810. }
  37811. var hasClass = indexesOf(word, '.').filter(function (i) {
  37812. // Allow escaped dot within class name
  37813. var escapedDot = word[i - 1] === '\\';
  37814. // Allow decimal numbers percent in @keyframes
  37815. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  37816. return !escapedDot && !isKeyframesPercent;
  37817. });
  37818. var hasId = indexesOf(word, '#').filter(function (i) {
  37819. return word[i - 1] !== '\\';
  37820. });
  37821. // Eliminate Sass interpolations from the list of id indexes
  37822. var interpolations = indexesOf(word, '#{');
  37823. if (interpolations.length) {
  37824. hasId = hasId.filter(function (hashIndex) {
  37825. return !~interpolations.indexOf(hashIndex);
  37826. });
  37827. }
  37828. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  37829. indices.forEach(function (ind, i) {
  37830. var index = indices[i + 1] || word.length;
  37831. var value = word.slice(ind, index);
  37832. if (i === 0 && firstCallback) {
  37833. return firstCallback.call(_this5, value, indices.length);
  37834. }
  37835. var node;
  37836. var current = _this5.currToken;
  37837. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  37838. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  37839. if (~hasClass.indexOf(ind)) {
  37840. var classNameOpts = {
  37841. value: value.slice(1),
  37842. source: source,
  37843. sourceIndex: sourceIndex
  37844. };
  37845. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  37846. } else if (~hasId.indexOf(ind)) {
  37847. var idOpts = {
  37848. value: value.slice(1),
  37849. source: source,
  37850. sourceIndex: sourceIndex
  37851. };
  37852. node = new _id["default"](unescapeProp(idOpts, "value"));
  37853. } else {
  37854. var tagOpts = {
  37855. value: value,
  37856. source: source,
  37857. sourceIndex: sourceIndex
  37858. };
  37859. unescapeProp(tagOpts, "value");
  37860. node = new _tag["default"](tagOpts);
  37861. }
  37862. _this5.newNode(node, namespace);
  37863. // Ensure that the namespace is used only once
  37864. namespace = null;
  37865. });
  37866. this.position++;
  37867. };
  37868. _proto.word = function word(namespace) {
  37869. var nextToken = this.nextToken;
  37870. if (nextToken && this.content(nextToken) === '|') {
  37871. this.position++;
  37872. return this.namespace();
  37873. }
  37874. return this.splitWord(namespace);
  37875. };
  37876. _proto.loop = function loop() {
  37877. while (this.position < this.tokens.length) {
  37878. this.parse(true);
  37879. }
  37880. this.current._inferEndPosition();
  37881. return this.root;
  37882. };
  37883. _proto.parse = function parse(throwOnParenthesis) {
  37884. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  37885. case tokens.space:
  37886. this.space();
  37887. break;
  37888. case tokens.comment:
  37889. this.comment();
  37890. break;
  37891. case tokens.openParenthesis:
  37892. this.parentheses();
  37893. break;
  37894. case tokens.closeParenthesis:
  37895. if (throwOnParenthesis) {
  37896. this.missingParenthesis();
  37897. }
  37898. break;
  37899. case tokens.openSquare:
  37900. this.attribute();
  37901. break;
  37902. case tokens.dollar:
  37903. case tokens.caret:
  37904. case tokens.equals:
  37905. case tokens.word:
  37906. this.word();
  37907. break;
  37908. case tokens.colon:
  37909. this.pseudo();
  37910. break;
  37911. case tokens.comma:
  37912. this.comma();
  37913. break;
  37914. case tokens.asterisk:
  37915. this.universal();
  37916. break;
  37917. case tokens.ampersand:
  37918. this.nesting();
  37919. break;
  37920. case tokens.slash:
  37921. case tokens.combinator:
  37922. this.combinator();
  37923. break;
  37924. case tokens.str:
  37925. this.string();
  37926. break;
  37927. // These cases throw; no break needed.
  37928. case tokens.closeSquare:
  37929. this.missingSquareBracket();
  37930. case tokens.semicolon:
  37931. this.missingBackslash();
  37932. default:
  37933. this.unexpected();
  37934. }
  37935. }
  37936. /**
  37937. * Helpers
  37938. */;
  37939. _proto.expected = function expected(description, index, found) {
  37940. if (Array.isArray(description)) {
  37941. var last = description.pop();
  37942. description = description.join(', ') + " or " + last;
  37943. }
  37944. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  37945. if (!found) {
  37946. return this.error("Expected " + an + " " + description + ".", {
  37947. index: index
  37948. });
  37949. }
  37950. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  37951. index: index
  37952. });
  37953. };
  37954. _proto.requiredSpace = function requiredSpace(space) {
  37955. return this.options.lossy ? ' ' : space;
  37956. };
  37957. _proto.optionalSpace = function optionalSpace(space) {
  37958. return this.options.lossy ? '' : space;
  37959. };
  37960. _proto.lossySpace = function lossySpace(space, required) {
  37961. if (this.options.lossy) {
  37962. return required ? ' ' : '';
  37963. } else {
  37964. return space;
  37965. }
  37966. };
  37967. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  37968. var content = this.content(token);
  37969. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  37970. return this.requiredSpace(content);
  37971. } else {
  37972. return content;
  37973. }
  37974. };
  37975. _proto.newNode = function newNode(node, namespace) {
  37976. if (namespace) {
  37977. if (/^ +$/.test(namespace)) {
  37978. if (!this.options.lossy) {
  37979. this.spaces = (this.spaces || '') + namespace;
  37980. }
  37981. namespace = true;
  37982. }
  37983. node.namespace = namespace;
  37984. unescapeProp(node, "namespace");
  37985. }
  37986. if (this.spaces) {
  37987. node.spaces.before = this.spaces;
  37988. this.spaces = '';
  37989. }
  37990. return this.current.append(node);
  37991. };
  37992. _proto.content = function content(token) {
  37993. if (token === void 0) {
  37994. token = this.currToken;
  37995. }
  37996. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  37997. };
  37998. /**
  37999. * returns the index of the next non-whitespace, non-comment token.
  38000. * returns -1 if no meaningful token is found.
  38001. */
  38002. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  38003. if (startPosition === void 0) {
  38004. startPosition = this.position + 1;
  38005. }
  38006. var searchPosition = startPosition;
  38007. while (searchPosition < this.tokens.length) {
  38008. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  38009. searchPosition++;
  38010. continue;
  38011. } else {
  38012. return searchPosition;
  38013. }
  38014. }
  38015. return -1;
  38016. };
  38017. _createClass(Parser, [{
  38018. key: "currToken",
  38019. get: function get() {
  38020. return this.tokens[this.position];
  38021. }
  38022. }, {
  38023. key: "nextToken",
  38024. get: function get() {
  38025. return this.tokens[this.position + 1];
  38026. }
  38027. }, {
  38028. key: "prevToken",
  38029. get: function get() {
  38030. return this.tokens[this.position - 1];
  38031. }
  38032. }]);
  38033. return Parser;
  38034. }();
  38035. exports["default"] = Parser;
  38036. module.exports = exports.default;
  38037. } (parser, parser.exports));
  38038. var parserExports = parser.exports;
  38039. (function (module, exports) {
  38040. exports.__esModule = true;
  38041. exports["default"] = void 0;
  38042. var _parser = _interopRequireDefault(parserExports);
  38043. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38044. var Processor = /*#__PURE__*/function () {
  38045. function Processor(func, options) {
  38046. this.func = func || function noop() {};
  38047. this.funcRes = null;
  38048. this.options = options;
  38049. }
  38050. var _proto = Processor.prototype;
  38051. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  38052. if (options === void 0) {
  38053. options = {};
  38054. }
  38055. var merged = Object.assign({}, this.options, options);
  38056. if (merged.updateSelector === false) {
  38057. return false;
  38058. } else {
  38059. return typeof rule !== "string";
  38060. }
  38061. };
  38062. _proto._isLossy = function _isLossy(options) {
  38063. if (options === void 0) {
  38064. options = {};
  38065. }
  38066. var merged = Object.assign({}, this.options, options);
  38067. if (merged.lossless === false) {
  38068. return true;
  38069. } else {
  38070. return false;
  38071. }
  38072. };
  38073. _proto._root = function _root(rule, options) {
  38074. if (options === void 0) {
  38075. options = {};
  38076. }
  38077. var parser = new _parser["default"](rule, this._parseOptions(options));
  38078. return parser.root;
  38079. };
  38080. _proto._parseOptions = function _parseOptions(options) {
  38081. return {
  38082. lossy: this._isLossy(options)
  38083. };
  38084. };
  38085. _proto._run = function _run(rule, options) {
  38086. var _this = this;
  38087. if (options === void 0) {
  38088. options = {};
  38089. }
  38090. return new Promise(function (resolve, reject) {
  38091. try {
  38092. var root = _this._root(rule, options);
  38093. Promise.resolve(_this.func(root)).then(function (transform) {
  38094. var string = undefined;
  38095. if (_this._shouldUpdateSelector(rule, options)) {
  38096. string = root.toString();
  38097. rule.selector = string;
  38098. }
  38099. return {
  38100. transform: transform,
  38101. root: root,
  38102. string: string
  38103. };
  38104. }).then(resolve, reject);
  38105. } catch (e) {
  38106. reject(e);
  38107. return;
  38108. }
  38109. });
  38110. };
  38111. _proto._runSync = function _runSync(rule, options) {
  38112. if (options === void 0) {
  38113. options = {};
  38114. }
  38115. var root = this._root(rule, options);
  38116. var transform = this.func(root);
  38117. if (transform && typeof transform.then === "function") {
  38118. throw new Error("Selector processor returned a promise to a synchronous call.");
  38119. }
  38120. var string = undefined;
  38121. if (options.updateSelector && typeof rule !== "string") {
  38122. string = root.toString();
  38123. rule.selector = string;
  38124. }
  38125. return {
  38126. transform: transform,
  38127. root: root,
  38128. string: string
  38129. };
  38130. }
  38131. /**
  38132. * Process rule into a selector AST.
  38133. *
  38134. * @param rule {postcss.Rule | string} The css selector to be processed
  38135. * @param options The options for processing
  38136. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  38137. */;
  38138. _proto.ast = function ast(rule, options) {
  38139. return this._run(rule, options).then(function (result) {
  38140. return result.root;
  38141. });
  38142. }
  38143. /**
  38144. * Process rule into a selector AST synchronously.
  38145. *
  38146. * @param rule {postcss.Rule | string} The css selector to be processed
  38147. * @param options The options for processing
  38148. * @returns {parser.Root} The AST of the selector after processing it.
  38149. */;
  38150. _proto.astSync = function astSync(rule, options) {
  38151. return this._runSync(rule, options).root;
  38152. }
  38153. /**
  38154. * Process a selector into a transformed value asynchronously
  38155. *
  38156. * @param rule {postcss.Rule | string} The css selector to be processed
  38157. * @param options The options for processing
  38158. * @returns {Promise<any>} The value returned by the processor.
  38159. */;
  38160. _proto.transform = function transform(rule, options) {
  38161. return this._run(rule, options).then(function (result) {
  38162. return result.transform;
  38163. });
  38164. }
  38165. /**
  38166. * Process a selector into a transformed value synchronously.
  38167. *
  38168. * @param rule {postcss.Rule | string} The css selector to be processed
  38169. * @param options The options for processing
  38170. * @returns {any} The value returned by the processor.
  38171. */;
  38172. _proto.transformSync = function transformSync(rule, options) {
  38173. return this._runSync(rule, options).transform;
  38174. }
  38175. /**
  38176. * Process a selector into a new selector string asynchronously.
  38177. *
  38178. * @param rule {postcss.Rule | string} The css selector to be processed
  38179. * @param options The options for processing
  38180. * @returns {string} the selector after processing.
  38181. */;
  38182. _proto.process = function process(rule, options) {
  38183. return this._run(rule, options).then(function (result) {
  38184. return result.string || result.root.toString();
  38185. });
  38186. }
  38187. /**
  38188. * Process a selector into a new selector string synchronously.
  38189. *
  38190. * @param rule {postcss.Rule | string} The css selector to be processed
  38191. * @param options The options for processing
  38192. * @returns {string} the selector after processing.
  38193. */;
  38194. _proto.processSync = function processSync(rule, options) {
  38195. var result = this._runSync(rule, options);
  38196. return result.string || result.root.toString();
  38197. };
  38198. return Processor;
  38199. }();
  38200. exports["default"] = Processor;
  38201. module.exports = exports.default;
  38202. } (processor, processor.exports));
  38203. var processorExports = processor.exports;
  38204. var selectors = {};
  38205. var constructors = {};
  38206. constructors.__esModule = true;
  38207. 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;
  38208. var _attribute = _interopRequireDefault(attribute$1);
  38209. var _className = _interopRequireDefault(classNameExports);
  38210. var _combinator = _interopRequireDefault(combinatorExports);
  38211. var _comment = _interopRequireDefault(commentExports);
  38212. var _id = _interopRequireDefault(idExports);
  38213. var _nesting = _interopRequireDefault(nestingExports);
  38214. var _pseudo = _interopRequireDefault(pseudoExports);
  38215. var _root = _interopRequireDefault(rootExports);
  38216. var _selector = _interopRequireDefault(selectorExports);
  38217. var _string = _interopRequireDefault(stringExports);
  38218. var _tag = _interopRequireDefault(tagExports);
  38219. var _universal = _interopRequireDefault(universalExports);
  38220. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38221. var attribute = function attribute(opts) {
  38222. return new _attribute["default"](opts);
  38223. };
  38224. constructors.attribute = attribute;
  38225. var className = function className(opts) {
  38226. return new _className["default"](opts);
  38227. };
  38228. constructors.className = className;
  38229. var combinator = function combinator(opts) {
  38230. return new _combinator["default"](opts);
  38231. };
  38232. constructors.combinator = combinator;
  38233. var comment = function comment(opts) {
  38234. return new _comment["default"](opts);
  38235. };
  38236. constructors.comment = comment;
  38237. var id = function id(opts) {
  38238. return new _id["default"](opts);
  38239. };
  38240. constructors.id = id;
  38241. var nesting = function nesting(opts) {
  38242. return new _nesting["default"](opts);
  38243. };
  38244. constructors.nesting = nesting;
  38245. var pseudo = function pseudo(opts) {
  38246. return new _pseudo["default"](opts);
  38247. };
  38248. constructors.pseudo = pseudo;
  38249. var root = function root(opts) {
  38250. return new _root["default"](opts);
  38251. };
  38252. constructors.root = root;
  38253. var selector = function selector(opts) {
  38254. return new _selector["default"](opts);
  38255. };
  38256. constructors.selector = selector;
  38257. var string = function string(opts) {
  38258. return new _string["default"](opts);
  38259. };
  38260. constructors.string = string;
  38261. var tag = function tag(opts) {
  38262. return new _tag["default"](opts);
  38263. };
  38264. constructors.tag = tag;
  38265. var universal = function universal(opts) {
  38266. return new _universal["default"](opts);
  38267. };
  38268. constructors.universal = universal;
  38269. var guards = {};
  38270. guards.__esModule = true;
  38271. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  38272. guards.isContainer = isContainer;
  38273. guards.isIdentifier = void 0;
  38274. guards.isNamespace = isNamespace;
  38275. guards.isNesting = void 0;
  38276. guards.isNode = isNode;
  38277. guards.isPseudo = void 0;
  38278. guards.isPseudoClass = isPseudoClass;
  38279. guards.isPseudoElement = isPseudoElement;
  38280. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  38281. var _types = types;
  38282. var _IS_TYPE;
  38283. 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);
  38284. function isNode(node) {
  38285. return typeof node === "object" && IS_TYPE[node.type];
  38286. }
  38287. function isNodeType(type, node) {
  38288. return isNode(node) && node.type === type;
  38289. }
  38290. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  38291. guards.isAttribute = isAttribute;
  38292. var isClassName = isNodeType.bind(null, _types.CLASS);
  38293. guards.isClassName = isClassName;
  38294. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  38295. guards.isCombinator = isCombinator;
  38296. var isComment = isNodeType.bind(null, _types.COMMENT);
  38297. guards.isComment = isComment;
  38298. var isIdentifier = isNodeType.bind(null, _types.ID);
  38299. guards.isIdentifier = isIdentifier;
  38300. var isNesting = isNodeType.bind(null, _types.NESTING);
  38301. guards.isNesting = isNesting;
  38302. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  38303. guards.isPseudo = isPseudo;
  38304. var isRoot = isNodeType.bind(null, _types.ROOT);
  38305. guards.isRoot = isRoot;
  38306. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  38307. guards.isSelector = isSelector;
  38308. var isString = isNodeType.bind(null, _types.STRING);
  38309. guards.isString = isString;
  38310. var isTag = isNodeType.bind(null, _types.TAG);
  38311. guards.isTag = isTag;
  38312. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  38313. guards.isUniversal = isUniversal;
  38314. function isPseudoElement(node) {
  38315. 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");
  38316. }
  38317. function isPseudoClass(node) {
  38318. return isPseudo(node) && !isPseudoElement(node);
  38319. }
  38320. function isContainer(node) {
  38321. return !!(isNode(node) && node.walk);
  38322. }
  38323. function isNamespace(node) {
  38324. return isAttribute(node) || isTag(node);
  38325. }
  38326. (function (exports) {
  38327. exports.__esModule = true;
  38328. var _types = types;
  38329. Object.keys(_types).forEach(function (key) {
  38330. if (key === "default" || key === "__esModule") return;
  38331. if (key in exports && exports[key] === _types[key]) return;
  38332. exports[key] = _types[key];
  38333. });
  38334. var _constructors = constructors;
  38335. Object.keys(_constructors).forEach(function (key) {
  38336. if (key === "default" || key === "__esModule") return;
  38337. if (key in exports && exports[key] === _constructors[key]) return;
  38338. exports[key] = _constructors[key];
  38339. });
  38340. var _guards = guards;
  38341. Object.keys(_guards).forEach(function (key) {
  38342. if (key === "default" || key === "__esModule") return;
  38343. if (key in exports && exports[key] === _guards[key]) return;
  38344. exports[key] = _guards[key];
  38345. });
  38346. } (selectors));
  38347. (function (module, exports) {
  38348. exports.__esModule = true;
  38349. exports["default"] = void 0;
  38350. var _processor = _interopRequireDefault(processorExports);
  38351. var selectors$1 = _interopRequireWildcard(selectors);
  38352. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  38353. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
  38354. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38355. var parser = function parser(processor) {
  38356. return new _processor["default"](processor);
  38357. };
  38358. Object.assign(parser, selectors$1);
  38359. delete parser.__esModule;
  38360. var _default = parser;
  38361. exports["default"] = _default;
  38362. module.exports = exports.default;
  38363. } (dist, dist.exports));
  38364. var distExports = dist.exports;
  38365. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  38366. const animationNameRE = /^(-\w+-)?animation-name$/;
  38367. const animationRE = /^(-\w+-)?animation$/;
  38368. const scopedPlugin = (id = "") => {
  38369. const keyframes = /* @__PURE__ */ Object.create(null);
  38370. const shortId = id.replace(/^data-v-/, "");
  38371. return {
  38372. postcssPlugin: "vue-sfc-scoped",
  38373. Rule(rule) {
  38374. processRule(id, rule);
  38375. },
  38376. AtRule(node) {
  38377. if (/-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  38378. keyframes[node.params] = node.params = node.params + "-" + shortId;
  38379. }
  38380. },
  38381. OnceExit(root) {
  38382. if (Object.keys(keyframes).length) {
  38383. root.walkDecls((decl) => {
  38384. if (animationNameRE.test(decl.prop)) {
  38385. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  38386. }
  38387. if (animationRE.test(decl.prop)) {
  38388. decl.value = decl.value.split(",").map((v) => {
  38389. const vals = v.trim().split(/\s+/);
  38390. const i = vals.findIndex((val) => keyframes[val]);
  38391. if (i !== -1) {
  38392. vals.splice(i, 1, keyframes[vals[i]]);
  38393. return vals.join(" ");
  38394. } else {
  38395. return v;
  38396. }
  38397. }).join(",");
  38398. }
  38399. });
  38400. }
  38401. }
  38402. };
  38403. };
  38404. const processedRules = /* @__PURE__ */ new WeakSet();
  38405. function processRule(id, rule) {
  38406. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && /-?keyframes$/.test(rule.parent.name)) {
  38407. return;
  38408. }
  38409. processedRules.add(rule);
  38410. rule.selector = selectorParser((selectorRoot) => {
  38411. selectorRoot.each((selector) => {
  38412. rewriteSelector(id, selector, selectorRoot);
  38413. });
  38414. }).processSync(rule.selector);
  38415. }
  38416. function rewriteSelector(id, selector, selectorRoot, slotted = false) {
  38417. let node = null;
  38418. let shouldInject = true;
  38419. selector.each((n) => {
  38420. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  38421. n.value = " ";
  38422. n.spaces.before = n.spaces.after = "";
  38423. warn(
  38424. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  38425. );
  38426. return false;
  38427. }
  38428. if (n.type === "pseudo") {
  38429. const { value } = n;
  38430. if (value === ":deep" || value === "::v-deep") {
  38431. if (n.nodes.length) {
  38432. let last = n;
  38433. n.nodes[0].each((ss) => {
  38434. selector.insertAfter(last, ss);
  38435. last = ss;
  38436. });
  38437. const prev = selector.at(selector.index(n) - 1);
  38438. if (!prev || !isSpaceCombinator(prev)) {
  38439. selector.insertAfter(
  38440. n,
  38441. selectorParser.combinator({
  38442. value: " "
  38443. })
  38444. );
  38445. }
  38446. selector.removeChild(n);
  38447. } else {
  38448. warn(
  38449. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  38450. );
  38451. const prev = selector.at(selector.index(n) - 1);
  38452. if (prev && isSpaceCombinator(prev)) {
  38453. selector.removeChild(prev);
  38454. }
  38455. selector.removeChild(n);
  38456. }
  38457. return false;
  38458. }
  38459. if (value === ":slotted" || value === "::v-slotted") {
  38460. rewriteSelector(
  38461. id,
  38462. n.nodes[0],
  38463. selectorRoot,
  38464. true
  38465. /* slotted */
  38466. );
  38467. let last = n;
  38468. n.nodes[0].each((ss) => {
  38469. selector.insertAfter(last, ss);
  38470. last = ss;
  38471. });
  38472. selector.removeChild(n);
  38473. shouldInject = false;
  38474. return false;
  38475. }
  38476. if (value === ":global" || value === "::v-global") {
  38477. selectorRoot.insertAfter(selector, n.nodes[0]);
  38478. selectorRoot.removeChild(selector);
  38479. return false;
  38480. }
  38481. }
  38482. if (n.type === "universal") {
  38483. const prev = selector.at(selector.index(n) - 1);
  38484. const next = selector.at(selector.index(n) + 1);
  38485. if (!prev) {
  38486. if (next) {
  38487. if (next.type === "combinator" && next.value === " ") {
  38488. selector.removeChild(next);
  38489. }
  38490. selector.removeChild(n);
  38491. return;
  38492. } else {
  38493. node = selectorParser.combinator({
  38494. value: ""
  38495. });
  38496. selector.insertBefore(n, node);
  38497. selector.removeChild(n);
  38498. return false;
  38499. }
  38500. }
  38501. if (node)
  38502. return;
  38503. }
  38504. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
  38505. node = n;
  38506. }
  38507. });
  38508. if (node) {
  38509. const { type, value } = node;
  38510. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  38511. node.nodes.forEach(
  38512. (value2) => rewriteSelector(id, value2, selectorRoot, slotted)
  38513. );
  38514. shouldInject = false;
  38515. }
  38516. }
  38517. if (node) {
  38518. node.spaces.after = "";
  38519. } else {
  38520. selector.first.spaces.before = "";
  38521. }
  38522. if (shouldInject) {
  38523. const idToAdd = slotted ? id + "-s" : id;
  38524. selector.insertAfter(
  38525. // If node is null it means we need to inject [id] at the start
  38526. // insertAfter can handle `null` here
  38527. node,
  38528. selectorParser.attribute({
  38529. attribute: idToAdd,
  38530. value: idToAdd,
  38531. raws: {},
  38532. quoteMark: `"`
  38533. })
  38534. );
  38535. }
  38536. }
  38537. function isSpaceCombinator(node) {
  38538. return node.type === "combinator" && /^\s+$/.test(node.value);
  38539. }
  38540. scopedPlugin.postcss = true;
  38541. var sourceMap$1 = {};
  38542. var sourceMapGenerator = {};
  38543. var base64Vlq = {};
  38544. var base64$1 = {};
  38545. /* -*- Mode: js; js-indent-level: 2; -*- */
  38546. /*
  38547. * Copyright 2011 Mozilla Foundation and contributors
  38548. * Licensed under the New BSD license. See LICENSE or:
  38549. * http://opensource.org/licenses/BSD-3-Clause
  38550. */
  38551. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  38552. /**
  38553. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  38554. */
  38555. base64$1.encode = function (number) {
  38556. if (0 <= number && number < intToCharMap.length) {
  38557. return intToCharMap[number];
  38558. }
  38559. throw new TypeError("Must be between 0 and 63: " + number);
  38560. };
  38561. /**
  38562. * Decode a single base 64 character code digit to an integer. Returns -1 on
  38563. * failure.
  38564. */
  38565. base64$1.decode = function (charCode) {
  38566. var bigA = 65; // 'A'
  38567. var bigZ = 90; // 'Z'
  38568. var littleA = 97; // 'a'
  38569. var littleZ = 122; // 'z'
  38570. var zero = 48; // '0'
  38571. var nine = 57; // '9'
  38572. var plus = 43; // '+'
  38573. var slash = 47; // '/'
  38574. var littleOffset = 26;
  38575. var numberOffset = 52;
  38576. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  38577. if (bigA <= charCode && charCode <= bigZ) {
  38578. return (charCode - bigA);
  38579. }
  38580. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  38581. if (littleA <= charCode && charCode <= littleZ) {
  38582. return (charCode - littleA + littleOffset);
  38583. }
  38584. // 52 - 61: 0123456789
  38585. if (zero <= charCode && charCode <= nine) {
  38586. return (charCode - zero + numberOffset);
  38587. }
  38588. // 62: +
  38589. if (charCode == plus) {
  38590. return 62;
  38591. }
  38592. // 63: /
  38593. if (charCode == slash) {
  38594. return 63;
  38595. }
  38596. // Invalid base64 digit.
  38597. return -1;
  38598. };
  38599. /* -*- Mode: js; js-indent-level: 2; -*- */
  38600. /*
  38601. * Copyright 2011 Mozilla Foundation and contributors
  38602. * Licensed under the New BSD license. See LICENSE or:
  38603. * http://opensource.org/licenses/BSD-3-Clause
  38604. *
  38605. * Based on the Base 64 VLQ implementation in Closure Compiler:
  38606. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  38607. *
  38608. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  38609. * Redistribution and use in source and binary forms, with or without
  38610. * modification, are permitted provided that the following conditions are
  38611. * met:
  38612. *
  38613. * * Redistributions of source code must retain the above copyright
  38614. * notice, this list of conditions and the following disclaimer.
  38615. * * Redistributions in binary form must reproduce the above
  38616. * copyright notice, this list of conditions and the following
  38617. * disclaimer in the documentation and/or other materials provided
  38618. * with the distribution.
  38619. * * Neither the name of Google Inc. nor the names of its
  38620. * contributors may be used to endorse or promote products derived
  38621. * from this software without specific prior written permission.
  38622. *
  38623. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  38624. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38625. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  38626. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38627. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  38628. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  38629. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  38630. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  38631. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38632. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38633. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38634. */
  38635. var base64 = base64$1;
  38636. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  38637. // length quantities we use in the source map spec, the first bit is the sign,
  38638. // the next four bits are the actual value, and the 6th bit is the
  38639. // continuation bit. The continuation bit tells us whether there are more
  38640. // digits in this value following this digit.
  38641. //
  38642. // Continuation
  38643. // | Sign
  38644. // | |
  38645. // V V
  38646. // 101011
  38647. var VLQ_BASE_SHIFT = 5;
  38648. // binary: 100000
  38649. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  38650. // binary: 011111
  38651. var VLQ_BASE_MASK = VLQ_BASE - 1;
  38652. // binary: 100000
  38653. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  38654. /**
  38655. * Converts from a two-complement value to a value where the sign bit is
  38656. * placed in the least significant bit. For example, as decimals:
  38657. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  38658. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  38659. */
  38660. function toVLQSigned(aValue) {
  38661. return aValue < 0
  38662. ? ((-aValue) << 1) + 1
  38663. : (aValue << 1) + 0;
  38664. }
  38665. /**
  38666. * Converts to a two-complement value from a value where the sign bit is
  38667. * placed in the least significant bit. For example, as decimals:
  38668. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  38669. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  38670. */
  38671. function fromVLQSigned(aValue) {
  38672. var isNegative = (aValue & 1) === 1;
  38673. var shifted = aValue >> 1;
  38674. return isNegative
  38675. ? -shifted
  38676. : shifted;
  38677. }
  38678. /**
  38679. * Returns the base 64 VLQ encoded value.
  38680. */
  38681. base64Vlq.encode = function base64VLQ_encode(aValue) {
  38682. var encoded = "";
  38683. var digit;
  38684. var vlq = toVLQSigned(aValue);
  38685. do {
  38686. digit = vlq & VLQ_BASE_MASK;
  38687. vlq >>>= VLQ_BASE_SHIFT;
  38688. if (vlq > 0) {
  38689. // There are still more digits in this value, so we must make sure the
  38690. // continuation bit is marked.
  38691. digit |= VLQ_CONTINUATION_BIT;
  38692. }
  38693. encoded += base64.encode(digit);
  38694. } while (vlq > 0);
  38695. return encoded;
  38696. };
  38697. /**
  38698. * Decodes the next base 64 VLQ value from the given string and returns the
  38699. * value and the rest of the string via the out parameter.
  38700. */
  38701. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  38702. var strLen = aStr.length;
  38703. var result = 0;
  38704. var shift = 0;
  38705. var continuation, digit;
  38706. do {
  38707. if (aIndex >= strLen) {
  38708. throw new Error("Expected more digits in base 64 VLQ value.");
  38709. }
  38710. digit = base64.decode(aStr.charCodeAt(aIndex++));
  38711. if (digit === -1) {
  38712. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  38713. }
  38714. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  38715. digit &= VLQ_BASE_MASK;
  38716. result = result + (digit << shift);
  38717. shift += VLQ_BASE_SHIFT;
  38718. } while (continuation);
  38719. aOutParam.value = fromVLQSigned(result);
  38720. aOutParam.rest = aIndex;
  38721. };
  38722. var util$5 = {};
  38723. /* -*- Mode: js; js-indent-level: 2; -*- */
  38724. (function (exports) {
  38725. /*
  38726. * Copyright 2011 Mozilla Foundation and contributors
  38727. * Licensed under the New BSD license. See LICENSE or:
  38728. * http://opensource.org/licenses/BSD-3-Clause
  38729. */
  38730. /**
  38731. * This is a helper function for getting values from parameter/options
  38732. * objects.
  38733. *
  38734. * @param args The object we are extracting values from
  38735. * @param name The name of the property we are getting.
  38736. * @param defaultValue An optional value to return if the property is missing
  38737. * from the object. If this is not specified and the property is missing, an
  38738. * error will be thrown.
  38739. */
  38740. function getArg(aArgs, aName, aDefaultValue) {
  38741. if (aName in aArgs) {
  38742. return aArgs[aName];
  38743. } else if (arguments.length === 3) {
  38744. return aDefaultValue;
  38745. } else {
  38746. throw new Error('"' + aName + '" is a required argument.');
  38747. }
  38748. }
  38749. exports.getArg = getArg;
  38750. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  38751. var dataUrlRegexp = /^data:.+\,.+$/;
  38752. function urlParse(aUrl) {
  38753. var match = aUrl.match(urlRegexp);
  38754. if (!match) {
  38755. return null;
  38756. }
  38757. return {
  38758. scheme: match[1],
  38759. auth: match[2],
  38760. host: match[3],
  38761. port: match[4],
  38762. path: match[5]
  38763. };
  38764. }
  38765. exports.urlParse = urlParse;
  38766. function urlGenerate(aParsedUrl) {
  38767. var url = '';
  38768. if (aParsedUrl.scheme) {
  38769. url += aParsedUrl.scheme + ':';
  38770. }
  38771. url += '//';
  38772. if (aParsedUrl.auth) {
  38773. url += aParsedUrl.auth + '@';
  38774. }
  38775. if (aParsedUrl.host) {
  38776. url += aParsedUrl.host;
  38777. }
  38778. if (aParsedUrl.port) {
  38779. url += ":" + aParsedUrl.port;
  38780. }
  38781. if (aParsedUrl.path) {
  38782. url += aParsedUrl.path;
  38783. }
  38784. return url;
  38785. }
  38786. exports.urlGenerate = urlGenerate;
  38787. /**
  38788. * Normalizes a path, or the path portion of a URL:
  38789. *
  38790. * - Replaces consecutive slashes with one slash.
  38791. * - Removes unnecessary '.' parts.
  38792. * - Removes unnecessary '<dir>/..' parts.
  38793. *
  38794. * Based on code in the Node.js 'path' core module.
  38795. *
  38796. * @param aPath The path or url to normalize.
  38797. */
  38798. function normalize(aPath) {
  38799. var path = aPath;
  38800. var url = urlParse(aPath);
  38801. if (url) {
  38802. if (!url.path) {
  38803. return aPath;
  38804. }
  38805. path = url.path;
  38806. }
  38807. var isAbsolute = exports.isAbsolute(path);
  38808. var parts = path.split(/\/+/);
  38809. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  38810. part = parts[i];
  38811. if (part === '.') {
  38812. parts.splice(i, 1);
  38813. } else if (part === '..') {
  38814. up++;
  38815. } else if (up > 0) {
  38816. if (part === '') {
  38817. // The first part is blank if the path is absolute. Trying to go
  38818. // above the root is a no-op. Therefore we can remove all '..' parts
  38819. // directly after the root.
  38820. parts.splice(i + 1, up);
  38821. up = 0;
  38822. } else {
  38823. parts.splice(i, 2);
  38824. up--;
  38825. }
  38826. }
  38827. }
  38828. path = parts.join('/');
  38829. if (path === '') {
  38830. path = isAbsolute ? '/' : '.';
  38831. }
  38832. if (url) {
  38833. url.path = path;
  38834. return urlGenerate(url);
  38835. }
  38836. return path;
  38837. }
  38838. exports.normalize = normalize;
  38839. /**
  38840. * Joins two paths/URLs.
  38841. *
  38842. * @param aRoot The root path or URL.
  38843. * @param aPath The path or URL to be joined with the root.
  38844. *
  38845. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  38846. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  38847. * first.
  38848. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  38849. * is updated with the result and aRoot is returned. Otherwise the result
  38850. * is returned.
  38851. * - If aPath is absolute, the result is aPath.
  38852. * - Otherwise the two paths are joined with a slash.
  38853. * - Joining for example 'http://' and 'www.example.com' is also supported.
  38854. */
  38855. function join(aRoot, aPath) {
  38856. if (aRoot === "") {
  38857. aRoot = ".";
  38858. }
  38859. if (aPath === "") {
  38860. aPath = ".";
  38861. }
  38862. var aPathUrl = urlParse(aPath);
  38863. var aRootUrl = urlParse(aRoot);
  38864. if (aRootUrl) {
  38865. aRoot = aRootUrl.path || '/';
  38866. }
  38867. // `join(foo, '//www.example.org')`
  38868. if (aPathUrl && !aPathUrl.scheme) {
  38869. if (aRootUrl) {
  38870. aPathUrl.scheme = aRootUrl.scheme;
  38871. }
  38872. return urlGenerate(aPathUrl);
  38873. }
  38874. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  38875. return aPath;
  38876. }
  38877. // `join('http://', 'www.example.com')`
  38878. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  38879. aRootUrl.host = aPath;
  38880. return urlGenerate(aRootUrl);
  38881. }
  38882. var joined = aPath.charAt(0) === '/'
  38883. ? aPath
  38884. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  38885. if (aRootUrl) {
  38886. aRootUrl.path = joined;
  38887. return urlGenerate(aRootUrl);
  38888. }
  38889. return joined;
  38890. }
  38891. exports.join = join;
  38892. exports.isAbsolute = function (aPath) {
  38893. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  38894. };
  38895. /**
  38896. * Make a path relative to a URL or another path.
  38897. *
  38898. * @param aRoot The root path or URL.
  38899. * @param aPath The path or URL to be made relative to aRoot.
  38900. */
  38901. function relative(aRoot, aPath) {
  38902. if (aRoot === "") {
  38903. aRoot = ".";
  38904. }
  38905. aRoot = aRoot.replace(/\/$/, '');
  38906. // It is possible for the path to be above the root. In this case, simply
  38907. // checking whether the root is a prefix of the path won't work. Instead, we
  38908. // need to remove components from the root one by one, until either we find
  38909. // a prefix that fits, or we run out of components to remove.
  38910. var level = 0;
  38911. while (aPath.indexOf(aRoot + '/') !== 0) {
  38912. var index = aRoot.lastIndexOf("/");
  38913. if (index < 0) {
  38914. return aPath;
  38915. }
  38916. // If the only part of the root that is left is the scheme (i.e. http://,
  38917. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  38918. // have exhausted all components, so the path is not relative to the root.
  38919. aRoot = aRoot.slice(0, index);
  38920. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  38921. return aPath;
  38922. }
  38923. ++level;
  38924. }
  38925. // Make sure we add a "../" for each component we removed from the root.
  38926. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  38927. }
  38928. exports.relative = relative;
  38929. var supportsNullProto = (function () {
  38930. var obj = Object.create(null);
  38931. return !('__proto__' in obj);
  38932. }());
  38933. function identity (s) {
  38934. return s;
  38935. }
  38936. /**
  38937. * Because behavior goes wacky when you set `__proto__` on objects, we
  38938. * have to prefix all the strings in our set with an arbitrary character.
  38939. *
  38940. * See https://github.com/mozilla/source-map/pull/31 and
  38941. * https://github.com/mozilla/source-map/issues/30
  38942. *
  38943. * @param String aStr
  38944. */
  38945. function toSetString(aStr) {
  38946. if (isProtoString(aStr)) {
  38947. return '$' + aStr;
  38948. }
  38949. return aStr;
  38950. }
  38951. exports.toSetString = supportsNullProto ? identity : toSetString;
  38952. function fromSetString(aStr) {
  38953. if (isProtoString(aStr)) {
  38954. return aStr.slice(1);
  38955. }
  38956. return aStr;
  38957. }
  38958. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  38959. function isProtoString(s) {
  38960. if (!s) {
  38961. return false;
  38962. }
  38963. var length = s.length;
  38964. if (length < 9 /* "__proto__".length */) {
  38965. return false;
  38966. }
  38967. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  38968. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  38969. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  38970. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  38971. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  38972. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  38973. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  38974. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  38975. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  38976. return false;
  38977. }
  38978. for (var i = length - 10; i >= 0; i--) {
  38979. if (s.charCodeAt(i) !== 36 /* '$' */) {
  38980. return false;
  38981. }
  38982. }
  38983. return true;
  38984. }
  38985. /**
  38986. * Comparator between two mappings where the original positions are compared.
  38987. *
  38988. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  38989. * mappings with the same original source/line/column, but different generated
  38990. * line and column the same. Useful when searching for a mapping with a
  38991. * stubbed out mapping.
  38992. */
  38993. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  38994. var cmp = strcmp(mappingA.source, mappingB.source);
  38995. if (cmp !== 0) {
  38996. return cmp;
  38997. }
  38998. cmp = mappingA.originalLine - mappingB.originalLine;
  38999. if (cmp !== 0) {
  39000. return cmp;
  39001. }
  39002. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39003. if (cmp !== 0 || onlyCompareOriginal) {
  39004. return cmp;
  39005. }
  39006. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39007. if (cmp !== 0) {
  39008. return cmp;
  39009. }
  39010. cmp = mappingA.generatedLine - mappingB.generatedLine;
  39011. if (cmp !== 0) {
  39012. return cmp;
  39013. }
  39014. return strcmp(mappingA.name, mappingB.name);
  39015. }
  39016. exports.compareByOriginalPositions = compareByOriginalPositions;
  39017. /**
  39018. * Comparator between two mappings with deflated source and name indices where
  39019. * the generated positions are compared.
  39020. *
  39021. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  39022. * mappings with the same generated line and column, but different
  39023. * source/name/original line and column the same. Useful when searching for a
  39024. * mapping with a stubbed out mapping.
  39025. */
  39026. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  39027. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  39028. if (cmp !== 0) {
  39029. return cmp;
  39030. }
  39031. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39032. if (cmp !== 0 || onlyCompareGenerated) {
  39033. return cmp;
  39034. }
  39035. cmp = strcmp(mappingA.source, mappingB.source);
  39036. if (cmp !== 0) {
  39037. return cmp;
  39038. }
  39039. cmp = mappingA.originalLine - mappingB.originalLine;
  39040. if (cmp !== 0) {
  39041. return cmp;
  39042. }
  39043. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39044. if (cmp !== 0) {
  39045. return cmp;
  39046. }
  39047. return strcmp(mappingA.name, mappingB.name);
  39048. }
  39049. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  39050. function strcmp(aStr1, aStr2) {
  39051. if (aStr1 === aStr2) {
  39052. return 0;
  39053. }
  39054. if (aStr1 === null) {
  39055. return 1; // aStr2 !== null
  39056. }
  39057. if (aStr2 === null) {
  39058. return -1; // aStr1 !== null
  39059. }
  39060. if (aStr1 > aStr2) {
  39061. return 1;
  39062. }
  39063. return -1;
  39064. }
  39065. /**
  39066. * Comparator between two mappings with inflated source and name strings where
  39067. * the generated positions are compared.
  39068. */
  39069. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  39070. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  39071. if (cmp !== 0) {
  39072. return cmp;
  39073. }
  39074. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39075. if (cmp !== 0) {
  39076. return cmp;
  39077. }
  39078. cmp = strcmp(mappingA.source, mappingB.source);
  39079. if (cmp !== 0) {
  39080. return cmp;
  39081. }
  39082. cmp = mappingA.originalLine - mappingB.originalLine;
  39083. if (cmp !== 0) {
  39084. return cmp;
  39085. }
  39086. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39087. if (cmp !== 0) {
  39088. return cmp;
  39089. }
  39090. return strcmp(mappingA.name, mappingB.name);
  39091. }
  39092. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  39093. /**
  39094. * Strip any JSON XSSI avoidance prefix from the string (as documented
  39095. * in the source maps specification), and then parse the string as
  39096. * JSON.
  39097. */
  39098. function parseSourceMapInput(str) {
  39099. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  39100. }
  39101. exports.parseSourceMapInput = parseSourceMapInput;
  39102. /**
  39103. * Compute the URL of a source given the the source root, the source's
  39104. * URL, and the source map's URL.
  39105. */
  39106. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  39107. sourceURL = sourceURL || '';
  39108. if (sourceRoot) {
  39109. // This follows what Chrome does.
  39110. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  39111. sourceRoot += '/';
  39112. }
  39113. // The spec says:
  39114. // Line 4: An optional source root, useful for relocating source
  39115. // files on a server or removing repeated values in the
  39116. // “sources” entry. This value is prepended to the individual
  39117. // entries in the “source” field.
  39118. sourceURL = sourceRoot + sourceURL;
  39119. }
  39120. // Historically, SourceMapConsumer did not take the sourceMapURL as
  39121. // a parameter. This mode is still somewhat supported, which is why
  39122. // this code block is conditional. However, it's preferable to pass
  39123. // the source map URL to SourceMapConsumer, so that this function
  39124. // can implement the source URL resolution algorithm as outlined in
  39125. // the spec. This block is basically the equivalent of:
  39126. // new URL(sourceURL, sourceMapURL).toString()
  39127. // ... except it avoids using URL, which wasn't available in the
  39128. // older releases of node still supported by this library.
  39129. //
  39130. // The spec says:
  39131. // If the sources are not absolute URLs after prepending of the
  39132. // “sourceRoot”, the sources are resolved relative to the
  39133. // SourceMap (like resolving script src in a html document).
  39134. if (sourceMapURL) {
  39135. var parsed = urlParse(sourceMapURL);
  39136. if (!parsed) {
  39137. throw new Error("sourceMapURL could not be parsed");
  39138. }
  39139. if (parsed.path) {
  39140. // Strip the last path component, but keep the "/".
  39141. var index = parsed.path.lastIndexOf('/');
  39142. if (index >= 0) {
  39143. parsed.path = parsed.path.substring(0, index + 1);
  39144. }
  39145. }
  39146. sourceURL = join(urlGenerate(parsed), sourceURL);
  39147. }
  39148. return normalize(sourceURL);
  39149. }
  39150. exports.computeSourceURL = computeSourceURL;
  39151. } (util$5));
  39152. var arraySet = {};
  39153. /* -*- Mode: js; js-indent-level: 2; -*- */
  39154. /*
  39155. * Copyright 2011 Mozilla Foundation and contributors
  39156. * Licensed under the New BSD license. See LICENSE or:
  39157. * http://opensource.org/licenses/BSD-3-Clause
  39158. */
  39159. var util$4 = util$5;
  39160. var has = Object.prototype.hasOwnProperty;
  39161. var hasNativeMap = typeof Map !== "undefined";
  39162. /**
  39163. * A data structure which is a combination of an array and a set. Adding a new
  39164. * member is O(1), testing for membership is O(1), and finding the index of an
  39165. * element is O(1). Removing elements from the set is not supported. Only
  39166. * strings are supported for membership.
  39167. */
  39168. function ArraySet$2() {
  39169. this._array = [];
  39170. this._set = hasNativeMap ? new Map() : Object.create(null);
  39171. }
  39172. /**
  39173. * Static method for creating ArraySet instances from an existing array.
  39174. */
  39175. ArraySet$2.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  39176. var set = new ArraySet$2();
  39177. for (var i = 0, len = aArray.length; i < len; i++) {
  39178. set.add(aArray[i], aAllowDuplicates);
  39179. }
  39180. return set;
  39181. };
  39182. /**
  39183. * Return how many unique items are in this ArraySet. If duplicates have been
  39184. * added, than those do not count towards the size.
  39185. *
  39186. * @returns Number
  39187. */
  39188. ArraySet$2.prototype.size = function ArraySet_size() {
  39189. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  39190. };
  39191. /**
  39192. * Add the given string to this set.
  39193. *
  39194. * @param String aStr
  39195. */
  39196. ArraySet$2.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  39197. var sStr = hasNativeMap ? aStr : util$4.toSetString(aStr);
  39198. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  39199. var idx = this._array.length;
  39200. if (!isDuplicate || aAllowDuplicates) {
  39201. this._array.push(aStr);
  39202. }
  39203. if (!isDuplicate) {
  39204. if (hasNativeMap) {
  39205. this._set.set(aStr, idx);
  39206. } else {
  39207. this._set[sStr] = idx;
  39208. }
  39209. }
  39210. };
  39211. /**
  39212. * Is the given string a member of this set?
  39213. *
  39214. * @param String aStr
  39215. */
  39216. ArraySet$2.prototype.has = function ArraySet_has(aStr) {
  39217. if (hasNativeMap) {
  39218. return this._set.has(aStr);
  39219. } else {
  39220. var sStr = util$4.toSetString(aStr);
  39221. return has.call(this._set, sStr);
  39222. }
  39223. };
  39224. /**
  39225. * What is the index of the given string in the array?
  39226. *
  39227. * @param String aStr
  39228. */
  39229. ArraySet$2.prototype.indexOf = function ArraySet_indexOf(aStr) {
  39230. if (hasNativeMap) {
  39231. var idx = this._set.get(aStr);
  39232. if (idx >= 0) {
  39233. return idx;
  39234. }
  39235. } else {
  39236. var sStr = util$4.toSetString(aStr);
  39237. if (has.call(this._set, sStr)) {
  39238. return this._set[sStr];
  39239. }
  39240. }
  39241. throw new Error('"' + aStr + '" is not in the set.');
  39242. };
  39243. /**
  39244. * What is the element at the given index?
  39245. *
  39246. * @param Number aIdx
  39247. */
  39248. ArraySet$2.prototype.at = function ArraySet_at(aIdx) {
  39249. if (aIdx >= 0 && aIdx < this._array.length) {
  39250. return this._array[aIdx];
  39251. }
  39252. throw new Error('No element indexed by ' + aIdx);
  39253. };
  39254. /**
  39255. * Returns the array representation of this set (which has the proper indices
  39256. * indicated by indexOf). Note that this is a copy of the internal array used
  39257. * for storing the members so that no one can mess with internal state.
  39258. */
  39259. ArraySet$2.prototype.toArray = function ArraySet_toArray() {
  39260. return this._array.slice();
  39261. };
  39262. arraySet.ArraySet = ArraySet$2;
  39263. var mappingList = {};
  39264. /* -*- Mode: js; js-indent-level: 2; -*- */
  39265. /*
  39266. * Copyright 2014 Mozilla Foundation and contributors
  39267. * Licensed under the New BSD license. See LICENSE or:
  39268. * http://opensource.org/licenses/BSD-3-Clause
  39269. */
  39270. var util$3 = util$5;
  39271. /**
  39272. * Determine whether mappingB is after mappingA with respect to generated
  39273. * position.
  39274. */
  39275. function generatedPositionAfter(mappingA, mappingB) {
  39276. // Optimized for most common case
  39277. var lineA = mappingA.generatedLine;
  39278. var lineB = mappingB.generatedLine;
  39279. var columnA = mappingA.generatedColumn;
  39280. var columnB = mappingB.generatedColumn;
  39281. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  39282. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  39283. }
  39284. /**
  39285. * A data structure to provide a sorted view of accumulated mappings in a
  39286. * performance conscious manner. It trades a neglibable overhead in general
  39287. * case for a large speedup in case of mappings being added in order.
  39288. */
  39289. function MappingList$1() {
  39290. this._array = [];
  39291. this._sorted = true;
  39292. // Serves as infimum
  39293. this._last = {generatedLine: -1, generatedColumn: 0};
  39294. }
  39295. /**
  39296. * Iterate through internal items. This method takes the same arguments that
  39297. * `Array.prototype.forEach` takes.
  39298. *
  39299. * NOTE: The order of the mappings is NOT guaranteed.
  39300. */
  39301. MappingList$1.prototype.unsortedForEach =
  39302. function MappingList_forEach(aCallback, aThisArg) {
  39303. this._array.forEach(aCallback, aThisArg);
  39304. };
  39305. /**
  39306. * Add the given source mapping.
  39307. *
  39308. * @param Object aMapping
  39309. */
  39310. MappingList$1.prototype.add = function MappingList_add(aMapping) {
  39311. if (generatedPositionAfter(this._last, aMapping)) {
  39312. this._last = aMapping;
  39313. this._array.push(aMapping);
  39314. } else {
  39315. this._sorted = false;
  39316. this._array.push(aMapping);
  39317. }
  39318. };
  39319. /**
  39320. * Returns the flat, sorted array of mappings. The mappings are sorted by
  39321. * generated position.
  39322. *
  39323. * WARNING: This method returns internal data without copying, for
  39324. * performance. The return value must NOT be mutated, and should be treated as
  39325. * an immutable borrow. If you want to take ownership, you must make your own
  39326. * copy.
  39327. */
  39328. MappingList$1.prototype.toArray = function MappingList_toArray() {
  39329. if (!this._sorted) {
  39330. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  39331. this._sorted = true;
  39332. }
  39333. return this._array;
  39334. };
  39335. mappingList.MappingList = MappingList$1;
  39336. /* -*- Mode: js; js-indent-level: 2; -*- */
  39337. /*
  39338. * Copyright 2011 Mozilla Foundation and contributors
  39339. * Licensed under the New BSD license. See LICENSE or:
  39340. * http://opensource.org/licenses/BSD-3-Clause
  39341. */
  39342. var base64VLQ$1 = base64Vlq;
  39343. var util$2 = util$5;
  39344. var ArraySet$1 = arraySet.ArraySet;
  39345. var MappingList = mappingList.MappingList;
  39346. /**
  39347. * An instance of the SourceMapGenerator represents a source map which is
  39348. * being built incrementally. You may pass an object with the following
  39349. * properties:
  39350. *
  39351. * - file: The filename of the generated source.
  39352. * - sourceRoot: A root for all relative URLs in this source map.
  39353. */
  39354. function SourceMapGenerator$2(aArgs) {
  39355. if (!aArgs) {
  39356. aArgs = {};
  39357. }
  39358. this._file = util$2.getArg(aArgs, 'file', null);
  39359. this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
  39360. this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
  39361. this._sources = new ArraySet$1();
  39362. this._names = new ArraySet$1();
  39363. this._mappings = new MappingList();
  39364. this._sourcesContents = null;
  39365. }
  39366. SourceMapGenerator$2.prototype._version = 3;
  39367. /**
  39368. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  39369. *
  39370. * @param aSourceMapConsumer The SourceMap.
  39371. */
  39372. SourceMapGenerator$2.fromSourceMap =
  39373. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  39374. var sourceRoot = aSourceMapConsumer.sourceRoot;
  39375. var generator = new SourceMapGenerator$2({
  39376. file: aSourceMapConsumer.file,
  39377. sourceRoot: sourceRoot
  39378. });
  39379. aSourceMapConsumer.eachMapping(function (mapping) {
  39380. var newMapping = {
  39381. generated: {
  39382. line: mapping.generatedLine,
  39383. column: mapping.generatedColumn
  39384. }
  39385. };
  39386. if (mapping.source != null) {
  39387. newMapping.source = mapping.source;
  39388. if (sourceRoot != null) {
  39389. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  39390. }
  39391. newMapping.original = {
  39392. line: mapping.originalLine,
  39393. column: mapping.originalColumn
  39394. };
  39395. if (mapping.name != null) {
  39396. newMapping.name = mapping.name;
  39397. }
  39398. }
  39399. generator.addMapping(newMapping);
  39400. });
  39401. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39402. var sourceRelative = sourceFile;
  39403. if (sourceRoot !== null) {
  39404. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  39405. }
  39406. if (!generator._sources.has(sourceRelative)) {
  39407. generator._sources.add(sourceRelative);
  39408. }
  39409. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39410. if (content != null) {
  39411. generator.setSourceContent(sourceFile, content);
  39412. }
  39413. });
  39414. return generator;
  39415. };
  39416. /**
  39417. * Add a single mapping from original source line and column to the generated
  39418. * source's line and column for this source map being created. The mapping
  39419. * object should have the following properties:
  39420. *
  39421. * - generated: An object with the generated line and column positions.
  39422. * - original: An object with the original line and column positions.
  39423. * - source: The original source file (relative to the sourceRoot).
  39424. * - name: An optional original token name for this mapping.
  39425. */
  39426. SourceMapGenerator$2.prototype.addMapping =
  39427. function SourceMapGenerator_addMapping(aArgs) {
  39428. var generated = util$2.getArg(aArgs, 'generated');
  39429. var original = util$2.getArg(aArgs, 'original', null);
  39430. var source = util$2.getArg(aArgs, 'source', null);
  39431. var name = util$2.getArg(aArgs, 'name', null);
  39432. if (!this._skipValidation) {
  39433. this._validateMapping(generated, original, source, name);
  39434. }
  39435. if (source != null) {
  39436. source = String(source);
  39437. if (!this._sources.has(source)) {
  39438. this._sources.add(source);
  39439. }
  39440. }
  39441. if (name != null) {
  39442. name = String(name);
  39443. if (!this._names.has(name)) {
  39444. this._names.add(name);
  39445. }
  39446. }
  39447. this._mappings.add({
  39448. generatedLine: generated.line,
  39449. generatedColumn: generated.column,
  39450. originalLine: original != null && original.line,
  39451. originalColumn: original != null && original.column,
  39452. source: source,
  39453. name: name
  39454. });
  39455. };
  39456. /**
  39457. * Set the source content for a source file.
  39458. */
  39459. SourceMapGenerator$2.prototype.setSourceContent =
  39460. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  39461. var source = aSourceFile;
  39462. if (this._sourceRoot != null) {
  39463. source = util$2.relative(this._sourceRoot, source);
  39464. }
  39465. if (aSourceContent != null) {
  39466. // Add the source content to the _sourcesContents map.
  39467. // Create a new _sourcesContents map if the property is null.
  39468. if (!this._sourcesContents) {
  39469. this._sourcesContents = Object.create(null);
  39470. }
  39471. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  39472. } else if (this._sourcesContents) {
  39473. // Remove the source file from the _sourcesContents map.
  39474. // If the _sourcesContents map is empty, set the property to null.
  39475. delete this._sourcesContents[util$2.toSetString(source)];
  39476. if (Object.keys(this._sourcesContents).length === 0) {
  39477. this._sourcesContents = null;
  39478. }
  39479. }
  39480. };
  39481. /**
  39482. * Applies the mappings of a sub-source-map for a specific source file to the
  39483. * source map being generated. Each mapping to the supplied source file is
  39484. * rewritten using the supplied source map. Note: The resolution for the
  39485. * resulting mappings is the minimium of this map and the supplied map.
  39486. *
  39487. * @param aSourceMapConsumer The source map to be applied.
  39488. * @param aSourceFile Optional. The filename of the source file.
  39489. * If omitted, SourceMapConsumer's file property will be used.
  39490. * @param aSourceMapPath Optional. The dirname of the path to the source map
  39491. * to be applied. If relative, it is relative to the SourceMapConsumer.
  39492. * This parameter is needed when the two source maps aren't in the same
  39493. * directory, and the source map to be applied contains relative source
  39494. * paths. If so, those relative source paths need to be rewritten
  39495. * relative to the SourceMapGenerator.
  39496. */
  39497. SourceMapGenerator$2.prototype.applySourceMap =
  39498. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  39499. var sourceFile = aSourceFile;
  39500. // If aSourceFile is omitted, we will use the file property of the SourceMap
  39501. if (aSourceFile == null) {
  39502. if (aSourceMapConsumer.file == null) {
  39503. throw new Error(
  39504. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  39505. 'or the source map\'s "file" property. Both were omitted.'
  39506. );
  39507. }
  39508. sourceFile = aSourceMapConsumer.file;
  39509. }
  39510. var sourceRoot = this._sourceRoot;
  39511. // Make "sourceFile" relative if an absolute Url is passed.
  39512. if (sourceRoot != null) {
  39513. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39514. }
  39515. // Applying the SourceMap can add and remove items from the sources and
  39516. // the names array.
  39517. var newSources = new ArraySet$1();
  39518. var newNames = new ArraySet$1();
  39519. // Find mappings for the "sourceFile"
  39520. this._mappings.unsortedForEach(function (mapping) {
  39521. if (mapping.source === sourceFile && mapping.originalLine != null) {
  39522. // Check if it can be mapped by the source map, then update the mapping.
  39523. var original = aSourceMapConsumer.originalPositionFor({
  39524. line: mapping.originalLine,
  39525. column: mapping.originalColumn
  39526. });
  39527. if (original.source != null) {
  39528. // Copy mapping
  39529. mapping.source = original.source;
  39530. if (aSourceMapPath != null) {
  39531. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  39532. }
  39533. if (sourceRoot != null) {
  39534. mapping.source = util$2.relative(sourceRoot, mapping.source);
  39535. }
  39536. mapping.originalLine = original.line;
  39537. mapping.originalColumn = original.column;
  39538. if (original.name != null) {
  39539. mapping.name = original.name;
  39540. }
  39541. }
  39542. }
  39543. var source = mapping.source;
  39544. if (source != null && !newSources.has(source)) {
  39545. newSources.add(source);
  39546. }
  39547. var name = mapping.name;
  39548. if (name != null && !newNames.has(name)) {
  39549. newNames.add(name);
  39550. }
  39551. }, this);
  39552. this._sources = newSources;
  39553. this._names = newNames;
  39554. // Copy sourcesContents of applied map.
  39555. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39556. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39557. if (content != null) {
  39558. if (aSourceMapPath != null) {
  39559. sourceFile = util$2.join(aSourceMapPath, sourceFile);
  39560. }
  39561. if (sourceRoot != null) {
  39562. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39563. }
  39564. this.setSourceContent(sourceFile, content);
  39565. }
  39566. }, this);
  39567. };
  39568. /**
  39569. * A mapping can have one of the three levels of data:
  39570. *
  39571. * 1. Just the generated position.
  39572. * 2. The Generated position, original position, and original source.
  39573. * 3. Generated and original position, original source, as well as a name
  39574. * token.
  39575. *
  39576. * To maintain consistency, we validate that any new mapping being added falls
  39577. * in to one of these categories.
  39578. */
  39579. SourceMapGenerator$2.prototype._validateMapping =
  39580. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  39581. aName) {
  39582. // When aOriginal is truthy but has empty values for .line and .column,
  39583. // it is most likely a programmer error. In this case we throw a very
  39584. // specific error message to try to guide them the right way.
  39585. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  39586. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  39587. throw new Error(
  39588. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  39589. 'the original mapping entirely and only map the generated position. If so, pass ' +
  39590. 'null for the original mapping instead of an object with empty or null values.'
  39591. );
  39592. }
  39593. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39594. && aGenerated.line > 0 && aGenerated.column >= 0
  39595. && !aOriginal && !aSource && !aName) {
  39596. // Case 1.
  39597. return;
  39598. }
  39599. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39600. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  39601. && aGenerated.line > 0 && aGenerated.column >= 0
  39602. && aOriginal.line > 0 && aOriginal.column >= 0
  39603. && aSource) {
  39604. // Cases 2 and 3.
  39605. return;
  39606. }
  39607. else {
  39608. throw new Error('Invalid mapping: ' + JSON.stringify({
  39609. generated: aGenerated,
  39610. source: aSource,
  39611. original: aOriginal,
  39612. name: aName
  39613. }));
  39614. }
  39615. };
  39616. /**
  39617. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  39618. * specified by the source map format.
  39619. */
  39620. SourceMapGenerator$2.prototype._serializeMappings =
  39621. function SourceMapGenerator_serializeMappings() {
  39622. var previousGeneratedColumn = 0;
  39623. var previousGeneratedLine = 1;
  39624. var previousOriginalColumn = 0;
  39625. var previousOriginalLine = 0;
  39626. var previousName = 0;
  39627. var previousSource = 0;
  39628. var result = '';
  39629. var next;
  39630. var mapping;
  39631. var nameIdx;
  39632. var sourceIdx;
  39633. var mappings = this._mappings.toArray();
  39634. for (var i = 0, len = mappings.length; i < len; i++) {
  39635. mapping = mappings[i];
  39636. next = '';
  39637. if (mapping.generatedLine !== previousGeneratedLine) {
  39638. previousGeneratedColumn = 0;
  39639. while (mapping.generatedLine !== previousGeneratedLine) {
  39640. next += ';';
  39641. previousGeneratedLine++;
  39642. }
  39643. }
  39644. else {
  39645. if (i > 0) {
  39646. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  39647. continue;
  39648. }
  39649. next += ',';
  39650. }
  39651. }
  39652. next += base64VLQ$1.encode(mapping.generatedColumn
  39653. - previousGeneratedColumn);
  39654. previousGeneratedColumn = mapping.generatedColumn;
  39655. if (mapping.source != null) {
  39656. sourceIdx = this._sources.indexOf(mapping.source);
  39657. next += base64VLQ$1.encode(sourceIdx - previousSource);
  39658. previousSource = sourceIdx;
  39659. // lines are stored 0-based in SourceMap spec version 3
  39660. next += base64VLQ$1.encode(mapping.originalLine - 1
  39661. - previousOriginalLine);
  39662. previousOriginalLine = mapping.originalLine - 1;
  39663. next += base64VLQ$1.encode(mapping.originalColumn
  39664. - previousOriginalColumn);
  39665. previousOriginalColumn = mapping.originalColumn;
  39666. if (mapping.name != null) {
  39667. nameIdx = this._names.indexOf(mapping.name);
  39668. next += base64VLQ$1.encode(nameIdx - previousName);
  39669. previousName = nameIdx;
  39670. }
  39671. }
  39672. result += next;
  39673. }
  39674. return result;
  39675. };
  39676. SourceMapGenerator$2.prototype._generateSourcesContent =
  39677. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  39678. return aSources.map(function (source) {
  39679. if (!this._sourcesContents) {
  39680. return null;
  39681. }
  39682. if (aSourceRoot != null) {
  39683. source = util$2.relative(aSourceRoot, source);
  39684. }
  39685. var key = util$2.toSetString(source);
  39686. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  39687. ? this._sourcesContents[key]
  39688. : null;
  39689. }, this);
  39690. };
  39691. /**
  39692. * Externalize the source map.
  39693. */
  39694. SourceMapGenerator$2.prototype.toJSON =
  39695. function SourceMapGenerator_toJSON() {
  39696. var map = {
  39697. version: this._version,
  39698. sources: this._sources.toArray(),
  39699. names: this._names.toArray(),
  39700. mappings: this._serializeMappings()
  39701. };
  39702. if (this._file != null) {
  39703. map.file = this._file;
  39704. }
  39705. if (this._sourceRoot != null) {
  39706. map.sourceRoot = this._sourceRoot;
  39707. }
  39708. if (this._sourcesContents) {
  39709. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  39710. }
  39711. return map;
  39712. };
  39713. /**
  39714. * Render the source map being generated to a string.
  39715. */
  39716. SourceMapGenerator$2.prototype.toString =
  39717. function SourceMapGenerator_toString() {
  39718. return JSON.stringify(this.toJSON());
  39719. };
  39720. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$2;
  39721. var sourceMapConsumer = {};
  39722. var binarySearch$1 = {};
  39723. /* -*- Mode: js; js-indent-level: 2; -*- */
  39724. (function (exports) {
  39725. /*
  39726. * Copyright 2011 Mozilla Foundation and contributors
  39727. * Licensed under the New BSD license. See LICENSE or:
  39728. * http://opensource.org/licenses/BSD-3-Clause
  39729. */
  39730. exports.GREATEST_LOWER_BOUND = 1;
  39731. exports.LEAST_UPPER_BOUND = 2;
  39732. /**
  39733. * Recursive implementation of binary search.
  39734. *
  39735. * @param aLow Indices here and lower do not contain the needle.
  39736. * @param aHigh Indices here and higher do not contain the needle.
  39737. * @param aNeedle The element being searched for.
  39738. * @param aHaystack The non-empty array being searched.
  39739. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  39740. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39741. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39742. * closest element that is smaller than or greater than the one we are
  39743. * searching for, respectively, if the exact element cannot be found.
  39744. */
  39745. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  39746. // This function terminates when one of the following is true:
  39747. //
  39748. // 1. We find the exact element we are looking for.
  39749. //
  39750. // 2. We did not find the exact element, but we can return the index of
  39751. // the next-closest element.
  39752. //
  39753. // 3. We did not find the exact element, and there is no next-closest
  39754. // element than the one we are searching for, so we return -1.
  39755. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  39756. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  39757. if (cmp === 0) {
  39758. // Found the element we are looking for.
  39759. return mid;
  39760. }
  39761. else if (cmp > 0) {
  39762. // Our needle is greater than aHaystack[mid].
  39763. if (aHigh - mid > 1) {
  39764. // The element is in the upper half.
  39765. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  39766. }
  39767. // The exact needle element was not found in this haystack. Determine if
  39768. // we are in termination case (3) or (2) and return the appropriate thing.
  39769. if (aBias == exports.LEAST_UPPER_BOUND) {
  39770. return aHigh < aHaystack.length ? aHigh : -1;
  39771. } else {
  39772. return mid;
  39773. }
  39774. }
  39775. else {
  39776. // Our needle is less than aHaystack[mid].
  39777. if (mid - aLow > 1) {
  39778. // The element is in the lower half.
  39779. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  39780. }
  39781. // we are in termination case (3) or (2) and return the appropriate thing.
  39782. if (aBias == exports.LEAST_UPPER_BOUND) {
  39783. return mid;
  39784. } else {
  39785. return aLow < 0 ? -1 : aLow;
  39786. }
  39787. }
  39788. }
  39789. /**
  39790. * This is an implementation of binary search which will always try and return
  39791. * the index of the closest element if there is no exact hit. This is because
  39792. * mappings between original and generated line/col pairs are single points,
  39793. * and there is an implicit region between each of them, so a miss just means
  39794. * that you aren't on the very start of a region.
  39795. *
  39796. * @param aNeedle The element you are looking for.
  39797. * @param aHaystack The array that is being searched.
  39798. * @param aCompare A function which takes the needle and an element in the
  39799. * array and returns -1, 0, or 1 depending on whether the needle is less
  39800. * than, equal to, or greater than the element, respectively.
  39801. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39802. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39803. * closest element that is smaller than or greater than the one we are
  39804. * searching for, respectively, if the exact element cannot be found.
  39805. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  39806. */
  39807. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  39808. if (aHaystack.length === 0) {
  39809. return -1;
  39810. }
  39811. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  39812. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  39813. if (index < 0) {
  39814. return -1;
  39815. }
  39816. // We have found either the exact element, or the next-closest element than
  39817. // the one we are searching for. However, there may be more than one such
  39818. // element. Make sure we always return the smallest of these.
  39819. while (index - 1 >= 0) {
  39820. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  39821. break;
  39822. }
  39823. --index;
  39824. }
  39825. return index;
  39826. };
  39827. } (binarySearch$1));
  39828. var quickSort$1 = {};
  39829. /* -*- Mode: js; js-indent-level: 2; -*- */
  39830. /*
  39831. * Copyright 2011 Mozilla Foundation and contributors
  39832. * Licensed under the New BSD license. See LICENSE or:
  39833. * http://opensource.org/licenses/BSD-3-Clause
  39834. */
  39835. // It turns out that some (most?) JavaScript engines don't self-host
  39836. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  39837. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  39838. // custom comparator function, calling back and forth between the VM's C++ and
  39839. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  39840. // worse generated code for the comparator function than would be optimal. In
  39841. // fact, when sorting with a comparator, these costs outweigh the benefits of
  39842. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  39843. // a ~3500ms mean speed-up in `bench/bench.html`.
  39844. /**
  39845. * Swap the elements indexed by `x` and `y` in the array `ary`.
  39846. *
  39847. * @param {Array} ary
  39848. * The array.
  39849. * @param {Number} x
  39850. * The index of the first item.
  39851. * @param {Number} y
  39852. * The index of the second item.
  39853. */
  39854. function swap(ary, x, y) {
  39855. var temp = ary[x];
  39856. ary[x] = ary[y];
  39857. ary[y] = temp;
  39858. }
  39859. /**
  39860. * Returns a random integer within the range `low .. high` inclusive.
  39861. *
  39862. * @param {Number} low
  39863. * The lower bound on the range.
  39864. * @param {Number} high
  39865. * The upper bound on the range.
  39866. */
  39867. function randomIntInRange(low, high) {
  39868. return Math.round(low + (Math.random() * (high - low)));
  39869. }
  39870. /**
  39871. * The Quick Sort algorithm.
  39872. *
  39873. * @param {Array} ary
  39874. * An array to sort.
  39875. * @param {function} comparator
  39876. * Function to use to compare two items.
  39877. * @param {Number} p
  39878. * Start index of the array
  39879. * @param {Number} r
  39880. * End index of the array
  39881. */
  39882. function doQuickSort(ary, comparator, p, r) {
  39883. // If our lower bound is less than our upper bound, we (1) partition the
  39884. // array into two pieces and (2) recurse on each half. If it is not, this is
  39885. // the empty array and our base case.
  39886. if (p < r) {
  39887. // (1) Partitioning.
  39888. //
  39889. // The partitioning chooses a pivot between `p` and `r` and moves all
  39890. // elements that are less than or equal to the pivot to the before it, and
  39891. // all the elements that are greater than it after it. The effect is that
  39892. // once partition is done, the pivot is in the exact place it will be when
  39893. // the array is put in sorted order, and it will not need to be moved
  39894. // again. This runs in O(n) time.
  39895. // Always choose a random pivot so that an input array which is reverse
  39896. // sorted does not cause O(n^2) running time.
  39897. var pivotIndex = randomIntInRange(p, r);
  39898. var i = p - 1;
  39899. swap(ary, pivotIndex, r);
  39900. var pivot = ary[r];
  39901. // Immediately after `j` is incremented in this loop, the following hold
  39902. // true:
  39903. //
  39904. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  39905. //
  39906. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  39907. for (var j = p; j < r; j++) {
  39908. if (comparator(ary[j], pivot) <= 0) {
  39909. i += 1;
  39910. swap(ary, i, j);
  39911. }
  39912. }
  39913. swap(ary, i + 1, j);
  39914. var q = i + 1;
  39915. // (2) Recurse on each half.
  39916. doQuickSort(ary, comparator, p, q - 1);
  39917. doQuickSort(ary, comparator, q + 1, r);
  39918. }
  39919. }
  39920. /**
  39921. * Sort the given array in-place with the given comparator function.
  39922. *
  39923. * @param {Array} ary
  39924. * An array to sort.
  39925. * @param {function} comparator
  39926. * Function to use to compare two items.
  39927. */
  39928. quickSort$1.quickSort = function (ary, comparator) {
  39929. doQuickSort(ary, comparator, 0, ary.length - 1);
  39930. };
  39931. /* -*- Mode: js; js-indent-level: 2; -*- */
  39932. /*
  39933. * Copyright 2011 Mozilla Foundation and contributors
  39934. * Licensed under the New BSD license. See LICENSE or:
  39935. * http://opensource.org/licenses/BSD-3-Clause
  39936. */
  39937. var util$1 = util$5;
  39938. var binarySearch = binarySearch$1;
  39939. var ArraySet = arraySet.ArraySet;
  39940. var base64VLQ = base64Vlq;
  39941. var quickSort = quickSort$1.quickSort;
  39942. function SourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  39943. var sourceMap = aSourceMap;
  39944. if (typeof aSourceMap === 'string') {
  39945. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  39946. }
  39947. return sourceMap.sections != null
  39948. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  39949. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  39950. }
  39951. SourceMapConsumer$1.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  39952. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  39953. };
  39954. /**
  39955. * The version of the source mapping spec that we are consuming.
  39956. */
  39957. SourceMapConsumer$1.prototype._version = 3;
  39958. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  39959. // parsed mapping coordinates from the source map's "mappings" attribute. They
  39960. // are lazily instantiated, accessed via the `_generatedMappings` and
  39961. // `_originalMappings` getters respectively, and we only parse the mappings
  39962. // and create these arrays once queried for a source location. We jump through
  39963. // these hoops because there can be many thousands of mappings, and parsing
  39964. // them is expensive, so we only want to do it if we must.
  39965. //
  39966. // Each object in the arrays is of the form:
  39967. //
  39968. // {
  39969. // generatedLine: The line number in the generated code,
  39970. // generatedColumn: The column number in the generated code,
  39971. // source: The path to the original source file that generated this
  39972. // chunk of code,
  39973. // originalLine: The line number in the original source that
  39974. // corresponds to this chunk of generated code,
  39975. // originalColumn: The column number in the original source that
  39976. // corresponds to this chunk of generated code,
  39977. // name: The name of the original symbol which generated this chunk of
  39978. // code.
  39979. // }
  39980. //
  39981. // All properties except for `generatedLine` and `generatedColumn` can be
  39982. // `null`.
  39983. //
  39984. // `_generatedMappings` is ordered by the generated positions.
  39985. //
  39986. // `_originalMappings` is ordered by the original positions.
  39987. SourceMapConsumer$1.prototype.__generatedMappings = null;
  39988. Object.defineProperty(SourceMapConsumer$1.prototype, '_generatedMappings', {
  39989. configurable: true,
  39990. enumerable: true,
  39991. get: function () {
  39992. if (!this.__generatedMappings) {
  39993. this._parseMappings(this._mappings, this.sourceRoot);
  39994. }
  39995. return this.__generatedMappings;
  39996. }
  39997. });
  39998. SourceMapConsumer$1.prototype.__originalMappings = null;
  39999. Object.defineProperty(SourceMapConsumer$1.prototype, '_originalMappings', {
  40000. configurable: true,
  40001. enumerable: true,
  40002. get: function () {
  40003. if (!this.__originalMappings) {
  40004. this._parseMappings(this._mappings, this.sourceRoot);
  40005. }
  40006. return this.__originalMappings;
  40007. }
  40008. });
  40009. SourceMapConsumer$1.prototype._charIsMappingSeparator =
  40010. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  40011. var c = aStr.charAt(index);
  40012. return c === ";" || c === ",";
  40013. };
  40014. /**
  40015. * Parse the mappings in a string in to a data structure which we can easily
  40016. * query (the ordered arrays in the `this.__generatedMappings` and
  40017. * `this.__originalMappings` properties).
  40018. */
  40019. SourceMapConsumer$1.prototype._parseMappings =
  40020. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40021. throw new Error("Subclasses must implement _parseMappings");
  40022. };
  40023. SourceMapConsumer$1.GENERATED_ORDER = 1;
  40024. SourceMapConsumer$1.ORIGINAL_ORDER = 2;
  40025. SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
  40026. SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
  40027. /**
  40028. * Iterate over each mapping between an original source/line/column and a
  40029. * generated line/column in this source map.
  40030. *
  40031. * @param Function aCallback
  40032. * The function that is called with each mapping.
  40033. * @param Object aContext
  40034. * Optional. If specified, this object will be the value of `this` every
  40035. * time that `aCallback` is called.
  40036. * @param aOrder
  40037. * Either `SourceMapConsumer.GENERATED_ORDER` or
  40038. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  40039. * iterate over the mappings sorted by the generated file's line/column
  40040. * order or the original's source/line/column order, respectively. Defaults to
  40041. * `SourceMapConsumer.GENERATED_ORDER`.
  40042. */
  40043. SourceMapConsumer$1.prototype.eachMapping =
  40044. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  40045. var context = aContext || null;
  40046. var order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
  40047. var mappings;
  40048. switch (order) {
  40049. case SourceMapConsumer$1.GENERATED_ORDER:
  40050. mappings = this._generatedMappings;
  40051. break;
  40052. case SourceMapConsumer$1.ORIGINAL_ORDER:
  40053. mappings = this._originalMappings;
  40054. break;
  40055. default:
  40056. throw new Error("Unknown order of iteration.");
  40057. }
  40058. var sourceRoot = this.sourceRoot;
  40059. mappings.map(function (mapping) {
  40060. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  40061. source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  40062. return {
  40063. source: source,
  40064. generatedLine: mapping.generatedLine,
  40065. generatedColumn: mapping.generatedColumn,
  40066. originalLine: mapping.originalLine,
  40067. originalColumn: mapping.originalColumn,
  40068. name: mapping.name === null ? null : this._names.at(mapping.name)
  40069. };
  40070. }, this).forEach(aCallback, context);
  40071. };
  40072. /**
  40073. * Returns all generated line and column information for the original source,
  40074. * line, and column provided. If no column is provided, returns all mappings
  40075. * corresponding to a either the line we are searching for or the next
  40076. * closest line that has any mappings. Otherwise, returns all mappings
  40077. * corresponding to the given line and either the column we are searching for
  40078. * or the next closest column that has any offsets.
  40079. *
  40080. * The only argument is an object with the following properties:
  40081. *
  40082. * - source: The filename of the original source.
  40083. * - line: The line number in the original source. The line number is 1-based.
  40084. * - column: Optional. the column number in the original source.
  40085. * The column number is 0-based.
  40086. *
  40087. * and an array of objects is returned, each with the following properties:
  40088. *
  40089. * - line: The line number in the generated source, or null. The
  40090. * line number is 1-based.
  40091. * - column: The column number in the generated source, or null.
  40092. * The column number is 0-based.
  40093. */
  40094. SourceMapConsumer$1.prototype.allGeneratedPositionsFor =
  40095. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  40096. var line = util$1.getArg(aArgs, 'line');
  40097. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  40098. // returns the index of the closest mapping less than the needle. By
  40099. // setting needle.originalColumn to 0, we thus find the last mapping for
  40100. // the given line, provided such a mapping exists.
  40101. var needle = {
  40102. source: util$1.getArg(aArgs, 'source'),
  40103. originalLine: line,
  40104. originalColumn: util$1.getArg(aArgs, 'column', 0)
  40105. };
  40106. needle.source = this._findSourceIndex(needle.source);
  40107. if (needle.source < 0) {
  40108. return [];
  40109. }
  40110. var mappings = [];
  40111. var index = this._findMapping(needle,
  40112. this._originalMappings,
  40113. "originalLine",
  40114. "originalColumn",
  40115. util$1.compareByOriginalPositions,
  40116. binarySearch.LEAST_UPPER_BOUND);
  40117. if (index >= 0) {
  40118. var mapping = this._originalMappings[index];
  40119. if (aArgs.column === undefined) {
  40120. var originalLine = mapping.originalLine;
  40121. // Iterate until either we run out of mappings, or we run into
  40122. // a mapping for a different line than the one we found. Since
  40123. // mappings are sorted, this is guaranteed to find all mappings for
  40124. // the line we found.
  40125. while (mapping && mapping.originalLine === originalLine) {
  40126. mappings.push({
  40127. line: util$1.getArg(mapping, 'generatedLine', null),
  40128. column: util$1.getArg(mapping, 'generatedColumn', null),
  40129. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40130. });
  40131. mapping = this._originalMappings[++index];
  40132. }
  40133. } else {
  40134. var originalColumn = mapping.originalColumn;
  40135. // Iterate until either we run out of mappings, or we run into
  40136. // a mapping for a different line than the one we were searching for.
  40137. // Since mappings are sorted, this is guaranteed to find all mappings for
  40138. // the line we are searching for.
  40139. while (mapping &&
  40140. mapping.originalLine === line &&
  40141. mapping.originalColumn == originalColumn) {
  40142. mappings.push({
  40143. line: util$1.getArg(mapping, 'generatedLine', null),
  40144. column: util$1.getArg(mapping, 'generatedColumn', null),
  40145. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40146. });
  40147. mapping = this._originalMappings[++index];
  40148. }
  40149. }
  40150. }
  40151. return mappings;
  40152. };
  40153. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
  40154. /**
  40155. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  40156. * query for information about the original file positions by giving it a file
  40157. * position in the generated source.
  40158. *
  40159. * The first parameter is the raw source map (either as a JSON string, or
  40160. * already parsed to an object). According to the spec, source maps have the
  40161. * following attributes:
  40162. *
  40163. * - version: Which version of the source map spec this map is following.
  40164. * - sources: An array of URLs to the original source files.
  40165. * - names: An array of identifiers which can be referrenced by individual mappings.
  40166. * - sourceRoot: Optional. The URL root from which all sources are relative.
  40167. * - sourcesContent: Optional. An array of contents of the original source files.
  40168. * - mappings: A string of base64 VLQs which contain the actual mappings.
  40169. * - file: Optional. The generated file this source map is associated with.
  40170. *
  40171. * Here is an example source map, taken from the source map spec[0]:
  40172. *
  40173. * {
  40174. * version : 3,
  40175. * file: "out.js",
  40176. * sourceRoot : "",
  40177. * sources: ["foo.js", "bar.js"],
  40178. * names: ["src", "maps", "are", "fun"],
  40179. * mappings: "AA,AB;;ABCDE;"
  40180. * }
  40181. *
  40182. * The second parameter, if given, is a string whose value is the URL
  40183. * at which the source map was found. This URL is used to compute the
  40184. * sources array.
  40185. *
  40186. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  40187. */
  40188. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40189. var sourceMap = aSourceMap;
  40190. if (typeof aSourceMap === 'string') {
  40191. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40192. }
  40193. var version = util$1.getArg(sourceMap, 'version');
  40194. var sources = util$1.getArg(sourceMap, 'sources');
  40195. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  40196. // requires the array) to play nice here.
  40197. var names = util$1.getArg(sourceMap, 'names', []);
  40198. var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
  40199. var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
  40200. var mappings = util$1.getArg(sourceMap, 'mappings');
  40201. var file = util$1.getArg(sourceMap, 'file', null);
  40202. // Once again, Sass deviates from the spec and supplies the version as a
  40203. // string rather than a number, so we use loose equality checking here.
  40204. if (version != this._version) {
  40205. throw new Error('Unsupported version: ' + version);
  40206. }
  40207. if (sourceRoot) {
  40208. sourceRoot = util$1.normalize(sourceRoot);
  40209. }
  40210. sources = sources
  40211. .map(String)
  40212. // Some source maps produce relative source paths like "./foo.js" instead of
  40213. // "foo.js". Normalize these first so that future comparisons will succeed.
  40214. // See bugzil.la/1090768.
  40215. .map(util$1.normalize)
  40216. // Always ensure that absolute sources are internally stored relative to
  40217. // the source root, if the source root is absolute. Not doing this would
  40218. // be particularly problematic when the source root is a prefix of the
  40219. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  40220. .map(function (source) {
  40221. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  40222. ? util$1.relative(sourceRoot, source)
  40223. : source;
  40224. });
  40225. // Pass `true` below to allow duplicate names and sources. While source maps
  40226. // are intended to be compressed and deduplicated, the TypeScript compiler
  40227. // sometimes generates source maps with duplicates in them. See Github issue
  40228. // #72 and bugzil.la/889492.
  40229. this._names = ArraySet.fromArray(names.map(String), true);
  40230. this._sources = ArraySet.fromArray(sources, true);
  40231. this._absoluteSources = this._sources.toArray().map(function (s) {
  40232. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  40233. });
  40234. this.sourceRoot = sourceRoot;
  40235. this.sourcesContent = sourcesContent;
  40236. this._mappings = mappings;
  40237. this._sourceMapURL = aSourceMapURL;
  40238. this.file = file;
  40239. }
  40240. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40241. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
  40242. /**
  40243. * Utility function to find the index of a source. Returns -1 if not
  40244. * found.
  40245. */
  40246. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  40247. var relativeSource = aSource;
  40248. if (this.sourceRoot != null) {
  40249. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40250. }
  40251. if (this._sources.has(relativeSource)) {
  40252. return this._sources.indexOf(relativeSource);
  40253. }
  40254. // Maybe aSource is an absolute URL as returned by |sources|. In
  40255. // this case we can't simply undo the transform.
  40256. var i;
  40257. for (i = 0; i < this._absoluteSources.length; ++i) {
  40258. if (this._absoluteSources[i] == aSource) {
  40259. return i;
  40260. }
  40261. }
  40262. return -1;
  40263. };
  40264. /**
  40265. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  40266. *
  40267. * @param SourceMapGenerator aSourceMap
  40268. * The source map that will be consumed.
  40269. * @param String aSourceMapURL
  40270. * The URL at which the source map can be found (optional)
  40271. * @returns BasicSourceMapConsumer
  40272. */
  40273. BasicSourceMapConsumer.fromSourceMap =
  40274. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  40275. var smc = Object.create(BasicSourceMapConsumer.prototype);
  40276. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  40277. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  40278. smc.sourceRoot = aSourceMap._sourceRoot;
  40279. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  40280. smc.sourceRoot);
  40281. smc.file = aSourceMap._file;
  40282. smc._sourceMapURL = aSourceMapURL;
  40283. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  40284. return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  40285. });
  40286. // Because we are modifying the entries (by converting string sources and
  40287. // names to indices into the sources and names ArraySets), we have to make
  40288. // a copy of the entry or else bad things happen. Shared mutable state
  40289. // strikes again! See github issue #191.
  40290. var generatedMappings = aSourceMap._mappings.toArray().slice();
  40291. var destGeneratedMappings = smc.__generatedMappings = [];
  40292. var destOriginalMappings = smc.__originalMappings = [];
  40293. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  40294. var srcMapping = generatedMappings[i];
  40295. var destMapping = new Mapping;
  40296. destMapping.generatedLine = srcMapping.generatedLine;
  40297. destMapping.generatedColumn = srcMapping.generatedColumn;
  40298. if (srcMapping.source) {
  40299. destMapping.source = sources.indexOf(srcMapping.source);
  40300. destMapping.originalLine = srcMapping.originalLine;
  40301. destMapping.originalColumn = srcMapping.originalColumn;
  40302. if (srcMapping.name) {
  40303. destMapping.name = names.indexOf(srcMapping.name);
  40304. }
  40305. destOriginalMappings.push(destMapping);
  40306. }
  40307. destGeneratedMappings.push(destMapping);
  40308. }
  40309. quickSort(smc.__originalMappings, util$1.compareByOriginalPositions);
  40310. return smc;
  40311. };
  40312. /**
  40313. * The version of the source mapping spec that we are consuming.
  40314. */
  40315. BasicSourceMapConsumer.prototype._version = 3;
  40316. /**
  40317. * The list of original sources.
  40318. */
  40319. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  40320. get: function () {
  40321. return this._absoluteSources.slice();
  40322. }
  40323. });
  40324. /**
  40325. * Provide the JIT with a nice shape / hidden class.
  40326. */
  40327. function Mapping() {
  40328. this.generatedLine = 0;
  40329. this.generatedColumn = 0;
  40330. this.source = null;
  40331. this.originalLine = null;
  40332. this.originalColumn = null;
  40333. this.name = null;
  40334. }
  40335. /**
  40336. * Parse the mappings in a string in to a data structure which we can easily
  40337. * query (the ordered arrays in the `this.__generatedMappings` and
  40338. * `this.__originalMappings` properties).
  40339. */
  40340. BasicSourceMapConsumer.prototype._parseMappings =
  40341. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40342. var generatedLine = 1;
  40343. var previousGeneratedColumn = 0;
  40344. var previousOriginalLine = 0;
  40345. var previousOriginalColumn = 0;
  40346. var previousSource = 0;
  40347. var previousName = 0;
  40348. var length = aStr.length;
  40349. var index = 0;
  40350. var cachedSegments = {};
  40351. var temp = {};
  40352. var originalMappings = [];
  40353. var generatedMappings = [];
  40354. var mapping, str, segment, end, value;
  40355. while (index < length) {
  40356. if (aStr.charAt(index) === ';') {
  40357. generatedLine++;
  40358. index++;
  40359. previousGeneratedColumn = 0;
  40360. }
  40361. else if (aStr.charAt(index) === ',') {
  40362. index++;
  40363. }
  40364. else {
  40365. mapping = new Mapping();
  40366. mapping.generatedLine = generatedLine;
  40367. // Because each offset is encoded relative to the previous one,
  40368. // many segments often have the same encoding. We can exploit this
  40369. // fact by caching the parsed variable length fields of each segment,
  40370. // allowing us to avoid a second parse if we encounter the same
  40371. // segment again.
  40372. for (end = index; end < length; end++) {
  40373. if (this._charIsMappingSeparator(aStr, end)) {
  40374. break;
  40375. }
  40376. }
  40377. str = aStr.slice(index, end);
  40378. segment = cachedSegments[str];
  40379. if (segment) {
  40380. index += str.length;
  40381. } else {
  40382. segment = [];
  40383. while (index < end) {
  40384. base64VLQ.decode(aStr, index, temp);
  40385. value = temp.value;
  40386. index = temp.rest;
  40387. segment.push(value);
  40388. }
  40389. if (segment.length === 2) {
  40390. throw new Error('Found a source, but no line and column');
  40391. }
  40392. if (segment.length === 3) {
  40393. throw new Error('Found a source and line, but no column');
  40394. }
  40395. cachedSegments[str] = segment;
  40396. }
  40397. // Generated column.
  40398. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  40399. previousGeneratedColumn = mapping.generatedColumn;
  40400. if (segment.length > 1) {
  40401. // Original source.
  40402. mapping.source = previousSource + segment[1];
  40403. previousSource += segment[1];
  40404. // Original line.
  40405. mapping.originalLine = previousOriginalLine + segment[2];
  40406. previousOriginalLine = mapping.originalLine;
  40407. // Lines are stored 0-based
  40408. mapping.originalLine += 1;
  40409. // Original column.
  40410. mapping.originalColumn = previousOriginalColumn + segment[3];
  40411. previousOriginalColumn = mapping.originalColumn;
  40412. if (segment.length > 4) {
  40413. // Original name.
  40414. mapping.name = previousName + segment[4];
  40415. previousName += segment[4];
  40416. }
  40417. }
  40418. generatedMappings.push(mapping);
  40419. if (typeof mapping.originalLine === 'number') {
  40420. originalMappings.push(mapping);
  40421. }
  40422. }
  40423. }
  40424. quickSort(generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40425. this.__generatedMappings = generatedMappings;
  40426. quickSort(originalMappings, util$1.compareByOriginalPositions);
  40427. this.__originalMappings = originalMappings;
  40428. };
  40429. /**
  40430. * Find the mapping that best matches the hypothetical "needle" mapping that
  40431. * we are searching for in the given "haystack" of mappings.
  40432. */
  40433. BasicSourceMapConsumer.prototype._findMapping =
  40434. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  40435. aColumnName, aComparator, aBias) {
  40436. // To return the position we are searching for, we must first find the
  40437. // mapping for the given position and then return the opposite position it
  40438. // points to. Because the mappings are sorted, we can use binary search to
  40439. // find the best mapping.
  40440. if (aNeedle[aLineName] <= 0) {
  40441. throw new TypeError('Line must be greater than or equal to 1, got '
  40442. + aNeedle[aLineName]);
  40443. }
  40444. if (aNeedle[aColumnName] < 0) {
  40445. throw new TypeError('Column must be greater than or equal to 0, got '
  40446. + aNeedle[aColumnName]);
  40447. }
  40448. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  40449. };
  40450. /**
  40451. * Compute the last column for each generated mapping. The last column is
  40452. * inclusive.
  40453. */
  40454. BasicSourceMapConsumer.prototype.computeColumnSpans =
  40455. function SourceMapConsumer_computeColumnSpans() {
  40456. for (var index = 0; index < this._generatedMappings.length; ++index) {
  40457. var mapping = this._generatedMappings[index];
  40458. // Mappings do not contain a field for the last generated columnt. We
  40459. // can come up with an optimistic estimate, however, by assuming that
  40460. // mappings are contiguous (i.e. given two consecutive mappings, the
  40461. // first mapping ends where the second one starts).
  40462. if (index + 1 < this._generatedMappings.length) {
  40463. var nextMapping = this._generatedMappings[index + 1];
  40464. if (mapping.generatedLine === nextMapping.generatedLine) {
  40465. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  40466. continue;
  40467. }
  40468. }
  40469. // The last mapping for each line spans the entire line.
  40470. mapping.lastGeneratedColumn = Infinity;
  40471. }
  40472. };
  40473. /**
  40474. * Returns the original source, line, and column information for the generated
  40475. * source's line and column positions provided. The only argument is an object
  40476. * with the following properties:
  40477. *
  40478. * - line: The line number in the generated source. The line number
  40479. * is 1-based.
  40480. * - column: The column number in the generated source. The column
  40481. * number is 0-based.
  40482. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40483. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40484. * closest element that is smaller than or greater than the one we are
  40485. * searching for, respectively, if the exact element cannot be found.
  40486. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40487. *
  40488. * and an object is returned with the following properties:
  40489. *
  40490. * - source: The original source file, or null.
  40491. * - line: The line number in the original source, or null. The
  40492. * line number is 1-based.
  40493. * - column: The column number in the original source, or null. The
  40494. * column number is 0-based.
  40495. * - name: The original identifier, or null.
  40496. */
  40497. BasicSourceMapConsumer.prototype.originalPositionFor =
  40498. function SourceMapConsumer_originalPositionFor(aArgs) {
  40499. var needle = {
  40500. generatedLine: util$1.getArg(aArgs, 'line'),
  40501. generatedColumn: util$1.getArg(aArgs, 'column')
  40502. };
  40503. var index = this._findMapping(
  40504. needle,
  40505. this._generatedMappings,
  40506. "generatedLine",
  40507. "generatedColumn",
  40508. util$1.compareByGeneratedPositionsDeflated,
  40509. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40510. );
  40511. if (index >= 0) {
  40512. var mapping = this._generatedMappings[index];
  40513. if (mapping.generatedLine === needle.generatedLine) {
  40514. var source = util$1.getArg(mapping, 'source', null);
  40515. if (source !== null) {
  40516. source = this._sources.at(source);
  40517. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  40518. }
  40519. var name = util$1.getArg(mapping, 'name', null);
  40520. if (name !== null) {
  40521. name = this._names.at(name);
  40522. }
  40523. return {
  40524. source: source,
  40525. line: util$1.getArg(mapping, 'originalLine', null),
  40526. column: util$1.getArg(mapping, 'originalColumn', null),
  40527. name: name
  40528. };
  40529. }
  40530. }
  40531. return {
  40532. source: null,
  40533. line: null,
  40534. column: null,
  40535. name: null
  40536. };
  40537. };
  40538. /**
  40539. * Return true if we have the source content for every source in the source
  40540. * map, false otherwise.
  40541. */
  40542. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  40543. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  40544. if (!this.sourcesContent) {
  40545. return false;
  40546. }
  40547. return this.sourcesContent.length >= this._sources.size() &&
  40548. !this.sourcesContent.some(function (sc) { return sc == null; });
  40549. };
  40550. /**
  40551. * Returns the original source content. The only argument is the url of the
  40552. * original source file. Returns null if no original source content is
  40553. * available.
  40554. */
  40555. BasicSourceMapConsumer.prototype.sourceContentFor =
  40556. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40557. if (!this.sourcesContent) {
  40558. return null;
  40559. }
  40560. var index = this._findSourceIndex(aSource);
  40561. if (index >= 0) {
  40562. return this.sourcesContent[index];
  40563. }
  40564. var relativeSource = aSource;
  40565. if (this.sourceRoot != null) {
  40566. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40567. }
  40568. var url;
  40569. if (this.sourceRoot != null
  40570. && (url = util$1.urlParse(this.sourceRoot))) {
  40571. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  40572. // many users. We can help them out when they expect file:// URIs to
  40573. // behave like it would if they were running a local HTTP server. See
  40574. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  40575. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  40576. if (url.scheme == "file"
  40577. && this._sources.has(fileUriAbsPath)) {
  40578. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  40579. }
  40580. if ((!url.path || url.path == "/")
  40581. && this._sources.has("/" + relativeSource)) {
  40582. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  40583. }
  40584. }
  40585. // This function is used recursively from
  40586. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  40587. // don't want to throw if we can't find the source - we just want to
  40588. // return null, so we provide a flag to exit gracefully.
  40589. if (nullOnMissing) {
  40590. return null;
  40591. }
  40592. else {
  40593. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  40594. }
  40595. };
  40596. /**
  40597. * Returns the generated line and column information for the original source,
  40598. * line, and column positions provided. The only argument is an object with
  40599. * the following properties:
  40600. *
  40601. * - source: The filename of the original source.
  40602. * - line: The line number in the original source. The line number
  40603. * is 1-based.
  40604. * - column: The column number in the original source. The column
  40605. * number is 0-based.
  40606. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40607. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40608. * closest element that is smaller than or greater than the one we are
  40609. * searching for, respectively, if the exact element cannot be found.
  40610. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40611. *
  40612. * and an object is returned with the following properties:
  40613. *
  40614. * - line: The line number in the generated source, or null. The
  40615. * line number is 1-based.
  40616. * - column: The column number in the generated source, or null.
  40617. * The column number is 0-based.
  40618. */
  40619. BasicSourceMapConsumer.prototype.generatedPositionFor =
  40620. function SourceMapConsumer_generatedPositionFor(aArgs) {
  40621. var source = util$1.getArg(aArgs, 'source');
  40622. source = this._findSourceIndex(source);
  40623. if (source < 0) {
  40624. return {
  40625. line: null,
  40626. column: null,
  40627. lastColumn: null
  40628. };
  40629. }
  40630. var needle = {
  40631. source: source,
  40632. originalLine: util$1.getArg(aArgs, 'line'),
  40633. originalColumn: util$1.getArg(aArgs, 'column')
  40634. };
  40635. var index = this._findMapping(
  40636. needle,
  40637. this._originalMappings,
  40638. "originalLine",
  40639. "originalColumn",
  40640. util$1.compareByOriginalPositions,
  40641. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40642. );
  40643. if (index >= 0) {
  40644. var mapping = this._originalMappings[index];
  40645. if (mapping.source === needle.source) {
  40646. return {
  40647. line: util$1.getArg(mapping, 'generatedLine', null),
  40648. column: util$1.getArg(mapping, 'generatedColumn', null),
  40649. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40650. };
  40651. }
  40652. }
  40653. return {
  40654. line: null,
  40655. column: null,
  40656. lastColumn: null
  40657. };
  40658. };
  40659. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  40660. /**
  40661. * An IndexedSourceMapConsumer instance represents a parsed source map which
  40662. * we can query for information. It differs from BasicSourceMapConsumer in
  40663. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  40664. * input.
  40665. *
  40666. * The first parameter is a raw source map (either as a JSON string, or already
  40667. * parsed to an object). According to the spec for indexed source maps, they
  40668. * have the following attributes:
  40669. *
  40670. * - version: Which version of the source map spec this map is following.
  40671. * - file: Optional. The generated file this source map is associated with.
  40672. * - sections: A list of section definitions.
  40673. *
  40674. * Each value under the "sections" field has two fields:
  40675. * - offset: The offset into the original specified at which this section
  40676. * begins to apply, defined as an object with a "line" and "column"
  40677. * field.
  40678. * - map: A source map definition. This source map could also be indexed,
  40679. * but doesn't have to be.
  40680. *
  40681. * Instead of the "map" field, it's also possible to have a "url" field
  40682. * specifying a URL to retrieve a source map from, but that's currently
  40683. * unsupported.
  40684. *
  40685. * Here's an example source map, taken from the source map spec[0], but
  40686. * modified to omit a section which uses the "url" field.
  40687. *
  40688. * {
  40689. * version : 3,
  40690. * file: "app.js",
  40691. * sections: [{
  40692. * offset: {line:100, column:10},
  40693. * map: {
  40694. * version : 3,
  40695. * file: "section.js",
  40696. * sources: ["foo.js", "bar.js"],
  40697. * names: ["src", "maps", "are", "fun"],
  40698. * mappings: "AAAA,E;;ABCDE;"
  40699. * }
  40700. * }],
  40701. * }
  40702. *
  40703. * The second parameter, if given, is a string whose value is the URL
  40704. * at which the source map was found. This URL is used to compute the
  40705. * sources array.
  40706. *
  40707. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  40708. */
  40709. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40710. var sourceMap = aSourceMap;
  40711. if (typeof aSourceMap === 'string') {
  40712. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40713. }
  40714. var version = util$1.getArg(sourceMap, 'version');
  40715. var sections = util$1.getArg(sourceMap, 'sections');
  40716. if (version != this._version) {
  40717. throw new Error('Unsupported version: ' + version);
  40718. }
  40719. this._sources = new ArraySet();
  40720. this._names = new ArraySet();
  40721. var lastOffset = {
  40722. line: -1,
  40723. column: 0
  40724. };
  40725. this._sections = sections.map(function (s) {
  40726. if (s.url) {
  40727. // The url field will require support for asynchronicity.
  40728. // See https://github.com/mozilla/source-map/issues/16
  40729. throw new Error('Support for url field in sections not implemented.');
  40730. }
  40731. var offset = util$1.getArg(s, 'offset');
  40732. var offsetLine = util$1.getArg(offset, 'line');
  40733. var offsetColumn = util$1.getArg(offset, 'column');
  40734. if (offsetLine < lastOffset.line ||
  40735. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  40736. throw new Error('Section offsets must be ordered and non-overlapping.');
  40737. }
  40738. lastOffset = offset;
  40739. return {
  40740. generatedOffset: {
  40741. // The offset fields are 0-based, but we use 1-based indices when
  40742. // encoding/decoding from VLQ.
  40743. generatedLine: offsetLine + 1,
  40744. generatedColumn: offsetColumn + 1
  40745. },
  40746. consumer: new SourceMapConsumer$1(util$1.getArg(s, 'map'), aSourceMapURL)
  40747. }
  40748. });
  40749. }
  40750. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40751. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer$1;
  40752. /**
  40753. * The version of the source mapping spec that we are consuming.
  40754. */
  40755. IndexedSourceMapConsumer.prototype._version = 3;
  40756. /**
  40757. * The list of original sources.
  40758. */
  40759. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  40760. get: function () {
  40761. var sources = [];
  40762. for (var i = 0; i < this._sections.length; i++) {
  40763. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  40764. sources.push(this._sections[i].consumer.sources[j]);
  40765. }
  40766. }
  40767. return sources;
  40768. }
  40769. });
  40770. /**
  40771. * Returns the original source, line, and column information for the generated
  40772. * source's line and column positions provided. The only argument is an object
  40773. * with the following properties:
  40774. *
  40775. * - line: The line number in the generated source. The line number
  40776. * is 1-based.
  40777. * - column: The column number in the generated source. The column
  40778. * number is 0-based.
  40779. *
  40780. * and an object is returned with the following properties:
  40781. *
  40782. * - source: The original source file, or null.
  40783. * - line: The line number in the original source, or null. The
  40784. * line number is 1-based.
  40785. * - column: The column number in the original source, or null. The
  40786. * column number is 0-based.
  40787. * - name: The original identifier, or null.
  40788. */
  40789. IndexedSourceMapConsumer.prototype.originalPositionFor =
  40790. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  40791. var needle = {
  40792. generatedLine: util$1.getArg(aArgs, 'line'),
  40793. generatedColumn: util$1.getArg(aArgs, 'column')
  40794. };
  40795. // Find the section containing the generated position we're trying to map
  40796. // to an original position.
  40797. var sectionIndex = binarySearch.search(needle, this._sections,
  40798. function(needle, section) {
  40799. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  40800. if (cmp) {
  40801. return cmp;
  40802. }
  40803. return (needle.generatedColumn -
  40804. section.generatedOffset.generatedColumn);
  40805. });
  40806. var section = this._sections[sectionIndex];
  40807. if (!section) {
  40808. return {
  40809. source: null,
  40810. line: null,
  40811. column: null,
  40812. name: null
  40813. };
  40814. }
  40815. return section.consumer.originalPositionFor({
  40816. line: needle.generatedLine -
  40817. (section.generatedOffset.generatedLine - 1),
  40818. column: needle.generatedColumn -
  40819. (section.generatedOffset.generatedLine === needle.generatedLine
  40820. ? section.generatedOffset.generatedColumn - 1
  40821. : 0),
  40822. bias: aArgs.bias
  40823. });
  40824. };
  40825. /**
  40826. * Return true if we have the source content for every source in the source
  40827. * map, false otherwise.
  40828. */
  40829. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  40830. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  40831. return this._sections.every(function (s) {
  40832. return s.consumer.hasContentsOfAllSources();
  40833. });
  40834. };
  40835. /**
  40836. * Returns the original source content. The only argument is the url of the
  40837. * original source file. Returns null if no original source content is
  40838. * available.
  40839. */
  40840. IndexedSourceMapConsumer.prototype.sourceContentFor =
  40841. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40842. for (var i = 0; i < this._sections.length; i++) {
  40843. var section = this._sections[i];
  40844. var content = section.consumer.sourceContentFor(aSource, true);
  40845. if (content) {
  40846. return content;
  40847. }
  40848. }
  40849. if (nullOnMissing) {
  40850. return null;
  40851. }
  40852. else {
  40853. throw new Error('"' + aSource + '" is not in the SourceMap.');
  40854. }
  40855. };
  40856. /**
  40857. * Returns the generated line and column information for the original source,
  40858. * line, and column positions provided. The only argument is an object with
  40859. * the following properties:
  40860. *
  40861. * - source: The filename of the original source.
  40862. * - line: The line number in the original source. The line number
  40863. * is 1-based.
  40864. * - column: The column number in the original source. The column
  40865. * number is 0-based.
  40866. *
  40867. * and an object is returned with the following properties:
  40868. *
  40869. * - line: The line number in the generated source, or null. The
  40870. * line number is 1-based.
  40871. * - column: The column number in the generated source, or null.
  40872. * The column number is 0-based.
  40873. */
  40874. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  40875. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  40876. for (var i = 0; i < this._sections.length; i++) {
  40877. var section = this._sections[i];
  40878. // Only consider this section if the requested source is in the list of
  40879. // sources of the consumer.
  40880. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
  40881. continue;
  40882. }
  40883. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  40884. if (generatedPosition) {
  40885. var ret = {
  40886. line: generatedPosition.line +
  40887. (section.generatedOffset.generatedLine - 1),
  40888. column: generatedPosition.column +
  40889. (section.generatedOffset.generatedLine === generatedPosition.line
  40890. ? section.generatedOffset.generatedColumn - 1
  40891. : 0)
  40892. };
  40893. return ret;
  40894. }
  40895. }
  40896. return {
  40897. line: null,
  40898. column: null
  40899. };
  40900. };
  40901. /**
  40902. * Parse the mappings in a string in to a data structure which we can easily
  40903. * query (the ordered arrays in the `this.__generatedMappings` and
  40904. * `this.__originalMappings` properties).
  40905. */
  40906. IndexedSourceMapConsumer.prototype._parseMappings =
  40907. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40908. this.__generatedMappings = [];
  40909. this.__originalMappings = [];
  40910. for (var i = 0; i < this._sections.length; i++) {
  40911. var section = this._sections[i];
  40912. var sectionMappings = section.consumer._generatedMappings;
  40913. for (var j = 0; j < sectionMappings.length; j++) {
  40914. var mapping = sectionMappings[j];
  40915. var source = section.consumer._sources.at(mapping.source);
  40916. source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  40917. this._sources.add(source);
  40918. source = this._sources.indexOf(source);
  40919. var name = null;
  40920. if (mapping.name) {
  40921. name = section.consumer._names.at(mapping.name);
  40922. this._names.add(name);
  40923. name = this._names.indexOf(name);
  40924. }
  40925. // The mappings coming from the consumer for the section have
  40926. // generated positions relative to the start of the section, so we
  40927. // need to offset them to be relative to the start of the concatenated
  40928. // generated file.
  40929. var adjustedMapping = {
  40930. source: source,
  40931. generatedLine: mapping.generatedLine +
  40932. (section.generatedOffset.generatedLine - 1),
  40933. generatedColumn: mapping.generatedColumn +
  40934. (section.generatedOffset.generatedLine === mapping.generatedLine
  40935. ? section.generatedOffset.generatedColumn - 1
  40936. : 0),
  40937. originalLine: mapping.originalLine,
  40938. originalColumn: mapping.originalColumn,
  40939. name: name
  40940. };
  40941. this.__generatedMappings.push(adjustedMapping);
  40942. if (typeof adjustedMapping.originalLine === 'number') {
  40943. this.__originalMappings.push(adjustedMapping);
  40944. }
  40945. }
  40946. }
  40947. quickSort(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40948. quickSort(this.__originalMappings, util$1.compareByOriginalPositions);
  40949. };
  40950. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  40951. var sourceNode = {};
  40952. /* -*- Mode: js; js-indent-level: 2; -*- */
  40953. /*
  40954. * Copyright 2011 Mozilla Foundation and contributors
  40955. * Licensed under the New BSD license. See LICENSE or:
  40956. * http://opensource.org/licenses/BSD-3-Clause
  40957. */
  40958. var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator;
  40959. var util = util$5;
  40960. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  40961. // operating systems these days (capturing the result).
  40962. var REGEX_NEWLINE = /(\r?\n)/;
  40963. // Newline character code for charCodeAt() comparisons
  40964. var NEWLINE_CODE = 10;
  40965. // Private symbol for identifying `SourceNode`s when multiple versions of
  40966. // the source-map library are loaded. This MUST NOT CHANGE across
  40967. // versions!
  40968. var isSourceNode = "$$$isSourceNode$$$";
  40969. /**
  40970. * SourceNodes provide a way to abstract over interpolating/concatenating
  40971. * snippets of generated JavaScript source code while maintaining the line and
  40972. * column information associated with the original source code.
  40973. *
  40974. * @param aLine The original line number.
  40975. * @param aColumn The original column number.
  40976. * @param aSource The original source's filename.
  40977. * @param aChunks Optional. An array of strings which are snippets of
  40978. * generated JS, or other SourceNodes.
  40979. * @param aName The original identifier.
  40980. */
  40981. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  40982. this.children = [];
  40983. this.sourceContents = {};
  40984. this.line = aLine == null ? null : aLine;
  40985. this.column = aColumn == null ? null : aColumn;
  40986. this.source = aSource == null ? null : aSource;
  40987. this.name = aName == null ? null : aName;
  40988. this[isSourceNode] = true;
  40989. if (aChunks != null) this.add(aChunks);
  40990. }
  40991. /**
  40992. * Creates a SourceNode from generated code and a SourceMapConsumer.
  40993. *
  40994. * @param aGeneratedCode The generated code
  40995. * @param aSourceMapConsumer The SourceMap for the generated code
  40996. * @param aRelativePath Optional. The path that relative sources in the
  40997. * SourceMapConsumer should be relative to.
  40998. */
  40999. SourceNode.fromStringWithSourceMap =
  41000. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  41001. // The SourceNode we want to fill with the generated code
  41002. // and the SourceMap
  41003. var node = new SourceNode();
  41004. // All even indices of this array are one line of the generated code,
  41005. // while all odd indices are the newlines between two adjacent lines
  41006. // (since `REGEX_NEWLINE` captures its match).
  41007. // Processed fragments are accessed by calling `shiftNextLine`.
  41008. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  41009. var remainingLinesIndex = 0;
  41010. var shiftNextLine = function() {
  41011. var lineContents = getNextLine();
  41012. // The last line of a file might not have a newline.
  41013. var newLine = getNextLine() || "";
  41014. return lineContents + newLine;
  41015. function getNextLine() {
  41016. return remainingLinesIndex < remainingLines.length ?
  41017. remainingLines[remainingLinesIndex++] : undefined;
  41018. }
  41019. };
  41020. // We need to remember the position of "remainingLines"
  41021. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  41022. // The generate SourceNodes we need a code range.
  41023. // To extract it current and last mapping is used.
  41024. // Here we store the last mapping.
  41025. var lastMapping = null;
  41026. aSourceMapConsumer.eachMapping(function (mapping) {
  41027. if (lastMapping !== null) {
  41028. // We add the code from "lastMapping" to "mapping":
  41029. // First check if there is a new line in between.
  41030. if (lastGeneratedLine < mapping.generatedLine) {
  41031. // Associate first line with "lastMapping"
  41032. addMappingWithCode(lastMapping, shiftNextLine());
  41033. lastGeneratedLine++;
  41034. lastGeneratedColumn = 0;
  41035. // The remaining code is added without mapping
  41036. } else {
  41037. // There is no new line in between.
  41038. // Associate the code between "lastGeneratedColumn" and
  41039. // "mapping.generatedColumn" with "lastMapping"
  41040. var nextLine = remainingLines[remainingLinesIndex] || '';
  41041. var code = nextLine.substr(0, mapping.generatedColumn -
  41042. lastGeneratedColumn);
  41043. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  41044. lastGeneratedColumn);
  41045. lastGeneratedColumn = mapping.generatedColumn;
  41046. addMappingWithCode(lastMapping, code);
  41047. // No more remaining code, continue
  41048. lastMapping = mapping;
  41049. return;
  41050. }
  41051. }
  41052. // We add the generated code until the first mapping
  41053. // to the SourceNode without any mapping.
  41054. // Each line is added as separate string.
  41055. while (lastGeneratedLine < mapping.generatedLine) {
  41056. node.add(shiftNextLine());
  41057. lastGeneratedLine++;
  41058. }
  41059. if (lastGeneratedColumn < mapping.generatedColumn) {
  41060. var nextLine = remainingLines[remainingLinesIndex] || '';
  41061. node.add(nextLine.substr(0, mapping.generatedColumn));
  41062. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  41063. lastGeneratedColumn = mapping.generatedColumn;
  41064. }
  41065. lastMapping = mapping;
  41066. }, this);
  41067. // We have processed all mappings.
  41068. if (remainingLinesIndex < remainingLines.length) {
  41069. if (lastMapping) {
  41070. // Associate the remaining code in the current line with "lastMapping"
  41071. addMappingWithCode(lastMapping, shiftNextLine());
  41072. }
  41073. // and add the remaining lines without any mapping
  41074. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  41075. }
  41076. // Copy sourcesContent into SourceNode
  41077. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  41078. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  41079. if (content != null) {
  41080. if (aRelativePath != null) {
  41081. sourceFile = util.join(aRelativePath, sourceFile);
  41082. }
  41083. node.setSourceContent(sourceFile, content);
  41084. }
  41085. });
  41086. return node;
  41087. function addMappingWithCode(mapping, code) {
  41088. if (mapping === null || mapping.source === undefined) {
  41089. node.add(code);
  41090. } else {
  41091. var source = aRelativePath
  41092. ? util.join(aRelativePath, mapping.source)
  41093. : mapping.source;
  41094. node.add(new SourceNode(mapping.originalLine,
  41095. mapping.originalColumn,
  41096. source,
  41097. code,
  41098. mapping.name));
  41099. }
  41100. }
  41101. };
  41102. /**
  41103. * Add a chunk of generated JS to this source node.
  41104. *
  41105. * @param aChunk A string snippet of generated JS code, another instance of
  41106. * SourceNode, or an array where each member is one of those things.
  41107. */
  41108. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  41109. if (Array.isArray(aChunk)) {
  41110. aChunk.forEach(function (chunk) {
  41111. this.add(chunk);
  41112. }, this);
  41113. }
  41114. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41115. if (aChunk) {
  41116. this.children.push(aChunk);
  41117. }
  41118. }
  41119. else {
  41120. throw new TypeError(
  41121. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41122. );
  41123. }
  41124. return this;
  41125. };
  41126. /**
  41127. * Add a chunk of generated JS to the beginning of this source node.
  41128. *
  41129. * @param aChunk A string snippet of generated JS code, another instance of
  41130. * SourceNode, or an array where each member is one of those things.
  41131. */
  41132. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  41133. if (Array.isArray(aChunk)) {
  41134. for (var i = aChunk.length-1; i >= 0; i--) {
  41135. this.prepend(aChunk[i]);
  41136. }
  41137. }
  41138. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41139. this.children.unshift(aChunk);
  41140. }
  41141. else {
  41142. throw new TypeError(
  41143. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41144. );
  41145. }
  41146. return this;
  41147. };
  41148. /**
  41149. * Walk over the tree of JS snippets in this node and its children. The
  41150. * walking function is called once for each snippet of JS and is passed that
  41151. * snippet and the its original associated source's line/column location.
  41152. *
  41153. * @param aFn The traversal function.
  41154. */
  41155. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  41156. var chunk;
  41157. for (var i = 0, len = this.children.length; i < len; i++) {
  41158. chunk = this.children[i];
  41159. if (chunk[isSourceNode]) {
  41160. chunk.walk(aFn);
  41161. }
  41162. else {
  41163. if (chunk !== '') {
  41164. aFn(chunk, { source: this.source,
  41165. line: this.line,
  41166. column: this.column,
  41167. name: this.name });
  41168. }
  41169. }
  41170. }
  41171. };
  41172. /**
  41173. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  41174. * each of `this.children`.
  41175. *
  41176. * @param aSep The separator.
  41177. */
  41178. SourceNode.prototype.join = function SourceNode_join(aSep) {
  41179. var newChildren;
  41180. var i;
  41181. var len = this.children.length;
  41182. if (len > 0) {
  41183. newChildren = [];
  41184. for (i = 0; i < len-1; i++) {
  41185. newChildren.push(this.children[i]);
  41186. newChildren.push(aSep);
  41187. }
  41188. newChildren.push(this.children[i]);
  41189. this.children = newChildren;
  41190. }
  41191. return this;
  41192. };
  41193. /**
  41194. * Call String.prototype.replace on the very right-most source snippet. Useful
  41195. * for trimming whitespace from the end of a source node, etc.
  41196. *
  41197. * @param aPattern The pattern to replace.
  41198. * @param aReplacement The thing to replace the pattern with.
  41199. */
  41200. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  41201. var lastChild = this.children[this.children.length - 1];
  41202. if (lastChild[isSourceNode]) {
  41203. lastChild.replaceRight(aPattern, aReplacement);
  41204. }
  41205. else if (typeof lastChild === 'string') {
  41206. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  41207. }
  41208. else {
  41209. this.children.push(''.replace(aPattern, aReplacement));
  41210. }
  41211. return this;
  41212. };
  41213. /**
  41214. * Set the source content for a source file. This will be added to the SourceMapGenerator
  41215. * in the sourcesContent field.
  41216. *
  41217. * @param aSourceFile The filename of the source file
  41218. * @param aSourceContent The content of the source file
  41219. */
  41220. SourceNode.prototype.setSourceContent =
  41221. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  41222. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  41223. };
  41224. /**
  41225. * Walk over the tree of SourceNodes. The walking function is called for each
  41226. * source file content and is passed the filename and source content.
  41227. *
  41228. * @param aFn The traversal function.
  41229. */
  41230. SourceNode.prototype.walkSourceContents =
  41231. function SourceNode_walkSourceContents(aFn) {
  41232. for (var i = 0, len = this.children.length; i < len; i++) {
  41233. if (this.children[i][isSourceNode]) {
  41234. this.children[i].walkSourceContents(aFn);
  41235. }
  41236. }
  41237. var sources = Object.keys(this.sourceContents);
  41238. for (var i = 0, len = sources.length; i < len; i++) {
  41239. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  41240. }
  41241. };
  41242. /**
  41243. * Return the string representation of this source node. Walks over the tree
  41244. * and concatenates all the various snippets together to one string.
  41245. */
  41246. SourceNode.prototype.toString = function SourceNode_toString() {
  41247. var str = "";
  41248. this.walk(function (chunk) {
  41249. str += chunk;
  41250. });
  41251. return str;
  41252. };
  41253. /**
  41254. * Returns the string representation of this source node along with a source
  41255. * map.
  41256. */
  41257. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  41258. var generated = {
  41259. code: "",
  41260. line: 1,
  41261. column: 0
  41262. };
  41263. var map = new SourceMapGenerator$1(aArgs);
  41264. var sourceMappingActive = false;
  41265. var lastOriginalSource = null;
  41266. var lastOriginalLine = null;
  41267. var lastOriginalColumn = null;
  41268. var lastOriginalName = null;
  41269. this.walk(function (chunk, original) {
  41270. generated.code += chunk;
  41271. if (original.source !== null
  41272. && original.line !== null
  41273. && original.column !== null) {
  41274. if(lastOriginalSource !== original.source
  41275. || lastOriginalLine !== original.line
  41276. || lastOriginalColumn !== original.column
  41277. || lastOriginalName !== original.name) {
  41278. map.addMapping({
  41279. source: original.source,
  41280. original: {
  41281. line: original.line,
  41282. column: original.column
  41283. },
  41284. generated: {
  41285. line: generated.line,
  41286. column: generated.column
  41287. },
  41288. name: original.name
  41289. });
  41290. }
  41291. lastOriginalSource = original.source;
  41292. lastOriginalLine = original.line;
  41293. lastOriginalColumn = original.column;
  41294. lastOriginalName = original.name;
  41295. sourceMappingActive = true;
  41296. } else if (sourceMappingActive) {
  41297. map.addMapping({
  41298. generated: {
  41299. line: generated.line,
  41300. column: generated.column
  41301. }
  41302. });
  41303. lastOriginalSource = null;
  41304. sourceMappingActive = false;
  41305. }
  41306. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  41307. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  41308. generated.line++;
  41309. generated.column = 0;
  41310. // Mappings end at eol
  41311. if (idx + 1 === length) {
  41312. lastOriginalSource = null;
  41313. sourceMappingActive = false;
  41314. } else if (sourceMappingActive) {
  41315. map.addMapping({
  41316. source: original.source,
  41317. original: {
  41318. line: original.line,
  41319. column: original.column
  41320. },
  41321. generated: {
  41322. line: generated.line,
  41323. column: generated.column
  41324. },
  41325. name: original.name
  41326. });
  41327. }
  41328. } else {
  41329. generated.column++;
  41330. }
  41331. }
  41332. });
  41333. this.walkSourceContents(function (sourceFile, sourceContent) {
  41334. map.setSourceContent(sourceFile, sourceContent);
  41335. });
  41336. return { code: generated.code, map: map };
  41337. };
  41338. sourceNode.SourceNode = SourceNode;
  41339. /*
  41340. * Copyright 2009-2011 Mozilla Foundation and contributors
  41341. * Licensed under the New BSD license. See LICENSE.txt or:
  41342. * http://opensource.org/licenses/BSD-3-Clause
  41343. */
  41344. sourceMap$1.SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  41345. sourceMap$1.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  41346. sourceMap$1.SourceNode = sourceNode.SourceNode;
  41347. var sourceMap = sourceMap$1;
  41348. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  41349. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  41350. var mergeSourceMap = merge;
  41351. /**
  41352. * Merge old source map and new source map and return merged.
  41353. * If old or new source map value is falsy, return another one as it is.
  41354. *
  41355. * @param {object|string} [oldMap] old source map object
  41356. * @param {object|string} [newmap] new source map object
  41357. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  41358. */
  41359. function merge(oldMap, newMap) {
  41360. if (!oldMap) return newMap
  41361. if (!newMap) return oldMap
  41362. var oldMapConsumer = new SourceMapConsumer(oldMap);
  41363. var newMapConsumer = new SourceMapConsumer(newMap);
  41364. var mergedMapGenerator = new SourceMapGenerator();
  41365. // iterate on new map and overwrite original position of new map with one of old map
  41366. newMapConsumer.eachMapping(function(m) {
  41367. // pass when `originalLine` is null.
  41368. // It occurs in case that the node does not have origin in original code.
  41369. if (m.originalLine == null) return
  41370. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  41371. line: m.originalLine,
  41372. column: m.originalColumn
  41373. });
  41374. if (origPosInOldMap.source == null) return
  41375. mergedMapGenerator.addMapping({
  41376. original: {
  41377. line: origPosInOldMap.line,
  41378. column: origPosInOldMap.column
  41379. },
  41380. generated: {
  41381. line: m.generatedLine,
  41382. column: m.generatedColumn
  41383. },
  41384. source: origPosInOldMap.source,
  41385. name: origPosInOldMap.name
  41386. });
  41387. });
  41388. var consumers = [oldMapConsumer, newMapConsumer];
  41389. consumers.forEach(function(consumer) {
  41390. consumer.sources.forEach(function(sourceFile) {
  41391. mergedMapGenerator._sources.add(sourceFile);
  41392. var sourceContent = consumer.sourceContentFor(sourceFile);
  41393. if (sourceContent != null) {
  41394. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  41395. }
  41396. });
  41397. });
  41398. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  41399. mergedMapGenerator._file = oldMap.file;
  41400. return JSON.parse(mergedMapGenerator.toString())
  41401. }
  41402. var merge$1 = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMap);
  41403. var __defProp$5 = Object.defineProperty;
  41404. var __defProps$4 = Object.defineProperties;
  41405. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  41406. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  41407. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  41408. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  41409. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41410. var __spreadValues$5 = (a, b) => {
  41411. for (var prop in b || (b = {}))
  41412. if (__hasOwnProp$5.call(b, prop))
  41413. __defNormalProp$5(a, prop, b[prop]);
  41414. if (__getOwnPropSymbols$5)
  41415. for (var prop of __getOwnPropSymbols$5(b)) {
  41416. if (__propIsEnum$5.call(b, prop))
  41417. __defNormalProp$5(a, prop, b[prop]);
  41418. }
  41419. return a;
  41420. };
  41421. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  41422. const scss = (source, map, options, load = require) => {
  41423. const nodeSass = load("sass");
  41424. const finalOptions = __spreadProps$4(__spreadValues$5({}, options), {
  41425. data: getSource(source, options.filename, options.additionalData),
  41426. file: options.filename,
  41427. outFile: options.filename,
  41428. sourceMap: !!map
  41429. });
  41430. try {
  41431. const result = nodeSass.renderSync(finalOptions);
  41432. const dependencies = result.stats.includedFiles;
  41433. if (map) {
  41434. return {
  41435. code: result.css.toString(),
  41436. map: merge$1(map, JSON.parse(result.map.toString())),
  41437. errors: [],
  41438. dependencies
  41439. };
  41440. }
  41441. return { code: result.css.toString(), errors: [], dependencies };
  41442. } catch (e) {
  41443. return { code: "", errors: [e], dependencies: [] };
  41444. }
  41445. };
  41446. const sass = (source, map, options, load) => scss(
  41447. source,
  41448. map,
  41449. __spreadProps$4(__spreadValues$5({}, options), {
  41450. indentedSyntax: true
  41451. }),
  41452. load
  41453. );
  41454. const less = (source, map, options, load = require) => {
  41455. const nodeLess = load("less");
  41456. let result;
  41457. let error = null;
  41458. nodeLess.render(
  41459. getSource(source, options.filename, options.additionalData),
  41460. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  41461. (err, output) => {
  41462. error = err;
  41463. result = output;
  41464. }
  41465. );
  41466. if (error)
  41467. return { code: "", errors: [error], dependencies: [] };
  41468. const dependencies = result.imports;
  41469. if (map) {
  41470. return {
  41471. code: result.css.toString(),
  41472. map: merge$1(map, result.map),
  41473. errors: [],
  41474. dependencies
  41475. };
  41476. }
  41477. return {
  41478. code: result.css.toString(),
  41479. errors: [],
  41480. dependencies
  41481. };
  41482. };
  41483. const styl = (source, map, options, load = require) => {
  41484. const nodeStylus = load("stylus");
  41485. try {
  41486. const ref = nodeStylus(source, options);
  41487. if (map)
  41488. ref.set("sourcemap", { inline: false, comment: false });
  41489. const result = ref.render();
  41490. const dependencies = ref.deps();
  41491. if (map) {
  41492. return {
  41493. code: result,
  41494. map: merge$1(map, ref.sourcemap),
  41495. errors: [],
  41496. dependencies
  41497. };
  41498. }
  41499. return { code: result, errors: [], dependencies };
  41500. } catch (e) {
  41501. return { code: "", errors: [e], dependencies: [] };
  41502. }
  41503. };
  41504. function getSource(source, filename, additionalData) {
  41505. if (!additionalData)
  41506. return source;
  41507. if (isFunction$1(additionalData)) {
  41508. return additionalData(source, filename);
  41509. }
  41510. return additionalData + source;
  41511. }
  41512. const processors = {
  41513. less,
  41514. sass,
  41515. scss,
  41516. styl,
  41517. stylus: styl
  41518. };
  41519. var __defProp$4 = Object.defineProperty;
  41520. var __defProps$3 = Object.defineProperties;
  41521. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  41522. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  41523. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  41524. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  41525. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41526. var __spreadValues$4 = (a, b) => {
  41527. for (var prop in b || (b = {}))
  41528. if (__hasOwnProp$4.call(b, prop))
  41529. __defNormalProp$4(a, prop, b[prop]);
  41530. if (__getOwnPropSymbols$4)
  41531. for (var prop of __getOwnPropSymbols$4(b)) {
  41532. if (__propIsEnum$4.call(b, prop))
  41533. __defNormalProp$4(a, prop, b[prop]);
  41534. }
  41535. return a;
  41536. };
  41537. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  41538. function compileStyle(options) {
  41539. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41540. isAsync: false
  41541. }));
  41542. }
  41543. function compileStyleAsync(options) {
  41544. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41545. isAsync: true
  41546. }));
  41547. }
  41548. function doCompileStyle(options) {
  41549. const {
  41550. filename,
  41551. id,
  41552. scoped = false,
  41553. trim = true,
  41554. isProd = false,
  41555. modules = false,
  41556. modulesOptions = {},
  41557. preprocessLang,
  41558. postcssOptions,
  41559. postcssPlugins
  41560. } = options;
  41561. const preprocessor = preprocessLang && processors[preprocessLang];
  41562. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  41563. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  41564. const source = preProcessedSource ? preProcessedSource.code : options.source;
  41565. const shortId = id.replace(/^data-v-/, "");
  41566. const longId = `data-v-${shortId}`;
  41567. const plugins = (postcssPlugins || []).slice();
  41568. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  41569. if (trim) {
  41570. plugins.push(trimPlugin());
  41571. }
  41572. if (scoped) {
  41573. plugins.push(scopedPlugin(longId));
  41574. }
  41575. let cssModules;
  41576. if (modules) {
  41577. {
  41578. throw new Error(
  41579. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  41580. );
  41581. }
  41582. }
  41583. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  41584. to: filename,
  41585. from: filename
  41586. });
  41587. if (map) {
  41588. postCSSOptions.map = {
  41589. inline: false,
  41590. annotation: false,
  41591. prev: map
  41592. };
  41593. }
  41594. let result;
  41595. let code;
  41596. let outMap;
  41597. const dependencies = new Set(
  41598. preProcessedSource ? preProcessedSource.dependencies : []
  41599. );
  41600. dependencies.delete(filename);
  41601. const errors = [];
  41602. if (preProcessedSource && preProcessedSource.errors.length) {
  41603. errors.push(...preProcessedSource.errors);
  41604. }
  41605. const recordPlainCssDependencies = (messages) => {
  41606. messages.forEach((msg) => {
  41607. if (msg.type === "dependency") {
  41608. dependencies.add(msg.file);
  41609. }
  41610. });
  41611. return dependencies;
  41612. };
  41613. try {
  41614. result = postcss$1(plugins).process(source, postCSSOptions);
  41615. if (options.isAsync) {
  41616. return result.then((result2) => ({
  41617. code: result2.css || "",
  41618. map: result2.map && result2.map.toJSON(),
  41619. errors,
  41620. modules: cssModules,
  41621. rawResult: result2,
  41622. dependencies: recordPlainCssDependencies(result2.messages)
  41623. })).catch((error) => ({
  41624. code: "",
  41625. map: void 0,
  41626. errors: [...errors, error],
  41627. rawResult: void 0,
  41628. dependencies
  41629. }));
  41630. }
  41631. recordPlainCssDependencies(result.messages);
  41632. code = result.css;
  41633. outMap = result.map;
  41634. } catch (e) {
  41635. errors.push(e);
  41636. }
  41637. return {
  41638. code: code || ``,
  41639. map: outMap && outMap.toJSON(),
  41640. errors,
  41641. rawResult: result,
  41642. dependencies
  41643. };
  41644. }
  41645. function preprocess(options, preprocessor) {
  41646. if (!options.preprocessCustomRequire) {
  41647. throw new Error(
  41648. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  41649. );
  41650. }
  41651. return preprocessor(
  41652. options.source,
  41653. options.inMap || options.map,
  41654. __spreadValues$4({
  41655. filename: options.filename
  41656. }, options.preprocessOptions),
  41657. options.preprocessCustomRequire
  41658. );
  41659. }
  41660. function analyzeScriptBindings(ast) {
  41661. for (const node of ast) {
  41662. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  41663. return analyzeBindingsFromOptions(node.declaration);
  41664. }
  41665. }
  41666. return {};
  41667. }
  41668. function analyzeBindingsFromOptions(node) {
  41669. const bindings = {};
  41670. Object.defineProperty(bindings, "__isScriptSetup", {
  41671. enumerable: false,
  41672. value: false
  41673. });
  41674. for (const property of node.properties) {
  41675. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  41676. if (property.key.name === "props") {
  41677. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41678. bindings[key] = "props";
  41679. }
  41680. } else if (property.key.name === "inject") {
  41681. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41682. bindings[key] = "options";
  41683. }
  41684. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  41685. for (const key of getObjectExpressionKeys(property.value)) {
  41686. bindings[key] = "options";
  41687. }
  41688. }
  41689. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  41690. for (const bodyItem of property.body.body) {
  41691. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  41692. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  41693. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  41694. }
  41695. }
  41696. }
  41697. }
  41698. }
  41699. return bindings;
  41700. }
  41701. function getObjectExpressionKeys(node) {
  41702. const keys = [];
  41703. for (const prop of node.properties) {
  41704. if (prop.type === "SpreadElement")
  41705. continue;
  41706. const key = resolveObjectKey(prop.key, prop.computed);
  41707. if (key)
  41708. keys.push(String(key));
  41709. }
  41710. return keys;
  41711. }
  41712. function getArrayExpressionKeys(node) {
  41713. const keys = [];
  41714. for (const element of node.elements) {
  41715. if (element && element.type === "StringLiteral") {
  41716. keys.push(element.value);
  41717. }
  41718. }
  41719. return keys;
  41720. }
  41721. function getObjectOrArrayExpressionKeys(value) {
  41722. if (value.type === "ArrayExpression") {
  41723. return getArrayExpressionKeys(value);
  41724. }
  41725. if (value.type === "ObjectExpression") {
  41726. return getObjectExpressionKeys(value);
  41727. }
  41728. return [];
  41729. }
  41730. const comma = ','.charCodeAt(0);
  41731. const semicolon = ';'.charCodeAt(0);
  41732. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  41733. const intToChar = new Uint8Array(64); // 64 possible chars.
  41734. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  41735. for (let i = 0; i < chars.length; i++) {
  41736. const c = chars.charCodeAt(i);
  41737. intToChar[i] = c;
  41738. charToInt[c] = i;
  41739. }
  41740. // Provide a fallback for older environments.
  41741. const td = typeof TextDecoder !== 'undefined'
  41742. ? /* #__PURE__ */ new TextDecoder()
  41743. : typeof Buffer !== 'undefined'
  41744. ? {
  41745. decode(buf) {
  41746. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  41747. return out.toString();
  41748. },
  41749. }
  41750. : {
  41751. decode(buf) {
  41752. let out = '';
  41753. for (let i = 0; i < buf.length; i++) {
  41754. out += String.fromCharCode(buf[i]);
  41755. }
  41756. return out;
  41757. },
  41758. };
  41759. function encode(decoded) {
  41760. const state = new Int32Array(5);
  41761. const bufLength = 1024 * 16;
  41762. const subLength = bufLength - 36;
  41763. const buf = new Uint8Array(bufLength);
  41764. const sub = buf.subarray(0, subLength);
  41765. let pos = 0;
  41766. let out = '';
  41767. for (let i = 0; i < decoded.length; i++) {
  41768. const line = decoded[i];
  41769. if (i > 0) {
  41770. if (pos === bufLength) {
  41771. out += td.decode(buf);
  41772. pos = 0;
  41773. }
  41774. buf[pos++] = semicolon;
  41775. }
  41776. if (line.length === 0)
  41777. continue;
  41778. state[0] = 0;
  41779. for (let j = 0; j < line.length; j++) {
  41780. const segment = line[j];
  41781. // We can push up to 5 ints, each int can take at most 7 chars, and we
  41782. // may push a comma.
  41783. if (pos > subLength) {
  41784. out += td.decode(sub);
  41785. buf.copyWithin(0, subLength, pos);
  41786. pos -= subLength;
  41787. }
  41788. if (j > 0)
  41789. buf[pos++] = comma;
  41790. pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
  41791. if (segment.length === 1)
  41792. continue;
  41793. pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
  41794. pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
  41795. pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
  41796. if (segment.length === 4)
  41797. continue;
  41798. pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
  41799. }
  41800. }
  41801. return out + td.decode(buf.subarray(0, pos));
  41802. }
  41803. function encodeInteger(buf, pos, state, segment, j) {
  41804. const next = segment[j];
  41805. let num = next - state[j];
  41806. state[j] = next;
  41807. num = num < 0 ? (-num << 1) | 1 : num << 1;
  41808. do {
  41809. let clamped = num & 0b011111;
  41810. num >>>= 5;
  41811. if (num > 0)
  41812. clamped |= 0b100000;
  41813. buf[pos++] = intToChar[clamped];
  41814. } while (num > 0);
  41815. return pos;
  41816. }
  41817. class BitSet {
  41818. constructor(arg) {
  41819. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  41820. }
  41821. add(n) {
  41822. this.bits[n >> 5] |= 1 << (n & 31);
  41823. }
  41824. has(n) {
  41825. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  41826. }
  41827. }
  41828. class Chunk {
  41829. constructor(start, end, content) {
  41830. this.start = start;
  41831. this.end = end;
  41832. this.original = content;
  41833. this.intro = '';
  41834. this.outro = '';
  41835. this.content = content;
  41836. this.storeName = false;
  41837. this.edited = false;
  41838. {
  41839. this.previous = null;
  41840. this.next = null;
  41841. }
  41842. }
  41843. appendLeft(content) {
  41844. this.outro += content;
  41845. }
  41846. appendRight(content) {
  41847. this.intro = this.intro + content;
  41848. }
  41849. clone() {
  41850. const chunk = new Chunk(this.start, this.end, this.original);
  41851. chunk.intro = this.intro;
  41852. chunk.outro = this.outro;
  41853. chunk.content = this.content;
  41854. chunk.storeName = this.storeName;
  41855. chunk.edited = this.edited;
  41856. return chunk;
  41857. }
  41858. contains(index) {
  41859. return this.start < index && index < this.end;
  41860. }
  41861. eachNext(fn) {
  41862. let chunk = this;
  41863. while (chunk) {
  41864. fn(chunk);
  41865. chunk = chunk.next;
  41866. }
  41867. }
  41868. eachPrevious(fn) {
  41869. let chunk = this;
  41870. while (chunk) {
  41871. fn(chunk);
  41872. chunk = chunk.previous;
  41873. }
  41874. }
  41875. edit(content, storeName, contentOnly) {
  41876. this.content = content;
  41877. if (!contentOnly) {
  41878. this.intro = '';
  41879. this.outro = '';
  41880. }
  41881. this.storeName = storeName;
  41882. this.edited = true;
  41883. return this;
  41884. }
  41885. prependLeft(content) {
  41886. this.outro = content + this.outro;
  41887. }
  41888. prependRight(content) {
  41889. this.intro = content + this.intro;
  41890. }
  41891. reset() {
  41892. this.intro = '';
  41893. this.outro = '';
  41894. if (this.edited) {
  41895. this.content = this.original;
  41896. this.storeName = false;
  41897. this.edited = false;
  41898. }
  41899. }
  41900. split(index) {
  41901. const sliceIndex = index - this.start;
  41902. const originalBefore = this.original.slice(0, sliceIndex);
  41903. const originalAfter = this.original.slice(sliceIndex);
  41904. this.original = originalBefore;
  41905. const newChunk = new Chunk(index, this.end, originalAfter);
  41906. newChunk.outro = this.outro;
  41907. this.outro = '';
  41908. this.end = index;
  41909. if (this.edited) {
  41910. // after split we should save the edit content record into the correct chunk
  41911. // to make sure sourcemap correct
  41912. // For example:
  41913. // ' test'.trim()
  41914. // split -> ' ' + 'test'
  41915. // ✔️ edit -> '' + 'test'
  41916. // ✖️ edit -> 'test' + ''
  41917. // TODO is this block necessary?...
  41918. newChunk.edit('', false);
  41919. this.content = '';
  41920. } else {
  41921. this.content = originalBefore;
  41922. }
  41923. newChunk.next = this.next;
  41924. if (newChunk.next) newChunk.next.previous = newChunk;
  41925. newChunk.previous = this;
  41926. this.next = newChunk;
  41927. return newChunk;
  41928. }
  41929. toString() {
  41930. return this.intro + this.content + this.outro;
  41931. }
  41932. trimEnd(rx) {
  41933. this.outro = this.outro.replace(rx, '');
  41934. if (this.outro.length) return true;
  41935. const trimmed = this.content.replace(rx, '');
  41936. if (trimmed.length) {
  41937. if (trimmed !== this.content) {
  41938. this.split(this.start + trimmed.length).edit('', undefined, true);
  41939. if (this.edited) {
  41940. // save the change, if it has been edited
  41941. this.edit(trimmed, this.storeName, true);
  41942. }
  41943. }
  41944. return true;
  41945. } else {
  41946. this.edit('', undefined, true);
  41947. this.intro = this.intro.replace(rx, '');
  41948. if (this.intro.length) return true;
  41949. }
  41950. }
  41951. trimStart(rx) {
  41952. this.intro = this.intro.replace(rx, '');
  41953. if (this.intro.length) return true;
  41954. const trimmed = this.content.replace(rx, '');
  41955. if (trimmed.length) {
  41956. if (trimmed !== this.content) {
  41957. const newChunk = this.split(this.end - trimmed.length);
  41958. if (this.edited) {
  41959. // save the change, if it has been edited
  41960. newChunk.edit(trimmed, this.storeName, true);
  41961. }
  41962. this.edit('', undefined, true);
  41963. }
  41964. return true;
  41965. } else {
  41966. this.edit('', undefined, true);
  41967. this.outro = this.outro.replace(rx, '');
  41968. if (this.outro.length) return true;
  41969. }
  41970. }
  41971. }
  41972. function getBtoa() {
  41973. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  41974. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  41975. } else if (typeof Buffer === 'function') {
  41976. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  41977. } else {
  41978. return () => {
  41979. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  41980. };
  41981. }
  41982. }
  41983. const btoa = /*#__PURE__*/ getBtoa();
  41984. class SourceMap {
  41985. constructor(properties) {
  41986. this.version = 3;
  41987. this.file = properties.file;
  41988. this.sources = properties.sources;
  41989. this.sourcesContent = properties.sourcesContent;
  41990. this.names = properties.names;
  41991. this.mappings = encode(properties.mappings);
  41992. if (typeof properties.x_google_ignoreList !== 'undefined') {
  41993. this.x_google_ignoreList = properties.x_google_ignoreList;
  41994. }
  41995. }
  41996. toString() {
  41997. return JSON.stringify(this);
  41998. }
  41999. toUrl() {
  42000. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  42001. }
  42002. }
  42003. function guessIndent(code) {
  42004. const lines = code.split('\n');
  42005. const tabbed = lines.filter((line) => /^\t+/.test(line));
  42006. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  42007. if (tabbed.length === 0 && spaced.length === 0) {
  42008. return null;
  42009. }
  42010. // More lines tabbed than spaced? Assume tabs, and
  42011. // default to tabs in the case of a tie (or nothing
  42012. // to go on)
  42013. if (tabbed.length >= spaced.length) {
  42014. return '\t';
  42015. }
  42016. // Otherwise, we need to guess the multiple
  42017. const min = spaced.reduce((previous, current) => {
  42018. const numSpaces = /^ +/.exec(current)[0].length;
  42019. return Math.min(numSpaces, previous);
  42020. }, Infinity);
  42021. return new Array(min + 1).join(' ');
  42022. }
  42023. function getRelativePath(from, to) {
  42024. const fromParts = from.split(/[/\\]/);
  42025. const toParts = to.split(/[/\\]/);
  42026. fromParts.pop(); // get dirname
  42027. while (fromParts[0] === toParts[0]) {
  42028. fromParts.shift();
  42029. toParts.shift();
  42030. }
  42031. if (fromParts.length) {
  42032. let i = fromParts.length;
  42033. while (i--) fromParts[i] = '..';
  42034. }
  42035. return fromParts.concat(toParts).join('/');
  42036. }
  42037. const toString = Object.prototype.toString;
  42038. function isObject(thing) {
  42039. return toString.call(thing) === '[object Object]';
  42040. }
  42041. function getLocator(source) {
  42042. const originalLines = source.split('\n');
  42043. const lineOffsets = [];
  42044. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  42045. lineOffsets.push(pos);
  42046. pos += originalLines[i].length + 1;
  42047. }
  42048. return function locate(index) {
  42049. let i = 0;
  42050. let j = lineOffsets.length;
  42051. while (i < j) {
  42052. const m = (i + j) >> 1;
  42053. if (index < lineOffsets[m]) {
  42054. j = m;
  42055. } else {
  42056. i = m + 1;
  42057. }
  42058. }
  42059. const line = i - 1;
  42060. const column = index - lineOffsets[line];
  42061. return { line, column };
  42062. };
  42063. }
  42064. const wordRegex = /\w/;
  42065. class Mappings {
  42066. constructor(hires) {
  42067. this.hires = hires;
  42068. this.generatedCodeLine = 0;
  42069. this.generatedCodeColumn = 0;
  42070. this.raw = [];
  42071. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  42072. this.pending = null;
  42073. }
  42074. addEdit(sourceIndex, content, loc, nameIndex) {
  42075. if (content.length) {
  42076. const contentLengthMinusOne = content.length - 1;
  42077. let contentLineEnd = content.indexOf('\n', 0);
  42078. let previousContentLineEnd = -1;
  42079. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  42080. // else code afterwards would fill one line too many
  42081. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  42082. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42083. if (nameIndex >= 0) {
  42084. segment.push(nameIndex);
  42085. }
  42086. this.rawSegments.push(segment);
  42087. this.generatedCodeLine += 1;
  42088. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42089. this.generatedCodeColumn = 0;
  42090. previousContentLineEnd = contentLineEnd;
  42091. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  42092. }
  42093. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42094. if (nameIndex >= 0) {
  42095. segment.push(nameIndex);
  42096. }
  42097. this.rawSegments.push(segment);
  42098. this.advance(content.slice(previousContentLineEnd + 1));
  42099. } else if (this.pending) {
  42100. this.rawSegments.push(this.pending);
  42101. this.advance(content);
  42102. }
  42103. this.pending = null;
  42104. }
  42105. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  42106. let originalCharIndex = chunk.start;
  42107. let first = true;
  42108. // when iterating each char, check if it's in a word boundary
  42109. let charInHiresBoundary = false;
  42110. while (originalCharIndex < chunk.end) {
  42111. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  42112. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42113. if (this.hires === 'boundary') {
  42114. // in hires "boundary", group segments per word boundary than per char
  42115. if (wordRegex.test(original[originalCharIndex])) {
  42116. // for first char in the boundary found, start the boundary by pushing a segment
  42117. if (!charInHiresBoundary) {
  42118. this.rawSegments.push(segment);
  42119. charInHiresBoundary = true;
  42120. }
  42121. } else {
  42122. // for non-word char, end the boundary by pushing a segment
  42123. this.rawSegments.push(segment);
  42124. charInHiresBoundary = false;
  42125. }
  42126. } else {
  42127. this.rawSegments.push(segment);
  42128. }
  42129. }
  42130. if (original[originalCharIndex] === '\n') {
  42131. loc.line += 1;
  42132. loc.column = 0;
  42133. this.generatedCodeLine += 1;
  42134. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42135. this.generatedCodeColumn = 0;
  42136. first = true;
  42137. } else {
  42138. loc.column += 1;
  42139. this.generatedCodeColumn += 1;
  42140. first = false;
  42141. }
  42142. originalCharIndex += 1;
  42143. }
  42144. this.pending = null;
  42145. }
  42146. advance(str) {
  42147. if (!str) return;
  42148. const lines = str.split('\n');
  42149. if (lines.length > 1) {
  42150. for (let i = 0; i < lines.length - 1; i++) {
  42151. this.generatedCodeLine++;
  42152. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42153. }
  42154. this.generatedCodeColumn = 0;
  42155. }
  42156. this.generatedCodeColumn += lines[lines.length - 1].length;
  42157. }
  42158. }
  42159. const n = '\n';
  42160. const warned = {
  42161. insertLeft: false,
  42162. insertRight: false,
  42163. storeName: false,
  42164. };
  42165. class MagicString {
  42166. constructor(string, options = {}) {
  42167. const chunk = new Chunk(0, string.length, string);
  42168. Object.defineProperties(this, {
  42169. original: { writable: true, value: string },
  42170. outro: { writable: true, value: '' },
  42171. intro: { writable: true, value: '' },
  42172. firstChunk: { writable: true, value: chunk },
  42173. lastChunk: { writable: true, value: chunk },
  42174. lastSearchedChunk: { writable: true, value: chunk },
  42175. byStart: { writable: true, value: {} },
  42176. byEnd: { writable: true, value: {} },
  42177. filename: { writable: true, value: options.filename },
  42178. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  42179. sourcemapLocations: { writable: true, value: new BitSet() },
  42180. storedNames: { writable: true, value: {} },
  42181. indentStr: { writable: true, value: undefined },
  42182. ignoreList: { writable: true, value: options.ignoreList },
  42183. });
  42184. this.byStart[0] = chunk;
  42185. this.byEnd[string.length] = chunk;
  42186. }
  42187. addSourcemapLocation(char) {
  42188. this.sourcemapLocations.add(char);
  42189. }
  42190. append(content) {
  42191. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42192. this.outro += content;
  42193. return this;
  42194. }
  42195. appendLeft(index, content) {
  42196. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42197. this._split(index);
  42198. const chunk = this.byEnd[index];
  42199. if (chunk) {
  42200. chunk.appendLeft(content);
  42201. } else {
  42202. this.intro += content;
  42203. }
  42204. return this;
  42205. }
  42206. appendRight(index, content) {
  42207. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42208. this._split(index);
  42209. const chunk = this.byStart[index];
  42210. if (chunk) {
  42211. chunk.appendRight(content);
  42212. } else {
  42213. this.outro += content;
  42214. }
  42215. return this;
  42216. }
  42217. clone() {
  42218. const cloned = new MagicString(this.original, { filename: this.filename });
  42219. let originalChunk = this.firstChunk;
  42220. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  42221. while (originalChunk) {
  42222. cloned.byStart[clonedChunk.start] = clonedChunk;
  42223. cloned.byEnd[clonedChunk.end] = clonedChunk;
  42224. const nextOriginalChunk = originalChunk.next;
  42225. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  42226. if (nextClonedChunk) {
  42227. clonedChunk.next = nextClonedChunk;
  42228. nextClonedChunk.previous = clonedChunk;
  42229. clonedChunk = nextClonedChunk;
  42230. }
  42231. originalChunk = nextOriginalChunk;
  42232. }
  42233. cloned.lastChunk = clonedChunk;
  42234. if (this.indentExclusionRanges) {
  42235. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  42236. }
  42237. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  42238. cloned.intro = this.intro;
  42239. cloned.outro = this.outro;
  42240. return cloned;
  42241. }
  42242. generateDecodedMap(options) {
  42243. options = options || {};
  42244. const sourceIndex = 0;
  42245. const names = Object.keys(this.storedNames);
  42246. const mappings = new Mappings(options.hires);
  42247. const locate = getLocator(this.original);
  42248. if (this.intro) {
  42249. mappings.advance(this.intro);
  42250. }
  42251. this.firstChunk.eachNext((chunk) => {
  42252. const loc = locate(chunk.start);
  42253. if (chunk.intro.length) mappings.advance(chunk.intro);
  42254. if (chunk.edited) {
  42255. mappings.addEdit(
  42256. sourceIndex,
  42257. chunk.content,
  42258. loc,
  42259. chunk.storeName ? names.indexOf(chunk.original) : -1,
  42260. );
  42261. } else {
  42262. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  42263. }
  42264. if (chunk.outro.length) mappings.advance(chunk.outro);
  42265. });
  42266. return {
  42267. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  42268. sources: [
  42269. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  42270. ],
  42271. sourcesContent: options.includeContent ? [this.original] : undefined,
  42272. names,
  42273. mappings: mappings.raw,
  42274. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  42275. };
  42276. }
  42277. generateMap(options) {
  42278. return new SourceMap(this.generateDecodedMap(options));
  42279. }
  42280. _ensureindentStr() {
  42281. if (this.indentStr === undefined) {
  42282. this.indentStr = guessIndent(this.original);
  42283. }
  42284. }
  42285. _getRawIndentString() {
  42286. this._ensureindentStr();
  42287. return this.indentStr;
  42288. }
  42289. getIndentString() {
  42290. this._ensureindentStr();
  42291. return this.indentStr === null ? '\t' : this.indentStr;
  42292. }
  42293. indent(indentStr, options) {
  42294. const pattern = /^[^\r\n]/gm;
  42295. if (isObject(indentStr)) {
  42296. options = indentStr;
  42297. indentStr = undefined;
  42298. }
  42299. if (indentStr === undefined) {
  42300. this._ensureindentStr();
  42301. indentStr = this.indentStr || '\t';
  42302. }
  42303. if (indentStr === '') return this; // noop
  42304. options = options || {};
  42305. // Process exclusion ranges
  42306. const isExcluded = {};
  42307. if (options.exclude) {
  42308. const exclusions =
  42309. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  42310. exclusions.forEach((exclusion) => {
  42311. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  42312. isExcluded[i] = true;
  42313. }
  42314. });
  42315. }
  42316. let shouldIndentNextCharacter = options.indentStart !== false;
  42317. const replacer = (match) => {
  42318. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  42319. shouldIndentNextCharacter = true;
  42320. return match;
  42321. };
  42322. this.intro = this.intro.replace(pattern, replacer);
  42323. let charIndex = 0;
  42324. let chunk = this.firstChunk;
  42325. while (chunk) {
  42326. const end = chunk.end;
  42327. if (chunk.edited) {
  42328. if (!isExcluded[charIndex]) {
  42329. chunk.content = chunk.content.replace(pattern, replacer);
  42330. if (chunk.content.length) {
  42331. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  42332. }
  42333. }
  42334. } else {
  42335. charIndex = chunk.start;
  42336. while (charIndex < end) {
  42337. if (!isExcluded[charIndex]) {
  42338. const char = this.original[charIndex];
  42339. if (char === '\n') {
  42340. shouldIndentNextCharacter = true;
  42341. } else if (char !== '\r' && shouldIndentNextCharacter) {
  42342. shouldIndentNextCharacter = false;
  42343. if (charIndex === chunk.start) {
  42344. chunk.prependRight(indentStr);
  42345. } else {
  42346. this._splitChunk(chunk, charIndex);
  42347. chunk = chunk.next;
  42348. chunk.prependRight(indentStr);
  42349. }
  42350. }
  42351. }
  42352. charIndex += 1;
  42353. }
  42354. }
  42355. charIndex = chunk.end;
  42356. chunk = chunk.next;
  42357. }
  42358. this.outro = this.outro.replace(pattern, replacer);
  42359. return this;
  42360. }
  42361. insert() {
  42362. throw new Error(
  42363. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  42364. );
  42365. }
  42366. insertLeft(index, content) {
  42367. if (!warned.insertLeft) {
  42368. console.warn(
  42369. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  42370. ); // eslint-disable-line no-console
  42371. warned.insertLeft = true;
  42372. }
  42373. return this.appendLeft(index, content);
  42374. }
  42375. insertRight(index, content) {
  42376. if (!warned.insertRight) {
  42377. console.warn(
  42378. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  42379. ); // eslint-disable-line no-console
  42380. warned.insertRight = true;
  42381. }
  42382. return this.prependRight(index, content);
  42383. }
  42384. move(start, end, index) {
  42385. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  42386. this._split(start);
  42387. this._split(end);
  42388. this._split(index);
  42389. const first = this.byStart[start];
  42390. const last = this.byEnd[end];
  42391. const oldLeft = first.previous;
  42392. const oldRight = last.next;
  42393. const newRight = this.byStart[index];
  42394. if (!newRight && last === this.lastChunk) return this;
  42395. const newLeft = newRight ? newRight.previous : this.lastChunk;
  42396. if (oldLeft) oldLeft.next = oldRight;
  42397. if (oldRight) oldRight.previous = oldLeft;
  42398. if (newLeft) newLeft.next = first;
  42399. if (newRight) newRight.previous = last;
  42400. if (!first.previous) this.firstChunk = last.next;
  42401. if (!last.next) {
  42402. this.lastChunk = first.previous;
  42403. this.lastChunk.next = null;
  42404. }
  42405. first.previous = newLeft;
  42406. last.next = newRight || null;
  42407. if (!newLeft) this.firstChunk = first;
  42408. if (!newRight) this.lastChunk = last;
  42409. return this;
  42410. }
  42411. overwrite(start, end, content, options) {
  42412. options = options || {};
  42413. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  42414. }
  42415. update(start, end, content, options) {
  42416. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  42417. while (start < 0) start += this.original.length;
  42418. while (end < 0) end += this.original.length;
  42419. if (end > this.original.length) throw new Error('end is out of bounds');
  42420. if (start === end)
  42421. throw new Error(
  42422. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  42423. );
  42424. this._split(start);
  42425. this._split(end);
  42426. if (options === true) {
  42427. if (!warned.storeName) {
  42428. console.warn(
  42429. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  42430. ); // eslint-disable-line no-console
  42431. warned.storeName = true;
  42432. }
  42433. options = { storeName: true };
  42434. }
  42435. const storeName = options !== undefined ? options.storeName : false;
  42436. const overwrite = options !== undefined ? options.overwrite : false;
  42437. if (storeName) {
  42438. const original = this.original.slice(start, end);
  42439. Object.defineProperty(this.storedNames, original, {
  42440. writable: true,
  42441. value: true,
  42442. enumerable: true,
  42443. });
  42444. }
  42445. const first = this.byStart[start];
  42446. const last = this.byEnd[end];
  42447. if (first) {
  42448. let chunk = first;
  42449. while (chunk !== last) {
  42450. if (chunk.next !== this.byStart[chunk.end]) {
  42451. throw new Error('Cannot overwrite across a split point');
  42452. }
  42453. chunk = chunk.next;
  42454. chunk.edit('', false);
  42455. }
  42456. first.edit(content, storeName, !overwrite);
  42457. } else {
  42458. // must be inserting at the end
  42459. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  42460. // TODO last chunk in the array may not be the last chunk, if it's moved...
  42461. last.next = newChunk;
  42462. newChunk.previous = last;
  42463. }
  42464. return this;
  42465. }
  42466. prepend(content) {
  42467. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42468. this.intro = content + this.intro;
  42469. return this;
  42470. }
  42471. prependLeft(index, content) {
  42472. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42473. this._split(index);
  42474. const chunk = this.byEnd[index];
  42475. if (chunk) {
  42476. chunk.prependLeft(content);
  42477. } else {
  42478. this.intro = content + this.intro;
  42479. }
  42480. return this;
  42481. }
  42482. prependRight(index, content) {
  42483. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42484. this._split(index);
  42485. const chunk = this.byStart[index];
  42486. if (chunk) {
  42487. chunk.prependRight(content);
  42488. } else {
  42489. this.outro = content + this.outro;
  42490. }
  42491. return this;
  42492. }
  42493. remove(start, end) {
  42494. while (start < 0) start += this.original.length;
  42495. while (end < 0) end += this.original.length;
  42496. if (start === end) return this;
  42497. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42498. if (start > end) throw new Error('end must be greater than start');
  42499. this._split(start);
  42500. this._split(end);
  42501. let chunk = this.byStart[start];
  42502. while (chunk) {
  42503. chunk.intro = '';
  42504. chunk.outro = '';
  42505. chunk.edit('');
  42506. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42507. }
  42508. return this;
  42509. }
  42510. reset(start, end) {
  42511. while (start < 0) start += this.original.length;
  42512. while (end < 0) end += this.original.length;
  42513. if (start === end) return this;
  42514. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42515. if (start > end) throw new Error('end must be greater than start');
  42516. this._split(start);
  42517. this._split(end);
  42518. let chunk = this.byStart[start];
  42519. while (chunk) {
  42520. chunk.reset();
  42521. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42522. }
  42523. return this;
  42524. }
  42525. lastChar() {
  42526. if (this.outro.length) return this.outro[this.outro.length - 1];
  42527. let chunk = this.lastChunk;
  42528. do {
  42529. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  42530. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  42531. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  42532. } while ((chunk = chunk.previous));
  42533. if (this.intro.length) return this.intro[this.intro.length - 1];
  42534. return '';
  42535. }
  42536. lastLine() {
  42537. let lineIndex = this.outro.lastIndexOf(n);
  42538. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  42539. let lineStr = this.outro;
  42540. let chunk = this.lastChunk;
  42541. do {
  42542. if (chunk.outro.length > 0) {
  42543. lineIndex = chunk.outro.lastIndexOf(n);
  42544. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  42545. lineStr = chunk.outro + lineStr;
  42546. }
  42547. if (chunk.content.length > 0) {
  42548. lineIndex = chunk.content.lastIndexOf(n);
  42549. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  42550. lineStr = chunk.content + lineStr;
  42551. }
  42552. if (chunk.intro.length > 0) {
  42553. lineIndex = chunk.intro.lastIndexOf(n);
  42554. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  42555. lineStr = chunk.intro + lineStr;
  42556. }
  42557. } while ((chunk = chunk.previous));
  42558. lineIndex = this.intro.lastIndexOf(n);
  42559. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  42560. return this.intro + lineStr;
  42561. }
  42562. slice(start = 0, end = this.original.length) {
  42563. while (start < 0) start += this.original.length;
  42564. while (end < 0) end += this.original.length;
  42565. let result = '';
  42566. // find start chunk
  42567. let chunk = this.firstChunk;
  42568. while (chunk && (chunk.start > start || chunk.end <= start)) {
  42569. // found end chunk before start
  42570. if (chunk.start < end && chunk.end >= end) {
  42571. return result;
  42572. }
  42573. chunk = chunk.next;
  42574. }
  42575. if (chunk && chunk.edited && chunk.start !== start)
  42576. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  42577. const startChunk = chunk;
  42578. while (chunk) {
  42579. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  42580. result += chunk.intro;
  42581. }
  42582. const containsEnd = chunk.start < end && chunk.end >= end;
  42583. if (containsEnd && chunk.edited && chunk.end !== end)
  42584. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  42585. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  42586. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  42587. result += chunk.content.slice(sliceStart, sliceEnd);
  42588. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  42589. result += chunk.outro;
  42590. }
  42591. if (containsEnd) {
  42592. break;
  42593. }
  42594. chunk = chunk.next;
  42595. }
  42596. return result;
  42597. }
  42598. // TODO deprecate this? not really very useful
  42599. snip(start, end) {
  42600. const clone = this.clone();
  42601. clone.remove(0, start);
  42602. clone.remove(end, clone.original.length);
  42603. return clone;
  42604. }
  42605. _split(index) {
  42606. if (this.byStart[index] || this.byEnd[index]) return;
  42607. let chunk = this.lastSearchedChunk;
  42608. const searchForward = index > chunk.end;
  42609. while (chunk) {
  42610. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  42611. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  42612. }
  42613. }
  42614. _splitChunk(chunk, index) {
  42615. if (chunk.edited && chunk.content.length) {
  42616. // zero-length edited chunks are a special case (overlapping replacements)
  42617. const loc = getLocator(this.original)(index);
  42618. throw new Error(
  42619. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  42620. );
  42621. }
  42622. const newChunk = chunk.split(index);
  42623. this.byEnd[index] = chunk;
  42624. this.byStart[index] = newChunk;
  42625. this.byEnd[newChunk.end] = newChunk;
  42626. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  42627. this.lastSearchedChunk = chunk;
  42628. return true;
  42629. }
  42630. toString() {
  42631. let str = this.intro;
  42632. let chunk = this.firstChunk;
  42633. while (chunk) {
  42634. str += chunk.toString();
  42635. chunk = chunk.next;
  42636. }
  42637. return str + this.outro;
  42638. }
  42639. isEmpty() {
  42640. let chunk = this.firstChunk;
  42641. do {
  42642. if (
  42643. (chunk.intro.length && chunk.intro.trim()) ||
  42644. (chunk.content.length && chunk.content.trim()) ||
  42645. (chunk.outro.length && chunk.outro.trim())
  42646. )
  42647. return false;
  42648. } while ((chunk = chunk.next));
  42649. return true;
  42650. }
  42651. length() {
  42652. let chunk = this.firstChunk;
  42653. let length = 0;
  42654. do {
  42655. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  42656. } while ((chunk = chunk.next));
  42657. return length;
  42658. }
  42659. trimLines() {
  42660. return this.trim('[\\r\\n]');
  42661. }
  42662. trim(charType) {
  42663. return this.trimStart(charType).trimEnd(charType);
  42664. }
  42665. trimEndAborted(charType) {
  42666. const rx = new RegExp((charType || '\\s') + '+$');
  42667. this.outro = this.outro.replace(rx, '');
  42668. if (this.outro.length) return true;
  42669. let chunk = this.lastChunk;
  42670. do {
  42671. const end = chunk.end;
  42672. const aborted = chunk.trimEnd(rx);
  42673. // if chunk was trimmed, we have a new lastChunk
  42674. if (chunk.end !== end) {
  42675. if (this.lastChunk === chunk) {
  42676. this.lastChunk = chunk.next;
  42677. }
  42678. this.byEnd[chunk.end] = chunk;
  42679. this.byStart[chunk.next.start] = chunk.next;
  42680. this.byEnd[chunk.next.end] = chunk.next;
  42681. }
  42682. if (aborted) return true;
  42683. chunk = chunk.previous;
  42684. } while (chunk);
  42685. return false;
  42686. }
  42687. trimEnd(charType) {
  42688. this.trimEndAborted(charType);
  42689. return this;
  42690. }
  42691. trimStartAborted(charType) {
  42692. const rx = new RegExp('^' + (charType || '\\s') + '+');
  42693. this.intro = this.intro.replace(rx, '');
  42694. if (this.intro.length) return true;
  42695. let chunk = this.firstChunk;
  42696. do {
  42697. const end = chunk.end;
  42698. const aborted = chunk.trimStart(rx);
  42699. if (chunk.end !== end) {
  42700. // special case...
  42701. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  42702. this.byEnd[chunk.end] = chunk;
  42703. this.byStart[chunk.next.start] = chunk.next;
  42704. this.byEnd[chunk.next.end] = chunk.next;
  42705. }
  42706. if (aborted) return true;
  42707. chunk = chunk.next;
  42708. } while (chunk);
  42709. return false;
  42710. }
  42711. trimStart(charType) {
  42712. this.trimStartAborted(charType);
  42713. return this;
  42714. }
  42715. hasChanged() {
  42716. return this.original !== this.toString();
  42717. }
  42718. _replaceRegexp(searchValue, replacement) {
  42719. function getReplacement(match, str) {
  42720. if (typeof replacement === 'string') {
  42721. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  42722. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  42723. if (i === '$') return '$';
  42724. if (i === '&') return match[0];
  42725. const num = +i;
  42726. if (num < match.length) return match[+i];
  42727. return `$${i}`;
  42728. });
  42729. } else {
  42730. return replacement(...match, match.index, str, match.groups);
  42731. }
  42732. }
  42733. function matchAll(re, str) {
  42734. let match;
  42735. const matches = [];
  42736. while ((match = re.exec(str))) {
  42737. matches.push(match);
  42738. }
  42739. return matches;
  42740. }
  42741. if (searchValue.global) {
  42742. const matches = matchAll(searchValue, this.original);
  42743. matches.forEach((match) => {
  42744. if (match.index != null)
  42745. this.overwrite(
  42746. match.index,
  42747. match.index + match[0].length,
  42748. getReplacement(match, this.original),
  42749. );
  42750. });
  42751. } else {
  42752. const match = this.original.match(searchValue);
  42753. if (match && match.index != null)
  42754. this.overwrite(
  42755. match.index,
  42756. match.index + match[0].length,
  42757. getReplacement(match, this.original),
  42758. );
  42759. }
  42760. return this;
  42761. }
  42762. _replaceString(string, replacement) {
  42763. const { original } = this;
  42764. const index = original.indexOf(string);
  42765. if (index !== -1) {
  42766. this.overwrite(index, index + string.length, replacement);
  42767. }
  42768. return this;
  42769. }
  42770. replace(searchValue, replacement) {
  42771. if (typeof searchValue === 'string') {
  42772. return this._replaceString(searchValue, replacement);
  42773. }
  42774. return this._replaceRegexp(searchValue, replacement);
  42775. }
  42776. _replaceAllString(string, replacement) {
  42777. const { original } = this;
  42778. const stringLength = string.length;
  42779. for (
  42780. let index = original.indexOf(string);
  42781. index !== -1;
  42782. index = original.indexOf(string, index + stringLength)
  42783. ) {
  42784. this.overwrite(index, index + stringLength, replacement);
  42785. }
  42786. return this;
  42787. }
  42788. replaceAll(searchValue, replacement) {
  42789. if (typeof searchValue === 'string') {
  42790. return this._replaceAllString(searchValue, replacement);
  42791. }
  42792. if (!searchValue.global) {
  42793. throw new TypeError(
  42794. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  42795. );
  42796. }
  42797. return this._replaceRegexp(searchValue, replacement);
  42798. }
  42799. }
  42800. var _a, _b;
  42801. class ScriptCompileContext {
  42802. constructor(descriptor, options) {
  42803. this.descriptor = descriptor;
  42804. this.options = options;
  42805. this.isCE = false;
  42806. this.source = this.descriptor.source;
  42807. this.filename = this.descriptor.filename;
  42808. this.s = new MagicString(this.source);
  42809. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  42810. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  42811. this.userImports = /* @__PURE__ */ Object.create(null);
  42812. // macros presence check
  42813. this.hasDefinePropsCall = false;
  42814. this.hasDefineEmitCall = false;
  42815. this.hasDefineExposeCall = false;
  42816. this.hasDefaultExportName = false;
  42817. this.hasDefaultExportRender = false;
  42818. this.hasDefineOptionsCall = false;
  42819. this.hasDefineSlotsCall = false;
  42820. this.hasDefineModelCall = false;
  42821. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  42822. // defineModel
  42823. this.modelDecls = /* @__PURE__ */ Object.create(null);
  42824. // codegen
  42825. this.bindingMetadata = {};
  42826. this.helperImports = /* @__PURE__ */ new Set();
  42827. const { script, scriptSetup } = descriptor;
  42828. const scriptLang = script && script.lang;
  42829. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  42830. this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
  42831. this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
  42832. const customElement = options.customElement;
  42833. const filename = this.descriptor.filename;
  42834. if (customElement) {
  42835. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  42836. }
  42837. const plugins = resolveParserPlugins(
  42838. scriptLang || scriptSetupLang,
  42839. options.babelParserPlugins
  42840. );
  42841. function parse(input, offset) {
  42842. try {
  42843. return parse_1$1(input, {
  42844. plugins,
  42845. sourceType: "module"
  42846. }).program;
  42847. } catch (e) {
  42848. e.message = `[vue/compiler-sfc] ${e.message}
  42849. ${descriptor.filename}
  42850. ${generateCodeFrame(
  42851. descriptor.source,
  42852. e.pos + offset,
  42853. e.pos + offset + 1
  42854. )}`;
  42855. throw e;
  42856. }
  42857. }
  42858. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  42859. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  42860. }
  42861. helper(key) {
  42862. this.helperImports.add(key);
  42863. return `_${key}`;
  42864. }
  42865. getString(node, scriptSetup = true) {
  42866. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  42867. return block.content.slice(node.start, node.end);
  42868. }
  42869. error(msg, node, scope) {
  42870. const offset = scope ? scope.offset : this.startOffset;
  42871. throw new Error(
  42872. `[@vue/compiler-sfc] ${msg}
  42873. ${(scope || this.descriptor).filename}
  42874. ${generateCodeFrame(
  42875. (scope || this.descriptor).source,
  42876. node.start + offset,
  42877. node.end + offset
  42878. )}`
  42879. );
  42880. }
  42881. }
  42882. function resolveParserPlugins(lang, userPlugins, dts = false) {
  42883. const plugins = [];
  42884. if (!userPlugins || !userPlugins.some(
  42885. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  42886. )) {
  42887. plugins.push("importAttributes");
  42888. }
  42889. if (lang === "jsx" || lang === "tsx") {
  42890. plugins.push("jsx");
  42891. } else if (userPlugins) {
  42892. userPlugins = userPlugins.filter((p) => p !== "jsx");
  42893. }
  42894. if (lang === "ts" || lang === "tsx") {
  42895. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  42896. if (!userPlugins || !userPlugins.includes("decorators")) {
  42897. plugins.push("decorators-legacy");
  42898. }
  42899. }
  42900. if (userPlugins) {
  42901. plugins.push(...userPlugins);
  42902. }
  42903. return plugins;
  42904. }
  42905. function rewriteDefault(input, as, parserPlugins) {
  42906. const ast = parse_1$1(input, {
  42907. sourceType: "module",
  42908. plugins: resolveParserPlugins("js", parserPlugins)
  42909. }).program.body;
  42910. const s = new MagicString(input);
  42911. rewriteDefaultAST(ast, s, as);
  42912. return s.toString();
  42913. }
  42914. function rewriteDefaultAST(ast, s, as) {
  42915. if (!hasDefaultExport(ast)) {
  42916. s.append(`
  42917. const ${as} = {}`);
  42918. return;
  42919. }
  42920. ast.forEach((node) => {
  42921. if (node.type === "ExportDefaultDeclaration") {
  42922. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  42923. let start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  42924. s.overwrite(start, node.declaration.id.start, ` class `);
  42925. s.append(`
  42926. const ${as} = ${node.declaration.id.name}`);
  42927. } else {
  42928. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  42929. }
  42930. } else if (node.type === "ExportNamedDeclaration") {
  42931. for (const specifier of node.specifiers) {
  42932. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  42933. if (node.source) {
  42934. if (specifier.local.name === "default") {
  42935. s.prepend(
  42936. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  42937. `
  42938. );
  42939. const end2 = specifierEnd(s, specifier.local.end, node.end);
  42940. s.remove(specifier.start, end2);
  42941. s.append(`
  42942. const ${as} = __VUE_DEFAULT__`);
  42943. continue;
  42944. } else {
  42945. s.prepend(
  42946. `import { ${s.slice(
  42947. specifier.local.start,
  42948. specifier.local.end
  42949. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  42950. `
  42951. );
  42952. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  42953. s.remove(specifier.start, end2);
  42954. s.append(`
  42955. const ${as} = __VUE_DEFAULT__`);
  42956. continue;
  42957. }
  42958. }
  42959. const end = specifierEnd(s, specifier.end, node.end);
  42960. s.remove(specifier.start, end);
  42961. s.append(`
  42962. const ${as} = ${specifier.local.name}`);
  42963. }
  42964. }
  42965. }
  42966. });
  42967. }
  42968. function hasDefaultExport(ast) {
  42969. for (const stmt of ast) {
  42970. if (stmt.type === "ExportDefaultDeclaration") {
  42971. return true;
  42972. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  42973. (spec) => spec.exported.name === "default"
  42974. )) {
  42975. return true;
  42976. }
  42977. }
  42978. return false;
  42979. }
  42980. function specifierEnd(s, end, nodeEnd) {
  42981. let hasCommas = false;
  42982. let oldEnd = end;
  42983. while (end < nodeEnd) {
  42984. if (/\s/.test(s.slice(end, end + 1))) {
  42985. end++;
  42986. } else if (s.slice(end, end + 1) === ",") {
  42987. end++;
  42988. hasCommas = true;
  42989. break;
  42990. } else if (s.slice(end, end + 1) === "}") {
  42991. break;
  42992. }
  42993. }
  42994. return hasCommas ? end : oldEnd;
  42995. }
  42996. var __defProp$3 = Object.defineProperty;
  42997. var __defProps$2 = Object.defineProperties;
  42998. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  42999. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  43000. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  43001. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  43002. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43003. var __spreadValues$3 = (a, b) => {
  43004. for (var prop in b || (b = {}))
  43005. if (__hasOwnProp$3.call(b, prop))
  43006. __defNormalProp$3(a, prop, b[prop]);
  43007. if (__getOwnPropSymbols$3)
  43008. for (var prop of __getOwnPropSymbols$3(b)) {
  43009. if (__propIsEnum$3.call(b, prop))
  43010. __defNormalProp$3(a, prop, b[prop]);
  43011. }
  43012. return a;
  43013. };
  43014. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  43015. const normalScriptDefaultVar = `__default__`;
  43016. function processNormalScript(ctx, scopeId) {
  43017. var _a;
  43018. const script = ctx.descriptor.script;
  43019. if (script.lang && !ctx.isJS && !ctx.isTS) {
  43020. return script;
  43021. }
  43022. try {
  43023. let content = script.content;
  43024. let map = script.map;
  43025. const scriptAst = ctx.scriptAst;
  43026. const bindings = analyzeScriptBindings(scriptAst.body);
  43027. const { cssVars } = ctx.descriptor;
  43028. const { genDefaultAs, isProd } = ctx.options;
  43029. if (cssVars.length || genDefaultAs) {
  43030. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  43031. const s = new MagicString(content);
  43032. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  43033. content = s.toString();
  43034. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  43035. content += genNormalScriptCssVarsCode(
  43036. cssVars,
  43037. bindings,
  43038. scopeId,
  43039. !!isProd,
  43040. defaultVar
  43041. );
  43042. }
  43043. if (!genDefaultAs) {
  43044. content += `
  43045. export default ${defaultVar}`;
  43046. }
  43047. }
  43048. return __spreadProps$2(__spreadValues$3({}, script), {
  43049. content,
  43050. map,
  43051. bindings,
  43052. scriptAst: scriptAst.body
  43053. });
  43054. } catch (e) {
  43055. return script;
  43056. }
  43057. }
  43058. var __defProp$2 = Object.defineProperty;
  43059. var __defProps$1 = Object.defineProperties;
  43060. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  43061. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  43062. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  43063. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  43064. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43065. var __spreadValues$2 = (a, b) => {
  43066. for (var prop in b || (b = {}))
  43067. if (__hasOwnProp$2.call(b, prop))
  43068. __defNormalProp$2(a, prop, b[prop]);
  43069. if (__getOwnPropSymbols$2)
  43070. for (var prop of __getOwnPropSymbols$2(b)) {
  43071. if (__propIsEnum$2.call(b, prop))
  43072. __defNormalProp$2(a, prop, b[prop]);
  43073. }
  43074. return a;
  43075. };
  43076. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  43077. class TypeScope {
  43078. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  43079. this.filename = filename;
  43080. this.source = source;
  43081. this.offset = offset;
  43082. this.imports = imports;
  43083. this.types = types;
  43084. this.declares = declares;
  43085. this.isGenericScope = false;
  43086. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  43087. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  43088. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  43089. }
  43090. }
  43091. function resolveTypeElements(ctx, node, scope, typeParameters) {
  43092. const canCache = !typeParameters;
  43093. if (canCache && node._resolvedElements) {
  43094. return node._resolvedElements;
  43095. }
  43096. const resolved = innerResolveTypeElements(
  43097. ctx,
  43098. node,
  43099. node._ownerScope || scope || ctxToScope(ctx),
  43100. typeParameters
  43101. );
  43102. return canCache ? node._resolvedElements = resolved : resolved;
  43103. }
  43104. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  43105. var _a, _b;
  43106. switch (node.type) {
  43107. case "TSTypeLiteral":
  43108. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  43109. case "TSInterfaceDeclaration":
  43110. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  43111. case "TSTypeAliasDeclaration":
  43112. case "TSParenthesizedType":
  43113. return resolveTypeElements(
  43114. ctx,
  43115. node.typeAnnotation,
  43116. scope,
  43117. typeParameters
  43118. );
  43119. case "TSFunctionType": {
  43120. return { props: {}, calls: [node] };
  43121. }
  43122. case "TSUnionType":
  43123. case "TSIntersectionType":
  43124. return mergeElements(
  43125. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  43126. node.type
  43127. );
  43128. case "TSMappedType":
  43129. return resolveMappedType(ctx, node, scope);
  43130. case "TSIndexedAccessType": {
  43131. const types = resolveIndexType(ctx, node, scope);
  43132. return mergeElements(
  43133. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  43134. "TSUnionType"
  43135. );
  43136. }
  43137. case "TSExpressionWithTypeArguments":
  43138. case "TSTypeReference": {
  43139. const typeName = getReferenceName(node);
  43140. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  43141. return resolveExtractPropTypes(
  43142. resolveTypeElements(
  43143. ctx,
  43144. node.typeParameters.params[0],
  43145. scope,
  43146. typeParameters
  43147. ),
  43148. scope
  43149. );
  43150. }
  43151. const resolved = resolveTypeReference(ctx, node, scope);
  43152. if (resolved) {
  43153. let typeParams;
  43154. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  43155. typeParams = /* @__PURE__ */ Object.create(null);
  43156. resolved.typeParameters.params.forEach((p, i) => {
  43157. let param = typeParameters && typeParameters[p.name];
  43158. if (!param)
  43159. param = node.typeParameters.params[i];
  43160. typeParams[p.name] = param;
  43161. });
  43162. }
  43163. return resolveTypeElements(
  43164. ctx,
  43165. resolved,
  43166. resolved._ownerScope,
  43167. typeParams
  43168. );
  43169. } else {
  43170. if (typeof typeName === "string") {
  43171. if (typeParameters && typeParameters[typeName]) {
  43172. return resolveTypeElements(
  43173. ctx,
  43174. typeParameters[typeName],
  43175. scope,
  43176. typeParameters
  43177. );
  43178. }
  43179. if (
  43180. // @ts-expect-error
  43181. SupportedBuiltinsSet.has(typeName)
  43182. ) {
  43183. return resolveBuiltin(
  43184. ctx,
  43185. node,
  43186. typeName,
  43187. scope,
  43188. typeParameters
  43189. );
  43190. } else if (typeName === "ReturnType" && node.typeParameters) {
  43191. const ret = resolveReturnType(
  43192. ctx,
  43193. node.typeParameters.params[0],
  43194. scope
  43195. );
  43196. if (ret) {
  43197. return resolveTypeElements(ctx, ret, scope);
  43198. }
  43199. }
  43200. }
  43201. return ctx.error(
  43202. `Unresolvable type reference or unsupported built-in utility type`,
  43203. node,
  43204. scope
  43205. );
  43206. }
  43207. }
  43208. case "TSImportType": {
  43209. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  43210. return resolveExtractPropTypes(
  43211. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  43212. scope
  43213. );
  43214. }
  43215. const sourceScope = importSourceToScope(
  43216. ctx,
  43217. node.argument,
  43218. scope,
  43219. node.argument.value
  43220. );
  43221. const resolved = resolveTypeReference(ctx, node, sourceScope);
  43222. if (resolved) {
  43223. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43224. }
  43225. break;
  43226. }
  43227. case "TSTypeQuery":
  43228. {
  43229. const resolved = resolveTypeReference(ctx, node, scope);
  43230. if (resolved) {
  43231. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43232. }
  43233. }
  43234. break;
  43235. }
  43236. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  43237. }
  43238. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  43239. const res = { props: {} };
  43240. for (const e of elements) {
  43241. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  43242. if (typeParameters) {
  43243. scope = createChildScope(scope);
  43244. scope.isGenericScope = true;
  43245. Object.assign(scope.types, typeParameters);
  43246. }
  43247. e._ownerScope = scope;
  43248. const name = getId(e.key);
  43249. if (name && !e.computed) {
  43250. res.props[name] = e;
  43251. } else if (e.key.type === "TemplateLiteral") {
  43252. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  43253. res.props[key] = e;
  43254. }
  43255. } else {
  43256. ctx.error(
  43257. `Unsupported computed key in type referenced by a macro`,
  43258. e.key,
  43259. scope
  43260. );
  43261. }
  43262. } else if (e.type === "TSCallSignatureDeclaration") {
  43263. (res.calls || (res.calls = [])).push(e);
  43264. }
  43265. }
  43266. return res;
  43267. }
  43268. function mergeElements(maps, type) {
  43269. if (maps.length === 1)
  43270. return maps[0];
  43271. const res = { props: {} };
  43272. const { props: baseProps } = res;
  43273. for (const { props, calls } of maps) {
  43274. for (const key in props) {
  43275. if (!hasOwn(baseProps, key)) {
  43276. baseProps[key] = props[key];
  43277. } else {
  43278. baseProps[key] = createProperty(
  43279. baseProps[key].key,
  43280. {
  43281. type,
  43282. // @ts-expect-error
  43283. types: [baseProps[key], props[key]]
  43284. },
  43285. baseProps[key]._ownerScope,
  43286. baseProps[key].optional || props[key].optional
  43287. );
  43288. }
  43289. }
  43290. if (calls) {
  43291. (res.calls || (res.calls = [])).push(...calls);
  43292. }
  43293. }
  43294. return res;
  43295. }
  43296. function createProperty(key, typeAnnotation, scope, optional) {
  43297. return {
  43298. type: "TSPropertySignature",
  43299. key,
  43300. kind: "get",
  43301. optional,
  43302. typeAnnotation: {
  43303. type: "TSTypeAnnotation",
  43304. typeAnnotation
  43305. },
  43306. _ownerScope: scope
  43307. };
  43308. }
  43309. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  43310. const base = typeElementsToMap(
  43311. ctx,
  43312. node.body.body,
  43313. node._ownerScope,
  43314. typeParameters
  43315. );
  43316. if (node.extends) {
  43317. for (const ext of node.extends) {
  43318. if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  43319. continue;
  43320. }
  43321. try {
  43322. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  43323. for (const key in props) {
  43324. if (!hasOwn(base.props, key)) {
  43325. base.props[key] = props[key];
  43326. }
  43327. }
  43328. if (calls) {
  43329. ;
  43330. (base.calls || (base.calls = [])).push(...calls);
  43331. }
  43332. } catch (e) {
  43333. ctx.error(
  43334. `Failed to resolve extends base type.
  43335. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  43336. interface Props extends /* @vue-ignore */ Base {}
  43337. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  43338. ext
  43339. );
  43340. }
  43341. }
  43342. }
  43343. return base;
  43344. }
  43345. function resolveMappedType(ctx, node, scope) {
  43346. const res = { props: {} };
  43347. const keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  43348. for (const key of keys) {
  43349. res.props[key] = createProperty(
  43350. {
  43351. type: "Identifier",
  43352. name: key
  43353. },
  43354. node.typeAnnotation,
  43355. scope,
  43356. !!node.optional
  43357. );
  43358. }
  43359. return res;
  43360. }
  43361. function resolveIndexType(ctx, node, scope) {
  43362. var _a, _b;
  43363. if (node.indexType.type === "TSNumberKeyword") {
  43364. return resolveArrayElementType(ctx, node.objectType, scope);
  43365. }
  43366. const { indexType, objectType } = node;
  43367. const types = [];
  43368. let keys;
  43369. let resolved;
  43370. if (indexType.type === "TSStringKeyword") {
  43371. resolved = resolveTypeElements(ctx, objectType, scope);
  43372. keys = Object.keys(resolved.props);
  43373. } else {
  43374. keys = resolveStringType(ctx, indexType, scope);
  43375. resolved = resolveTypeElements(ctx, objectType, scope);
  43376. }
  43377. for (const key of keys) {
  43378. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  43379. if (targetType) {
  43380. targetType._ownerScope = resolved.props[key]._ownerScope;
  43381. types.push(targetType);
  43382. }
  43383. }
  43384. return types;
  43385. }
  43386. function resolveArrayElementType(ctx, node, scope) {
  43387. if (node.type === "TSArrayType") {
  43388. return [node.elementType];
  43389. }
  43390. if (node.type === "TSTupleType") {
  43391. return node.elementTypes.map(
  43392. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  43393. );
  43394. }
  43395. if (node.type === "TSTypeReference") {
  43396. if (getReferenceName(node) === "Array" && node.typeParameters) {
  43397. return node.typeParameters.params;
  43398. } else {
  43399. const resolved = resolveTypeReference(ctx, node, scope);
  43400. if (resolved) {
  43401. return resolveArrayElementType(ctx, resolved, scope);
  43402. }
  43403. }
  43404. }
  43405. return ctx.error(
  43406. "Failed to resolve element type from target type",
  43407. node,
  43408. scope
  43409. );
  43410. }
  43411. function resolveStringType(ctx, node, scope) {
  43412. switch (node.type) {
  43413. case "StringLiteral":
  43414. return [node.value];
  43415. case "TSLiteralType":
  43416. return resolveStringType(ctx, node.literal, scope);
  43417. case "TSUnionType":
  43418. return node.types.map((t) => resolveStringType(ctx, t, scope)).flat();
  43419. case "TemplateLiteral": {
  43420. return resolveTemplateKeys(ctx, node, scope);
  43421. }
  43422. case "TSTypeReference": {
  43423. const resolved = resolveTypeReference(ctx, node, scope);
  43424. if (resolved) {
  43425. return resolveStringType(ctx, resolved, scope);
  43426. }
  43427. if (node.typeName.type === "Identifier") {
  43428. const getParam = (index = 0) => resolveStringType(ctx, node.typeParameters.params[index], scope);
  43429. switch (node.typeName.name) {
  43430. case "Extract":
  43431. return getParam(1);
  43432. case "Exclude": {
  43433. const excluded = getParam(1);
  43434. return getParam().filter((s) => !excluded.includes(s));
  43435. }
  43436. case "Uppercase":
  43437. return getParam().map((s) => s.toUpperCase());
  43438. case "Lowercase":
  43439. return getParam().map((s) => s.toLowerCase());
  43440. case "Capitalize":
  43441. return getParam().map(capitalize$1);
  43442. case "Uncapitalize":
  43443. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  43444. default:
  43445. ctx.error(
  43446. "Unsupported type when resolving index type",
  43447. node.typeName,
  43448. scope
  43449. );
  43450. }
  43451. }
  43452. }
  43453. }
  43454. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  43455. }
  43456. function resolveTemplateKeys(ctx, node, scope) {
  43457. if (!node.expressions.length) {
  43458. return [node.quasis[0].value.raw];
  43459. }
  43460. const res = [];
  43461. const e = node.expressions[0];
  43462. const q = node.quasis[0];
  43463. const leading = q ? q.value.raw : ``;
  43464. const resolved = resolveStringType(ctx, e, scope);
  43465. const restResolved = resolveTemplateKeys(
  43466. ctx,
  43467. __spreadProps$1(__spreadValues$2({}, node), {
  43468. expressions: node.expressions.slice(1),
  43469. quasis: q ? node.quasis.slice(1) : node.quasis
  43470. }),
  43471. scope
  43472. );
  43473. for (const r of resolved) {
  43474. for (const rr of restResolved) {
  43475. res.push(leading + r + rr);
  43476. }
  43477. }
  43478. return res;
  43479. }
  43480. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  43481. "Partial",
  43482. "Required",
  43483. "Readonly",
  43484. "Pick",
  43485. "Omit"
  43486. ]);
  43487. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  43488. const t = resolveTypeElements(
  43489. ctx,
  43490. node.typeParameters.params[0],
  43491. scope,
  43492. typeParameters
  43493. );
  43494. switch (name) {
  43495. case "Partial": {
  43496. const res2 = { props: {}, calls: t.calls };
  43497. Object.keys(t.props).forEach((key) => {
  43498. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  43499. });
  43500. return res2;
  43501. }
  43502. case "Required": {
  43503. const res2 = { props: {}, calls: t.calls };
  43504. Object.keys(t.props).forEach((key) => {
  43505. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  43506. });
  43507. return res2;
  43508. }
  43509. case "Readonly":
  43510. return t;
  43511. case "Pick": {
  43512. const picked = resolveStringType(
  43513. ctx,
  43514. node.typeParameters.params[1],
  43515. scope
  43516. );
  43517. const res2 = { props: {}, calls: t.calls };
  43518. for (const key of picked) {
  43519. res2.props[key] = t.props[key];
  43520. }
  43521. return res2;
  43522. }
  43523. case "Omit":
  43524. const omitted = resolveStringType(
  43525. ctx,
  43526. node.typeParameters.params[1],
  43527. scope
  43528. );
  43529. const res = { props: {}, calls: t.calls };
  43530. for (const key in t.props) {
  43531. if (!omitted.includes(key)) {
  43532. res.props[key] = t.props[key];
  43533. }
  43534. }
  43535. return res;
  43536. }
  43537. }
  43538. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  43539. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  43540. if (canCache && node._resolvedReference) {
  43541. return node._resolvedReference;
  43542. }
  43543. const resolved = innerResolveTypeReference(
  43544. ctx,
  43545. scope || ctxToScope(ctx),
  43546. name || getReferenceName(node),
  43547. node,
  43548. onlyExported
  43549. );
  43550. return canCache ? node._resolvedReference = resolved : resolved;
  43551. }
  43552. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  43553. if (typeof name === "string") {
  43554. if (scope.imports[name]) {
  43555. return resolveTypeFromImport(ctx, node, name, scope);
  43556. } else {
  43557. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  43558. if (lookupSource[name]) {
  43559. return lookupSource[name];
  43560. } else {
  43561. const globalScopes = resolveGlobalScope(ctx);
  43562. if (globalScopes) {
  43563. for (const s of globalScopes) {
  43564. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  43565. if (src[name]) {
  43566. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  43567. return src[name];
  43568. }
  43569. }
  43570. }
  43571. }
  43572. }
  43573. } else {
  43574. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  43575. if (ns) {
  43576. if (ns.type !== "TSModuleDeclaration") {
  43577. ns = ns._ns;
  43578. }
  43579. if (ns) {
  43580. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  43581. return innerResolveTypeReference(
  43582. ctx,
  43583. childScope,
  43584. name.length > 2 ? name.slice(1) : name[name.length - 1],
  43585. node,
  43586. !ns.declare
  43587. );
  43588. }
  43589. }
  43590. }
  43591. }
  43592. function getReferenceName(node) {
  43593. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  43594. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  43595. return ref.name;
  43596. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  43597. return qualifiedNameToPath(ref);
  43598. } else {
  43599. return "default";
  43600. }
  43601. }
  43602. function qualifiedNameToPath(node) {
  43603. if (node.type === "Identifier") {
  43604. return [node.name];
  43605. } else {
  43606. return [...qualifiedNameToPath(node.left), node.right.name];
  43607. }
  43608. }
  43609. function resolveGlobalScope(ctx) {
  43610. if (ctx.options.globalTypeFiles) {
  43611. const fs = resolveFS(ctx);
  43612. if (!fs) {
  43613. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  43614. }
  43615. return ctx.options.globalTypeFiles.map(
  43616. (file) => fileToScope(ctx, normalizePath(file), true)
  43617. );
  43618. }
  43619. }
  43620. let ts;
  43621. let loadTS;
  43622. function registerTS(_loadTS) {
  43623. loadTS = () => {
  43624. try {
  43625. return _loadTS();
  43626. } catch (err) {
  43627. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  43628. throw new Error(
  43629. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  43630. );
  43631. } else {
  43632. throw new Error(
  43633. "Failed to load TypeScript for resolving imported types."
  43634. );
  43635. }
  43636. }
  43637. };
  43638. }
  43639. function resolveFS(ctx) {
  43640. if (ctx.fs) {
  43641. return ctx.fs;
  43642. }
  43643. if (!ts && loadTS) {
  43644. ts = loadTS();
  43645. }
  43646. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  43647. if (!fs) {
  43648. return;
  43649. }
  43650. return ctx.fs = {
  43651. fileExists(file) {
  43652. if (file.endsWith(".vue.ts")) {
  43653. file = file.replace(/\.ts$/, "");
  43654. }
  43655. return fs.fileExists(file);
  43656. },
  43657. readFile(file) {
  43658. if (file.endsWith(".vue.ts")) {
  43659. file = file.replace(/\.ts$/, "");
  43660. }
  43661. return fs.readFile(file);
  43662. },
  43663. realpath: fs.realpath
  43664. };
  43665. }
  43666. function resolveTypeFromImport(ctx, node, name, scope) {
  43667. const { source, imported } = scope.imports[name];
  43668. const sourceScope = importSourceToScope(ctx, node, scope, source);
  43669. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  43670. }
  43671. function importSourceToScope(ctx, node, scope, source) {
  43672. let fs;
  43673. try {
  43674. fs = resolveFS(ctx);
  43675. } catch (err) {
  43676. return ctx.error(err.message, node, scope);
  43677. }
  43678. if (!fs) {
  43679. return ctx.error(
  43680. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  43681. node,
  43682. scope
  43683. );
  43684. }
  43685. let resolved = scope.resolvedImportSources[source];
  43686. if (!resolved) {
  43687. if (source.startsWith("..")) {
  43688. const osSpecificJoinFn = joinPaths;
  43689. const filename = osSpecificJoinFn(dirname$2(scope.filename), source);
  43690. resolved = resolveExt(filename, fs);
  43691. } else if (source.startsWith(".")) {
  43692. const filename = joinPaths(dirname$2(scope.filename), source);
  43693. resolved = resolveExt(filename, fs);
  43694. } else {
  43695. {
  43696. return ctx.error(
  43697. `Type import from non-relative sources is not supported in the browser build.`,
  43698. node,
  43699. scope
  43700. );
  43701. }
  43702. }
  43703. if (resolved) {
  43704. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  43705. }
  43706. }
  43707. if (resolved) {
  43708. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  43709. return fileToScope(ctx, resolved);
  43710. } else {
  43711. return ctx.error(
  43712. `Failed to resolve import source ${JSON.stringify(source)}.`,
  43713. node,
  43714. scope
  43715. );
  43716. }
  43717. }
  43718. function resolveExt(filename, fs) {
  43719. filename = filename.replace(/\.js$/, "");
  43720. const tryResolve = (filename2) => {
  43721. if (fs.fileExists(filename2))
  43722. return filename2;
  43723. };
  43724. return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
  43725. }
  43726. const tsConfigCache = createCache();
  43727. const tsConfigRefMap = /* @__PURE__ */ new Map();
  43728. const fileToScopeCache = createCache();
  43729. function invalidateTypeCache(filename) {
  43730. filename = normalizePath(filename);
  43731. fileToScopeCache.delete(filename);
  43732. tsConfigCache.delete(filename);
  43733. const affectedConfig = tsConfigRefMap.get(filename);
  43734. if (affectedConfig)
  43735. tsConfigCache.delete(affectedConfig);
  43736. }
  43737. function fileToScope(ctx, filename, asGlobal = false) {
  43738. const cached = fileToScopeCache.get(filename);
  43739. if (cached) {
  43740. return cached;
  43741. }
  43742. const fs = resolveFS(ctx);
  43743. const source = fs.readFile(filename) || "";
  43744. const body = parseFile(filename, source, ctx.options.babelParserPlugins);
  43745. const scope = new TypeScope(filename, source, 0, recordImports(body));
  43746. recordTypes(ctx, body, scope, asGlobal);
  43747. fileToScopeCache.set(filename, scope);
  43748. return scope;
  43749. }
  43750. function parseFile(filename, content, parserPlugins) {
  43751. const ext = extname(filename);
  43752. if (ext === ".ts" || ext === ".tsx") {
  43753. return parse_1$1(content, {
  43754. plugins: resolveParserPlugins(
  43755. ext.slice(1),
  43756. parserPlugins,
  43757. filename.endsWith(".d.ts")
  43758. ),
  43759. sourceType: "module"
  43760. }).program.body;
  43761. } else if (ext === ".vue") {
  43762. const {
  43763. descriptor: { script, scriptSetup }
  43764. } = parse$7(content);
  43765. if (!script && !scriptSetup) {
  43766. return [];
  43767. }
  43768. const scriptOffset = script ? script.loc.start.offset : Infinity;
  43769. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  43770. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  43771. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  43772. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  43773. if (secondBlock) {
  43774. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  43775. }
  43776. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  43777. return parse_1$1(scriptContent, {
  43778. plugins: resolveParserPlugins(lang, parserPlugins),
  43779. sourceType: "module"
  43780. }).program.body;
  43781. }
  43782. return [];
  43783. }
  43784. function ctxToScope(ctx) {
  43785. if (ctx.scope) {
  43786. return ctx.scope;
  43787. }
  43788. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  43789. const scope = new TypeScope(
  43790. ctx.filename,
  43791. ctx.source,
  43792. "startOffset" in ctx ? ctx.startOffset : 0,
  43793. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  43794. );
  43795. recordTypes(ctx, body, scope);
  43796. return ctx.scope = scope;
  43797. }
  43798. function moduleDeclToScope(ctx, node, parentScope) {
  43799. if (node._resolvedChildScope) {
  43800. return node._resolvedChildScope;
  43801. }
  43802. const scope = createChildScope(parentScope);
  43803. if (node.body.type === "TSModuleDeclaration") {
  43804. const decl = node.body;
  43805. decl._ownerScope = scope;
  43806. const id = getId(decl.id);
  43807. scope.types[id] = scope.exportedTypes[id] = decl;
  43808. } else {
  43809. recordTypes(ctx, node.body.body, scope);
  43810. }
  43811. return node._resolvedChildScope = scope;
  43812. }
  43813. function createChildScope(parentScope) {
  43814. return new TypeScope(
  43815. parentScope.filename,
  43816. parentScope.source,
  43817. parentScope.offset,
  43818. Object.create(parentScope.imports),
  43819. Object.create(parentScope.types),
  43820. Object.create(parentScope.declares)
  43821. );
  43822. }
  43823. const importExportRE = /^Import|^Export/;
  43824. function recordTypes(ctx, body, scope, asGlobal = false) {
  43825. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  43826. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  43827. for (const stmt of body) {
  43828. if (asGlobal) {
  43829. if (isAmbient) {
  43830. if (stmt.declare) {
  43831. recordType(stmt, types, declares);
  43832. }
  43833. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  43834. for (const s of stmt.body.body) {
  43835. recordType(s, types, declares);
  43836. }
  43837. }
  43838. } else {
  43839. recordType(stmt, types, declares);
  43840. }
  43841. }
  43842. if (!asGlobal) {
  43843. for (const stmt of body) {
  43844. if (stmt.type === "ExportNamedDeclaration") {
  43845. if (stmt.declaration) {
  43846. recordType(stmt.declaration, types, declares);
  43847. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  43848. } else {
  43849. for (const spec of stmt.specifiers) {
  43850. if (spec.type === "ExportSpecifier") {
  43851. const local = spec.local.name;
  43852. const exported = getId(spec.exported);
  43853. if (stmt.source) {
  43854. imports[exported] = {
  43855. source: stmt.source.value,
  43856. imported: local
  43857. };
  43858. exportedTypes[exported] = {
  43859. type: "TSTypeReference",
  43860. typeName: {
  43861. type: "Identifier",
  43862. name: local
  43863. },
  43864. _ownerScope: scope
  43865. };
  43866. } else if (types[local]) {
  43867. exportedTypes[exported] = types[local];
  43868. }
  43869. }
  43870. }
  43871. }
  43872. } else if (stmt.type === "ExportAllDeclaration") {
  43873. const sourceScope = importSourceToScope(
  43874. ctx,
  43875. stmt.source,
  43876. scope,
  43877. stmt.source.value
  43878. );
  43879. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  43880. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  43881. if (stmt.declaration.type !== "Identifier") {
  43882. recordType(stmt.declaration, types, declares, "default");
  43883. recordType(
  43884. stmt.declaration,
  43885. exportedTypes,
  43886. exportedDeclares,
  43887. "default"
  43888. );
  43889. } else if (types[stmt.declaration.name]) {
  43890. exportedTypes["default"] = types[stmt.declaration.name];
  43891. }
  43892. }
  43893. }
  43894. }
  43895. for (const key of Object.keys(types)) {
  43896. const node = types[key];
  43897. node._ownerScope = scope;
  43898. if (node._ns)
  43899. node._ns._ownerScope = scope;
  43900. }
  43901. for (const key of Object.keys(declares)) {
  43902. declares[key]._ownerScope = scope;
  43903. }
  43904. }
  43905. function recordType(node, types, declares, overwriteId) {
  43906. switch (node.type) {
  43907. case "TSInterfaceDeclaration":
  43908. case "TSEnumDeclaration":
  43909. case "TSModuleDeclaration": {
  43910. const id = overwriteId || getId(node.id);
  43911. let existing = types[id];
  43912. if (existing) {
  43913. if (node.type === "TSModuleDeclaration") {
  43914. if (existing.type === "TSModuleDeclaration") {
  43915. mergeNamespaces(existing, node);
  43916. } else {
  43917. attachNamespace(existing, node);
  43918. }
  43919. break;
  43920. }
  43921. if (existing.type === "TSModuleDeclaration") {
  43922. types[id] = node;
  43923. attachNamespace(node, existing);
  43924. break;
  43925. }
  43926. if (existing.type !== node.type) {
  43927. break;
  43928. }
  43929. if (node.type === "TSInterfaceDeclaration") {
  43930. existing.body.body.push(...node.body.body);
  43931. } else {
  43932. existing.members.push(...node.members);
  43933. }
  43934. } else {
  43935. types[id] = node;
  43936. }
  43937. break;
  43938. }
  43939. case "ClassDeclaration":
  43940. if (overwriteId || node.id)
  43941. types[overwriteId || getId(node.id)] = node;
  43942. break;
  43943. case "TSTypeAliasDeclaration":
  43944. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  43945. break;
  43946. case "TSDeclareFunction":
  43947. if (node.id)
  43948. declares[node.id.name] = node;
  43949. break;
  43950. case "VariableDeclaration": {
  43951. if (node.declare) {
  43952. for (const decl of node.declarations) {
  43953. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  43954. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  43955. }
  43956. }
  43957. }
  43958. break;
  43959. }
  43960. }
  43961. }
  43962. function mergeNamespaces(to, from) {
  43963. const toBody = to.body;
  43964. const fromBody = from.body;
  43965. if (toBody.type === "TSModuleDeclaration") {
  43966. if (fromBody.type === "TSModuleDeclaration") {
  43967. mergeNamespaces(toBody, fromBody);
  43968. } else {
  43969. fromBody.body.push({
  43970. type: "ExportNamedDeclaration",
  43971. declaration: toBody,
  43972. exportKind: "type",
  43973. specifiers: []
  43974. });
  43975. }
  43976. } else if (fromBody.type === "TSModuleDeclaration") {
  43977. toBody.body.push({
  43978. type: "ExportNamedDeclaration",
  43979. declaration: fromBody,
  43980. exportKind: "type",
  43981. specifiers: []
  43982. });
  43983. } else {
  43984. toBody.body.push(...fromBody.body);
  43985. }
  43986. }
  43987. function attachNamespace(to, ns) {
  43988. if (!to._ns) {
  43989. to._ns = ns;
  43990. } else {
  43991. mergeNamespaces(to._ns, ns);
  43992. }
  43993. }
  43994. function recordImports(body) {
  43995. const imports = /* @__PURE__ */ Object.create(null);
  43996. for (const s of body) {
  43997. recordImport(s, imports);
  43998. }
  43999. return imports;
  44000. }
  44001. function recordImport(node, imports) {
  44002. if (node.type !== "ImportDeclaration") {
  44003. return;
  44004. }
  44005. for (const s of node.specifiers) {
  44006. imports[s.local.name] = {
  44007. imported: getImportedName(s),
  44008. source: node.source.value
  44009. };
  44010. }
  44011. }
  44012. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)) {
  44013. try {
  44014. switch (node.type) {
  44015. case "TSStringKeyword":
  44016. return ["String"];
  44017. case "TSNumberKeyword":
  44018. return ["Number"];
  44019. case "TSBooleanKeyword":
  44020. return ["Boolean"];
  44021. case "TSObjectKeyword":
  44022. return ["Object"];
  44023. case "TSNullKeyword":
  44024. return ["null"];
  44025. case "TSTypeLiteral":
  44026. case "TSInterfaceDeclaration": {
  44027. const types = /* @__PURE__ */ new Set();
  44028. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  44029. for (const m of members) {
  44030. if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  44031. types.add("Function");
  44032. } else {
  44033. types.add("Object");
  44034. }
  44035. }
  44036. return types.size ? Array.from(types) : ["Object"];
  44037. }
  44038. case "TSPropertySignature":
  44039. if (node.typeAnnotation) {
  44040. return inferRuntimeType(
  44041. ctx,
  44042. node.typeAnnotation.typeAnnotation,
  44043. scope
  44044. );
  44045. }
  44046. break;
  44047. case "TSMethodSignature":
  44048. case "TSFunctionType":
  44049. return ["Function"];
  44050. case "TSArrayType":
  44051. case "TSTupleType":
  44052. return ["Array"];
  44053. case "TSLiteralType":
  44054. switch (node.literal.type) {
  44055. case "StringLiteral":
  44056. return ["String"];
  44057. case "BooleanLiteral":
  44058. return ["Boolean"];
  44059. case "NumericLiteral":
  44060. case "BigIntLiteral":
  44061. return ["Number"];
  44062. default:
  44063. return [UNKNOWN_TYPE];
  44064. }
  44065. case "TSTypeReference": {
  44066. const resolved = resolveTypeReference(ctx, node, scope);
  44067. if (resolved) {
  44068. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  44069. }
  44070. if (node.typeName.type === "Identifier") {
  44071. switch (node.typeName.name) {
  44072. case "Array":
  44073. case "Function":
  44074. case "Object":
  44075. case "Set":
  44076. case "Map":
  44077. case "WeakSet":
  44078. case "WeakMap":
  44079. case "Date":
  44080. case "Promise":
  44081. case "Error":
  44082. return [node.typeName.name];
  44083. case "Partial":
  44084. case "Required":
  44085. case "Readonly":
  44086. case "Record":
  44087. case "Pick":
  44088. case "Omit":
  44089. case "InstanceType":
  44090. return ["Object"];
  44091. case "Uppercase":
  44092. case "Lowercase":
  44093. case "Capitalize":
  44094. case "Uncapitalize":
  44095. return ["String"];
  44096. case "Parameters":
  44097. case "ConstructorParameters":
  44098. return ["Array"];
  44099. case "NonNullable":
  44100. if (node.typeParameters && node.typeParameters.params[0]) {
  44101. return inferRuntimeType(
  44102. ctx,
  44103. node.typeParameters.params[0],
  44104. scope
  44105. ).filter((t) => t !== "null");
  44106. }
  44107. break;
  44108. case "Extract":
  44109. if (node.typeParameters && node.typeParameters.params[1]) {
  44110. return inferRuntimeType(
  44111. ctx,
  44112. node.typeParameters.params[1],
  44113. scope
  44114. );
  44115. }
  44116. break;
  44117. case "Exclude":
  44118. case "OmitThisParameter":
  44119. if (node.typeParameters && node.typeParameters.params[0]) {
  44120. return inferRuntimeType(
  44121. ctx,
  44122. node.typeParameters.params[0],
  44123. scope
  44124. );
  44125. }
  44126. break;
  44127. }
  44128. }
  44129. break;
  44130. }
  44131. case "TSParenthesizedType":
  44132. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  44133. case "TSUnionType":
  44134. return flattenTypes(ctx, node.types, scope);
  44135. case "TSIntersectionType": {
  44136. return flattenTypes(ctx, node.types, scope).filter(
  44137. (t) => t !== UNKNOWN_TYPE
  44138. );
  44139. }
  44140. case "TSEnumDeclaration":
  44141. return inferEnumType(node);
  44142. case "TSSymbolKeyword":
  44143. return ["Symbol"];
  44144. case "TSIndexedAccessType": {
  44145. const types = resolveIndexType(ctx, node, scope);
  44146. return flattenTypes(ctx, types, scope);
  44147. }
  44148. case "ClassDeclaration":
  44149. return ["Object"];
  44150. case "TSImportType": {
  44151. const sourceScope = importSourceToScope(
  44152. ctx,
  44153. node.argument,
  44154. scope,
  44155. node.argument.value
  44156. );
  44157. const resolved = resolveTypeReference(ctx, node, sourceScope);
  44158. if (resolved) {
  44159. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  44160. }
  44161. break;
  44162. }
  44163. case "TSTypeQuery": {
  44164. const id = node.exprName;
  44165. if (id.type === "Identifier") {
  44166. const matched = scope.declares[id.name];
  44167. if (matched) {
  44168. return inferRuntimeType(ctx, matched, matched._ownerScope);
  44169. }
  44170. }
  44171. break;
  44172. }
  44173. }
  44174. } catch (e) {
  44175. }
  44176. return [UNKNOWN_TYPE];
  44177. }
  44178. function flattenTypes(ctx, types, scope) {
  44179. if (types.length === 1) {
  44180. return inferRuntimeType(ctx, types[0], scope);
  44181. }
  44182. return [
  44183. ...new Set(
  44184. [].concat(
  44185. ...types.map((t) => inferRuntimeType(ctx, t, scope))
  44186. )
  44187. )
  44188. ];
  44189. }
  44190. function inferEnumType(node) {
  44191. const types = /* @__PURE__ */ new Set();
  44192. for (const m of node.members) {
  44193. if (m.initializer) {
  44194. switch (m.initializer.type) {
  44195. case "StringLiteral":
  44196. types.add("String");
  44197. break;
  44198. case "NumericLiteral":
  44199. types.add("Number");
  44200. break;
  44201. }
  44202. }
  44203. }
  44204. return types.size ? [...types] : ["Number"];
  44205. }
  44206. function resolveExtractPropTypes({ props }, scope) {
  44207. const res = { props: {} };
  44208. for (const key in props) {
  44209. const raw = props[key];
  44210. res.props[key] = reverseInferType(
  44211. raw.key,
  44212. raw.typeAnnotation.typeAnnotation,
  44213. scope
  44214. );
  44215. }
  44216. return res;
  44217. }
  44218. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  44219. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  44220. const typeType = findStaticPropertyType(node, "type");
  44221. if (typeType) {
  44222. const requiredType = findStaticPropertyType(node, "required");
  44223. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  44224. return reverseInferType(key, typeType, scope, optional2, false);
  44225. }
  44226. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  44227. if (node.typeName.name.endsWith("Constructor")) {
  44228. return createProperty(
  44229. key,
  44230. ctorToType(node.typeName.name),
  44231. scope,
  44232. optional
  44233. );
  44234. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  44235. return createProperty(key, node.typeParameters.params[0], scope, optional);
  44236. }
  44237. }
  44238. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  44239. for (const t of node.typeParameters.params) {
  44240. const inferred = reverseInferType(key, t, scope, optional);
  44241. if (inferred)
  44242. return inferred;
  44243. }
  44244. }
  44245. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  44246. }
  44247. function ctorToType(ctorType) {
  44248. const ctor = ctorType.slice(0, -11);
  44249. switch (ctor) {
  44250. case "String":
  44251. case "Number":
  44252. case "Boolean":
  44253. return { type: `TS${ctor}Keyword` };
  44254. case "Array":
  44255. case "Function":
  44256. case "Object":
  44257. case "Set":
  44258. case "Map":
  44259. case "WeakSet":
  44260. case "WeakMap":
  44261. case "Date":
  44262. case "Promise":
  44263. return {
  44264. type: "TSTypeReference",
  44265. typeName: { type: "Identifier", name: ctor }
  44266. };
  44267. }
  44268. return { type: `TSNullKeyword` };
  44269. }
  44270. function findStaticPropertyType(node, key) {
  44271. const prop = node.members.find(
  44272. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  44273. );
  44274. return prop && prop.typeAnnotation.typeAnnotation;
  44275. }
  44276. function resolveReturnType(ctx, arg, scope) {
  44277. var _a;
  44278. let resolved = arg;
  44279. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  44280. resolved = resolveTypeReference(ctx, arg, scope);
  44281. }
  44282. if (!resolved)
  44283. return;
  44284. if (resolved.type === "TSFunctionType") {
  44285. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  44286. }
  44287. if (resolved.type === "TSDeclareFunction") {
  44288. return resolved.returnType;
  44289. }
  44290. }
  44291. function resolveUnionType(ctx, node, scope) {
  44292. if (node.type === "TSTypeReference") {
  44293. const resolved = resolveTypeReference(ctx, node, scope);
  44294. if (resolved)
  44295. node = resolved;
  44296. }
  44297. let types;
  44298. if (node.type === "TSUnionType") {
  44299. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  44300. } else {
  44301. types = [node];
  44302. }
  44303. return types;
  44304. }
  44305. const DEFINE_MODEL = "defineModel";
  44306. function processDefineModel(ctx, node, declId) {
  44307. if (!isCallOf(node, DEFINE_MODEL)) {
  44308. return false;
  44309. }
  44310. ctx.hasDefineModelCall = true;
  44311. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  44312. let modelName;
  44313. let options;
  44314. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  44315. const hasName = arg0 && arg0.type === "StringLiteral";
  44316. if (hasName) {
  44317. modelName = arg0.value;
  44318. options = node.arguments[1];
  44319. } else {
  44320. modelName = "modelValue";
  44321. options = arg0;
  44322. }
  44323. if (ctx.modelDecls[modelName]) {
  44324. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  44325. }
  44326. let optionsString = options && ctx.getString(options);
  44327. let optionsRemoved = !options;
  44328. const runtimeOptionNodes = [];
  44329. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  44330. let removed = 0;
  44331. for (let i = options.properties.length - 1; i >= 0; i--) {
  44332. const p = options.properties[i];
  44333. const next = options.properties[i + 1];
  44334. const start = p.start;
  44335. const end = next ? next.start : options.end - 1;
  44336. if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
  44337. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  44338. } else {
  44339. removed++;
  44340. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  44341. runtimeOptionNodes.push(p);
  44342. }
  44343. }
  44344. if (removed === options.properties.length) {
  44345. optionsRemoved = true;
  44346. ctx.s.remove(
  44347. ctx.startOffset + (hasName ? arg0.end : options.start),
  44348. ctx.startOffset + options.end
  44349. );
  44350. }
  44351. }
  44352. ctx.modelDecls[modelName] = {
  44353. type,
  44354. options: optionsString,
  44355. runtimeOptionNodes,
  44356. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  44357. };
  44358. ctx.bindingMetadata[modelName] = "props";
  44359. ctx.s.overwrite(
  44360. ctx.startOffset + node.callee.start,
  44361. ctx.startOffset + node.callee.end,
  44362. ctx.helper("useModel")
  44363. );
  44364. ctx.s.appendLeft(
  44365. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  44366. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  44367. );
  44368. return true;
  44369. }
  44370. function genModelProps(ctx) {
  44371. if (!ctx.hasDefineModelCall)
  44372. return;
  44373. const isProd = !!ctx.options.isProd;
  44374. let modelPropsDecl = "";
  44375. for (const [name, { type, options }] of Object.entries(ctx.modelDecls)) {
  44376. let skipCheck = false;
  44377. let runtimeTypes = type && inferRuntimeType(ctx, type);
  44378. if (runtimeTypes) {
  44379. const hasBoolean = runtimeTypes.includes("Boolean");
  44380. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  44381. if (isProd || hasUnknownType) {
  44382. runtimeTypes = runtimeTypes.filter(
  44383. (t) => t === "Boolean" || hasBoolean && t === "String" || t === "Function" && options
  44384. );
  44385. skipCheck = !isProd && hasUnknownType && runtimeTypes.length > 0;
  44386. }
  44387. }
  44388. let runtimeType = runtimeTypes && runtimeTypes.length > 0 && toRuntimeTypeString(runtimeTypes) || void 0;
  44389. const codegenOptions = concatStrings([
  44390. runtimeType && `type: ${runtimeType}`,
  44391. skipCheck && "skipCheck: true"
  44392. ]);
  44393. let decl;
  44394. if (runtimeType && options) {
  44395. decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
  44396. } else {
  44397. decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
  44398. }
  44399. modelPropsDecl += `
  44400. ${JSON.stringify(name)}: ${decl},`;
  44401. const modifierPropName = JSON.stringify(
  44402. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  44403. );
  44404. modelPropsDecl += `
  44405. ${modifierPropName}: {},`;
  44406. }
  44407. return `{${modelPropsDecl}
  44408. }`;
  44409. }
  44410. const DEFINE_PROPS = "defineProps";
  44411. const WITH_DEFAULTS = "withDefaults";
  44412. function processDefineProps(ctx, node, declId) {
  44413. if (!isCallOf(node, DEFINE_PROPS)) {
  44414. return processWithDefaults(ctx, node, declId);
  44415. }
  44416. if (ctx.hasDefinePropsCall) {
  44417. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  44418. }
  44419. ctx.hasDefinePropsCall = true;
  44420. ctx.propsRuntimeDecl = node.arguments[0];
  44421. if (ctx.propsRuntimeDecl) {
  44422. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  44423. if (!(key in ctx.bindingMetadata)) {
  44424. ctx.bindingMetadata[key] = "props";
  44425. }
  44426. }
  44427. }
  44428. if (node.typeParameters) {
  44429. if (ctx.propsRuntimeDecl) {
  44430. ctx.error(
  44431. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  44432. node
  44433. );
  44434. }
  44435. ctx.propsTypeDecl = node.typeParameters.params[0];
  44436. }
  44437. if (declId && declId.type === "ObjectPattern") {
  44438. processPropsDestructure(ctx, declId);
  44439. }
  44440. ctx.propsCall = node;
  44441. ctx.propsDecl = declId;
  44442. return true;
  44443. }
  44444. function processWithDefaults(ctx, node, declId) {
  44445. if (!isCallOf(node, WITH_DEFAULTS)) {
  44446. return false;
  44447. }
  44448. if (!processDefineProps(ctx, node.arguments[0], declId)) {
  44449. ctx.error(
  44450. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  44451. node.arguments[0] || node
  44452. );
  44453. }
  44454. if (ctx.propsRuntimeDecl) {
  44455. ctx.error(
  44456. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  44457. node
  44458. );
  44459. }
  44460. if (ctx.propsDestructureDecl) {
  44461. ctx.error(
  44462. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  44463. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
  44464. node.callee
  44465. );
  44466. }
  44467. ctx.propsRuntimeDefaults = node.arguments[1];
  44468. if (!ctx.propsRuntimeDefaults) {
  44469. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  44470. }
  44471. ctx.propsCall = node;
  44472. return true;
  44473. }
  44474. function genRuntimeProps(ctx) {
  44475. let propsDecls;
  44476. if (ctx.propsRuntimeDecl) {
  44477. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  44478. if (ctx.propsDestructureDecl) {
  44479. const defaults = [];
  44480. for (const key in ctx.propsDestructuredBindings) {
  44481. const d = genDestructuredDefaultValue(ctx, key);
  44482. const finalKey = getEscapedPropName(key);
  44483. if (d)
  44484. defaults.push(
  44485. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  44486. );
  44487. }
  44488. if (defaults.length) {
  44489. propsDecls = `/*#__PURE__*/${ctx.helper(
  44490. `mergeDefaults`
  44491. )}(${propsDecls}, {
  44492. ${defaults.join(",\n ")}
  44493. })`;
  44494. }
  44495. }
  44496. } else if (ctx.propsTypeDecl) {
  44497. propsDecls = extractRuntimeProps(ctx);
  44498. }
  44499. const modelsDecls = genModelProps(ctx);
  44500. if (propsDecls && modelsDecls) {
  44501. return `/*#__PURE__*/${ctx.helper(
  44502. "mergeModels"
  44503. )}(${propsDecls}, ${modelsDecls})`;
  44504. } else {
  44505. return modelsDecls || propsDecls;
  44506. }
  44507. }
  44508. function extractRuntimeProps(ctx) {
  44509. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  44510. if (!props.length) {
  44511. return;
  44512. }
  44513. const propStrings = [];
  44514. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  44515. for (const prop of props) {
  44516. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  44517. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  44518. ctx.bindingMetadata[prop.key] = "props";
  44519. }
  44520. }
  44521. let propsDecls = `{
  44522. ${propStrings.join(",\n ")}
  44523. }`;
  44524. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  44525. propsDecls = `/*#__PURE__*/${ctx.helper(
  44526. "mergeDefaults"
  44527. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  44528. }
  44529. return propsDecls;
  44530. }
  44531. function resolveRuntimePropsFromType(ctx, node) {
  44532. const props = [];
  44533. const elements = resolveTypeElements(ctx, node);
  44534. for (const key in elements.props) {
  44535. const e = elements.props[key];
  44536. let type = inferRuntimeType(ctx, e);
  44537. let skipCheck = false;
  44538. if (type.includes(UNKNOWN_TYPE)) {
  44539. if (type.includes("Boolean") || type.includes("Function")) {
  44540. type = type.filter((t) => t !== UNKNOWN_TYPE);
  44541. skipCheck = true;
  44542. } else {
  44543. type = ["null"];
  44544. }
  44545. }
  44546. props.push({
  44547. key,
  44548. required: !e.optional,
  44549. type: type || [`null`],
  44550. skipCheck
  44551. });
  44552. }
  44553. return props;
  44554. }
  44555. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  44556. let defaultString;
  44557. const destructured = genDestructuredDefaultValue(ctx, key, type);
  44558. if (destructured) {
  44559. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  44560. } else if (hasStaticDefaults) {
  44561. const prop = ctx.propsRuntimeDefaults.properties.find(
  44562. (node) => {
  44563. if (node.type === "SpreadElement")
  44564. return false;
  44565. return resolveObjectKey(node.key, node.computed) === key;
  44566. }
  44567. );
  44568. if (prop) {
  44569. if (prop.type === "ObjectProperty") {
  44570. defaultString = `default: ${ctx.getString(prop.value)}`;
  44571. } else {
  44572. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  44573. }
  44574. }
  44575. }
  44576. const finalKey = getEscapedPropName(key);
  44577. if (!ctx.options.isProd) {
  44578. return `${finalKey}: { ${concatStrings([
  44579. `type: ${toRuntimeTypeString(type)}`,
  44580. `required: ${required}`,
  44581. skipCheck && "skipCheck: true",
  44582. defaultString
  44583. ])} }`;
  44584. } else if (type.some(
  44585. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  44586. )) {
  44587. return `${finalKey}: { ${concatStrings([
  44588. `type: ${toRuntimeTypeString(type)}`,
  44589. defaultString
  44590. ])} }`;
  44591. } else {
  44592. if (ctx.isCE) {
  44593. if (defaultString) {
  44594. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  44595. type
  44596. )} }`}`;
  44597. } else {
  44598. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  44599. }
  44600. }
  44601. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  44602. }
  44603. }
  44604. function hasStaticWithDefaults(ctx) {
  44605. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  44606. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  44607. ));
  44608. }
  44609. function genDestructuredDefaultValue(ctx, key, inferredType) {
  44610. const destructured = ctx.propsDestructuredBindings[key];
  44611. const defaultVal = destructured && destructured.default;
  44612. if (defaultVal) {
  44613. const value = ctx.getString(defaultVal);
  44614. const unwrapped = unwrapTSNode(defaultVal);
  44615. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  44616. const valueType = inferValueType(unwrapped);
  44617. if (valueType && !inferredType.includes(valueType)) {
  44618. ctx.error(
  44619. `Default value of prop "${key}" does not match declared type.`,
  44620. unwrapped
  44621. );
  44622. }
  44623. }
  44624. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  44625. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  44626. return {
  44627. valueString: needFactoryWrap ? `() => (${value})` : value,
  44628. needSkipFactory
  44629. };
  44630. }
  44631. }
  44632. function inferValueType(node) {
  44633. switch (node.type) {
  44634. case "StringLiteral":
  44635. return "String";
  44636. case "NumericLiteral":
  44637. return "Number";
  44638. case "BooleanLiteral":
  44639. return "Boolean";
  44640. case "ObjectExpression":
  44641. return "Object";
  44642. case "ArrayExpression":
  44643. return "Array";
  44644. case "FunctionExpression":
  44645. case "ArrowFunctionExpression":
  44646. return "Function";
  44647. }
  44648. }
  44649. function processPropsDestructure(ctx, declId) {
  44650. if (!ctx.options.propsDestructure) {
  44651. return;
  44652. }
  44653. warnOnce$3(
  44654. `This project is using reactive props destructure, which is an experimental feature. It may receive breaking changes or be removed in the future, so use at your own risk.
  44655. To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
  44656. );
  44657. ctx.propsDestructureDecl = declId;
  44658. const registerBinding = (key, local, defaultValue) => {
  44659. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  44660. if (local !== key) {
  44661. ctx.bindingMetadata[local] = "props-aliased";
  44662. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  44663. }
  44664. };
  44665. for (const prop of declId.properties) {
  44666. if (prop.type === "ObjectProperty") {
  44667. const propKey = resolveObjectKey(prop.key, prop.computed);
  44668. if (!propKey) {
  44669. ctx.error(
  44670. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  44671. prop.key
  44672. );
  44673. }
  44674. if (prop.value.type === "AssignmentPattern") {
  44675. const { left, right } = prop.value;
  44676. if (left.type !== "Identifier") {
  44677. ctx.error(
  44678. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44679. left
  44680. );
  44681. }
  44682. registerBinding(propKey, left.name, right);
  44683. } else if (prop.value.type === "Identifier") {
  44684. registerBinding(propKey, prop.value.name);
  44685. } else {
  44686. ctx.error(
  44687. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44688. prop.value
  44689. );
  44690. }
  44691. } else {
  44692. ctx.propsDestructureRestId = prop.argument.name;
  44693. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  44694. }
  44695. }
  44696. }
  44697. function transformDestructuredProps(ctx, vueImportAliases) {
  44698. if (!ctx.options.propsDestructure) {
  44699. return;
  44700. }
  44701. const rootScope = {};
  44702. const scopeStack = [rootScope];
  44703. let currentScope = rootScope;
  44704. const excludedIds = /* @__PURE__ */ new WeakSet();
  44705. const parentStack = [];
  44706. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  44707. for (const key in ctx.propsDestructuredBindings) {
  44708. const { local } = ctx.propsDestructuredBindings[key];
  44709. rootScope[local] = true;
  44710. propsLocalToPublicMap[local] = key;
  44711. }
  44712. function pushScope() {
  44713. scopeStack.push(currentScope = Object.create(currentScope));
  44714. }
  44715. function popScope() {
  44716. scopeStack.pop();
  44717. currentScope = scopeStack[scopeStack.length - 1] || null;
  44718. }
  44719. function registerLocalBinding(id) {
  44720. excludedIds.add(id);
  44721. if (currentScope) {
  44722. currentScope[id.name] = false;
  44723. } else {
  44724. ctx.error(
  44725. "registerBinding called without active scope, something is wrong.",
  44726. id
  44727. );
  44728. }
  44729. }
  44730. function walkScope(node, isRoot = false) {
  44731. for (const stmt of node.body) {
  44732. if (stmt.type === "VariableDeclaration") {
  44733. walkVariableDeclaration(stmt, isRoot);
  44734. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  44735. if (stmt.declare || !stmt.id)
  44736. continue;
  44737. registerLocalBinding(stmt.id);
  44738. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  44739. walkVariableDeclaration(stmt.left);
  44740. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  44741. walkVariableDeclaration(stmt.declaration, isRoot);
  44742. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  44743. walkVariableDeclaration(stmt.body, isRoot);
  44744. }
  44745. }
  44746. }
  44747. function walkVariableDeclaration(stmt, isRoot = false) {
  44748. if (stmt.declare) {
  44749. return;
  44750. }
  44751. for (const decl of stmt.declarations) {
  44752. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  44753. for (const id of extractIdentifiers$1(decl.id)) {
  44754. if (isDefineProps) {
  44755. excludedIds.add(id);
  44756. } else {
  44757. registerLocalBinding(id);
  44758. }
  44759. }
  44760. }
  44761. }
  44762. function rewriteId(id, parent, parentStack2) {
  44763. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  44764. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  44765. }
  44766. if (isStaticProperty(parent) && parent.shorthand) {
  44767. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  44768. ctx.s.appendLeft(
  44769. id.end + ctx.startOffset,
  44770. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  44771. );
  44772. }
  44773. } else {
  44774. ctx.s.overwrite(
  44775. id.start + ctx.startOffset,
  44776. id.end + ctx.startOffset,
  44777. genPropsAccessExp(propsLocalToPublicMap[id.name])
  44778. );
  44779. }
  44780. }
  44781. function checkUsage(node, method, alias = method) {
  44782. if (isCallOf(node, alias)) {
  44783. const arg = unwrapTSNode(node.arguments[0]);
  44784. if (arg.type === "Identifier" && currentScope[arg.name]) {
  44785. ctx.error(
  44786. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  44787. arg
  44788. );
  44789. }
  44790. }
  44791. }
  44792. const ast = ctx.scriptSetupAst;
  44793. walkScope(ast, true);
  44794. walk$2(ast, {
  44795. enter(node, parent) {
  44796. parent && parentStack.push(parent);
  44797. if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
  44798. return this.skip();
  44799. }
  44800. checkUsage(node, "watch", vueImportAliases.watch);
  44801. checkUsage(node, "toRef", vueImportAliases.toRef);
  44802. if (isFunctionType(node)) {
  44803. pushScope();
  44804. walkFunctionParams(node, registerLocalBinding);
  44805. if (node.body.type === "BlockStatement") {
  44806. walkScope(node.body);
  44807. }
  44808. return;
  44809. }
  44810. if (node.type === "CatchClause") {
  44811. pushScope();
  44812. if (node.param && node.param.type === "Identifier") {
  44813. registerLocalBinding(node.param);
  44814. }
  44815. walkScope(node.body);
  44816. return;
  44817. }
  44818. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  44819. pushScope();
  44820. walkScope(node);
  44821. return;
  44822. }
  44823. if (node.type === "Identifier") {
  44824. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  44825. if (currentScope[node.name]) {
  44826. rewriteId(node, parent, parentStack);
  44827. }
  44828. }
  44829. }
  44830. },
  44831. leave(node, parent) {
  44832. parent && parentStack.pop();
  44833. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node)) {
  44834. popScope();
  44835. }
  44836. }
  44837. });
  44838. }
  44839. const DEFINE_EMITS = "defineEmits";
  44840. function processDefineEmits(ctx, node, declId) {
  44841. if (!isCallOf(node, DEFINE_EMITS)) {
  44842. return false;
  44843. }
  44844. if (ctx.hasDefineEmitCall) {
  44845. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  44846. }
  44847. ctx.hasDefineEmitCall = true;
  44848. ctx.emitsRuntimeDecl = node.arguments[0];
  44849. if (node.typeParameters) {
  44850. if (ctx.emitsRuntimeDecl) {
  44851. ctx.error(
  44852. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  44853. node
  44854. );
  44855. }
  44856. ctx.emitsTypeDecl = node.typeParameters.params[0];
  44857. }
  44858. ctx.emitDecl = declId;
  44859. return true;
  44860. }
  44861. function genRuntimeEmits(ctx) {
  44862. let emitsDecl = "";
  44863. if (ctx.emitsRuntimeDecl) {
  44864. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  44865. } else if (ctx.emitsTypeDecl) {
  44866. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  44867. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  44868. }
  44869. if (ctx.hasDefineModelCall) {
  44870. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  44871. emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
  44872. "mergeModels"
  44873. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  44874. }
  44875. return emitsDecl;
  44876. }
  44877. function extractRuntimeEmits(ctx) {
  44878. const emits = /* @__PURE__ */ new Set();
  44879. const node = ctx.emitsTypeDecl;
  44880. if (node.type === "TSFunctionType") {
  44881. extractEventNames(ctx, node.parameters[0], emits);
  44882. return emits;
  44883. }
  44884. const { props, calls } = resolveTypeElements(ctx, node);
  44885. let hasProperty = false;
  44886. for (const key in props) {
  44887. emits.add(key);
  44888. hasProperty = true;
  44889. }
  44890. if (calls) {
  44891. if (hasProperty) {
  44892. ctx.error(
  44893. `defineEmits() type cannot mixed call signature and property syntax.`,
  44894. node
  44895. );
  44896. }
  44897. for (const call of calls) {
  44898. extractEventNames(ctx, call.parameters[0], emits);
  44899. }
  44900. }
  44901. return emits;
  44902. }
  44903. function extractEventNames(ctx, eventName, emits) {
  44904. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  44905. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  44906. for (const type of types) {
  44907. if (type.type === "TSLiteralType") {
  44908. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  44909. emits.add(String(type.literal.value));
  44910. }
  44911. }
  44912. }
  44913. }
  44914. }
  44915. const DEFINE_EXPOSE = "defineExpose";
  44916. function processDefineExpose(ctx, node) {
  44917. if (isCallOf(node, DEFINE_EXPOSE)) {
  44918. if (ctx.hasDefineExposeCall) {
  44919. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  44920. }
  44921. ctx.hasDefineExposeCall = true;
  44922. return true;
  44923. }
  44924. return false;
  44925. }
  44926. const DEFINE_SLOTS = "defineSlots";
  44927. function processDefineSlots(ctx, node, declId) {
  44928. if (!isCallOf(node, DEFINE_SLOTS)) {
  44929. return false;
  44930. }
  44931. if (ctx.hasDefineSlotsCall) {
  44932. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  44933. }
  44934. ctx.hasDefineSlotsCall = true;
  44935. if (node.arguments.length > 0) {
  44936. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  44937. }
  44938. if (declId) {
  44939. ctx.s.overwrite(
  44940. ctx.startOffset + node.start,
  44941. ctx.startOffset + node.end,
  44942. `${ctx.helper("useSlots")}()`
  44943. );
  44944. }
  44945. return true;
  44946. }
  44947. const DEFINE_OPTIONS = "defineOptions";
  44948. function processDefineOptions(ctx, node) {
  44949. if (!isCallOf(node, DEFINE_OPTIONS)) {
  44950. return false;
  44951. }
  44952. if (ctx.hasDefineOptionsCall) {
  44953. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  44954. }
  44955. if (node.typeParameters) {
  44956. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  44957. }
  44958. if (!node.arguments[0])
  44959. return true;
  44960. ctx.hasDefineOptionsCall = true;
  44961. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  44962. let propsOption = void 0;
  44963. let emitsOption = void 0;
  44964. let exposeOption = void 0;
  44965. let slotsOption = void 0;
  44966. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  44967. for (const prop of ctx.optionsRuntimeDecl.properties) {
  44968. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  44969. if (prop.key.name === "props")
  44970. propsOption = prop;
  44971. if (prop.key.name === "emits")
  44972. emitsOption = prop;
  44973. if (prop.key.name === "expose")
  44974. exposeOption = prop;
  44975. if (prop.key.name === "slots")
  44976. slotsOption = prop;
  44977. }
  44978. }
  44979. }
  44980. if (propsOption) {
  44981. ctx.error(
  44982. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  44983. propsOption
  44984. );
  44985. }
  44986. if (emitsOption) {
  44987. ctx.error(
  44988. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  44989. emitsOption
  44990. );
  44991. }
  44992. if (exposeOption) {
  44993. ctx.error(
  44994. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  44995. exposeOption
  44996. );
  44997. }
  44998. if (slotsOption) {
  44999. ctx.error(
  45000. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  45001. slotsOption
  45002. );
  45003. }
  45004. return true;
  45005. }
  45006. function processAwait(ctx, node, needSemi, isStatement) {
  45007. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  45008. const startOffset = ctx.startOffset;
  45009. const argumentStr = ctx.descriptor.source.slice(
  45010. argumentStart + startOffset,
  45011. node.argument.end + startOffset
  45012. );
  45013. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  45014. ctx.s.overwrite(
  45015. node.start + startOffset,
  45016. argumentStart + startOffset,
  45017. `${needSemi ? `;` : ``}(
  45018. ([__temp,__restore] = ${ctx.helper(
  45019. `withAsyncContext`
  45020. )}(${containsNestedAwait ? `async ` : ``}() => `
  45021. );
  45022. ctx.s.appendLeft(
  45023. node.end + startOffset,
  45024. `)),
  45025. ${isStatement ? `` : `__temp = `}await __temp,
  45026. __restore()${isStatement ? `` : `,
  45027. __temp`}
  45028. )`
  45029. );
  45030. }
  45031. var __defProp$1 = Object.defineProperty;
  45032. var __defProps = Object.defineProperties;
  45033. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  45034. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  45035. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  45036. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  45037. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45038. var __spreadValues$1 = (a, b) => {
  45039. for (var prop in b || (b = {}))
  45040. if (__hasOwnProp$1.call(b, prop))
  45041. __defNormalProp$1(a, prop, b[prop]);
  45042. if (__getOwnPropSymbols$1)
  45043. for (var prop of __getOwnPropSymbols$1(b)) {
  45044. if (__propIsEnum$1.call(b, prop))
  45045. __defNormalProp$1(a, prop, b[prop]);
  45046. }
  45047. return a;
  45048. };
  45049. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  45050. function compileScript(sfc, options) {
  45051. var _a, _b, _c;
  45052. if (!options.id) {
  45053. warnOnce$3(
  45054. `compileScript now requires passing the \`id\` option.
  45055. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  45056. );
  45057. }
  45058. const ctx = new ScriptCompileContext(sfc, options);
  45059. const { script, scriptSetup, source, filename } = sfc;
  45060. const hoistStatic = options.hoistStatic !== false && !script;
  45061. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  45062. const scriptLang = script && script.lang;
  45063. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  45064. if (!scriptSetup) {
  45065. if (!script) {
  45066. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  45067. }
  45068. return processNormalScript(ctx, scopeId);
  45069. }
  45070. if (script && scriptLang !== scriptSetupLang) {
  45071. throw new Error(
  45072. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  45073. );
  45074. }
  45075. if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
  45076. return scriptSetup;
  45077. }
  45078. const scriptBindings = /* @__PURE__ */ Object.create(null);
  45079. const setupBindings = /* @__PURE__ */ Object.create(null);
  45080. let defaultExport;
  45081. let hasAwait = false;
  45082. let hasInlinedSsrRenderFn = false;
  45083. const startOffset = ctx.startOffset;
  45084. const endOffset = ctx.endOffset;
  45085. const scriptStartOffset = script && script.loc.start.offset;
  45086. const scriptEndOffset = script && script.loc.end.offset;
  45087. function hoistNode(node) {
  45088. const start = node.start + startOffset;
  45089. let end = node.end + startOffset;
  45090. if (node.trailingComments && node.trailingComments.length > 0) {
  45091. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  45092. end = lastCommentNode.end + startOffset;
  45093. }
  45094. while (end <= source.length) {
  45095. if (!/\s/.test(source.charAt(end))) {
  45096. break;
  45097. }
  45098. end++;
  45099. }
  45100. ctx.s.move(start, end, 0);
  45101. }
  45102. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  45103. let isUsedInTemplate = needTemplateUsageCheck;
  45104. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  45105. isUsedInTemplate = isImportUsed(local, sfc);
  45106. }
  45107. ctx.userImports[local] = {
  45108. isType,
  45109. imported,
  45110. local,
  45111. source: source2,
  45112. isFromSetup,
  45113. isUsedInTemplate
  45114. };
  45115. }
  45116. function checkInvalidScopeReference(node, method) {
  45117. if (!node)
  45118. return;
  45119. walkIdentifiers(node, (id) => {
  45120. const binding = setupBindings[id.name];
  45121. if (binding && binding !== "literal-const") {
  45122. ctx.error(
  45123. `\`${method}()\` in <script setup> cannot reference locally declared variables because it will be hoisted outside of the setup() function. If your component options require initialization in the module scope, use a separate normal <script> to export the options instead.`,
  45124. id
  45125. );
  45126. }
  45127. });
  45128. }
  45129. const scriptAst = ctx.scriptAst;
  45130. const scriptSetupAst = ctx.scriptSetupAst;
  45131. if (scriptAst) {
  45132. for (const node of scriptAst.body) {
  45133. if (node.type === "ImportDeclaration") {
  45134. for (const specifier of node.specifiers) {
  45135. const imported = getImportedName(specifier);
  45136. registerUserImport(
  45137. node.source.value,
  45138. specifier.local.name,
  45139. imported,
  45140. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45141. false,
  45142. !options.inlineTemplate
  45143. );
  45144. }
  45145. }
  45146. }
  45147. }
  45148. for (const node of scriptSetupAst.body) {
  45149. if (node.type === "ImportDeclaration") {
  45150. hoistNode(node);
  45151. let removed = 0;
  45152. const removeSpecifier = (i) => {
  45153. const removeLeft = i > removed;
  45154. removed++;
  45155. const current = node.specifiers[i];
  45156. const next = node.specifiers[i + 1];
  45157. ctx.s.remove(
  45158. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  45159. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  45160. );
  45161. };
  45162. for (let i = 0; i < node.specifiers.length; i++) {
  45163. const specifier = node.specifiers[i];
  45164. const local = specifier.local.name;
  45165. const imported = getImportedName(specifier);
  45166. const source2 = node.source.value;
  45167. const existing = ctx.userImports[local];
  45168. if (source2 === "vue" && (imported === DEFINE_PROPS || imported === DEFINE_EMITS || imported === DEFINE_EXPOSE)) {
  45169. warnOnce$3(
  45170. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  45171. );
  45172. removeSpecifier(i);
  45173. } else if (existing) {
  45174. if (existing.source === source2 && existing.imported === imported) {
  45175. removeSpecifier(i);
  45176. } else {
  45177. ctx.error(
  45178. `different imports aliased to same local name.`,
  45179. specifier
  45180. );
  45181. }
  45182. } else {
  45183. registerUserImport(
  45184. source2,
  45185. local,
  45186. imported,
  45187. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45188. true,
  45189. !options.inlineTemplate
  45190. );
  45191. }
  45192. }
  45193. if (node.specifiers.length && removed === node.specifiers.length) {
  45194. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45195. }
  45196. }
  45197. }
  45198. const vueImportAliases = {};
  45199. for (const key in ctx.userImports) {
  45200. const { source: source2, imported, local } = ctx.userImports[key];
  45201. if (source2 === "vue")
  45202. vueImportAliases[imported] = local;
  45203. }
  45204. if (script && scriptAst) {
  45205. for (const node of scriptAst.body) {
  45206. if (node.type === "ExportDefaultDeclaration") {
  45207. defaultExport = node;
  45208. let optionProperties;
  45209. if (defaultExport.declaration.type === "ObjectExpression") {
  45210. optionProperties = defaultExport.declaration.properties;
  45211. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  45212. optionProperties = defaultExport.declaration.arguments[0].properties;
  45213. }
  45214. if (optionProperties) {
  45215. for (const p of optionProperties) {
  45216. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  45217. ctx.hasDefaultExportName = true;
  45218. }
  45219. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  45220. ctx.hasDefaultExportRender = true;
  45221. }
  45222. }
  45223. }
  45224. const start = node.start + scriptStartOffset;
  45225. const end = node.declaration.start + scriptStartOffset;
  45226. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  45227. } else if (node.type === "ExportNamedDeclaration") {
  45228. const defaultSpecifier = node.specifiers.find(
  45229. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  45230. );
  45231. if (defaultSpecifier) {
  45232. defaultExport = node;
  45233. if (node.specifiers.length > 1) {
  45234. ctx.s.remove(
  45235. defaultSpecifier.start + scriptStartOffset,
  45236. defaultSpecifier.end + scriptStartOffset
  45237. );
  45238. } else {
  45239. ctx.s.remove(
  45240. node.start + scriptStartOffset,
  45241. node.end + scriptStartOffset
  45242. );
  45243. }
  45244. if (node.source) {
  45245. ctx.s.prepend(
  45246. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  45247. `
  45248. );
  45249. } else {
  45250. ctx.s.appendLeft(
  45251. scriptEndOffset,
  45252. `
  45253. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  45254. `
  45255. );
  45256. }
  45257. }
  45258. if (node.declaration) {
  45259. walkDeclaration(
  45260. "script",
  45261. node.declaration,
  45262. scriptBindings,
  45263. vueImportAliases,
  45264. hoistStatic
  45265. );
  45266. }
  45267. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45268. walkDeclaration(
  45269. "script",
  45270. node,
  45271. scriptBindings,
  45272. vueImportAliases,
  45273. hoistStatic
  45274. );
  45275. }
  45276. }
  45277. if (scriptStartOffset > startOffset) {
  45278. if (!/\n$/.test(script.content.trim())) {
  45279. ctx.s.appendLeft(scriptEndOffset, `
  45280. `);
  45281. }
  45282. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  45283. }
  45284. }
  45285. for (const node of scriptSetupAst.body) {
  45286. if (node.type === "ExpressionStatement") {
  45287. const expr = unwrapTSNode(node.expression);
  45288. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  45289. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45290. } else if (processDefineExpose(ctx, expr)) {
  45291. const callee = expr.callee;
  45292. ctx.s.overwrite(
  45293. callee.start + startOffset,
  45294. callee.end + startOffset,
  45295. "__expose"
  45296. );
  45297. } else {
  45298. processDefineModel(ctx, expr);
  45299. }
  45300. }
  45301. if (node.type === "VariableDeclaration" && !node.declare) {
  45302. const total = node.declarations.length;
  45303. let left = total;
  45304. let lastNonRemoved;
  45305. for (let i = 0; i < total; i++) {
  45306. const decl = node.declarations[i];
  45307. const init = decl.init && unwrapTSNode(decl.init);
  45308. if (init) {
  45309. if (processDefineOptions(ctx, init)) {
  45310. ctx.error(
  45311. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  45312. node
  45313. );
  45314. }
  45315. const isDefineProps = processDefineProps(ctx, init, decl.id);
  45316. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  45317. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  45318. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  45319. if (left === 1) {
  45320. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45321. } else {
  45322. let start = decl.start + startOffset;
  45323. let end = decl.end + startOffset;
  45324. if (i === total - 1) {
  45325. start = node.declarations[lastNonRemoved].end + startOffset;
  45326. } else {
  45327. end = node.declarations[i + 1].start + startOffset;
  45328. }
  45329. ctx.s.remove(start, end);
  45330. left--;
  45331. }
  45332. } else if (isDefineEmits) {
  45333. ctx.s.overwrite(
  45334. startOffset + init.start,
  45335. startOffset + init.end,
  45336. "__emit"
  45337. );
  45338. } else {
  45339. lastNonRemoved = i;
  45340. }
  45341. }
  45342. }
  45343. }
  45344. let isAllLiteral = false;
  45345. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45346. isAllLiteral = walkDeclaration(
  45347. "scriptSetup",
  45348. node,
  45349. setupBindings,
  45350. vueImportAliases,
  45351. hoistStatic
  45352. );
  45353. }
  45354. if (hoistStatic && isAllLiteral) {
  45355. hoistNode(node);
  45356. }
  45357. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  45358. const scope = [scriptSetupAst.body];
  45359. walk$2(node, {
  45360. enter(child, parent) {
  45361. if (isFunctionType(child)) {
  45362. this.skip();
  45363. }
  45364. if (child.type === "BlockStatement") {
  45365. scope.push(child.body);
  45366. }
  45367. if (child.type === "AwaitExpression") {
  45368. hasAwait = true;
  45369. const currentScope = scope[scope.length - 1];
  45370. const needsSemi = currentScope.some((n, i) => {
  45371. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  45372. });
  45373. processAwait(
  45374. ctx,
  45375. child,
  45376. needsSemi,
  45377. parent.type === "ExpressionStatement"
  45378. );
  45379. }
  45380. },
  45381. exit(node2) {
  45382. if (node2.type === "BlockStatement")
  45383. scope.pop();
  45384. }
  45385. });
  45386. }
  45387. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  45388. ctx.error(
  45389. `<script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`,
  45390. node
  45391. );
  45392. }
  45393. if (ctx.isTS) {
  45394. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  45395. if (node.type !== "TSEnumDeclaration") {
  45396. hoistNode(node);
  45397. }
  45398. }
  45399. }
  45400. }
  45401. if (ctx.propsDestructureDecl) {
  45402. transformDestructuredProps(ctx, vueImportAliases);
  45403. }
  45404. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  45405. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  45406. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  45407. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  45408. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  45409. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  45410. for (const node of runtimeOptionNodes) {
  45411. checkInvalidScopeReference(node, DEFINE_MODEL);
  45412. }
  45413. }
  45414. if (script) {
  45415. if (startOffset < scriptStartOffset) {
  45416. ctx.s.remove(0, startOffset);
  45417. ctx.s.remove(endOffset, scriptStartOffset);
  45418. ctx.s.remove(scriptEndOffset, source.length);
  45419. } else {
  45420. ctx.s.remove(0, scriptStartOffset);
  45421. ctx.s.remove(scriptEndOffset, startOffset);
  45422. ctx.s.remove(endOffset, source.length);
  45423. }
  45424. } else {
  45425. ctx.s.remove(0, startOffset);
  45426. ctx.s.remove(endOffset, source.length);
  45427. }
  45428. if (scriptAst) {
  45429. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  45430. }
  45431. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  45432. ctx.userImports
  45433. )) {
  45434. if (isType)
  45435. continue;
  45436. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  45437. }
  45438. for (const key in scriptBindings) {
  45439. ctx.bindingMetadata[key] = scriptBindings[key];
  45440. }
  45441. for (const key in setupBindings) {
  45442. ctx.bindingMetadata[key] = setupBindings[key];
  45443. }
  45444. if (sfc.cssVars.length && // no need to do this when targeting SSR
  45445. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  45446. ctx.helperImports.add(CSS_VARS_HELPER);
  45447. ctx.helperImports.add("unref");
  45448. ctx.s.prependLeft(
  45449. startOffset,
  45450. `
  45451. ${genCssVarsCode(
  45452. sfc.cssVars,
  45453. ctx.bindingMetadata,
  45454. scopeId,
  45455. !!options.isProd
  45456. )}
  45457. `
  45458. );
  45459. }
  45460. let args = `__props`;
  45461. if (ctx.propsTypeDecl) {
  45462. args += `: any`;
  45463. }
  45464. if (ctx.propsDecl) {
  45465. if (ctx.propsDestructureRestId) {
  45466. ctx.s.overwrite(
  45467. startOffset + ctx.propsCall.start,
  45468. startOffset + ctx.propsCall.end,
  45469. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  45470. Object.keys(ctx.propsDestructuredBindings)
  45471. )})`
  45472. );
  45473. ctx.s.overwrite(
  45474. startOffset + ctx.propsDestructureDecl.start,
  45475. startOffset + ctx.propsDestructureDecl.end,
  45476. ctx.propsDestructureRestId
  45477. );
  45478. } else if (!ctx.propsDestructureDecl) {
  45479. ctx.s.overwrite(
  45480. startOffset + ctx.propsCall.start,
  45481. startOffset + ctx.propsCall.end,
  45482. "__props"
  45483. );
  45484. }
  45485. }
  45486. if (hasAwait) {
  45487. const any = ctx.isTS ? `: any` : ``;
  45488. ctx.s.prependLeft(startOffset, `
  45489. let __temp${any}, __restore${any}
  45490. `);
  45491. }
  45492. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  45493. if (ctx.emitDecl) {
  45494. destructureElements.push(`emit: __emit`);
  45495. }
  45496. if (destructureElements.length) {
  45497. args += `, { ${destructureElements.join(", ")} }`;
  45498. }
  45499. let returned;
  45500. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  45501. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  45502. for (const key in ctx.userImports) {
  45503. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  45504. allBindings[key] = true;
  45505. }
  45506. }
  45507. returned = `{ `;
  45508. for (const key in allBindings) {
  45509. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  45510. returned += `get ${key}() { return ${key} }, `;
  45511. } else if (ctx.bindingMetadata[key] === "setup-let") {
  45512. const setArg = key === "v" ? `_v` : `v`;
  45513. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  45514. } else {
  45515. returned += `${key}, `;
  45516. }
  45517. }
  45518. returned = returned.replace(/, $/, "") + ` }`;
  45519. } else {
  45520. if (sfc.template && !sfc.template.src) {
  45521. if (options.templateOptions && options.templateOptions.ssr) {
  45522. hasInlinedSsrRenderFn = true;
  45523. }
  45524. const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
  45525. filename,
  45526. ast: sfc.template.ast,
  45527. source: sfc.template.content,
  45528. inMap: sfc.template.map
  45529. }, options.templateOptions), {
  45530. id: scopeId,
  45531. scoped: sfc.styles.some((s) => s.scoped),
  45532. isProd: options.isProd,
  45533. ssrCssVars: sfc.cssVars,
  45534. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  45535. inline: true,
  45536. isTS: ctx.isTS,
  45537. bindingMetadata: ctx.bindingMetadata
  45538. })
  45539. }));
  45540. if (tips.length) {
  45541. tips.forEach(warnOnce$3);
  45542. }
  45543. const err = errors[0];
  45544. if (typeof err === "string") {
  45545. throw new Error(err);
  45546. } else if (err) {
  45547. if (err.loc) {
  45548. err.message += `
  45549. ` + sfc.filename + "\n" + generateCodeFrame(
  45550. source,
  45551. err.loc.start.offset,
  45552. err.loc.end.offset
  45553. ) + `
  45554. `;
  45555. }
  45556. throw err;
  45557. }
  45558. if (preamble) {
  45559. ctx.s.prepend(preamble);
  45560. }
  45561. if (ast && ast.helpers.has(UNREF)) {
  45562. ctx.helperImports.delete("unref");
  45563. }
  45564. returned = code;
  45565. } else {
  45566. returned = `() => {}`;
  45567. }
  45568. }
  45569. if (!options.inlineTemplate && true) {
  45570. ctx.s.appendRight(
  45571. endOffset,
  45572. `
  45573. const __returned__ = ${returned}
  45574. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  45575. return __returned__
  45576. }
  45577. `
  45578. );
  45579. } else {
  45580. ctx.s.appendRight(endOffset, `
  45581. return ${returned}
  45582. }
  45583. `);
  45584. }
  45585. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  45586. let runtimeOptions = ``;
  45587. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  45588. const match = filename.match(/([^/\\]+)\.\w+$/);
  45589. if (match) {
  45590. runtimeOptions += `
  45591. __name: '${match[1]}',`;
  45592. }
  45593. }
  45594. if (hasInlinedSsrRenderFn) {
  45595. runtimeOptions += `
  45596. __ssrInlineRender: true,`;
  45597. }
  45598. const propsDecl = genRuntimeProps(ctx);
  45599. if (propsDecl)
  45600. runtimeOptions += `
  45601. props: ${propsDecl},`;
  45602. const emitsDecl = genRuntimeEmits(ctx);
  45603. if (emitsDecl)
  45604. runtimeOptions += `
  45605. emits: ${emitsDecl},`;
  45606. let definedOptions = "";
  45607. if (ctx.optionsRuntimeDecl) {
  45608. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  45609. }
  45610. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  45611. `;
  45612. if (ctx.isTS) {
  45613. const def = (defaultExport ? `
  45614. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  45615. ...${definedOptions},` : "");
  45616. ctx.s.prependLeft(
  45617. startOffset,
  45618. `
  45619. ${genDefaultAs} /*#__PURE__*/${ctx.helper(
  45620. `defineComponent`
  45621. )}({${def}${runtimeOptions}
  45622. ${hasAwait ? `async ` : ``}setup(${args}) {
  45623. ${exposeCall}`
  45624. );
  45625. ctx.s.appendRight(endOffset, `})`);
  45626. } else {
  45627. if (defaultExport || definedOptions) {
  45628. ctx.s.prependLeft(
  45629. startOffset,
  45630. `
  45631. ${genDefaultAs} /*#__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  45632. ${hasAwait ? `async ` : ``}setup(${args}) {
  45633. ${exposeCall}`
  45634. );
  45635. ctx.s.appendRight(endOffset, `})`);
  45636. } else {
  45637. ctx.s.prependLeft(
  45638. startOffset,
  45639. `
  45640. ${genDefaultAs} {${runtimeOptions}
  45641. ${hasAwait ? `async ` : ``}setup(${args}) {
  45642. ${exposeCall}`
  45643. );
  45644. ctx.s.appendRight(endOffset, `}`);
  45645. }
  45646. }
  45647. if (ctx.helperImports.size > 0) {
  45648. const runtimeModuleName = (_c = (_b = options.templateOptions) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.runtimeModuleName;
  45649. const importSrc = runtimeModuleName ? JSON.stringify(runtimeModuleName) : `'vue'`;
  45650. ctx.s.prepend(
  45651. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from ${importSrc}
  45652. `
  45653. );
  45654. }
  45655. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  45656. bindings: ctx.bindingMetadata,
  45657. imports: ctx.userImports,
  45658. content: ctx.s.toString(),
  45659. map: options.sourceMap !== false ? ctx.s.generateMap({
  45660. source: filename,
  45661. hires: true,
  45662. includeContent: true
  45663. }) : void 0,
  45664. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  45665. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  45666. deps: ctx.deps ? [...ctx.deps] : void 0
  45667. });
  45668. }
  45669. function registerBinding(bindings, node, type) {
  45670. bindings[node.name] = type;
  45671. }
  45672. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
  45673. let isAllLiteral = false;
  45674. if (node.type === "VariableDeclaration") {
  45675. const isConst = node.kind === "const";
  45676. isAllLiteral = isConst && node.declarations.every(
  45677. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  45678. );
  45679. for (const { id, init: _init } of node.declarations) {
  45680. const init = _init && unwrapTSNode(_init);
  45681. const isDefineCall = !!(isConst && isCallOf(
  45682. init,
  45683. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
  45684. ));
  45685. if (id.type === "Identifier") {
  45686. let bindingType;
  45687. const userReactiveBinding = userImportAliases["reactive"];
  45688. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  45689. bindingType = "literal-const";
  45690. } else if (isCallOf(init, userReactiveBinding)) {
  45691. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  45692. } else if (
  45693. // if a declaration is a const literal, we can mark it so that
  45694. // the generated render fn code doesn't need to unref() it
  45695. isDefineCall || isConst && canNeverBeRef(init, userReactiveBinding)
  45696. ) {
  45697. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  45698. } else if (isConst) {
  45699. if (isCallOf(
  45700. init,
  45701. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === DEFINE_MODEL
  45702. )) {
  45703. bindingType = "setup-ref";
  45704. } else {
  45705. bindingType = "setup-maybe-ref";
  45706. }
  45707. } else {
  45708. bindingType = "setup-let";
  45709. }
  45710. registerBinding(bindings, id, bindingType);
  45711. } else {
  45712. if (isCallOf(init, DEFINE_PROPS)) {
  45713. continue;
  45714. }
  45715. if (id.type === "ObjectPattern") {
  45716. walkObjectPattern(id, bindings, isConst, isDefineCall);
  45717. } else if (id.type === "ArrayPattern") {
  45718. walkArrayPattern(id, bindings, isConst, isDefineCall);
  45719. }
  45720. }
  45721. }
  45722. } else if (node.type === "TSEnumDeclaration") {
  45723. isAllLiteral = node.members.every(
  45724. (member) => !member.initializer || isStaticNode(member.initializer)
  45725. );
  45726. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  45727. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  45728. bindings[node.id.name] = "setup-const";
  45729. }
  45730. return isAllLiteral;
  45731. }
  45732. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  45733. for (const p of node.properties) {
  45734. if (p.type === "ObjectProperty") {
  45735. if (p.key.type === "Identifier" && p.key === p.value) {
  45736. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45737. registerBinding(bindings, p.key, type);
  45738. } else {
  45739. walkPattern(p.value, bindings, isConst, isDefineCall);
  45740. }
  45741. } else {
  45742. const type = isConst ? "setup-const" : "setup-let";
  45743. registerBinding(bindings, p.argument, type);
  45744. }
  45745. }
  45746. }
  45747. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  45748. for (const e of node.elements) {
  45749. e && walkPattern(e, bindings, isConst, isDefineCall);
  45750. }
  45751. }
  45752. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  45753. if (node.type === "Identifier") {
  45754. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45755. registerBinding(bindings, node, type);
  45756. } else if (node.type === "RestElement") {
  45757. const type = isConst ? "setup-const" : "setup-let";
  45758. registerBinding(bindings, node.argument, type);
  45759. } else if (node.type === "ObjectPattern") {
  45760. walkObjectPattern(node, bindings, isConst);
  45761. } else if (node.type === "ArrayPattern") {
  45762. walkArrayPattern(node, bindings, isConst);
  45763. } else if (node.type === "AssignmentPattern") {
  45764. if (node.left.type === "Identifier") {
  45765. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45766. registerBinding(bindings, node.left, type);
  45767. } else {
  45768. walkPattern(node.left, bindings, isConst);
  45769. }
  45770. }
  45771. }
  45772. function canNeverBeRef(node, userReactiveImport) {
  45773. if (isCallOf(node, userReactiveImport)) {
  45774. return true;
  45775. }
  45776. switch (node.type) {
  45777. case "UnaryExpression":
  45778. case "BinaryExpression":
  45779. case "ArrayExpression":
  45780. case "ObjectExpression":
  45781. case "FunctionExpression":
  45782. case "ArrowFunctionExpression":
  45783. case "UpdateExpression":
  45784. case "ClassExpression":
  45785. case "TaggedTemplateExpression":
  45786. return true;
  45787. case "SequenceExpression":
  45788. return canNeverBeRef(
  45789. node.expressions[node.expressions.length - 1],
  45790. userReactiveImport
  45791. );
  45792. default:
  45793. if (isLiteralNode(node)) {
  45794. return true;
  45795. }
  45796. return false;
  45797. }
  45798. }
  45799. function isStaticNode(node) {
  45800. node = unwrapTSNode(node);
  45801. switch (node.type) {
  45802. case "UnaryExpression":
  45803. return isStaticNode(node.argument);
  45804. case "LogicalExpression":
  45805. case "BinaryExpression":
  45806. return isStaticNode(node.left) && isStaticNode(node.right);
  45807. case "ConditionalExpression": {
  45808. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  45809. }
  45810. case "SequenceExpression":
  45811. case "TemplateLiteral":
  45812. return node.expressions.every((expr) => isStaticNode(expr));
  45813. case "ParenthesizedExpression":
  45814. return isStaticNode(node.expression);
  45815. case "StringLiteral":
  45816. case "NumericLiteral":
  45817. case "BooleanLiteral":
  45818. case "NullLiteral":
  45819. case "BigIntLiteral":
  45820. return true;
  45821. }
  45822. return false;
  45823. }
  45824. var __defProp = Object.defineProperty;
  45825. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  45826. var __hasOwnProp = Object.prototype.hasOwnProperty;
  45827. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  45828. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45829. var __spreadValues = (a, b) => {
  45830. for (var prop in b || (b = {}))
  45831. if (__hasOwnProp.call(b, prop))
  45832. __defNormalProp(a, prop, b[prop]);
  45833. if (__getOwnPropSymbols)
  45834. for (var prop of __getOwnPropSymbols(b)) {
  45835. if (__propIsEnum.call(b, prop))
  45836. __defNormalProp(a, prop, b[prop]);
  45837. }
  45838. return a;
  45839. };
  45840. const version = "3.4.23";
  45841. const parseCache = parseCache$1;
  45842. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  45843. const walk = walk$2;
  45844. const shouldTransformRef = () => false;
  45845. export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, errorMessages, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };