compiler-sfc.esm-browser.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237
  1. /**
  2. * @vue/compiler-sfc v3.4.21
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. function makeMap(str, expectsLowerCase) {
  7. const set = new Set(str.split(","));
  8. return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
  9. }
  10. const EMPTY_OBJ = Object.freeze({}) ;
  11. const NOOP = () => {
  12. };
  13. const NO = () => false;
  14. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  15. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  16. const extend = Object.assign;
  17. const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
  18. const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
  19. const isArray$3 = Array.isArray;
  20. const isMap = (val) => toTypeString(val) === "[object Map]";
  21. const isSet = (val) => toTypeString(val) === "[object Set]";
  22. const isFunction$1 = (val) => typeof val === "function";
  23. const isString$2 = (val) => typeof val === "string";
  24. const isSymbol$1 = (val) => typeof val === "symbol";
  25. const isObject$2 = (val) => val !== null && typeof val === "object";
  26. const objectToString$1 = Object.prototype.toString;
  27. const toTypeString = (value) => objectToString$1.call(value);
  28. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  29. const isReservedProp = /* @__PURE__ */ makeMap(
  30. // the leading comma is intentional so empty string "" is also included
  31. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  32. );
  33. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  34. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  35. );
  36. const cacheStringFunction = (fn) => {
  37. const cache = /* @__PURE__ */ Object.create(null);
  38. return (str) => {
  39. const hit = cache[str];
  40. return hit || (cache[str] = fn(str));
  41. };
  42. };
  43. const camelizeRE = /-(\w)/g;
  44. const camelize = cacheStringFunction((str) => {
  45. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  46. });
  47. const hyphenateRE = /\B([A-Z])/g;
  48. const hyphenate = cacheStringFunction(
  49. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  50. );
  51. const capitalize$1 = cacheStringFunction((str) => {
  52. return str.charAt(0).toUpperCase() + str.slice(1);
  53. });
  54. const toHandlerKey = cacheStringFunction((str) => {
  55. const s = str ? `on${capitalize$1(str)}` : ``;
  56. return s;
  57. });
  58. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  59. function genPropsAccessExp(name) {
  60. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  61. }
  62. const PatchFlagNames = {
  63. [1]: `TEXT`,
  64. [2]: `CLASS`,
  65. [4]: `STYLE`,
  66. [8]: `PROPS`,
  67. [16]: `FULL_PROPS`,
  68. [32]: `NEED_HYDRATION`,
  69. [64]: `STABLE_FRAGMENT`,
  70. [128]: `KEYED_FRAGMENT`,
  71. [256]: `UNKEYED_FRAGMENT`,
  72. [512]: `NEED_PATCH`,
  73. [1024]: `DYNAMIC_SLOTS`,
  74. [2048]: `DEV_ROOT_FRAGMENT`,
  75. [-1]: `HOISTED`,
  76. [-2]: `BAIL`
  77. };
  78. const slotFlagsText = {
  79. [1]: "STABLE",
  80. [2]: "DYNAMIC",
  81. [3]: "FORWARDED"
  82. };
  83. 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";
  84. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  85. const range = 2;
  86. function generateCodeFrame(source, start = 0, end = source.length) {
  87. let lines = source.split(/(\r?\n)/);
  88. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  89. lines = lines.filter((_, idx) => idx % 2 === 0);
  90. let count = 0;
  91. const res = [];
  92. for (let i = 0; i < lines.length; i++) {
  93. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  94. if (count >= start) {
  95. for (let j = i - range; j <= i + range || end > count; j++) {
  96. if (j < 0 || j >= lines.length)
  97. continue;
  98. const line = j + 1;
  99. res.push(
  100. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  101. );
  102. const lineLength = lines[j].length;
  103. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  104. if (j === i) {
  105. const pad = start - (count - (lineLength + newLineSeqLength));
  106. const length = Math.max(
  107. 1,
  108. end > count ? lineLength - pad : end - start
  109. );
  110. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  111. } else if (j > i) {
  112. if (end > count) {
  113. const length = Math.max(Math.min(end - count, lineLength), 1);
  114. res.push(` | ` + "^".repeat(length));
  115. }
  116. count += lineLength + newLineSeqLength;
  117. }
  118. }
  119. break;
  120. }
  121. }
  122. return res.join("\n");
  123. }
  124. function normalizeStyle(value) {
  125. if (isArray$3(value)) {
  126. const res = {};
  127. for (let i = 0; i < value.length; i++) {
  128. const item = value[i];
  129. const normalized = isString$2(item) ? parseStringStyle(item) : normalizeStyle(item);
  130. if (normalized) {
  131. for (const key in normalized) {
  132. res[key] = normalized[key];
  133. }
  134. }
  135. }
  136. return res;
  137. } else if (isString$2(value) || isObject$2(value)) {
  138. return value;
  139. }
  140. }
  141. const listDelimiterRE = /;(?![^(]*\))/g;
  142. const propertyDelimiterRE = /:([^]+)/;
  143. const styleCommentRE = /\/\*[^]*?\*\//g;
  144. function parseStringStyle(cssText) {
  145. const ret = {};
  146. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  147. if (item) {
  148. const tmp = item.split(propertyDelimiterRE);
  149. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  150. }
  151. });
  152. return ret;
  153. }
  154. function stringifyStyle(styles) {
  155. let ret = "";
  156. if (!styles || isString$2(styles)) {
  157. return ret;
  158. }
  159. for (const key in styles) {
  160. const value = styles[key];
  161. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  162. if (isString$2(value) || typeof value === "number") {
  163. ret += `${normalizedKey}:${value};`;
  164. }
  165. }
  166. return ret;
  167. }
  168. function normalizeClass(value) {
  169. let res = "";
  170. if (isString$2(value)) {
  171. res = value;
  172. } else if (isArray$3(value)) {
  173. for (let i = 0; i < value.length; i++) {
  174. const normalized = normalizeClass(value[i]);
  175. if (normalized) {
  176. res += normalized + " ";
  177. }
  178. }
  179. } else if (isObject$2(value)) {
  180. for (const name in value) {
  181. if (value[name]) {
  182. res += name + " ";
  183. }
  184. }
  185. }
  186. return res.trim();
  187. }
  188. 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";
  189. 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";
  190. 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";
  191. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  192. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  193. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  194. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  195. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  196. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  197. const isBooleanAttr = /* @__PURE__ */ makeMap(
  198. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  199. );
  200. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  201. const attrValidationCache = {};
  202. function isSSRSafeAttrName(name) {
  203. if (attrValidationCache.hasOwnProperty(name)) {
  204. return attrValidationCache[name];
  205. }
  206. const isUnsafe = unsafeAttrCharRE.test(name);
  207. if (isUnsafe) {
  208. console.error(`unsafe attribute name: ${name}`);
  209. }
  210. return attrValidationCache[name] = !isUnsafe;
  211. }
  212. const propsToAttrMap = {
  213. acceptCharset: "accept-charset",
  214. className: "class",
  215. htmlFor: "for",
  216. httpEquiv: "http-equiv"
  217. };
  218. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  219. `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`
  220. );
  221. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  222. `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`
  223. );
  224. const escapeRE = /["'&<>]/;
  225. function escapeHtml(string) {
  226. const str = "" + string;
  227. const match = escapeRE.exec(str);
  228. if (!match) {
  229. return str;
  230. }
  231. let html = "";
  232. let escaped;
  233. let index;
  234. let lastIndex = 0;
  235. for (index = match.index; index < str.length; index++) {
  236. switch (str.charCodeAt(index)) {
  237. case 34:
  238. escaped = "&quot;";
  239. break;
  240. case 38:
  241. escaped = "&amp;";
  242. break;
  243. case 39:
  244. escaped = "&#39;";
  245. break;
  246. case 60:
  247. escaped = "&lt;";
  248. break;
  249. case 62:
  250. escaped = "&gt;";
  251. break;
  252. default:
  253. continue;
  254. }
  255. if (lastIndex !== index) {
  256. html += str.slice(lastIndex, index);
  257. }
  258. lastIndex = index + 1;
  259. html += escaped;
  260. }
  261. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  262. }
  263. const toDisplayString = (val) => {
  264. 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);
  265. };
  266. const replacer = (_key, val) => {
  267. if (val && val.__v_isRef) {
  268. return replacer(_key, val.value);
  269. } else if (isMap(val)) {
  270. return {
  271. [`Map(${val.size})`]: [...val.entries()].reduce(
  272. (entries, [key, val2], i) => {
  273. entries[stringifySymbol(key, i) + " =>"] = val2;
  274. return entries;
  275. },
  276. {}
  277. )
  278. };
  279. } else if (isSet(val)) {
  280. return {
  281. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  282. };
  283. } else if (isSymbol$1(val)) {
  284. return stringifySymbol(val);
  285. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  286. return String(val);
  287. }
  288. return val;
  289. };
  290. const stringifySymbol = (v, i = "") => {
  291. var _a;
  292. return isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
  293. };
  294. const FRAGMENT = Symbol(`Fragment` );
  295. const TELEPORT = Symbol(`Teleport` );
  296. const SUSPENSE = Symbol(`Suspense` );
  297. const KEEP_ALIVE = Symbol(`KeepAlive` );
  298. const BASE_TRANSITION = Symbol(`BaseTransition` );
  299. const OPEN_BLOCK = Symbol(`openBlock` );
  300. const CREATE_BLOCK = Symbol(`createBlock` );
  301. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  302. const CREATE_VNODE = Symbol(`createVNode` );
  303. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  304. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  305. const CREATE_TEXT = Symbol(`createTextVNode` );
  306. const CREATE_STATIC = Symbol(`createStaticVNode` );
  307. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  308. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  309. `resolveDynamicComponent`
  310. );
  311. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  312. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  313. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  314. const RENDER_LIST = Symbol(`renderList` );
  315. const RENDER_SLOT = Symbol(`renderSlot` );
  316. const CREATE_SLOTS = Symbol(`createSlots` );
  317. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  318. const MERGE_PROPS = Symbol(`mergeProps` );
  319. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  320. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  321. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  322. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  323. const TO_HANDLERS = Symbol(`toHandlers` );
  324. const CAMELIZE = Symbol(`camelize` );
  325. const CAPITALIZE = Symbol(`capitalize` );
  326. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  327. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  328. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  329. const POP_SCOPE_ID = Symbol(`popScopeId` );
  330. const WITH_CTX = Symbol(`withCtx` );
  331. const UNREF = Symbol(`unref` );
  332. const IS_REF = Symbol(`isRef` );
  333. const WITH_MEMO = Symbol(`withMemo` );
  334. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  335. const helperNameMap = {
  336. [FRAGMENT]: `Fragment`,
  337. [TELEPORT]: `Teleport`,
  338. [SUSPENSE]: `Suspense`,
  339. [KEEP_ALIVE]: `KeepAlive`,
  340. [BASE_TRANSITION]: `BaseTransition`,
  341. [OPEN_BLOCK]: `openBlock`,
  342. [CREATE_BLOCK]: `createBlock`,
  343. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  344. [CREATE_VNODE]: `createVNode`,
  345. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  346. [CREATE_COMMENT]: `createCommentVNode`,
  347. [CREATE_TEXT]: `createTextVNode`,
  348. [CREATE_STATIC]: `createStaticVNode`,
  349. [RESOLVE_COMPONENT]: `resolveComponent`,
  350. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  351. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  352. [RESOLVE_FILTER]: `resolveFilter`,
  353. [WITH_DIRECTIVES]: `withDirectives`,
  354. [RENDER_LIST]: `renderList`,
  355. [RENDER_SLOT]: `renderSlot`,
  356. [CREATE_SLOTS]: `createSlots`,
  357. [TO_DISPLAY_STRING]: `toDisplayString`,
  358. [MERGE_PROPS]: `mergeProps`,
  359. [NORMALIZE_CLASS]: `normalizeClass`,
  360. [NORMALIZE_STYLE]: `normalizeStyle`,
  361. [NORMALIZE_PROPS]: `normalizeProps`,
  362. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  363. [TO_HANDLERS]: `toHandlers`,
  364. [CAMELIZE]: `camelize`,
  365. [CAPITALIZE]: `capitalize`,
  366. [TO_HANDLER_KEY]: `toHandlerKey`,
  367. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  368. [PUSH_SCOPE_ID]: `pushScopeId`,
  369. [POP_SCOPE_ID]: `popScopeId`,
  370. [WITH_CTX]: `withCtx`,
  371. [UNREF]: `unref`,
  372. [IS_REF]: `isRef`,
  373. [WITH_MEMO]: `withMemo`,
  374. [IS_MEMO_SAME]: `isMemoSame`
  375. };
  376. function registerRuntimeHelpers(helpers) {
  377. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  378. helperNameMap[s] = helpers[s];
  379. });
  380. }
  381. const Namespaces = {
  382. "HTML": 0,
  383. "0": "HTML",
  384. "SVG": 1,
  385. "1": "SVG",
  386. "MATH_ML": 2,
  387. "2": "MATH_ML"
  388. };
  389. const NodeTypes = {
  390. "ROOT": 0,
  391. "0": "ROOT",
  392. "ELEMENT": 1,
  393. "1": "ELEMENT",
  394. "TEXT": 2,
  395. "2": "TEXT",
  396. "COMMENT": 3,
  397. "3": "COMMENT",
  398. "SIMPLE_EXPRESSION": 4,
  399. "4": "SIMPLE_EXPRESSION",
  400. "INTERPOLATION": 5,
  401. "5": "INTERPOLATION",
  402. "ATTRIBUTE": 6,
  403. "6": "ATTRIBUTE",
  404. "DIRECTIVE": 7,
  405. "7": "DIRECTIVE",
  406. "COMPOUND_EXPRESSION": 8,
  407. "8": "COMPOUND_EXPRESSION",
  408. "IF": 9,
  409. "9": "IF",
  410. "IF_BRANCH": 10,
  411. "10": "IF_BRANCH",
  412. "FOR": 11,
  413. "11": "FOR",
  414. "TEXT_CALL": 12,
  415. "12": "TEXT_CALL",
  416. "VNODE_CALL": 13,
  417. "13": "VNODE_CALL",
  418. "JS_CALL_EXPRESSION": 14,
  419. "14": "JS_CALL_EXPRESSION",
  420. "JS_OBJECT_EXPRESSION": 15,
  421. "15": "JS_OBJECT_EXPRESSION",
  422. "JS_PROPERTY": 16,
  423. "16": "JS_PROPERTY",
  424. "JS_ARRAY_EXPRESSION": 17,
  425. "17": "JS_ARRAY_EXPRESSION",
  426. "JS_FUNCTION_EXPRESSION": 18,
  427. "18": "JS_FUNCTION_EXPRESSION",
  428. "JS_CONDITIONAL_EXPRESSION": 19,
  429. "19": "JS_CONDITIONAL_EXPRESSION",
  430. "JS_CACHE_EXPRESSION": 20,
  431. "20": "JS_CACHE_EXPRESSION",
  432. "JS_BLOCK_STATEMENT": 21,
  433. "21": "JS_BLOCK_STATEMENT",
  434. "JS_TEMPLATE_LITERAL": 22,
  435. "22": "JS_TEMPLATE_LITERAL",
  436. "JS_IF_STATEMENT": 23,
  437. "23": "JS_IF_STATEMENT",
  438. "JS_ASSIGNMENT_EXPRESSION": 24,
  439. "24": "JS_ASSIGNMENT_EXPRESSION",
  440. "JS_SEQUENCE_EXPRESSION": 25,
  441. "25": "JS_SEQUENCE_EXPRESSION",
  442. "JS_RETURN_STATEMENT": 26,
  443. "26": "JS_RETURN_STATEMENT"
  444. };
  445. const ElementTypes = {
  446. "ELEMENT": 0,
  447. "0": "ELEMENT",
  448. "COMPONENT": 1,
  449. "1": "COMPONENT",
  450. "SLOT": 2,
  451. "2": "SLOT",
  452. "TEMPLATE": 3,
  453. "3": "TEMPLATE"
  454. };
  455. const ConstantTypes = {
  456. "NOT_CONSTANT": 0,
  457. "0": "NOT_CONSTANT",
  458. "CAN_SKIP_PATCH": 1,
  459. "1": "CAN_SKIP_PATCH",
  460. "CAN_HOIST": 2,
  461. "2": "CAN_HOIST",
  462. "CAN_STRINGIFY": 3,
  463. "3": "CAN_STRINGIFY"
  464. };
  465. const locStub = {
  466. start: { line: 1, column: 1, offset: 0 },
  467. end: { line: 1, column: 1, offset: 0 },
  468. source: ""
  469. };
  470. function createRoot(children, source = "") {
  471. return {
  472. type: 0,
  473. source,
  474. children,
  475. helpers: /* @__PURE__ */ new Set(),
  476. components: [],
  477. directives: [],
  478. hoists: [],
  479. imports: [],
  480. cached: 0,
  481. temps: 0,
  482. codegenNode: void 0,
  483. loc: locStub
  484. };
  485. }
  486. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  487. if (context) {
  488. if (isBlock) {
  489. context.helper(OPEN_BLOCK);
  490. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  491. } else {
  492. context.helper(getVNodeHelper(context.inSSR, isComponent));
  493. }
  494. if (directives) {
  495. context.helper(WITH_DIRECTIVES);
  496. }
  497. }
  498. return {
  499. type: 13,
  500. tag,
  501. props,
  502. children,
  503. patchFlag,
  504. dynamicProps,
  505. directives,
  506. isBlock,
  507. disableTracking,
  508. isComponent,
  509. loc
  510. };
  511. }
  512. function createArrayExpression(elements, loc = locStub) {
  513. return {
  514. type: 17,
  515. loc,
  516. elements
  517. };
  518. }
  519. function createObjectExpression(properties, loc = locStub) {
  520. return {
  521. type: 15,
  522. loc,
  523. properties
  524. };
  525. }
  526. function createObjectProperty(key, value) {
  527. return {
  528. type: 16,
  529. loc: locStub,
  530. key: isString$2(key) ? createSimpleExpression(key, true) : key,
  531. value
  532. };
  533. }
  534. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  535. return {
  536. type: 4,
  537. loc,
  538. content,
  539. isStatic,
  540. constType: isStatic ? 3 : constType
  541. };
  542. }
  543. function createInterpolation(content, loc) {
  544. return {
  545. type: 5,
  546. loc,
  547. content: isString$2(content) ? createSimpleExpression(content, false, loc) : content
  548. };
  549. }
  550. function createCompoundExpression(children, loc = locStub) {
  551. return {
  552. type: 8,
  553. loc,
  554. children
  555. };
  556. }
  557. function createCallExpression(callee, args = [], loc = locStub) {
  558. return {
  559. type: 14,
  560. loc,
  561. callee,
  562. arguments: args
  563. };
  564. }
  565. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  566. return {
  567. type: 18,
  568. params,
  569. returns,
  570. newline,
  571. isSlot,
  572. loc
  573. };
  574. }
  575. function createConditionalExpression(test, consequent, alternate, newline = true) {
  576. return {
  577. type: 19,
  578. test,
  579. consequent,
  580. alternate,
  581. newline,
  582. loc: locStub
  583. };
  584. }
  585. function createCacheExpression(index, value, isVNode = false) {
  586. return {
  587. type: 20,
  588. index,
  589. value,
  590. isVNode,
  591. loc: locStub
  592. };
  593. }
  594. function createBlockStatement(body) {
  595. return {
  596. type: 21,
  597. body,
  598. loc: locStub
  599. };
  600. }
  601. function createTemplateLiteral(elements) {
  602. return {
  603. type: 22,
  604. elements,
  605. loc: locStub
  606. };
  607. }
  608. function createIfStatement(test, consequent, alternate) {
  609. return {
  610. type: 23,
  611. test,
  612. consequent,
  613. alternate,
  614. loc: locStub
  615. };
  616. }
  617. function createAssignmentExpression(left, right) {
  618. return {
  619. type: 24,
  620. left,
  621. right,
  622. loc: locStub
  623. };
  624. }
  625. function createSequenceExpression(expressions) {
  626. return {
  627. type: 25,
  628. expressions,
  629. loc: locStub
  630. };
  631. }
  632. function createReturnStatement(returns) {
  633. return {
  634. type: 26,
  635. returns,
  636. loc: locStub
  637. };
  638. }
  639. function getVNodeHelper(ssr, isComponent) {
  640. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  641. }
  642. function getVNodeBlockHelper(ssr, isComponent) {
  643. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  644. }
  645. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  646. if (!node.isBlock) {
  647. node.isBlock = true;
  648. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  649. helper(OPEN_BLOCK);
  650. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  651. }
  652. }
  653. // Generated using scripts/write-decode-map.ts
  654. var htmlDecodeTree = new Uint16Array(
  655. // prettier-ignore
  656. "\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"
  657. .split("")
  658. .map((c) => c.charCodeAt(0)));
  659. // Generated using scripts/write-decode-map.ts
  660. var xmlDecodeTree = new Uint16Array(
  661. // prettier-ignore
  662. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  663. .split("")
  664. .map((c) => c.charCodeAt(0)));
  665. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  666. var _a$1;
  667. const decodeMap = new Map([
  668. [0, 65533],
  669. // C1 Unicode control character reference replacements
  670. [128, 8364],
  671. [130, 8218],
  672. [131, 402],
  673. [132, 8222],
  674. [133, 8230],
  675. [134, 8224],
  676. [135, 8225],
  677. [136, 710],
  678. [137, 8240],
  679. [138, 352],
  680. [139, 8249],
  681. [140, 338],
  682. [142, 381],
  683. [145, 8216],
  684. [146, 8217],
  685. [147, 8220],
  686. [148, 8221],
  687. [149, 8226],
  688. [150, 8211],
  689. [151, 8212],
  690. [152, 732],
  691. [153, 8482],
  692. [154, 353],
  693. [155, 8250],
  694. [156, 339],
  695. [158, 382],
  696. [159, 376],
  697. ]);
  698. /**
  699. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  700. */
  701. const fromCodePoint =
  702. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  703. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  704. let output = "";
  705. if (codePoint > 0xffff) {
  706. codePoint -= 0x10000;
  707. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  708. codePoint = 0xdc00 | (codePoint & 0x3ff);
  709. }
  710. output += String.fromCharCode(codePoint);
  711. return output;
  712. };
  713. /**
  714. * Replace the given code point with a replacement character if it is a
  715. * surrogate or is outside the valid range. Otherwise return the code
  716. * point unchanged.
  717. */
  718. function replaceCodePoint(codePoint) {
  719. var _a;
  720. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  721. return 0xfffd;
  722. }
  723. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  724. }
  725. var CharCodes;
  726. (function (CharCodes) {
  727. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  728. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  729. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  730. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  731. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  732. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  733. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  734. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  735. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  736. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  737. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  738. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  739. })(CharCodes || (CharCodes = {}));
  740. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  741. const TO_LOWER_BIT = 0b100000;
  742. var BinTrieFlags;
  743. (function (BinTrieFlags) {
  744. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  745. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  746. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  747. })(BinTrieFlags || (BinTrieFlags = {}));
  748. function isNumber$2(code) {
  749. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  750. }
  751. function isHexadecimalCharacter(code) {
  752. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  753. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  754. }
  755. function isAsciiAlphaNumeric(code) {
  756. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  757. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  758. isNumber$2(code));
  759. }
  760. /**
  761. * Checks if the given character is a valid end character for an entity in an attribute.
  762. *
  763. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  764. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  765. */
  766. function isEntityInAttributeInvalidEnd(code) {
  767. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  768. }
  769. var EntityDecoderState;
  770. (function (EntityDecoderState) {
  771. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  772. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  773. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  774. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  775. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  776. })(EntityDecoderState || (EntityDecoderState = {}));
  777. var DecodingMode;
  778. (function (DecodingMode) {
  779. /** Entities in text nodes that can end with any character. */
  780. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  781. /** Only allow entities terminated with a semicolon. */
  782. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  783. /** Entities in attributes have limitations on ending characters. */
  784. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  785. })(DecodingMode || (DecodingMode = {}));
  786. /**
  787. * Token decoder with support of writing partial entities.
  788. */
  789. class EntityDecoder {
  790. constructor(
  791. /** The tree used to decode entities. */
  792. decodeTree,
  793. /**
  794. * The function that is called when a codepoint is decoded.
  795. *
  796. * For multi-byte named entities, this will be called multiple times,
  797. * with the second codepoint, and the same `consumed` value.
  798. *
  799. * @param codepoint The decoded codepoint.
  800. * @param consumed The number of bytes consumed by the decoder.
  801. */
  802. emitCodePoint,
  803. /** An object that is used to produce errors. */
  804. errors) {
  805. this.decodeTree = decodeTree;
  806. this.emitCodePoint = emitCodePoint;
  807. this.errors = errors;
  808. /** The current state of the decoder. */
  809. this.state = EntityDecoderState.EntityStart;
  810. /** Characters that were consumed while parsing an entity. */
  811. this.consumed = 1;
  812. /**
  813. * The result of the entity.
  814. *
  815. * Either the result index of a numeric entity, or the codepoint of a
  816. * numeric entity.
  817. */
  818. this.result = 0;
  819. /** The current index in the decode tree. */
  820. this.treeIndex = 0;
  821. /** The number of characters that were consumed in excess. */
  822. this.excess = 1;
  823. /** The mode in which the decoder is operating. */
  824. this.decodeMode = DecodingMode.Strict;
  825. }
  826. /** Resets the instance to make it reusable. */
  827. startEntity(decodeMode) {
  828. this.decodeMode = decodeMode;
  829. this.state = EntityDecoderState.EntityStart;
  830. this.result = 0;
  831. this.treeIndex = 0;
  832. this.excess = 1;
  833. this.consumed = 1;
  834. }
  835. /**
  836. * Write an entity to the decoder. This can be called multiple times with partial entities.
  837. * If the entity is incomplete, the decoder will return -1.
  838. *
  839. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  840. * entity is incomplete, and resume when the next string is written.
  841. *
  842. * @param string The string containing the entity (or a continuation of the entity).
  843. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  844. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  845. */
  846. write(str, offset) {
  847. switch (this.state) {
  848. case EntityDecoderState.EntityStart: {
  849. if (str.charCodeAt(offset) === CharCodes.NUM) {
  850. this.state = EntityDecoderState.NumericStart;
  851. this.consumed += 1;
  852. return this.stateNumericStart(str, offset + 1);
  853. }
  854. this.state = EntityDecoderState.NamedEntity;
  855. return this.stateNamedEntity(str, offset);
  856. }
  857. case EntityDecoderState.NumericStart: {
  858. return this.stateNumericStart(str, offset);
  859. }
  860. case EntityDecoderState.NumericDecimal: {
  861. return this.stateNumericDecimal(str, offset);
  862. }
  863. case EntityDecoderState.NumericHex: {
  864. return this.stateNumericHex(str, offset);
  865. }
  866. case EntityDecoderState.NamedEntity: {
  867. return this.stateNamedEntity(str, offset);
  868. }
  869. }
  870. }
  871. /**
  872. * Switches between the numeric decimal and hexadecimal states.
  873. *
  874. * Equivalent to the `Numeric character reference state` in the HTML spec.
  875. *
  876. * @param str The string containing the entity (or a continuation of the entity).
  877. * @param offset The current offset.
  878. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  879. */
  880. stateNumericStart(str, offset) {
  881. if (offset >= str.length) {
  882. return -1;
  883. }
  884. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  885. this.state = EntityDecoderState.NumericHex;
  886. this.consumed += 1;
  887. return this.stateNumericHex(str, offset + 1);
  888. }
  889. this.state = EntityDecoderState.NumericDecimal;
  890. return this.stateNumericDecimal(str, offset);
  891. }
  892. addToNumericResult(str, start, end, base) {
  893. if (start !== end) {
  894. const digitCount = end - start;
  895. this.result =
  896. this.result * Math.pow(base, digitCount) +
  897. parseInt(str.substr(start, digitCount), base);
  898. this.consumed += digitCount;
  899. }
  900. }
  901. /**
  902. * Parses a hexadecimal numeric entity.
  903. *
  904. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  905. *
  906. * @param str The string containing the entity (or a continuation of the entity).
  907. * @param offset The current offset.
  908. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  909. */
  910. stateNumericHex(str, offset) {
  911. const startIdx = offset;
  912. while (offset < str.length) {
  913. const char = str.charCodeAt(offset);
  914. if (isNumber$2(char) || isHexadecimalCharacter(char)) {
  915. offset += 1;
  916. }
  917. else {
  918. this.addToNumericResult(str, startIdx, offset, 16);
  919. return this.emitNumericEntity(char, 3);
  920. }
  921. }
  922. this.addToNumericResult(str, startIdx, offset, 16);
  923. return -1;
  924. }
  925. /**
  926. * Parses a decimal numeric entity.
  927. *
  928. * Equivalent to the `Decimal character reference state` in the HTML spec.
  929. *
  930. * @param str The string containing the entity (or a continuation of the entity).
  931. * @param offset The current offset.
  932. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  933. */
  934. stateNumericDecimal(str, offset) {
  935. const startIdx = offset;
  936. while (offset < str.length) {
  937. const char = str.charCodeAt(offset);
  938. if (isNumber$2(char)) {
  939. offset += 1;
  940. }
  941. else {
  942. this.addToNumericResult(str, startIdx, offset, 10);
  943. return this.emitNumericEntity(char, 2);
  944. }
  945. }
  946. this.addToNumericResult(str, startIdx, offset, 10);
  947. return -1;
  948. }
  949. /**
  950. * Validate and emit a numeric entity.
  951. *
  952. * Implements the logic from the `Hexademical character reference start
  953. * state` and `Numeric character reference end state` in the HTML spec.
  954. *
  955. * @param lastCp The last code point of the entity. Used to see if the
  956. * entity was terminated with a semicolon.
  957. * @param expectedLength The minimum number of characters that should be
  958. * consumed. Used to validate that at least one digit
  959. * was consumed.
  960. * @returns The number of characters that were consumed.
  961. */
  962. emitNumericEntity(lastCp, expectedLength) {
  963. var _a;
  964. // Ensure we consumed at least one digit.
  965. if (this.consumed <= expectedLength) {
  966. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  967. return 0;
  968. }
  969. // Figure out if this is a legit end of the entity
  970. if (lastCp === CharCodes.SEMI) {
  971. this.consumed += 1;
  972. }
  973. else if (this.decodeMode === DecodingMode.Strict) {
  974. return 0;
  975. }
  976. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  977. if (this.errors) {
  978. if (lastCp !== CharCodes.SEMI) {
  979. this.errors.missingSemicolonAfterCharacterReference();
  980. }
  981. this.errors.validateNumericCharacterReference(this.result);
  982. }
  983. return this.consumed;
  984. }
  985. /**
  986. * Parses a named entity.
  987. *
  988. * Equivalent to the `Named character reference state` in the HTML spec.
  989. *
  990. * @param str The string containing the entity (or a continuation of the entity).
  991. * @param offset The current offset.
  992. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  993. */
  994. stateNamedEntity(str, offset) {
  995. const { decodeTree } = this;
  996. let current = decodeTree[this.treeIndex];
  997. // The mask is the number of bytes of the value, including the current byte.
  998. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  999. for (; offset < str.length; offset++, this.excess++) {
  1000. const char = str.charCodeAt(offset);
  1001. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1002. if (this.treeIndex < 0) {
  1003. return this.result === 0 ||
  1004. // If we are parsing an attribute
  1005. (this.decodeMode === DecodingMode.Attribute &&
  1006. // We shouldn't have consumed any characters after the entity,
  1007. (valueLength === 0 ||
  1008. // And there should be no invalid characters.
  1009. isEntityInAttributeInvalidEnd(char)))
  1010. ? 0
  1011. : this.emitNotTerminatedNamedEntity();
  1012. }
  1013. current = decodeTree[this.treeIndex];
  1014. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1015. // If the branch is a value, store it and continue
  1016. if (valueLength !== 0) {
  1017. // If the entity is terminated by a semicolon, we are done.
  1018. if (char === CharCodes.SEMI) {
  1019. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1020. }
  1021. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1022. if (this.decodeMode !== DecodingMode.Strict) {
  1023. this.result = this.treeIndex;
  1024. this.consumed += this.excess;
  1025. this.excess = 0;
  1026. }
  1027. }
  1028. }
  1029. return -1;
  1030. }
  1031. /**
  1032. * Emit a named entity that was not terminated with a semicolon.
  1033. *
  1034. * @returns The number of characters consumed.
  1035. */
  1036. emitNotTerminatedNamedEntity() {
  1037. var _a;
  1038. const { result, decodeTree } = this;
  1039. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1040. this.emitNamedEntityData(result, valueLength, this.consumed);
  1041. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1042. return this.consumed;
  1043. }
  1044. /**
  1045. * Emit a named entity.
  1046. *
  1047. * @param result The index of the entity in the decode tree.
  1048. * @param valueLength The number of bytes in the entity.
  1049. * @param consumed The number of characters consumed.
  1050. *
  1051. * @returns The number of characters consumed.
  1052. */
  1053. emitNamedEntityData(result, valueLength, consumed) {
  1054. const { decodeTree } = this;
  1055. this.emitCodePoint(valueLength === 1
  1056. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1057. : decodeTree[result + 1], consumed);
  1058. if (valueLength === 3) {
  1059. // For multi-byte values, we need to emit the second byte.
  1060. this.emitCodePoint(decodeTree[result + 2], consumed);
  1061. }
  1062. return consumed;
  1063. }
  1064. /**
  1065. * Signal to the parser that the end of the input was reached.
  1066. *
  1067. * Remaining data will be emitted and relevant errors will be produced.
  1068. *
  1069. * @returns The number of characters consumed.
  1070. */
  1071. end() {
  1072. var _a;
  1073. switch (this.state) {
  1074. case EntityDecoderState.NamedEntity: {
  1075. // Emit a named entity if we have one.
  1076. return this.result !== 0 &&
  1077. (this.decodeMode !== DecodingMode.Attribute ||
  1078. this.result === this.treeIndex)
  1079. ? this.emitNotTerminatedNamedEntity()
  1080. : 0;
  1081. }
  1082. // Otherwise, emit a numeric entity if we have one.
  1083. case EntityDecoderState.NumericDecimal: {
  1084. return this.emitNumericEntity(0, 2);
  1085. }
  1086. case EntityDecoderState.NumericHex: {
  1087. return this.emitNumericEntity(0, 3);
  1088. }
  1089. case EntityDecoderState.NumericStart: {
  1090. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1091. return 0;
  1092. }
  1093. case EntityDecoderState.EntityStart: {
  1094. // Return 0 if we have no entity.
  1095. return 0;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. /**
  1101. * Creates a function that decodes entities in a string.
  1102. *
  1103. * @param decodeTree The decode tree.
  1104. * @returns A function that decodes entities in a string.
  1105. */
  1106. function getDecoder(decodeTree) {
  1107. let ret = "";
  1108. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1109. return function decodeWithTrie(str, decodeMode) {
  1110. let lastIndex = 0;
  1111. let offset = 0;
  1112. while ((offset = str.indexOf("&", offset)) >= 0) {
  1113. ret += str.slice(lastIndex, offset);
  1114. decoder.startEntity(decodeMode);
  1115. const len = decoder.write(str,
  1116. // Skip the "&"
  1117. offset + 1);
  1118. if (len < 0) {
  1119. lastIndex = offset + decoder.end();
  1120. break;
  1121. }
  1122. lastIndex = offset + len;
  1123. // If `len` is 0, skip the current `&` and continue.
  1124. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1125. }
  1126. const result = ret + str.slice(lastIndex);
  1127. // Make sure we don't keep a reference to the final string.
  1128. ret = "";
  1129. return result;
  1130. };
  1131. }
  1132. /**
  1133. * Determines the branch of the current node that is taken given the current
  1134. * character. This function is used to traverse the trie.
  1135. *
  1136. * @param decodeTree The trie.
  1137. * @param current The current node.
  1138. * @param nodeIdx The index right after the current node and its value.
  1139. * @param char The current character.
  1140. * @returns The index of the next node, or -1 if no branch is taken.
  1141. */
  1142. function determineBranch(decodeTree, current, nodeIdx, char) {
  1143. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1144. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1145. // Case 1: Single branch encoded in jump offset
  1146. if (branchCount === 0) {
  1147. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1148. }
  1149. // Case 2: Multiple branches encoded in jump table
  1150. if (jumpOffset) {
  1151. const value = char - jumpOffset;
  1152. return value < 0 || value >= branchCount
  1153. ? -1
  1154. : decodeTree[nodeIdx + value] - 1;
  1155. }
  1156. // Case 3: Multiple branches encoded in dictionary
  1157. // Binary search for the character.
  1158. let lo = nodeIdx;
  1159. let hi = lo + branchCount - 1;
  1160. while (lo <= hi) {
  1161. const mid = (lo + hi) >>> 1;
  1162. const midVal = decodeTree[mid];
  1163. if (midVal < char) {
  1164. lo = mid + 1;
  1165. }
  1166. else if (midVal > char) {
  1167. hi = mid - 1;
  1168. }
  1169. else {
  1170. return decodeTree[mid + branchCount];
  1171. }
  1172. }
  1173. return -1;
  1174. }
  1175. const htmlDecoder = getDecoder(htmlDecodeTree);
  1176. getDecoder(xmlDecodeTree);
  1177. /**
  1178. * Decodes an HTML string.
  1179. *
  1180. * @param str The string to decode.
  1181. * @param mode The decoding mode.
  1182. * @returns The decoded string.
  1183. */
  1184. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1185. return htmlDecoder(str, mode);
  1186. }
  1187. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1188. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1189. function isTagStartChar(c) {
  1190. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1191. }
  1192. function isWhitespace$1(c) {
  1193. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1194. }
  1195. function isEndOfTagSection(c) {
  1196. return c === 47 || c === 62 || isWhitespace$1(c);
  1197. }
  1198. function toCharCodes(str) {
  1199. const ret = new Uint8Array(str.length);
  1200. for (let i = 0; i < str.length; i++) {
  1201. ret[i] = str.charCodeAt(i);
  1202. }
  1203. return ret;
  1204. }
  1205. const Sequences = {
  1206. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1207. // CDATA[
  1208. CdataEnd: new Uint8Array([93, 93, 62]),
  1209. // ]]>
  1210. CommentEnd: new Uint8Array([45, 45, 62]),
  1211. // `-->`
  1212. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1213. // `<\/script`
  1214. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1215. // `</style`
  1216. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1217. // `</title`
  1218. TextareaEnd: new Uint8Array([
  1219. 60,
  1220. 47,
  1221. 116,
  1222. 101,
  1223. 120,
  1224. 116,
  1225. 97,
  1226. 114,
  1227. 101,
  1228. 97
  1229. ])
  1230. // `</textarea
  1231. };
  1232. let Tokenizer$1 = class Tokenizer {
  1233. constructor(stack, cbs) {
  1234. this.stack = stack;
  1235. this.cbs = cbs;
  1236. /** The current state the tokenizer is in. */
  1237. this.state = 1;
  1238. /** The read buffer. */
  1239. this.buffer = "";
  1240. /** The beginning of the section that is currently being read. */
  1241. this.sectionStart = 0;
  1242. /** The index within the buffer that we are currently looking at. */
  1243. this.index = 0;
  1244. /** The start of the last entity. */
  1245. this.entityStart = 0;
  1246. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1247. this.baseState = 1;
  1248. /** For special parsing behavior inside of script and style tags. */
  1249. this.inRCDATA = false;
  1250. /** For disabling RCDATA tags handling */
  1251. this.inXML = false;
  1252. /** For disabling interpolation parsing in v-pre */
  1253. this.inVPre = false;
  1254. /** Record newline positions for fast line / column calculation */
  1255. this.newlines = [];
  1256. this.mode = 0;
  1257. this.delimiterOpen = defaultDelimitersOpen;
  1258. this.delimiterClose = defaultDelimitersClose;
  1259. this.delimiterIndex = -1;
  1260. this.currentSequence = void 0;
  1261. this.sequenceIndex = 0;
  1262. {
  1263. this.entityDecoder = new EntityDecoder(
  1264. htmlDecodeTree,
  1265. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1266. );
  1267. }
  1268. }
  1269. get inSFCRoot() {
  1270. return this.mode === 2 && this.stack.length === 0;
  1271. }
  1272. reset() {
  1273. this.state = 1;
  1274. this.mode = 0;
  1275. this.buffer = "";
  1276. this.sectionStart = 0;
  1277. this.index = 0;
  1278. this.baseState = 1;
  1279. this.inRCDATA = false;
  1280. this.currentSequence = void 0;
  1281. this.newlines.length = 0;
  1282. this.delimiterOpen = defaultDelimitersOpen;
  1283. this.delimiterClose = defaultDelimitersClose;
  1284. }
  1285. /**
  1286. * Generate Position object with line / column information using recorded
  1287. * newline positions. We know the index is always going to be an already
  1288. * processed index, so all the newlines up to this index should have been
  1289. * recorded.
  1290. */
  1291. getPos(index) {
  1292. let line = 1;
  1293. let column = index + 1;
  1294. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1295. const newlineIndex = this.newlines[i];
  1296. if (index > newlineIndex) {
  1297. line = i + 2;
  1298. column = index - newlineIndex;
  1299. break;
  1300. }
  1301. }
  1302. return {
  1303. column,
  1304. line,
  1305. offset: index
  1306. };
  1307. }
  1308. peek() {
  1309. return this.buffer.charCodeAt(this.index + 1);
  1310. }
  1311. stateText(c) {
  1312. if (c === 60) {
  1313. if (this.index > this.sectionStart) {
  1314. this.cbs.ontext(this.sectionStart, this.index);
  1315. }
  1316. this.state = 5;
  1317. this.sectionStart = this.index;
  1318. } else if (c === 38) {
  1319. this.startEntity();
  1320. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1321. this.state = 2;
  1322. this.delimiterIndex = 0;
  1323. this.stateInterpolationOpen(c);
  1324. }
  1325. }
  1326. stateInterpolationOpen(c) {
  1327. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1328. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1329. const start = this.index + 1 - this.delimiterOpen.length;
  1330. if (start > this.sectionStart) {
  1331. this.cbs.ontext(this.sectionStart, start);
  1332. }
  1333. this.state = 3;
  1334. this.sectionStart = start;
  1335. } else {
  1336. this.delimiterIndex++;
  1337. }
  1338. } else if (this.inRCDATA) {
  1339. this.state = 32;
  1340. this.stateInRCDATA(c);
  1341. } else {
  1342. this.state = 1;
  1343. this.stateText(c);
  1344. }
  1345. }
  1346. stateInterpolation(c) {
  1347. if (c === this.delimiterClose[0]) {
  1348. this.state = 4;
  1349. this.delimiterIndex = 0;
  1350. this.stateInterpolationClose(c);
  1351. }
  1352. }
  1353. stateInterpolationClose(c) {
  1354. if (c === this.delimiterClose[this.delimiterIndex]) {
  1355. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1356. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1357. if (this.inRCDATA) {
  1358. this.state = 32;
  1359. } else {
  1360. this.state = 1;
  1361. }
  1362. this.sectionStart = this.index + 1;
  1363. } else {
  1364. this.delimiterIndex++;
  1365. }
  1366. } else {
  1367. this.state = 3;
  1368. this.stateInterpolation(c);
  1369. }
  1370. }
  1371. stateSpecialStartSequence(c) {
  1372. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1373. const isMatch = isEnd ? (
  1374. // If we are at the end of the sequence, make sure the tag name has ended
  1375. isEndOfTagSection(c)
  1376. ) : (
  1377. // Otherwise, do a case-insensitive comparison
  1378. (c | 32) === this.currentSequence[this.sequenceIndex]
  1379. );
  1380. if (!isMatch) {
  1381. this.inRCDATA = false;
  1382. } else if (!isEnd) {
  1383. this.sequenceIndex++;
  1384. return;
  1385. }
  1386. this.sequenceIndex = 0;
  1387. this.state = 6;
  1388. this.stateInTagName(c);
  1389. }
  1390. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1391. stateInRCDATA(c) {
  1392. if (this.sequenceIndex === this.currentSequence.length) {
  1393. if (c === 62 || isWhitespace$1(c)) {
  1394. const endOfText = this.index - this.currentSequence.length;
  1395. if (this.sectionStart < endOfText) {
  1396. const actualIndex = this.index;
  1397. this.index = endOfText;
  1398. this.cbs.ontext(this.sectionStart, endOfText);
  1399. this.index = actualIndex;
  1400. }
  1401. this.sectionStart = endOfText + 2;
  1402. this.stateInClosingTagName(c);
  1403. this.inRCDATA = false;
  1404. return;
  1405. }
  1406. this.sequenceIndex = 0;
  1407. }
  1408. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1409. this.sequenceIndex += 1;
  1410. } else if (this.sequenceIndex === 0) {
  1411. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1412. if (c === 38) {
  1413. this.startEntity();
  1414. } else if (c === this.delimiterOpen[0]) {
  1415. this.state = 2;
  1416. this.delimiterIndex = 0;
  1417. this.stateInterpolationOpen(c);
  1418. }
  1419. } else if (this.fastForwardTo(60)) {
  1420. this.sequenceIndex = 1;
  1421. }
  1422. } else {
  1423. this.sequenceIndex = Number(c === 60);
  1424. }
  1425. }
  1426. stateCDATASequence(c) {
  1427. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1428. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1429. this.state = 28;
  1430. this.currentSequence = Sequences.CdataEnd;
  1431. this.sequenceIndex = 0;
  1432. this.sectionStart = this.index + 1;
  1433. }
  1434. } else {
  1435. this.sequenceIndex = 0;
  1436. this.state = 23;
  1437. this.stateInDeclaration(c);
  1438. }
  1439. }
  1440. /**
  1441. * When we wait for one specific character, we can speed things up
  1442. * by skipping through the buffer until we find it.
  1443. *
  1444. * @returns Whether the character was found.
  1445. */
  1446. fastForwardTo(c) {
  1447. while (++this.index < this.buffer.length) {
  1448. const cc = this.buffer.charCodeAt(this.index);
  1449. if (cc === 10) {
  1450. this.newlines.push(this.index);
  1451. }
  1452. if (cc === c) {
  1453. return true;
  1454. }
  1455. }
  1456. this.index = this.buffer.length - 1;
  1457. return false;
  1458. }
  1459. /**
  1460. * Comments and CDATA end with `-->` and `]]>`.
  1461. *
  1462. * Their common qualities are:
  1463. * - Their end sequences have a distinct character they start with.
  1464. * - That character is then repeated, so we have to check multiple repeats.
  1465. * - All characters but the start character of the sequence can be skipped.
  1466. */
  1467. stateInCommentLike(c) {
  1468. if (c === this.currentSequence[this.sequenceIndex]) {
  1469. if (++this.sequenceIndex === this.currentSequence.length) {
  1470. if (this.currentSequence === Sequences.CdataEnd) {
  1471. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1472. } else {
  1473. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1474. }
  1475. this.sequenceIndex = 0;
  1476. this.sectionStart = this.index + 1;
  1477. this.state = 1;
  1478. }
  1479. } else if (this.sequenceIndex === 0) {
  1480. if (this.fastForwardTo(this.currentSequence[0])) {
  1481. this.sequenceIndex = 1;
  1482. }
  1483. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1484. this.sequenceIndex = 0;
  1485. }
  1486. }
  1487. startSpecial(sequence, offset) {
  1488. this.enterRCDATA(sequence, offset);
  1489. this.state = 31;
  1490. }
  1491. enterRCDATA(sequence, offset) {
  1492. this.inRCDATA = true;
  1493. this.currentSequence = sequence;
  1494. this.sequenceIndex = offset;
  1495. }
  1496. stateBeforeTagName(c) {
  1497. if (c === 33) {
  1498. this.state = 22;
  1499. this.sectionStart = this.index + 1;
  1500. } else if (c === 63) {
  1501. this.state = 24;
  1502. this.sectionStart = this.index + 1;
  1503. } else if (isTagStartChar(c)) {
  1504. this.sectionStart = this.index;
  1505. if (this.mode === 0) {
  1506. this.state = 6;
  1507. } else if (this.inSFCRoot) {
  1508. this.state = 34;
  1509. } else if (!this.inXML) {
  1510. if (c === 116) {
  1511. this.state = 30;
  1512. } else {
  1513. this.state = c === 115 ? 29 : 6;
  1514. }
  1515. } else {
  1516. this.state = 6;
  1517. }
  1518. } else if (c === 47) {
  1519. this.state = 8;
  1520. } else {
  1521. this.state = 1;
  1522. this.stateText(c);
  1523. }
  1524. }
  1525. stateInTagName(c) {
  1526. if (isEndOfTagSection(c)) {
  1527. this.handleTagName(c);
  1528. }
  1529. }
  1530. stateInSFCRootTagName(c) {
  1531. if (isEndOfTagSection(c)) {
  1532. const tag = this.buffer.slice(this.sectionStart, this.index);
  1533. if (tag !== "template") {
  1534. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1535. }
  1536. this.handleTagName(c);
  1537. }
  1538. }
  1539. handleTagName(c) {
  1540. this.cbs.onopentagname(this.sectionStart, this.index);
  1541. this.sectionStart = -1;
  1542. this.state = 11;
  1543. this.stateBeforeAttrName(c);
  1544. }
  1545. stateBeforeClosingTagName(c) {
  1546. if (isWhitespace$1(c)) ; else if (c === 62) {
  1547. {
  1548. this.cbs.onerr(14, this.index);
  1549. }
  1550. this.state = 1;
  1551. this.sectionStart = this.index + 1;
  1552. } else {
  1553. this.state = isTagStartChar(c) ? 9 : 27;
  1554. this.sectionStart = this.index;
  1555. }
  1556. }
  1557. stateInClosingTagName(c) {
  1558. if (c === 62 || isWhitespace$1(c)) {
  1559. this.cbs.onclosetag(this.sectionStart, this.index);
  1560. this.sectionStart = -1;
  1561. this.state = 10;
  1562. this.stateAfterClosingTagName(c);
  1563. }
  1564. }
  1565. stateAfterClosingTagName(c) {
  1566. if (c === 62) {
  1567. this.state = 1;
  1568. this.sectionStart = this.index + 1;
  1569. }
  1570. }
  1571. stateBeforeAttrName(c) {
  1572. if (c === 62) {
  1573. this.cbs.onopentagend(this.index);
  1574. if (this.inRCDATA) {
  1575. this.state = 32;
  1576. } else {
  1577. this.state = 1;
  1578. }
  1579. this.sectionStart = this.index + 1;
  1580. } else if (c === 47) {
  1581. this.state = 7;
  1582. if (this.peek() !== 62) {
  1583. this.cbs.onerr(22, this.index);
  1584. }
  1585. } else if (c === 60 && this.peek() === 47) {
  1586. this.cbs.onopentagend(this.index);
  1587. this.state = 5;
  1588. this.sectionStart = this.index;
  1589. } else if (!isWhitespace$1(c)) {
  1590. if (c === 61) {
  1591. this.cbs.onerr(
  1592. 19,
  1593. this.index
  1594. );
  1595. }
  1596. this.handleAttrStart(c);
  1597. }
  1598. }
  1599. handleAttrStart(c) {
  1600. if (c === 118 && this.peek() === 45) {
  1601. this.state = 13;
  1602. this.sectionStart = this.index;
  1603. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1604. this.cbs.ondirname(this.index, this.index + 1);
  1605. this.state = 14;
  1606. this.sectionStart = this.index + 1;
  1607. } else {
  1608. this.state = 12;
  1609. this.sectionStart = this.index;
  1610. }
  1611. }
  1612. stateInSelfClosingTag(c) {
  1613. if (c === 62) {
  1614. this.cbs.onselfclosingtag(this.index);
  1615. this.state = 1;
  1616. this.sectionStart = this.index + 1;
  1617. this.inRCDATA = false;
  1618. } else if (!isWhitespace$1(c)) {
  1619. this.state = 11;
  1620. this.stateBeforeAttrName(c);
  1621. }
  1622. }
  1623. stateInAttrName(c) {
  1624. if (c === 61 || isEndOfTagSection(c)) {
  1625. this.cbs.onattribname(this.sectionStart, this.index);
  1626. this.handleAttrNameEnd(c);
  1627. } else if (c === 34 || c === 39 || c === 60) {
  1628. this.cbs.onerr(
  1629. 17,
  1630. this.index
  1631. );
  1632. }
  1633. }
  1634. stateInDirName(c) {
  1635. if (c === 61 || isEndOfTagSection(c)) {
  1636. this.cbs.ondirname(this.sectionStart, this.index);
  1637. this.handleAttrNameEnd(c);
  1638. } else if (c === 58) {
  1639. this.cbs.ondirname(this.sectionStart, this.index);
  1640. this.state = 14;
  1641. this.sectionStart = this.index + 1;
  1642. } else if (c === 46) {
  1643. this.cbs.ondirname(this.sectionStart, this.index);
  1644. this.state = 16;
  1645. this.sectionStart = this.index + 1;
  1646. }
  1647. }
  1648. stateInDirArg(c) {
  1649. if (c === 61 || isEndOfTagSection(c)) {
  1650. this.cbs.ondirarg(this.sectionStart, this.index);
  1651. this.handleAttrNameEnd(c);
  1652. } else if (c === 91) {
  1653. this.state = 15;
  1654. } else if (c === 46) {
  1655. this.cbs.ondirarg(this.sectionStart, this.index);
  1656. this.state = 16;
  1657. this.sectionStart = this.index + 1;
  1658. }
  1659. }
  1660. stateInDynamicDirArg(c) {
  1661. if (c === 93) {
  1662. this.state = 14;
  1663. } else if (c === 61 || isEndOfTagSection(c)) {
  1664. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1665. this.handleAttrNameEnd(c);
  1666. {
  1667. this.cbs.onerr(
  1668. 27,
  1669. this.index
  1670. );
  1671. }
  1672. }
  1673. }
  1674. stateInDirModifier(c) {
  1675. if (c === 61 || isEndOfTagSection(c)) {
  1676. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1677. this.handleAttrNameEnd(c);
  1678. } else if (c === 46) {
  1679. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1680. this.sectionStart = this.index + 1;
  1681. }
  1682. }
  1683. handleAttrNameEnd(c) {
  1684. this.sectionStart = this.index;
  1685. this.state = 17;
  1686. this.cbs.onattribnameend(this.index);
  1687. this.stateAfterAttrName(c);
  1688. }
  1689. stateAfterAttrName(c) {
  1690. if (c === 61) {
  1691. this.state = 18;
  1692. } else if (c === 47 || c === 62) {
  1693. this.cbs.onattribend(0, this.sectionStart);
  1694. this.sectionStart = -1;
  1695. this.state = 11;
  1696. this.stateBeforeAttrName(c);
  1697. } else if (!isWhitespace$1(c)) {
  1698. this.cbs.onattribend(0, this.sectionStart);
  1699. this.handleAttrStart(c);
  1700. }
  1701. }
  1702. stateBeforeAttrValue(c) {
  1703. if (c === 34) {
  1704. this.state = 19;
  1705. this.sectionStart = this.index + 1;
  1706. } else if (c === 39) {
  1707. this.state = 20;
  1708. this.sectionStart = this.index + 1;
  1709. } else if (!isWhitespace$1(c)) {
  1710. this.sectionStart = this.index;
  1711. this.state = 21;
  1712. this.stateInAttrValueNoQuotes(c);
  1713. }
  1714. }
  1715. handleInAttrValue(c, quote) {
  1716. if (c === quote || false) {
  1717. this.cbs.onattribdata(this.sectionStart, this.index);
  1718. this.sectionStart = -1;
  1719. this.cbs.onattribend(
  1720. quote === 34 ? 3 : 2,
  1721. this.index + 1
  1722. );
  1723. this.state = 11;
  1724. } else if (c === 38) {
  1725. this.startEntity();
  1726. }
  1727. }
  1728. stateInAttrValueDoubleQuotes(c) {
  1729. this.handleInAttrValue(c, 34);
  1730. }
  1731. stateInAttrValueSingleQuotes(c) {
  1732. this.handleInAttrValue(c, 39);
  1733. }
  1734. stateInAttrValueNoQuotes(c) {
  1735. if (isWhitespace$1(c) || c === 62) {
  1736. this.cbs.onattribdata(this.sectionStart, this.index);
  1737. this.sectionStart = -1;
  1738. this.cbs.onattribend(1, this.index);
  1739. this.state = 11;
  1740. this.stateBeforeAttrName(c);
  1741. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1742. this.cbs.onerr(
  1743. 18,
  1744. this.index
  1745. );
  1746. } else if (c === 38) {
  1747. this.startEntity();
  1748. }
  1749. }
  1750. stateBeforeDeclaration(c) {
  1751. if (c === 91) {
  1752. this.state = 26;
  1753. this.sequenceIndex = 0;
  1754. } else {
  1755. this.state = c === 45 ? 25 : 23;
  1756. }
  1757. }
  1758. stateInDeclaration(c) {
  1759. if (c === 62 || this.fastForwardTo(62)) {
  1760. this.state = 1;
  1761. this.sectionStart = this.index + 1;
  1762. }
  1763. }
  1764. stateInProcessingInstruction(c) {
  1765. if (c === 62 || this.fastForwardTo(62)) {
  1766. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1767. this.state = 1;
  1768. this.sectionStart = this.index + 1;
  1769. }
  1770. }
  1771. stateBeforeComment(c) {
  1772. if (c === 45) {
  1773. this.state = 28;
  1774. this.currentSequence = Sequences.CommentEnd;
  1775. this.sequenceIndex = 2;
  1776. this.sectionStart = this.index + 1;
  1777. } else {
  1778. this.state = 23;
  1779. }
  1780. }
  1781. stateInSpecialComment(c) {
  1782. if (c === 62 || this.fastForwardTo(62)) {
  1783. this.cbs.oncomment(this.sectionStart, this.index);
  1784. this.state = 1;
  1785. this.sectionStart = this.index + 1;
  1786. }
  1787. }
  1788. stateBeforeSpecialS(c) {
  1789. if (c === Sequences.ScriptEnd[3]) {
  1790. this.startSpecial(Sequences.ScriptEnd, 4);
  1791. } else if (c === Sequences.StyleEnd[3]) {
  1792. this.startSpecial(Sequences.StyleEnd, 4);
  1793. } else {
  1794. this.state = 6;
  1795. this.stateInTagName(c);
  1796. }
  1797. }
  1798. stateBeforeSpecialT(c) {
  1799. if (c === Sequences.TitleEnd[3]) {
  1800. this.startSpecial(Sequences.TitleEnd, 4);
  1801. } else if (c === Sequences.TextareaEnd[3]) {
  1802. this.startSpecial(Sequences.TextareaEnd, 4);
  1803. } else {
  1804. this.state = 6;
  1805. this.stateInTagName(c);
  1806. }
  1807. }
  1808. startEntity() {
  1809. {
  1810. this.baseState = this.state;
  1811. this.state = 33;
  1812. this.entityStart = this.index;
  1813. this.entityDecoder.startEntity(
  1814. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1815. );
  1816. }
  1817. }
  1818. stateInEntity() {
  1819. {
  1820. const length = this.entityDecoder.write(this.buffer, this.index);
  1821. if (length >= 0) {
  1822. this.state = this.baseState;
  1823. if (length === 0) {
  1824. this.index = this.entityStart;
  1825. }
  1826. } else {
  1827. this.index = this.buffer.length - 1;
  1828. }
  1829. }
  1830. }
  1831. /**
  1832. * Iterates through the buffer, calling the function corresponding to the current state.
  1833. *
  1834. * States that are more likely to be hit are higher up, as a performance improvement.
  1835. */
  1836. parse(input) {
  1837. this.buffer = input;
  1838. while (this.index < this.buffer.length) {
  1839. const c = this.buffer.charCodeAt(this.index);
  1840. if (c === 10) {
  1841. this.newlines.push(this.index);
  1842. }
  1843. switch (this.state) {
  1844. case 1: {
  1845. this.stateText(c);
  1846. break;
  1847. }
  1848. case 2: {
  1849. this.stateInterpolationOpen(c);
  1850. break;
  1851. }
  1852. case 3: {
  1853. this.stateInterpolation(c);
  1854. break;
  1855. }
  1856. case 4: {
  1857. this.stateInterpolationClose(c);
  1858. break;
  1859. }
  1860. case 31: {
  1861. this.stateSpecialStartSequence(c);
  1862. break;
  1863. }
  1864. case 32: {
  1865. this.stateInRCDATA(c);
  1866. break;
  1867. }
  1868. case 26: {
  1869. this.stateCDATASequence(c);
  1870. break;
  1871. }
  1872. case 19: {
  1873. this.stateInAttrValueDoubleQuotes(c);
  1874. break;
  1875. }
  1876. case 12: {
  1877. this.stateInAttrName(c);
  1878. break;
  1879. }
  1880. case 13: {
  1881. this.stateInDirName(c);
  1882. break;
  1883. }
  1884. case 14: {
  1885. this.stateInDirArg(c);
  1886. break;
  1887. }
  1888. case 15: {
  1889. this.stateInDynamicDirArg(c);
  1890. break;
  1891. }
  1892. case 16: {
  1893. this.stateInDirModifier(c);
  1894. break;
  1895. }
  1896. case 28: {
  1897. this.stateInCommentLike(c);
  1898. break;
  1899. }
  1900. case 27: {
  1901. this.stateInSpecialComment(c);
  1902. break;
  1903. }
  1904. case 11: {
  1905. this.stateBeforeAttrName(c);
  1906. break;
  1907. }
  1908. case 6: {
  1909. this.stateInTagName(c);
  1910. break;
  1911. }
  1912. case 34: {
  1913. this.stateInSFCRootTagName(c);
  1914. break;
  1915. }
  1916. case 9: {
  1917. this.stateInClosingTagName(c);
  1918. break;
  1919. }
  1920. case 5: {
  1921. this.stateBeforeTagName(c);
  1922. break;
  1923. }
  1924. case 17: {
  1925. this.stateAfterAttrName(c);
  1926. break;
  1927. }
  1928. case 20: {
  1929. this.stateInAttrValueSingleQuotes(c);
  1930. break;
  1931. }
  1932. case 18: {
  1933. this.stateBeforeAttrValue(c);
  1934. break;
  1935. }
  1936. case 8: {
  1937. this.stateBeforeClosingTagName(c);
  1938. break;
  1939. }
  1940. case 10: {
  1941. this.stateAfterClosingTagName(c);
  1942. break;
  1943. }
  1944. case 29: {
  1945. this.stateBeforeSpecialS(c);
  1946. break;
  1947. }
  1948. case 30: {
  1949. this.stateBeforeSpecialT(c);
  1950. break;
  1951. }
  1952. case 21: {
  1953. this.stateInAttrValueNoQuotes(c);
  1954. break;
  1955. }
  1956. case 7: {
  1957. this.stateInSelfClosingTag(c);
  1958. break;
  1959. }
  1960. case 23: {
  1961. this.stateInDeclaration(c);
  1962. break;
  1963. }
  1964. case 22: {
  1965. this.stateBeforeDeclaration(c);
  1966. break;
  1967. }
  1968. case 25: {
  1969. this.stateBeforeComment(c);
  1970. break;
  1971. }
  1972. case 24: {
  1973. this.stateInProcessingInstruction(c);
  1974. break;
  1975. }
  1976. case 33: {
  1977. this.stateInEntity();
  1978. break;
  1979. }
  1980. }
  1981. this.index++;
  1982. }
  1983. this.cleanup();
  1984. this.finish();
  1985. }
  1986. /**
  1987. * Remove data that has already been consumed from the buffer.
  1988. */
  1989. cleanup() {
  1990. if (this.sectionStart !== this.index) {
  1991. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  1992. this.cbs.ontext(this.sectionStart, this.index);
  1993. this.sectionStart = this.index;
  1994. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  1995. this.cbs.onattribdata(this.sectionStart, this.index);
  1996. this.sectionStart = this.index;
  1997. }
  1998. }
  1999. }
  2000. finish() {
  2001. if (this.state === 33) {
  2002. this.entityDecoder.end();
  2003. this.state = this.baseState;
  2004. }
  2005. this.handleTrailingData();
  2006. this.cbs.onend();
  2007. }
  2008. /** Handle any trailing data. */
  2009. handleTrailingData() {
  2010. const endIndex = this.buffer.length;
  2011. if (this.sectionStart >= endIndex) {
  2012. return;
  2013. }
  2014. if (this.state === 28) {
  2015. if (this.currentSequence === Sequences.CdataEnd) {
  2016. this.cbs.oncdata(this.sectionStart, endIndex);
  2017. } else {
  2018. this.cbs.oncomment(this.sectionStart, endIndex);
  2019. }
  2020. } 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 {
  2021. this.cbs.ontext(this.sectionStart, endIndex);
  2022. }
  2023. }
  2024. emitCodePoint(cp, consumed) {
  2025. {
  2026. if (this.baseState !== 1 && this.baseState !== 32) {
  2027. if (this.sectionStart < this.entityStart) {
  2028. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2029. }
  2030. this.sectionStart = this.entityStart + consumed;
  2031. this.index = this.sectionStart - 1;
  2032. this.cbs.onattribentity(
  2033. fromCodePoint(cp),
  2034. this.entityStart,
  2035. this.sectionStart
  2036. );
  2037. } else {
  2038. if (this.sectionStart < this.entityStart) {
  2039. this.cbs.ontext(this.sectionStart, this.entityStart);
  2040. }
  2041. this.sectionStart = this.entityStart + consumed;
  2042. this.index = this.sectionStart - 1;
  2043. this.cbs.ontextentity(
  2044. fromCodePoint(cp),
  2045. this.entityStart,
  2046. this.sectionStart
  2047. );
  2048. }
  2049. }
  2050. }
  2051. };
  2052. const CompilerDeprecationTypes = {
  2053. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2054. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2055. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2056. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2057. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2058. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2059. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2060. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2061. };
  2062. const deprecationData = {
  2063. ["COMPILER_IS_ON_ELEMENT"]: {
  2064. 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:".`,
  2065. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2066. },
  2067. ["COMPILER_V_BIND_SYNC"]: {
  2068. 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}\`.`,
  2069. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2070. },
  2071. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2072. 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.`,
  2073. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2074. },
  2075. ["COMPILER_V_ON_NATIVE"]: {
  2076. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2077. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2078. },
  2079. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2080. 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.`,
  2081. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2082. },
  2083. ["COMPILER_NATIVE_TEMPLATE"]: {
  2084. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2085. },
  2086. ["COMPILER_INLINE_TEMPLATE"]: {
  2087. message: `"inline-template" has been removed in Vue 3.`,
  2088. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2089. },
  2090. ["COMPILER_FILTERS"]: {
  2091. 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.`,
  2092. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2093. }
  2094. };
  2095. function getCompatValue(key, { compatConfig }) {
  2096. const value = compatConfig && compatConfig[key];
  2097. if (key === "MODE") {
  2098. return value || 3;
  2099. } else {
  2100. return value;
  2101. }
  2102. }
  2103. function isCompatEnabled(key, context) {
  2104. const mode = getCompatValue("MODE", context);
  2105. const value = getCompatValue(key, context);
  2106. return mode === 3 ? value === true : value !== false;
  2107. }
  2108. function checkCompatEnabled(key, context, loc, ...args) {
  2109. const enabled = isCompatEnabled(key, context);
  2110. if (enabled) {
  2111. warnDeprecation(key, context, loc, ...args);
  2112. }
  2113. return enabled;
  2114. }
  2115. function warnDeprecation(key, context, loc, ...args) {
  2116. const val = getCompatValue(key, context);
  2117. if (val === "suppress-warning") {
  2118. return;
  2119. }
  2120. const { message, link } = deprecationData[key];
  2121. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2122. Details: ${link}` : ``}`;
  2123. const err = new SyntaxError(msg);
  2124. err.code = key;
  2125. if (loc)
  2126. err.loc = loc;
  2127. context.onWarn(err);
  2128. }
  2129. function defaultOnError(error) {
  2130. throw error;
  2131. }
  2132. function defaultOnWarn(msg) {
  2133. console.warn(`[Vue warn] ${msg.message}`);
  2134. }
  2135. function createCompilerError(code, loc, messages, additionalMessage) {
  2136. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2137. const error = new SyntaxError(String(msg));
  2138. error.code = code;
  2139. error.loc = loc;
  2140. return error;
  2141. }
  2142. const ErrorCodes = {
  2143. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2144. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2145. "CDATA_IN_HTML_CONTENT": 1,
  2146. "1": "CDATA_IN_HTML_CONTENT",
  2147. "DUPLICATE_ATTRIBUTE": 2,
  2148. "2": "DUPLICATE_ATTRIBUTE",
  2149. "END_TAG_WITH_ATTRIBUTES": 3,
  2150. "3": "END_TAG_WITH_ATTRIBUTES",
  2151. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2152. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2153. "EOF_BEFORE_TAG_NAME": 5,
  2154. "5": "EOF_BEFORE_TAG_NAME",
  2155. "EOF_IN_CDATA": 6,
  2156. "6": "EOF_IN_CDATA",
  2157. "EOF_IN_COMMENT": 7,
  2158. "7": "EOF_IN_COMMENT",
  2159. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2160. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2161. "EOF_IN_TAG": 9,
  2162. "9": "EOF_IN_TAG",
  2163. "INCORRECTLY_CLOSED_COMMENT": 10,
  2164. "10": "INCORRECTLY_CLOSED_COMMENT",
  2165. "INCORRECTLY_OPENED_COMMENT": 11,
  2166. "11": "INCORRECTLY_OPENED_COMMENT",
  2167. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2168. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2169. "MISSING_ATTRIBUTE_VALUE": 13,
  2170. "13": "MISSING_ATTRIBUTE_VALUE",
  2171. "MISSING_END_TAG_NAME": 14,
  2172. "14": "MISSING_END_TAG_NAME",
  2173. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2174. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2175. "NESTED_COMMENT": 16,
  2176. "16": "NESTED_COMMENT",
  2177. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2178. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2179. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2180. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2181. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2182. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2183. "UNEXPECTED_NULL_CHARACTER": 20,
  2184. "20": "UNEXPECTED_NULL_CHARACTER",
  2185. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2186. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2187. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2188. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2189. "X_INVALID_END_TAG": 23,
  2190. "23": "X_INVALID_END_TAG",
  2191. "X_MISSING_END_TAG": 24,
  2192. "24": "X_MISSING_END_TAG",
  2193. "X_MISSING_INTERPOLATION_END": 25,
  2194. "25": "X_MISSING_INTERPOLATION_END",
  2195. "X_MISSING_DIRECTIVE_NAME": 26,
  2196. "26": "X_MISSING_DIRECTIVE_NAME",
  2197. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2198. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2199. "X_V_IF_NO_EXPRESSION": 28,
  2200. "28": "X_V_IF_NO_EXPRESSION",
  2201. "X_V_IF_SAME_KEY": 29,
  2202. "29": "X_V_IF_SAME_KEY",
  2203. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2204. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2205. "X_V_FOR_NO_EXPRESSION": 31,
  2206. "31": "X_V_FOR_NO_EXPRESSION",
  2207. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2208. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2209. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2210. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2211. "X_V_BIND_NO_EXPRESSION": 34,
  2212. "34": "X_V_BIND_NO_EXPRESSION",
  2213. "X_V_ON_NO_EXPRESSION": 35,
  2214. "35": "X_V_ON_NO_EXPRESSION",
  2215. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2216. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2217. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2218. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2219. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2220. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2221. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2222. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2223. "X_V_SLOT_MISPLACED": 40,
  2224. "40": "X_V_SLOT_MISPLACED",
  2225. "X_V_MODEL_NO_EXPRESSION": 41,
  2226. "41": "X_V_MODEL_NO_EXPRESSION",
  2227. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2228. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2229. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2230. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2231. "X_V_MODEL_ON_PROPS": 44,
  2232. "44": "X_V_MODEL_ON_PROPS",
  2233. "X_INVALID_EXPRESSION": 45,
  2234. "45": "X_INVALID_EXPRESSION",
  2235. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2236. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2237. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2238. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2239. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2240. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2241. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2242. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2243. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2244. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2245. "X_VNODE_HOOKS": 51,
  2246. "51": "X_VNODE_HOOKS",
  2247. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2248. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2249. "__EXTEND_POINT__": 53,
  2250. "53": "__EXTEND_POINT__"
  2251. };
  2252. const errorMessages$1 = {
  2253. // parse errors
  2254. [0]: "Illegal comment.",
  2255. [1]: "CDATA section is allowed only in XML context.",
  2256. [2]: "Duplicate attribute.",
  2257. [3]: "End tag cannot have attributes.",
  2258. [4]: "Illegal '/' in tags.",
  2259. [5]: "Unexpected EOF in tag.",
  2260. [6]: "Unexpected EOF in CDATA section.",
  2261. [7]: "Unexpected EOF in comment.",
  2262. [8]: "Unexpected EOF in script.",
  2263. [9]: "Unexpected EOF in tag.",
  2264. [10]: "Incorrectly closed comment.",
  2265. [11]: "Incorrectly opened comment.",
  2266. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2267. [13]: "Attribute value was expected.",
  2268. [14]: "End tag name was expected.",
  2269. [15]: "Whitespace was expected.",
  2270. [16]: "Unexpected '<!--' in comment.",
  2271. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2272. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2273. [19]: "Attribute name cannot start with '='.",
  2274. [21]: "'<?' is allowed only in XML context.",
  2275. [20]: `Unexpected null character.`,
  2276. [22]: "Illegal '/' in tags.",
  2277. // Vue-specific parse errors
  2278. [23]: "Invalid end tag.",
  2279. [24]: "Element is missing end tag.",
  2280. [25]: "Interpolation end sign was not found.",
  2281. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2282. [26]: "Legal directive name was expected.",
  2283. // transform errors
  2284. [28]: `v-if/v-else-if is missing expression.`,
  2285. [29]: `v-if/else branches must use unique keys.`,
  2286. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2287. [31]: `v-for is missing expression.`,
  2288. [32]: `v-for has invalid expression.`,
  2289. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2290. [34]: `v-bind is missing expression.`,
  2291. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2292. [35]: `v-on is missing expression.`,
  2293. [36]: `Unexpected custom directive on <slot> outlet.`,
  2294. [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.`,
  2295. [38]: `Duplicate slot names found. `,
  2296. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2297. [40]: `v-slot can only be used on components or <template> tags.`,
  2298. [41]: `v-model is missing expression.`,
  2299. [42]: `v-model value must be a valid JavaScript member expression.`,
  2300. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2301. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2302. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2303. [45]: `Error parsing JavaScript expression: `,
  2304. [46]: `<KeepAlive> expects exactly one child component.`,
  2305. [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.`,
  2306. // generic errors
  2307. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2308. [48]: `ES module mode is not supported in this build of compiler.`,
  2309. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2310. [50]: `"scopeId" option is only supported in module mode.`,
  2311. // just to fulfill types
  2312. [53]: ``
  2313. };
  2314. function getDefaultExportFromCjs (x) {
  2315. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2316. }
  2317. function getAugmentedNamespace(n) {
  2318. if (n.__esModule) return n;
  2319. var f = n.default;
  2320. if (typeof f == "function") {
  2321. var a = function a () {
  2322. if (this instanceof a) {
  2323. return Reflect.construct(f, arguments, this.constructor);
  2324. }
  2325. return f.apply(this, arguments);
  2326. };
  2327. a.prototype = f.prototype;
  2328. } else a = {};
  2329. Object.defineProperty(a, '__esModule', {value: true});
  2330. Object.keys(n).forEach(function (k) {
  2331. var d = Object.getOwnPropertyDescriptor(n, k);
  2332. Object.defineProperty(a, k, d.get ? d : {
  2333. enumerable: true,
  2334. get: function () {
  2335. return n[k];
  2336. }
  2337. });
  2338. });
  2339. return a;
  2340. }
  2341. var lib = {};
  2342. Object.defineProperty(lib, '__esModule', {
  2343. value: true
  2344. });
  2345. function _objectWithoutPropertiesLoose(source, excluded) {
  2346. if (source == null) return {};
  2347. var target = {};
  2348. var sourceKeys = Object.keys(source);
  2349. var key, i;
  2350. for (i = 0; i < sourceKeys.length; i++) {
  2351. key = sourceKeys[i];
  2352. if (excluded.indexOf(key) >= 0) continue;
  2353. target[key] = source[key];
  2354. }
  2355. return target;
  2356. }
  2357. class Position {
  2358. constructor(line, col, index) {
  2359. this.line = void 0;
  2360. this.column = void 0;
  2361. this.index = void 0;
  2362. this.line = line;
  2363. this.column = col;
  2364. this.index = index;
  2365. }
  2366. }
  2367. class SourceLocation {
  2368. constructor(start, end) {
  2369. this.start = void 0;
  2370. this.end = void 0;
  2371. this.filename = void 0;
  2372. this.identifierName = void 0;
  2373. this.start = start;
  2374. this.end = end;
  2375. }
  2376. }
  2377. function createPositionWithColumnOffset(position, columnOffset) {
  2378. const {
  2379. line,
  2380. column,
  2381. index
  2382. } = position;
  2383. return new Position(line, column + columnOffset, index + columnOffset);
  2384. }
  2385. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2386. var ModuleErrors = {
  2387. ImportMetaOutsideModule: {
  2388. message: `import.meta may appear only with 'sourceType: "module"'`,
  2389. code
  2390. },
  2391. ImportOutsideModule: {
  2392. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2393. code
  2394. }
  2395. };
  2396. const NodeDescriptions = {
  2397. ArrayPattern: "array destructuring pattern",
  2398. AssignmentExpression: "assignment expression",
  2399. AssignmentPattern: "assignment expression",
  2400. ArrowFunctionExpression: "arrow function expression",
  2401. ConditionalExpression: "conditional expression",
  2402. CatchClause: "catch clause",
  2403. ForOfStatement: "for-of statement",
  2404. ForInStatement: "for-in statement",
  2405. ForStatement: "for-loop",
  2406. FormalParameters: "function parameter list",
  2407. Identifier: "identifier",
  2408. ImportSpecifier: "import specifier",
  2409. ImportDefaultSpecifier: "import default specifier",
  2410. ImportNamespaceSpecifier: "import namespace specifier",
  2411. ObjectPattern: "object destructuring pattern",
  2412. ParenthesizedExpression: "parenthesized expression",
  2413. RestElement: "rest element",
  2414. UpdateExpression: {
  2415. true: "prefix operation",
  2416. false: "postfix operation"
  2417. },
  2418. VariableDeclarator: "variable declaration",
  2419. YieldExpression: "yield expression"
  2420. };
  2421. const toNodeDescription = ({
  2422. type,
  2423. prefix
  2424. }) => type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[String(prefix)] : NodeDescriptions[type];
  2425. var StandardErrors = {
  2426. AccessorIsGenerator: ({
  2427. kind
  2428. }) => `A ${kind}ter cannot be a generator.`,
  2429. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2430. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2431. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2432. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2433. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2434. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2435. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2436. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  2437. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2438. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2439. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2440. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2441. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2442. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2443. ConstructorIsAsync: "Constructor can't be an async function.",
  2444. ConstructorIsGenerator: "Constructor can't be a generator.",
  2445. DeclarationMissingInitializer: ({
  2446. kind
  2447. }) => `Missing initializer in ${kind} declaration.`,
  2448. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2449. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2450. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2451. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2452. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2453. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2454. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2455. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2456. DeletePrivateField: "Deleting a private field is not allowed.",
  2457. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2458. DuplicateConstructor: "Duplicate constructor in the same class.",
  2459. DuplicateDefaultExport: "Only one default export allowed per module.",
  2460. DuplicateExport: ({
  2461. exportName
  2462. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2463. DuplicateProto: "Redefinition of __proto__ property.",
  2464. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2465. DynamicImportPhaseRequiresImportExpressions: ({
  2466. phase
  2467. }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
  2468. ElementAfterRest: "Rest element must be last element.",
  2469. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2470. ExportBindingIsString: ({
  2471. localName,
  2472. exportName
  2473. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2474. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2475. ForInOfLoopInitializer: ({
  2476. type
  2477. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2478. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2479. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2480. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2481. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2482. IllegalBreakContinue: ({
  2483. type
  2484. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2485. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2486. IllegalReturn: "'return' outside of function.",
  2487. 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.",
  2488. ImportBindingIsString: ({
  2489. importName
  2490. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2491. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  2492. ImportCallArity: ({
  2493. maxArgumentCount
  2494. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  2495. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2496. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2497. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2498. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2499. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2500. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2501. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2502. InvalidCodePoint: "Code point out of bounds.",
  2503. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2504. InvalidDecimal: "Invalid decimal.",
  2505. InvalidDigit: ({
  2506. radix
  2507. }) => `Expected number in radix ${radix}.`,
  2508. InvalidEscapeSequence: "Bad character escape sequence.",
  2509. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2510. InvalidEscapedReservedWord: ({
  2511. reservedWord
  2512. }) => `Escape sequence in keyword ${reservedWord}.`,
  2513. InvalidIdentifier: ({
  2514. identifierName
  2515. }) => `Invalid identifier ${identifierName}.`,
  2516. InvalidLhs: ({
  2517. ancestor
  2518. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2519. InvalidLhsBinding: ({
  2520. ancestor
  2521. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2522. InvalidLhsOptionalChaining: ({
  2523. ancestor
  2524. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2525. InvalidNumber: "Invalid number.",
  2526. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2527. InvalidOrUnexpectedToken: ({
  2528. unexpected
  2529. }) => `Unexpected character '${unexpected}'.`,
  2530. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2531. InvalidPrivateFieldResolution: ({
  2532. identifierName
  2533. }) => `Private name #${identifierName} is not defined.`,
  2534. InvalidPropertyBindingPattern: "Binding member expression.",
  2535. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2536. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2537. LabelRedeclaration: ({
  2538. labelName
  2539. }) => `Label '${labelName}' is already declared.`,
  2540. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2541. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2542. MalformedRegExpFlags: "Invalid regular expression flag.",
  2543. MissingClassName: "A class name is required.",
  2544. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2545. MissingSemicolon: "Missing semicolon.",
  2546. MissingPlugin: ({
  2547. missingPlugin
  2548. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2549. MissingOneOfPlugins: ({
  2550. missingPlugin
  2551. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2552. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2553. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2554. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2555. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2556. ModuleAttributesWithDuplicateKeys: ({
  2557. key
  2558. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2559. ModuleExportNameHasLoneSurrogate: ({
  2560. surrogateCharCode
  2561. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2562. ModuleExportUndefined: ({
  2563. localName
  2564. }) => `Export '${localName}' is not defined.`,
  2565. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2566. NewlineAfterThrow: "Illegal newline after throw.",
  2567. NoCatchOrFinally: "Missing catch or finally clause.",
  2568. NumberIdentifier: "Identifier directly after number.",
  2569. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2570. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2571. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2572. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2573. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2574. ParamDupe: "Argument name clash.",
  2575. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2576. PatternHasMethod: "Object pattern can't contain methods.",
  2577. PrivateInExpectedIn: ({
  2578. identifierName
  2579. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2580. PrivateNameRedeclaration: ({
  2581. identifierName
  2582. }) => `Duplicate private name #${identifierName}.`,
  2583. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2584. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2585. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2586. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2587. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2588. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2589. 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.",
  2590. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2591. StaticPrototype: "Classes may not have static property named prototype.",
  2592. 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?",
  2593. SuperPrivateField: "Private fields can't be accessed on super.",
  2594. TrailingDecorator: "Decorators must be attached to a class element.",
  2595. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2596. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2597. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2598. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2599. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2600. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2601. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2602. UnexpectedKeyword: ({
  2603. keyword
  2604. }) => `Unexpected keyword '${keyword}'.`,
  2605. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2606. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2607. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2608. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2609. UnexpectedPrivateField: "Unexpected private name.",
  2610. UnexpectedReservedWord: ({
  2611. reservedWord
  2612. }) => `Unexpected reserved word '${reservedWord}'.`,
  2613. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2614. UnexpectedToken: ({
  2615. expected,
  2616. unexpected
  2617. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2618. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2619. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  2620. UnsupportedBind: "Binding should be performed on object property.",
  2621. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2622. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2623. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2624. UnsupportedMetaProperty: ({
  2625. target,
  2626. onlyValidPropertyName
  2627. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2628. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2629. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2630. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2631. UnterminatedComment: "Unterminated comment.",
  2632. UnterminatedRegExp: "Unterminated regular expression.",
  2633. UnterminatedString: "Unterminated string constant.",
  2634. UnterminatedTemplate: "Unterminated template.",
  2635. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2636. VarRedeclaration: ({
  2637. identifierName
  2638. }) => `Identifier '${identifierName}' has already been declared.`,
  2639. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2640. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2641. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2642. };
  2643. var StrictModeErrors = {
  2644. StrictDelete: "Deleting local variable in strict mode.",
  2645. StrictEvalArguments: ({
  2646. referenceName
  2647. }) => `Assigning to '${referenceName}' in strict mode.`,
  2648. StrictEvalArgumentsBinding: ({
  2649. bindingName
  2650. }) => `Binding '${bindingName}' in strict mode.`,
  2651. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2652. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2653. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2654. StrictWith: "'with' in strict mode."
  2655. };
  2656. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2657. var PipelineOperatorErrors = {
  2658. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2659. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2660. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2661. PipeTopicUnconfiguredToken: ({
  2662. token
  2663. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2664. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2665. PipeUnparenthesizedBody: ({
  2666. type
  2667. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2668. type
  2669. })}; please wrap it in parentheses.`,
  2670. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2671. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2672. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2673. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2674. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2675. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2676. };
  2677. const _excluded = ["toMessage"],
  2678. _excluded2 = ["message"];
  2679. function defineHidden(obj, key, value) {
  2680. Object.defineProperty(obj, key, {
  2681. enumerable: false,
  2682. configurable: true,
  2683. value
  2684. });
  2685. }
  2686. function toParseErrorConstructor(_ref) {
  2687. let {
  2688. toMessage
  2689. } = _ref,
  2690. properties = _objectWithoutPropertiesLoose(_ref, _excluded);
  2691. return function constructor(loc, details) {
  2692. const error = new SyntaxError();
  2693. Object.assign(error, properties, {
  2694. loc,
  2695. pos: loc.index
  2696. });
  2697. if ("missingPlugin" in details) {
  2698. Object.assign(error, {
  2699. missingPlugin: details.missingPlugin
  2700. });
  2701. }
  2702. defineHidden(error, "clone", function clone(overrides = {}) {
  2703. var _overrides$loc;
  2704. const {
  2705. line,
  2706. column,
  2707. index
  2708. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2709. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2710. });
  2711. defineHidden(error, "details", details);
  2712. Object.defineProperty(error, "message", {
  2713. configurable: true,
  2714. get() {
  2715. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2716. this.message = message;
  2717. return message;
  2718. },
  2719. set(value) {
  2720. Object.defineProperty(this, "message", {
  2721. value,
  2722. writable: true
  2723. });
  2724. }
  2725. });
  2726. return error;
  2727. };
  2728. }
  2729. function ParseErrorEnum(argument, syntaxPlugin) {
  2730. if (Array.isArray(argument)) {
  2731. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2732. }
  2733. const ParseErrorConstructors = {};
  2734. for (const reasonCode of Object.keys(argument)) {
  2735. const template = argument[reasonCode];
  2736. const _ref2 = typeof template === "string" ? {
  2737. message: () => template
  2738. } : typeof template === "function" ? {
  2739. message: template
  2740. } : template,
  2741. {
  2742. message
  2743. } = _ref2,
  2744. rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
  2745. const toMessage = typeof message === "string" ? () => message : message;
  2746. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2747. code: "BABEL_PARSER_SYNTAX_ERROR",
  2748. reasonCode,
  2749. toMessage
  2750. }, syntaxPlugin ? {
  2751. syntaxPlugin
  2752. } : {}, rest));
  2753. }
  2754. return ParseErrorConstructors;
  2755. }
  2756. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2757. const {
  2758. defineProperty
  2759. } = Object;
  2760. const toUnenumerable = (object, key) => defineProperty(object, key, {
  2761. enumerable: false,
  2762. value: object[key]
  2763. });
  2764. function toESTreeLocation(node) {
  2765. node.loc.start && toUnenumerable(node.loc.start, "index");
  2766. node.loc.end && toUnenumerable(node.loc.end, "index");
  2767. return node;
  2768. }
  2769. var estree = superClass => class ESTreeParserMixin extends superClass {
  2770. parse() {
  2771. const file = toESTreeLocation(super.parse());
  2772. if (this.options.tokens) {
  2773. file.tokens = file.tokens.map(toESTreeLocation);
  2774. }
  2775. return file;
  2776. }
  2777. parseRegExpLiteral({
  2778. pattern,
  2779. flags
  2780. }) {
  2781. let regex = null;
  2782. try {
  2783. regex = new RegExp(pattern, flags);
  2784. } catch (e) {}
  2785. const node = this.estreeParseLiteral(regex);
  2786. node.regex = {
  2787. pattern,
  2788. flags
  2789. };
  2790. return node;
  2791. }
  2792. parseBigIntLiteral(value) {
  2793. let bigInt;
  2794. try {
  2795. bigInt = BigInt(value);
  2796. } catch (_unused) {
  2797. bigInt = null;
  2798. }
  2799. const node = this.estreeParseLiteral(bigInt);
  2800. node.bigint = String(node.value || value);
  2801. return node;
  2802. }
  2803. parseDecimalLiteral(value) {
  2804. const decimal = null;
  2805. const node = this.estreeParseLiteral(decimal);
  2806. node.decimal = String(node.value || value);
  2807. return node;
  2808. }
  2809. estreeParseLiteral(value) {
  2810. return this.parseLiteral(value, "Literal");
  2811. }
  2812. parseStringLiteral(value) {
  2813. return this.estreeParseLiteral(value);
  2814. }
  2815. parseNumericLiteral(value) {
  2816. return this.estreeParseLiteral(value);
  2817. }
  2818. parseNullLiteral() {
  2819. return this.estreeParseLiteral(null);
  2820. }
  2821. parseBooleanLiteral(value) {
  2822. return this.estreeParseLiteral(value);
  2823. }
  2824. directiveToStmt(directive) {
  2825. const expression = directive.value;
  2826. delete directive.value;
  2827. expression.type = "Literal";
  2828. expression.raw = expression.extra.raw;
  2829. expression.value = expression.extra.expressionValue;
  2830. const stmt = directive;
  2831. stmt.type = "ExpressionStatement";
  2832. stmt.expression = expression;
  2833. stmt.directive = expression.extra.rawValue;
  2834. delete expression.extra;
  2835. return stmt;
  2836. }
  2837. initFunction(node, isAsync) {
  2838. super.initFunction(node, isAsync);
  2839. node.expression = false;
  2840. }
  2841. checkDeclaration(node) {
  2842. if (node != null && this.isObjectProperty(node)) {
  2843. this.checkDeclaration(node.value);
  2844. } else {
  2845. super.checkDeclaration(node);
  2846. }
  2847. }
  2848. getObjectOrClassMethodParams(method) {
  2849. return method.value.params;
  2850. }
  2851. isValidDirective(stmt) {
  2852. var _stmt$expression$extr;
  2853. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  2854. }
  2855. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  2856. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  2857. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  2858. node.body = directiveStatements.concat(node.body);
  2859. delete node.directives;
  2860. }
  2861. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  2862. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  2863. if (method.typeParameters) {
  2864. method.value.typeParameters = method.typeParameters;
  2865. delete method.typeParameters;
  2866. }
  2867. classBody.body.push(method);
  2868. }
  2869. parsePrivateName() {
  2870. const node = super.parsePrivateName();
  2871. {
  2872. if (!this.getPluginOption("estree", "classFeatures")) {
  2873. return node;
  2874. }
  2875. }
  2876. return this.convertPrivateNameToPrivateIdentifier(node);
  2877. }
  2878. convertPrivateNameToPrivateIdentifier(node) {
  2879. const name = super.getPrivateNameSV(node);
  2880. node = node;
  2881. delete node.id;
  2882. node.name = name;
  2883. node.type = "PrivateIdentifier";
  2884. return node;
  2885. }
  2886. isPrivateName(node) {
  2887. {
  2888. if (!this.getPluginOption("estree", "classFeatures")) {
  2889. return super.isPrivateName(node);
  2890. }
  2891. }
  2892. return node.type === "PrivateIdentifier";
  2893. }
  2894. getPrivateNameSV(node) {
  2895. {
  2896. if (!this.getPluginOption("estree", "classFeatures")) {
  2897. return super.getPrivateNameSV(node);
  2898. }
  2899. }
  2900. return node.name;
  2901. }
  2902. parseLiteral(value, type) {
  2903. const node = super.parseLiteral(value, type);
  2904. node.raw = node.extra.raw;
  2905. delete node.extra;
  2906. return node;
  2907. }
  2908. parseFunctionBody(node, allowExpression, isMethod = false) {
  2909. super.parseFunctionBody(node, allowExpression, isMethod);
  2910. node.expression = node.body.type !== "BlockStatement";
  2911. }
  2912. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  2913. let funcNode = this.startNode();
  2914. funcNode.kind = node.kind;
  2915. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  2916. funcNode.type = "FunctionExpression";
  2917. delete funcNode.kind;
  2918. node.value = funcNode;
  2919. if (type === "ClassPrivateMethod") {
  2920. node.computed = false;
  2921. }
  2922. return this.finishNode(node, "MethodDefinition");
  2923. }
  2924. parseClassProperty(...args) {
  2925. const propertyNode = super.parseClassProperty(...args);
  2926. {
  2927. if (!this.getPluginOption("estree", "classFeatures")) {
  2928. return propertyNode;
  2929. }
  2930. }
  2931. propertyNode.type = "PropertyDefinition";
  2932. return propertyNode;
  2933. }
  2934. parseClassPrivateProperty(...args) {
  2935. const propertyNode = super.parseClassPrivateProperty(...args);
  2936. {
  2937. if (!this.getPluginOption("estree", "classFeatures")) {
  2938. return propertyNode;
  2939. }
  2940. }
  2941. propertyNode.type = "PropertyDefinition";
  2942. propertyNode.computed = false;
  2943. return propertyNode;
  2944. }
  2945. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  2946. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  2947. if (node) {
  2948. node.type = "Property";
  2949. if (node.kind === "method") {
  2950. node.kind = "init";
  2951. }
  2952. node.shorthand = false;
  2953. }
  2954. return node;
  2955. }
  2956. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  2957. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  2958. if (node) {
  2959. node.kind = "init";
  2960. node.type = "Property";
  2961. }
  2962. return node;
  2963. }
  2964. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  2965. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  2966. }
  2967. isAssignable(node, isBinding) {
  2968. if (node != null && this.isObjectProperty(node)) {
  2969. return this.isAssignable(node.value, isBinding);
  2970. }
  2971. return super.isAssignable(node, isBinding);
  2972. }
  2973. toAssignable(node, isLHS = false) {
  2974. if (node != null && this.isObjectProperty(node)) {
  2975. const {
  2976. key,
  2977. value
  2978. } = node;
  2979. if (this.isPrivateName(key)) {
  2980. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  2981. }
  2982. this.toAssignable(value, isLHS);
  2983. } else {
  2984. super.toAssignable(node, isLHS);
  2985. }
  2986. }
  2987. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  2988. if (prop.kind === "get" || prop.kind === "set") {
  2989. this.raise(Errors.PatternHasAccessor, prop.key);
  2990. } else if (prop.method) {
  2991. this.raise(Errors.PatternHasMethod, prop.key);
  2992. } else {
  2993. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  2994. }
  2995. }
  2996. finishCallExpression(unfinished, optional) {
  2997. const node = super.finishCallExpression(unfinished, optional);
  2998. if (node.callee.type === "Import") {
  2999. node.type = "ImportExpression";
  3000. node.source = node.arguments[0];
  3001. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  3002. var _node$arguments$, _node$arguments$2;
  3003. node.options = (_node$arguments$ = node.arguments[1]) != null ? _node$arguments$ : null;
  3004. node.attributes = (_node$arguments$2 = node.arguments[1]) != null ? _node$arguments$2 : null;
  3005. }
  3006. delete node.arguments;
  3007. delete node.callee;
  3008. }
  3009. return node;
  3010. }
  3011. toReferencedArguments(node) {
  3012. if (node.type === "ImportExpression") {
  3013. return;
  3014. }
  3015. super.toReferencedArguments(node);
  3016. }
  3017. parseExport(unfinished, decorators) {
  3018. const exportStartLoc = this.state.lastTokStartLoc;
  3019. const node = super.parseExport(unfinished, decorators);
  3020. switch (node.type) {
  3021. case "ExportAllDeclaration":
  3022. node.exported = null;
  3023. break;
  3024. case "ExportNamedDeclaration":
  3025. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3026. node.type = "ExportAllDeclaration";
  3027. node.exported = node.specifiers[0].exported;
  3028. delete node.specifiers;
  3029. }
  3030. case "ExportDefaultDeclaration":
  3031. {
  3032. var _declaration$decorato;
  3033. const {
  3034. declaration
  3035. } = node;
  3036. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3037. this.resetStartLocation(node, exportStartLoc);
  3038. }
  3039. }
  3040. break;
  3041. }
  3042. return node;
  3043. }
  3044. parseSubscript(base, startLoc, noCalls, state) {
  3045. const node = super.parseSubscript(base, startLoc, noCalls, state);
  3046. if (state.optionalChainMember) {
  3047. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  3048. node.type = node.type.substring(8);
  3049. }
  3050. if (state.stop) {
  3051. const chain = this.startNodeAtNode(node);
  3052. chain.expression = node;
  3053. return this.finishNode(chain, "ChainExpression");
  3054. }
  3055. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  3056. node.optional = false;
  3057. }
  3058. return node;
  3059. }
  3060. isOptionalMemberExpression(node) {
  3061. if (node.type === "ChainExpression") {
  3062. return node.expression.type === "MemberExpression";
  3063. }
  3064. return super.isOptionalMemberExpression(node);
  3065. }
  3066. hasPropertyAsPrivateName(node) {
  3067. if (node.type === "ChainExpression") {
  3068. node = node.expression;
  3069. }
  3070. return super.hasPropertyAsPrivateName(node);
  3071. }
  3072. isObjectProperty(node) {
  3073. return node.type === "Property" && node.kind === "init" && !node.method;
  3074. }
  3075. isObjectMethod(node) {
  3076. return node.method || node.kind === "get" || node.kind === "set";
  3077. }
  3078. finishNodeAt(node, type, endLoc) {
  3079. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3080. }
  3081. resetStartLocation(node, startLoc) {
  3082. super.resetStartLocation(node, startLoc);
  3083. toESTreeLocation(node);
  3084. }
  3085. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3086. super.resetEndLocation(node, endLoc);
  3087. toESTreeLocation(node);
  3088. }
  3089. };
  3090. class TokContext {
  3091. constructor(token, preserveSpace) {
  3092. this.token = void 0;
  3093. this.preserveSpace = void 0;
  3094. this.token = token;
  3095. this.preserveSpace = !!preserveSpace;
  3096. }
  3097. }
  3098. const types$1 = {
  3099. brace: new TokContext("{"),
  3100. j_oTag: new TokContext("<tag"),
  3101. j_cTag: new TokContext("</tag"),
  3102. j_expr: new TokContext("<tag>...</tag>", true)
  3103. };
  3104. {
  3105. types$1.template = new TokContext("`", true);
  3106. }
  3107. const beforeExpr = true;
  3108. const startsExpr = true;
  3109. const isLoop = true;
  3110. const isAssign = true;
  3111. const prefix = true;
  3112. const postfix = true;
  3113. class ExportedTokenType {
  3114. constructor(label, conf = {}) {
  3115. this.label = void 0;
  3116. this.keyword = void 0;
  3117. this.beforeExpr = void 0;
  3118. this.startsExpr = void 0;
  3119. this.rightAssociative = void 0;
  3120. this.isLoop = void 0;
  3121. this.isAssign = void 0;
  3122. this.prefix = void 0;
  3123. this.postfix = void 0;
  3124. this.binop = void 0;
  3125. this.label = label;
  3126. this.keyword = conf.keyword;
  3127. this.beforeExpr = !!conf.beforeExpr;
  3128. this.startsExpr = !!conf.startsExpr;
  3129. this.rightAssociative = !!conf.rightAssociative;
  3130. this.isLoop = !!conf.isLoop;
  3131. this.isAssign = !!conf.isAssign;
  3132. this.prefix = !!conf.prefix;
  3133. this.postfix = !!conf.postfix;
  3134. this.binop = conf.binop != null ? conf.binop : null;
  3135. {
  3136. this.updateContext = null;
  3137. }
  3138. }
  3139. }
  3140. const keywords$1 = new Map();
  3141. function createKeyword(name, options = {}) {
  3142. options.keyword = name;
  3143. const token = createToken(name, options);
  3144. keywords$1.set(name, token);
  3145. return token;
  3146. }
  3147. function createBinop(name, binop) {
  3148. return createToken(name, {
  3149. beforeExpr,
  3150. binop
  3151. });
  3152. }
  3153. let tokenTypeCounter = -1;
  3154. const tokenTypes$1 = [];
  3155. const tokenLabels = [];
  3156. const tokenBinops = [];
  3157. const tokenBeforeExprs = [];
  3158. const tokenStartsExprs = [];
  3159. const tokenPrefixes = [];
  3160. function createToken(name, options = {}) {
  3161. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3162. ++tokenTypeCounter;
  3163. tokenLabels.push(name);
  3164. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3165. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3166. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3167. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3168. tokenTypes$1.push(new ExportedTokenType(name, options));
  3169. return tokenTypeCounter;
  3170. }
  3171. function createKeywordLike(name, options = {}) {
  3172. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3173. ++tokenTypeCounter;
  3174. keywords$1.set(name, tokenTypeCounter);
  3175. tokenLabels.push(name);
  3176. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3177. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3178. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3179. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3180. tokenTypes$1.push(new ExportedTokenType("name", options));
  3181. return tokenTypeCounter;
  3182. }
  3183. const tt = {
  3184. bracketL: createToken("[", {
  3185. beforeExpr,
  3186. startsExpr
  3187. }),
  3188. bracketHashL: createToken("#[", {
  3189. beforeExpr,
  3190. startsExpr
  3191. }),
  3192. bracketBarL: createToken("[|", {
  3193. beforeExpr,
  3194. startsExpr
  3195. }),
  3196. bracketR: createToken("]"),
  3197. bracketBarR: createToken("|]"),
  3198. braceL: createToken("{", {
  3199. beforeExpr,
  3200. startsExpr
  3201. }),
  3202. braceBarL: createToken("{|", {
  3203. beforeExpr,
  3204. startsExpr
  3205. }),
  3206. braceHashL: createToken("#{", {
  3207. beforeExpr,
  3208. startsExpr
  3209. }),
  3210. braceR: createToken("}"),
  3211. braceBarR: createToken("|}"),
  3212. parenL: createToken("(", {
  3213. beforeExpr,
  3214. startsExpr
  3215. }),
  3216. parenR: createToken(")"),
  3217. comma: createToken(",", {
  3218. beforeExpr
  3219. }),
  3220. semi: createToken(";", {
  3221. beforeExpr
  3222. }),
  3223. colon: createToken(":", {
  3224. beforeExpr
  3225. }),
  3226. doubleColon: createToken("::", {
  3227. beforeExpr
  3228. }),
  3229. dot: createToken("."),
  3230. question: createToken("?", {
  3231. beforeExpr
  3232. }),
  3233. questionDot: createToken("?."),
  3234. arrow: createToken("=>", {
  3235. beforeExpr
  3236. }),
  3237. template: createToken("template"),
  3238. ellipsis: createToken("...", {
  3239. beforeExpr
  3240. }),
  3241. backQuote: createToken("`", {
  3242. startsExpr
  3243. }),
  3244. dollarBraceL: createToken("${", {
  3245. beforeExpr,
  3246. startsExpr
  3247. }),
  3248. templateTail: createToken("...`", {
  3249. startsExpr
  3250. }),
  3251. templateNonTail: createToken("...${", {
  3252. beforeExpr,
  3253. startsExpr
  3254. }),
  3255. at: createToken("@"),
  3256. hash: createToken("#", {
  3257. startsExpr
  3258. }),
  3259. interpreterDirective: createToken("#!..."),
  3260. eq: createToken("=", {
  3261. beforeExpr,
  3262. isAssign
  3263. }),
  3264. assign: createToken("_=", {
  3265. beforeExpr,
  3266. isAssign
  3267. }),
  3268. slashAssign: createToken("_=", {
  3269. beforeExpr,
  3270. isAssign
  3271. }),
  3272. xorAssign: createToken("_=", {
  3273. beforeExpr,
  3274. isAssign
  3275. }),
  3276. moduloAssign: createToken("_=", {
  3277. beforeExpr,
  3278. isAssign
  3279. }),
  3280. incDec: createToken("++/--", {
  3281. prefix,
  3282. postfix,
  3283. startsExpr
  3284. }),
  3285. bang: createToken("!", {
  3286. beforeExpr,
  3287. prefix,
  3288. startsExpr
  3289. }),
  3290. tilde: createToken("~", {
  3291. beforeExpr,
  3292. prefix,
  3293. startsExpr
  3294. }),
  3295. doubleCaret: createToken("^^", {
  3296. startsExpr
  3297. }),
  3298. doubleAt: createToken("@@", {
  3299. startsExpr
  3300. }),
  3301. pipeline: createBinop("|>", 0),
  3302. nullishCoalescing: createBinop("??", 1),
  3303. logicalOR: createBinop("||", 1),
  3304. logicalAND: createBinop("&&", 2),
  3305. bitwiseOR: createBinop("|", 3),
  3306. bitwiseXOR: createBinop("^", 4),
  3307. bitwiseAND: createBinop("&", 5),
  3308. equality: createBinop("==/!=/===/!==", 6),
  3309. lt: createBinop("</>/<=/>=", 7),
  3310. gt: createBinop("</>/<=/>=", 7),
  3311. relational: createBinop("</>/<=/>=", 7),
  3312. bitShift: createBinop("<</>>/>>>", 8),
  3313. bitShiftL: createBinop("<</>>/>>>", 8),
  3314. bitShiftR: createBinop("<</>>/>>>", 8),
  3315. plusMin: createToken("+/-", {
  3316. beforeExpr,
  3317. binop: 9,
  3318. prefix,
  3319. startsExpr
  3320. }),
  3321. modulo: createToken("%", {
  3322. binop: 10,
  3323. startsExpr
  3324. }),
  3325. star: createToken("*", {
  3326. binop: 10
  3327. }),
  3328. slash: createBinop("/", 10),
  3329. exponent: createToken("**", {
  3330. beforeExpr,
  3331. binop: 11,
  3332. rightAssociative: true
  3333. }),
  3334. _in: createKeyword("in", {
  3335. beforeExpr,
  3336. binop: 7
  3337. }),
  3338. _instanceof: createKeyword("instanceof", {
  3339. beforeExpr,
  3340. binop: 7
  3341. }),
  3342. _break: createKeyword("break"),
  3343. _case: createKeyword("case", {
  3344. beforeExpr
  3345. }),
  3346. _catch: createKeyword("catch"),
  3347. _continue: createKeyword("continue"),
  3348. _debugger: createKeyword("debugger"),
  3349. _default: createKeyword("default", {
  3350. beforeExpr
  3351. }),
  3352. _else: createKeyword("else", {
  3353. beforeExpr
  3354. }),
  3355. _finally: createKeyword("finally"),
  3356. _function: createKeyword("function", {
  3357. startsExpr
  3358. }),
  3359. _if: createKeyword("if"),
  3360. _return: createKeyword("return", {
  3361. beforeExpr
  3362. }),
  3363. _switch: createKeyword("switch"),
  3364. _throw: createKeyword("throw", {
  3365. beforeExpr,
  3366. prefix,
  3367. startsExpr
  3368. }),
  3369. _try: createKeyword("try"),
  3370. _var: createKeyword("var"),
  3371. _const: createKeyword("const"),
  3372. _with: createKeyword("with"),
  3373. _new: createKeyword("new", {
  3374. beforeExpr,
  3375. startsExpr
  3376. }),
  3377. _this: createKeyword("this", {
  3378. startsExpr
  3379. }),
  3380. _super: createKeyword("super", {
  3381. startsExpr
  3382. }),
  3383. _class: createKeyword("class", {
  3384. startsExpr
  3385. }),
  3386. _extends: createKeyword("extends", {
  3387. beforeExpr
  3388. }),
  3389. _export: createKeyword("export"),
  3390. _import: createKeyword("import", {
  3391. startsExpr
  3392. }),
  3393. _null: createKeyword("null", {
  3394. startsExpr
  3395. }),
  3396. _true: createKeyword("true", {
  3397. startsExpr
  3398. }),
  3399. _false: createKeyword("false", {
  3400. startsExpr
  3401. }),
  3402. _typeof: createKeyword("typeof", {
  3403. beforeExpr,
  3404. prefix,
  3405. startsExpr
  3406. }),
  3407. _void: createKeyword("void", {
  3408. beforeExpr,
  3409. prefix,
  3410. startsExpr
  3411. }),
  3412. _delete: createKeyword("delete", {
  3413. beforeExpr,
  3414. prefix,
  3415. startsExpr
  3416. }),
  3417. _do: createKeyword("do", {
  3418. isLoop,
  3419. beforeExpr
  3420. }),
  3421. _for: createKeyword("for", {
  3422. isLoop
  3423. }),
  3424. _while: createKeyword("while", {
  3425. isLoop
  3426. }),
  3427. _as: createKeywordLike("as", {
  3428. startsExpr
  3429. }),
  3430. _assert: createKeywordLike("assert", {
  3431. startsExpr
  3432. }),
  3433. _async: createKeywordLike("async", {
  3434. startsExpr
  3435. }),
  3436. _await: createKeywordLike("await", {
  3437. startsExpr
  3438. }),
  3439. _defer: createKeywordLike("defer", {
  3440. startsExpr
  3441. }),
  3442. _from: createKeywordLike("from", {
  3443. startsExpr
  3444. }),
  3445. _get: createKeywordLike("get", {
  3446. startsExpr
  3447. }),
  3448. _let: createKeywordLike("let", {
  3449. startsExpr
  3450. }),
  3451. _meta: createKeywordLike("meta", {
  3452. startsExpr
  3453. }),
  3454. _of: createKeywordLike("of", {
  3455. startsExpr
  3456. }),
  3457. _sent: createKeywordLike("sent", {
  3458. startsExpr
  3459. }),
  3460. _set: createKeywordLike("set", {
  3461. startsExpr
  3462. }),
  3463. _source: createKeywordLike("source", {
  3464. startsExpr
  3465. }),
  3466. _static: createKeywordLike("static", {
  3467. startsExpr
  3468. }),
  3469. _using: createKeywordLike("using", {
  3470. startsExpr
  3471. }),
  3472. _yield: createKeywordLike("yield", {
  3473. startsExpr
  3474. }),
  3475. _asserts: createKeywordLike("asserts", {
  3476. startsExpr
  3477. }),
  3478. _checks: createKeywordLike("checks", {
  3479. startsExpr
  3480. }),
  3481. _exports: createKeywordLike("exports", {
  3482. startsExpr
  3483. }),
  3484. _global: createKeywordLike("global", {
  3485. startsExpr
  3486. }),
  3487. _implements: createKeywordLike("implements", {
  3488. startsExpr
  3489. }),
  3490. _intrinsic: createKeywordLike("intrinsic", {
  3491. startsExpr
  3492. }),
  3493. _infer: createKeywordLike("infer", {
  3494. startsExpr
  3495. }),
  3496. _is: createKeywordLike("is", {
  3497. startsExpr
  3498. }),
  3499. _mixins: createKeywordLike("mixins", {
  3500. startsExpr
  3501. }),
  3502. _proto: createKeywordLike("proto", {
  3503. startsExpr
  3504. }),
  3505. _require: createKeywordLike("require", {
  3506. startsExpr
  3507. }),
  3508. _satisfies: createKeywordLike("satisfies", {
  3509. startsExpr
  3510. }),
  3511. _keyof: createKeywordLike("keyof", {
  3512. startsExpr
  3513. }),
  3514. _readonly: createKeywordLike("readonly", {
  3515. startsExpr
  3516. }),
  3517. _unique: createKeywordLike("unique", {
  3518. startsExpr
  3519. }),
  3520. _abstract: createKeywordLike("abstract", {
  3521. startsExpr
  3522. }),
  3523. _declare: createKeywordLike("declare", {
  3524. startsExpr
  3525. }),
  3526. _enum: createKeywordLike("enum", {
  3527. startsExpr
  3528. }),
  3529. _module: createKeywordLike("module", {
  3530. startsExpr
  3531. }),
  3532. _namespace: createKeywordLike("namespace", {
  3533. startsExpr
  3534. }),
  3535. _interface: createKeywordLike("interface", {
  3536. startsExpr
  3537. }),
  3538. _type: createKeywordLike("type", {
  3539. startsExpr
  3540. }),
  3541. _opaque: createKeywordLike("opaque", {
  3542. startsExpr
  3543. }),
  3544. name: createToken("name", {
  3545. startsExpr
  3546. }),
  3547. string: createToken("string", {
  3548. startsExpr
  3549. }),
  3550. num: createToken("num", {
  3551. startsExpr
  3552. }),
  3553. bigint: createToken("bigint", {
  3554. startsExpr
  3555. }),
  3556. decimal: createToken("decimal", {
  3557. startsExpr
  3558. }),
  3559. regexp: createToken("regexp", {
  3560. startsExpr
  3561. }),
  3562. privateName: createToken("#name", {
  3563. startsExpr
  3564. }),
  3565. eof: createToken("eof"),
  3566. jsxName: createToken("jsxName"),
  3567. jsxText: createToken("jsxText", {
  3568. beforeExpr: true
  3569. }),
  3570. jsxTagStart: createToken("jsxTagStart", {
  3571. startsExpr: true
  3572. }),
  3573. jsxTagEnd: createToken("jsxTagEnd"),
  3574. placeholder: createToken("%%", {
  3575. startsExpr: true
  3576. })
  3577. };
  3578. function tokenIsIdentifier(token) {
  3579. return token >= 93 && token <= 132;
  3580. }
  3581. function tokenKeywordOrIdentifierIsKeyword(token) {
  3582. return token <= 92;
  3583. }
  3584. function tokenIsKeywordOrIdentifier(token) {
  3585. return token >= 58 && token <= 132;
  3586. }
  3587. function tokenIsLiteralPropertyName(token) {
  3588. return token >= 58 && token <= 136;
  3589. }
  3590. function tokenComesBeforeExpression(token) {
  3591. return tokenBeforeExprs[token];
  3592. }
  3593. function tokenCanStartExpression(token) {
  3594. return tokenStartsExprs[token];
  3595. }
  3596. function tokenIsAssignment(token) {
  3597. return token >= 29 && token <= 33;
  3598. }
  3599. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3600. return token >= 129 && token <= 131;
  3601. }
  3602. function tokenIsLoop(token) {
  3603. return token >= 90 && token <= 92;
  3604. }
  3605. function tokenIsKeyword(token) {
  3606. return token >= 58 && token <= 92;
  3607. }
  3608. function tokenIsOperator(token) {
  3609. return token >= 39 && token <= 59;
  3610. }
  3611. function tokenIsPostfix(token) {
  3612. return token === 34;
  3613. }
  3614. function tokenIsPrefix(token) {
  3615. return tokenPrefixes[token];
  3616. }
  3617. function tokenIsTSTypeOperator(token) {
  3618. return token >= 121 && token <= 123;
  3619. }
  3620. function tokenIsTSDeclarationStart(token) {
  3621. return token >= 124 && token <= 130;
  3622. }
  3623. function tokenLabelName(token) {
  3624. return tokenLabels[token];
  3625. }
  3626. function tokenOperatorPrecedence(token) {
  3627. return tokenBinops[token];
  3628. }
  3629. function tokenIsRightAssociative(token) {
  3630. return token === 57;
  3631. }
  3632. function tokenIsTemplate(token) {
  3633. return token >= 24 && token <= 25;
  3634. }
  3635. function getExportedToken(token) {
  3636. return tokenTypes$1[token];
  3637. }
  3638. {
  3639. tokenTypes$1[8].updateContext = context => {
  3640. context.pop();
  3641. };
  3642. tokenTypes$1[5].updateContext = tokenTypes$1[7].updateContext = tokenTypes$1[23].updateContext = context => {
  3643. context.push(types$1.brace);
  3644. };
  3645. tokenTypes$1[22].updateContext = context => {
  3646. if (context[context.length - 1] === types$1.template) {
  3647. context.pop();
  3648. } else {
  3649. context.push(types$1.template);
  3650. }
  3651. };
  3652. tokenTypes$1[142].updateContext = context => {
  3653. context.push(types$1.j_expr, types$1.j_oTag);
  3654. };
  3655. }
  3656. 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";
  3657. 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";
  3658. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3659. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3660. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3661. 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];
  3662. 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];
  3663. function isInAstralSet(code, set) {
  3664. let pos = 0x10000;
  3665. for (let i = 0, length = set.length; i < length; i += 2) {
  3666. pos += set[i];
  3667. if (pos > code) return false;
  3668. pos += set[i + 1];
  3669. if (pos >= code) return true;
  3670. }
  3671. return false;
  3672. }
  3673. function isIdentifierStart(code) {
  3674. if (code < 65) return code === 36;
  3675. if (code <= 90) return true;
  3676. if (code < 97) return code === 95;
  3677. if (code <= 122) return true;
  3678. if (code <= 0xffff) {
  3679. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3680. }
  3681. return isInAstralSet(code, astralIdentifierStartCodes);
  3682. }
  3683. function isIdentifierChar(code) {
  3684. if (code < 48) return code === 36;
  3685. if (code < 58) return true;
  3686. if (code < 65) return false;
  3687. if (code <= 90) return true;
  3688. if (code < 97) return code === 95;
  3689. if (code <= 122) return true;
  3690. if (code <= 0xffff) {
  3691. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3692. }
  3693. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3694. }
  3695. const reservedWords = {
  3696. 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"],
  3697. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3698. strictBind: ["eval", "arguments"]
  3699. };
  3700. const keywords = new Set(reservedWords.keyword);
  3701. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3702. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3703. function isReservedWord(word, inModule) {
  3704. return inModule && word === "await" || word === "enum";
  3705. }
  3706. function isStrictReservedWord(word, inModule) {
  3707. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3708. }
  3709. function isStrictBindOnlyReservedWord(word) {
  3710. return reservedWordsStrictBindSet.has(word);
  3711. }
  3712. function isStrictBindReservedWord(word, inModule) {
  3713. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3714. }
  3715. function isKeyword(word) {
  3716. return keywords.has(word);
  3717. }
  3718. function isIteratorStart(current, next, next2) {
  3719. return current === 64 && next === 64 && isIdentifierStart(next2);
  3720. }
  3721. 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"]);
  3722. function canBeReservedWord(word) {
  3723. return reservedWordLikeSet.has(word);
  3724. }
  3725. class Scope {
  3726. constructor(flags) {
  3727. this.flags = 0;
  3728. this.names = new Map();
  3729. this.firstLexicalName = "";
  3730. this.flags = flags;
  3731. }
  3732. }
  3733. class ScopeHandler {
  3734. constructor(parser, inModule) {
  3735. this.parser = void 0;
  3736. this.scopeStack = [];
  3737. this.inModule = void 0;
  3738. this.undefinedExports = new Map();
  3739. this.parser = parser;
  3740. this.inModule = inModule;
  3741. }
  3742. get inTopLevel() {
  3743. return (this.currentScope().flags & 1) > 0;
  3744. }
  3745. get inFunction() {
  3746. return (this.currentVarScopeFlags() & 2) > 0;
  3747. }
  3748. get allowSuper() {
  3749. return (this.currentThisScopeFlags() & 16) > 0;
  3750. }
  3751. get allowDirectSuper() {
  3752. return (this.currentThisScopeFlags() & 32) > 0;
  3753. }
  3754. get inClass() {
  3755. return (this.currentThisScopeFlags() & 64) > 0;
  3756. }
  3757. get inClassAndNotInNonArrowFunction() {
  3758. const flags = this.currentThisScopeFlags();
  3759. return (flags & 64) > 0 && (flags & 2) === 0;
  3760. }
  3761. get inStaticBlock() {
  3762. for (let i = this.scopeStack.length - 1;; i--) {
  3763. const {
  3764. flags
  3765. } = this.scopeStack[i];
  3766. if (flags & 128) {
  3767. return true;
  3768. }
  3769. if (flags & (387 | 64)) {
  3770. return false;
  3771. }
  3772. }
  3773. }
  3774. get inNonArrowFunction() {
  3775. return (this.currentThisScopeFlags() & 2) > 0;
  3776. }
  3777. get treatFunctionsAsVar() {
  3778. return this.treatFunctionsAsVarInScope(this.currentScope());
  3779. }
  3780. createScope(flags) {
  3781. return new Scope(flags);
  3782. }
  3783. enter(flags) {
  3784. this.scopeStack.push(this.createScope(flags));
  3785. }
  3786. exit() {
  3787. const scope = this.scopeStack.pop();
  3788. return scope.flags;
  3789. }
  3790. treatFunctionsAsVarInScope(scope) {
  3791. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  3792. }
  3793. declareName(name, bindingType, loc) {
  3794. let scope = this.currentScope();
  3795. if (bindingType & 8 || bindingType & 16) {
  3796. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3797. let type = scope.names.get(name) || 0;
  3798. if (bindingType & 16) {
  3799. type = type | 4;
  3800. } else {
  3801. if (!scope.firstLexicalName) {
  3802. scope.firstLexicalName = name;
  3803. }
  3804. type = type | 2;
  3805. }
  3806. scope.names.set(name, type);
  3807. if (bindingType & 8) {
  3808. this.maybeExportDefined(scope, name);
  3809. }
  3810. } else if (bindingType & 4) {
  3811. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  3812. scope = this.scopeStack[i];
  3813. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3814. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  3815. this.maybeExportDefined(scope, name);
  3816. if (scope.flags & 387) break;
  3817. }
  3818. }
  3819. if (this.parser.inModule && scope.flags & 1) {
  3820. this.undefinedExports.delete(name);
  3821. }
  3822. }
  3823. maybeExportDefined(scope, name) {
  3824. if (this.parser.inModule && scope.flags & 1) {
  3825. this.undefinedExports.delete(name);
  3826. }
  3827. }
  3828. checkRedeclarationInScope(scope, name, bindingType, loc) {
  3829. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  3830. this.parser.raise(Errors.VarRedeclaration, loc, {
  3831. identifierName: name
  3832. });
  3833. }
  3834. }
  3835. isRedeclaredInScope(scope, name, bindingType) {
  3836. if (!(bindingType & 1)) return false;
  3837. if (bindingType & 8) {
  3838. return scope.names.has(name);
  3839. }
  3840. const type = scope.names.get(name);
  3841. if (bindingType & 16) {
  3842. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  3843. }
  3844. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  3845. }
  3846. checkLocalExport(id) {
  3847. const {
  3848. name
  3849. } = id;
  3850. const topLevelScope = this.scopeStack[0];
  3851. if (!topLevelScope.names.has(name)) {
  3852. this.undefinedExports.set(name, id.loc.start);
  3853. }
  3854. }
  3855. currentScope() {
  3856. return this.scopeStack[this.scopeStack.length - 1];
  3857. }
  3858. currentVarScopeFlags() {
  3859. for (let i = this.scopeStack.length - 1;; i--) {
  3860. const {
  3861. flags
  3862. } = this.scopeStack[i];
  3863. if (flags & 387) {
  3864. return flags;
  3865. }
  3866. }
  3867. }
  3868. currentThisScopeFlags() {
  3869. for (let i = this.scopeStack.length - 1;; i--) {
  3870. const {
  3871. flags
  3872. } = this.scopeStack[i];
  3873. if (flags & (387 | 64) && !(flags & 4)) {
  3874. return flags;
  3875. }
  3876. }
  3877. }
  3878. }
  3879. class FlowScope extends Scope {
  3880. constructor(...args) {
  3881. super(...args);
  3882. this.declareFunctions = new Set();
  3883. }
  3884. }
  3885. class FlowScopeHandler extends ScopeHandler {
  3886. createScope(flags) {
  3887. return new FlowScope(flags);
  3888. }
  3889. declareName(name, bindingType, loc) {
  3890. const scope = this.currentScope();
  3891. if (bindingType & 2048) {
  3892. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3893. this.maybeExportDefined(scope, name);
  3894. scope.declareFunctions.add(name);
  3895. return;
  3896. }
  3897. super.declareName(name, bindingType, loc);
  3898. }
  3899. isRedeclaredInScope(scope, name, bindingType) {
  3900. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  3901. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  3902. const type = scope.names.get(name);
  3903. return (type & 4) > 0 || (type & 2) > 0;
  3904. }
  3905. return false;
  3906. }
  3907. checkLocalExport(id) {
  3908. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  3909. super.checkLocalExport(id);
  3910. }
  3911. }
  3912. }
  3913. class BaseParser {
  3914. constructor() {
  3915. this.sawUnambiguousESM = false;
  3916. this.ambiguousScriptDifferentAst = false;
  3917. }
  3918. hasPlugin(pluginConfig) {
  3919. if (typeof pluginConfig === "string") {
  3920. return this.plugins.has(pluginConfig);
  3921. } else {
  3922. const [pluginName, pluginOptions] = pluginConfig;
  3923. if (!this.hasPlugin(pluginName)) {
  3924. return false;
  3925. }
  3926. const actualOptions = this.plugins.get(pluginName);
  3927. for (const key of Object.keys(pluginOptions)) {
  3928. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  3929. return false;
  3930. }
  3931. }
  3932. return true;
  3933. }
  3934. }
  3935. getPluginOption(plugin, name) {
  3936. var _this$plugins$get;
  3937. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  3938. }
  3939. }
  3940. function setTrailingComments(node, comments) {
  3941. if (node.trailingComments === undefined) {
  3942. node.trailingComments = comments;
  3943. } else {
  3944. node.trailingComments.unshift(...comments);
  3945. }
  3946. }
  3947. function setLeadingComments(node, comments) {
  3948. if (node.leadingComments === undefined) {
  3949. node.leadingComments = comments;
  3950. } else {
  3951. node.leadingComments.unshift(...comments);
  3952. }
  3953. }
  3954. function setInnerComments(node, comments) {
  3955. if (node.innerComments === undefined) {
  3956. node.innerComments = comments;
  3957. } else {
  3958. node.innerComments.unshift(...comments);
  3959. }
  3960. }
  3961. function adjustInnerComments(node, elements, commentWS) {
  3962. let lastElement = null;
  3963. let i = elements.length;
  3964. while (lastElement === null && i > 0) {
  3965. lastElement = elements[--i];
  3966. }
  3967. if (lastElement === null || lastElement.start > commentWS.start) {
  3968. setInnerComments(node, commentWS.comments);
  3969. } else {
  3970. setTrailingComments(lastElement, commentWS.comments);
  3971. }
  3972. }
  3973. class CommentsParser extends BaseParser {
  3974. addComment(comment) {
  3975. if (this.filename) comment.loc.filename = this.filename;
  3976. const {
  3977. commentsLen
  3978. } = this.state;
  3979. if (this.comments.length != commentsLen) this.comments.length = commentsLen;
  3980. this.comments.push(comment);
  3981. this.state.commentsLen++;
  3982. }
  3983. processComment(node) {
  3984. const {
  3985. commentStack
  3986. } = this.state;
  3987. const commentStackLength = commentStack.length;
  3988. if (commentStackLength === 0) return;
  3989. let i = commentStackLength - 1;
  3990. const lastCommentWS = commentStack[i];
  3991. if (lastCommentWS.start === node.end) {
  3992. lastCommentWS.leadingNode = node;
  3993. i--;
  3994. }
  3995. const {
  3996. start: nodeStart
  3997. } = node;
  3998. for (; i >= 0; i--) {
  3999. const commentWS = commentStack[i];
  4000. const commentEnd = commentWS.end;
  4001. if (commentEnd > nodeStart) {
  4002. commentWS.containingNode = node;
  4003. this.finalizeComment(commentWS);
  4004. commentStack.splice(i, 1);
  4005. } else {
  4006. if (commentEnd === nodeStart) {
  4007. commentWS.trailingNode = node;
  4008. }
  4009. break;
  4010. }
  4011. }
  4012. }
  4013. finalizeComment(commentWS) {
  4014. const {
  4015. comments
  4016. } = commentWS;
  4017. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  4018. if (commentWS.leadingNode !== null) {
  4019. setTrailingComments(commentWS.leadingNode, comments);
  4020. }
  4021. if (commentWS.trailingNode !== null) {
  4022. setLeadingComments(commentWS.trailingNode, comments);
  4023. }
  4024. } else {
  4025. const {
  4026. containingNode: node,
  4027. start: commentStart
  4028. } = commentWS;
  4029. if (this.input.charCodeAt(commentStart - 1) === 44) {
  4030. switch (node.type) {
  4031. case "ObjectExpression":
  4032. case "ObjectPattern":
  4033. case "RecordExpression":
  4034. adjustInnerComments(node, node.properties, commentWS);
  4035. break;
  4036. case "CallExpression":
  4037. case "OptionalCallExpression":
  4038. adjustInnerComments(node, node.arguments, commentWS);
  4039. break;
  4040. case "FunctionDeclaration":
  4041. case "FunctionExpression":
  4042. case "ArrowFunctionExpression":
  4043. case "ObjectMethod":
  4044. case "ClassMethod":
  4045. case "ClassPrivateMethod":
  4046. adjustInnerComments(node, node.params, commentWS);
  4047. break;
  4048. case "ArrayExpression":
  4049. case "ArrayPattern":
  4050. case "TupleExpression":
  4051. adjustInnerComments(node, node.elements, commentWS);
  4052. break;
  4053. case "ExportNamedDeclaration":
  4054. case "ImportDeclaration":
  4055. adjustInnerComments(node, node.specifiers, commentWS);
  4056. break;
  4057. default:
  4058. {
  4059. setInnerComments(node, comments);
  4060. }
  4061. }
  4062. } else {
  4063. setInnerComments(node, comments);
  4064. }
  4065. }
  4066. }
  4067. finalizeRemainingComments() {
  4068. const {
  4069. commentStack
  4070. } = this.state;
  4071. for (let i = commentStack.length - 1; i >= 0; i--) {
  4072. this.finalizeComment(commentStack[i]);
  4073. }
  4074. this.state.commentStack = [];
  4075. }
  4076. resetPreviousNodeTrailingComments(node) {
  4077. const {
  4078. commentStack
  4079. } = this.state;
  4080. const {
  4081. length
  4082. } = commentStack;
  4083. if (length === 0) return;
  4084. const commentWS = commentStack[length - 1];
  4085. if (commentWS.leadingNode === node) {
  4086. commentWS.leadingNode = null;
  4087. }
  4088. }
  4089. resetPreviousIdentifierLeadingComments(node) {
  4090. const {
  4091. commentStack
  4092. } = this.state;
  4093. const {
  4094. length
  4095. } = commentStack;
  4096. if (length === 0) return;
  4097. if (commentStack[length - 1].trailingNode === node) {
  4098. commentStack[length - 1].trailingNode = null;
  4099. } else if (length >= 2 && commentStack[length - 2].trailingNode === node) {
  4100. commentStack[length - 2].trailingNode = null;
  4101. }
  4102. }
  4103. takeSurroundingComments(node, start, end) {
  4104. const {
  4105. commentStack
  4106. } = this.state;
  4107. const commentStackLength = commentStack.length;
  4108. if (commentStackLength === 0) return;
  4109. let i = commentStackLength - 1;
  4110. for (; i >= 0; i--) {
  4111. const commentWS = commentStack[i];
  4112. const commentEnd = commentWS.end;
  4113. const commentStart = commentWS.start;
  4114. if (commentStart === end) {
  4115. commentWS.leadingNode = node;
  4116. } else if (commentEnd === start) {
  4117. commentWS.trailingNode = node;
  4118. } else if (commentEnd < start) {
  4119. break;
  4120. }
  4121. }
  4122. }
  4123. }
  4124. const lineBreak = /\r\n?|[\n\u2028\u2029]/;
  4125. const lineBreakG = new RegExp(lineBreak.source, "g");
  4126. function isNewLine(code) {
  4127. switch (code) {
  4128. case 10:
  4129. case 13:
  4130. case 8232:
  4131. case 8233:
  4132. return true;
  4133. default:
  4134. return false;
  4135. }
  4136. }
  4137. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  4138. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  4139. const skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
  4140. function isWhitespace(code) {
  4141. switch (code) {
  4142. case 0x0009:
  4143. case 0x000b:
  4144. case 0x000c:
  4145. case 32:
  4146. case 160:
  4147. case 5760:
  4148. case 0x2000:
  4149. case 0x2001:
  4150. case 0x2002:
  4151. case 0x2003:
  4152. case 0x2004:
  4153. case 0x2005:
  4154. case 0x2006:
  4155. case 0x2007:
  4156. case 0x2008:
  4157. case 0x2009:
  4158. case 0x200a:
  4159. case 0x202f:
  4160. case 0x205f:
  4161. case 0x3000:
  4162. case 0xfeff:
  4163. return true;
  4164. default:
  4165. return false;
  4166. }
  4167. }
  4168. class State {
  4169. constructor() {
  4170. this.flags = 1024;
  4171. this.curLine = void 0;
  4172. this.lineStart = void 0;
  4173. this.startLoc = void 0;
  4174. this.endLoc = void 0;
  4175. this.errors = [];
  4176. this.potentialArrowAt = -1;
  4177. this.noArrowAt = [];
  4178. this.noArrowParamsConversionAt = [];
  4179. this.topicContext = {
  4180. maxNumOfResolvableTopics: 0,
  4181. maxTopicIndex: null
  4182. };
  4183. this.labels = [];
  4184. this.commentsLen = 0;
  4185. this.commentStack = [];
  4186. this.pos = 0;
  4187. this.type = 139;
  4188. this.value = null;
  4189. this.start = 0;
  4190. this.end = 0;
  4191. this.lastTokEndLoc = null;
  4192. this.lastTokStartLoc = null;
  4193. this.context = [types$1.brace];
  4194. this.firstInvalidTemplateEscapePos = null;
  4195. this.strictErrors = new Map();
  4196. this.tokensLength = 0;
  4197. }
  4198. get strict() {
  4199. return (this.flags & 1) > 0;
  4200. }
  4201. set strict(value) {
  4202. if (value) {
  4203. this.flags |= 1;
  4204. } else {
  4205. this.flags &= ~1;
  4206. }
  4207. }
  4208. init({
  4209. strictMode,
  4210. sourceType,
  4211. startLine,
  4212. startColumn
  4213. }) {
  4214. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  4215. this.curLine = startLine;
  4216. this.lineStart = -startColumn;
  4217. this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
  4218. }
  4219. get maybeInArrowParameters() {
  4220. return (this.flags & 2) > 0;
  4221. }
  4222. set maybeInArrowParameters(value) {
  4223. if (value) {
  4224. this.flags |= 2;
  4225. } else {
  4226. this.flags &= ~2;
  4227. }
  4228. }
  4229. get inType() {
  4230. return (this.flags & 4) > 0;
  4231. }
  4232. set inType(value) {
  4233. if (value) {
  4234. this.flags |= 4;
  4235. } else {
  4236. this.flags &= ~4;
  4237. }
  4238. }
  4239. get noAnonFunctionType() {
  4240. return (this.flags & 8) > 0;
  4241. }
  4242. set noAnonFunctionType(value) {
  4243. if (value) {
  4244. this.flags |= 8;
  4245. } else {
  4246. this.flags &= ~8;
  4247. }
  4248. }
  4249. get hasFlowComment() {
  4250. return (this.flags & 16) > 0;
  4251. }
  4252. set hasFlowComment(value) {
  4253. if (value) {
  4254. this.flags |= 16;
  4255. } else {
  4256. this.flags &= ~16;
  4257. }
  4258. }
  4259. get isAmbientContext() {
  4260. return (this.flags & 32) > 0;
  4261. }
  4262. set isAmbientContext(value) {
  4263. if (value) {
  4264. this.flags |= 32;
  4265. } else {
  4266. this.flags &= ~32;
  4267. }
  4268. }
  4269. get inAbstractClass() {
  4270. return (this.flags & 64) > 0;
  4271. }
  4272. set inAbstractClass(value) {
  4273. if (value) {
  4274. this.flags |= 64;
  4275. } else {
  4276. this.flags &= ~64;
  4277. }
  4278. }
  4279. get inDisallowConditionalTypesContext() {
  4280. return (this.flags & 128) > 0;
  4281. }
  4282. set inDisallowConditionalTypesContext(value) {
  4283. if (value) {
  4284. this.flags |= 128;
  4285. } else {
  4286. this.flags &= ~128;
  4287. }
  4288. }
  4289. get soloAwait() {
  4290. return (this.flags & 256) > 0;
  4291. }
  4292. set soloAwait(value) {
  4293. if (value) {
  4294. this.flags |= 256;
  4295. } else {
  4296. this.flags &= ~256;
  4297. }
  4298. }
  4299. get inFSharpPipelineDirectBody() {
  4300. return (this.flags & 512) > 0;
  4301. }
  4302. set inFSharpPipelineDirectBody(value) {
  4303. if (value) {
  4304. this.flags |= 512;
  4305. } else {
  4306. this.flags &= ~512;
  4307. }
  4308. }
  4309. get canStartJSXElement() {
  4310. return (this.flags & 1024) > 0;
  4311. }
  4312. set canStartJSXElement(value) {
  4313. if (value) {
  4314. this.flags |= 1024;
  4315. } else {
  4316. this.flags &= ~1024;
  4317. }
  4318. }
  4319. get containsEsc() {
  4320. return (this.flags & 2048) > 0;
  4321. }
  4322. set containsEsc(value) {
  4323. if (value) {
  4324. this.flags |= 2048;
  4325. } else {
  4326. this.flags &= ~2048;
  4327. }
  4328. }
  4329. curPosition() {
  4330. return new Position(this.curLine, this.pos - this.lineStart, this.pos);
  4331. }
  4332. clone() {
  4333. const state = new State();
  4334. state.flags = this.flags;
  4335. state.curLine = this.curLine;
  4336. state.lineStart = this.lineStart;
  4337. state.startLoc = this.startLoc;
  4338. state.endLoc = this.endLoc;
  4339. state.errors = this.errors.slice();
  4340. state.potentialArrowAt = this.potentialArrowAt;
  4341. state.noArrowAt = this.noArrowAt.slice();
  4342. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  4343. state.topicContext = this.topicContext;
  4344. state.labels = this.labels.slice();
  4345. state.commentsLen = this.commentsLen;
  4346. state.commentStack = this.commentStack.slice();
  4347. state.pos = this.pos;
  4348. state.type = this.type;
  4349. state.value = this.value;
  4350. state.start = this.start;
  4351. state.end = this.end;
  4352. state.lastTokEndLoc = this.lastTokEndLoc;
  4353. state.lastTokStartLoc = this.lastTokStartLoc;
  4354. state.context = this.context.slice();
  4355. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  4356. state.strictErrors = this.strictErrors;
  4357. state.tokensLength = this.tokensLength;
  4358. return state;
  4359. }
  4360. }
  4361. var _isDigit = function isDigit(code) {
  4362. return code >= 48 && code <= 57;
  4363. };
  4364. const forbiddenNumericSeparatorSiblings = {
  4365. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  4366. hex: new Set([46, 88, 95, 120])
  4367. };
  4368. const isAllowedNumericSeparatorSibling = {
  4369. bin: ch => ch === 48 || ch === 49,
  4370. oct: ch => ch >= 48 && ch <= 55,
  4371. dec: ch => ch >= 48 && ch <= 57,
  4372. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  4373. };
  4374. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  4375. const initialPos = pos;
  4376. const initialLineStart = lineStart;
  4377. const initialCurLine = curLine;
  4378. let out = "";
  4379. let firstInvalidLoc = null;
  4380. let chunkStart = pos;
  4381. const {
  4382. length
  4383. } = input;
  4384. for (;;) {
  4385. if (pos >= length) {
  4386. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4387. out += input.slice(chunkStart, pos);
  4388. break;
  4389. }
  4390. const ch = input.charCodeAt(pos);
  4391. if (isStringEnd(type, ch, input, pos)) {
  4392. out += input.slice(chunkStart, pos);
  4393. break;
  4394. }
  4395. if (ch === 92) {
  4396. out += input.slice(chunkStart, pos);
  4397. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  4398. if (res.ch === null && !firstInvalidLoc) {
  4399. firstInvalidLoc = {
  4400. pos,
  4401. lineStart,
  4402. curLine
  4403. };
  4404. } else {
  4405. out += res.ch;
  4406. }
  4407. ({
  4408. pos,
  4409. lineStart,
  4410. curLine
  4411. } = res);
  4412. chunkStart = pos;
  4413. } else if (ch === 8232 || ch === 8233) {
  4414. ++pos;
  4415. ++curLine;
  4416. lineStart = pos;
  4417. } else if (ch === 10 || ch === 13) {
  4418. if (type === "template") {
  4419. out += input.slice(chunkStart, pos) + "\n";
  4420. ++pos;
  4421. if (ch === 13 && input.charCodeAt(pos) === 10) {
  4422. ++pos;
  4423. }
  4424. ++curLine;
  4425. chunkStart = lineStart = pos;
  4426. } else {
  4427. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4428. }
  4429. } else {
  4430. ++pos;
  4431. }
  4432. }
  4433. return {
  4434. pos,
  4435. str: out,
  4436. firstInvalidLoc,
  4437. lineStart,
  4438. curLine,
  4439. containsInvalid: !!firstInvalidLoc
  4440. };
  4441. }
  4442. function isStringEnd(type, ch, input, pos) {
  4443. if (type === "template") {
  4444. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  4445. }
  4446. return ch === (type === "double" ? 34 : 39);
  4447. }
  4448. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  4449. const throwOnInvalid = !inTemplate;
  4450. pos++;
  4451. const res = ch => ({
  4452. pos,
  4453. ch,
  4454. lineStart,
  4455. curLine
  4456. });
  4457. const ch = input.charCodeAt(pos++);
  4458. switch (ch) {
  4459. case 110:
  4460. return res("\n");
  4461. case 114:
  4462. return res("\r");
  4463. case 120:
  4464. {
  4465. let code;
  4466. ({
  4467. code,
  4468. pos
  4469. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  4470. return res(code === null ? null : String.fromCharCode(code));
  4471. }
  4472. case 117:
  4473. {
  4474. let code;
  4475. ({
  4476. code,
  4477. pos
  4478. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  4479. return res(code === null ? null : String.fromCodePoint(code));
  4480. }
  4481. case 116:
  4482. return res("\t");
  4483. case 98:
  4484. return res("\b");
  4485. case 118:
  4486. return res("\u000b");
  4487. case 102:
  4488. return res("\f");
  4489. case 13:
  4490. if (input.charCodeAt(pos) === 10) {
  4491. ++pos;
  4492. }
  4493. case 10:
  4494. lineStart = pos;
  4495. ++curLine;
  4496. case 8232:
  4497. case 8233:
  4498. return res("");
  4499. case 56:
  4500. case 57:
  4501. if (inTemplate) {
  4502. return res(null);
  4503. } else {
  4504. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  4505. }
  4506. default:
  4507. if (ch >= 48 && ch <= 55) {
  4508. const startPos = pos - 1;
  4509. const match = input.slice(startPos, pos + 2).match(/^[0-7]+/);
  4510. let octalStr = match[0];
  4511. let octal = parseInt(octalStr, 8);
  4512. if (octal > 255) {
  4513. octalStr = octalStr.slice(0, -1);
  4514. octal = parseInt(octalStr, 8);
  4515. }
  4516. pos += octalStr.length - 1;
  4517. const next = input.charCodeAt(pos);
  4518. if (octalStr !== "0" || next === 56 || next === 57) {
  4519. if (inTemplate) {
  4520. return res(null);
  4521. } else {
  4522. errors.strictNumericEscape(startPos, lineStart, curLine);
  4523. }
  4524. }
  4525. return res(String.fromCharCode(octal));
  4526. }
  4527. return res(String.fromCharCode(ch));
  4528. }
  4529. }
  4530. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  4531. const initialPos = pos;
  4532. let n;
  4533. ({
  4534. n,
  4535. pos
  4536. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  4537. if (n === null) {
  4538. if (throwOnInvalid) {
  4539. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  4540. } else {
  4541. pos = initialPos - 1;
  4542. }
  4543. }
  4544. return {
  4545. code: n,
  4546. pos
  4547. };
  4548. }
  4549. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  4550. const start = pos;
  4551. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  4552. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  4553. let invalid = false;
  4554. let total = 0;
  4555. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  4556. const code = input.charCodeAt(pos);
  4557. let val;
  4558. if (code === 95 && allowNumSeparator !== "bail") {
  4559. const prev = input.charCodeAt(pos - 1);
  4560. const next = input.charCodeAt(pos + 1);
  4561. if (!allowNumSeparator) {
  4562. if (bailOnError) return {
  4563. n: null,
  4564. pos
  4565. };
  4566. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  4567. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  4568. if (bailOnError) return {
  4569. n: null,
  4570. pos
  4571. };
  4572. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  4573. }
  4574. ++pos;
  4575. continue;
  4576. }
  4577. if (code >= 97) {
  4578. val = code - 97 + 10;
  4579. } else if (code >= 65) {
  4580. val = code - 65 + 10;
  4581. } else if (_isDigit(code)) {
  4582. val = code - 48;
  4583. } else {
  4584. val = Infinity;
  4585. }
  4586. if (val >= radix) {
  4587. if (val <= 9 && bailOnError) {
  4588. return {
  4589. n: null,
  4590. pos
  4591. };
  4592. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  4593. val = 0;
  4594. } else if (forceLen) {
  4595. val = 0;
  4596. invalid = true;
  4597. } else {
  4598. break;
  4599. }
  4600. }
  4601. ++pos;
  4602. total = total * radix + val;
  4603. }
  4604. if (pos === start || len != null && pos - start !== len || invalid) {
  4605. return {
  4606. n: null,
  4607. pos
  4608. };
  4609. }
  4610. return {
  4611. n: total,
  4612. pos
  4613. };
  4614. }
  4615. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  4616. const ch = input.charCodeAt(pos);
  4617. let code;
  4618. if (ch === 123) {
  4619. ++pos;
  4620. ({
  4621. code,
  4622. pos
  4623. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  4624. ++pos;
  4625. if (code !== null && code > 0x10ffff) {
  4626. if (throwOnInvalid) {
  4627. errors.invalidCodePoint(pos, lineStart, curLine);
  4628. } else {
  4629. return {
  4630. code: null,
  4631. pos
  4632. };
  4633. }
  4634. }
  4635. } else {
  4636. ({
  4637. code,
  4638. pos
  4639. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  4640. }
  4641. return {
  4642. code,
  4643. pos
  4644. };
  4645. }
  4646. function buildPosition(pos, lineStart, curLine) {
  4647. return new Position(curLine, pos - lineStart, pos);
  4648. }
  4649. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  4650. class Token {
  4651. constructor(state) {
  4652. this.type = state.type;
  4653. this.value = state.value;
  4654. this.start = state.start;
  4655. this.end = state.end;
  4656. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  4657. }
  4658. }
  4659. class Tokenizer extends CommentsParser {
  4660. constructor(options, input) {
  4661. super();
  4662. this.isLookahead = void 0;
  4663. this.tokens = [];
  4664. this.errorHandlers_readInt = {
  4665. invalidDigit: (pos, lineStart, curLine, radix) => {
  4666. if (!this.options.errorRecovery) return false;
  4667. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  4668. radix
  4669. });
  4670. return true;
  4671. },
  4672. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  4673. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  4674. };
  4675. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  4676. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  4677. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  4678. });
  4679. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  4680. strictNumericEscape: (pos, lineStart, curLine) => {
  4681. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  4682. },
  4683. unterminated: (pos, lineStart, curLine) => {
  4684. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  4685. }
  4686. });
  4687. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  4688. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  4689. unterminated: (pos, lineStart, curLine) => {
  4690. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  4691. }
  4692. });
  4693. this.state = new State();
  4694. this.state.init(options);
  4695. this.input = input;
  4696. this.length = input.length;
  4697. this.comments = [];
  4698. this.isLookahead = false;
  4699. }
  4700. pushToken(token) {
  4701. this.tokens.length = this.state.tokensLength;
  4702. this.tokens.push(token);
  4703. ++this.state.tokensLength;
  4704. }
  4705. next() {
  4706. this.checkKeywordEscapes();
  4707. if (this.options.tokens) {
  4708. this.pushToken(new Token(this.state));
  4709. }
  4710. this.state.lastTokEndLoc = this.state.endLoc;
  4711. this.state.lastTokStartLoc = this.state.startLoc;
  4712. this.nextToken();
  4713. }
  4714. eat(type) {
  4715. if (this.match(type)) {
  4716. this.next();
  4717. return true;
  4718. } else {
  4719. return false;
  4720. }
  4721. }
  4722. match(type) {
  4723. return this.state.type === type;
  4724. }
  4725. createLookaheadState(state) {
  4726. return {
  4727. pos: state.pos,
  4728. value: null,
  4729. type: state.type,
  4730. start: state.start,
  4731. end: state.end,
  4732. context: [this.curContext()],
  4733. inType: state.inType,
  4734. startLoc: state.startLoc,
  4735. lastTokEndLoc: state.lastTokEndLoc,
  4736. curLine: state.curLine,
  4737. lineStart: state.lineStart,
  4738. curPosition: state.curPosition
  4739. };
  4740. }
  4741. lookahead() {
  4742. const old = this.state;
  4743. this.state = this.createLookaheadState(old);
  4744. this.isLookahead = true;
  4745. this.nextToken();
  4746. this.isLookahead = false;
  4747. const curr = this.state;
  4748. this.state = old;
  4749. return curr;
  4750. }
  4751. nextTokenStart() {
  4752. return this.nextTokenStartSince(this.state.pos);
  4753. }
  4754. nextTokenStartSince(pos) {
  4755. skipWhiteSpace.lastIndex = pos;
  4756. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  4757. }
  4758. lookaheadCharCode() {
  4759. return this.input.charCodeAt(this.nextTokenStart());
  4760. }
  4761. nextTokenInLineStart() {
  4762. return this.nextTokenInLineStartSince(this.state.pos);
  4763. }
  4764. nextTokenInLineStartSince(pos) {
  4765. skipWhiteSpaceInLine.lastIndex = pos;
  4766. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  4767. }
  4768. lookaheadInLineCharCode() {
  4769. return this.input.charCodeAt(this.nextTokenInLineStart());
  4770. }
  4771. codePointAtPos(pos) {
  4772. let cp = this.input.charCodeAt(pos);
  4773. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  4774. const trail = this.input.charCodeAt(pos);
  4775. if ((trail & 0xfc00) === 0xdc00) {
  4776. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  4777. }
  4778. }
  4779. return cp;
  4780. }
  4781. setStrict(strict) {
  4782. this.state.strict = strict;
  4783. if (strict) {
  4784. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  4785. this.state.strictErrors.clear();
  4786. }
  4787. }
  4788. curContext() {
  4789. return this.state.context[this.state.context.length - 1];
  4790. }
  4791. nextToken() {
  4792. this.skipSpace();
  4793. this.state.start = this.state.pos;
  4794. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  4795. if (this.state.pos >= this.length) {
  4796. this.finishToken(139);
  4797. return;
  4798. }
  4799. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  4800. }
  4801. skipBlockComment(commentEnd) {
  4802. let startLoc;
  4803. if (!this.isLookahead) startLoc = this.state.curPosition();
  4804. const start = this.state.pos;
  4805. const end = this.input.indexOf(commentEnd, start + 2);
  4806. if (end === -1) {
  4807. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  4808. }
  4809. this.state.pos = end + commentEnd.length;
  4810. lineBreakG.lastIndex = start + 2;
  4811. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  4812. ++this.state.curLine;
  4813. this.state.lineStart = lineBreakG.lastIndex;
  4814. }
  4815. if (this.isLookahead) return;
  4816. const comment = {
  4817. type: "CommentBlock",
  4818. value: this.input.slice(start + 2, end),
  4819. start,
  4820. end: end + commentEnd.length,
  4821. loc: new SourceLocation(startLoc, this.state.curPosition())
  4822. };
  4823. if (this.options.tokens) this.pushToken(comment);
  4824. return comment;
  4825. }
  4826. skipLineComment(startSkip) {
  4827. const start = this.state.pos;
  4828. let startLoc;
  4829. if (!this.isLookahead) startLoc = this.state.curPosition();
  4830. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  4831. if (this.state.pos < this.length) {
  4832. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4833. ch = this.input.charCodeAt(this.state.pos);
  4834. }
  4835. }
  4836. if (this.isLookahead) return;
  4837. const end = this.state.pos;
  4838. const value = this.input.slice(start + startSkip, end);
  4839. const comment = {
  4840. type: "CommentLine",
  4841. value,
  4842. start,
  4843. end,
  4844. loc: new SourceLocation(startLoc, this.state.curPosition())
  4845. };
  4846. if (this.options.tokens) this.pushToken(comment);
  4847. return comment;
  4848. }
  4849. skipSpace() {
  4850. const spaceStart = this.state.pos;
  4851. const comments = [];
  4852. loop: while (this.state.pos < this.length) {
  4853. const ch = this.input.charCodeAt(this.state.pos);
  4854. switch (ch) {
  4855. case 32:
  4856. case 160:
  4857. case 9:
  4858. ++this.state.pos;
  4859. break;
  4860. case 13:
  4861. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  4862. ++this.state.pos;
  4863. }
  4864. case 10:
  4865. case 8232:
  4866. case 8233:
  4867. ++this.state.pos;
  4868. ++this.state.curLine;
  4869. this.state.lineStart = this.state.pos;
  4870. break;
  4871. case 47:
  4872. switch (this.input.charCodeAt(this.state.pos + 1)) {
  4873. case 42:
  4874. {
  4875. const comment = this.skipBlockComment("*/");
  4876. if (comment !== undefined) {
  4877. this.addComment(comment);
  4878. if (this.options.attachComment) comments.push(comment);
  4879. }
  4880. break;
  4881. }
  4882. case 47:
  4883. {
  4884. const comment = this.skipLineComment(2);
  4885. if (comment !== undefined) {
  4886. this.addComment(comment);
  4887. if (this.options.attachComment) comments.push(comment);
  4888. }
  4889. break;
  4890. }
  4891. default:
  4892. break loop;
  4893. }
  4894. break;
  4895. default:
  4896. if (isWhitespace(ch)) {
  4897. ++this.state.pos;
  4898. } else if (ch === 45 && !this.inModule && this.options.annexB) {
  4899. const pos = this.state.pos;
  4900. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  4901. const comment = this.skipLineComment(3);
  4902. if (comment !== undefined) {
  4903. this.addComment(comment);
  4904. if (this.options.attachComment) comments.push(comment);
  4905. }
  4906. } else {
  4907. break loop;
  4908. }
  4909. } else if (ch === 60 && !this.inModule && this.options.annexB) {
  4910. const pos = this.state.pos;
  4911. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  4912. const comment = this.skipLineComment(4);
  4913. if (comment !== undefined) {
  4914. this.addComment(comment);
  4915. if (this.options.attachComment) comments.push(comment);
  4916. }
  4917. } else {
  4918. break loop;
  4919. }
  4920. } else {
  4921. break loop;
  4922. }
  4923. }
  4924. }
  4925. if (comments.length > 0) {
  4926. const end = this.state.pos;
  4927. const commentWhitespace = {
  4928. start: spaceStart,
  4929. end,
  4930. comments,
  4931. leadingNode: null,
  4932. trailingNode: null,
  4933. containingNode: null
  4934. };
  4935. this.state.commentStack.push(commentWhitespace);
  4936. }
  4937. }
  4938. finishToken(type, val) {
  4939. this.state.end = this.state.pos;
  4940. this.state.endLoc = this.state.curPosition();
  4941. const prevType = this.state.type;
  4942. this.state.type = type;
  4943. this.state.value = val;
  4944. if (!this.isLookahead) {
  4945. this.updateContext(prevType);
  4946. }
  4947. }
  4948. replaceToken(type) {
  4949. this.state.type = type;
  4950. this.updateContext();
  4951. }
  4952. readToken_numberSign() {
  4953. if (this.state.pos === 0 && this.readToken_interpreter()) {
  4954. return;
  4955. }
  4956. const nextPos = this.state.pos + 1;
  4957. const next = this.codePointAtPos(nextPos);
  4958. if (next >= 48 && next <= 57) {
  4959. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  4960. }
  4961. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  4962. this.expectPlugin("recordAndTuple");
  4963. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  4964. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  4965. }
  4966. this.state.pos += 2;
  4967. if (next === 123) {
  4968. this.finishToken(7);
  4969. } else {
  4970. this.finishToken(1);
  4971. }
  4972. } else if (isIdentifierStart(next)) {
  4973. ++this.state.pos;
  4974. this.finishToken(138, this.readWord1(next));
  4975. } else if (next === 92) {
  4976. ++this.state.pos;
  4977. this.finishToken(138, this.readWord1());
  4978. } else {
  4979. this.finishOp(27, 1);
  4980. }
  4981. }
  4982. readToken_dot() {
  4983. const next = this.input.charCodeAt(this.state.pos + 1);
  4984. if (next >= 48 && next <= 57) {
  4985. this.readNumber(true);
  4986. return;
  4987. }
  4988. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  4989. this.state.pos += 3;
  4990. this.finishToken(21);
  4991. } else {
  4992. ++this.state.pos;
  4993. this.finishToken(16);
  4994. }
  4995. }
  4996. readToken_slash() {
  4997. const next = this.input.charCodeAt(this.state.pos + 1);
  4998. if (next === 61) {
  4999. this.finishOp(31, 2);
  5000. } else {
  5001. this.finishOp(56, 1);
  5002. }
  5003. }
  5004. readToken_interpreter() {
  5005. if (this.state.pos !== 0 || this.length < 2) return false;
  5006. let ch = this.input.charCodeAt(this.state.pos + 1);
  5007. if (ch !== 33) return false;
  5008. const start = this.state.pos;
  5009. this.state.pos += 1;
  5010. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  5011. ch = this.input.charCodeAt(this.state.pos);
  5012. }
  5013. const value = this.input.slice(start + 2, this.state.pos);
  5014. this.finishToken(28, value);
  5015. return true;
  5016. }
  5017. readToken_mult_modulo(code) {
  5018. let type = code === 42 ? 55 : 54;
  5019. let width = 1;
  5020. let next = this.input.charCodeAt(this.state.pos + 1);
  5021. if (code === 42 && next === 42) {
  5022. width++;
  5023. next = this.input.charCodeAt(this.state.pos + 2);
  5024. type = 57;
  5025. }
  5026. if (next === 61 && !this.state.inType) {
  5027. width++;
  5028. type = code === 37 ? 33 : 30;
  5029. }
  5030. this.finishOp(type, width);
  5031. }
  5032. readToken_pipe_amp(code) {
  5033. const next = this.input.charCodeAt(this.state.pos + 1);
  5034. if (next === code) {
  5035. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  5036. this.finishOp(30, 3);
  5037. } else {
  5038. this.finishOp(code === 124 ? 41 : 42, 2);
  5039. }
  5040. return;
  5041. }
  5042. if (code === 124) {
  5043. if (next === 62) {
  5044. this.finishOp(39, 2);
  5045. return;
  5046. }
  5047. if (this.hasPlugin("recordAndTuple") && next === 125) {
  5048. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5049. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5050. }
  5051. this.state.pos += 2;
  5052. this.finishToken(9);
  5053. return;
  5054. }
  5055. if (this.hasPlugin("recordAndTuple") && next === 93) {
  5056. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5057. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5058. }
  5059. this.state.pos += 2;
  5060. this.finishToken(4);
  5061. return;
  5062. }
  5063. }
  5064. if (next === 61) {
  5065. this.finishOp(30, 2);
  5066. return;
  5067. }
  5068. this.finishOp(code === 124 ? 43 : 45, 1);
  5069. }
  5070. readToken_caret() {
  5071. const next = this.input.charCodeAt(this.state.pos + 1);
  5072. if (next === 61 && !this.state.inType) {
  5073. this.finishOp(32, 2);
  5074. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  5075. proposal: "hack",
  5076. topicToken: "^^"
  5077. }])) {
  5078. this.finishOp(37, 2);
  5079. const lookaheadCh = this.input.codePointAt(this.state.pos);
  5080. if (lookaheadCh === 94) {
  5081. this.unexpected();
  5082. }
  5083. } else {
  5084. this.finishOp(44, 1);
  5085. }
  5086. }
  5087. readToken_atSign() {
  5088. const next = this.input.charCodeAt(this.state.pos + 1);
  5089. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  5090. proposal: "hack",
  5091. topicToken: "@@"
  5092. }])) {
  5093. this.finishOp(38, 2);
  5094. } else {
  5095. this.finishOp(26, 1);
  5096. }
  5097. }
  5098. readToken_plus_min(code) {
  5099. const next = this.input.charCodeAt(this.state.pos + 1);
  5100. if (next === code) {
  5101. this.finishOp(34, 2);
  5102. return;
  5103. }
  5104. if (next === 61) {
  5105. this.finishOp(30, 2);
  5106. } else {
  5107. this.finishOp(53, 1);
  5108. }
  5109. }
  5110. readToken_lt() {
  5111. const {
  5112. pos
  5113. } = this.state;
  5114. const next = this.input.charCodeAt(pos + 1);
  5115. if (next === 60) {
  5116. if (this.input.charCodeAt(pos + 2) === 61) {
  5117. this.finishOp(30, 3);
  5118. return;
  5119. }
  5120. this.finishOp(51, 2);
  5121. return;
  5122. }
  5123. if (next === 61) {
  5124. this.finishOp(49, 2);
  5125. return;
  5126. }
  5127. this.finishOp(47, 1);
  5128. }
  5129. readToken_gt() {
  5130. const {
  5131. pos
  5132. } = this.state;
  5133. const next = this.input.charCodeAt(pos + 1);
  5134. if (next === 62) {
  5135. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  5136. if (this.input.charCodeAt(pos + size) === 61) {
  5137. this.finishOp(30, size + 1);
  5138. return;
  5139. }
  5140. this.finishOp(52, size);
  5141. return;
  5142. }
  5143. if (next === 61) {
  5144. this.finishOp(49, 2);
  5145. return;
  5146. }
  5147. this.finishOp(48, 1);
  5148. }
  5149. readToken_eq_excl(code) {
  5150. const next = this.input.charCodeAt(this.state.pos + 1);
  5151. if (next === 61) {
  5152. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  5153. return;
  5154. }
  5155. if (code === 61 && next === 62) {
  5156. this.state.pos += 2;
  5157. this.finishToken(19);
  5158. return;
  5159. }
  5160. this.finishOp(code === 61 ? 29 : 35, 1);
  5161. }
  5162. readToken_question() {
  5163. const next = this.input.charCodeAt(this.state.pos + 1);
  5164. const next2 = this.input.charCodeAt(this.state.pos + 2);
  5165. if (next === 63) {
  5166. if (next2 === 61) {
  5167. this.finishOp(30, 3);
  5168. } else {
  5169. this.finishOp(40, 2);
  5170. }
  5171. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  5172. this.state.pos += 2;
  5173. this.finishToken(18);
  5174. } else {
  5175. ++this.state.pos;
  5176. this.finishToken(17);
  5177. }
  5178. }
  5179. getTokenFromCode(code) {
  5180. switch (code) {
  5181. case 46:
  5182. this.readToken_dot();
  5183. return;
  5184. case 40:
  5185. ++this.state.pos;
  5186. this.finishToken(10);
  5187. return;
  5188. case 41:
  5189. ++this.state.pos;
  5190. this.finishToken(11);
  5191. return;
  5192. case 59:
  5193. ++this.state.pos;
  5194. this.finishToken(13);
  5195. return;
  5196. case 44:
  5197. ++this.state.pos;
  5198. this.finishToken(12);
  5199. return;
  5200. case 91:
  5201. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5202. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5203. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5204. }
  5205. this.state.pos += 2;
  5206. this.finishToken(2);
  5207. } else {
  5208. ++this.state.pos;
  5209. this.finishToken(0);
  5210. }
  5211. return;
  5212. case 93:
  5213. ++this.state.pos;
  5214. this.finishToken(3);
  5215. return;
  5216. case 123:
  5217. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5218. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5219. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5220. }
  5221. this.state.pos += 2;
  5222. this.finishToken(6);
  5223. } else {
  5224. ++this.state.pos;
  5225. this.finishToken(5);
  5226. }
  5227. return;
  5228. case 125:
  5229. ++this.state.pos;
  5230. this.finishToken(8);
  5231. return;
  5232. case 58:
  5233. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  5234. this.finishOp(15, 2);
  5235. } else {
  5236. ++this.state.pos;
  5237. this.finishToken(14);
  5238. }
  5239. return;
  5240. case 63:
  5241. this.readToken_question();
  5242. return;
  5243. case 96:
  5244. this.readTemplateToken();
  5245. return;
  5246. case 48:
  5247. {
  5248. const next = this.input.charCodeAt(this.state.pos + 1);
  5249. if (next === 120 || next === 88) {
  5250. this.readRadixNumber(16);
  5251. return;
  5252. }
  5253. if (next === 111 || next === 79) {
  5254. this.readRadixNumber(8);
  5255. return;
  5256. }
  5257. if (next === 98 || next === 66) {
  5258. this.readRadixNumber(2);
  5259. return;
  5260. }
  5261. }
  5262. case 49:
  5263. case 50:
  5264. case 51:
  5265. case 52:
  5266. case 53:
  5267. case 54:
  5268. case 55:
  5269. case 56:
  5270. case 57:
  5271. this.readNumber(false);
  5272. return;
  5273. case 34:
  5274. case 39:
  5275. this.readString(code);
  5276. return;
  5277. case 47:
  5278. this.readToken_slash();
  5279. return;
  5280. case 37:
  5281. case 42:
  5282. this.readToken_mult_modulo(code);
  5283. return;
  5284. case 124:
  5285. case 38:
  5286. this.readToken_pipe_amp(code);
  5287. return;
  5288. case 94:
  5289. this.readToken_caret();
  5290. return;
  5291. case 43:
  5292. case 45:
  5293. this.readToken_plus_min(code);
  5294. return;
  5295. case 60:
  5296. this.readToken_lt();
  5297. return;
  5298. case 62:
  5299. this.readToken_gt();
  5300. return;
  5301. case 61:
  5302. case 33:
  5303. this.readToken_eq_excl(code);
  5304. return;
  5305. case 126:
  5306. this.finishOp(36, 1);
  5307. return;
  5308. case 64:
  5309. this.readToken_atSign();
  5310. return;
  5311. case 35:
  5312. this.readToken_numberSign();
  5313. return;
  5314. case 92:
  5315. this.readWord();
  5316. return;
  5317. default:
  5318. if (isIdentifierStart(code)) {
  5319. this.readWord(code);
  5320. return;
  5321. }
  5322. }
  5323. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  5324. unexpected: String.fromCodePoint(code)
  5325. });
  5326. }
  5327. finishOp(type, size) {
  5328. const str = this.input.slice(this.state.pos, this.state.pos + size);
  5329. this.state.pos += size;
  5330. this.finishToken(type, str);
  5331. }
  5332. readRegexp() {
  5333. const startLoc = this.state.startLoc;
  5334. const start = this.state.start + 1;
  5335. let escaped, inClass;
  5336. let {
  5337. pos
  5338. } = this.state;
  5339. for (;; ++pos) {
  5340. if (pos >= this.length) {
  5341. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5342. }
  5343. const ch = this.input.charCodeAt(pos);
  5344. if (isNewLine(ch)) {
  5345. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5346. }
  5347. if (escaped) {
  5348. escaped = false;
  5349. } else {
  5350. if (ch === 91) {
  5351. inClass = true;
  5352. } else if (ch === 93 && inClass) {
  5353. inClass = false;
  5354. } else if (ch === 47 && !inClass) {
  5355. break;
  5356. }
  5357. escaped = ch === 92;
  5358. }
  5359. }
  5360. const content = this.input.slice(start, pos);
  5361. ++pos;
  5362. let mods = "";
  5363. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  5364. while (pos < this.length) {
  5365. const cp = this.codePointAtPos(pos);
  5366. const char = String.fromCharCode(cp);
  5367. if (VALID_REGEX_FLAGS.has(cp)) {
  5368. if (cp === 118) {
  5369. if (mods.includes("u")) {
  5370. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5371. }
  5372. } else if (cp === 117) {
  5373. if (mods.includes("v")) {
  5374. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5375. }
  5376. }
  5377. if (mods.includes(char)) {
  5378. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  5379. }
  5380. } else if (isIdentifierChar(cp) || cp === 92) {
  5381. this.raise(Errors.MalformedRegExpFlags, nextPos());
  5382. } else {
  5383. break;
  5384. }
  5385. ++pos;
  5386. mods += char;
  5387. }
  5388. this.state.pos = pos;
  5389. this.finishToken(137, {
  5390. pattern: content,
  5391. flags: mods
  5392. });
  5393. }
  5394. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  5395. const {
  5396. n,
  5397. pos
  5398. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  5399. this.state.pos = pos;
  5400. return n;
  5401. }
  5402. readRadixNumber(radix) {
  5403. const startLoc = this.state.curPosition();
  5404. let isBigInt = false;
  5405. this.state.pos += 2;
  5406. const val = this.readInt(radix);
  5407. if (val == null) {
  5408. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  5409. radix
  5410. });
  5411. }
  5412. const next = this.input.charCodeAt(this.state.pos);
  5413. if (next === 110) {
  5414. ++this.state.pos;
  5415. isBigInt = true;
  5416. } else if (next === 109) {
  5417. throw this.raise(Errors.InvalidDecimal, startLoc);
  5418. }
  5419. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5420. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5421. }
  5422. if (isBigInt) {
  5423. const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, "");
  5424. this.finishToken(135, str);
  5425. return;
  5426. }
  5427. this.finishToken(134, val);
  5428. }
  5429. readNumber(startsWithDot) {
  5430. const start = this.state.pos;
  5431. const startLoc = this.state.curPosition();
  5432. let isFloat = false;
  5433. let isBigInt = false;
  5434. let isDecimal = false;
  5435. let hasExponent = false;
  5436. let isOctal = false;
  5437. if (!startsWithDot && this.readInt(10) === null) {
  5438. this.raise(Errors.InvalidNumber, this.state.curPosition());
  5439. }
  5440. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5441. if (hasLeadingZero) {
  5442. const integer = this.input.slice(start, this.state.pos);
  5443. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  5444. if (!this.state.strict) {
  5445. const underscorePos = integer.indexOf("_");
  5446. if (underscorePos > 0) {
  5447. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  5448. }
  5449. }
  5450. isOctal = hasLeadingZero && !/[89]/.test(integer);
  5451. }
  5452. let next = this.input.charCodeAt(this.state.pos);
  5453. if (next === 46 && !isOctal) {
  5454. ++this.state.pos;
  5455. this.readInt(10);
  5456. isFloat = true;
  5457. next = this.input.charCodeAt(this.state.pos);
  5458. }
  5459. if ((next === 69 || next === 101) && !isOctal) {
  5460. next = this.input.charCodeAt(++this.state.pos);
  5461. if (next === 43 || next === 45) {
  5462. ++this.state.pos;
  5463. }
  5464. if (this.readInt(10) === null) {
  5465. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  5466. }
  5467. isFloat = true;
  5468. hasExponent = true;
  5469. next = this.input.charCodeAt(this.state.pos);
  5470. }
  5471. if (next === 110) {
  5472. if (isFloat || hasLeadingZero) {
  5473. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  5474. }
  5475. ++this.state.pos;
  5476. isBigInt = true;
  5477. }
  5478. if (next === 109) {
  5479. this.expectPlugin("decimal", this.state.curPosition());
  5480. if (hasExponent || hasLeadingZero) {
  5481. this.raise(Errors.InvalidDecimal, startLoc);
  5482. }
  5483. ++this.state.pos;
  5484. isDecimal = true;
  5485. }
  5486. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5487. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5488. }
  5489. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  5490. if (isBigInt) {
  5491. this.finishToken(135, str);
  5492. return;
  5493. }
  5494. if (isDecimal) {
  5495. this.finishToken(136, str);
  5496. return;
  5497. }
  5498. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  5499. this.finishToken(134, val);
  5500. }
  5501. readCodePoint(throwOnInvalid) {
  5502. const {
  5503. code,
  5504. pos
  5505. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  5506. this.state.pos = pos;
  5507. return code;
  5508. }
  5509. readString(quote) {
  5510. const {
  5511. str,
  5512. pos,
  5513. curLine,
  5514. lineStart
  5515. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  5516. this.state.pos = pos + 1;
  5517. this.state.lineStart = lineStart;
  5518. this.state.curLine = curLine;
  5519. this.finishToken(133, str);
  5520. }
  5521. readTemplateContinuation() {
  5522. if (!this.match(8)) {
  5523. this.unexpected(null, 8);
  5524. }
  5525. this.state.pos--;
  5526. this.readTemplateToken();
  5527. }
  5528. readTemplateToken() {
  5529. const opening = this.input[this.state.pos];
  5530. const {
  5531. str,
  5532. firstInvalidLoc,
  5533. pos,
  5534. curLine,
  5535. lineStart
  5536. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  5537. this.state.pos = pos + 1;
  5538. this.state.lineStart = lineStart;
  5539. this.state.curLine = curLine;
  5540. if (firstInvalidLoc) {
  5541. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
  5542. }
  5543. if (this.input.codePointAt(pos) === 96) {
  5544. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  5545. } else {
  5546. this.state.pos++;
  5547. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  5548. }
  5549. }
  5550. recordStrictModeErrors(toParseError, at) {
  5551. const index = at.index;
  5552. if (this.state.strict && !this.state.strictErrors.has(index)) {
  5553. this.raise(toParseError, at);
  5554. } else {
  5555. this.state.strictErrors.set(index, [toParseError, at]);
  5556. }
  5557. }
  5558. readWord1(firstCode) {
  5559. this.state.containsEsc = false;
  5560. let word = "";
  5561. const start = this.state.pos;
  5562. let chunkStart = this.state.pos;
  5563. if (firstCode !== undefined) {
  5564. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  5565. }
  5566. while (this.state.pos < this.length) {
  5567. const ch = this.codePointAtPos(this.state.pos);
  5568. if (isIdentifierChar(ch)) {
  5569. this.state.pos += ch <= 0xffff ? 1 : 2;
  5570. } else if (ch === 92) {
  5571. this.state.containsEsc = true;
  5572. word += this.input.slice(chunkStart, this.state.pos);
  5573. const escStart = this.state.curPosition();
  5574. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  5575. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  5576. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  5577. chunkStart = this.state.pos - 1;
  5578. continue;
  5579. }
  5580. ++this.state.pos;
  5581. const esc = this.readCodePoint(true);
  5582. if (esc !== null) {
  5583. if (!identifierCheck(esc)) {
  5584. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  5585. }
  5586. word += String.fromCodePoint(esc);
  5587. }
  5588. chunkStart = this.state.pos;
  5589. } else {
  5590. break;
  5591. }
  5592. }
  5593. return word + this.input.slice(chunkStart, this.state.pos);
  5594. }
  5595. readWord(firstCode) {
  5596. const word = this.readWord1(firstCode);
  5597. const type = keywords$1.get(word);
  5598. if (type !== undefined) {
  5599. this.finishToken(type, tokenLabelName(type));
  5600. } else {
  5601. this.finishToken(132, word);
  5602. }
  5603. }
  5604. checkKeywordEscapes() {
  5605. const {
  5606. type
  5607. } = this.state;
  5608. if (tokenIsKeyword(type) && this.state.containsEsc) {
  5609. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  5610. reservedWord: tokenLabelName(type)
  5611. });
  5612. }
  5613. }
  5614. raise(toParseError, at, details = {}) {
  5615. const loc = at instanceof Position ? at : at.loc.start;
  5616. const error = toParseError(loc, details);
  5617. if (!this.options.errorRecovery) throw error;
  5618. if (!this.isLookahead) this.state.errors.push(error);
  5619. return error;
  5620. }
  5621. raiseOverwrite(toParseError, at, details = {}) {
  5622. const loc = at instanceof Position ? at : at.loc.start;
  5623. const pos = loc.index;
  5624. const errors = this.state.errors;
  5625. for (let i = errors.length - 1; i >= 0; i--) {
  5626. const error = errors[i];
  5627. if (error.loc.index === pos) {
  5628. return errors[i] = toParseError(loc, details);
  5629. }
  5630. if (error.loc.index < pos) break;
  5631. }
  5632. return this.raise(toParseError, at, details);
  5633. }
  5634. updateContext(prevType) {}
  5635. unexpected(loc, type) {
  5636. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  5637. expected: type ? tokenLabelName(type) : null
  5638. });
  5639. }
  5640. expectPlugin(pluginName, loc) {
  5641. if (this.hasPlugin(pluginName)) {
  5642. return true;
  5643. }
  5644. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  5645. missingPlugin: [pluginName]
  5646. });
  5647. }
  5648. expectOnePlugin(pluginNames) {
  5649. if (!pluginNames.some(name => this.hasPlugin(name))) {
  5650. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  5651. missingPlugin: pluginNames
  5652. });
  5653. }
  5654. }
  5655. errorBuilder(error) {
  5656. return (pos, lineStart, curLine) => {
  5657. this.raise(error, buildPosition(pos, lineStart, curLine));
  5658. };
  5659. }
  5660. }
  5661. class ClassScope {
  5662. constructor() {
  5663. this.privateNames = new Set();
  5664. this.loneAccessors = new Map();
  5665. this.undefinedPrivateNames = new Map();
  5666. }
  5667. }
  5668. class ClassScopeHandler {
  5669. constructor(parser) {
  5670. this.parser = void 0;
  5671. this.stack = [];
  5672. this.undefinedPrivateNames = new Map();
  5673. this.parser = parser;
  5674. }
  5675. current() {
  5676. return this.stack[this.stack.length - 1];
  5677. }
  5678. enter() {
  5679. this.stack.push(new ClassScope());
  5680. }
  5681. exit() {
  5682. const oldClassScope = this.stack.pop();
  5683. const current = this.current();
  5684. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  5685. if (current) {
  5686. if (!current.undefinedPrivateNames.has(name)) {
  5687. current.undefinedPrivateNames.set(name, loc);
  5688. }
  5689. } else {
  5690. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5691. identifierName: name
  5692. });
  5693. }
  5694. }
  5695. }
  5696. declarePrivateName(name, elementType, loc) {
  5697. const {
  5698. privateNames,
  5699. loneAccessors,
  5700. undefinedPrivateNames
  5701. } = this.current();
  5702. let redefined = privateNames.has(name);
  5703. if (elementType & 3) {
  5704. const accessor = redefined && loneAccessors.get(name);
  5705. if (accessor) {
  5706. const oldStatic = accessor & 4;
  5707. const newStatic = elementType & 4;
  5708. const oldKind = accessor & 3;
  5709. const newKind = elementType & 3;
  5710. redefined = oldKind === newKind || oldStatic !== newStatic;
  5711. if (!redefined) loneAccessors.delete(name);
  5712. } else if (!redefined) {
  5713. loneAccessors.set(name, elementType);
  5714. }
  5715. }
  5716. if (redefined) {
  5717. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  5718. identifierName: name
  5719. });
  5720. }
  5721. privateNames.add(name);
  5722. undefinedPrivateNames.delete(name);
  5723. }
  5724. usePrivateName(name, loc) {
  5725. let classScope;
  5726. for (classScope of this.stack) {
  5727. if (classScope.privateNames.has(name)) return;
  5728. }
  5729. if (classScope) {
  5730. classScope.undefinedPrivateNames.set(name, loc);
  5731. } else {
  5732. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5733. identifierName: name
  5734. });
  5735. }
  5736. }
  5737. }
  5738. class ExpressionScope {
  5739. constructor(type = 0) {
  5740. this.type = type;
  5741. }
  5742. canBeArrowParameterDeclaration() {
  5743. return this.type === 2 || this.type === 1;
  5744. }
  5745. isCertainlyParameterDeclaration() {
  5746. return this.type === 3;
  5747. }
  5748. }
  5749. class ArrowHeadParsingScope extends ExpressionScope {
  5750. constructor(type) {
  5751. super(type);
  5752. this.declarationErrors = new Map();
  5753. }
  5754. recordDeclarationError(ParsingErrorClass, at) {
  5755. const index = at.index;
  5756. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  5757. }
  5758. clearDeclarationError(index) {
  5759. this.declarationErrors.delete(index);
  5760. }
  5761. iterateErrors(iterator) {
  5762. this.declarationErrors.forEach(iterator);
  5763. }
  5764. }
  5765. class ExpressionScopeHandler {
  5766. constructor(parser) {
  5767. this.parser = void 0;
  5768. this.stack = [new ExpressionScope()];
  5769. this.parser = parser;
  5770. }
  5771. enter(scope) {
  5772. this.stack.push(scope);
  5773. }
  5774. exit() {
  5775. this.stack.pop();
  5776. }
  5777. recordParameterInitializerError(toParseError, node) {
  5778. const origin = node.loc.start;
  5779. const {
  5780. stack
  5781. } = this;
  5782. let i = stack.length - 1;
  5783. let scope = stack[i];
  5784. while (!scope.isCertainlyParameterDeclaration()) {
  5785. if (scope.canBeArrowParameterDeclaration()) {
  5786. scope.recordDeclarationError(toParseError, origin);
  5787. } else {
  5788. return;
  5789. }
  5790. scope = stack[--i];
  5791. }
  5792. this.parser.raise(toParseError, origin);
  5793. }
  5794. recordArrowParameterBindingError(error, node) {
  5795. const {
  5796. stack
  5797. } = this;
  5798. const scope = stack[stack.length - 1];
  5799. const origin = node.loc.start;
  5800. if (scope.isCertainlyParameterDeclaration()) {
  5801. this.parser.raise(error, origin);
  5802. } else if (scope.canBeArrowParameterDeclaration()) {
  5803. scope.recordDeclarationError(error, origin);
  5804. } else {
  5805. return;
  5806. }
  5807. }
  5808. recordAsyncArrowParametersError(at) {
  5809. const {
  5810. stack
  5811. } = this;
  5812. let i = stack.length - 1;
  5813. let scope = stack[i];
  5814. while (scope.canBeArrowParameterDeclaration()) {
  5815. if (scope.type === 2) {
  5816. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  5817. }
  5818. scope = stack[--i];
  5819. }
  5820. }
  5821. validateAsPattern() {
  5822. const {
  5823. stack
  5824. } = this;
  5825. const currentScope = stack[stack.length - 1];
  5826. if (!currentScope.canBeArrowParameterDeclaration()) return;
  5827. currentScope.iterateErrors(([toParseError, loc]) => {
  5828. this.parser.raise(toParseError, loc);
  5829. let i = stack.length - 2;
  5830. let scope = stack[i];
  5831. while (scope.canBeArrowParameterDeclaration()) {
  5832. scope.clearDeclarationError(loc.index);
  5833. scope = stack[--i];
  5834. }
  5835. });
  5836. }
  5837. }
  5838. function newParameterDeclarationScope() {
  5839. return new ExpressionScope(3);
  5840. }
  5841. function newArrowHeadScope() {
  5842. return new ArrowHeadParsingScope(1);
  5843. }
  5844. function newAsyncArrowScope() {
  5845. return new ArrowHeadParsingScope(2);
  5846. }
  5847. function newExpressionScope() {
  5848. return new ExpressionScope();
  5849. }
  5850. class ProductionParameterHandler {
  5851. constructor() {
  5852. this.stacks = [];
  5853. }
  5854. enter(flags) {
  5855. this.stacks.push(flags);
  5856. }
  5857. exit() {
  5858. this.stacks.pop();
  5859. }
  5860. currentFlags() {
  5861. return this.stacks[this.stacks.length - 1];
  5862. }
  5863. get hasAwait() {
  5864. return (this.currentFlags() & 2) > 0;
  5865. }
  5866. get hasYield() {
  5867. return (this.currentFlags() & 1) > 0;
  5868. }
  5869. get hasReturn() {
  5870. return (this.currentFlags() & 4) > 0;
  5871. }
  5872. get hasIn() {
  5873. return (this.currentFlags() & 8) > 0;
  5874. }
  5875. }
  5876. function functionFlags(isAsync, isGenerator) {
  5877. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  5878. }
  5879. class UtilParser extends Tokenizer {
  5880. addExtra(node, key, value, enumerable = true) {
  5881. if (!node) return;
  5882. const extra = node.extra = node.extra || {};
  5883. if (enumerable) {
  5884. extra[key] = value;
  5885. } else {
  5886. Object.defineProperty(extra, key, {
  5887. enumerable,
  5888. value
  5889. });
  5890. }
  5891. }
  5892. isContextual(token) {
  5893. return this.state.type === token && !this.state.containsEsc;
  5894. }
  5895. isUnparsedContextual(nameStart, name) {
  5896. const nameEnd = nameStart + name.length;
  5897. if (this.input.slice(nameStart, nameEnd) === name) {
  5898. const nextCh = this.input.charCodeAt(nameEnd);
  5899. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  5900. }
  5901. return false;
  5902. }
  5903. isLookaheadContextual(name) {
  5904. const next = this.nextTokenStart();
  5905. return this.isUnparsedContextual(next, name);
  5906. }
  5907. eatContextual(token) {
  5908. if (this.isContextual(token)) {
  5909. this.next();
  5910. return true;
  5911. }
  5912. return false;
  5913. }
  5914. expectContextual(token, toParseError) {
  5915. if (!this.eatContextual(token)) {
  5916. if (toParseError != null) {
  5917. throw this.raise(toParseError, this.state.startLoc);
  5918. }
  5919. this.unexpected(null, token);
  5920. }
  5921. }
  5922. canInsertSemicolon() {
  5923. return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
  5924. }
  5925. hasPrecedingLineBreak() {
  5926. return lineBreak.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start));
  5927. }
  5928. hasFollowingLineBreak() {
  5929. skipWhiteSpaceToLineBreak.lastIndex = this.state.end;
  5930. return skipWhiteSpaceToLineBreak.test(this.input);
  5931. }
  5932. isLineTerminator() {
  5933. return this.eat(13) || this.canInsertSemicolon();
  5934. }
  5935. semicolon(allowAsi = true) {
  5936. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  5937. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  5938. }
  5939. expect(type, loc) {
  5940. this.eat(type) || this.unexpected(loc, type);
  5941. }
  5942. tryParse(fn, oldState = this.state.clone()) {
  5943. const abortSignal = {
  5944. node: null
  5945. };
  5946. try {
  5947. const node = fn((node = null) => {
  5948. abortSignal.node = node;
  5949. throw abortSignal;
  5950. });
  5951. if (this.state.errors.length > oldState.errors.length) {
  5952. const failState = this.state;
  5953. this.state = oldState;
  5954. this.state.tokensLength = failState.tokensLength;
  5955. return {
  5956. node,
  5957. error: failState.errors[oldState.errors.length],
  5958. thrown: false,
  5959. aborted: false,
  5960. failState
  5961. };
  5962. }
  5963. return {
  5964. node,
  5965. error: null,
  5966. thrown: false,
  5967. aborted: false,
  5968. failState: null
  5969. };
  5970. } catch (error) {
  5971. const failState = this.state;
  5972. this.state = oldState;
  5973. if (error instanceof SyntaxError) {
  5974. return {
  5975. node: null,
  5976. error,
  5977. thrown: true,
  5978. aborted: false,
  5979. failState
  5980. };
  5981. }
  5982. if (error === abortSignal) {
  5983. return {
  5984. node: abortSignal.node,
  5985. error: null,
  5986. thrown: false,
  5987. aborted: true,
  5988. failState
  5989. };
  5990. }
  5991. throw error;
  5992. }
  5993. }
  5994. checkExpressionErrors(refExpressionErrors, andThrow) {
  5995. if (!refExpressionErrors) return false;
  5996. const {
  5997. shorthandAssignLoc,
  5998. doubleProtoLoc,
  5999. privateKeyLoc,
  6000. optionalParametersLoc
  6001. } = refExpressionErrors;
  6002. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
  6003. if (!andThrow) {
  6004. return hasErrors;
  6005. }
  6006. if (shorthandAssignLoc != null) {
  6007. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  6008. }
  6009. if (doubleProtoLoc != null) {
  6010. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  6011. }
  6012. if (privateKeyLoc != null) {
  6013. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  6014. }
  6015. if (optionalParametersLoc != null) {
  6016. this.unexpected(optionalParametersLoc);
  6017. }
  6018. }
  6019. isLiteralPropertyName() {
  6020. return tokenIsLiteralPropertyName(this.state.type);
  6021. }
  6022. isPrivateName(node) {
  6023. return node.type === "PrivateName";
  6024. }
  6025. getPrivateNameSV(node) {
  6026. return node.id.name;
  6027. }
  6028. hasPropertyAsPrivateName(node) {
  6029. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  6030. }
  6031. isObjectProperty(node) {
  6032. return node.type === "ObjectProperty";
  6033. }
  6034. isObjectMethod(node) {
  6035. return node.type === "ObjectMethod";
  6036. }
  6037. initializeScopes(inModule = this.options.sourceType === "module") {
  6038. const oldLabels = this.state.labels;
  6039. this.state.labels = [];
  6040. const oldExportedIdentifiers = this.exportedIdentifiers;
  6041. this.exportedIdentifiers = new Set();
  6042. const oldInModule = this.inModule;
  6043. this.inModule = inModule;
  6044. const oldScope = this.scope;
  6045. const ScopeHandler = this.getScopeHandler();
  6046. this.scope = new ScopeHandler(this, inModule);
  6047. const oldProdParam = this.prodParam;
  6048. this.prodParam = new ProductionParameterHandler();
  6049. const oldClassScope = this.classScope;
  6050. this.classScope = new ClassScopeHandler(this);
  6051. const oldExpressionScope = this.expressionScope;
  6052. this.expressionScope = new ExpressionScopeHandler(this);
  6053. return () => {
  6054. this.state.labels = oldLabels;
  6055. this.exportedIdentifiers = oldExportedIdentifiers;
  6056. this.inModule = oldInModule;
  6057. this.scope = oldScope;
  6058. this.prodParam = oldProdParam;
  6059. this.classScope = oldClassScope;
  6060. this.expressionScope = oldExpressionScope;
  6061. };
  6062. }
  6063. enterInitialScopes() {
  6064. let paramFlags = 0;
  6065. if (this.inModule) {
  6066. paramFlags |= 2;
  6067. }
  6068. this.scope.enter(1);
  6069. this.prodParam.enter(paramFlags);
  6070. }
  6071. checkDestructuringPrivate(refExpressionErrors) {
  6072. const {
  6073. privateKeyLoc
  6074. } = refExpressionErrors;
  6075. if (privateKeyLoc !== null) {
  6076. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  6077. }
  6078. }
  6079. }
  6080. class ExpressionErrors {
  6081. constructor() {
  6082. this.shorthandAssignLoc = null;
  6083. this.doubleProtoLoc = null;
  6084. this.privateKeyLoc = null;
  6085. this.optionalParametersLoc = null;
  6086. }
  6087. }
  6088. let Node$5 = class Node {
  6089. constructor(parser, pos, loc) {
  6090. this.type = "";
  6091. this.start = pos;
  6092. this.end = 0;
  6093. this.loc = new SourceLocation(loc);
  6094. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  6095. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  6096. }
  6097. };
  6098. const NodePrototype = Node$5.prototype;
  6099. {
  6100. NodePrototype.__clone = function () {
  6101. const newNode = new Node$5(undefined, this.start, this.loc.start);
  6102. const keys = Object.keys(this);
  6103. for (let i = 0, length = keys.length; i < length; i++) {
  6104. const key = keys[i];
  6105. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  6106. newNode[key] = this[key];
  6107. }
  6108. }
  6109. return newNode;
  6110. };
  6111. }
  6112. function clonePlaceholder(node) {
  6113. return cloneIdentifier(node);
  6114. }
  6115. function cloneIdentifier(node) {
  6116. const {
  6117. type,
  6118. start,
  6119. end,
  6120. loc,
  6121. range,
  6122. extra,
  6123. name
  6124. } = node;
  6125. const cloned = Object.create(NodePrototype);
  6126. cloned.type = type;
  6127. cloned.start = start;
  6128. cloned.end = end;
  6129. cloned.loc = loc;
  6130. cloned.range = range;
  6131. cloned.extra = extra;
  6132. cloned.name = name;
  6133. if (type === "Placeholder") {
  6134. cloned.expectedNode = node.expectedNode;
  6135. }
  6136. return cloned;
  6137. }
  6138. function cloneStringLiteral(node) {
  6139. const {
  6140. type,
  6141. start,
  6142. end,
  6143. loc,
  6144. range,
  6145. extra
  6146. } = node;
  6147. if (type === "Placeholder") {
  6148. return clonePlaceholder(node);
  6149. }
  6150. const cloned = Object.create(NodePrototype);
  6151. cloned.type = type;
  6152. cloned.start = start;
  6153. cloned.end = end;
  6154. cloned.loc = loc;
  6155. cloned.range = range;
  6156. if (node.raw !== undefined) {
  6157. cloned.raw = node.raw;
  6158. } else {
  6159. cloned.extra = extra;
  6160. }
  6161. cloned.value = node.value;
  6162. return cloned;
  6163. }
  6164. class NodeUtils extends UtilParser {
  6165. startNode() {
  6166. const loc = this.state.startLoc;
  6167. return new Node$5(this, loc.index, loc);
  6168. }
  6169. startNodeAt(loc) {
  6170. return new Node$5(this, loc.index, loc);
  6171. }
  6172. startNodeAtNode(type) {
  6173. return this.startNodeAt(type.loc.start);
  6174. }
  6175. finishNode(node, type) {
  6176. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  6177. }
  6178. finishNodeAt(node, type, endLoc) {
  6179. node.type = type;
  6180. node.end = endLoc.index;
  6181. node.loc.end = endLoc;
  6182. if (this.options.ranges) node.range[1] = endLoc.index;
  6183. if (this.options.attachComment) this.processComment(node);
  6184. return node;
  6185. }
  6186. resetStartLocation(node, startLoc) {
  6187. node.start = startLoc.index;
  6188. node.loc.start = startLoc;
  6189. if (this.options.ranges) node.range[0] = startLoc.index;
  6190. }
  6191. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  6192. node.end = endLoc.index;
  6193. node.loc.end = endLoc;
  6194. if (this.options.ranges) node.range[1] = endLoc.index;
  6195. }
  6196. resetStartLocationFromNode(node, locationNode) {
  6197. this.resetStartLocation(node, locationNode.loc.start);
  6198. }
  6199. }
  6200. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  6201. const FlowErrors = ParseErrorEnum`flow`({
  6202. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  6203. 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.",
  6204. AssignReservedType: ({
  6205. reservedType
  6206. }) => `Cannot overwrite reserved type ${reservedType}.`,
  6207. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  6208. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  6209. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  6210. EnumBooleanMemberNotInitialized: ({
  6211. memberName,
  6212. enumName
  6213. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  6214. EnumDuplicateMemberName: ({
  6215. memberName,
  6216. enumName
  6217. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  6218. EnumInconsistentMemberValues: ({
  6219. enumName
  6220. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  6221. EnumInvalidExplicitType: ({
  6222. invalidEnumType,
  6223. enumName
  6224. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6225. EnumInvalidExplicitTypeUnknownSupplied: ({
  6226. enumName
  6227. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6228. EnumInvalidMemberInitializerPrimaryType: ({
  6229. enumName,
  6230. memberName,
  6231. explicitType
  6232. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  6233. EnumInvalidMemberInitializerSymbolType: ({
  6234. enumName,
  6235. memberName
  6236. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  6237. EnumInvalidMemberInitializerUnknownType: ({
  6238. enumName,
  6239. memberName
  6240. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  6241. EnumInvalidMemberName: ({
  6242. enumName,
  6243. memberName,
  6244. suggestion
  6245. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  6246. EnumNumberMemberNotInitialized: ({
  6247. enumName,
  6248. memberName
  6249. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  6250. EnumStringMemberInconsistentlyInitialized: ({
  6251. enumName
  6252. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  6253. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  6254. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  6255. 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.",
  6256. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  6257. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  6258. InexactVariance: "Explicit inexact syntax cannot have variance.",
  6259. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  6260. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  6261. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  6262. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  6263. PatternIsOptional: Object.assign({
  6264. message: "A binding pattern parameter cannot be optional in an implementation signature."
  6265. }, {
  6266. reasonCode: "OptionalBindingPattern"
  6267. }),
  6268. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  6269. SpreadVariance: "Spread properties cannot have variance.",
  6270. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  6271. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  6272. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  6273. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  6274. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  6275. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  6276. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  6277. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  6278. UnexpectedReservedType: ({
  6279. reservedType
  6280. }) => `Unexpected reserved type ${reservedType}.`,
  6281. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  6282. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  6283. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  6284. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  6285. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  6286. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  6287. UnsupportedDeclareExportKind: ({
  6288. unsupportedExportKind,
  6289. suggestion
  6290. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  6291. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  6292. UnterminatedFlowComment: "Unterminated flow-comment."
  6293. });
  6294. function isEsModuleType(bodyElement) {
  6295. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  6296. }
  6297. function hasTypeImportKind(node) {
  6298. return node.importKind === "type" || node.importKind === "typeof";
  6299. }
  6300. const exportSuggestions = {
  6301. const: "declare export var",
  6302. let: "declare export var",
  6303. type: "export type",
  6304. interface: "export interface"
  6305. };
  6306. function partition(list, test) {
  6307. const list1 = [];
  6308. const list2 = [];
  6309. for (let i = 0; i < list.length; i++) {
  6310. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  6311. }
  6312. return [list1, list2];
  6313. }
  6314. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  6315. var flow = superClass => class FlowParserMixin extends superClass {
  6316. constructor(...args) {
  6317. super(...args);
  6318. this.flowPragma = undefined;
  6319. }
  6320. getScopeHandler() {
  6321. return FlowScopeHandler;
  6322. }
  6323. shouldParseTypes() {
  6324. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  6325. }
  6326. shouldParseEnums() {
  6327. return !!this.getPluginOption("flow", "enums");
  6328. }
  6329. finishToken(type, val) {
  6330. if (type !== 133 && type !== 13 && type !== 28) {
  6331. if (this.flowPragma === undefined) {
  6332. this.flowPragma = null;
  6333. }
  6334. }
  6335. super.finishToken(type, val);
  6336. }
  6337. addComment(comment) {
  6338. if (this.flowPragma === undefined) {
  6339. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  6340. if (!matches) ;else if (matches[1] === "flow") {
  6341. this.flowPragma = "flow";
  6342. } else if (matches[1] === "noflow") {
  6343. this.flowPragma = "noflow";
  6344. } else {
  6345. throw new Error("Unexpected flow pragma");
  6346. }
  6347. }
  6348. super.addComment(comment);
  6349. }
  6350. flowParseTypeInitialiser(tok) {
  6351. const oldInType = this.state.inType;
  6352. this.state.inType = true;
  6353. this.expect(tok || 14);
  6354. const type = this.flowParseType();
  6355. this.state.inType = oldInType;
  6356. return type;
  6357. }
  6358. flowParsePredicate() {
  6359. const node = this.startNode();
  6360. const moduloLoc = this.state.startLoc;
  6361. this.next();
  6362. this.expectContextual(110);
  6363. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  6364. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  6365. }
  6366. if (this.eat(10)) {
  6367. node.value = super.parseExpression();
  6368. this.expect(11);
  6369. return this.finishNode(node, "DeclaredPredicate");
  6370. } else {
  6371. return this.finishNode(node, "InferredPredicate");
  6372. }
  6373. }
  6374. flowParseTypeAndPredicateInitialiser() {
  6375. const oldInType = this.state.inType;
  6376. this.state.inType = true;
  6377. this.expect(14);
  6378. let type = null;
  6379. let predicate = null;
  6380. if (this.match(54)) {
  6381. this.state.inType = oldInType;
  6382. predicate = this.flowParsePredicate();
  6383. } else {
  6384. type = this.flowParseType();
  6385. this.state.inType = oldInType;
  6386. if (this.match(54)) {
  6387. predicate = this.flowParsePredicate();
  6388. }
  6389. }
  6390. return [type, predicate];
  6391. }
  6392. flowParseDeclareClass(node) {
  6393. this.next();
  6394. this.flowParseInterfaceish(node, true);
  6395. return this.finishNode(node, "DeclareClass");
  6396. }
  6397. flowParseDeclareFunction(node) {
  6398. this.next();
  6399. const id = node.id = this.parseIdentifier();
  6400. const typeNode = this.startNode();
  6401. const typeContainer = this.startNode();
  6402. if (this.match(47)) {
  6403. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  6404. } else {
  6405. typeNode.typeParameters = null;
  6406. }
  6407. this.expect(10);
  6408. const tmp = this.flowParseFunctionTypeParams();
  6409. typeNode.params = tmp.params;
  6410. typeNode.rest = tmp.rest;
  6411. typeNode.this = tmp._this;
  6412. this.expect(11);
  6413. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6414. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  6415. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  6416. this.resetEndLocation(id);
  6417. this.semicolon();
  6418. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  6419. return this.finishNode(node, "DeclareFunction");
  6420. }
  6421. flowParseDeclare(node, insideModule) {
  6422. if (this.match(80)) {
  6423. return this.flowParseDeclareClass(node);
  6424. } else if (this.match(68)) {
  6425. return this.flowParseDeclareFunction(node);
  6426. } else if (this.match(74)) {
  6427. return this.flowParseDeclareVariable(node);
  6428. } else if (this.eatContextual(127)) {
  6429. if (this.match(16)) {
  6430. return this.flowParseDeclareModuleExports(node);
  6431. } else {
  6432. if (insideModule) {
  6433. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  6434. }
  6435. return this.flowParseDeclareModule(node);
  6436. }
  6437. } else if (this.isContextual(130)) {
  6438. return this.flowParseDeclareTypeAlias(node);
  6439. } else if (this.isContextual(131)) {
  6440. return this.flowParseDeclareOpaqueType(node);
  6441. } else if (this.isContextual(129)) {
  6442. return this.flowParseDeclareInterface(node);
  6443. } else if (this.match(82)) {
  6444. return this.flowParseDeclareExportDeclaration(node, insideModule);
  6445. } else {
  6446. this.unexpected();
  6447. }
  6448. }
  6449. flowParseDeclareVariable(node) {
  6450. this.next();
  6451. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  6452. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  6453. this.semicolon();
  6454. return this.finishNode(node, "DeclareVariable");
  6455. }
  6456. flowParseDeclareModule(node) {
  6457. this.scope.enter(0);
  6458. if (this.match(133)) {
  6459. node.id = super.parseExprAtom();
  6460. } else {
  6461. node.id = this.parseIdentifier();
  6462. }
  6463. const bodyNode = node.body = this.startNode();
  6464. const body = bodyNode.body = [];
  6465. this.expect(5);
  6466. while (!this.match(8)) {
  6467. let bodyNode = this.startNode();
  6468. if (this.match(83)) {
  6469. this.next();
  6470. if (!this.isContextual(130) && !this.match(87)) {
  6471. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  6472. }
  6473. super.parseImport(bodyNode);
  6474. } else {
  6475. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  6476. bodyNode = this.flowParseDeclare(bodyNode, true);
  6477. }
  6478. body.push(bodyNode);
  6479. }
  6480. this.scope.exit();
  6481. this.expect(8);
  6482. this.finishNode(bodyNode, "BlockStatement");
  6483. let kind = null;
  6484. let hasModuleExport = false;
  6485. body.forEach(bodyElement => {
  6486. if (isEsModuleType(bodyElement)) {
  6487. if (kind === "CommonJS") {
  6488. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6489. }
  6490. kind = "ES";
  6491. } else if (bodyElement.type === "DeclareModuleExports") {
  6492. if (hasModuleExport) {
  6493. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  6494. }
  6495. if (kind === "ES") {
  6496. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6497. }
  6498. kind = "CommonJS";
  6499. hasModuleExport = true;
  6500. }
  6501. });
  6502. node.kind = kind || "CommonJS";
  6503. return this.finishNode(node, "DeclareModule");
  6504. }
  6505. flowParseDeclareExportDeclaration(node, insideModule) {
  6506. this.expect(82);
  6507. if (this.eat(65)) {
  6508. if (this.match(68) || this.match(80)) {
  6509. node.declaration = this.flowParseDeclare(this.startNode());
  6510. } else {
  6511. node.declaration = this.flowParseType();
  6512. this.semicolon();
  6513. }
  6514. node.default = true;
  6515. return this.finishNode(node, "DeclareExportDeclaration");
  6516. } else {
  6517. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  6518. const label = this.state.value;
  6519. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  6520. unsupportedExportKind: label,
  6521. suggestion: exportSuggestions[label]
  6522. });
  6523. }
  6524. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  6525. node.declaration = this.flowParseDeclare(this.startNode());
  6526. node.default = false;
  6527. return this.finishNode(node, "DeclareExportDeclaration");
  6528. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  6529. node = this.parseExport(node, null);
  6530. if (node.type === "ExportNamedDeclaration") {
  6531. node.type = "ExportDeclaration";
  6532. node.default = false;
  6533. delete node.exportKind;
  6534. }
  6535. node.type = "Declare" + node.type;
  6536. return node;
  6537. }
  6538. }
  6539. this.unexpected();
  6540. }
  6541. flowParseDeclareModuleExports(node) {
  6542. this.next();
  6543. this.expectContextual(111);
  6544. node.typeAnnotation = this.flowParseTypeAnnotation();
  6545. this.semicolon();
  6546. return this.finishNode(node, "DeclareModuleExports");
  6547. }
  6548. flowParseDeclareTypeAlias(node) {
  6549. this.next();
  6550. const finished = this.flowParseTypeAlias(node);
  6551. finished.type = "DeclareTypeAlias";
  6552. return finished;
  6553. }
  6554. flowParseDeclareOpaqueType(node) {
  6555. this.next();
  6556. const finished = this.flowParseOpaqueType(node, true);
  6557. finished.type = "DeclareOpaqueType";
  6558. return finished;
  6559. }
  6560. flowParseDeclareInterface(node) {
  6561. this.next();
  6562. this.flowParseInterfaceish(node, false);
  6563. return this.finishNode(node, "DeclareInterface");
  6564. }
  6565. flowParseInterfaceish(node, isClass) {
  6566. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  6567. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  6568. if (this.match(47)) {
  6569. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6570. } else {
  6571. node.typeParameters = null;
  6572. }
  6573. node.extends = [];
  6574. if (this.eat(81)) {
  6575. do {
  6576. node.extends.push(this.flowParseInterfaceExtends());
  6577. } while (!isClass && this.eat(12));
  6578. }
  6579. if (isClass) {
  6580. node.implements = [];
  6581. node.mixins = [];
  6582. if (this.eatContextual(117)) {
  6583. do {
  6584. node.mixins.push(this.flowParseInterfaceExtends());
  6585. } while (this.eat(12));
  6586. }
  6587. if (this.eatContextual(113)) {
  6588. do {
  6589. node.implements.push(this.flowParseInterfaceExtends());
  6590. } while (this.eat(12));
  6591. }
  6592. }
  6593. node.body = this.flowParseObjectType({
  6594. allowStatic: isClass,
  6595. allowExact: false,
  6596. allowSpread: false,
  6597. allowProto: isClass,
  6598. allowInexact: false
  6599. });
  6600. }
  6601. flowParseInterfaceExtends() {
  6602. const node = this.startNode();
  6603. node.id = this.flowParseQualifiedTypeIdentifier();
  6604. if (this.match(47)) {
  6605. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6606. } else {
  6607. node.typeParameters = null;
  6608. }
  6609. return this.finishNode(node, "InterfaceExtends");
  6610. }
  6611. flowParseInterface(node) {
  6612. this.flowParseInterfaceish(node, false);
  6613. return this.finishNode(node, "InterfaceDeclaration");
  6614. }
  6615. checkNotUnderscore(word) {
  6616. if (word === "_") {
  6617. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  6618. }
  6619. }
  6620. checkReservedType(word, startLoc, declaration) {
  6621. if (!reservedTypes.has(word)) return;
  6622. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  6623. reservedType: word
  6624. });
  6625. }
  6626. flowParseRestrictedIdentifier(liberal, declaration) {
  6627. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  6628. return this.parseIdentifier(liberal);
  6629. }
  6630. flowParseTypeAlias(node) {
  6631. node.id = this.flowParseRestrictedIdentifier(false, true);
  6632. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6633. if (this.match(47)) {
  6634. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6635. } else {
  6636. node.typeParameters = null;
  6637. }
  6638. node.right = this.flowParseTypeInitialiser(29);
  6639. this.semicolon();
  6640. return this.finishNode(node, "TypeAlias");
  6641. }
  6642. flowParseOpaqueType(node, declare) {
  6643. this.expectContextual(130);
  6644. node.id = this.flowParseRestrictedIdentifier(true, true);
  6645. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6646. if (this.match(47)) {
  6647. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6648. } else {
  6649. node.typeParameters = null;
  6650. }
  6651. node.supertype = null;
  6652. if (this.match(14)) {
  6653. node.supertype = this.flowParseTypeInitialiser(14);
  6654. }
  6655. node.impltype = null;
  6656. if (!declare) {
  6657. node.impltype = this.flowParseTypeInitialiser(29);
  6658. }
  6659. this.semicolon();
  6660. return this.finishNode(node, "OpaqueType");
  6661. }
  6662. flowParseTypeParameter(requireDefault = false) {
  6663. const nodeStartLoc = this.state.startLoc;
  6664. const node = this.startNode();
  6665. const variance = this.flowParseVariance();
  6666. const ident = this.flowParseTypeAnnotatableIdentifier();
  6667. node.name = ident.name;
  6668. node.variance = variance;
  6669. node.bound = ident.typeAnnotation;
  6670. if (this.match(29)) {
  6671. this.eat(29);
  6672. node.default = this.flowParseType();
  6673. } else {
  6674. if (requireDefault) {
  6675. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  6676. }
  6677. }
  6678. return this.finishNode(node, "TypeParameter");
  6679. }
  6680. flowParseTypeParameterDeclaration() {
  6681. const oldInType = this.state.inType;
  6682. const node = this.startNode();
  6683. node.params = [];
  6684. this.state.inType = true;
  6685. if (this.match(47) || this.match(142)) {
  6686. this.next();
  6687. } else {
  6688. this.unexpected();
  6689. }
  6690. let defaultRequired = false;
  6691. do {
  6692. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  6693. node.params.push(typeParameter);
  6694. if (typeParameter.default) {
  6695. defaultRequired = true;
  6696. }
  6697. if (!this.match(48)) {
  6698. this.expect(12);
  6699. }
  6700. } while (!this.match(48));
  6701. this.expect(48);
  6702. this.state.inType = oldInType;
  6703. return this.finishNode(node, "TypeParameterDeclaration");
  6704. }
  6705. flowParseTypeParameterInstantiation() {
  6706. const node = this.startNode();
  6707. const oldInType = this.state.inType;
  6708. node.params = [];
  6709. this.state.inType = true;
  6710. this.expect(47);
  6711. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6712. this.state.noAnonFunctionType = false;
  6713. while (!this.match(48)) {
  6714. node.params.push(this.flowParseType());
  6715. if (!this.match(48)) {
  6716. this.expect(12);
  6717. }
  6718. }
  6719. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6720. this.expect(48);
  6721. this.state.inType = oldInType;
  6722. return this.finishNode(node, "TypeParameterInstantiation");
  6723. }
  6724. flowParseTypeParameterInstantiationCallOrNew() {
  6725. const node = this.startNode();
  6726. const oldInType = this.state.inType;
  6727. node.params = [];
  6728. this.state.inType = true;
  6729. this.expect(47);
  6730. while (!this.match(48)) {
  6731. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  6732. if (!this.match(48)) {
  6733. this.expect(12);
  6734. }
  6735. }
  6736. this.expect(48);
  6737. this.state.inType = oldInType;
  6738. return this.finishNode(node, "TypeParameterInstantiation");
  6739. }
  6740. flowParseInterfaceType() {
  6741. const node = this.startNode();
  6742. this.expectContextual(129);
  6743. node.extends = [];
  6744. if (this.eat(81)) {
  6745. do {
  6746. node.extends.push(this.flowParseInterfaceExtends());
  6747. } while (this.eat(12));
  6748. }
  6749. node.body = this.flowParseObjectType({
  6750. allowStatic: false,
  6751. allowExact: false,
  6752. allowSpread: false,
  6753. allowProto: false,
  6754. allowInexact: false
  6755. });
  6756. return this.finishNode(node, "InterfaceTypeAnnotation");
  6757. }
  6758. flowParseObjectPropertyKey() {
  6759. return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
  6760. }
  6761. flowParseObjectTypeIndexer(node, isStatic, variance) {
  6762. node.static = isStatic;
  6763. if (this.lookahead().type === 14) {
  6764. node.id = this.flowParseObjectPropertyKey();
  6765. node.key = this.flowParseTypeInitialiser();
  6766. } else {
  6767. node.id = null;
  6768. node.key = this.flowParseType();
  6769. }
  6770. this.expect(3);
  6771. node.value = this.flowParseTypeInitialiser();
  6772. node.variance = variance;
  6773. return this.finishNode(node, "ObjectTypeIndexer");
  6774. }
  6775. flowParseObjectTypeInternalSlot(node, isStatic) {
  6776. node.static = isStatic;
  6777. node.id = this.flowParseObjectPropertyKey();
  6778. this.expect(3);
  6779. this.expect(3);
  6780. if (this.match(47) || this.match(10)) {
  6781. node.method = true;
  6782. node.optional = false;
  6783. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6784. } else {
  6785. node.method = false;
  6786. if (this.eat(17)) {
  6787. node.optional = true;
  6788. }
  6789. node.value = this.flowParseTypeInitialiser();
  6790. }
  6791. return this.finishNode(node, "ObjectTypeInternalSlot");
  6792. }
  6793. flowParseObjectTypeMethodish(node) {
  6794. node.params = [];
  6795. node.rest = null;
  6796. node.typeParameters = null;
  6797. node.this = null;
  6798. if (this.match(47)) {
  6799. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6800. }
  6801. this.expect(10);
  6802. if (this.match(78)) {
  6803. node.this = this.flowParseFunctionTypeParam(true);
  6804. node.this.name = null;
  6805. if (!this.match(11)) {
  6806. this.expect(12);
  6807. }
  6808. }
  6809. while (!this.match(11) && !this.match(21)) {
  6810. node.params.push(this.flowParseFunctionTypeParam(false));
  6811. if (!this.match(11)) {
  6812. this.expect(12);
  6813. }
  6814. }
  6815. if (this.eat(21)) {
  6816. node.rest = this.flowParseFunctionTypeParam(false);
  6817. }
  6818. this.expect(11);
  6819. node.returnType = this.flowParseTypeInitialiser();
  6820. return this.finishNode(node, "FunctionTypeAnnotation");
  6821. }
  6822. flowParseObjectTypeCallProperty(node, isStatic) {
  6823. const valueNode = this.startNode();
  6824. node.static = isStatic;
  6825. node.value = this.flowParseObjectTypeMethodish(valueNode);
  6826. return this.finishNode(node, "ObjectTypeCallProperty");
  6827. }
  6828. flowParseObjectType({
  6829. allowStatic,
  6830. allowExact,
  6831. allowSpread,
  6832. allowProto,
  6833. allowInexact
  6834. }) {
  6835. const oldInType = this.state.inType;
  6836. this.state.inType = true;
  6837. const nodeStart = this.startNode();
  6838. nodeStart.callProperties = [];
  6839. nodeStart.properties = [];
  6840. nodeStart.indexers = [];
  6841. nodeStart.internalSlots = [];
  6842. let endDelim;
  6843. let exact;
  6844. let inexact = false;
  6845. if (allowExact && this.match(6)) {
  6846. this.expect(6);
  6847. endDelim = 9;
  6848. exact = true;
  6849. } else {
  6850. this.expect(5);
  6851. endDelim = 8;
  6852. exact = false;
  6853. }
  6854. nodeStart.exact = exact;
  6855. while (!this.match(endDelim)) {
  6856. let isStatic = false;
  6857. let protoStartLoc = null;
  6858. let inexactStartLoc = null;
  6859. const node = this.startNode();
  6860. if (allowProto && this.isContextual(118)) {
  6861. const lookahead = this.lookahead();
  6862. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6863. this.next();
  6864. protoStartLoc = this.state.startLoc;
  6865. allowStatic = false;
  6866. }
  6867. }
  6868. if (allowStatic && this.isContextual(106)) {
  6869. const lookahead = this.lookahead();
  6870. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6871. this.next();
  6872. isStatic = true;
  6873. }
  6874. }
  6875. const variance = this.flowParseVariance();
  6876. if (this.eat(0)) {
  6877. if (protoStartLoc != null) {
  6878. this.unexpected(protoStartLoc);
  6879. }
  6880. if (this.eat(0)) {
  6881. if (variance) {
  6882. this.unexpected(variance.loc.start);
  6883. }
  6884. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  6885. } else {
  6886. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  6887. }
  6888. } else if (this.match(10) || this.match(47)) {
  6889. if (protoStartLoc != null) {
  6890. this.unexpected(protoStartLoc);
  6891. }
  6892. if (variance) {
  6893. this.unexpected(variance.loc.start);
  6894. }
  6895. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  6896. } else {
  6897. let kind = "init";
  6898. if (this.isContextual(99) || this.isContextual(104)) {
  6899. const lookahead = this.lookahead();
  6900. if (tokenIsLiteralPropertyName(lookahead.type)) {
  6901. kind = this.state.value;
  6902. this.next();
  6903. }
  6904. }
  6905. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  6906. if (propOrInexact === null) {
  6907. inexact = true;
  6908. inexactStartLoc = this.state.lastTokStartLoc;
  6909. } else {
  6910. nodeStart.properties.push(propOrInexact);
  6911. }
  6912. }
  6913. this.flowObjectTypeSemicolon();
  6914. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  6915. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  6916. }
  6917. }
  6918. this.expect(endDelim);
  6919. if (allowSpread) {
  6920. nodeStart.inexact = inexact;
  6921. }
  6922. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  6923. this.state.inType = oldInType;
  6924. return out;
  6925. }
  6926. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  6927. if (this.eat(21)) {
  6928. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  6929. if (isInexactToken) {
  6930. if (!allowSpread) {
  6931. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  6932. } else if (!allowInexact) {
  6933. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  6934. }
  6935. if (variance) {
  6936. this.raise(FlowErrors.InexactVariance, variance);
  6937. }
  6938. return null;
  6939. }
  6940. if (!allowSpread) {
  6941. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  6942. }
  6943. if (protoStartLoc != null) {
  6944. this.unexpected(protoStartLoc);
  6945. }
  6946. if (variance) {
  6947. this.raise(FlowErrors.SpreadVariance, variance);
  6948. }
  6949. node.argument = this.flowParseType();
  6950. return this.finishNode(node, "ObjectTypeSpreadProperty");
  6951. } else {
  6952. node.key = this.flowParseObjectPropertyKey();
  6953. node.static = isStatic;
  6954. node.proto = protoStartLoc != null;
  6955. node.kind = kind;
  6956. let optional = false;
  6957. if (this.match(47) || this.match(10)) {
  6958. node.method = true;
  6959. if (protoStartLoc != null) {
  6960. this.unexpected(protoStartLoc);
  6961. }
  6962. if (variance) {
  6963. this.unexpected(variance.loc.start);
  6964. }
  6965. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6966. if (kind === "get" || kind === "set") {
  6967. this.flowCheckGetterSetterParams(node);
  6968. }
  6969. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  6970. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  6971. }
  6972. } else {
  6973. if (kind !== "init") this.unexpected();
  6974. node.method = false;
  6975. if (this.eat(17)) {
  6976. optional = true;
  6977. }
  6978. node.value = this.flowParseTypeInitialiser();
  6979. node.variance = variance;
  6980. }
  6981. node.optional = optional;
  6982. return this.finishNode(node, "ObjectTypeProperty");
  6983. }
  6984. }
  6985. flowCheckGetterSetterParams(property) {
  6986. const paramCount = property.kind === "get" ? 0 : 1;
  6987. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  6988. if (property.value.this) {
  6989. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  6990. }
  6991. if (length !== paramCount) {
  6992. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  6993. }
  6994. if (property.kind === "set" && property.value.rest) {
  6995. this.raise(Errors.BadSetterRestParameter, property);
  6996. }
  6997. }
  6998. flowObjectTypeSemicolon() {
  6999. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  7000. this.unexpected();
  7001. }
  7002. }
  7003. flowParseQualifiedTypeIdentifier(startLoc, id) {
  7004. var _startLoc;
  7005. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  7006. let node = id || this.flowParseRestrictedIdentifier(true);
  7007. while (this.eat(16)) {
  7008. const node2 = this.startNodeAt(startLoc);
  7009. node2.qualification = node;
  7010. node2.id = this.flowParseRestrictedIdentifier(true);
  7011. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  7012. }
  7013. return node;
  7014. }
  7015. flowParseGenericType(startLoc, id) {
  7016. const node = this.startNodeAt(startLoc);
  7017. node.typeParameters = null;
  7018. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  7019. if (this.match(47)) {
  7020. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7021. }
  7022. return this.finishNode(node, "GenericTypeAnnotation");
  7023. }
  7024. flowParseTypeofType() {
  7025. const node = this.startNode();
  7026. this.expect(87);
  7027. node.argument = this.flowParsePrimaryType();
  7028. return this.finishNode(node, "TypeofTypeAnnotation");
  7029. }
  7030. flowParseTupleType() {
  7031. const node = this.startNode();
  7032. node.types = [];
  7033. this.expect(0);
  7034. while (this.state.pos < this.length && !this.match(3)) {
  7035. node.types.push(this.flowParseType());
  7036. if (this.match(3)) break;
  7037. this.expect(12);
  7038. }
  7039. this.expect(3);
  7040. return this.finishNode(node, "TupleTypeAnnotation");
  7041. }
  7042. flowParseFunctionTypeParam(first) {
  7043. let name = null;
  7044. let optional = false;
  7045. let typeAnnotation = null;
  7046. const node = this.startNode();
  7047. const lh = this.lookahead();
  7048. const isThis = this.state.type === 78;
  7049. if (lh.type === 14 || lh.type === 17) {
  7050. if (isThis && !first) {
  7051. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  7052. }
  7053. name = this.parseIdentifier(isThis);
  7054. if (this.eat(17)) {
  7055. optional = true;
  7056. if (isThis) {
  7057. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  7058. }
  7059. }
  7060. typeAnnotation = this.flowParseTypeInitialiser();
  7061. } else {
  7062. typeAnnotation = this.flowParseType();
  7063. }
  7064. node.name = name;
  7065. node.optional = optional;
  7066. node.typeAnnotation = typeAnnotation;
  7067. return this.finishNode(node, "FunctionTypeParam");
  7068. }
  7069. reinterpretTypeAsFunctionTypeParam(type) {
  7070. const node = this.startNodeAt(type.loc.start);
  7071. node.name = null;
  7072. node.optional = false;
  7073. node.typeAnnotation = type;
  7074. return this.finishNode(node, "FunctionTypeParam");
  7075. }
  7076. flowParseFunctionTypeParams(params = []) {
  7077. let rest = null;
  7078. let _this = null;
  7079. if (this.match(78)) {
  7080. _this = this.flowParseFunctionTypeParam(true);
  7081. _this.name = null;
  7082. if (!this.match(11)) {
  7083. this.expect(12);
  7084. }
  7085. }
  7086. while (!this.match(11) && !this.match(21)) {
  7087. params.push(this.flowParseFunctionTypeParam(false));
  7088. if (!this.match(11)) {
  7089. this.expect(12);
  7090. }
  7091. }
  7092. if (this.eat(21)) {
  7093. rest = this.flowParseFunctionTypeParam(false);
  7094. }
  7095. return {
  7096. params,
  7097. rest,
  7098. _this
  7099. };
  7100. }
  7101. flowIdentToTypeAnnotation(startLoc, node, id) {
  7102. switch (id.name) {
  7103. case "any":
  7104. return this.finishNode(node, "AnyTypeAnnotation");
  7105. case "bool":
  7106. case "boolean":
  7107. return this.finishNode(node, "BooleanTypeAnnotation");
  7108. case "mixed":
  7109. return this.finishNode(node, "MixedTypeAnnotation");
  7110. case "empty":
  7111. return this.finishNode(node, "EmptyTypeAnnotation");
  7112. case "number":
  7113. return this.finishNode(node, "NumberTypeAnnotation");
  7114. case "string":
  7115. return this.finishNode(node, "StringTypeAnnotation");
  7116. case "symbol":
  7117. return this.finishNode(node, "SymbolTypeAnnotation");
  7118. default:
  7119. this.checkNotUnderscore(id.name);
  7120. return this.flowParseGenericType(startLoc, id);
  7121. }
  7122. }
  7123. flowParsePrimaryType() {
  7124. const startLoc = this.state.startLoc;
  7125. const node = this.startNode();
  7126. let tmp;
  7127. let type;
  7128. let isGroupedType = false;
  7129. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7130. switch (this.state.type) {
  7131. case 5:
  7132. return this.flowParseObjectType({
  7133. allowStatic: false,
  7134. allowExact: false,
  7135. allowSpread: true,
  7136. allowProto: false,
  7137. allowInexact: true
  7138. });
  7139. case 6:
  7140. return this.flowParseObjectType({
  7141. allowStatic: false,
  7142. allowExact: true,
  7143. allowSpread: true,
  7144. allowProto: false,
  7145. allowInexact: false
  7146. });
  7147. case 0:
  7148. this.state.noAnonFunctionType = false;
  7149. type = this.flowParseTupleType();
  7150. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7151. return type;
  7152. case 47:
  7153. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7154. this.expect(10);
  7155. tmp = this.flowParseFunctionTypeParams();
  7156. node.params = tmp.params;
  7157. node.rest = tmp.rest;
  7158. node.this = tmp._this;
  7159. this.expect(11);
  7160. this.expect(19);
  7161. node.returnType = this.flowParseType();
  7162. return this.finishNode(node, "FunctionTypeAnnotation");
  7163. case 10:
  7164. this.next();
  7165. if (!this.match(11) && !this.match(21)) {
  7166. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  7167. const token = this.lookahead().type;
  7168. isGroupedType = token !== 17 && token !== 14;
  7169. } else {
  7170. isGroupedType = true;
  7171. }
  7172. }
  7173. if (isGroupedType) {
  7174. this.state.noAnonFunctionType = false;
  7175. type = this.flowParseType();
  7176. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7177. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  7178. this.expect(11);
  7179. return type;
  7180. } else {
  7181. this.eat(12);
  7182. }
  7183. }
  7184. if (type) {
  7185. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  7186. } else {
  7187. tmp = this.flowParseFunctionTypeParams();
  7188. }
  7189. node.params = tmp.params;
  7190. node.rest = tmp.rest;
  7191. node.this = tmp._this;
  7192. this.expect(11);
  7193. this.expect(19);
  7194. node.returnType = this.flowParseType();
  7195. node.typeParameters = null;
  7196. return this.finishNode(node, "FunctionTypeAnnotation");
  7197. case 133:
  7198. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  7199. case 85:
  7200. case 86:
  7201. node.value = this.match(85);
  7202. this.next();
  7203. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  7204. case 53:
  7205. if (this.state.value === "-") {
  7206. this.next();
  7207. if (this.match(134)) {
  7208. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  7209. }
  7210. if (this.match(135)) {
  7211. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  7212. }
  7213. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  7214. }
  7215. this.unexpected();
  7216. return;
  7217. case 134:
  7218. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  7219. case 135:
  7220. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  7221. case 88:
  7222. this.next();
  7223. return this.finishNode(node, "VoidTypeAnnotation");
  7224. case 84:
  7225. this.next();
  7226. return this.finishNode(node, "NullLiteralTypeAnnotation");
  7227. case 78:
  7228. this.next();
  7229. return this.finishNode(node, "ThisTypeAnnotation");
  7230. case 55:
  7231. this.next();
  7232. return this.finishNode(node, "ExistsTypeAnnotation");
  7233. case 87:
  7234. return this.flowParseTypeofType();
  7235. default:
  7236. if (tokenIsKeyword(this.state.type)) {
  7237. const label = tokenLabelName(this.state.type);
  7238. this.next();
  7239. return super.createIdentifier(node, label);
  7240. } else if (tokenIsIdentifier(this.state.type)) {
  7241. if (this.isContextual(129)) {
  7242. return this.flowParseInterfaceType();
  7243. }
  7244. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  7245. }
  7246. }
  7247. this.unexpected();
  7248. }
  7249. flowParsePostfixType() {
  7250. const startLoc = this.state.startLoc;
  7251. let type = this.flowParsePrimaryType();
  7252. let seenOptionalIndexedAccess = false;
  7253. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  7254. const node = this.startNodeAt(startLoc);
  7255. const optional = this.eat(18);
  7256. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  7257. this.expect(0);
  7258. if (!optional && this.match(3)) {
  7259. node.elementType = type;
  7260. this.next();
  7261. type = this.finishNode(node, "ArrayTypeAnnotation");
  7262. } else {
  7263. node.objectType = type;
  7264. node.indexType = this.flowParseType();
  7265. this.expect(3);
  7266. if (seenOptionalIndexedAccess) {
  7267. node.optional = optional;
  7268. type = this.finishNode(node, "OptionalIndexedAccessType");
  7269. } else {
  7270. type = this.finishNode(node, "IndexedAccessType");
  7271. }
  7272. }
  7273. }
  7274. return type;
  7275. }
  7276. flowParsePrefixType() {
  7277. const node = this.startNode();
  7278. if (this.eat(17)) {
  7279. node.typeAnnotation = this.flowParsePrefixType();
  7280. return this.finishNode(node, "NullableTypeAnnotation");
  7281. } else {
  7282. return this.flowParsePostfixType();
  7283. }
  7284. }
  7285. flowParseAnonFunctionWithoutParens() {
  7286. const param = this.flowParsePrefixType();
  7287. if (!this.state.noAnonFunctionType && this.eat(19)) {
  7288. const node = this.startNodeAt(param.loc.start);
  7289. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  7290. node.rest = null;
  7291. node.this = null;
  7292. node.returnType = this.flowParseType();
  7293. node.typeParameters = null;
  7294. return this.finishNode(node, "FunctionTypeAnnotation");
  7295. }
  7296. return param;
  7297. }
  7298. flowParseIntersectionType() {
  7299. const node = this.startNode();
  7300. this.eat(45);
  7301. const type = this.flowParseAnonFunctionWithoutParens();
  7302. node.types = [type];
  7303. while (this.eat(45)) {
  7304. node.types.push(this.flowParseAnonFunctionWithoutParens());
  7305. }
  7306. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  7307. }
  7308. flowParseUnionType() {
  7309. const node = this.startNode();
  7310. this.eat(43);
  7311. const type = this.flowParseIntersectionType();
  7312. node.types = [type];
  7313. while (this.eat(43)) {
  7314. node.types.push(this.flowParseIntersectionType());
  7315. }
  7316. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  7317. }
  7318. flowParseType() {
  7319. const oldInType = this.state.inType;
  7320. this.state.inType = true;
  7321. const type = this.flowParseUnionType();
  7322. this.state.inType = oldInType;
  7323. return type;
  7324. }
  7325. flowParseTypeOrImplicitInstantiation() {
  7326. if (this.state.type === 132 && this.state.value === "_") {
  7327. const startLoc = this.state.startLoc;
  7328. const node = this.parseIdentifier();
  7329. return this.flowParseGenericType(startLoc, node);
  7330. } else {
  7331. return this.flowParseType();
  7332. }
  7333. }
  7334. flowParseTypeAnnotation() {
  7335. const node = this.startNode();
  7336. node.typeAnnotation = this.flowParseTypeInitialiser();
  7337. return this.finishNode(node, "TypeAnnotation");
  7338. }
  7339. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  7340. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  7341. if (this.match(14)) {
  7342. ident.typeAnnotation = this.flowParseTypeAnnotation();
  7343. this.resetEndLocation(ident);
  7344. }
  7345. return ident;
  7346. }
  7347. typeCastToParameter(node) {
  7348. node.expression.typeAnnotation = node.typeAnnotation;
  7349. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  7350. return node.expression;
  7351. }
  7352. flowParseVariance() {
  7353. let variance = null;
  7354. if (this.match(53)) {
  7355. variance = this.startNode();
  7356. if (this.state.value === "+") {
  7357. variance.kind = "plus";
  7358. } else {
  7359. variance.kind = "minus";
  7360. }
  7361. this.next();
  7362. return this.finishNode(variance, "Variance");
  7363. }
  7364. return variance;
  7365. }
  7366. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  7367. if (allowExpressionBody) {
  7368. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  7369. return;
  7370. }
  7371. super.parseFunctionBody(node, false, isMethod);
  7372. }
  7373. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  7374. if (this.match(14)) {
  7375. const typeNode = this.startNode();
  7376. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  7377. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  7378. }
  7379. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  7380. }
  7381. parseStatementLike(flags) {
  7382. if (this.state.strict && this.isContextual(129)) {
  7383. const lookahead = this.lookahead();
  7384. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  7385. const node = this.startNode();
  7386. this.next();
  7387. return this.flowParseInterface(node);
  7388. }
  7389. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7390. const node = this.startNode();
  7391. this.next();
  7392. return this.flowParseEnumDeclaration(node);
  7393. }
  7394. const stmt = super.parseStatementLike(flags);
  7395. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  7396. this.flowPragma = null;
  7397. }
  7398. return stmt;
  7399. }
  7400. parseExpressionStatement(node, expr, decorators) {
  7401. if (expr.type === "Identifier") {
  7402. if (expr.name === "declare") {
  7403. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  7404. return this.flowParseDeclare(node);
  7405. }
  7406. } else if (tokenIsIdentifier(this.state.type)) {
  7407. if (expr.name === "interface") {
  7408. return this.flowParseInterface(node);
  7409. } else if (expr.name === "type") {
  7410. return this.flowParseTypeAlias(node);
  7411. } else if (expr.name === "opaque") {
  7412. return this.flowParseOpaqueType(node, false);
  7413. }
  7414. }
  7415. }
  7416. return super.parseExpressionStatement(node, expr, decorators);
  7417. }
  7418. shouldParseExportDeclaration() {
  7419. const {
  7420. type
  7421. } = this.state;
  7422. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7423. return !this.state.containsEsc;
  7424. }
  7425. return super.shouldParseExportDeclaration();
  7426. }
  7427. isExportDefaultSpecifier() {
  7428. const {
  7429. type
  7430. } = this.state;
  7431. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7432. return this.state.containsEsc;
  7433. }
  7434. return super.isExportDefaultSpecifier();
  7435. }
  7436. parseExportDefaultExpression() {
  7437. if (this.shouldParseEnums() && this.isContextual(126)) {
  7438. const node = this.startNode();
  7439. this.next();
  7440. return this.flowParseEnumDeclaration(node);
  7441. }
  7442. return super.parseExportDefaultExpression();
  7443. }
  7444. parseConditional(expr, startLoc, refExpressionErrors) {
  7445. if (!this.match(17)) return expr;
  7446. if (this.state.maybeInArrowParameters) {
  7447. const nextCh = this.lookaheadCharCode();
  7448. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  7449. this.setOptionalParametersError(refExpressionErrors);
  7450. return expr;
  7451. }
  7452. }
  7453. this.expect(17);
  7454. const state = this.state.clone();
  7455. const originalNoArrowAt = this.state.noArrowAt;
  7456. const node = this.startNodeAt(startLoc);
  7457. let {
  7458. consequent,
  7459. failed
  7460. } = this.tryParseConditionalConsequent();
  7461. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7462. if (failed || invalid.length > 0) {
  7463. const noArrowAt = [...originalNoArrowAt];
  7464. if (invalid.length > 0) {
  7465. this.state = state;
  7466. this.state.noArrowAt = noArrowAt;
  7467. for (let i = 0; i < invalid.length; i++) {
  7468. noArrowAt.push(invalid[i].start);
  7469. }
  7470. ({
  7471. consequent,
  7472. failed
  7473. } = this.tryParseConditionalConsequent());
  7474. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7475. }
  7476. if (failed && valid.length > 1) {
  7477. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  7478. }
  7479. if (failed && valid.length === 1) {
  7480. this.state = state;
  7481. noArrowAt.push(valid[0].start);
  7482. this.state.noArrowAt = noArrowAt;
  7483. ({
  7484. consequent,
  7485. failed
  7486. } = this.tryParseConditionalConsequent());
  7487. }
  7488. }
  7489. this.getArrowLikeExpressions(consequent, true);
  7490. this.state.noArrowAt = originalNoArrowAt;
  7491. this.expect(14);
  7492. node.test = expr;
  7493. node.consequent = consequent;
  7494. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  7495. return this.finishNode(node, "ConditionalExpression");
  7496. }
  7497. tryParseConditionalConsequent() {
  7498. this.state.noArrowParamsConversionAt.push(this.state.start);
  7499. const consequent = this.parseMaybeAssignAllowIn();
  7500. const failed = !this.match(14);
  7501. this.state.noArrowParamsConversionAt.pop();
  7502. return {
  7503. consequent,
  7504. failed
  7505. };
  7506. }
  7507. getArrowLikeExpressions(node, disallowInvalid) {
  7508. const stack = [node];
  7509. const arrows = [];
  7510. while (stack.length !== 0) {
  7511. const node = stack.pop();
  7512. if (node.type === "ArrowFunctionExpression") {
  7513. if (node.typeParameters || !node.returnType) {
  7514. this.finishArrowValidation(node);
  7515. } else {
  7516. arrows.push(node);
  7517. }
  7518. stack.push(node.body);
  7519. } else if (node.type === "ConditionalExpression") {
  7520. stack.push(node.consequent);
  7521. stack.push(node.alternate);
  7522. }
  7523. }
  7524. if (disallowInvalid) {
  7525. arrows.forEach(node => this.finishArrowValidation(node));
  7526. return [arrows, []];
  7527. }
  7528. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  7529. }
  7530. finishArrowValidation(node) {
  7531. var _node$extra;
  7532. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  7533. this.scope.enter(2 | 4);
  7534. super.checkParams(node, false, true);
  7535. this.scope.exit();
  7536. }
  7537. forwardNoArrowParamsConversionAt(node, parse) {
  7538. let result;
  7539. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  7540. this.state.noArrowParamsConversionAt.push(this.state.start);
  7541. result = parse();
  7542. this.state.noArrowParamsConversionAt.pop();
  7543. } else {
  7544. result = parse();
  7545. }
  7546. return result;
  7547. }
  7548. parseParenItem(node, startLoc) {
  7549. node = super.parseParenItem(node, startLoc);
  7550. if (this.eat(17)) {
  7551. node.optional = true;
  7552. this.resetEndLocation(node);
  7553. }
  7554. if (this.match(14)) {
  7555. const typeCastNode = this.startNodeAt(startLoc);
  7556. typeCastNode.expression = node;
  7557. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  7558. return this.finishNode(typeCastNode, "TypeCastExpression");
  7559. }
  7560. return node;
  7561. }
  7562. assertModuleNodeAllowed(node) {
  7563. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  7564. return;
  7565. }
  7566. super.assertModuleNodeAllowed(node);
  7567. }
  7568. parseExportDeclaration(node) {
  7569. if (this.isContextual(130)) {
  7570. node.exportKind = "type";
  7571. const declarationNode = this.startNode();
  7572. this.next();
  7573. if (this.match(5)) {
  7574. node.specifiers = this.parseExportSpecifiers(true);
  7575. super.parseExportFrom(node);
  7576. return null;
  7577. } else {
  7578. return this.flowParseTypeAlias(declarationNode);
  7579. }
  7580. } else if (this.isContextual(131)) {
  7581. node.exportKind = "type";
  7582. const declarationNode = this.startNode();
  7583. this.next();
  7584. return this.flowParseOpaqueType(declarationNode, false);
  7585. } else if (this.isContextual(129)) {
  7586. node.exportKind = "type";
  7587. const declarationNode = this.startNode();
  7588. this.next();
  7589. return this.flowParseInterface(declarationNode);
  7590. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7591. node.exportKind = "value";
  7592. const declarationNode = this.startNode();
  7593. this.next();
  7594. return this.flowParseEnumDeclaration(declarationNode);
  7595. } else {
  7596. return super.parseExportDeclaration(node);
  7597. }
  7598. }
  7599. eatExportStar(node) {
  7600. if (super.eatExportStar(node)) return true;
  7601. if (this.isContextual(130) && this.lookahead().type === 55) {
  7602. node.exportKind = "type";
  7603. this.next();
  7604. this.next();
  7605. return true;
  7606. }
  7607. return false;
  7608. }
  7609. maybeParseExportNamespaceSpecifier(node) {
  7610. const {
  7611. startLoc
  7612. } = this.state;
  7613. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  7614. if (hasNamespace && node.exportKind === "type") {
  7615. this.unexpected(startLoc);
  7616. }
  7617. return hasNamespace;
  7618. }
  7619. parseClassId(node, isStatement, optionalId) {
  7620. super.parseClassId(node, isStatement, optionalId);
  7621. if (this.match(47)) {
  7622. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7623. }
  7624. }
  7625. parseClassMember(classBody, member, state) {
  7626. const {
  7627. startLoc
  7628. } = this.state;
  7629. if (this.isContextual(125)) {
  7630. if (super.parseClassMemberFromModifier(classBody, member)) {
  7631. return;
  7632. }
  7633. member.declare = true;
  7634. }
  7635. super.parseClassMember(classBody, member, state);
  7636. if (member.declare) {
  7637. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  7638. this.raise(FlowErrors.DeclareClassElement, startLoc);
  7639. } else if (member.value) {
  7640. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  7641. }
  7642. }
  7643. }
  7644. isIterator(word) {
  7645. return word === "iterator" || word === "asyncIterator";
  7646. }
  7647. readIterator() {
  7648. const word = super.readWord1();
  7649. const fullWord = "@@" + word;
  7650. if (!this.isIterator(word) || !this.state.inType) {
  7651. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  7652. identifierName: fullWord
  7653. });
  7654. }
  7655. this.finishToken(132, fullWord);
  7656. }
  7657. getTokenFromCode(code) {
  7658. const next = this.input.charCodeAt(this.state.pos + 1);
  7659. if (code === 123 && next === 124) {
  7660. this.finishOp(6, 2);
  7661. } else if (this.state.inType && (code === 62 || code === 60)) {
  7662. this.finishOp(code === 62 ? 48 : 47, 1);
  7663. } else if (this.state.inType && code === 63) {
  7664. if (next === 46) {
  7665. this.finishOp(18, 2);
  7666. } else {
  7667. this.finishOp(17, 1);
  7668. }
  7669. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  7670. this.state.pos += 2;
  7671. this.readIterator();
  7672. } else {
  7673. super.getTokenFromCode(code);
  7674. }
  7675. }
  7676. isAssignable(node, isBinding) {
  7677. if (node.type === "TypeCastExpression") {
  7678. return this.isAssignable(node.expression, isBinding);
  7679. } else {
  7680. return super.isAssignable(node, isBinding);
  7681. }
  7682. }
  7683. toAssignable(node, isLHS = false) {
  7684. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  7685. node.left = this.typeCastToParameter(node.left);
  7686. }
  7687. super.toAssignable(node, isLHS);
  7688. }
  7689. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  7690. for (let i = 0; i < exprList.length; i++) {
  7691. const expr = exprList[i];
  7692. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  7693. exprList[i] = this.typeCastToParameter(expr);
  7694. }
  7695. }
  7696. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  7697. }
  7698. toReferencedList(exprList, isParenthesizedExpr) {
  7699. for (let i = 0; i < exprList.length; i++) {
  7700. var _expr$extra;
  7701. const expr = exprList[i];
  7702. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  7703. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  7704. }
  7705. }
  7706. return exprList;
  7707. }
  7708. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  7709. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  7710. if (canBePattern && !this.state.maybeInArrowParameters) {
  7711. this.toReferencedList(node.elements);
  7712. }
  7713. return node;
  7714. }
  7715. isValidLVal(type, isParenthesized, binding) {
  7716. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  7717. }
  7718. parseClassProperty(node) {
  7719. if (this.match(14)) {
  7720. node.typeAnnotation = this.flowParseTypeAnnotation();
  7721. }
  7722. return super.parseClassProperty(node);
  7723. }
  7724. parseClassPrivateProperty(node) {
  7725. if (this.match(14)) {
  7726. node.typeAnnotation = this.flowParseTypeAnnotation();
  7727. }
  7728. return super.parseClassPrivateProperty(node);
  7729. }
  7730. isClassMethod() {
  7731. return this.match(47) || super.isClassMethod();
  7732. }
  7733. isClassProperty() {
  7734. return this.match(14) || super.isClassProperty();
  7735. }
  7736. isNonstaticConstructor(method) {
  7737. return !this.match(14) && super.isNonstaticConstructor(method);
  7738. }
  7739. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  7740. if (method.variance) {
  7741. this.unexpected(method.variance.loc.start);
  7742. }
  7743. delete method.variance;
  7744. if (this.match(47)) {
  7745. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7746. }
  7747. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  7748. if (method.params && isConstructor) {
  7749. const params = method.params;
  7750. if (params.length > 0 && this.isThisParam(params[0])) {
  7751. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7752. }
  7753. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  7754. const params = method.value.params;
  7755. if (params.length > 0 && this.isThisParam(params[0])) {
  7756. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7757. }
  7758. }
  7759. }
  7760. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  7761. if (method.variance) {
  7762. this.unexpected(method.variance.loc.start);
  7763. }
  7764. delete method.variance;
  7765. if (this.match(47)) {
  7766. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7767. }
  7768. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  7769. }
  7770. parseClassSuper(node) {
  7771. super.parseClassSuper(node);
  7772. if (node.superClass && this.match(47)) {
  7773. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  7774. }
  7775. if (this.isContextual(113)) {
  7776. this.next();
  7777. const implemented = node.implements = [];
  7778. do {
  7779. const node = this.startNode();
  7780. node.id = this.flowParseRestrictedIdentifier(true);
  7781. if (this.match(47)) {
  7782. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7783. } else {
  7784. node.typeParameters = null;
  7785. }
  7786. implemented.push(this.finishNode(node, "ClassImplements"));
  7787. } while (this.eat(12));
  7788. }
  7789. }
  7790. checkGetterSetterParams(method) {
  7791. super.checkGetterSetterParams(method);
  7792. const params = this.getObjectOrClassMethodParams(method);
  7793. if (params.length > 0) {
  7794. const param = params[0];
  7795. if (this.isThisParam(param) && method.kind === "get") {
  7796. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  7797. } else if (this.isThisParam(param)) {
  7798. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  7799. }
  7800. }
  7801. }
  7802. parsePropertyNamePrefixOperator(node) {
  7803. node.variance = this.flowParseVariance();
  7804. }
  7805. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  7806. if (prop.variance) {
  7807. this.unexpected(prop.variance.loc.start);
  7808. }
  7809. delete prop.variance;
  7810. let typeParameters;
  7811. if (this.match(47) && !isAccessor) {
  7812. typeParameters = this.flowParseTypeParameterDeclaration();
  7813. if (!this.match(10)) this.unexpected();
  7814. }
  7815. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  7816. if (typeParameters) {
  7817. (result.value || result).typeParameters = typeParameters;
  7818. }
  7819. return result;
  7820. }
  7821. parseAssignableListItemTypes(param) {
  7822. if (this.eat(17)) {
  7823. if (param.type !== "Identifier") {
  7824. this.raise(FlowErrors.PatternIsOptional, param);
  7825. }
  7826. if (this.isThisParam(param)) {
  7827. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  7828. }
  7829. param.optional = true;
  7830. }
  7831. if (this.match(14)) {
  7832. param.typeAnnotation = this.flowParseTypeAnnotation();
  7833. } else if (this.isThisParam(param)) {
  7834. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  7835. }
  7836. if (this.match(29) && this.isThisParam(param)) {
  7837. this.raise(FlowErrors.ThisParamNoDefault, param);
  7838. }
  7839. this.resetEndLocation(param);
  7840. return param;
  7841. }
  7842. parseMaybeDefault(startLoc, left) {
  7843. const node = super.parseMaybeDefault(startLoc, left);
  7844. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  7845. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  7846. }
  7847. return node;
  7848. }
  7849. checkImportReflection(node) {
  7850. super.checkImportReflection(node);
  7851. if (node.module && node.importKind !== "value") {
  7852. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  7853. }
  7854. }
  7855. parseImportSpecifierLocal(node, specifier, type) {
  7856. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  7857. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  7858. }
  7859. isPotentialImportPhase(isExport) {
  7860. if (super.isPotentialImportPhase(isExport)) return true;
  7861. if (this.isContextual(130)) {
  7862. if (!isExport) return true;
  7863. const ch = this.lookaheadCharCode();
  7864. return ch === 123 || ch === 42;
  7865. }
  7866. return !isExport && this.isContextual(87);
  7867. }
  7868. applyImportPhase(node, isExport, phase, loc) {
  7869. super.applyImportPhase(node, isExport, phase, loc);
  7870. if (isExport) {
  7871. if (!phase && this.match(65)) {
  7872. return;
  7873. }
  7874. node.exportKind = phase === "type" ? phase : "value";
  7875. } else {
  7876. if (phase === "type" && this.match(55)) this.unexpected();
  7877. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  7878. }
  7879. }
  7880. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  7881. const firstIdent = specifier.imported;
  7882. let specifierTypeKind = null;
  7883. if (firstIdent.type === "Identifier") {
  7884. if (firstIdent.name === "type") {
  7885. specifierTypeKind = "type";
  7886. } else if (firstIdent.name === "typeof") {
  7887. specifierTypeKind = "typeof";
  7888. }
  7889. }
  7890. let isBinding = false;
  7891. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  7892. const as_ident = this.parseIdentifier(true);
  7893. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  7894. specifier.imported = as_ident;
  7895. specifier.importKind = specifierTypeKind;
  7896. specifier.local = cloneIdentifier(as_ident);
  7897. } else {
  7898. specifier.imported = firstIdent;
  7899. specifier.importKind = null;
  7900. specifier.local = this.parseIdentifier();
  7901. }
  7902. } else {
  7903. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  7904. specifier.imported = this.parseIdentifier(true);
  7905. specifier.importKind = specifierTypeKind;
  7906. } else {
  7907. if (importedIsString) {
  7908. throw this.raise(Errors.ImportBindingIsString, specifier, {
  7909. importName: firstIdent.value
  7910. });
  7911. }
  7912. specifier.imported = firstIdent;
  7913. specifier.importKind = null;
  7914. }
  7915. if (this.eatContextual(93)) {
  7916. specifier.local = this.parseIdentifier();
  7917. } else {
  7918. isBinding = true;
  7919. specifier.local = cloneIdentifier(specifier.imported);
  7920. }
  7921. }
  7922. const specifierIsTypeImport = hasTypeImportKind(specifier);
  7923. if (isInTypeOnlyImport && specifierIsTypeImport) {
  7924. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  7925. }
  7926. if (isInTypeOnlyImport || specifierIsTypeImport) {
  7927. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  7928. }
  7929. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  7930. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  7931. }
  7932. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  7933. }
  7934. parseBindingAtom() {
  7935. switch (this.state.type) {
  7936. case 78:
  7937. return this.parseIdentifier(true);
  7938. default:
  7939. return super.parseBindingAtom();
  7940. }
  7941. }
  7942. parseFunctionParams(node, isConstructor) {
  7943. const kind = node.kind;
  7944. if (kind !== "get" && kind !== "set" && this.match(47)) {
  7945. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7946. }
  7947. super.parseFunctionParams(node, isConstructor);
  7948. }
  7949. parseVarId(decl, kind) {
  7950. super.parseVarId(decl, kind);
  7951. if (this.match(14)) {
  7952. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  7953. this.resetEndLocation(decl.id);
  7954. }
  7955. }
  7956. parseAsyncArrowFromCallExpression(node, call) {
  7957. if (this.match(14)) {
  7958. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7959. this.state.noAnonFunctionType = true;
  7960. node.returnType = this.flowParseTypeAnnotation();
  7961. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7962. }
  7963. return super.parseAsyncArrowFromCallExpression(node, call);
  7964. }
  7965. shouldParseAsyncArrow() {
  7966. return this.match(14) || super.shouldParseAsyncArrow();
  7967. }
  7968. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  7969. var _jsx;
  7970. let state = null;
  7971. let jsx;
  7972. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  7973. state = this.state.clone();
  7974. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  7975. if (!jsx.error) return jsx.node;
  7976. const {
  7977. context
  7978. } = this.state;
  7979. const currentContext = context[context.length - 1];
  7980. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  7981. context.pop();
  7982. }
  7983. }
  7984. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  7985. var _jsx2, _jsx3;
  7986. state = state || this.state.clone();
  7987. let typeParameters;
  7988. const arrow = this.tryParse(abort => {
  7989. var _arrowExpression$extr;
  7990. typeParameters = this.flowParseTypeParameterDeclaration();
  7991. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  7992. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  7993. this.resetStartLocationFromNode(result, typeParameters);
  7994. return result;
  7995. });
  7996. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  7997. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  7998. if (expr.type !== "ArrowFunctionExpression") abort();
  7999. expr.typeParameters = typeParameters;
  8000. this.resetStartLocationFromNode(expr, typeParameters);
  8001. return arrowExpression;
  8002. }, state);
  8003. let arrowExpression = null;
  8004. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  8005. if (!arrow.error && !arrow.aborted) {
  8006. if (arrow.node.async) {
  8007. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  8008. }
  8009. return arrow.node;
  8010. }
  8011. arrowExpression = arrow.node;
  8012. }
  8013. if ((_jsx2 = jsx) != null && _jsx2.node) {
  8014. this.state = jsx.failState;
  8015. return jsx.node;
  8016. }
  8017. if (arrowExpression) {
  8018. this.state = arrow.failState;
  8019. return arrowExpression;
  8020. }
  8021. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  8022. if (arrow.thrown) throw arrow.error;
  8023. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  8024. }
  8025. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8026. }
  8027. parseArrow(node) {
  8028. if (this.match(14)) {
  8029. const result = this.tryParse(() => {
  8030. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8031. this.state.noAnonFunctionType = true;
  8032. const typeNode = this.startNode();
  8033. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  8034. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8035. if (this.canInsertSemicolon()) this.unexpected();
  8036. if (!this.match(19)) this.unexpected();
  8037. return typeNode;
  8038. });
  8039. if (result.thrown) return null;
  8040. if (result.error) this.state = result.failState;
  8041. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  8042. }
  8043. return super.parseArrow(node);
  8044. }
  8045. shouldParseArrow(params) {
  8046. return this.match(14) || super.shouldParseArrow(params);
  8047. }
  8048. setArrowFunctionParameters(node, params) {
  8049. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8050. node.params = params;
  8051. } else {
  8052. super.setArrowFunctionParameters(node, params);
  8053. }
  8054. }
  8055. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  8056. if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8057. return;
  8058. }
  8059. for (let i = 0; i < node.params.length; i++) {
  8060. if (this.isThisParam(node.params[i]) && i > 0) {
  8061. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  8062. }
  8063. }
  8064. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  8065. }
  8066. parseParenAndDistinguishExpression(canBeArrow) {
  8067. return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
  8068. }
  8069. parseSubscripts(base, startLoc, noCalls) {
  8070. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startLoc.index) !== -1) {
  8071. this.next();
  8072. const node = this.startNodeAt(startLoc);
  8073. node.callee = base;
  8074. node.arguments = super.parseCallExpressionArguments(11, false);
  8075. base = this.finishNode(node, "CallExpression");
  8076. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  8077. const state = this.state.clone();
  8078. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  8079. if (!arrow.error && !arrow.aborted) return arrow.node;
  8080. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  8081. if (result.node && !result.error) return result.node;
  8082. if (arrow.node) {
  8083. this.state = arrow.failState;
  8084. return arrow.node;
  8085. }
  8086. if (result.node) {
  8087. this.state = result.failState;
  8088. return result.node;
  8089. }
  8090. throw arrow.error || result.error;
  8091. }
  8092. return super.parseSubscripts(base, startLoc, noCalls);
  8093. }
  8094. parseSubscript(base, startLoc, noCalls, subscriptState) {
  8095. if (this.match(18) && this.isLookaheadToken_lt()) {
  8096. subscriptState.optionalChainMember = true;
  8097. if (noCalls) {
  8098. subscriptState.stop = true;
  8099. return base;
  8100. }
  8101. this.next();
  8102. const node = this.startNodeAt(startLoc);
  8103. node.callee = base;
  8104. node.typeArguments = this.flowParseTypeParameterInstantiation();
  8105. this.expect(10);
  8106. node.arguments = this.parseCallExpressionArguments(11, false);
  8107. node.optional = true;
  8108. return this.finishCallExpression(node, true);
  8109. } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {
  8110. const node = this.startNodeAt(startLoc);
  8111. node.callee = base;
  8112. const result = this.tryParse(() => {
  8113. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  8114. this.expect(10);
  8115. node.arguments = super.parseCallExpressionArguments(11, false);
  8116. if (subscriptState.optionalChainMember) {
  8117. node.optional = false;
  8118. }
  8119. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  8120. });
  8121. if (result.node) {
  8122. if (result.error) this.state = result.failState;
  8123. return result.node;
  8124. }
  8125. }
  8126. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  8127. }
  8128. parseNewCallee(node) {
  8129. super.parseNewCallee(node);
  8130. let targs = null;
  8131. if (this.shouldParseTypes() && this.match(47)) {
  8132. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  8133. }
  8134. node.typeArguments = targs;
  8135. }
  8136. parseAsyncArrowWithTypeParameters(startLoc) {
  8137. const node = this.startNodeAt(startLoc);
  8138. this.parseFunctionParams(node, false);
  8139. if (!this.parseArrow(node)) return;
  8140. return super.parseArrowExpression(node, undefined, true);
  8141. }
  8142. readToken_mult_modulo(code) {
  8143. const next = this.input.charCodeAt(this.state.pos + 1);
  8144. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  8145. this.state.hasFlowComment = false;
  8146. this.state.pos += 2;
  8147. this.nextToken();
  8148. return;
  8149. }
  8150. super.readToken_mult_modulo(code);
  8151. }
  8152. readToken_pipe_amp(code) {
  8153. const next = this.input.charCodeAt(this.state.pos + 1);
  8154. if (code === 124 && next === 125) {
  8155. this.finishOp(9, 2);
  8156. return;
  8157. }
  8158. super.readToken_pipe_amp(code);
  8159. }
  8160. parseTopLevel(file, program) {
  8161. const fileNode = super.parseTopLevel(file, program);
  8162. if (this.state.hasFlowComment) {
  8163. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  8164. }
  8165. return fileNode;
  8166. }
  8167. skipBlockComment() {
  8168. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  8169. if (this.state.hasFlowComment) {
  8170. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  8171. }
  8172. this.hasFlowCommentCompletion();
  8173. const commentSkip = this.skipFlowComment();
  8174. if (commentSkip) {
  8175. this.state.pos += commentSkip;
  8176. this.state.hasFlowComment = true;
  8177. }
  8178. return;
  8179. }
  8180. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  8181. }
  8182. skipFlowComment() {
  8183. const {
  8184. pos
  8185. } = this.state;
  8186. let shiftToFirstNonWhiteSpace = 2;
  8187. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  8188. shiftToFirstNonWhiteSpace++;
  8189. }
  8190. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  8191. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  8192. if (ch2 === 58 && ch3 === 58) {
  8193. return shiftToFirstNonWhiteSpace + 2;
  8194. }
  8195. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  8196. return shiftToFirstNonWhiteSpace + 12;
  8197. }
  8198. if (ch2 === 58 && ch3 !== 58) {
  8199. return shiftToFirstNonWhiteSpace;
  8200. }
  8201. return false;
  8202. }
  8203. hasFlowCommentCompletion() {
  8204. const end = this.input.indexOf("*/", this.state.pos);
  8205. if (end === -1) {
  8206. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8207. }
  8208. }
  8209. flowEnumErrorBooleanMemberNotInitialized(loc, {
  8210. enumName,
  8211. memberName
  8212. }) {
  8213. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  8214. memberName,
  8215. enumName
  8216. });
  8217. }
  8218. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  8219. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  8220. }
  8221. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  8222. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  8223. }
  8224. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  8225. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  8226. }
  8227. flowEnumMemberInit() {
  8228. const startLoc = this.state.startLoc;
  8229. const endOfInit = () => this.match(12) || this.match(8);
  8230. switch (this.state.type) {
  8231. case 134:
  8232. {
  8233. const literal = this.parseNumericLiteral(this.state.value);
  8234. if (endOfInit()) {
  8235. return {
  8236. type: "number",
  8237. loc: literal.loc.start,
  8238. value: literal
  8239. };
  8240. }
  8241. return {
  8242. type: "invalid",
  8243. loc: startLoc
  8244. };
  8245. }
  8246. case 133:
  8247. {
  8248. const literal = this.parseStringLiteral(this.state.value);
  8249. if (endOfInit()) {
  8250. return {
  8251. type: "string",
  8252. loc: literal.loc.start,
  8253. value: literal
  8254. };
  8255. }
  8256. return {
  8257. type: "invalid",
  8258. loc: startLoc
  8259. };
  8260. }
  8261. case 85:
  8262. case 86:
  8263. {
  8264. const literal = this.parseBooleanLiteral(this.match(85));
  8265. if (endOfInit()) {
  8266. return {
  8267. type: "boolean",
  8268. loc: literal.loc.start,
  8269. value: literal
  8270. };
  8271. }
  8272. return {
  8273. type: "invalid",
  8274. loc: startLoc
  8275. };
  8276. }
  8277. default:
  8278. return {
  8279. type: "invalid",
  8280. loc: startLoc
  8281. };
  8282. }
  8283. }
  8284. flowEnumMemberRaw() {
  8285. const loc = this.state.startLoc;
  8286. const id = this.parseIdentifier(true);
  8287. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  8288. type: "none",
  8289. loc
  8290. };
  8291. return {
  8292. id,
  8293. init
  8294. };
  8295. }
  8296. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  8297. const {
  8298. explicitType
  8299. } = context;
  8300. if (explicitType === null) {
  8301. return;
  8302. }
  8303. if (explicitType !== expectedType) {
  8304. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  8305. }
  8306. }
  8307. flowEnumMembers({
  8308. enumName,
  8309. explicitType
  8310. }) {
  8311. const seenNames = new Set();
  8312. const members = {
  8313. booleanMembers: [],
  8314. numberMembers: [],
  8315. stringMembers: [],
  8316. defaultedMembers: []
  8317. };
  8318. let hasUnknownMembers = false;
  8319. while (!this.match(8)) {
  8320. if (this.eat(21)) {
  8321. hasUnknownMembers = true;
  8322. break;
  8323. }
  8324. const memberNode = this.startNode();
  8325. const {
  8326. id,
  8327. init
  8328. } = this.flowEnumMemberRaw();
  8329. const memberName = id.name;
  8330. if (memberName === "") {
  8331. continue;
  8332. }
  8333. if (/^[a-z]/.test(memberName)) {
  8334. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  8335. memberName,
  8336. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  8337. enumName
  8338. });
  8339. }
  8340. if (seenNames.has(memberName)) {
  8341. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  8342. memberName,
  8343. enumName
  8344. });
  8345. }
  8346. seenNames.add(memberName);
  8347. const context = {
  8348. enumName,
  8349. explicitType,
  8350. memberName
  8351. };
  8352. memberNode.id = id;
  8353. switch (init.type) {
  8354. case "boolean":
  8355. {
  8356. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  8357. memberNode.init = init.value;
  8358. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  8359. break;
  8360. }
  8361. case "number":
  8362. {
  8363. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  8364. memberNode.init = init.value;
  8365. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  8366. break;
  8367. }
  8368. case "string":
  8369. {
  8370. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  8371. memberNode.init = init.value;
  8372. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  8373. break;
  8374. }
  8375. case "invalid":
  8376. {
  8377. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  8378. }
  8379. case "none":
  8380. {
  8381. switch (explicitType) {
  8382. case "boolean":
  8383. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  8384. break;
  8385. case "number":
  8386. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  8387. break;
  8388. default:
  8389. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  8390. }
  8391. }
  8392. }
  8393. if (!this.match(8)) {
  8394. this.expect(12);
  8395. }
  8396. }
  8397. return {
  8398. members,
  8399. hasUnknownMembers
  8400. };
  8401. }
  8402. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  8403. enumName
  8404. }) {
  8405. if (initializedMembers.length === 0) {
  8406. return defaultedMembers;
  8407. } else if (defaultedMembers.length === 0) {
  8408. return initializedMembers;
  8409. } else if (defaultedMembers.length > initializedMembers.length) {
  8410. for (const member of initializedMembers) {
  8411. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8412. enumName
  8413. });
  8414. }
  8415. return defaultedMembers;
  8416. } else {
  8417. for (const member of defaultedMembers) {
  8418. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8419. enumName
  8420. });
  8421. }
  8422. return initializedMembers;
  8423. }
  8424. }
  8425. flowEnumParseExplicitType({
  8426. enumName
  8427. }) {
  8428. if (!this.eatContextual(102)) return null;
  8429. if (!tokenIsIdentifier(this.state.type)) {
  8430. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  8431. enumName
  8432. });
  8433. }
  8434. const {
  8435. value
  8436. } = this.state;
  8437. this.next();
  8438. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  8439. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  8440. enumName,
  8441. invalidEnumType: value
  8442. });
  8443. }
  8444. return value;
  8445. }
  8446. flowEnumBody(node, id) {
  8447. const enumName = id.name;
  8448. const nameLoc = id.loc.start;
  8449. const explicitType = this.flowEnumParseExplicitType({
  8450. enumName
  8451. });
  8452. this.expect(5);
  8453. const {
  8454. members,
  8455. hasUnknownMembers
  8456. } = this.flowEnumMembers({
  8457. enumName,
  8458. explicitType
  8459. });
  8460. node.hasUnknownMembers = hasUnknownMembers;
  8461. switch (explicitType) {
  8462. case "boolean":
  8463. node.explicitType = true;
  8464. node.members = members.booleanMembers;
  8465. this.expect(8);
  8466. return this.finishNode(node, "EnumBooleanBody");
  8467. case "number":
  8468. node.explicitType = true;
  8469. node.members = members.numberMembers;
  8470. this.expect(8);
  8471. return this.finishNode(node, "EnumNumberBody");
  8472. case "string":
  8473. node.explicitType = true;
  8474. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8475. enumName
  8476. });
  8477. this.expect(8);
  8478. return this.finishNode(node, "EnumStringBody");
  8479. case "symbol":
  8480. node.members = members.defaultedMembers;
  8481. this.expect(8);
  8482. return this.finishNode(node, "EnumSymbolBody");
  8483. default:
  8484. {
  8485. const empty = () => {
  8486. node.members = [];
  8487. this.expect(8);
  8488. return this.finishNode(node, "EnumStringBody");
  8489. };
  8490. node.explicitType = false;
  8491. const boolsLen = members.booleanMembers.length;
  8492. const numsLen = members.numberMembers.length;
  8493. const strsLen = members.stringMembers.length;
  8494. const defaultedLen = members.defaultedMembers.length;
  8495. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  8496. return empty();
  8497. } else if (!boolsLen && !numsLen) {
  8498. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8499. enumName
  8500. });
  8501. this.expect(8);
  8502. return this.finishNode(node, "EnumStringBody");
  8503. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  8504. for (const member of members.defaultedMembers) {
  8505. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  8506. enumName,
  8507. memberName: member.id.name
  8508. });
  8509. }
  8510. node.members = members.booleanMembers;
  8511. this.expect(8);
  8512. return this.finishNode(node, "EnumBooleanBody");
  8513. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  8514. for (const member of members.defaultedMembers) {
  8515. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  8516. enumName,
  8517. memberName: member.id.name
  8518. });
  8519. }
  8520. node.members = members.numberMembers;
  8521. this.expect(8);
  8522. return this.finishNode(node, "EnumNumberBody");
  8523. } else {
  8524. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  8525. enumName
  8526. });
  8527. return empty();
  8528. }
  8529. }
  8530. }
  8531. }
  8532. flowParseEnumDeclaration(node) {
  8533. const id = this.parseIdentifier();
  8534. node.id = id;
  8535. node.body = this.flowEnumBody(this.startNode(), id);
  8536. return this.finishNode(node, "EnumDeclaration");
  8537. }
  8538. isLookaheadToken_lt() {
  8539. const next = this.nextTokenStart();
  8540. if (this.input.charCodeAt(next) === 60) {
  8541. const afterNext = this.input.charCodeAt(next + 1);
  8542. return afterNext !== 60 && afterNext !== 61;
  8543. }
  8544. return false;
  8545. }
  8546. maybeUnwrapTypeCastExpression(node) {
  8547. return node.type === "TypeCastExpression" ? node.expression : node;
  8548. }
  8549. };
  8550. const entities = {
  8551. __proto__: null,
  8552. quot: "\u0022",
  8553. amp: "&",
  8554. apos: "\u0027",
  8555. lt: "<",
  8556. gt: ">",
  8557. nbsp: "\u00A0",
  8558. iexcl: "\u00A1",
  8559. cent: "\u00A2",
  8560. pound: "\u00A3",
  8561. curren: "\u00A4",
  8562. yen: "\u00A5",
  8563. brvbar: "\u00A6",
  8564. sect: "\u00A7",
  8565. uml: "\u00A8",
  8566. copy: "\u00A9",
  8567. ordf: "\u00AA",
  8568. laquo: "\u00AB",
  8569. not: "\u00AC",
  8570. shy: "\u00AD",
  8571. reg: "\u00AE",
  8572. macr: "\u00AF",
  8573. deg: "\u00B0",
  8574. plusmn: "\u00B1",
  8575. sup2: "\u00B2",
  8576. sup3: "\u00B3",
  8577. acute: "\u00B4",
  8578. micro: "\u00B5",
  8579. para: "\u00B6",
  8580. middot: "\u00B7",
  8581. cedil: "\u00B8",
  8582. sup1: "\u00B9",
  8583. ordm: "\u00BA",
  8584. raquo: "\u00BB",
  8585. frac14: "\u00BC",
  8586. frac12: "\u00BD",
  8587. frac34: "\u00BE",
  8588. iquest: "\u00BF",
  8589. Agrave: "\u00C0",
  8590. Aacute: "\u00C1",
  8591. Acirc: "\u00C2",
  8592. Atilde: "\u00C3",
  8593. Auml: "\u00C4",
  8594. Aring: "\u00C5",
  8595. AElig: "\u00C6",
  8596. Ccedil: "\u00C7",
  8597. Egrave: "\u00C8",
  8598. Eacute: "\u00C9",
  8599. Ecirc: "\u00CA",
  8600. Euml: "\u00CB",
  8601. Igrave: "\u00CC",
  8602. Iacute: "\u00CD",
  8603. Icirc: "\u00CE",
  8604. Iuml: "\u00CF",
  8605. ETH: "\u00D0",
  8606. Ntilde: "\u00D1",
  8607. Ograve: "\u00D2",
  8608. Oacute: "\u00D3",
  8609. Ocirc: "\u00D4",
  8610. Otilde: "\u00D5",
  8611. Ouml: "\u00D6",
  8612. times: "\u00D7",
  8613. Oslash: "\u00D8",
  8614. Ugrave: "\u00D9",
  8615. Uacute: "\u00DA",
  8616. Ucirc: "\u00DB",
  8617. Uuml: "\u00DC",
  8618. Yacute: "\u00DD",
  8619. THORN: "\u00DE",
  8620. szlig: "\u00DF",
  8621. agrave: "\u00E0",
  8622. aacute: "\u00E1",
  8623. acirc: "\u00E2",
  8624. atilde: "\u00E3",
  8625. auml: "\u00E4",
  8626. aring: "\u00E5",
  8627. aelig: "\u00E6",
  8628. ccedil: "\u00E7",
  8629. egrave: "\u00E8",
  8630. eacute: "\u00E9",
  8631. ecirc: "\u00EA",
  8632. euml: "\u00EB",
  8633. igrave: "\u00EC",
  8634. iacute: "\u00ED",
  8635. icirc: "\u00EE",
  8636. iuml: "\u00EF",
  8637. eth: "\u00F0",
  8638. ntilde: "\u00F1",
  8639. ograve: "\u00F2",
  8640. oacute: "\u00F3",
  8641. ocirc: "\u00F4",
  8642. otilde: "\u00F5",
  8643. ouml: "\u00F6",
  8644. divide: "\u00F7",
  8645. oslash: "\u00F8",
  8646. ugrave: "\u00F9",
  8647. uacute: "\u00FA",
  8648. ucirc: "\u00FB",
  8649. uuml: "\u00FC",
  8650. yacute: "\u00FD",
  8651. thorn: "\u00FE",
  8652. yuml: "\u00FF",
  8653. OElig: "\u0152",
  8654. oelig: "\u0153",
  8655. Scaron: "\u0160",
  8656. scaron: "\u0161",
  8657. Yuml: "\u0178",
  8658. fnof: "\u0192",
  8659. circ: "\u02C6",
  8660. tilde: "\u02DC",
  8661. Alpha: "\u0391",
  8662. Beta: "\u0392",
  8663. Gamma: "\u0393",
  8664. Delta: "\u0394",
  8665. Epsilon: "\u0395",
  8666. Zeta: "\u0396",
  8667. Eta: "\u0397",
  8668. Theta: "\u0398",
  8669. Iota: "\u0399",
  8670. Kappa: "\u039A",
  8671. Lambda: "\u039B",
  8672. Mu: "\u039C",
  8673. Nu: "\u039D",
  8674. Xi: "\u039E",
  8675. Omicron: "\u039F",
  8676. Pi: "\u03A0",
  8677. Rho: "\u03A1",
  8678. Sigma: "\u03A3",
  8679. Tau: "\u03A4",
  8680. Upsilon: "\u03A5",
  8681. Phi: "\u03A6",
  8682. Chi: "\u03A7",
  8683. Psi: "\u03A8",
  8684. Omega: "\u03A9",
  8685. alpha: "\u03B1",
  8686. beta: "\u03B2",
  8687. gamma: "\u03B3",
  8688. delta: "\u03B4",
  8689. epsilon: "\u03B5",
  8690. zeta: "\u03B6",
  8691. eta: "\u03B7",
  8692. theta: "\u03B8",
  8693. iota: "\u03B9",
  8694. kappa: "\u03BA",
  8695. lambda: "\u03BB",
  8696. mu: "\u03BC",
  8697. nu: "\u03BD",
  8698. xi: "\u03BE",
  8699. omicron: "\u03BF",
  8700. pi: "\u03C0",
  8701. rho: "\u03C1",
  8702. sigmaf: "\u03C2",
  8703. sigma: "\u03C3",
  8704. tau: "\u03C4",
  8705. upsilon: "\u03C5",
  8706. phi: "\u03C6",
  8707. chi: "\u03C7",
  8708. psi: "\u03C8",
  8709. omega: "\u03C9",
  8710. thetasym: "\u03D1",
  8711. upsih: "\u03D2",
  8712. piv: "\u03D6",
  8713. ensp: "\u2002",
  8714. emsp: "\u2003",
  8715. thinsp: "\u2009",
  8716. zwnj: "\u200C",
  8717. zwj: "\u200D",
  8718. lrm: "\u200E",
  8719. rlm: "\u200F",
  8720. ndash: "\u2013",
  8721. mdash: "\u2014",
  8722. lsquo: "\u2018",
  8723. rsquo: "\u2019",
  8724. sbquo: "\u201A",
  8725. ldquo: "\u201C",
  8726. rdquo: "\u201D",
  8727. bdquo: "\u201E",
  8728. dagger: "\u2020",
  8729. Dagger: "\u2021",
  8730. bull: "\u2022",
  8731. hellip: "\u2026",
  8732. permil: "\u2030",
  8733. prime: "\u2032",
  8734. Prime: "\u2033",
  8735. lsaquo: "\u2039",
  8736. rsaquo: "\u203A",
  8737. oline: "\u203E",
  8738. frasl: "\u2044",
  8739. euro: "\u20AC",
  8740. image: "\u2111",
  8741. weierp: "\u2118",
  8742. real: "\u211C",
  8743. trade: "\u2122",
  8744. alefsym: "\u2135",
  8745. larr: "\u2190",
  8746. uarr: "\u2191",
  8747. rarr: "\u2192",
  8748. darr: "\u2193",
  8749. harr: "\u2194",
  8750. crarr: "\u21B5",
  8751. lArr: "\u21D0",
  8752. uArr: "\u21D1",
  8753. rArr: "\u21D2",
  8754. dArr: "\u21D3",
  8755. hArr: "\u21D4",
  8756. forall: "\u2200",
  8757. part: "\u2202",
  8758. exist: "\u2203",
  8759. empty: "\u2205",
  8760. nabla: "\u2207",
  8761. isin: "\u2208",
  8762. notin: "\u2209",
  8763. ni: "\u220B",
  8764. prod: "\u220F",
  8765. sum: "\u2211",
  8766. minus: "\u2212",
  8767. lowast: "\u2217",
  8768. radic: "\u221A",
  8769. prop: "\u221D",
  8770. infin: "\u221E",
  8771. ang: "\u2220",
  8772. and: "\u2227",
  8773. or: "\u2228",
  8774. cap: "\u2229",
  8775. cup: "\u222A",
  8776. int: "\u222B",
  8777. there4: "\u2234",
  8778. sim: "\u223C",
  8779. cong: "\u2245",
  8780. asymp: "\u2248",
  8781. ne: "\u2260",
  8782. equiv: "\u2261",
  8783. le: "\u2264",
  8784. ge: "\u2265",
  8785. sub: "\u2282",
  8786. sup: "\u2283",
  8787. nsub: "\u2284",
  8788. sube: "\u2286",
  8789. supe: "\u2287",
  8790. oplus: "\u2295",
  8791. otimes: "\u2297",
  8792. perp: "\u22A5",
  8793. sdot: "\u22C5",
  8794. lceil: "\u2308",
  8795. rceil: "\u2309",
  8796. lfloor: "\u230A",
  8797. rfloor: "\u230B",
  8798. lang: "\u2329",
  8799. rang: "\u232A",
  8800. loz: "\u25CA",
  8801. spades: "\u2660",
  8802. clubs: "\u2663",
  8803. hearts: "\u2665",
  8804. diams: "\u2666"
  8805. };
  8806. const JsxErrors = ParseErrorEnum`jsx`({
  8807. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  8808. MissingClosingTagElement: ({
  8809. openingTagName
  8810. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  8811. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  8812. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  8813. UnexpectedToken: ({
  8814. unexpected,
  8815. HTMLEntity
  8816. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  8817. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  8818. UnterminatedJsxContent: "Unterminated JSX contents.",
  8819. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  8820. });
  8821. function isFragment(object) {
  8822. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  8823. }
  8824. function getQualifiedJSXName(object) {
  8825. if (object.type === "JSXIdentifier") {
  8826. return object.name;
  8827. }
  8828. if (object.type === "JSXNamespacedName") {
  8829. return object.namespace.name + ":" + object.name.name;
  8830. }
  8831. if (object.type === "JSXMemberExpression") {
  8832. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  8833. }
  8834. throw new Error("Node had unexpected type: " + object.type);
  8835. }
  8836. var jsx = superClass => class JSXParserMixin extends superClass {
  8837. jsxReadToken() {
  8838. let out = "";
  8839. let chunkStart = this.state.pos;
  8840. for (;;) {
  8841. if (this.state.pos >= this.length) {
  8842. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  8843. }
  8844. const ch = this.input.charCodeAt(this.state.pos);
  8845. switch (ch) {
  8846. case 60:
  8847. case 123:
  8848. if (this.state.pos === this.state.start) {
  8849. if (ch === 60 && this.state.canStartJSXElement) {
  8850. ++this.state.pos;
  8851. this.finishToken(142);
  8852. } else {
  8853. super.getTokenFromCode(ch);
  8854. }
  8855. return;
  8856. }
  8857. out += this.input.slice(chunkStart, this.state.pos);
  8858. this.finishToken(141, out);
  8859. return;
  8860. case 38:
  8861. out += this.input.slice(chunkStart, this.state.pos);
  8862. out += this.jsxReadEntity();
  8863. chunkStart = this.state.pos;
  8864. break;
  8865. case 62:
  8866. case 125:
  8867. default:
  8868. if (isNewLine(ch)) {
  8869. out += this.input.slice(chunkStart, this.state.pos);
  8870. out += this.jsxReadNewLine(true);
  8871. chunkStart = this.state.pos;
  8872. } else {
  8873. ++this.state.pos;
  8874. }
  8875. }
  8876. }
  8877. }
  8878. jsxReadNewLine(normalizeCRLF) {
  8879. const ch = this.input.charCodeAt(this.state.pos);
  8880. let out;
  8881. ++this.state.pos;
  8882. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  8883. ++this.state.pos;
  8884. out = normalizeCRLF ? "\n" : "\r\n";
  8885. } else {
  8886. out = String.fromCharCode(ch);
  8887. }
  8888. ++this.state.curLine;
  8889. this.state.lineStart = this.state.pos;
  8890. return out;
  8891. }
  8892. jsxReadString(quote) {
  8893. let out = "";
  8894. let chunkStart = ++this.state.pos;
  8895. for (;;) {
  8896. if (this.state.pos >= this.length) {
  8897. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  8898. }
  8899. const ch = this.input.charCodeAt(this.state.pos);
  8900. if (ch === quote) break;
  8901. if (ch === 38) {
  8902. out += this.input.slice(chunkStart, this.state.pos);
  8903. out += this.jsxReadEntity();
  8904. chunkStart = this.state.pos;
  8905. } else if (isNewLine(ch)) {
  8906. out += this.input.slice(chunkStart, this.state.pos);
  8907. out += this.jsxReadNewLine(false);
  8908. chunkStart = this.state.pos;
  8909. } else {
  8910. ++this.state.pos;
  8911. }
  8912. }
  8913. out += this.input.slice(chunkStart, this.state.pos++);
  8914. this.finishToken(133, out);
  8915. }
  8916. jsxReadEntity() {
  8917. const startPos = ++this.state.pos;
  8918. if (this.codePointAtPos(this.state.pos) === 35) {
  8919. ++this.state.pos;
  8920. let radix = 10;
  8921. if (this.codePointAtPos(this.state.pos) === 120) {
  8922. radix = 16;
  8923. ++this.state.pos;
  8924. }
  8925. const codePoint = this.readInt(radix, undefined, false, "bail");
  8926. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  8927. ++this.state.pos;
  8928. return String.fromCodePoint(codePoint);
  8929. }
  8930. } else {
  8931. let count = 0;
  8932. let semi = false;
  8933. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) == 59)) {
  8934. ++this.state.pos;
  8935. }
  8936. if (semi) {
  8937. const desc = this.input.slice(startPos, this.state.pos);
  8938. const entity = entities[desc];
  8939. ++this.state.pos;
  8940. if (entity) {
  8941. return entity;
  8942. }
  8943. }
  8944. }
  8945. this.state.pos = startPos;
  8946. return "&";
  8947. }
  8948. jsxReadWord() {
  8949. let ch;
  8950. const start = this.state.pos;
  8951. do {
  8952. ch = this.input.charCodeAt(++this.state.pos);
  8953. } while (isIdentifierChar(ch) || ch === 45);
  8954. this.finishToken(140, this.input.slice(start, this.state.pos));
  8955. }
  8956. jsxParseIdentifier() {
  8957. const node = this.startNode();
  8958. if (this.match(140)) {
  8959. node.name = this.state.value;
  8960. } else if (tokenIsKeyword(this.state.type)) {
  8961. node.name = tokenLabelName(this.state.type);
  8962. } else {
  8963. this.unexpected();
  8964. }
  8965. this.next();
  8966. return this.finishNode(node, "JSXIdentifier");
  8967. }
  8968. jsxParseNamespacedName() {
  8969. const startLoc = this.state.startLoc;
  8970. const name = this.jsxParseIdentifier();
  8971. if (!this.eat(14)) return name;
  8972. const node = this.startNodeAt(startLoc);
  8973. node.namespace = name;
  8974. node.name = this.jsxParseIdentifier();
  8975. return this.finishNode(node, "JSXNamespacedName");
  8976. }
  8977. jsxParseElementName() {
  8978. const startLoc = this.state.startLoc;
  8979. let node = this.jsxParseNamespacedName();
  8980. if (node.type === "JSXNamespacedName") {
  8981. return node;
  8982. }
  8983. while (this.eat(16)) {
  8984. const newNode = this.startNodeAt(startLoc);
  8985. newNode.object = node;
  8986. newNode.property = this.jsxParseIdentifier();
  8987. node = this.finishNode(newNode, "JSXMemberExpression");
  8988. }
  8989. return node;
  8990. }
  8991. jsxParseAttributeValue() {
  8992. let node;
  8993. switch (this.state.type) {
  8994. case 5:
  8995. node = this.startNode();
  8996. this.setContext(types$1.brace);
  8997. this.next();
  8998. node = this.jsxParseExpressionContainer(node, types$1.j_oTag);
  8999. if (node.expression.type === "JSXEmptyExpression") {
  9000. this.raise(JsxErrors.AttributeIsEmpty, node);
  9001. }
  9002. return node;
  9003. case 142:
  9004. case 133:
  9005. return this.parseExprAtom();
  9006. default:
  9007. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  9008. }
  9009. }
  9010. jsxParseEmptyExpression() {
  9011. const node = this.startNodeAt(this.state.lastTokEndLoc);
  9012. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  9013. }
  9014. jsxParseSpreadChild(node) {
  9015. this.next();
  9016. node.expression = this.parseExpression();
  9017. this.setContext(types$1.j_expr);
  9018. this.state.canStartJSXElement = true;
  9019. this.expect(8);
  9020. return this.finishNode(node, "JSXSpreadChild");
  9021. }
  9022. jsxParseExpressionContainer(node, previousContext) {
  9023. if (this.match(8)) {
  9024. node.expression = this.jsxParseEmptyExpression();
  9025. } else {
  9026. const expression = this.parseExpression();
  9027. node.expression = expression;
  9028. }
  9029. this.setContext(previousContext);
  9030. this.state.canStartJSXElement = true;
  9031. this.expect(8);
  9032. return this.finishNode(node, "JSXExpressionContainer");
  9033. }
  9034. jsxParseAttribute() {
  9035. const node = this.startNode();
  9036. if (this.match(5)) {
  9037. this.setContext(types$1.brace);
  9038. this.next();
  9039. this.expect(21);
  9040. node.argument = this.parseMaybeAssignAllowIn();
  9041. this.setContext(types$1.j_oTag);
  9042. this.state.canStartJSXElement = true;
  9043. this.expect(8);
  9044. return this.finishNode(node, "JSXSpreadAttribute");
  9045. }
  9046. node.name = this.jsxParseNamespacedName();
  9047. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  9048. return this.finishNode(node, "JSXAttribute");
  9049. }
  9050. jsxParseOpeningElementAt(startLoc) {
  9051. const node = this.startNodeAt(startLoc);
  9052. if (this.eat(143)) {
  9053. return this.finishNode(node, "JSXOpeningFragment");
  9054. }
  9055. node.name = this.jsxParseElementName();
  9056. return this.jsxParseOpeningElementAfterName(node);
  9057. }
  9058. jsxParseOpeningElementAfterName(node) {
  9059. const attributes = [];
  9060. while (!this.match(56) && !this.match(143)) {
  9061. attributes.push(this.jsxParseAttribute());
  9062. }
  9063. node.attributes = attributes;
  9064. node.selfClosing = this.eat(56);
  9065. this.expect(143);
  9066. return this.finishNode(node, "JSXOpeningElement");
  9067. }
  9068. jsxParseClosingElementAt(startLoc) {
  9069. const node = this.startNodeAt(startLoc);
  9070. if (this.eat(143)) {
  9071. return this.finishNode(node, "JSXClosingFragment");
  9072. }
  9073. node.name = this.jsxParseElementName();
  9074. this.expect(143);
  9075. return this.finishNode(node, "JSXClosingElement");
  9076. }
  9077. jsxParseElementAt(startLoc) {
  9078. const node = this.startNodeAt(startLoc);
  9079. const children = [];
  9080. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  9081. let closingElement = null;
  9082. if (!openingElement.selfClosing) {
  9083. contents: for (;;) {
  9084. switch (this.state.type) {
  9085. case 142:
  9086. startLoc = this.state.startLoc;
  9087. this.next();
  9088. if (this.eat(56)) {
  9089. closingElement = this.jsxParseClosingElementAt(startLoc);
  9090. break contents;
  9091. }
  9092. children.push(this.jsxParseElementAt(startLoc));
  9093. break;
  9094. case 141:
  9095. children.push(this.parseExprAtom());
  9096. break;
  9097. case 5:
  9098. {
  9099. const node = this.startNode();
  9100. this.setContext(types$1.brace);
  9101. this.next();
  9102. if (this.match(21)) {
  9103. children.push(this.jsxParseSpreadChild(node));
  9104. } else {
  9105. children.push(this.jsxParseExpressionContainer(node, types$1.j_expr));
  9106. }
  9107. break;
  9108. }
  9109. default:
  9110. this.unexpected();
  9111. }
  9112. }
  9113. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  9114. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  9115. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  9116. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9117. openingTagName: getQualifiedJSXName(openingElement.name)
  9118. });
  9119. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  9120. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  9121. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9122. openingTagName: getQualifiedJSXName(openingElement.name)
  9123. });
  9124. }
  9125. }
  9126. }
  9127. if (isFragment(openingElement)) {
  9128. node.openingFragment = openingElement;
  9129. node.closingFragment = closingElement;
  9130. } else {
  9131. node.openingElement = openingElement;
  9132. node.closingElement = closingElement;
  9133. }
  9134. node.children = children;
  9135. if (this.match(47)) {
  9136. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  9137. }
  9138. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  9139. }
  9140. jsxParseElement() {
  9141. const startLoc = this.state.startLoc;
  9142. this.next();
  9143. return this.jsxParseElementAt(startLoc);
  9144. }
  9145. setContext(newContext) {
  9146. const {
  9147. context
  9148. } = this.state;
  9149. context[context.length - 1] = newContext;
  9150. }
  9151. parseExprAtom(refExpressionErrors) {
  9152. if (this.match(141)) {
  9153. return this.parseLiteral(this.state.value, "JSXText");
  9154. } else if (this.match(142)) {
  9155. return this.jsxParseElement();
  9156. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  9157. this.replaceToken(142);
  9158. return this.jsxParseElement();
  9159. } else {
  9160. return super.parseExprAtom(refExpressionErrors);
  9161. }
  9162. }
  9163. skipSpace() {
  9164. const curContext = this.curContext();
  9165. if (!curContext.preserveSpace) super.skipSpace();
  9166. }
  9167. getTokenFromCode(code) {
  9168. const context = this.curContext();
  9169. if (context === types$1.j_expr) {
  9170. this.jsxReadToken();
  9171. return;
  9172. }
  9173. if (context === types$1.j_oTag || context === types$1.j_cTag) {
  9174. if (isIdentifierStart(code)) {
  9175. this.jsxReadWord();
  9176. return;
  9177. }
  9178. if (code === 62) {
  9179. ++this.state.pos;
  9180. this.finishToken(143);
  9181. return;
  9182. }
  9183. if ((code === 34 || code === 39) && context === types$1.j_oTag) {
  9184. this.jsxReadString(code);
  9185. return;
  9186. }
  9187. }
  9188. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  9189. ++this.state.pos;
  9190. this.finishToken(142);
  9191. return;
  9192. }
  9193. super.getTokenFromCode(code);
  9194. }
  9195. updateContext(prevType) {
  9196. const {
  9197. context,
  9198. type
  9199. } = this.state;
  9200. if (type === 56 && prevType === 142) {
  9201. context.splice(-2, 2, types$1.j_cTag);
  9202. this.state.canStartJSXElement = false;
  9203. } else if (type === 142) {
  9204. context.push(types$1.j_oTag);
  9205. } else if (type === 143) {
  9206. const out = context[context.length - 1];
  9207. if (out === types$1.j_oTag && prevType === 56 || out === types$1.j_cTag) {
  9208. context.pop();
  9209. this.state.canStartJSXElement = context[context.length - 1] === types$1.j_expr;
  9210. } else {
  9211. this.setContext(types$1.j_expr);
  9212. this.state.canStartJSXElement = true;
  9213. }
  9214. } else {
  9215. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  9216. }
  9217. }
  9218. };
  9219. class TypeScriptScope extends Scope {
  9220. constructor(...args) {
  9221. super(...args);
  9222. this.tsNames = new Map();
  9223. }
  9224. }
  9225. class TypeScriptScopeHandler extends ScopeHandler {
  9226. constructor(...args) {
  9227. super(...args);
  9228. this.importsStack = [];
  9229. }
  9230. createScope(flags) {
  9231. this.importsStack.push(new Set());
  9232. return new TypeScriptScope(flags);
  9233. }
  9234. enter(flags) {
  9235. if (flags == 256) {
  9236. this.importsStack.push(new Set());
  9237. }
  9238. super.enter(flags);
  9239. }
  9240. exit() {
  9241. const flags = super.exit();
  9242. if (flags == 256) {
  9243. this.importsStack.pop();
  9244. }
  9245. return flags;
  9246. }
  9247. hasImport(name, allowShadow) {
  9248. const len = this.importsStack.length;
  9249. if (this.importsStack[len - 1].has(name)) {
  9250. return true;
  9251. }
  9252. if (!allowShadow && len > 1) {
  9253. for (let i = 0; i < len - 1; i++) {
  9254. if (this.importsStack[i].has(name)) return true;
  9255. }
  9256. }
  9257. return false;
  9258. }
  9259. declareName(name, bindingType, loc) {
  9260. if (bindingType & 4096) {
  9261. if (this.hasImport(name, true)) {
  9262. this.parser.raise(Errors.VarRedeclaration, loc, {
  9263. identifierName: name
  9264. });
  9265. }
  9266. this.importsStack[this.importsStack.length - 1].add(name);
  9267. return;
  9268. }
  9269. const scope = this.currentScope();
  9270. let type = scope.tsNames.get(name) || 0;
  9271. if (bindingType & 1024) {
  9272. this.maybeExportDefined(scope, name);
  9273. scope.tsNames.set(name, type | 16);
  9274. return;
  9275. }
  9276. super.declareName(name, bindingType, loc);
  9277. if (bindingType & 2) {
  9278. if (!(bindingType & 1)) {
  9279. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  9280. this.maybeExportDefined(scope, name);
  9281. }
  9282. type = type | 1;
  9283. }
  9284. if (bindingType & 256) {
  9285. type = type | 2;
  9286. }
  9287. if (bindingType & 512) {
  9288. type = type | 4;
  9289. }
  9290. if (bindingType & 128) {
  9291. type = type | 8;
  9292. }
  9293. if (type) scope.tsNames.set(name, type);
  9294. }
  9295. isRedeclaredInScope(scope, name, bindingType) {
  9296. const type = scope.tsNames.get(name);
  9297. if ((type & 2) > 0) {
  9298. if (bindingType & 256) {
  9299. const isConst = !!(bindingType & 512);
  9300. const wasConst = (type & 4) > 0;
  9301. return isConst !== wasConst;
  9302. }
  9303. return true;
  9304. }
  9305. if (bindingType & 128 && (type & 8) > 0) {
  9306. if (scope.names.get(name) & 2) {
  9307. return !!(bindingType & 1);
  9308. } else {
  9309. return false;
  9310. }
  9311. }
  9312. if (bindingType & 2 && (type & 1) > 0) {
  9313. return true;
  9314. }
  9315. return super.isRedeclaredInScope(scope, name, bindingType);
  9316. }
  9317. checkLocalExport(id) {
  9318. const {
  9319. name
  9320. } = id;
  9321. if (this.hasImport(name)) return;
  9322. const len = this.scopeStack.length;
  9323. for (let i = len - 1; i >= 0; i--) {
  9324. const scope = this.scopeStack[i];
  9325. const type = scope.tsNames.get(name);
  9326. if ((type & 1) > 0 || (type & 16) > 0) {
  9327. return;
  9328. }
  9329. }
  9330. super.checkLocalExport(id);
  9331. }
  9332. }
  9333. const getOwn$1 = (object, key) => Object.hasOwnProperty.call(object, key) && object[key];
  9334. const unwrapParenthesizedExpression = node => {
  9335. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9336. };
  9337. class LValParser extends NodeUtils {
  9338. toAssignable(node, isLHS = false) {
  9339. var _node$extra, _node$extra3;
  9340. let parenthesized = undefined;
  9341. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9342. parenthesized = unwrapParenthesizedExpression(node);
  9343. if (isLHS) {
  9344. if (parenthesized.type === "Identifier") {
  9345. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9346. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9347. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9348. }
  9349. } else {
  9350. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9351. }
  9352. }
  9353. switch (node.type) {
  9354. case "Identifier":
  9355. case "ObjectPattern":
  9356. case "ArrayPattern":
  9357. case "AssignmentPattern":
  9358. case "RestElement":
  9359. break;
  9360. case "ObjectExpression":
  9361. node.type = "ObjectPattern";
  9362. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9363. var _node$extra2;
  9364. const prop = node.properties[i];
  9365. const isLast = i === last;
  9366. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9367. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9368. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9369. }
  9370. }
  9371. break;
  9372. case "ObjectProperty":
  9373. {
  9374. const {
  9375. key,
  9376. value
  9377. } = node;
  9378. if (this.isPrivateName(key)) {
  9379. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9380. }
  9381. this.toAssignable(value, isLHS);
  9382. break;
  9383. }
  9384. case "SpreadElement":
  9385. {
  9386. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9387. }
  9388. case "ArrayExpression":
  9389. node.type = "ArrayPattern";
  9390. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9391. break;
  9392. case "AssignmentExpression":
  9393. if (node.operator !== "=") {
  9394. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9395. }
  9396. node.type = "AssignmentPattern";
  9397. delete node.operator;
  9398. this.toAssignable(node.left, isLHS);
  9399. break;
  9400. case "ParenthesizedExpression":
  9401. this.toAssignable(parenthesized, isLHS);
  9402. break;
  9403. }
  9404. }
  9405. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9406. if (prop.type === "ObjectMethod") {
  9407. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9408. } else if (prop.type === "SpreadElement") {
  9409. prop.type = "RestElement";
  9410. const arg = prop.argument;
  9411. this.checkToRestConversion(arg, false);
  9412. this.toAssignable(arg, isLHS);
  9413. if (!isLast) {
  9414. this.raise(Errors.RestTrailingComma, prop);
  9415. }
  9416. } else {
  9417. this.toAssignable(prop, isLHS);
  9418. }
  9419. }
  9420. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9421. const end = exprList.length - 1;
  9422. for (let i = 0; i <= end; i++) {
  9423. const elt = exprList[i];
  9424. if (!elt) continue;
  9425. if (elt.type === "SpreadElement") {
  9426. elt.type = "RestElement";
  9427. const arg = elt.argument;
  9428. this.checkToRestConversion(arg, true);
  9429. this.toAssignable(arg, isLHS);
  9430. } else {
  9431. this.toAssignable(elt, isLHS);
  9432. }
  9433. if (elt.type === "RestElement") {
  9434. if (i < end) {
  9435. this.raise(Errors.RestTrailingComma, elt);
  9436. } else if (trailingCommaLoc) {
  9437. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9438. }
  9439. }
  9440. }
  9441. }
  9442. isAssignable(node, isBinding) {
  9443. switch (node.type) {
  9444. case "Identifier":
  9445. case "ObjectPattern":
  9446. case "ArrayPattern":
  9447. case "AssignmentPattern":
  9448. case "RestElement":
  9449. return true;
  9450. case "ObjectExpression":
  9451. {
  9452. const last = node.properties.length - 1;
  9453. return node.properties.every((prop, i) => {
  9454. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9455. });
  9456. }
  9457. case "ObjectProperty":
  9458. return this.isAssignable(node.value);
  9459. case "SpreadElement":
  9460. return this.isAssignable(node.argument);
  9461. case "ArrayExpression":
  9462. return node.elements.every(element => element === null || this.isAssignable(element));
  9463. case "AssignmentExpression":
  9464. return node.operator === "=";
  9465. case "ParenthesizedExpression":
  9466. return this.isAssignable(node.expression);
  9467. case "MemberExpression":
  9468. case "OptionalMemberExpression":
  9469. return !isBinding;
  9470. default:
  9471. return false;
  9472. }
  9473. }
  9474. toReferencedList(exprList, isParenthesizedExpr) {
  9475. return exprList;
  9476. }
  9477. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9478. this.toReferencedList(exprList, isParenthesizedExpr);
  9479. for (const expr of exprList) {
  9480. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9481. this.toReferencedListDeep(expr.elements);
  9482. }
  9483. }
  9484. }
  9485. parseSpread(refExpressionErrors) {
  9486. const node = this.startNode();
  9487. this.next();
  9488. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9489. return this.finishNode(node, "SpreadElement");
  9490. }
  9491. parseRestBinding() {
  9492. const node = this.startNode();
  9493. this.next();
  9494. node.argument = this.parseBindingAtom();
  9495. return this.finishNode(node, "RestElement");
  9496. }
  9497. parseBindingAtom() {
  9498. switch (this.state.type) {
  9499. case 0:
  9500. {
  9501. const node = this.startNode();
  9502. this.next();
  9503. node.elements = this.parseBindingList(3, 93, 1);
  9504. return this.finishNode(node, "ArrayPattern");
  9505. }
  9506. case 5:
  9507. return this.parseObjectLike(8, true);
  9508. }
  9509. return this.parseIdentifier();
  9510. }
  9511. parseBindingList(close, closeCharCode, flags) {
  9512. const allowEmpty = flags & 1;
  9513. const elts = [];
  9514. let first = true;
  9515. while (!this.eat(close)) {
  9516. if (first) {
  9517. first = false;
  9518. } else {
  9519. this.expect(12);
  9520. }
  9521. if (allowEmpty && this.match(12)) {
  9522. elts.push(null);
  9523. } else if (this.eat(close)) {
  9524. break;
  9525. } else if (this.match(21)) {
  9526. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags));
  9527. if (!this.checkCommaAfterRest(closeCharCode)) {
  9528. this.expect(close);
  9529. break;
  9530. }
  9531. } else {
  9532. const decorators = [];
  9533. if (this.match(26) && this.hasPlugin("decorators")) {
  9534. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9535. }
  9536. while (this.match(26)) {
  9537. decorators.push(this.parseDecorator());
  9538. }
  9539. elts.push(this.parseAssignableListItem(flags, decorators));
  9540. }
  9541. }
  9542. return elts;
  9543. }
  9544. parseBindingRestProperty(prop) {
  9545. this.next();
  9546. prop.argument = this.parseIdentifier();
  9547. this.checkCommaAfterRest(125);
  9548. return this.finishNode(prop, "RestElement");
  9549. }
  9550. parseBindingProperty() {
  9551. const prop = this.startNode();
  9552. const {
  9553. type,
  9554. startLoc
  9555. } = this.state;
  9556. if (type === 21) {
  9557. return this.parseBindingRestProperty(prop);
  9558. } else if (type === 138) {
  9559. this.expectPlugin("destructuringPrivate", startLoc);
  9560. this.classScope.usePrivateName(this.state.value, startLoc);
  9561. prop.key = this.parsePrivateName();
  9562. } else {
  9563. this.parsePropertyName(prop);
  9564. }
  9565. prop.method = false;
  9566. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9567. }
  9568. parseAssignableListItem(flags, decorators) {
  9569. const left = this.parseMaybeDefault();
  9570. this.parseAssignableListItemTypes(left, flags);
  9571. const elt = this.parseMaybeDefault(left.loc.start, left);
  9572. if (decorators.length) {
  9573. left.decorators = decorators;
  9574. }
  9575. return elt;
  9576. }
  9577. parseAssignableListItemTypes(param, flags) {
  9578. return param;
  9579. }
  9580. parseMaybeDefault(startLoc, left) {
  9581. var _startLoc, _left;
  9582. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  9583. left = (_left = left) != null ? _left : this.parseBindingAtom();
  9584. if (!this.eat(29)) return left;
  9585. const node = this.startNodeAt(startLoc);
  9586. node.left = left;
  9587. node.right = this.parseMaybeAssignAllowIn();
  9588. return this.finishNode(node, "AssignmentPattern");
  9589. }
  9590. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9591. return getOwn$1({
  9592. AssignmentPattern: "left",
  9593. RestElement: "argument",
  9594. ObjectProperty: "value",
  9595. ParenthesizedExpression: "expression",
  9596. ArrayPattern: "elements",
  9597. ObjectPattern: "properties"
  9598. }, type);
  9599. }
  9600. isOptionalMemberExpression(expression) {
  9601. return expression.type === "OptionalMemberExpression";
  9602. }
  9603. checkLVal(expression, {
  9604. in: ancestor,
  9605. binding = 64,
  9606. checkClashes = false,
  9607. strictModeChanged = false,
  9608. hasParenthesizedAncestor = false
  9609. }) {
  9610. var _expression$extra;
  9611. const type = expression.type;
  9612. if (this.isObjectMethod(expression)) return;
  9613. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9614. if (isOptionalMemberExpression || type === "MemberExpression") {
  9615. if (isOptionalMemberExpression) {
  9616. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9617. if (ancestor.type !== "AssignmentExpression") {
  9618. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9619. ancestor
  9620. });
  9621. }
  9622. }
  9623. if (binding !== 64) {
  9624. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9625. }
  9626. return;
  9627. }
  9628. if (type === "Identifier") {
  9629. this.checkIdentifier(expression, binding, strictModeChanged);
  9630. const {
  9631. name
  9632. } = expression;
  9633. if (checkClashes) {
  9634. if (checkClashes.has(name)) {
  9635. this.raise(Errors.ParamDupe, expression);
  9636. } else {
  9637. checkClashes.add(name);
  9638. }
  9639. }
  9640. return;
  9641. }
  9642. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9643. if (validity === true) return;
  9644. if (validity === false) {
  9645. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9646. this.raise(ParseErrorClass, expression, {
  9647. ancestor
  9648. });
  9649. return;
  9650. }
  9651. const [key, isParenthesizedExpression] = Array.isArray(validity) ? validity : [validity, type === "ParenthesizedExpression"];
  9652. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9653. type
  9654. } : ancestor;
  9655. for (const child of [].concat(expression[key])) {
  9656. if (child) {
  9657. this.checkLVal(child, {
  9658. in: nextAncestor,
  9659. binding,
  9660. checkClashes,
  9661. strictModeChanged,
  9662. hasParenthesizedAncestor: isParenthesizedExpression
  9663. });
  9664. }
  9665. }
  9666. }
  9667. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9668. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9669. if (bindingType === 64) {
  9670. this.raise(Errors.StrictEvalArguments, at, {
  9671. referenceName: at.name
  9672. });
  9673. } else {
  9674. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9675. bindingName: at.name
  9676. });
  9677. }
  9678. }
  9679. if (bindingType & 8192 && at.name === "let") {
  9680. this.raise(Errors.LetInLexicalBinding, at);
  9681. }
  9682. if (!(bindingType & 64)) {
  9683. this.declareNameFromIdentifier(at, bindingType);
  9684. }
  9685. }
  9686. declareNameFromIdentifier(identifier, binding) {
  9687. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  9688. }
  9689. checkToRestConversion(node, allowPattern) {
  9690. switch (node.type) {
  9691. case "ParenthesizedExpression":
  9692. this.checkToRestConversion(node.expression, allowPattern);
  9693. break;
  9694. case "Identifier":
  9695. case "MemberExpression":
  9696. break;
  9697. case "ArrayExpression":
  9698. case "ObjectExpression":
  9699. if (allowPattern) break;
  9700. default:
  9701. this.raise(Errors.InvalidRestAssignmentPattern, node);
  9702. }
  9703. }
  9704. checkCommaAfterRest(close) {
  9705. if (!this.match(12)) {
  9706. return false;
  9707. }
  9708. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  9709. return true;
  9710. }
  9711. }
  9712. const getOwn = (object, key) => Object.hasOwnProperty.call(object, key) && object[key];
  9713. function nonNull(x) {
  9714. if (x == null) {
  9715. throw new Error(`Unexpected ${x} value.`);
  9716. }
  9717. return x;
  9718. }
  9719. function assert$1(x) {
  9720. if (!x) {
  9721. throw new Error("Assert fail");
  9722. }
  9723. }
  9724. const TSErrors = ParseErrorEnum`typescript`({
  9725. AbstractMethodHasImplementation: ({
  9726. methodName
  9727. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  9728. AbstractPropertyHasInitializer: ({
  9729. propertyName
  9730. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  9731. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  9732. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  9733. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  9734. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  9735. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  9736. ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  9737. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  9738. DeclareAccessor: ({
  9739. kind
  9740. }) => `'declare' is not allowed in ${kind}ters.`,
  9741. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  9742. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  9743. DuplicateAccessibilityModifier: ({
  9744. modifier
  9745. }) => `Accessibility modifier already seen.`,
  9746. DuplicateModifier: ({
  9747. modifier
  9748. }) => `Duplicate modifier: '${modifier}'.`,
  9749. EmptyHeritageClauseType: ({
  9750. token
  9751. }) => `'${token}' list cannot be empty.`,
  9752. EmptyTypeArguments: "Type argument list cannot be empty.",
  9753. EmptyTypeParameters: "Type parameter list cannot be empty.",
  9754. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  9755. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  9756. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  9757. IncompatibleModifiers: ({
  9758. modifiers
  9759. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  9760. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  9761. IndexSignatureHasAccessibility: ({
  9762. modifier
  9763. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  9764. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  9765. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  9766. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  9767. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  9768. InvalidModifierOnTypeMember: ({
  9769. modifier
  9770. }) => `'${modifier}' modifier cannot appear on a type member.`,
  9771. InvalidModifierOnTypeParameter: ({
  9772. modifier
  9773. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  9774. InvalidModifierOnTypeParameterPositions: ({
  9775. modifier
  9776. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  9777. InvalidModifiersOrder: ({
  9778. orderedModifiers
  9779. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  9780. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  9781. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  9782. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  9783. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  9784. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  9785. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  9786. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  9787. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  9788. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  9789. PrivateElementHasAccessibility: ({
  9790. modifier
  9791. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  9792. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  9793. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  9794. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  9795. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  9796. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  9797. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  9798. SingleTypeParameterWithoutTrailingComma: ({
  9799. typeParameterName
  9800. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  9801. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  9802. 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?`).",
  9803. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  9804. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  9805. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  9806. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  9807. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  9808. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  9809. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  9810. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  9811. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  9812. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  9813. UnsupportedSignatureParameterKind: ({
  9814. type
  9815. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`
  9816. });
  9817. function keywordTypeFromName(value) {
  9818. switch (value) {
  9819. case "any":
  9820. return "TSAnyKeyword";
  9821. case "boolean":
  9822. return "TSBooleanKeyword";
  9823. case "bigint":
  9824. return "TSBigIntKeyword";
  9825. case "never":
  9826. return "TSNeverKeyword";
  9827. case "number":
  9828. return "TSNumberKeyword";
  9829. case "object":
  9830. return "TSObjectKeyword";
  9831. case "string":
  9832. return "TSStringKeyword";
  9833. case "symbol":
  9834. return "TSSymbolKeyword";
  9835. case "undefined":
  9836. return "TSUndefinedKeyword";
  9837. case "unknown":
  9838. return "TSUnknownKeyword";
  9839. default:
  9840. return undefined;
  9841. }
  9842. }
  9843. function tsIsAccessModifier(modifier) {
  9844. return modifier === "private" || modifier === "public" || modifier === "protected";
  9845. }
  9846. function tsIsVarianceAnnotations(modifier) {
  9847. return modifier === "in" || modifier === "out";
  9848. }
  9849. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  9850. constructor(...args) {
  9851. super(...args);
  9852. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  9853. allowedModifiers: ["in", "out"],
  9854. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9855. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9856. });
  9857. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  9858. allowedModifiers: ["const"],
  9859. disallowedModifiers: ["in", "out"],
  9860. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  9861. });
  9862. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  9863. allowedModifiers: ["in", "out", "const"],
  9864. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9865. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9866. });
  9867. }
  9868. getScopeHandler() {
  9869. return TypeScriptScopeHandler;
  9870. }
  9871. tsIsIdentifier() {
  9872. return tokenIsIdentifier(this.state.type);
  9873. }
  9874. tsTokenCanFollowModifier() {
  9875. return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  9876. }
  9877. tsNextTokenCanFollowModifier() {
  9878. this.next();
  9879. return this.tsTokenCanFollowModifier();
  9880. }
  9881. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
  9882. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  9883. return undefined;
  9884. }
  9885. const modifier = this.state.value;
  9886. if (allowedModifiers.indexOf(modifier) !== -1) {
  9887. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  9888. return undefined;
  9889. }
  9890. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  9891. return modifier;
  9892. }
  9893. }
  9894. return undefined;
  9895. }
  9896. tsParseModifiers({
  9897. allowedModifiers,
  9898. disallowedModifiers,
  9899. stopOnStartOfClassStaticBlock,
  9900. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  9901. }, modified) {
  9902. const enforceOrder = (loc, modifier, before, after) => {
  9903. if (modifier === before && modified[after]) {
  9904. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  9905. orderedModifiers: [before, after]
  9906. });
  9907. }
  9908. };
  9909. const incompatible = (loc, modifier, mod1, mod2) => {
  9910. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  9911. this.raise(TSErrors.IncompatibleModifiers, loc, {
  9912. modifiers: [mod1, mod2]
  9913. });
  9914. }
  9915. };
  9916. for (;;) {
  9917. const {
  9918. startLoc
  9919. } = this.state;
  9920. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
  9921. if (!modifier) break;
  9922. if (tsIsAccessModifier(modifier)) {
  9923. if (modified.accessibility) {
  9924. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  9925. modifier
  9926. });
  9927. } else {
  9928. enforceOrder(startLoc, modifier, modifier, "override");
  9929. enforceOrder(startLoc, modifier, modifier, "static");
  9930. enforceOrder(startLoc, modifier, modifier, "readonly");
  9931. modified.accessibility = modifier;
  9932. }
  9933. } else if (tsIsVarianceAnnotations(modifier)) {
  9934. if (modified[modifier]) {
  9935. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9936. modifier
  9937. });
  9938. }
  9939. modified[modifier] = true;
  9940. enforceOrder(startLoc, modifier, "in", "out");
  9941. } else {
  9942. if (Object.hasOwnProperty.call(modified, modifier)) {
  9943. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9944. modifier
  9945. });
  9946. } else {
  9947. enforceOrder(startLoc, modifier, "static", "readonly");
  9948. enforceOrder(startLoc, modifier, "static", "override");
  9949. enforceOrder(startLoc, modifier, "override", "readonly");
  9950. enforceOrder(startLoc, modifier, "abstract", "override");
  9951. incompatible(startLoc, modifier, "declare", "override");
  9952. incompatible(startLoc, modifier, "static", "abstract");
  9953. }
  9954. modified[modifier] = true;
  9955. }
  9956. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  9957. this.raise(errorTemplate, startLoc, {
  9958. modifier
  9959. });
  9960. }
  9961. }
  9962. }
  9963. tsIsListTerminator(kind) {
  9964. switch (kind) {
  9965. case "EnumMembers":
  9966. case "TypeMembers":
  9967. return this.match(8);
  9968. case "HeritageClauseElement":
  9969. return this.match(5);
  9970. case "TupleElementTypes":
  9971. return this.match(3);
  9972. case "TypeParametersOrArguments":
  9973. return this.match(48);
  9974. }
  9975. }
  9976. tsParseList(kind, parseElement) {
  9977. const result = [];
  9978. while (!this.tsIsListTerminator(kind)) {
  9979. result.push(parseElement());
  9980. }
  9981. return result;
  9982. }
  9983. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  9984. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  9985. }
  9986. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  9987. const result = [];
  9988. let trailingCommaPos = -1;
  9989. for (;;) {
  9990. if (this.tsIsListTerminator(kind)) {
  9991. break;
  9992. }
  9993. trailingCommaPos = -1;
  9994. const element = parseElement();
  9995. if (element == null) {
  9996. return undefined;
  9997. }
  9998. result.push(element);
  9999. if (this.eat(12)) {
  10000. trailingCommaPos = this.state.lastTokStartLoc.index;
  10001. continue;
  10002. }
  10003. if (this.tsIsListTerminator(kind)) {
  10004. break;
  10005. }
  10006. if (expectSuccess) {
  10007. this.expect(12);
  10008. }
  10009. return undefined;
  10010. }
  10011. if (refTrailingCommaPos) {
  10012. refTrailingCommaPos.value = trailingCommaPos;
  10013. }
  10014. return result;
  10015. }
  10016. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  10017. if (!skipFirstToken) {
  10018. if (bracket) {
  10019. this.expect(0);
  10020. } else {
  10021. this.expect(47);
  10022. }
  10023. }
  10024. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  10025. if (bracket) {
  10026. this.expect(3);
  10027. } else {
  10028. this.expect(48);
  10029. }
  10030. return result;
  10031. }
  10032. tsParseImportType() {
  10033. const node = this.startNode();
  10034. this.expect(83);
  10035. this.expect(10);
  10036. if (!this.match(133)) {
  10037. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10038. }
  10039. node.argument = super.parseExprAtom();
  10040. this.expect(11);
  10041. if (this.eat(16)) {
  10042. node.qualifier = this.tsParseEntityName();
  10043. }
  10044. if (this.match(47)) {
  10045. node.typeParameters = this.tsParseTypeArguments();
  10046. }
  10047. return this.finishNode(node, "TSImportType");
  10048. }
  10049. tsParseEntityName(allowReservedWords = true) {
  10050. let entity = this.parseIdentifier(allowReservedWords);
  10051. while (this.eat(16)) {
  10052. const node = this.startNodeAtNode(entity);
  10053. node.left = entity;
  10054. node.right = this.parseIdentifier(allowReservedWords);
  10055. entity = this.finishNode(node, "TSQualifiedName");
  10056. }
  10057. return entity;
  10058. }
  10059. tsParseTypeReference() {
  10060. const node = this.startNode();
  10061. node.typeName = this.tsParseEntityName();
  10062. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10063. node.typeParameters = this.tsParseTypeArguments();
  10064. }
  10065. return this.finishNode(node, "TSTypeReference");
  10066. }
  10067. tsParseThisTypePredicate(lhs) {
  10068. this.next();
  10069. const node = this.startNodeAtNode(lhs);
  10070. node.parameterName = lhs;
  10071. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10072. node.asserts = false;
  10073. return this.finishNode(node, "TSTypePredicate");
  10074. }
  10075. tsParseThisTypeNode() {
  10076. const node = this.startNode();
  10077. this.next();
  10078. return this.finishNode(node, "TSThisType");
  10079. }
  10080. tsParseTypeQuery() {
  10081. const node = this.startNode();
  10082. this.expect(87);
  10083. if (this.match(83)) {
  10084. node.exprName = this.tsParseImportType();
  10085. } else {
  10086. node.exprName = this.tsParseEntityName();
  10087. }
  10088. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10089. node.typeParameters = this.tsParseTypeArguments();
  10090. }
  10091. return this.finishNode(node, "TSTypeQuery");
  10092. }
  10093. tsParseTypeParameter(parseModifiers) {
  10094. const node = this.startNode();
  10095. parseModifiers(node);
  10096. node.name = this.tsParseTypeParameterName();
  10097. node.constraint = this.tsEatThenParseType(81);
  10098. node.default = this.tsEatThenParseType(29);
  10099. return this.finishNode(node, "TSTypeParameter");
  10100. }
  10101. tsTryParseTypeParameters(parseModifiers) {
  10102. if (this.match(47)) {
  10103. return this.tsParseTypeParameters(parseModifiers);
  10104. }
  10105. }
  10106. tsParseTypeParameters(parseModifiers) {
  10107. const node = this.startNode();
  10108. if (this.match(47) || this.match(142)) {
  10109. this.next();
  10110. } else {
  10111. this.unexpected();
  10112. }
  10113. const refTrailingCommaPos = {
  10114. value: -1
  10115. };
  10116. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10117. if (node.params.length === 0) {
  10118. this.raise(TSErrors.EmptyTypeParameters, node);
  10119. }
  10120. if (refTrailingCommaPos.value !== -1) {
  10121. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10122. }
  10123. return this.finishNode(node, "TSTypeParameterDeclaration");
  10124. }
  10125. tsFillSignature(returnToken, signature) {
  10126. const returnTokenRequired = returnToken === 19;
  10127. const paramsKey = "parameters";
  10128. const returnTypeKey = "typeAnnotation";
  10129. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10130. this.expect(10);
  10131. signature[paramsKey] = this.tsParseBindingListForSignature();
  10132. if (returnTokenRequired) {
  10133. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10134. } else if (this.match(returnToken)) {
  10135. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10136. }
  10137. }
  10138. tsParseBindingListForSignature() {
  10139. const list = super.parseBindingList(11, 41, 2);
  10140. for (const pattern of list) {
  10141. const {
  10142. type
  10143. } = pattern;
  10144. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10145. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10146. type
  10147. });
  10148. }
  10149. }
  10150. return list;
  10151. }
  10152. tsParseTypeMemberSemicolon() {
  10153. if (!this.eat(12) && !this.isLineTerminator()) {
  10154. this.expect(13);
  10155. }
  10156. }
  10157. tsParseSignatureMember(kind, node) {
  10158. this.tsFillSignature(14, node);
  10159. this.tsParseTypeMemberSemicolon();
  10160. return this.finishNode(node, kind);
  10161. }
  10162. tsIsUnambiguouslyIndexSignature() {
  10163. this.next();
  10164. if (tokenIsIdentifier(this.state.type)) {
  10165. this.next();
  10166. return this.match(14);
  10167. }
  10168. return false;
  10169. }
  10170. tsTryParseIndexSignature(node) {
  10171. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10172. return;
  10173. }
  10174. this.expect(0);
  10175. const id = this.parseIdentifier();
  10176. id.typeAnnotation = this.tsParseTypeAnnotation();
  10177. this.resetEndLocation(id);
  10178. this.expect(3);
  10179. node.parameters = [id];
  10180. const type = this.tsTryParseTypeAnnotation();
  10181. if (type) node.typeAnnotation = type;
  10182. this.tsParseTypeMemberSemicolon();
  10183. return this.finishNode(node, "TSIndexSignature");
  10184. }
  10185. tsParsePropertyOrMethodSignature(node, readonly) {
  10186. if (this.eat(17)) node.optional = true;
  10187. const nodeAny = node;
  10188. if (this.match(10) || this.match(47)) {
  10189. if (readonly) {
  10190. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10191. }
  10192. const method = nodeAny;
  10193. if (method.kind && this.match(47)) {
  10194. this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition());
  10195. }
  10196. this.tsFillSignature(14, method);
  10197. this.tsParseTypeMemberSemicolon();
  10198. const paramsKey = "parameters";
  10199. const returnTypeKey = "typeAnnotation";
  10200. if (method.kind === "get") {
  10201. if (method[paramsKey].length > 0) {
  10202. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10203. if (this.isThisParam(method[paramsKey][0])) {
  10204. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10205. }
  10206. }
  10207. } else if (method.kind === "set") {
  10208. if (method[paramsKey].length !== 1) {
  10209. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10210. } else {
  10211. const firstParameter = method[paramsKey][0];
  10212. if (this.isThisParam(firstParameter)) {
  10213. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10214. }
  10215. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10216. this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition());
  10217. }
  10218. if (firstParameter.type === "RestElement") {
  10219. this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition());
  10220. }
  10221. }
  10222. if (method[returnTypeKey]) {
  10223. this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]);
  10224. }
  10225. } else {
  10226. method.kind = "method";
  10227. }
  10228. return this.finishNode(method, "TSMethodSignature");
  10229. } else {
  10230. const property = nodeAny;
  10231. if (readonly) property.readonly = true;
  10232. const type = this.tsTryParseTypeAnnotation();
  10233. if (type) property.typeAnnotation = type;
  10234. this.tsParseTypeMemberSemicolon();
  10235. return this.finishNode(property, "TSPropertySignature");
  10236. }
  10237. }
  10238. tsParseTypeMember() {
  10239. const node = this.startNode();
  10240. if (this.match(10) || this.match(47)) {
  10241. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10242. }
  10243. if (this.match(77)) {
  10244. const id = this.startNode();
  10245. this.next();
  10246. if (this.match(10) || this.match(47)) {
  10247. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10248. } else {
  10249. node.key = this.createIdentifier(id, "new");
  10250. return this.tsParsePropertyOrMethodSignature(node, false);
  10251. }
  10252. }
  10253. this.tsParseModifiers({
  10254. allowedModifiers: ["readonly"],
  10255. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10256. }, node);
  10257. const idx = this.tsTryParseIndexSignature(node);
  10258. if (idx) {
  10259. return idx;
  10260. }
  10261. super.parsePropertyName(node);
  10262. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10263. node.kind = node.key.name;
  10264. super.parsePropertyName(node);
  10265. }
  10266. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10267. }
  10268. tsParseTypeLiteral() {
  10269. const node = this.startNode();
  10270. node.members = this.tsParseObjectTypeMembers();
  10271. return this.finishNode(node, "TSTypeLiteral");
  10272. }
  10273. tsParseObjectTypeMembers() {
  10274. this.expect(5);
  10275. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10276. this.expect(8);
  10277. return members;
  10278. }
  10279. tsIsStartOfMappedType() {
  10280. this.next();
  10281. if (this.eat(53)) {
  10282. return this.isContextual(122);
  10283. }
  10284. if (this.isContextual(122)) {
  10285. this.next();
  10286. }
  10287. if (!this.match(0)) {
  10288. return false;
  10289. }
  10290. this.next();
  10291. if (!this.tsIsIdentifier()) {
  10292. return false;
  10293. }
  10294. this.next();
  10295. return this.match(58);
  10296. }
  10297. tsParseMappedTypeParameter() {
  10298. const node = this.startNode();
  10299. node.name = this.tsParseTypeParameterName();
  10300. node.constraint = this.tsExpectThenParseType(58);
  10301. return this.finishNode(node, "TSTypeParameter");
  10302. }
  10303. tsParseMappedType() {
  10304. const node = this.startNode();
  10305. this.expect(5);
  10306. if (this.match(53)) {
  10307. node.readonly = this.state.value;
  10308. this.next();
  10309. this.expectContextual(122);
  10310. } else if (this.eatContextual(122)) {
  10311. node.readonly = true;
  10312. }
  10313. this.expect(0);
  10314. node.typeParameter = this.tsParseMappedTypeParameter();
  10315. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10316. this.expect(3);
  10317. if (this.match(53)) {
  10318. node.optional = this.state.value;
  10319. this.next();
  10320. this.expect(17);
  10321. } else if (this.eat(17)) {
  10322. node.optional = true;
  10323. }
  10324. node.typeAnnotation = this.tsTryParseType();
  10325. this.semicolon();
  10326. this.expect(8);
  10327. return this.finishNode(node, "TSMappedType");
  10328. }
  10329. tsParseTupleType() {
  10330. const node = this.startNode();
  10331. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10332. let seenOptionalElement = false;
  10333. node.elementTypes.forEach(elementNode => {
  10334. const {
  10335. type
  10336. } = elementNode;
  10337. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10338. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10339. }
  10340. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10341. });
  10342. return this.finishNode(node, "TSTupleType");
  10343. }
  10344. tsParseTupleElementType() {
  10345. const {
  10346. startLoc
  10347. } = this.state;
  10348. const rest = this.eat(21);
  10349. let labeled;
  10350. let label;
  10351. let optional;
  10352. let type;
  10353. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10354. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10355. if (chAfterWord === 58) {
  10356. labeled = true;
  10357. optional = false;
  10358. label = this.parseIdentifier(true);
  10359. this.expect(14);
  10360. type = this.tsParseType();
  10361. } else if (chAfterWord === 63) {
  10362. optional = true;
  10363. const startLoc = this.state.startLoc;
  10364. const wordName = this.state.value;
  10365. const typeOrLabel = this.tsParseNonArrayType();
  10366. if (this.lookaheadCharCode() === 58) {
  10367. labeled = true;
  10368. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10369. this.expect(17);
  10370. this.expect(14);
  10371. type = this.tsParseType();
  10372. } else {
  10373. labeled = false;
  10374. type = typeOrLabel;
  10375. this.expect(17);
  10376. }
  10377. } else {
  10378. type = this.tsParseType();
  10379. optional = this.eat(17);
  10380. labeled = this.eat(14);
  10381. }
  10382. if (labeled) {
  10383. let labeledNode;
  10384. if (label) {
  10385. labeledNode = this.startNodeAtNode(label);
  10386. labeledNode.optional = optional;
  10387. labeledNode.label = label;
  10388. labeledNode.elementType = type;
  10389. if (this.eat(17)) {
  10390. labeledNode.optional = true;
  10391. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10392. }
  10393. } else {
  10394. labeledNode = this.startNodeAtNode(type);
  10395. labeledNode.optional = optional;
  10396. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10397. labeledNode.label = type;
  10398. labeledNode.elementType = this.tsParseType();
  10399. }
  10400. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10401. } else if (optional) {
  10402. const optionalTypeNode = this.startNodeAtNode(type);
  10403. optionalTypeNode.typeAnnotation = type;
  10404. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10405. }
  10406. if (rest) {
  10407. const restNode = this.startNodeAt(startLoc);
  10408. restNode.typeAnnotation = type;
  10409. type = this.finishNode(restNode, "TSRestType");
  10410. }
  10411. return type;
  10412. }
  10413. tsParseParenthesizedType() {
  10414. const node = this.startNode();
  10415. this.expect(10);
  10416. node.typeAnnotation = this.tsParseType();
  10417. this.expect(11);
  10418. return this.finishNode(node, "TSParenthesizedType");
  10419. }
  10420. tsParseFunctionOrConstructorType(type, abstract) {
  10421. const node = this.startNode();
  10422. if (type === "TSConstructorType") {
  10423. node.abstract = !!abstract;
  10424. if (abstract) this.next();
  10425. this.next();
  10426. }
  10427. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10428. return this.finishNode(node, type);
  10429. }
  10430. tsParseLiteralTypeNode() {
  10431. const node = this.startNode();
  10432. switch (this.state.type) {
  10433. case 134:
  10434. case 135:
  10435. case 133:
  10436. case 85:
  10437. case 86:
  10438. node.literal = super.parseExprAtom();
  10439. break;
  10440. default:
  10441. this.unexpected();
  10442. }
  10443. return this.finishNode(node, "TSLiteralType");
  10444. }
  10445. tsParseTemplateLiteralType() {
  10446. const node = this.startNode();
  10447. node.literal = super.parseTemplate(false);
  10448. return this.finishNode(node, "TSLiteralType");
  10449. }
  10450. parseTemplateSubstitution() {
  10451. if (this.state.inType) return this.tsParseType();
  10452. return super.parseTemplateSubstitution();
  10453. }
  10454. tsParseThisTypeOrThisTypePredicate() {
  10455. const thisKeyword = this.tsParseThisTypeNode();
  10456. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10457. return this.tsParseThisTypePredicate(thisKeyword);
  10458. } else {
  10459. return thisKeyword;
  10460. }
  10461. }
  10462. tsParseNonArrayType() {
  10463. switch (this.state.type) {
  10464. case 133:
  10465. case 134:
  10466. case 135:
  10467. case 85:
  10468. case 86:
  10469. return this.tsParseLiteralTypeNode();
  10470. case 53:
  10471. if (this.state.value === "-") {
  10472. const node = this.startNode();
  10473. const nextToken = this.lookahead();
  10474. if (nextToken.type !== 134 && nextToken.type !== 135) {
  10475. this.unexpected();
  10476. }
  10477. node.literal = this.parseMaybeUnary();
  10478. return this.finishNode(node, "TSLiteralType");
  10479. }
  10480. break;
  10481. case 78:
  10482. return this.tsParseThisTypeOrThisTypePredicate();
  10483. case 87:
  10484. return this.tsParseTypeQuery();
  10485. case 83:
  10486. return this.tsParseImportType();
  10487. case 5:
  10488. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10489. case 0:
  10490. return this.tsParseTupleType();
  10491. case 10:
  10492. return this.tsParseParenthesizedType();
  10493. case 25:
  10494. case 24:
  10495. return this.tsParseTemplateLiteralType();
  10496. default:
  10497. {
  10498. const {
  10499. type
  10500. } = this.state;
  10501. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10502. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10503. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10504. const node = this.startNode();
  10505. this.next();
  10506. return this.finishNode(node, nodeType);
  10507. }
  10508. return this.tsParseTypeReference();
  10509. }
  10510. }
  10511. }
  10512. this.unexpected();
  10513. }
  10514. tsParseArrayTypeOrHigher() {
  10515. let type = this.tsParseNonArrayType();
  10516. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10517. if (this.match(3)) {
  10518. const node = this.startNodeAtNode(type);
  10519. node.elementType = type;
  10520. this.expect(3);
  10521. type = this.finishNode(node, "TSArrayType");
  10522. } else {
  10523. const node = this.startNodeAtNode(type);
  10524. node.objectType = type;
  10525. node.indexType = this.tsParseType();
  10526. this.expect(3);
  10527. type = this.finishNode(node, "TSIndexedAccessType");
  10528. }
  10529. }
  10530. return type;
  10531. }
  10532. tsParseTypeOperator() {
  10533. const node = this.startNode();
  10534. const operator = this.state.value;
  10535. this.next();
  10536. node.operator = operator;
  10537. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10538. if (operator === "readonly") {
  10539. this.tsCheckTypeAnnotationForReadOnly(node);
  10540. }
  10541. return this.finishNode(node, "TSTypeOperator");
  10542. }
  10543. tsCheckTypeAnnotationForReadOnly(node) {
  10544. switch (node.typeAnnotation.type) {
  10545. case "TSTupleType":
  10546. case "TSArrayType":
  10547. return;
  10548. default:
  10549. this.raise(TSErrors.UnexpectedReadonly, node);
  10550. }
  10551. }
  10552. tsParseInferType() {
  10553. const node = this.startNode();
  10554. this.expectContextual(115);
  10555. const typeParameter = this.startNode();
  10556. typeParameter.name = this.tsParseTypeParameterName();
  10557. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10558. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10559. return this.finishNode(node, "TSInferType");
  10560. }
  10561. tsParseConstraintForInferType() {
  10562. if (this.eat(81)) {
  10563. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10564. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10565. return constraint;
  10566. }
  10567. }
  10568. }
  10569. tsParseTypeOperatorOrHigher() {
  10570. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10571. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10572. }
  10573. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10574. const node = this.startNode();
  10575. const hasLeadingOperator = this.eat(operator);
  10576. const types = [];
  10577. do {
  10578. types.push(parseConstituentType());
  10579. } while (this.eat(operator));
  10580. if (types.length === 1 && !hasLeadingOperator) {
  10581. return types[0];
  10582. }
  10583. node.types = types;
  10584. return this.finishNode(node, kind);
  10585. }
  10586. tsParseIntersectionTypeOrHigher() {
  10587. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10588. }
  10589. tsParseUnionTypeOrHigher() {
  10590. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  10591. }
  10592. tsIsStartOfFunctionType() {
  10593. if (this.match(47)) {
  10594. return true;
  10595. }
  10596. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  10597. }
  10598. tsSkipParameterStart() {
  10599. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  10600. this.next();
  10601. return true;
  10602. }
  10603. if (this.match(5)) {
  10604. const {
  10605. errors
  10606. } = this.state;
  10607. const previousErrorCount = errors.length;
  10608. try {
  10609. this.parseObjectLike(8, true);
  10610. return errors.length === previousErrorCount;
  10611. } catch (_unused) {
  10612. return false;
  10613. }
  10614. }
  10615. if (this.match(0)) {
  10616. this.next();
  10617. const {
  10618. errors
  10619. } = this.state;
  10620. const previousErrorCount = errors.length;
  10621. try {
  10622. super.parseBindingList(3, 93, 1);
  10623. return errors.length === previousErrorCount;
  10624. } catch (_unused2) {
  10625. return false;
  10626. }
  10627. }
  10628. return false;
  10629. }
  10630. tsIsUnambiguouslyStartOfFunctionType() {
  10631. this.next();
  10632. if (this.match(11) || this.match(21)) {
  10633. return true;
  10634. }
  10635. if (this.tsSkipParameterStart()) {
  10636. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  10637. return true;
  10638. }
  10639. if (this.match(11)) {
  10640. this.next();
  10641. if (this.match(19)) {
  10642. return true;
  10643. }
  10644. }
  10645. }
  10646. return false;
  10647. }
  10648. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  10649. return this.tsInType(() => {
  10650. const t = this.startNode();
  10651. this.expect(returnToken);
  10652. const node = this.startNode();
  10653. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  10654. if (asserts && this.match(78)) {
  10655. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  10656. if (thisTypePredicate.type === "TSThisType") {
  10657. node.parameterName = thisTypePredicate;
  10658. node.asserts = true;
  10659. node.typeAnnotation = null;
  10660. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  10661. } else {
  10662. this.resetStartLocationFromNode(thisTypePredicate, node);
  10663. thisTypePredicate.asserts = true;
  10664. }
  10665. t.typeAnnotation = thisTypePredicate;
  10666. return this.finishNode(t, "TSTypeAnnotation");
  10667. }
  10668. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  10669. if (!typePredicateVariable) {
  10670. if (!asserts) {
  10671. return this.tsParseTypeAnnotation(false, t);
  10672. }
  10673. node.parameterName = this.parseIdentifier();
  10674. node.asserts = asserts;
  10675. node.typeAnnotation = null;
  10676. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10677. return this.finishNode(t, "TSTypeAnnotation");
  10678. }
  10679. const type = this.tsParseTypeAnnotation(false);
  10680. node.parameterName = typePredicateVariable;
  10681. node.typeAnnotation = type;
  10682. node.asserts = asserts;
  10683. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10684. return this.finishNode(t, "TSTypeAnnotation");
  10685. });
  10686. }
  10687. tsTryParseTypeOrTypePredicateAnnotation() {
  10688. if (this.match(14)) {
  10689. return this.tsParseTypeOrTypePredicateAnnotation(14);
  10690. }
  10691. }
  10692. tsTryParseTypeAnnotation() {
  10693. if (this.match(14)) {
  10694. return this.tsParseTypeAnnotation();
  10695. }
  10696. }
  10697. tsTryParseType() {
  10698. return this.tsEatThenParseType(14);
  10699. }
  10700. tsParseTypePredicatePrefix() {
  10701. const id = this.parseIdentifier();
  10702. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10703. this.next();
  10704. return id;
  10705. }
  10706. }
  10707. tsParseTypePredicateAsserts() {
  10708. if (this.state.type !== 109) {
  10709. return false;
  10710. }
  10711. const containsEsc = this.state.containsEsc;
  10712. this.next();
  10713. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  10714. return false;
  10715. }
  10716. if (containsEsc) {
  10717. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  10718. reservedWord: "asserts"
  10719. });
  10720. }
  10721. return true;
  10722. }
  10723. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  10724. this.tsInType(() => {
  10725. if (eatColon) this.expect(14);
  10726. t.typeAnnotation = this.tsParseType();
  10727. });
  10728. return this.finishNode(t, "TSTypeAnnotation");
  10729. }
  10730. tsParseType() {
  10731. assert$1(this.state.inType);
  10732. const type = this.tsParseNonConditionalType();
  10733. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  10734. return type;
  10735. }
  10736. const node = this.startNodeAtNode(type);
  10737. node.checkType = type;
  10738. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  10739. this.expect(17);
  10740. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10741. this.expect(14);
  10742. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10743. return this.finishNode(node, "TSConditionalType");
  10744. }
  10745. isAbstractConstructorSignature() {
  10746. return this.isContextual(124) && this.lookahead().type === 77;
  10747. }
  10748. tsParseNonConditionalType() {
  10749. if (this.tsIsStartOfFunctionType()) {
  10750. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  10751. }
  10752. if (this.match(77)) {
  10753. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  10754. } else if (this.isAbstractConstructorSignature()) {
  10755. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  10756. }
  10757. return this.tsParseUnionTypeOrHigher();
  10758. }
  10759. tsParseTypeAssertion() {
  10760. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  10761. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  10762. }
  10763. const node = this.startNode();
  10764. node.typeAnnotation = this.tsInType(() => {
  10765. this.next();
  10766. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  10767. });
  10768. this.expect(48);
  10769. node.expression = this.parseMaybeUnary();
  10770. return this.finishNode(node, "TSTypeAssertion");
  10771. }
  10772. tsParseHeritageClause(token) {
  10773. const originalStartLoc = this.state.startLoc;
  10774. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  10775. const node = this.startNode();
  10776. node.expression = this.tsParseEntityName();
  10777. if (this.match(47)) {
  10778. node.typeParameters = this.tsParseTypeArguments();
  10779. }
  10780. return this.finishNode(node, "TSExpressionWithTypeArguments");
  10781. });
  10782. if (!delimitedList.length) {
  10783. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  10784. token
  10785. });
  10786. }
  10787. return delimitedList;
  10788. }
  10789. tsParseInterfaceDeclaration(node, properties = {}) {
  10790. if (this.hasFollowingLineBreak()) return null;
  10791. this.expectContextual(129);
  10792. if (properties.declare) node.declare = true;
  10793. if (tokenIsIdentifier(this.state.type)) {
  10794. node.id = this.parseIdentifier();
  10795. this.checkIdentifier(node.id, 130);
  10796. } else {
  10797. node.id = null;
  10798. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  10799. }
  10800. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  10801. if (this.eat(81)) {
  10802. node.extends = this.tsParseHeritageClause("extends");
  10803. }
  10804. const body = this.startNode();
  10805. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  10806. node.body = this.finishNode(body, "TSInterfaceBody");
  10807. return this.finishNode(node, "TSInterfaceDeclaration");
  10808. }
  10809. tsParseTypeAliasDeclaration(node) {
  10810. node.id = this.parseIdentifier();
  10811. this.checkIdentifier(node.id, 2);
  10812. node.typeAnnotation = this.tsInType(() => {
  10813. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  10814. this.expect(29);
  10815. if (this.isContextual(114) && this.lookahead().type !== 16) {
  10816. const node = this.startNode();
  10817. this.next();
  10818. return this.finishNode(node, "TSIntrinsicKeyword");
  10819. }
  10820. return this.tsParseType();
  10821. });
  10822. this.semicolon();
  10823. return this.finishNode(node, "TSTypeAliasDeclaration");
  10824. }
  10825. tsInNoContext(cb) {
  10826. const oldContext = this.state.context;
  10827. this.state.context = [oldContext[0]];
  10828. try {
  10829. return cb();
  10830. } finally {
  10831. this.state.context = oldContext;
  10832. }
  10833. }
  10834. tsInType(cb) {
  10835. const oldInType = this.state.inType;
  10836. this.state.inType = true;
  10837. try {
  10838. return cb();
  10839. } finally {
  10840. this.state.inType = oldInType;
  10841. }
  10842. }
  10843. tsInDisallowConditionalTypesContext(cb) {
  10844. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10845. this.state.inDisallowConditionalTypesContext = true;
  10846. try {
  10847. return cb();
  10848. } finally {
  10849. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10850. }
  10851. }
  10852. tsInAllowConditionalTypesContext(cb) {
  10853. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10854. this.state.inDisallowConditionalTypesContext = false;
  10855. try {
  10856. return cb();
  10857. } finally {
  10858. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10859. }
  10860. }
  10861. tsEatThenParseType(token) {
  10862. if (this.match(token)) {
  10863. return this.tsNextThenParseType();
  10864. }
  10865. }
  10866. tsExpectThenParseType(token) {
  10867. return this.tsInType(() => {
  10868. this.expect(token);
  10869. return this.tsParseType();
  10870. });
  10871. }
  10872. tsNextThenParseType() {
  10873. return this.tsInType(() => {
  10874. this.next();
  10875. return this.tsParseType();
  10876. });
  10877. }
  10878. tsParseEnumMember() {
  10879. const node = this.startNode();
  10880. node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  10881. if (this.eat(29)) {
  10882. node.initializer = super.parseMaybeAssignAllowIn();
  10883. }
  10884. return this.finishNode(node, "TSEnumMember");
  10885. }
  10886. tsParseEnumDeclaration(node, properties = {}) {
  10887. if (properties.const) node.const = true;
  10888. if (properties.declare) node.declare = true;
  10889. this.expectContextual(126);
  10890. node.id = this.parseIdentifier();
  10891. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  10892. this.expect(5);
  10893. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  10894. this.expect(8);
  10895. return this.finishNode(node, "TSEnumDeclaration");
  10896. }
  10897. tsParseModuleBlock() {
  10898. const node = this.startNode();
  10899. this.scope.enter(0);
  10900. this.expect(5);
  10901. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  10902. this.scope.exit();
  10903. return this.finishNode(node, "TSModuleBlock");
  10904. }
  10905. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  10906. node.id = this.parseIdentifier();
  10907. if (!nested) {
  10908. this.checkIdentifier(node.id, 1024);
  10909. }
  10910. if (this.eat(16)) {
  10911. const inner = this.startNode();
  10912. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  10913. node.body = inner;
  10914. } else {
  10915. this.scope.enter(256);
  10916. this.prodParam.enter(0);
  10917. node.body = this.tsParseModuleBlock();
  10918. this.prodParam.exit();
  10919. this.scope.exit();
  10920. }
  10921. return this.finishNode(node, "TSModuleDeclaration");
  10922. }
  10923. tsParseAmbientExternalModuleDeclaration(node) {
  10924. if (this.isContextual(112)) {
  10925. node.global = true;
  10926. node.id = this.parseIdentifier();
  10927. } else if (this.match(133)) {
  10928. node.id = super.parseStringLiteral(this.state.value);
  10929. } else {
  10930. this.unexpected();
  10931. }
  10932. if (this.match(5)) {
  10933. this.scope.enter(256);
  10934. this.prodParam.enter(0);
  10935. node.body = this.tsParseModuleBlock();
  10936. this.prodParam.exit();
  10937. this.scope.exit();
  10938. } else {
  10939. this.semicolon();
  10940. }
  10941. return this.finishNode(node, "TSModuleDeclaration");
  10942. }
  10943. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  10944. node.isExport = isExport || false;
  10945. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  10946. this.checkIdentifier(node.id, 4096);
  10947. this.expect(29);
  10948. const moduleReference = this.tsParseModuleReference();
  10949. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  10950. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  10951. }
  10952. node.moduleReference = moduleReference;
  10953. this.semicolon();
  10954. return this.finishNode(node, "TSImportEqualsDeclaration");
  10955. }
  10956. tsIsExternalModuleReference() {
  10957. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  10958. }
  10959. tsParseModuleReference() {
  10960. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  10961. }
  10962. tsParseExternalModuleReference() {
  10963. const node = this.startNode();
  10964. this.expectContextual(119);
  10965. this.expect(10);
  10966. if (!this.match(133)) {
  10967. this.unexpected();
  10968. }
  10969. node.expression = super.parseExprAtom();
  10970. this.expect(11);
  10971. this.sawUnambiguousESM = true;
  10972. return this.finishNode(node, "TSExternalModuleReference");
  10973. }
  10974. tsLookAhead(f) {
  10975. const state = this.state.clone();
  10976. const res = f();
  10977. this.state = state;
  10978. return res;
  10979. }
  10980. tsTryParseAndCatch(f) {
  10981. const result = this.tryParse(abort => f() || abort());
  10982. if (result.aborted || !result.node) return;
  10983. if (result.error) this.state = result.failState;
  10984. return result.node;
  10985. }
  10986. tsTryParse(f) {
  10987. const state = this.state.clone();
  10988. const result = f();
  10989. if (result !== undefined && result !== false) {
  10990. return result;
  10991. }
  10992. this.state = state;
  10993. }
  10994. tsTryParseDeclare(nany) {
  10995. if (this.isLineTerminator()) {
  10996. return;
  10997. }
  10998. let startType = this.state.type;
  10999. let kind;
  11000. if (this.isContextual(100)) {
  11001. startType = 74;
  11002. kind = "let";
  11003. }
  11004. return this.tsInAmbientContext(() => {
  11005. switch (startType) {
  11006. case 68:
  11007. nany.declare = true;
  11008. return super.parseFunctionStatement(nany, false, false);
  11009. case 80:
  11010. nany.declare = true;
  11011. return this.parseClass(nany, true, false);
  11012. case 126:
  11013. return this.tsParseEnumDeclaration(nany, {
  11014. declare: true
  11015. });
  11016. case 112:
  11017. return this.tsParseAmbientExternalModuleDeclaration(nany);
  11018. case 75:
  11019. case 74:
  11020. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11021. nany.declare = true;
  11022. return this.parseVarStatement(nany, kind || this.state.value, true);
  11023. }
  11024. this.expect(75);
  11025. return this.tsParseEnumDeclaration(nany, {
  11026. const: true,
  11027. declare: true
  11028. });
  11029. case 129:
  11030. {
  11031. const result = this.tsParseInterfaceDeclaration(nany, {
  11032. declare: true
  11033. });
  11034. if (result) return result;
  11035. }
  11036. default:
  11037. if (tokenIsIdentifier(startType)) {
  11038. return this.tsParseDeclaration(nany, this.state.value, true, null);
  11039. }
  11040. }
  11041. });
  11042. }
  11043. tsTryParseExportDeclaration() {
  11044. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11045. }
  11046. tsParseExpressionStatement(node, expr, decorators) {
  11047. switch (expr.name) {
  11048. case "declare":
  11049. {
  11050. const declaration = this.tsTryParseDeclare(node);
  11051. if (declaration) {
  11052. declaration.declare = true;
  11053. }
  11054. return declaration;
  11055. }
  11056. case "global":
  11057. if (this.match(5)) {
  11058. this.scope.enter(256);
  11059. this.prodParam.enter(0);
  11060. const mod = node;
  11061. mod.global = true;
  11062. mod.id = expr;
  11063. mod.body = this.tsParseModuleBlock();
  11064. this.scope.exit();
  11065. this.prodParam.exit();
  11066. return this.finishNode(mod, "TSModuleDeclaration");
  11067. }
  11068. break;
  11069. default:
  11070. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11071. }
  11072. }
  11073. tsParseDeclaration(node, value, next, decorators) {
  11074. switch (value) {
  11075. case "abstract":
  11076. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11077. return this.tsParseAbstractDeclaration(node, decorators);
  11078. }
  11079. break;
  11080. case "module":
  11081. if (this.tsCheckLineTerminator(next)) {
  11082. if (this.match(133)) {
  11083. return this.tsParseAmbientExternalModuleDeclaration(node);
  11084. } else if (tokenIsIdentifier(this.state.type)) {
  11085. return this.tsParseModuleOrNamespaceDeclaration(node);
  11086. }
  11087. }
  11088. break;
  11089. case "namespace":
  11090. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11091. return this.tsParseModuleOrNamespaceDeclaration(node);
  11092. }
  11093. break;
  11094. case "type":
  11095. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11096. return this.tsParseTypeAliasDeclaration(node);
  11097. }
  11098. break;
  11099. }
  11100. }
  11101. tsCheckLineTerminator(next) {
  11102. if (next) {
  11103. if (this.hasFollowingLineBreak()) return false;
  11104. this.next();
  11105. return true;
  11106. }
  11107. return !this.isLineTerminator();
  11108. }
  11109. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11110. if (!this.match(47)) return;
  11111. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11112. this.state.maybeInArrowParameters = true;
  11113. const res = this.tsTryParseAndCatch(() => {
  11114. const node = this.startNodeAt(startLoc);
  11115. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11116. super.parseFunctionParams(node);
  11117. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11118. this.expect(19);
  11119. return node;
  11120. });
  11121. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11122. if (!res) return;
  11123. return super.parseArrowExpression(res, null, true);
  11124. }
  11125. tsParseTypeArgumentsInExpression() {
  11126. if (this.reScan_lt() !== 47) return;
  11127. return this.tsParseTypeArguments();
  11128. }
  11129. tsParseTypeArguments() {
  11130. const node = this.startNode();
  11131. node.params = this.tsInType(() => this.tsInNoContext(() => {
  11132. this.expect(47);
  11133. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11134. }));
  11135. if (node.params.length === 0) {
  11136. this.raise(TSErrors.EmptyTypeArguments, node);
  11137. } else if (!this.state.inType && this.curContext() === types$1.brace) {
  11138. this.reScan_lt_gt();
  11139. }
  11140. this.expect(48);
  11141. return this.finishNode(node, "TSTypeParameterInstantiation");
  11142. }
  11143. tsIsDeclarationStart() {
  11144. return tokenIsTSDeclarationStart(this.state.type);
  11145. }
  11146. isExportDefaultSpecifier() {
  11147. if (this.tsIsDeclarationStart()) return false;
  11148. return super.isExportDefaultSpecifier();
  11149. }
  11150. parseAssignableListItem(flags, decorators) {
  11151. const startLoc = this.state.startLoc;
  11152. const modified = {};
  11153. this.tsParseModifiers({
  11154. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11155. }, modified);
  11156. const accessibility = modified.accessibility;
  11157. const override = modified.override;
  11158. const readonly = modified.readonly;
  11159. if (!(flags & 4) && (accessibility || readonly || override)) {
  11160. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11161. }
  11162. const left = this.parseMaybeDefault();
  11163. this.parseAssignableListItemTypes(left, flags);
  11164. const elt = this.parseMaybeDefault(left.loc.start, left);
  11165. if (accessibility || readonly || override) {
  11166. const pp = this.startNodeAt(startLoc);
  11167. if (decorators.length) {
  11168. pp.decorators = decorators;
  11169. }
  11170. if (accessibility) pp.accessibility = accessibility;
  11171. if (readonly) pp.readonly = readonly;
  11172. if (override) pp.override = override;
  11173. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11174. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11175. }
  11176. pp.parameter = elt;
  11177. return this.finishNode(pp, "TSParameterProperty");
  11178. }
  11179. if (decorators.length) {
  11180. left.decorators = decorators;
  11181. }
  11182. return elt;
  11183. }
  11184. isSimpleParameter(node) {
  11185. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11186. }
  11187. tsDisallowOptionalPattern(node) {
  11188. for (const param of node.params) {
  11189. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11190. this.raise(TSErrors.PatternIsOptional, param);
  11191. }
  11192. }
  11193. }
  11194. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11195. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11196. this.tsDisallowOptionalPattern(node);
  11197. }
  11198. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11199. if (this.match(14)) {
  11200. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11201. }
  11202. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11203. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11204. return this.finishNode(node, bodilessType);
  11205. }
  11206. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11207. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11208. if (node.declare) {
  11209. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11210. }
  11211. }
  11212. this.tsDisallowOptionalPattern(node);
  11213. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11214. }
  11215. registerFunctionStatementId(node) {
  11216. if (!node.body && node.id) {
  11217. this.checkIdentifier(node.id, 1024);
  11218. } else {
  11219. super.registerFunctionStatementId(node);
  11220. }
  11221. }
  11222. tsCheckForInvalidTypeCasts(items) {
  11223. items.forEach(node => {
  11224. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11225. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11226. }
  11227. });
  11228. }
  11229. toReferencedList(exprList, isInParens) {
  11230. this.tsCheckForInvalidTypeCasts(exprList);
  11231. return exprList;
  11232. }
  11233. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11234. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11235. if (node.type === "ArrayExpression") {
  11236. this.tsCheckForInvalidTypeCasts(node.elements);
  11237. }
  11238. return node;
  11239. }
  11240. parseSubscript(base, startLoc, noCalls, state) {
  11241. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11242. this.state.canStartJSXElement = false;
  11243. this.next();
  11244. const nonNullExpression = this.startNodeAt(startLoc);
  11245. nonNullExpression.expression = base;
  11246. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11247. }
  11248. let isOptionalCall = false;
  11249. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11250. if (noCalls) {
  11251. state.stop = true;
  11252. return base;
  11253. }
  11254. state.optionalChainMember = isOptionalCall = true;
  11255. this.next();
  11256. }
  11257. if (this.match(47) || this.match(51)) {
  11258. let missingParenErrorLoc;
  11259. const result = this.tsTryParseAndCatch(() => {
  11260. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11261. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11262. if (asyncArrowFn) {
  11263. return asyncArrowFn;
  11264. }
  11265. }
  11266. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11267. if (!typeArguments) return;
  11268. if (isOptionalCall && !this.match(10)) {
  11269. missingParenErrorLoc = this.state.curPosition();
  11270. return;
  11271. }
  11272. if (tokenIsTemplate(this.state.type)) {
  11273. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11274. result.typeParameters = typeArguments;
  11275. return result;
  11276. }
  11277. if (!noCalls && this.eat(10)) {
  11278. const node = this.startNodeAt(startLoc);
  11279. node.callee = base;
  11280. node.arguments = this.parseCallExpressionArguments(11, false);
  11281. this.tsCheckForInvalidTypeCasts(node.arguments);
  11282. node.typeParameters = typeArguments;
  11283. if (state.optionalChainMember) {
  11284. node.optional = isOptionalCall;
  11285. }
  11286. return this.finishCallExpression(node, state.optionalChainMember);
  11287. }
  11288. const tokenType = this.state.type;
  11289. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11290. return;
  11291. }
  11292. const node = this.startNodeAt(startLoc);
  11293. node.expression = base;
  11294. node.typeParameters = typeArguments;
  11295. return this.finishNode(node, "TSInstantiationExpression");
  11296. });
  11297. if (missingParenErrorLoc) {
  11298. this.unexpected(missingParenErrorLoc, 10);
  11299. }
  11300. if (result) {
  11301. if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
  11302. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11303. }
  11304. return result;
  11305. }
  11306. }
  11307. return super.parseSubscript(base, startLoc, noCalls, state);
  11308. }
  11309. parseNewCallee(node) {
  11310. var _callee$extra;
  11311. super.parseNewCallee(node);
  11312. const {
  11313. callee
  11314. } = node;
  11315. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11316. node.typeParameters = callee.typeParameters;
  11317. node.callee = callee.expression;
  11318. }
  11319. }
  11320. parseExprOp(left, leftStartLoc, minPrec) {
  11321. let isSatisfies;
  11322. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11323. const node = this.startNodeAt(leftStartLoc);
  11324. node.expression = left;
  11325. node.typeAnnotation = this.tsInType(() => {
  11326. this.next();
  11327. if (this.match(75)) {
  11328. if (isSatisfies) {
  11329. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11330. keyword: "const"
  11331. });
  11332. }
  11333. return this.tsParseTypeReference();
  11334. }
  11335. return this.tsParseType();
  11336. });
  11337. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11338. this.reScan_lt_gt();
  11339. return this.parseExprOp(node, leftStartLoc, minPrec);
  11340. }
  11341. return super.parseExprOp(left, leftStartLoc, minPrec);
  11342. }
  11343. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11344. if (!this.state.isAmbientContext) {
  11345. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11346. }
  11347. }
  11348. checkImportReflection(node) {
  11349. super.checkImportReflection(node);
  11350. if (node.module && node.importKind !== "value") {
  11351. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11352. }
  11353. }
  11354. checkDuplicateExports() {}
  11355. isPotentialImportPhase(isExport) {
  11356. if (super.isPotentialImportPhase(isExport)) return true;
  11357. if (this.isContextual(130)) {
  11358. const ch = this.lookaheadCharCode();
  11359. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11360. }
  11361. return !isExport && this.isContextual(87);
  11362. }
  11363. applyImportPhase(node, isExport, phase, loc) {
  11364. super.applyImportPhase(node, isExport, phase, loc);
  11365. if (isExport) {
  11366. node.exportKind = phase === "type" ? "type" : "value";
  11367. } else {
  11368. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11369. }
  11370. }
  11371. parseImport(node) {
  11372. if (this.match(133)) {
  11373. node.importKind = "value";
  11374. return super.parseImport(node);
  11375. }
  11376. let importNode;
  11377. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11378. node.importKind = "value";
  11379. return this.tsParseImportEqualsDeclaration(node);
  11380. } else if (this.isContextual(130)) {
  11381. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11382. if (this.lookaheadCharCode() === 61) {
  11383. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11384. } else {
  11385. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11386. }
  11387. } else {
  11388. importNode = super.parseImport(node);
  11389. }
  11390. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11391. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11392. }
  11393. return importNode;
  11394. }
  11395. parseExport(node, decorators) {
  11396. if (this.match(83)) {
  11397. this.next();
  11398. let maybeDefaultIdentifier = null;
  11399. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11400. maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11401. } else {
  11402. node.importKind = "value";
  11403. }
  11404. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, true);
  11405. } else if (this.eat(29)) {
  11406. const assign = node;
  11407. assign.expression = super.parseExpression();
  11408. this.semicolon();
  11409. this.sawUnambiguousESM = true;
  11410. return this.finishNode(assign, "TSExportAssignment");
  11411. } else if (this.eatContextual(93)) {
  11412. const decl = node;
  11413. this.expectContextual(128);
  11414. decl.id = this.parseIdentifier();
  11415. this.semicolon();
  11416. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11417. } else {
  11418. return super.parseExport(node, decorators);
  11419. }
  11420. }
  11421. isAbstractClass() {
  11422. return this.isContextual(124) && this.lookahead().type === 80;
  11423. }
  11424. parseExportDefaultExpression() {
  11425. if (this.isAbstractClass()) {
  11426. const cls = this.startNode();
  11427. this.next();
  11428. cls.abstract = true;
  11429. return this.parseClass(cls, true, true);
  11430. }
  11431. if (this.match(129)) {
  11432. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11433. if (result) return result;
  11434. }
  11435. return super.parseExportDefaultExpression();
  11436. }
  11437. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11438. const {
  11439. isAmbientContext
  11440. } = this.state;
  11441. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11442. if (!isAmbientContext) return declaration;
  11443. for (const {
  11444. id,
  11445. init
  11446. } of declaration.declarations) {
  11447. if (!init) continue;
  11448. if (kind !== "const" || !!id.typeAnnotation) {
  11449. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11450. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11451. this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11452. }
  11453. }
  11454. return declaration;
  11455. }
  11456. parseStatementContent(flags, decorators) {
  11457. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11458. const node = this.startNode();
  11459. this.expect(75);
  11460. return this.tsParseEnumDeclaration(node, {
  11461. const: true
  11462. });
  11463. }
  11464. if (this.isContextual(126)) {
  11465. return this.tsParseEnumDeclaration(this.startNode());
  11466. }
  11467. if (this.isContextual(129)) {
  11468. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11469. if (result) return result;
  11470. }
  11471. return super.parseStatementContent(flags, decorators);
  11472. }
  11473. parseAccessModifier() {
  11474. return this.tsParseModifier(["public", "protected", "private"]);
  11475. }
  11476. tsHasSomeModifiers(member, modifiers) {
  11477. return modifiers.some(modifier => {
  11478. if (tsIsAccessModifier(modifier)) {
  11479. return member.accessibility === modifier;
  11480. }
  11481. return !!member[modifier];
  11482. });
  11483. }
  11484. tsIsStartOfStaticBlocks() {
  11485. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11486. }
  11487. parseClassMember(classBody, member, state) {
  11488. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11489. this.tsParseModifiers({
  11490. allowedModifiers: modifiers,
  11491. disallowedModifiers: ["in", "out"],
  11492. stopOnStartOfClassStaticBlock: true,
  11493. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11494. }, member);
  11495. const callParseClassMemberWithIsStatic = () => {
  11496. if (this.tsIsStartOfStaticBlocks()) {
  11497. this.next();
  11498. this.next();
  11499. if (this.tsHasSomeModifiers(member, modifiers)) {
  11500. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11501. }
  11502. super.parseClassStaticBlock(classBody, member);
  11503. } else {
  11504. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11505. }
  11506. };
  11507. if (member.declare) {
  11508. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11509. } else {
  11510. callParseClassMemberWithIsStatic();
  11511. }
  11512. }
  11513. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11514. const idx = this.tsTryParseIndexSignature(member);
  11515. if (idx) {
  11516. classBody.body.push(idx);
  11517. if (member.abstract) {
  11518. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11519. }
  11520. if (member.accessibility) {
  11521. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11522. modifier: member.accessibility
  11523. });
  11524. }
  11525. if (member.declare) {
  11526. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  11527. }
  11528. if (member.override) {
  11529. this.raise(TSErrors.IndexSignatureHasOverride, member);
  11530. }
  11531. return;
  11532. }
  11533. if (!this.state.inAbstractClass && member.abstract) {
  11534. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  11535. }
  11536. if (member.override) {
  11537. if (!state.hadSuperClass) {
  11538. this.raise(TSErrors.OverrideNotInSubClass, member);
  11539. }
  11540. }
  11541. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  11542. }
  11543. parsePostMemberNameModifiers(methodOrProp) {
  11544. const optional = this.eat(17);
  11545. if (optional) methodOrProp.optional = true;
  11546. if (methodOrProp.readonly && this.match(10)) {
  11547. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  11548. }
  11549. if (methodOrProp.declare && this.match(10)) {
  11550. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  11551. }
  11552. }
  11553. parseExpressionStatement(node, expr, decorators) {
  11554. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  11555. return decl || super.parseExpressionStatement(node, expr, decorators);
  11556. }
  11557. shouldParseExportDeclaration() {
  11558. if (this.tsIsDeclarationStart()) return true;
  11559. return super.shouldParseExportDeclaration();
  11560. }
  11561. parseConditional(expr, startLoc, refExpressionErrors) {
  11562. if (!this.state.maybeInArrowParameters || !this.match(17)) {
  11563. return super.parseConditional(expr, startLoc, refExpressionErrors);
  11564. }
  11565. const result = this.tryParse(() => super.parseConditional(expr, startLoc));
  11566. if (!result.node) {
  11567. if (result.error) {
  11568. super.setOptionalParametersError(refExpressionErrors, result.error);
  11569. }
  11570. return expr;
  11571. }
  11572. if (result.error) this.state = result.failState;
  11573. return result.node;
  11574. }
  11575. parseParenItem(node, startLoc) {
  11576. node = super.parseParenItem(node, startLoc);
  11577. if (this.eat(17)) {
  11578. node.optional = true;
  11579. this.resetEndLocation(node);
  11580. }
  11581. if (this.match(14)) {
  11582. const typeCastNode = this.startNodeAt(startLoc);
  11583. typeCastNode.expression = node;
  11584. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  11585. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  11586. }
  11587. return node;
  11588. }
  11589. parseExportDeclaration(node) {
  11590. if (!this.state.isAmbientContext && this.isContextual(125)) {
  11591. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  11592. }
  11593. const startLoc = this.state.startLoc;
  11594. const isDeclare = this.eatContextual(125);
  11595. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  11596. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  11597. }
  11598. const isIdentifier = tokenIsIdentifier(this.state.type);
  11599. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  11600. if (!declaration) return null;
  11601. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  11602. node.exportKind = "type";
  11603. }
  11604. if (isDeclare) {
  11605. this.resetStartLocation(declaration, startLoc);
  11606. declaration.declare = true;
  11607. }
  11608. return declaration;
  11609. }
  11610. parseClassId(node, isStatement, optionalId, bindingType) {
  11611. if ((!isStatement || optionalId) && this.isContextual(113)) {
  11612. return;
  11613. }
  11614. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  11615. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11616. if (typeParameters) node.typeParameters = typeParameters;
  11617. }
  11618. parseClassPropertyAnnotation(node) {
  11619. if (!node.optional) {
  11620. if (this.eat(35)) {
  11621. node.definite = true;
  11622. } else if (this.eat(17)) {
  11623. node.optional = true;
  11624. }
  11625. }
  11626. const type = this.tsTryParseTypeAnnotation();
  11627. if (type) node.typeAnnotation = type;
  11628. }
  11629. parseClassProperty(node) {
  11630. this.parseClassPropertyAnnotation(node);
  11631. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  11632. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  11633. }
  11634. if (node.abstract && this.match(29)) {
  11635. const {
  11636. key
  11637. } = node;
  11638. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  11639. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  11640. });
  11641. }
  11642. return super.parseClassProperty(node);
  11643. }
  11644. parseClassPrivateProperty(node) {
  11645. if (node.abstract) {
  11646. this.raise(TSErrors.PrivateElementHasAbstract, node);
  11647. }
  11648. if (node.accessibility) {
  11649. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  11650. modifier: node.accessibility
  11651. });
  11652. }
  11653. this.parseClassPropertyAnnotation(node);
  11654. return super.parseClassPrivateProperty(node);
  11655. }
  11656. parseClassAccessorProperty(node) {
  11657. this.parseClassPropertyAnnotation(node);
  11658. if (node.optional) {
  11659. this.raise(TSErrors.AccessorCannotBeOptional, node);
  11660. }
  11661. return super.parseClassAccessorProperty(node);
  11662. }
  11663. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  11664. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11665. if (typeParameters && isConstructor) {
  11666. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  11667. }
  11668. const {
  11669. declare = false,
  11670. kind
  11671. } = method;
  11672. if (declare && (kind === "get" || kind === "set")) {
  11673. this.raise(TSErrors.DeclareAccessor, method, {
  11674. kind
  11675. });
  11676. }
  11677. if (typeParameters) method.typeParameters = typeParameters;
  11678. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  11679. }
  11680. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  11681. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11682. if (typeParameters) method.typeParameters = typeParameters;
  11683. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  11684. }
  11685. declareClassPrivateMethodInScope(node, kind) {
  11686. if (node.type === "TSDeclareMethod") return;
  11687. if (node.type === "MethodDefinition" && !node.value.body) return;
  11688. super.declareClassPrivateMethodInScope(node, kind);
  11689. }
  11690. parseClassSuper(node) {
  11691. super.parseClassSuper(node);
  11692. if (node.superClass && (this.match(47) || this.match(51))) {
  11693. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  11694. }
  11695. if (this.eatContextual(113)) {
  11696. node.implements = this.tsParseHeritageClause("implements");
  11697. }
  11698. }
  11699. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  11700. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11701. if (typeParameters) prop.typeParameters = typeParameters;
  11702. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  11703. }
  11704. parseFunctionParams(node, isConstructor) {
  11705. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11706. if (typeParameters) node.typeParameters = typeParameters;
  11707. super.parseFunctionParams(node, isConstructor);
  11708. }
  11709. parseVarId(decl, kind) {
  11710. super.parseVarId(decl, kind);
  11711. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  11712. decl.definite = true;
  11713. }
  11714. const type = this.tsTryParseTypeAnnotation();
  11715. if (type) {
  11716. decl.id.typeAnnotation = type;
  11717. this.resetEndLocation(decl.id);
  11718. }
  11719. }
  11720. parseAsyncArrowFromCallExpression(node, call) {
  11721. if (this.match(14)) {
  11722. node.returnType = this.tsParseTypeAnnotation();
  11723. }
  11724. return super.parseAsyncArrowFromCallExpression(node, call);
  11725. }
  11726. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  11727. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  11728. let state;
  11729. let jsx;
  11730. let typeCast;
  11731. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  11732. state = this.state.clone();
  11733. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11734. if (!jsx.error) return jsx.node;
  11735. const {
  11736. context
  11737. } = this.state;
  11738. const currentContext = context[context.length - 1];
  11739. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  11740. context.pop();
  11741. }
  11742. }
  11743. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  11744. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11745. }
  11746. if (!state || state === this.state) state = this.state.clone();
  11747. let typeParameters;
  11748. const arrow = this.tryParse(abort => {
  11749. var _expr$extra, _typeParameters;
  11750. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11751. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11752. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  11753. abort();
  11754. }
  11755. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  11756. this.resetStartLocationFromNode(expr, typeParameters);
  11757. }
  11758. expr.typeParameters = typeParameters;
  11759. return expr;
  11760. }, state);
  11761. if (!arrow.error && !arrow.aborted) {
  11762. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11763. return arrow.node;
  11764. }
  11765. if (!jsx) {
  11766. assert$1(!this.hasPlugin("jsx"));
  11767. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11768. if (!typeCast.error) return typeCast.node;
  11769. }
  11770. if ((_jsx2 = jsx) != null && _jsx2.node) {
  11771. this.state = jsx.failState;
  11772. return jsx.node;
  11773. }
  11774. if (arrow.node) {
  11775. this.state = arrow.failState;
  11776. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11777. return arrow.node;
  11778. }
  11779. if ((_typeCast = typeCast) != null && _typeCast.node) {
  11780. this.state = typeCast.failState;
  11781. return typeCast.node;
  11782. }
  11783. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  11784. }
  11785. reportReservedArrowTypeParam(node) {
  11786. var _node$extra;
  11787. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11788. this.raise(TSErrors.ReservedArrowTypeParam, node);
  11789. }
  11790. }
  11791. parseMaybeUnary(refExpressionErrors, sawUnary) {
  11792. if (!this.hasPlugin("jsx") && this.match(47)) {
  11793. return this.tsParseTypeAssertion();
  11794. }
  11795. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  11796. }
  11797. parseArrow(node) {
  11798. if (this.match(14)) {
  11799. const result = this.tryParse(abort => {
  11800. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11801. if (this.canInsertSemicolon() || !this.match(19)) abort();
  11802. return returnType;
  11803. });
  11804. if (result.aborted) return;
  11805. if (!result.thrown) {
  11806. if (result.error) this.state = result.failState;
  11807. node.returnType = result.node;
  11808. }
  11809. }
  11810. return super.parseArrow(node);
  11811. }
  11812. parseAssignableListItemTypes(param, flags) {
  11813. if (!(flags & 2)) return param;
  11814. if (this.eat(17)) {
  11815. param.optional = true;
  11816. }
  11817. const type = this.tsTryParseTypeAnnotation();
  11818. if (type) param.typeAnnotation = type;
  11819. this.resetEndLocation(param);
  11820. return param;
  11821. }
  11822. isAssignable(node, isBinding) {
  11823. switch (node.type) {
  11824. case "TSTypeCastExpression":
  11825. return this.isAssignable(node.expression, isBinding);
  11826. case "TSParameterProperty":
  11827. return true;
  11828. default:
  11829. return super.isAssignable(node, isBinding);
  11830. }
  11831. }
  11832. toAssignable(node, isLHS = false) {
  11833. switch (node.type) {
  11834. case "ParenthesizedExpression":
  11835. this.toAssignableParenthesizedExpression(node, isLHS);
  11836. break;
  11837. case "TSAsExpression":
  11838. case "TSSatisfiesExpression":
  11839. case "TSNonNullExpression":
  11840. case "TSTypeAssertion":
  11841. if (isLHS) {
  11842. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  11843. } else {
  11844. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  11845. }
  11846. this.toAssignable(node.expression, isLHS);
  11847. break;
  11848. case "AssignmentExpression":
  11849. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  11850. node.left = this.typeCastToParameter(node.left);
  11851. }
  11852. default:
  11853. super.toAssignable(node, isLHS);
  11854. }
  11855. }
  11856. toAssignableParenthesizedExpression(node, isLHS) {
  11857. switch (node.expression.type) {
  11858. case "TSAsExpression":
  11859. case "TSSatisfiesExpression":
  11860. case "TSNonNullExpression":
  11861. case "TSTypeAssertion":
  11862. case "ParenthesizedExpression":
  11863. this.toAssignable(node.expression, isLHS);
  11864. break;
  11865. default:
  11866. super.toAssignable(node, isLHS);
  11867. }
  11868. }
  11869. checkToRestConversion(node, allowPattern) {
  11870. switch (node.type) {
  11871. case "TSAsExpression":
  11872. case "TSSatisfiesExpression":
  11873. case "TSTypeAssertion":
  11874. case "TSNonNullExpression":
  11875. this.checkToRestConversion(node.expression, false);
  11876. break;
  11877. default:
  11878. super.checkToRestConversion(node, allowPattern);
  11879. }
  11880. }
  11881. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  11882. return getOwn({
  11883. TSTypeCastExpression: true,
  11884. TSParameterProperty: "parameter",
  11885. TSNonNullExpression: "expression",
  11886. TSAsExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11887. TSSatisfiesExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11888. TSTypeAssertion: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true]
  11889. }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  11890. }
  11891. parseBindingAtom() {
  11892. if (this.state.type === 78) {
  11893. return this.parseIdentifier(true);
  11894. }
  11895. return super.parseBindingAtom();
  11896. }
  11897. parseMaybeDecoratorArguments(expr) {
  11898. if (this.match(47) || this.match(51)) {
  11899. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11900. if (this.match(10)) {
  11901. const call = super.parseMaybeDecoratorArguments(expr);
  11902. call.typeParameters = typeArguments;
  11903. return call;
  11904. }
  11905. this.unexpected(null, 10);
  11906. }
  11907. return super.parseMaybeDecoratorArguments(expr);
  11908. }
  11909. checkCommaAfterRest(close) {
  11910. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  11911. this.next();
  11912. return false;
  11913. }
  11914. return super.checkCommaAfterRest(close);
  11915. }
  11916. isClassMethod() {
  11917. return this.match(47) || super.isClassMethod();
  11918. }
  11919. isClassProperty() {
  11920. return this.match(35) || this.match(14) || super.isClassProperty();
  11921. }
  11922. parseMaybeDefault(startLoc, left) {
  11923. const node = super.parseMaybeDefault(startLoc, left);
  11924. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  11925. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  11926. }
  11927. return node;
  11928. }
  11929. getTokenFromCode(code) {
  11930. if (this.state.inType) {
  11931. if (code === 62) {
  11932. this.finishOp(48, 1);
  11933. return;
  11934. }
  11935. if (code === 60) {
  11936. this.finishOp(47, 1);
  11937. return;
  11938. }
  11939. }
  11940. super.getTokenFromCode(code);
  11941. }
  11942. reScan_lt_gt() {
  11943. const {
  11944. type
  11945. } = this.state;
  11946. if (type === 47) {
  11947. this.state.pos -= 1;
  11948. this.readToken_lt();
  11949. } else if (type === 48) {
  11950. this.state.pos -= 1;
  11951. this.readToken_gt();
  11952. }
  11953. }
  11954. reScan_lt() {
  11955. const {
  11956. type
  11957. } = this.state;
  11958. if (type === 51) {
  11959. this.state.pos -= 2;
  11960. this.finishOp(47, 1);
  11961. return 47;
  11962. }
  11963. return type;
  11964. }
  11965. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  11966. for (let i = 0; i < exprList.length; i++) {
  11967. const expr = exprList[i];
  11968. if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
  11969. exprList[i] = this.typeCastToParameter(expr);
  11970. }
  11971. }
  11972. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  11973. }
  11974. typeCastToParameter(node) {
  11975. node.expression.typeAnnotation = node.typeAnnotation;
  11976. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  11977. return node.expression;
  11978. }
  11979. shouldParseArrow(params) {
  11980. if (this.match(14)) {
  11981. return params.every(expr => this.isAssignable(expr, true));
  11982. }
  11983. return super.shouldParseArrow(params);
  11984. }
  11985. shouldParseAsyncArrow() {
  11986. return this.match(14) || super.shouldParseAsyncArrow();
  11987. }
  11988. canHaveLeadingDecorator() {
  11989. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  11990. }
  11991. jsxParseOpeningElementAfterName(node) {
  11992. if (this.match(47) || this.match(51)) {
  11993. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  11994. if (typeArguments) node.typeParameters = typeArguments;
  11995. }
  11996. return super.jsxParseOpeningElementAfterName(node);
  11997. }
  11998. getGetterSetterExpectedParamCount(method) {
  11999. const baseCount = super.getGetterSetterExpectedParamCount(method);
  12000. const params = this.getObjectOrClassMethodParams(method);
  12001. const firstParam = params[0];
  12002. const hasContextParam = firstParam && this.isThisParam(firstParam);
  12003. return hasContextParam ? baseCount + 1 : baseCount;
  12004. }
  12005. parseCatchClauseParam() {
  12006. const param = super.parseCatchClauseParam();
  12007. const type = this.tsTryParseTypeAnnotation();
  12008. if (type) {
  12009. param.typeAnnotation = type;
  12010. this.resetEndLocation(param);
  12011. }
  12012. return param;
  12013. }
  12014. tsInAmbientContext(cb) {
  12015. const oldIsAmbientContext = this.state.isAmbientContext;
  12016. this.state.isAmbientContext = true;
  12017. try {
  12018. return cb();
  12019. } finally {
  12020. this.state.isAmbientContext = oldIsAmbientContext;
  12021. }
  12022. }
  12023. parseClass(node, isStatement, optionalId) {
  12024. const oldInAbstractClass = this.state.inAbstractClass;
  12025. this.state.inAbstractClass = !!node.abstract;
  12026. try {
  12027. return super.parseClass(node, isStatement, optionalId);
  12028. } finally {
  12029. this.state.inAbstractClass = oldInAbstractClass;
  12030. }
  12031. }
  12032. tsParseAbstractDeclaration(node, decorators) {
  12033. if (this.match(80)) {
  12034. node.abstract = true;
  12035. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12036. } else if (this.isContextual(129)) {
  12037. if (!this.hasFollowingLineBreak()) {
  12038. node.abstract = true;
  12039. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node);
  12040. return this.tsParseInterfaceDeclaration(node);
  12041. }
  12042. } else {
  12043. this.unexpected(null, 80);
  12044. }
  12045. }
  12046. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12047. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12048. if (method.abstract) {
  12049. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  12050. if (hasBody) {
  12051. const {
  12052. key
  12053. } = method;
  12054. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12055. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  12056. });
  12057. }
  12058. }
  12059. return method;
  12060. }
  12061. tsParseTypeParameterName() {
  12062. const typeName = this.parseIdentifier();
  12063. return typeName.name;
  12064. }
  12065. shouldParseAsAmbientContext() {
  12066. return !!this.getPluginOption("typescript", "dts");
  12067. }
  12068. parse() {
  12069. if (this.shouldParseAsAmbientContext()) {
  12070. this.state.isAmbientContext = true;
  12071. }
  12072. return super.parse();
  12073. }
  12074. getExpression() {
  12075. if (this.shouldParseAsAmbientContext()) {
  12076. this.state.isAmbientContext = true;
  12077. }
  12078. return super.getExpression();
  12079. }
  12080. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12081. if (!isString && isMaybeTypeOnly) {
  12082. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12083. return this.finishNode(node, "ExportSpecifier");
  12084. }
  12085. node.exportKind = "value";
  12086. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12087. }
  12088. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12089. if (!importedIsString && isMaybeTypeOnly) {
  12090. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12091. return this.finishNode(specifier, "ImportSpecifier");
  12092. }
  12093. specifier.importKind = "value";
  12094. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12095. }
  12096. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12097. const leftOfAsKey = isImport ? "imported" : "local";
  12098. const rightOfAsKey = isImport ? "local" : "exported";
  12099. let leftOfAs = node[leftOfAsKey];
  12100. let rightOfAs;
  12101. let hasTypeSpecifier = false;
  12102. let canParseAsKeyword = true;
  12103. const loc = leftOfAs.loc.start;
  12104. if (this.isContextual(93)) {
  12105. const firstAs = this.parseIdentifier();
  12106. if (this.isContextual(93)) {
  12107. const secondAs = this.parseIdentifier();
  12108. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12109. hasTypeSpecifier = true;
  12110. leftOfAs = firstAs;
  12111. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12112. canParseAsKeyword = false;
  12113. } else {
  12114. rightOfAs = secondAs;
  12115. canParseAsKeyword = false;
  12116. }
  12117. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12118. canParseAsKeyword = false;
  12119. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12120. } else {
  12121. hasTypeSpecifier = true;
  12122. leftOfAs = firstAs;
  12123. }
  12124. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12125. hasTypeSpecifier = true;
  12126. if (isImport) {
  12127. leftOfAs = this.parseIdentifier(true);
  12128. if (!this.isContextual(93)) {
  12129. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12130. }
  12131. } else {
  12132. leftOfAs = this.parseModuleExportName();
  12133. }
  12134. }
  12135. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12136. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12137. }
  12138. node[leftOfAsKey] = leftOfAs;
  12139. node[rightOfAsKey] = rightOfAs;
  12140. const kindKey = isImport ? "importKind" : "exportKind";
  12141. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12142. if (canParseAsKeyword && this.eatContextual(93)) {
  12143. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12144. }
  12145. if (!node[rightOfAsKey]) {
  12146. node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]);
  12147. }
  12148. if (isImport) {
  12149. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12150. }
  12151. }
  12152. };
  12153. function isPossiblyLiteralEnum(expression) {
  12154. if (expression.type !== "MemberExpression") return false;
  12155. const {
  12156. computed,
  12157. property
  12158. } = expression;
  12159. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12160. return false;
  12161. }
  12162. return isUncomputedMemberExpressionChain(expression.object);
  12163. }
  12164. function isValidAmbientConstInitializer(expression, estree) {
  12165. var _expression$extra;
  12166. const {
  12167. type
  12168. } = expression;
  12169. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12170. return false;
  12171. }
  12172. if (estree) {
  12173. if (type === "Literal") {
  12174. const {
  12175. value
  12176. } = expression;
  12177. if (typeof value === "string" || typeof value === "boolean") {
  12178. return true;
  12179. }
  12180. }
  12181. } else {
  12182. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12183. return true;
  12184. }
  12185. }
  12186. if (isNumber$1(expression, estree) || isNegativeNumber(expression, estree)) {
  12187. return true;
  12188. }
  12189. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12190. return true;
  12191. }
  12192. if (isPossiblyLiteralEnum(expression)) {
  12193. return true;
  12194. }
  12195. return false;
  12196. }
  12197. function isNumber$1(expression, estree) {
  12198. if (estree) {
  12199. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12200. }
  12201. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12202. }
  12203. function isNegativeNumber(expression, estree) {
  12204. if (expression.type === "UnaryExpression") {
  12205. const {
  12206. operator,
  12207. argument
  12208. } = expression;
  12209. if (operator === "-" && isNumber$1(argument, estree)) {
  12210. return true;
  12211. }
  12212. }
  12213. return false;
  12214. }
  12215. function isUncomputedMemberExpressionChain(expression) {
  12216. if (expression.type === "Identifier") return true;
  12217. if (expression.type !== "MemberExpression" || expression.computed) {
  12218. return false;
  12219. }
  12220. return isUncomputedMemberExpressionChain(expression.object);
  12221. }
  12222. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12223. ClassNameIsRequired: "A class name is required.",
  12224. UnexpectedSpace: "Unexpected space in placeholder."
  12225. });
  12226. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12227. parsePlaceholder(expectedNode) {
  12228. if (this.match(144)) {
  12229. const node = this.startNode();
  12230. this.next();
  12231. this.assertNoSpace();
  12232. node.name = super.parseIdentifier(true);
  12233. this.assertNoSpace();
  12234. this.expect(144);
  12235. return this.finishPlaceholder(node, expectedNode);
  12236. }
  12237. }
  12238. finishPlaceholder(node, expectedNode) {
  12239. const isFinished = !!(node.expectedNode && node.type === "Placeholder");
  12240. node.expectedNode = expectedNode;
  12241. return isFinished ? node : this.finishNode(node, "Placeholder");
  12242. }
  12243. getTokenFromCode(code) {
  12244. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12245. this.finishOp(144, 2);
  12246. } else {
  12247. super.getTokenFromCode(code);
  12248. }
  12249. }
  12250. parseExprAtom(refExpressionErrors) {
  12251. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12252. }
  12253. parseIdentifier(liberal) {
  12254. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12255. }
  12256. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12257. if (word !== undefined) {
  12258. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12259. }
  12260. }
  12261. parseBindingAtom() {
  12262. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12263. }
  12264. isValidLVal(type, isParenthesized, binding) {
  12265. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12266. }
  12267. toAssignable(node, isLHS) {
  12268. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12269. node.expectedNode = "Pattern";
  12270. } else {
  12271. super.toAssignable(node, isLHS);
  12272. }
  12273. }
  12274. chStartsBindingIdentifier(ch, pos) {
  12275. if (super.chStartsBindingIdentifier(ch, pos)) {
  12276. return true;
  12277. }
  12278. const nextToken = this.lookahead();
  12279. if (nextToken.type === 144) {
  12280. return true;
  12281. }
  12282. return false;
  12283. }
  12284. verifyBreakContinue(node, isBreak) {
  12285. if (node.label && node.label.type === "Placeholder") return;
  12286. super.verifyBreakContinue(node, isBreak);
  12287. }
  12288. parseExpressionStatement(node, expr) {
  12289. var _expr$extra;
  12290. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12291. return super.parseExpressionStatement(node, expr);
  12292. }
  12293. if (this.match(14)) {
  12294. const stmt = node;
  12295. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12296. this.next();
  12297. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12298. return this.finishNode(stmt, "LabeledStatement");
  12299. }
  12300. this.semicolon();
  12301. node.name = expr.name;
  12302. return this.finishPlaceholder(node, "Statement");
  12303. }
  12304. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12305. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12306. }
  12307. parseFunctionId(requireId) {
  12308. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12309. }
  12310. parseClass(node, isStatement, optionalId) {
  12311. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12312. this.next();
  12313. const oldStrict = this.state.strict;
  12314. const placeholder = this.parsePlaceholder("Identifier");
  12315. if (placeholder) {
  12316. if (this.match(81) || this.match(144) || this.match(5)) {
  12317. node.id = placeholder;
  12318. } else if (optionalId || !isStatement) {
  12319. node.id = null;
  12320. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12321. return this.finishNode(node, type);
  12322. } else {
  12323. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12324. }
  12325. } else {
  12326. this.parseClassId(node, isStatement, optionalId);
  12327. }
  12328. super.parseClassSuper(node);
  12329. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12330. return this.finishNode(node, type);
  12331. }
  12332. parseExport(node, decorators) {
  12333. const placeholder = this.parsePlaceholder("Identifier");
  12334. if (!placeholder) return super.parseExport(node, decorators);
  12335. if (!this.isContextual(98) && !this.match(12)) {
  12336. node.specifiers = [];
  12337. node.source = null;
  12338. node.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12339. return this.finishNode(node, "ExportNamedDeclaration");
  12340. }
  12341. this.expectPlugin("exportDefaultFrom");
  12342. const specifier = this.startNode();
  12343. specifier.exported = placeholder;
  12344. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12345. return super.parseExport(node, decorators);
  12346. }
  12347. isExportDefaultSpecifier() {
  12348. if (this.match(65)) {
  12349. const next = this.nextTokenStart();
  12350. if (this.isUnparsedContextual(next, "from")) {
  12351. if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
  12352. return true;
  12353. }
  12354. }
  12355. }
  12356. return super.isExportDefaultSpecifier();
  12357. }
  12358. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12359. var _specifiers;
  12360. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12361. return true;
  12362. }
  12363. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12364. }
  12365. checkExport(node) {
  12366. const {
  12367. specifiers
  12368. } = node;
  12369. if (specifiers != null && specifiers.length) {
  12370. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12371. }
  12372. super.checkExport(node);
  12373. node.specifiers = specifiers;
  12374. }
  12375. parseImport(node) {
  12376. const placeholder = this.parsePlaceholder("Identifier");
  12377. if (!placeholder) return super.parseImport(node);
  12378. node.specifiers = [];
  12379. if (!this.isContextual(98) && !this.match(12)) {
  12380. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12381. this.semicolon();
  12382. return this.finishNode(node, "ImportDeclaration");
  12383. }
  12384. const specifier = this.startNodeAtNode(placeholder);
  12385. specifier.local = placeholder;
  12386. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  12387. if (this.eat(12)) {
  12388. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  12389. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  12390. }
  12391. this.expectContextual(98);
  12392. node.source = this.parseImportSource();
  12393. this.semicolon();
  12394. return this.finishNode(node, "ImportDeclaration");
  12395. }
  12396. parseImportSource() {
  12397. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  12398. }
  12399. assertNoSpace() {
  12400. if (this.state.start > this.state.lastTokEndLoc.index) {
  12401. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  12402. }
  12403. }
  12404. };
  12405. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  12406. parseV8Intrinsic() {
  12407. if (this.match(54)) {
  12408. const v8IntrinsicStartLoc = this.state.startLoc;
  12409. const node = this.startNode();
  12410. this.next();
  12411. if (tokenIsIdentifier(this.state.type)) {
  12412. const name = this.parseIdentifierName();
  12413. const identifier = this.createIdentifier(node, name);
  12414. identifier.type = "V8IntrinsicIdentifier";
  12415. if (this.match(10)) {
  12416. return identifier;
  12417. }
  12418. }
  12419. this.unexpected(v8IntrinsicStartLoc);
  12420. }
  12421. }
  12422. parseExprAtom(refExpressionErrors) {
  12423. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  12424. }
  12425. };
  12426. function hasPlugin(plugins, expectedConfig) {
  12427. const [expectedName, expectedOptions] = typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig;
  12428. const expectedKeys = Object.keys(expectedOptions);
  12429. const expectedOptionsIsEmpty = expectedKeys.length === 0;
  12430. return plugins.some(p => {
  12431. if (typeof p === "string") {
  12432. return expectedOptionsIsEmpty && p === expectedName;
  12433. } else {
  12434. const [pluginName, pluginOptions] = p;
  12435. if (pluginName !== expectedName) {
  12436. return false;
  12437. }
  12438. for (const key of expectedKeys) {
  12439. if (pluginOptions[key] !== expectedOptions[key]) {
  12440. return false;
  12441. }
  12442. }
  12443. return true;
  12444. }
  12445. });
  12446. }
  12447. function getPluginOption(plugins, name, option) {
  12448. const plugin = plugins.find(plugin => {
  12449. if (Array.isArray(plugin)) {
  12450. return plugin[0] === name;
  12451. } else {
  12452. return plugin === name;
  12453. }
  12454. });
  12455. if (plugin && Array.isArray(plugin) && plugin.length > 1) {
  12456. return plugin[1][option];
  12457. }
  12458. return null;
  12459. }
  12460. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  12461. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  12462. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  12463. function validatePlugins(plugins) {
  12464. if (hasPlugin(plugins, "decorators")) {
  12465. if (hasPlugin(plugins, "decorators-legacy")) {
  12466. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  12467. }
  12468. const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
  12469. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  12470. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  12471. }
  12472. const allowCallParenthesized = getPluginOption(plugins, "decorators", "allowCallParenthesized");
  12473. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  12474. throw new Error("'allowCallParenthesized' must be a boolean.");
  12475. }
  12476. }
  12477. if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
  12478. throw new Error("Cannot combine flow and typescript plugins.");
  12479. }
  12480. if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
  12481. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  12482. }
  12483. if (hasPlugin(plugins, "pipelineOperator")) {
  12484. const proposal = getPluginOption(plugins, "pipelineOperator", "proposal");
  12485. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  12486. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  12487. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  12488. }
  12489. const tupleSyntaxIsHash = hasPlugin(plugins, ["recordAndTuple", {
  12490. syntaxType: "hash"
  12491. }]);
  12492. if (proposal === "hack") {
  12493. if (hasPlugin(plugins, "placeholders")) {
  12494. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  12495. }
  12496. if (hasPlugin(plugins, "v8intrinsic")) {
  12497. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  12498. }
  12499. const topicToken = getPluginOption(plugins, "pipelineOperator", "topicToken");
  12500. if (!TOPIC_TOKENS.includes(topicToken)) {
  12501. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  12502. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  12503. }
  12504. if (topicToken === "#" && tupleSyntaxIsHash) {
  12505. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  12506. }
  12507. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  12508. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  12509. }
  12510. }
  12511. if (hasPlugin(plugins, "moduleAttributes")) {
  12512. {
  12513. if (hasPlugin(plugins, "importAssertions") || hasPlugin(plugins, "importAttributes")) {
  12514. throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");
  12515. }
  12516. const moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
  12517. if (moduleAttributesVersionPluginOption !== "may-2020") {
  12518. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  12519. }
  12520. }
  12521. }
  12522. if (hasPlugin(plugins, "importAssertions") && hasPlugin(plugins, "importAttributes")) {
  12523. throw new Error("Cannot combine importAssertions and importAttributes plugins.");
  12524. }
  12525. if (hasPlugin(plugins, "recordAndTuple") && getPluginOption(plugins, "recordAndTuple", "syntaxType") != null && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) {
  12526. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  12527. }
  12528. if (hasPlugin(plugins, "asyncDoExpressions") && !hasPlugin(plugins, "doExpressions")) {
  12529. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  12530. error.missingPlugins = "doExpressions";
  12531. throw error;
  12532. }
  12533. if (hasPlugin(plugins, "optionalChainingAssign") && getPluginOption(plugins, "optionalChainingAssign", "version") !== "2023-07") {
  12534. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  12535. }
  12536. }
  12537. const mixinPlugins = {
  12538. estree,
  12539. jsx,
  12540. flow,
  12541. typescript,
  12542. v8intrinsic,
  12543. placeholders
  12544. };
  12545. const mixinPluginNames = Object.keys(mixinPlugins);
  12546. const defaultOptions = {
  12547. sourceType: "script",
  12548. sourceFilename: undefined,
  12549. startColumn: 0,
  12550. startLine: 1,
  12551. allowAwaitOutsideFunction: false,
  12552. allowReturnOutsideFunction: false,
  12553. allowNewTargetOutsideFunction: false,
  12554. allowImportExportEverywhere: false,
  12555. allowSuperOutsideMethod: false,
  12556. allowUndeclaredExports: false,
  12557. plugins: [],
  12558. strictMode: null,
  12559. ranges: false,
  12560. tokens: false,
  12561. createImportExpressions: false,
  12562. createParenthesizedExpressions: false,
  12563. errorRecovery: false,
  12564. attachComment: true,
  12565. annexB: true
  12566. };
  12567. function getOptions(opts) {
  12568. if (opts == null) {
  12569. return Object.assign({}, defaultOptions);
  12570. }
  12571. if (opts.annexB != null && opts.annexB !== false) {
  12572. throw new Error("The `annexB` option can only be set to `false`.");
  12573. }
  12574. const options = {};
  12575. for (const key of Object.keys(defaultOptions)) {
  12576. var _opts$key;
  12577. options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key];
  12578. }
  12579. return options;
  12580. }
  12581. class ExpressionParser extends LValParser {
  12582. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  12583. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  12584. return;
  12585. }
  12586. const key = prop.key;
  12587. const name = key.type === "Identifier" ? key.name : key.value;
  12588. if (name === "__proto__") {
  12589. if (isRecord) {
  12590. this.raise(Errors.RecordNoProto, key);
  12591. return;
  12592. }
  12593. if (protoRef.used) {
  12594. if (refExpressionErrors) {
  12595. if (refExpressionErrors.doubleProtoLoc === null) {
  12596. refExpressionErrors.doubleProtoLoc = key.loc.start;
  12597. }
  12598. } else {
  12599. this.raise(Errors.DuplicateProto, key);
  12600. }
  12601. }
  12602. protoRef.used = true;
  12603. }
  12604. }
  12605. shouldExitDescending(expr, potentialArrowAt) {
  12606. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  12607. }
  12608. getExpression() {
  12609. this.enterInitialScopes();
  12610. this.nextToken();
  12611. const expr = this.parseExpression();
  12612. if (!this.match(139)) {
  12613. this.unexpected();
  12614. }
  12615. this.finalizeRemainingComments();
  12616. expr.comments = this.comments;
  12617. expr.errors = this.state.errors;
  12618. if (this.options.tokens) {
  12619. expr.tokens = this.tokens;
  12620. }
  12621. return expr;
  12622. }
  12623. parseExpression(disallowIn, refExpressionErrors) {
  12624. if (disallowIn) {
  12625. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12626. }
  12627. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12628. }
  12629. parseExpressionBase(refExpressionErrors) {
  12630. const startLoc = this.state.startLoc;
  12631. const expr = this.parseMaybeAssign(refExpressionErrors);
  12632. if (this.match(12)) {
  12633. const node = this.startNodeAt(startLoc);
  12634. node.expressions = [expr];
  12635. while (this.eat(12)) {
  12636. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  12637. }
  12638. this.toReferencedList(node.expressions);
  12639. return this.finishNode(node, "SequenceExpression");
  12640. }
  12641. return expr;
  12642. }
  12643. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  12644. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12645. }
  12646. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  12647. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12648. }
  12649. setOptionalParametersError(refExpressionErrors, resultError) {
  12650. var _resultError$loc;
  12651. refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
  12652. }
  12653. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12654. const startLoc = this.state.startLoc;
  12655. if (this.isContextual(108)) {
  12656. if (this.prodParam.hasYield) {
  12657. let left = this.parseYield();
  12658. if (afterLeftParse) {
  12659. left = afterLeftParse.call(this, left, startLoc);
  12660. }
  12661. return left;
  12662. }
  12663. }
  12664. let ownExpressionErrors;
  12665. if (refExpressionErrors) {
  12666. ownExpressionErrors = false;
  12667. } else {
  12668. refExpressionErrors = new ExpressionErrors();
  12669. ownExpressionErrors = true;
  12670. }
  12671. const {
  12672. type
  12673. } = this.state;
  12674. if (type === 10 || tokenIsIdentifier(type)) {
  12675. this.state.potentialArrowAt = this.state.start;
  12676. }
  12677. let left = this.parseMaybeConditional(refExpressionErrors);
  12678. if (afterLeftParse) {
  12679. left = afterLeftParse.call(this, left, startLoc);
  12680. }
  12681. if (tokenIsAssignment(this.state.type)) {
  12682. const node = this.startNodeAt(startLoc);
  12683. const operator = this.state.value;
  12684. node.operator = operator;
  12685. if (this.match(29)) {
  12686. this.toAssignable(left, true);
  12687. node.left = left;
  12688. const startIndex = startLoc.index;
  12689. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  12690. refExpressionErrors.doubleProtoLoc = null;
  12691. }
  12692. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  12693. refExpressionErrors.shorthandAssignLoc = null;
  12694. }
  12695. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  12696. this.checkDestructuringPrivate(refExpressionErrors);
  12697. refExpressionErrors.privateKeyLoc = null;
  12698. }
  12699. } else {
  12700. node.left = left;
  12701. }
  12702. this.next();
  12703. node.right = this.parseMaybeAssign();
  12704. this.checkLVal(left, {
  12705. in: this.finishNode(node, "AssignmentExpression")
  12706. });
  12707. return node;
  12708. } else if (ownExpressionErrors) {
  12709. this.checkExpressionErrors(refExpressionErrors, true);
  12710. }
  12711. return left;
  12712. }
  12713. parseMaybeConditional(refExpressionErrors) {
  12714. const startLoc = this.state.startLoc;
  12715. const potentialArrowAt = this.state.potentialArrowAt;
  12716. const expr = this.parseExprOps(refExpressionErrors);
  12717. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12718. return expr;
  12719. }
  12720. return this.parseConditional(expr, startLoc, refExpressionErrors);
  12721. }
  12722. parseConditional(expr, startLoc, refExpressionErrors) {
  12723. if (this.eat(17)) {
  12724. const node = this.startNodeAt(startLoc);
  12725. node.test = expr;
  12726. node.consequent = this.parseMaybeAssignAllowIn();
  12727. this.expect(14);
  12728. node.alternate = this.parseMaybeAssign();
  12729. return this.finishNode(node, "ConditionalExpression");
  12730. }
  12731. return expr;
  12732. }
  12733. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  12734. return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  12735. }
  12736. parseExprOps(refExpressionErrors) {
  12737. const startLoc = this.state.startLoc;
  12738. const potentialArrowAt = this.state.potentialArrowAt;
  12739. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  12740. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12741. return expr;
  12742. }
  12743. return this.parseExprOp(expr, startLoc, -1);
  12744. }
  12745. parseExprOp(left, leftStartLoc, minPrec) {
  12746. if (this.isPrivateName(left)) {
  12747. const value = this.getPrivateNameSV(left);
  12748. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  12749. this.raise(Errors.PrivateInExpectedIn, left, {
  12750. identifierName: value
  12751. });
  12752. }
  12753. this.classScope.usePrivateName(value, left.loc.start);
  12754. }
  12755. const op = this.state.type;
  12756. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  12757. let prec = tokenOperatorPrecedence(op);
  12758. if (prec > minPrec) {
  12759. if (op === 39) {
  12760. this.expectPlugin("pipelineOperator");
  12761. if (this.state.inFSharpPipelineDirectBody) {
  12762. return left;
  12763. }
  12764. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  12765. }
  12766. const node = this.startNodeAt(leftStartLoc);
  12767. node.left = left;
  12768. node.operator = this.state.value;
  12769. const logical = op === 41 || op === 42;
  12770. const coalesce = op === 40;
  12771. if (coalesce) {
  12772. prec = tokenOperatorPrecedence(42);
  12773. }
  12774. this.next();
  12775. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  12776. proposal: "minimal"
  12777. }])) {
  12778. if (this.state.type === 96 && this.prodParam.hasAwait) {
  12779. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  12780. }
  12781. }
  12782. node.right = this.parseExprOpRightExpr(op, prec);
  12783. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  12784. const nextOp = this.state.type;
  12785. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  12786. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  12787. }
  12788. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  12789. }
  12790. }
  12791. return left;
  12792. }
  12793. parseExprOpRightExpr(op, prec) {
  12794. const startLoc = this.state.startLoc;
  12795. switch (op) {
  12796. case 39:
  12797. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  12798. case "hack":
  12799. return this.withTopicBindingContext(() => {
  12800. return this.parseHackPipeBody();
  12801. });
  12802. case "smart":
  12803. return this.withTopicBindingContext(() => {
  12804. if (this.prodParam.hasYield && this.isContextual(108)) {
  12805. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  12806. }
  12807. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  12808. });
  12809. case "fsharp":
  12810. return this.withSoloAwaitPermittingContext(() => {
  12811. return this.parseFSharpPipelineBody(prec);
  12812. });
  12813. }
  12814. default:
  12815. return this.parseExprOpBaseRightExpr(op, prec);
  12816. }
  12817. }
  12818. parseExprOpBaseRightExpr(op, prec) {
  12819. const startLoc = this.state.startLoc;
  12820. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  12821. }
  12822. parseHackPipeBody() {
  12823. var _body$extra;
  12824. const {
  12825. startLoc
  12826. } = this.state;
  12827. const body = this.parseMaybeAssign();
  12828. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  12829. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  12830. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  12831. type: body.type
  12832. });
  12833. }
  12834. if (!this.topicReferenceWasUsedInCurrentContext()) {
  12835. this.raise(Errors.PipeTopicUnused, startLoc);
  12836. }
  12837. return body;
  12838. }
  12839. checkExponentialAfterUnary(node) {
  12840. if (this.match(57)) {
  12841. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  12842. }
  12843. }
  12844. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12845. const startLoc = this.state.startLoc;
  12846. const isAwait = this.isContextual(96);
  12847. if (isAwait && this.isAwaitAllowed()) {
  12848. this.next();
  12849. const expr = this.parseAwait(startLoc);
  12850. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  12851. return expr;
  12852. }
  12853. const update = this.match(34);
  12854. const node = this.startNode();
  12855. if (tokenIsPrefix(this.state.type)) {
  12856. node.operator = this.state.value;
  12857. node.prefix = true;
  12858. if (this.match(72)) {
  12859. this.expectPlugin("throwExpressions");
  12860. }
  12861. const isDelete = this.match(89);
  12862. this.next();
  12863. node.argument = this.parseMaybeUnary(null, true);
  12864. this.checkExpressionErrors(refExpressionErrors, true);
  12865. if (this.state.strict && isDelete) {
  12866. const arg = node.argument;
  12867. if (arg.type === "Identifier") {
  12868. this.raise(Errors.StrictDelete, node);
  12869. } else if (this.hasPropertyAsPrivateName(arg)) {
  12870. this.raise(Errors.DeletePrivateField, node);
  12871. }
  12872. }
  12873. if (!update) {
  12874. if (!sawUnary) {
  12875. this.checkExponentialAfterUnary(node);
  12876. }
  12877. return this.finishNode(node, "UnaryExpression");
  12878. }
  12879. }
  12880. const expr = this.parseUpdate(node, update, refExpressionErrors);
  12881. if (isAwait) {
  12882. const {
  12883. type
  12884. } = this.state;
  12885. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  12886. if (startsExpr && !this.isAmbiguousAwait()) {
  12887. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  12888. return this.parseAwait(startLoc);
  12889. }
  12890. }
  12891. return expr;
  12892. }
  12893. parseUpdate(node, update, refExpressionErrors) {
  12894. if (update) {
  12895. const updateExpressionNode = node;
  12896. this.checkLVal(updateExpressionNode.argument, {
  12897. in: this.finishNode(updateExpressionNode, "UpdateExpression")
  12898. });
  12899. return node;
  12900. }
  12901. const startLoc = this.state.startLoc;
  12902. let expr = this.parseExprSubscripts(refExpressionErrors);
  12903. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  12904. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  12905. const node = this.startNodeAt(startLoc);
  12906. node.operator = this.state.value;
  12907. node.prefix = false;
  12908. node.argument = expr;
  12909. this.next();
  12910. this.checkLVal(expr, {
  12911. in: expr = this.finishNode(node, "UpdateExpression")
  12912. });
  12913. }
  12914. return expr;
  12915. }
  12916. parseExprSubscripts(refExpressionErrors) {
  12917. const startLoc = this.state.startLoc;
  12918. const potentialArrowAt = this.state.potentialArrowAt;
  12919. const expr = this.parseExprAtom(refExpressionErrors);
  12920. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12921. return expr;
  12922. }
  12923. return this.parseSubscripts(expr, startLoc);
  12924. }
  12925. parseSubscripts(base, startLoc, noCalls) {
  12926. const state = {
  12927. optionalChainMember: false,
  12928. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  12929. stop: false
  12930. };
  12931. do {
  12932. base = this.parseSubscript(base, startLoc, noCalls, state);
  12933. state.maybeAsyncArrow = false;
  12934. } while (!state.stop);
  12935. return base;
  12936. }
  12937. parseSubscript(base, startLoc, noCalls, state) {
  12938. const {
  12939. type
  12940. } = this.state;
  12941. if (!noCalls && type === 15) {
  12942. return this.parseBind(base, startLoc, noCalls, state);
  12943. } else if (tokenIsTemplate(type)) {
  12944. return this.parseTaggedTemplateExpression(base, startLoc, state);
  12945. }
  12946. let optional = false;
  12947. if (type === 18) {
  12948. if (noCalls) {
  12949. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  12950. if (this.lookaheadCharCode() === 40) {
  12951. state.stop = true;
  12952. return base;
  12953. }
  12954. }
  12955. state.optionalChainMember = optional = true;
  12956. this.next();
  12957. }
  12958. if (!noCalls && this.match(10)) {
  12959. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  12960. } else {
  12961. const computed = this.eat(0);
  12962. if (computed || optional || this.eat(16)) {
  12963. return this.parseMember(base, startLoc, state, computed, optional);
  12964. } else {
  12965. state.stop = true;
  12966. return base;
  12967. }
  12968. }
  12969. }
  12970. parseMember(base, startLoc, state, computed, optional) {
  12971. const node = this.startNodeAt(startLoc);
  12972. node.object = base;
  12973. node.computed = computed;
  12974. if (computed) {
  12975. node.property = this.parseExpression();
  12976. this.expect(3);
  12977. } else if (this.match(138)) {
  12978. if (base.type === "Super") {
  12979. this.raise(Errors.SuperPrivateField, startLoc);
  12980. }
  12981. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  12982. node.property = this.parsePrivateName();
  12983. } else {
  12984. node.property = this.parseIdentifier(true);
  12985. }
  12986. if (state.optionalChainMember) {
  12987. node.optional = optional;
  12988. return this.finishNode(node, "OptionalMemberExpression");
  12989. } else {
  12990. return this.finishNode(node, "MemberExpression");
  12991. }
  12992. }
  12993. parseBind(base, startLoc, noCalls, state) {
  12994. const node = this.startNodeAt(startLoc);
  12995. node.object = base;
  12996. this.next();
  12997. node.callee = this.parseNoCallExpr();
  12998. state.stop = true;
  12999. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  13000. }
  13001. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13002. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13003. let refExpressionErrors = null;
  13004. this.state.maybeInArrowParameters = true;
  13005. this.next();
  13006. const node = this.startNodeAt(startLoc);
  13007. node.callee = base;
  13008. const {
  13009. maybeAsyncArrow,
  13010. optionalChainMember
  13011. } = state;
  13012. if (maybeAsyncArrow) {
  13013. this.expressionScope.enter(newAsyncArrowScope());
  13014. refExpressionErrors = new ExpressionErrors();
  13015. }
  13016. if (optionalChainMember) {
  13017. node.optional = optional;
  13018. }
  13019. if (optional) {
  13020. node.arguments = this.parseCallExpressionArguments(11);
  13021. } else {
  13022. node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  13023. }
  13024. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13025. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13026. state.stop = true;
  13027. this.checkDestructuringPrivate(refExpressionErrors);
  13028. this.expressionScope.validateAsPattern();
  13029. this.expressionScope.exit();
  13030. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13031. } else {
  13032. if (maybeAsyncArrow) {
  13033. this.checkExpressionErrors(refExpressionErrors, true);
  13034. this.expressionScope.exit();
  13035. }
  13036. this.toReferencedArguments(finishedNode);
  13037. }
  13038. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13039. return finishedNode;
  13040. }
  13041. toReferencedArguments(node, isParenthesizedExpr) {
  13042. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13043. }
  13044. parseTaggedTemplateExpression(base, startLoc, state) {
  13045. const node = this.startNodeAt(startLoc);
  13046. node.tag = base;
  13047. node.quasi = this.parseTemplate(true);
  13048. if (state.optionalChainMember) {
  13049. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13050. }
  13051. return this.finishNode(node, "TaggedTemplateExpression");
  13052. }
  13053. atPossibleAsyncArrow(base) {
  13054. 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;
  13055. }
  13056. expectImportAttributesPlugin() {
  13057. if (!this.hasPlugin("importAssertions")) {
  13058. this.expectPlugin("importAttributes");
  13059. }
  13060. }
  13061. finishCallExpression(node, optional) {
  13062. if (node.callee.type === "Import") {
  13063. if (node.arguments.length === 2) {
  13064. {
  13065. if (!this.hasPlugin("moduleAttributes")) {
  13066. this.expectImportAttributesPlugin();
  13067. }
  13068. }
  13069. }
  13070. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13071. this.raise(Errors.ImportCallArity, node, {
  13072. maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1
  13073. });
  13074. } else {
  13075. for (const arg of node.arguments) {
  13076. if (arg.type === "SpreadElement") {
  13077. this.raise(Errors.ImportCallSpreadArgument, arg);
  13078. }
  13079. }
  13080. }
  13081. }
  13082. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13083. }
  13084. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13085. const elts = [];
  13086. let first = true;
  13087. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13088. this.state.inFSharpPipelineDirectBody = false;
  13089. while (!this.eat(close)) {
  13090. if (first) {
  13091. first = false;
  13092. } else {
  13093. this.expect(12);
  13094. if (this.match(close)) {
  13095. if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  13096. this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc);
  13097. }
  13098. if (nodeForExtra) {
  13099. this.addTrailingCommaExtraToNode(nodeForExtra);
  13100. }
  13101. this.next();
  13102. break;
  13103. }
  13104. }
  13105. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  13106. }
  13107. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13108. return elts;
  13109. }
  13110. shouldParseAsyncArrow() {
  13111. return this.match(19) && !this.canInsertSemicolon();
  13112. }
  13113. parseAsyncArrowFromCallExpression(node, call) {
  13114. var _call$extra;
  13115. this.resetPreviousNodeTrailingComments(call);
  13116. this.expect(19);
  13117. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13118. if (call.innerComments) {
  13119. setInnerComments(node, call.innerComments);
  13120. }
  13121. if (call.callee.trailingComments) {
  13122. setInnerComments(node, call.callee.trailingComments);
  13123. }
  13124. return node;
  13125. }
  13126. parseNoCallExpr() {
  13127. const startLoc = this.state.startLoc;
  13128. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13129. }
  13130. parseExprAtom(refExpressionErrors) {
  13131. let node;
  13132. let decorators = null;
  13133. const {
  13134. type
  13135. } = this.state;
  13136. switch (type) {
  13137. case 79:
  13138. return this.parseSuper();
  13139. case 83:
  13140. node = this.startNode();
  13141. this.next();
  13142. if (this.match(16)) {
  13143. return this.parseImportMetaProperty(node);
  13144. }
  13145. if (this.match(10)) {
  13146. if (this.options.createImportExpressions) {
  13147. return this.parseImportCall(node);
  13148. } else {
  13149. return this.finishNode(node, "Import");
  13150. }
  13151. } else {
  13152. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13153. return this.finishNode(node, "Import");
  13154. }
  13155. case 78:
  13156. node = this.startNode();
  13157. this.next();
  13158. return this.finishNode(node, "ThisExpression");
  13159. case 90:
  13160. {
  13161. return this.parseDo(this.startNode(), false);
  13162. }
  13163. case 56:
  13164. case 31:
  13165. {
  13166. this.readRegexp();
  13167. return this.parseRegExpLiteral(this.state.value);
  13168. }
  13169. case 134:
  13170. return this.parseNumericLiteral(this.state.value);
  13171. case 135:
  13172. return this.parseBigIntLiteral(this.state.value);
  13173. case 136:
  13174. return this.parseDecimalLiteral(this.state.value);
  13175. case 133:
  13176. return this.parseStringLiteral(this.state.value);
  13177. case 84:
  13178. return this.parseNullLiteral();
  13179. case 85:
  13180. return this.parseBooleanLiteral(true);
  13181. case 86:
  13182. return this.parseBooleanLiteral(false);
  13183. case 10:
  13184. {
  13185. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13186. return this.parseParenAndDistinguishExpression(canBeArrow);
  13187. }
  13188. case 2:
  13189. case 1:
  13190. {
  13191. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13192. }
  13193. case 0:
  13194. {
  13195. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13196. }
  13197. case 6:
  13198. case 7:
  13199. {
  13200. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13201. }
  13202. case 5:
  13203. {
  13204. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13205. }
  13206. case 68:
  13207. return this.parseFunctionOrFunctionSent();
  13208. case 26:
  13209. decorators = this.parseDecorators();
  13210. case 80:
  13211. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13212. case 77:
  13213. return this.parseNewOrNewTarget();
  13214. case 25:
  13215. case 24:
  13216. return this.parseTemplate(false);
  13217. case 15:
  13218. {
  13219. node = this.startNode();
  13220. this.next();
  13221. node.object = null;
  13222. const callee = node.callee = this.parseNoCallExpr();
  13223. if (callee.type === "MemberExpression") {
  13224. return this.finishNode(node, "BindExpression");
  13225. } else {
  13226. throw this.raise(Errors.UnsupportedBind, callee);
  13227. }
  13228. }
  13229. case 138:
  13230. {
  13231. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13232. identifierName: this.state.value
  13233. });
  13234. return this.parsePrivateName();
  13235. }
  13236. case 33:
  13237. {
  13238. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13239. }
  13240. case 32:
  13241. {
  13242. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13243. }
  13244. case 37:
  13245. case 38:
  13246. {
  13247. return this.parseTopicReference("hack");
  13248. }
  13249. case 44:
  13250. case 54:
  13251. case 27:
  13252. {
  13253. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13254. if (pipeProposal) {
  13255. return this.parseTopicReference(pipeProposal);
  13256. }
  13257. this.unexpected();
  13258. break;
  13259. }
  13260. case 47:
  13261. {
  13262. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13263. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13264. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13265. } else {
  13266. this.unexpected();
  13267. }
  13268. break;
  13269. }
  13270. default:
  13271. if (tokenIsIdentifier(type)) {
  13272. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13273. return this.parseModuleExpression();
  13274. }
  13275. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13276. const containsEsc = this.state.containsEsc;
  13277. const id = this.parseIdentifier();
  13278. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13279. const {
  13280. type
  13281. } = this.state;
  13282. if (type === 68) {
  13283. this.resetPreviousNodeTrailingComments(id);
  13284. this.next();
  13285. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13286. } else if (tokenIsIdentifier(type)) {
  13287. if (this.lookaheadCharCode() === 61) {
  13288. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13289. } else {
  13290. return id;
  13291. }
  13292. } else if (type === 90) {
  13293. this.resetPreviousNodeTrailingComments(id);
  13294. return this.parseDo(this.startNodeAtNode(id), true);
  13295. }
  13296. }
  13297. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13298. this.next();
  13299. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13300. }
  13301. return id;
  13302. } else {
  13303. this.unexpected();
  13304. }
  13305. }
  13306. }
  13307. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13308. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13309. if (pipeProposal) {
  13310. this.state.type = topicTokenType;
  13311. this.state.value = topicTokenValue;
  13312. this.state.pos--;
  13313. this.state.end--;
  13314. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13315. return this.parseTopicReference(pipeProposal);
  13316. } else {
  13317. this.unexpected();
  13318. }
  13319. }
  13320. parseTopicReference(pipeProposal) {
  13321. const node = this.startNode();
  13322. const startLoc = this.state.startLoc;
  13323. const tokenType = this.state.type;
  13324. this.next();
  13325. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13326. }
  13327. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13328. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13329. const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
  13330. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13331. this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc);
  13332. }
  13333. this.registerTopicReference();
  13334. return this.finishNode(node, nodeType);
  13335. } else {
  13336. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13337. token: tokenLabelName(tokenType)
  13338. });
  13339. }
  13340. }
  13341. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13342. switch (pipeProposal) {
  13343. case "hack":
  13344. {
  13345. return this.hasPlugin(["pipelineOperator", {
  13346. topicToken: tokenLabelName(tokenType)
  13347. }]);
  13348. }
  13349. case "smart":
  13350. return tokenType === 27;
  13351. default:
  13352. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13353. }
  13354. }
  13355. parseAsyncArrowUnaryFunction(node) {
  13356. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13357. const params = [this.parseIdentifier()];
  13358. this.prodParam.exit();
  13359. if (this.hasPrecedingLineBreak()) {
  13360. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13361. }
  13362. this.expect(19);
  13363. return this.parseArrowExpression(node, params, true);
  13364. }
  13365. parseDo(node, isAsync) {
  13366. this.expectPlugin("doExpressions");
  13367. if (isAsync) {
  13368. this.expectPlugin("asyncDoExpressions");
  13369. }
  13370. node.async = isAsync;
  13371. this.next();
  13372. const oldLabels = this.state.labels;
  13373. this.state.labels = [];
  13374. if (isAsync) {
  13375. this.prodParam.enter(2);
  13376. node.body = this.parseBlock();
  13377. this.prodParam.exit();
  13378. } else {
  13379. node.body = this.parseBlock();
  13380. }
  13381. this.state.labels = oldLabels;
  13382. return this.finishNode(node, "DoExpression");
  13383. }
  13384. parseSuper() {
  13385. const node = this.startNode();
  13386. this.next();
  13387. if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  13388. this.raise(Errors.SuperNotAllowed, node);
  13389. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  13390. this.raise(Errors.UnexpectedSuper, node);
  13391. }
  13392. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13393. this.raise(Errors.UnsupportedSuper, node);
  13394. }
  13395. return this.finishNode(node, "Super");
  13396. }
  13397. parsePrivateName() {
  13398. const node = this.startNode();
  13399. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13400. const name = this.state.value;
  13401. this.next();
  13402. node.id = this.createIdentifier(id, name);
  13403. return this.finishNode(node, "PrivateName");
  13404. }
  13405. parseFunctionOrFunctionSent() {
  13406. const node = this.startNode();
  13407. this.next();
  13408. if (this.prodParam.hasYield && this.match(16)) {
  13409. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13410. this.next();
  13411. if (this.match(103)) {
  13412. this.expectPlugin("functionSent");
  13413. } else if (!this.hasPlugin("functionSent")) {
  13414. this.unexpected();
  13415. }
  13416. return this.parseMetaProperty(node, meta, "sent");
  13417. }
  13418. return this.parseFunction(node);
  13419. }
  13420. parseMetaProperty(node, meta, propertyName) {
  13421. node.meta = meta;
  13422. const containsEsc = this.state.containsEsc;
  13423. node.property = this.parseIdentifier(true);
  13424. if (node.property.name !== propertyName || containsEsc) {
  13425. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13426. target: meta.name,
  13427. onlyValidPropertyName: propertyName
  13428. });
  13429. }
  13430. return this.finishNode(node, "MetaProperty");
  13431. }
  13432. parseImportMetaProperty(node) {
  13433. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  13434. this.next();
  13435. if (this.isContextual(101)) {
  13436. if (!this.inModule) {
  13437. this.raise(Errors.ImportMetaOutsideModule, id);
  13438. }
  13439. this.sawUnambiguousESM = true;
  13440. } else if (this.isContextual(105) || this.isContextual(97)) {
  13441. const isSource = this.isContextual(105);
  13442. if (!isSource) this.unexpected();
  13443. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  13444. if (!this.options.createImportExpressions) {
  13445. throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, {
  13446. phase: this.state.value
  13447. });
  13448. }
  13449. this.next();
  13450. node.phase = isSource ? "source" : "defer";
  13451. return this.parseImportCall(node);
  13452. }
  13453. return this.parseMetaProperty(node, id, "meta");
  13454. }
  13455. parseLiteralAtNode(value, type, node) {
  13456. this.addExtra(node, "rawValue", value);
  13457. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13458. node.value = value;
  13459. this.next();
  13460. return this.finishNode(node, type);
  13461. }
  13462. parseLiteral(value, type) {
  13463. const node = this.startNode();
  13464. return this.parseLiteralAtNode(value, type, node);
  13465. }
  13466. parseStringLiteral(value) {
  13467. return this.parseLiteral(value, "StringLiteral");
  13468. }
  13469. parseNumericLiteral(value) {
  13470. return this.parseLiteral(value, "NumericLiteral");
  13471. }
  13472. parseBigIntLiteral(value) {
  13473. return this.parseLiteral(value, "BigIntLiteral");
  13474. }
  13475. parseDecimalLiteral(value) {
  13476. return this.parseLiteral(value, "DecimalLiteral");
  13477. }
  13478. parseRegExpLiteral(value) {
  13479. const node = this.parseLiteral(value.value, "RegExpLiteral");
  13480. node.pattern = value.pattern;
  13481. node.flags = value.flags;
  13482. return node;
  13483. }
  13484. parseBooleanLiteral(value) {
  13485. const node = this.startNode();
  13486. node.value = value;
  13487. this.next();
  13488. return this.finishNode(node, "BooleanLiteral");
  13489. }
  13490. parseNullLiteral() {
  13491. const node = this.startNode();
  13492. this.next();
  13493. return this.finishNode(node, "NullLiteral");
  13494. }
  13495. parseParenAndDistinguishExpression(canBeArrow) {
  13496. const startLoc = this.state.startLoc;
  13497. let val;
  13498. this.next();
  13499. this.expressionScope.enter(newArrowHeadScope());
  13500. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13501. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13502. this.state.maybeInArrowParameters = true;
  13503. this.state.inFSharpPipelineDirectBody = false;
  13504. const innerStartLoc = this.state.startLoc;
  13505. const exprList = [];
  13506. const refExpressionErrors = new ExpressionErrors();
  13507. let first = true;
  13508. let spreadStartLoc;
  13509. let optionalCommaStartLoc;
  13510. while (!this.match(11)) {
  13511. if (first) {
  13512. first = false;
  13513. } else {
  13514. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  13515. if (this.match(11)) {
  13516. optionalCommaStartLoc = this.state.startLoc;
  13517. break;
  13518. }
  13519. }
  13520. if (this.match(21)) {
  13521. const spreadNodeStartLoc = this.state.startLoc;
  13522. spreadStartLoc = this.state.startLoc;
  13523. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  13524. if (!this.checkCommaAfterRest(41)) {
  13525. break;
  13526. }
  13527. } else {
  13528. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  13529. }
  13530. }
  13531. const innerEndLoc = this.state.lastTokEndLoc;
  13532. this.expect(11);
  13533. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13534. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13535. let arrowNode = this.startNodeAt(startLoc);
  13536. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  13537. this.checkDestructuringPrivate(refExpressionErrors);
  13538. this.expressionScope.validateAsPattern();
  13539. this.expressionScope.exit();
  13540. this.parseArrowExpression(arrowNode, exprList, false);
  13541. return arrowNode;
  13542. }
  13543. this.expressionScope.exit();
  13544. if (!exprList.length) {
  13545. this.unexpected(this.state.lastTokStartLoc);
  13546. }
  13547. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  13548. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  13549. this.checkExpressionErrors(refExpressionErrors, true);
  13550. this.toReferencedListDeep(exprList, true);
  13551. if (exprList.length > 1) {
  13552. val = this.startNodeAt(innerStartLoc);
  13553. val.expressions = exprList;
  13554. this.finishNode(val, "SequenceExpression");
  13555. this.resetEndLocation(val, innerEndLoc);
  13556. } else {
  13557. val = exprList[0];
  13558. }
  13559. return this.wrapParenthesis(startLoc, val);
  13560. }
  13561. wrapParenthesis(startLoc, expression) {
  13562. if (!this.options.createParenthesizedExpressions) {
  13563. this.addExtra(expression, "parenthesized", true);
  13564. this.addExtra(expression, "parenStart", startLoc.index);
  13565. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  13566. return expression;
  13567. }
  13568. const parenExpression = this.startNodeAt(startLoc);
  13569. parenExpression.expression = expression;
  13570. return this.finishNode(parenExpression, "ParenthesizedExpression");
  13571. }
  13572. shouldParseArrow(params) {
  13573. return !this.canInsertSemicolon();
  13574. }
  13575. parseArrow(node) {
  13576. if (this.eat(19)) {
  13577. return node;
  13578. }
  13579. }
  13580. parseParenItem(node, startLoc) {
  13581. return node;
  13582. }
  13583. parseNewOrNewTarget() {
  13584. const node = this.startNode();
  13585. this.next();
  13586. if (this.match(16)) {
  13587. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  13588. this.next();
  13589. const metaProp = this.parseMetaProperty(node, meta, "target");
  13590. if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) {
  13591. this.raise(Errors.UnexpectedNewTarget, metaProp);
  13592. }
  13593. return metaProp;
  13594. }
  13595. return this.parseNew(node);
  13596. }
  13597. parseNew(node) {
  13598. this.parseNewCallee(node);
  13599. if (this.eat(10)) {
  13600. const args = this.parseExprList(11);
  13601. this.toReferencedList(args);
  13602. node.arguments = args;
  13603. } else {
  13604. node.arguments = [];
  13605. }
  13606. return this.finishNode(node, "NewExpression");
  13607. }
  13608. parseNewCallee(node) {
  13609. const isImport = this.match(83);
  13610. const callee = this.parseNoCallExpr();
  13611. node.callee = callee;
  13612. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  13613. this.raise(Errors.ImportCallNotNewExpression, callee);
  13614. }
  13615. }
  13616. parseTemplateElement(isTagged) {
  13617. const {
  13618. start,
  13619. startLoc,
  13620. end,
  13621. value
  13622. } = this.state;
  13623. const elemStart = start + 1;
  13624. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  13625. if (value === null) {
  13626. if (!isTagged) {
  13627. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  13628. }
  13629. }
  13630. const isTail = this.match(24);
  13631. const endOffset = isTail ? -1 : -2;
  13632. const elemEnd = end + endOffset;
  13633. elem.value = {
  13634. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  13635. cooked: value === null ? null : value.slice(1, endOffset)
  13636. };
  13637. elem.tail = isTail;
  13638. this.next();
  13639. const finishedNode = this.finishNode(elem, "TemplateElement");
  13640. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  13641. return finishedNode;
  13642. }
  13643. parseTemplate(isTagged) {
  13644. const node = this.startNode();
  13645. node.expressions = [];
  13646. let curElt = this.parseTemplateElement(isTagged);
  13647. node.quasis = [curElt];
  13648. while (!curElt.tail) {
  13649. node.expressions.push(this.parseTemplateSubstitution());
  13650. this.readTemplateContinuation();
  13651. node.quasis.push(curElt = this.parseTemplateElement(isTagged));
  13652. }
  13653. return this.finishNode(node, "TemplateLiteral");
  13654. }
  13655. parseTemplateSubstitution() {
  13656. return this.parseExpression();
  13657. }
  13658. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  13659. if (isRecord) {
  13660. this.expectPlugin("recordAndTuple");
  13661. }
  13662. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13663. this.state.inFSharpPipelineDirectBody = false;
  13664. const propHash = Object.create(null);
  13665. let first = true;
  13666. const node = this.startNode();
  13667. node.properties = [];
  13668. this.next();
  13669. while (!this.match(close)) {
  13670. if (first) {
  13671. first = false;
  13672. } else {
  13673. this.expect(12);
  13674. if (this.match(close)) {
  13675. this.addTrailingCommaExtraToNode(node);
  13676. break;
  13677. }
  13678. }
  13679. let prop;
  13680. if (isPattern) {
  13681. prop = this.parseBindingProperty();
  13682. } else {
  13683. prop = this.parsePropertyDefinition(refExpressionErrors);
  13684. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  13685. }
  13686. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  13687. this.raise(Errors.InvalidRecordProperty, prop);
  13688. }
  13689. if (prop.shorthand) {
  13690. this.addExtra(prop, "shorthand", true);
  13691. }
  13692. node.properties.push(prop);
  13693. }
  13694. this.next();
  13695. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13696. let type = "ObjectExpression";
  13697. if (isPattern) {
  13698. type = "ObjectPattern";
  13699. } else if (isRecord) {
  13700. type = "RecordExpression";
  13701. }
  13702. return this.finishNode(node, type);
  13703. }
  13704. addTrailingCommaExtraToNode(node) {
  13705. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  13706. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  13707. }
  13708. maybeAsyncOrAccessorProp(prop) {
  13709. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  13710. }
  13711. parsePropertyDefinition(refExpressionErrors) {
  13712. let decorators = [];
  13713. if (this.match(26)) {
  13714. if (this.hasPlugin("decorators")) {
  13715. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  13716. }
  13717. while (this.match(26)) {
  13718. decorators.push(this.parseDecorator());
  13719. }
  13720. }
  13721. const prop = this.startNode();
  13722. let isAsync = false;
  13723. let isAccessor = false;
  13724. let startLoc;
  13725. if (this.match(21)) {
  13726. if (decorators.length) this.unexpected();
  13727. return this.parseSpread();
  13728. }
  13729. if (decorators.length) {
  13730. prop.decorators = decorators;
  13731. decorators = [];
  13732. }
  13733. prop.method = false;
  13734. if (refExpressionErrors) {
  13735. startLoc = this.state.startLoc;
  13736. }
  13737. let isGenerator = this.eat(55);
  13738. this.parsePropertyNamePrefixOperator(prop);
  13739. const containsEsc = this.state.containsEsc;
  13740. const key = this.parsePropertyName(prop, refExpressionErrors);
  13741. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  13742. const keyName = key.name;
  13743. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  13744. isAsync = true;
  13745. this.resetPreviousNodeTrailingComments(key);
  13746. isGenerator = this.eat(55);
  13747. this.parsePropertyName(prop);
  13748. }
  13749. if (keyName === "get" || keyName === "set") {
  13750. isAccessor = true;
  13751. this.resetPreviousNodeTrailingComments(key);
  13752. prop.kind = keyName;
  13753. if (this.match(55)) {
  13754. isGenerator = true;
  13755. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  13756. kind: keyName
  13757. });
  13758. this.next();
  13759. }
  13760. this.parsePropertyName(prop);
  13761. }
  13762. }
  13763. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  13764. }
  13765. getGetterSetterExpectedParamCount(method) {
  13766. return method.kind === "get" ? 0 : 1;
  13767. }
  13768. getObjectOrClassMethodParams(method) {
  13769. return method.params;
  13770. }
  13771. checkGetterSetterParams(method) {
  13772. var _params;
  13773. const paramCount = this.getGetterSetterExpectedParamCount(method);
  13774. const params = this.getObjectOrClassMethodParams(method);
  13775. if (params.length !== paramCount) {
  13776. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  13777. }
  13778. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  13779. this.raise(Errors.BadSetterRestParameter, method);
  13780. }
  13781. }
  13782. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  13783. if (isAccessor) {
  13784. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  13785. this.checkGetterSetterParams(finishedProp);
  13786. return finishedProp;
  13787. }
  13788. if (isAsync || isGenerator || this.match(10)) {
  13789. if (isPattern) this.unexpected();
  13790. prop.kind = "method";
  13791. prop.method = true;
  13792. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  13793. }
  13794. }
  13795. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  13796. prop.shorthand = false;
  13797. if (this.eat(14)) {
  13798. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  13799. return this.finishNode(prop, "ObjectProperty");
  13800. }
  13801. if (!prop.computed && prop.key.type === "Identifier") {
  13802. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  13803. if (isPattern) {
  13804. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13805. } else if (this.match(29)) {
  13806. const shorthandAssignLoc = this.state.startLoc;
  13807. if (refExpressionErrors != null) {
  13808. if (refExpressionErrors.shorthandAssignLoc === null) {
  13809. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  13810. }
  13811. } else {
  13812. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  13813. }
  13814. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13815. } else {
  13816. prop.value = cloneIdentifier(prop.key);
  13817. }
  13818. prop.shorthand = true;
  13819. return this.finishNode(prop, "ObjectProperty");
  13820. }
  13821. }
  13822. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  13823. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  13824. if (!node) this.unexpected();
  13825. return node;
  13826. }
  13827. parsePropertyName(prop, refExpressionErrors) {
  13828. if (this.eat(0)) {
  13829. prop.computed = true;
  13830. prop.key = this.parseMaybeAssignAllowIn();
  13831. this.expect(3);
  13832. } else {
  13833. const {
  13834. type,
  13835. value
  13836. } = this.state;
  13837. let key;
  13838. if (tokenIsKeywordOrIdentifier(type)) {
  13839. key = this.parseIdentifier(true);
  13840. } else {
  13841. switch (type) {
  13842. case 134:
  13843. key = this.parseNumericLiteral(value);
  13844. break;
  13845. case 133:
  13846. key = this.parseStringLiteral(value);
  13847. break;
  13848. case 135:
  13849. key = this.parseBigIntLiteral(value);
  13850. break;
  13851. case 136:
  13852. key = this.parseDecimalLiteral(value);
  13853. break;
  13854. case 138:
  13855. {
  13856. const privateKeyLoc = this.state.startLoc;
  13857. if (refExpressionErrors != null) {
  13858. if (refExpressionErrors.privateKeyLoc === null) {
  13859. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  13860. }
  13861. } else {
  13862. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  13863. }
  13864. key = this.parsePrivateName();
  13865. break;
  13866. }
  13867. default:
  13868. this.unexpected();
  13869. }
  13870. }
  13871. prop.key = key;
  13872. if (type !== 138) {
  13873. prop.computed = false;
  13874. }
  13875. }
  13876. return prop.key;
  13877. }
  13878. initFunction(node, isAsync) {
  13879. node.id = null;
  13880. node.generator = false;
  13881. node.async = isAsync;
  13882. }
  13883. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  13884. this.initFunction(node, isAsync);
  13885. node.generator = isGenerator;
  13886. this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
  13887. this.prodParam.enter(functionFlags(isAsync, node.generator));
  13888. this.parseFunctionParams(node, isConstructor);
  13889. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  13890. this.prodParam.exit();
  13891. this.scope.exit();
  13892. return finishedNode;
  13893. }
  13894. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  13895. if (isTuple) {
  13896. this.expectPlugin("recordAndTuple");
  13897. }
  13898. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13899. this.state.inFSharpPipelineDirectBody = false;
  13900. const node = this.startNode();
  13901. this.next();
  13902. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  13903. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13904. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  13905. }
  13906. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  13907. this.scope.enter(2 | 4);
  13908. let flags = functionFlags(isAsync, false);
  13909. if (!this.match(5) && this.prodParam.hasIn) {
  13910. flags |= 8;
  13911. }
  13912. this.prodParam.enter(flags);
  13913. this.initFunction(node, isAsync);
  13914. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13915. if (params) {
  13916. this.state.maybeInArrowParameters = true;
  13917. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  13918. }
  13919. this.state.maybeInArrowParameters = false;
  13920. this.parseFunctionBody(node, true);
  13921. this.prodParam.exit();
  13922. this.scope.exit();
  13923. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13924. return this.finishNode(node, "ArrowFunctionExpression");
  13925. }
  13926. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  13927. this.toAssignableList(params, trailingCommaLoc, false);
  13928. node.params = params;
  13929. }
  13930. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  13931. this.parseFunctionBody(node, false, isMethod);
  13932. return this.finishNode(node, type);
  13933. }
  13934. parseFunctionBody(node, allowExpression, isMethod = false) {
  13935. const isExpression = allowExpression && !this.match(5);
  13936. this.expressionScope.enter(newExpressionScope());
  13937. if (isExpression) {
  13938. node.body = this.parseMaybeAssign();
  13939. this.checkParams(node, false, allowExpression, false);
  13940. } else {
  13941. const oldStrict = this.state.strict;
  13942. const oldLabels = this.state.labels;
  13943. this.state.labels = [];
  13944. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  13945. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  13946. const nonSimple = !this.isSimpleParamList(node.params);
  13947. if (hasStrictModeDirective && nonSimple) {
  13948. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  13949. }
  13950. const strictModeChanged = !oldStrict && this.state.strict;
  13951. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  13952. if (this.state.strict && node.id) {
  13953. this.checkIdentifier(node.id, 65, strictModeChanged);
  13954. }
  13955. });
  13956. this.prodParam.exit();
  13957. this.state.labels = oldLabels;
  13958. }
  13959. this.expressionScope.exit();
  13960. }
  13961. isSimpleParameter(node) {
  13962. return node.type === "Identifier";
  13963. }
  13964. isSimpleParamList(params) {
  13965. for (let i = 0, len = params.length; i < len; i++) {
  13966. if (!this.isSimpleParameter(params[i])) return false;
  13967. }
  13968. return true;
  13969. }
  13970. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  13971. const checkClashes = !allowDuplicates && new Set();
  13972. const formalParameters = {
  13973. type: "FormalParameters"
  13974. };
  13975. for (const param of node.params) {
  13976. this.checkLVal(param, {
  13977. in: formalParameters,
  13978. binding: 5,
  13979. checkClashes,
  13980. strictModeChanged
  13981. });
  13982. }
  13983. }
  13984. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  13985. const elts = [];
  13986. let first = true;
  13987. while (!this.eat(close)) {
  13988. if (first) {
  13989. first = false;
  13990. } else {
  13991. this.expect(12);
  13992. if (this.match(close)) {
  13993. if (nodeForExtra) {
  13994. this.addTrailingCommaExtraToNode(nodeForExtra);
  13995. }
  13996. this.next();
  13997. break;
  13998. }
  13999. }
  14000. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  14001. }
  14002. return elts;
  14003. }
  14004. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  14005. let elt;
  14006. if (this.match(12)) {
  14007. if (!allowEmpty) {
  14008. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14009. unexpected: ","
  14010. });
  14011. }
  14012. elt = null;
  14013. } else if (this.match(21)) {
  14014. const spreadNodeStartLoc = this.state.startLoc;
  14015. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14016. } else if (this.match(17)) {
  14017. this.expectPlugin("partialApplication");
  14018. if (!allowPlaceholder) {
  14019. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14020. }
  14021. const node = this.startNode();
  14022. this.next();
  14023. elt = this.finishNode(node, "ArgumentPlaceholder");
  14024. } else {
  14025. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  14026. }
  14027. return elt;
  14028. }
  14029. parseIdentifier(liberal) {
  14030. const node = this.startNode();
  14031. const name = this.parseIdentifierName(liberal);
  14032. return this.createIdentifier(node, name);
  14033. }
  14034. createIdentifier(node, name) {
  14035. node.name = name;
  14036. node.loc.identifierName = name;
  14037. return this.finishNode(node, "Identifier");
  14038. }
  14039. parseIdentifierName(liberal) {
  14040. let name;
  14041. const {
  14042. startLoc,
  14043. type
  14044. } = this.state;
  14045. if (tokenIsKeywordOrIdentifier(type)) {
  14046. name = this.state.value;
  14047. } else {
  14048. this.unexpected();
  14049. }
  14050. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14051. if (liberal) {
  14052. if (tokenIsKeyword) {
  14053. this.replaceToken(132);
  14054. }
  14055. } else {
  14056. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14057. }
  14058. this.next();
  14059. return name;
  14060. }
  14061. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14062. if (word.length > 10) {
  14063. return;
  14064. }
  14065. if (!canBeReservedWord(word)) {
  14066. return;
  14067. }
  14068. if (checkKeywords && isKeyword(word)) {
  14069. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14070. keyword: word
  14071. });
  14072. return;
  14073. }
  14074. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14075. if (reservedTest(word, this.inModule)) {
  14076. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14077. reservedWord: word
  14078. });
  14079. return;
  14080. } else if (word === "yield") {
  14081. if (this.prodParam.hasYield) {
  14082. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14083. return;
  14084. }
  14085. } else if (word === "await") {
  14086. if (this.prodParam.hasAwait) {
  14087. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14088. return;
  14089. }
  14090. if (this.scope.inStaticBlock) {
  14091. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14092. return;
  14093. }
  14094. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14095. } else if (word === "arguments") {
  14096. if (this.scope.inClassAndNotInNonArrowFunction) {
  14097. this.raise(Errors.ArgumentsInClass, startLoc);
  14098. return;
  14099. }
  14100. }
  14101. }
  14102. isAwaitAllowed() {
  14103. if (this.prodParam.hasAwait) return true;
  14104. if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
  14105. return true;
  14106. }
  14107. return false;
  14108. }
  14109. parseAwait(startLoc) {
  14110. const node = this.startNodeAt(startLoc);
  14111. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14112. if (this.eat(55)) {
  14113. this.raise(Errors.ObsoleteAwaitStar, node);
  14114. }
  14115. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  14116. if (this.isAmbiguousAwait()) {
  14117. this.ambiguousScriptDifferentAst = true;
  14118. } else {
  14119. this.sawUnambiguousESM = true;
  14120. }
  14121. }
  14122. if (!this.state.soloAwait) {
  14123. node.argument = this.parseMaybeUnary(null, true);
  14124. }
  14125. return this.finishNode(node, "AwaitExpression");
  14126. }
  14127. isAmbiguousAwait() {
  14128. if (this.hasPrecedingLineBreak()) return true;
  14129. const {
  14130. type
  14131. } = this.state;
  14132. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14133. }
  14134. parseYield() {
  14135. const node = this.startNode();
  14136. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14137. this.next();
  14138. let delegating = false;
  14139. let argument = null;
  14140. if (!this.hasPrecedingLineBreak()) {
  14141. delegating = this.eat(55);
  14142. switch (this.state.type) {
  14143. case 13:
  14144. case 139:
  14145. case 8:
  14146. case 11:
  14147. case 3:
  14148. case 9:
  14149. case 14:
  14150. case 12:
  14151. if (!delegating) break;
  14152. default:
  14153. argument = this.parseMaybeAssign();
  14154. }
  14155. }
  14156. node.delegate = delegating;
  14157. node.argument = argument;
  14158. return this.finishNode(node, "YieldExpression");
  14159. }
  14160. parseImportCall(node) {
  14161. this.next();
  14162. node.source = this.parseMaybeAssignAllowIn();
  14163. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  14164. node.options = null;
  14165. }
  14166. if (this.eat(12)) {
  14167. this.expectImportAttributesPlugin();
  14168. if (!this.match(11)) {
  14169. node.options = this.parseMaybeAssignAllowIn();
  14170. this.eat(12);
  14171. }
  14172. }
  14173. this.expect(11);
  14174. return this.finishNode(node, "ImportExpression");
  14175. }
  14176. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14177. if (this.hasPlugin(["pipelineOperator", {
  14178. proposal: "smart"
  14179. }])) {
  14180. if (left.type === "SequenceExpression") {
  14181. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14182. }
  14183. }
  14184. }
  14185. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14186. if (this.isSimpleReference(childExpr)) {
  14187. const bodyNode = this.startNodeAt(startLoc);
  14188. bodyNode.callee = childExpr;
  14189. return this.finishNode(bodyNode, "PipelineBareFunction");
  14190. } else {
  14191. const bodyNode = this.startNodeAt(startLoc);
  14192. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14193. bodyNode.expression = childExpr;
  14194. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14195. }
  14196. }
  14197. isSimpleReference(expression) {
  14198. switch (expression.type) {
  14199. case "MemberExpression":
  14200. return !expression.computed && this.isSimpleReference(expression.object);
  14201. case "Identifier":
  14202. return true;
  14203. default:
  14204. return false;
  14205. }
  14206. }
  14207. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14208. if (this.match(19)) {
  14209. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14210. }
  14211. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14212. this.raise(Errors.PipelineTopicUnused, startLoc);
  14213. }
  14214. }
  14215. withTopicBindingContext(callback) {
  14216. const outerContextTopicState = this.state.topicContext;
  14217. this.state.topicContext = {
  14218. maxNumOfResolvableTopics: 1,
  14219. maxTopicIndex: null
  14220. };
  14221. try {
  14222. return callback();
  14223. } finally {
  14224. this.state.topicContext = outerContextTopicState;
  14225. }
  14226. }
  14227. withSmartMixTopicForbiddingContext(callback) {
  14228. if (this.hasPlugin(["pipelineOperator", {
  14229. proposal: "smart"
  14230. }])) {
  14231. const outerContextTopicState = this.state.topicContext;
  14232. this.state.topicContext = {
  14233. maxNumOfResolvableTopics: 0,
  14234. maxTopicIndex: null
  14235. };
  14236. try {
  14237. return callback();
  14238. } finally {
  14239. this.state.topicContext = outerContextTopicState;
  14240. }
  14241. } else {
  14242. return callback();
  14243. }
  14244. }
  14245. withSoloAwaitPermittingContext(callback) {
  14246. const outerContextSoloAwaitState = this.state.soloAwait;
  14247. this.state.soloAwait = true;
  14248. try {
  14249. return callback();
  14250. } finally {
  14251. this.state.soloAwait = outerContextSoloAwaitState;
  14252. }
  14253. }
  14254. allowInAnd(callback) {
  14255. const flags = this.prodParam.currentFlags();
  14256. const prodParamToSet = 8 & ~flags;
  14257. if (prodParamToSet) {
  14258. this.prodParam.enter(flags | 8);
  14259. try {
  14260. return callback();
  14261. } finally {
  14262. this.prodParam.exit();
  14263. }
  14264. }
  14265. return callback();
  14266. }
  14267. disallowInAnd(callback) {
  14268. const flags = this.prodParam.currentFlags();
  14269. const prodParamToClear = 8 & flags;
  14270. if (prodParamToClear) {
  14271. this.prodParam.enter(flags & ~8);
  14272. try {
  14273. return callback();
  14274. } finally {
  14275. this.prodParam.exit();
  14276. }
  14277. }
  14278. return callback();
  14279. }
  14280. registerTopicReference() {
  14281. this.state.topicContext.maxTopicIndex = 0;
  14282. }
  14283. topicReferenceIsAllowedInCurrentContext() {
  14284. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14285. }
  14286. topicReferenceWasUsedInCurrentContext() {
  14287. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14288. }
  14289. parseFSharpPipelineBody(prec) {
  14290. const startLoc = this.state.startLoc;
  14291. this.state.potentialArrowAt = this.state.start;
  14292. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14293. this.state.inFSharpPipelineDirectBody = true;
  14294. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14295. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14296. return ret;
  14297. }
  14298. parseModuleExpression() {
  14299. this.expectPlugin("moduleBlocks");
  14300. const node = this.startNode();
  14301. this.next();
  14302. if (!this.match(5)) {
  14303. this.unexpected(null, 5);
  14304. }
  14305. const program = this.startNodeAt(this.state.endLoc);
  14306. this.next();
  14307. const revertScopes = this.initializeScopes(true);
  14308. this.enterInitialScopes();
  14309. try {
  14310. node.body = this.parseProgram(program, 8, "module");
  14311. } finally {
  14312. revertScopes();
  14313. }
  14314. return this.finishNode(node, "ModuleExpression");
  14315. }
  14316. parsePropertyNamePrefixOperator(prop) {}
  14317. }
  14318. const loopLabel = {
  14319. kind: 1
  14320. },
  14321. switchLabel = {
  14322. kind: 2
  14323. };
  14324. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14325. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14326. function babel7CompatTokens(tokens, input) {
  14327. for (let i = 0; i < tokens.length; i++) {
  14328. const token = tokens[i];
  14329. const {
  14330. type
  14331. } = token;
  14332. if (typeof type === "number") {
  14333. {
  14334. if (type === 138) {
  14335. const {
  14336. loc,
  14337. start,
  14338. value,
  14339. end
  14340. } = token;
  14341. const hashEndPos = start + 1;
  14342. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14343. tokens.splice(i, 1, new Token({
  14344. type: getExportedToken(27),
  14345. value: "#",
  14346. start: start,
  14347. end: hashEndPos,
  14348. startLoc: loc.start,
  14349. endLoc: hashEndLoc
  14350. }), new Token({
  14351. type: getExportedToken(132),
  14352. value: value,
  14353. start: hashEndPos,
  14354. end: end,
  14355. startLoc: hashEndLoc,
  14356. endLoc: loc.end
  14357. }));
  14358. i++;
  14359. continue;
  14360. }
  14361. if (tokenIsTemplate(type)) {
  14362. const {
  14363. loc,
  14364. start,
  14365. value,
  14366. end
  14367. } = token;
  14368. const backquoteEnd = start + 1;
  14369. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14370. let startToken;
  14371. if (input.charCodeAt(start) === 96) {
  14372. startToken = new Token({
  14373. type: getExportedToken(22),
  14374. value: "`",
  14375. start: start,
  14376. end: backquoteEnd,
  14377. startLoc: loc.start,
  14378. endLoc: backquoteEndLoc
  14379. });
  14380. } else {
  14381. startToken = new Token({
  14382. type: getExportedToken(8),
  14383. value: "}",
  14384. start: start,
  14385. end: backquoteEnd,
  14386. startLoc: loc.start,
  14387. endLoc: backquoteEndLoc
  14388. });
  14389. }
  14390. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14391. if (type === 24) {
  14392. templateElementEnd = end - 1;
  14393. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14394. templateValue = value === null ? null : value.slice(1, -1);
  14395. endToken = new Token({
  14396. type: getExportedToken(22),
  14397. value: "`",
  14398. start: templateElementEnd,
  14399. end: end,
  14400. startLoc: templateElementEndLoc,
  14401. endLoc: loc.end
  14402. });
  14403. } else {
  14404. templateElementEnd = end - 2;
  14405. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  14406. templateValue = value === null ? null : value.slice(1, -2);
  14407. endToken = new Token({
  14408. type: getExportedToken(23),
  14409. value: "${",
  14410. start: templateElementEnd,
  14411. end: end,
  14412. startLoc: templateElementEndLoc,
  14413. endLoc: loc.end
  14414. });
  14415. }
  14416. tokens.splice(i, 1, startToken, new Token({
  14417. type: getExportedToken(20),
  14418. value: templateValue,
  14419. start: backquoteEnd,
  14420. end: templateElementEnd,
  14421. startLoc: backquoteEndLoc,
  14422. endLoc: templateElementEndLoc
  14423. }), endToken);
  14424. i += 2;
  14425. continue;
  14426. }
  14427. }
  14428. token.type = getExportedToken(type);
  14429. }
  14430. }
  14431. return tokens;
  14432. }
  14433. class StatementParser extends ExpressionParser {
  14434. parseTopLevel(file, program) {
  14435. file.program = this.parseProgram(program);
  14436. file.comments = this.comments;
  14437. if (this.options.tokens) {
  14438. file.tokens = babel7CompatTokens(this.tokens, this.input);
  14439. }
  14440. return this.finishNode(file, "File");
  14441. }
  14442. parseProgram(program, end = 139, sourceType = this.options.sourceType) {
  14443. program.sourceType = sourceType;
  14444. program.interpreter = this.parseInterpreterDirective();
  14445. this.parseBlockBody(program, true, true, end);
  14446. if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  14447. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  14448. this.raise(Errors.ModuleExportUndefined, at, {
  14449. localName
  14450. });
  14451. }
  14452. }
  14453. let finishedProgram;
  14454. if (end === 139) {
  14455. finishedProgram = this.finishNode(program, "Program");
  14456. } else {
  14457. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  14458. }
  14459. return finishedProgram;
  14460. }
  14461. stmtToDirective(stmt) {
  14462. const directive = stmt;
  14463. directive.type = "Directive";
  14464. directive.value = directive.expression;
  14465. delete directive.expression;
  14466. const directiveLiteral = directive.value;
  14467. const expressionValue = directiveLiteral.value;
  14468. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  14469. const val = directiveLiteral.value = raw.slice(1, -1);
  14470. this.addExtra(directiveLiteral, "raw", raw);
  14471. this.addExtra(directiveLiteral, "rawValue", val);
  14472. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  14473. directiveLiteral.type = "DirectiveLiteral";
  14474. return directive;
  14475. }
  14476. parseInterpreterDirective() {
  14477. if (!this.match(28)) {
  14478. return null;
  14479. }
  14480. const node = this.startNode();
  14481. node.value = this.state.value;
  14482. this.next();
  14483. return this.finishNode(node, "InterpreterDirective");
  14484. }
  14485. isLet() {
  14486. if (!this.isContextual(100)) {
  14487. return false;
  14488. }
  14489. return this.hasFollowingBindingAtom();
  14490. }
  14491. chStartsBindingIdentifier(ch, pos) {
  14492. if (isIdentifierStart(ch)) {
  14493. keywordRelationalOperator.lastIndex = pos;
  14494. if (keywordRelationalOperator.test(this.input)) {
  14495. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  14496. if (!isIdentifierChar(endCh) && endCh !== 92) {
  14497. return false;
  14498. }
  14499. }
  14500. return true;
  14501. } else if (ch === 92) {
  14502. return true;
  14503. } else {
  14504. return false;
  14505. }
  14506. }
  14507. chStartsBindingPattern(ch) {
  14508. return ch === 91 || ch === 123;
  14509. }
  14510. hasFollowingBindingAtom() {
  14511. const next = this.nextTokenStart();
  14512. const nextCh = this.codePointAtPos(next);
  14513. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  14514. }
  14515. hasInLineFollowingBindingIdentifier() {
  14516. const next = this.nextTokenInLineStart();
  14517. const nextCh = this.codePointAtPos(next);
  14518. return this.chStartsBindingIdentifier(nextCh, next);
  14519. }
  14520. startsUsingForOf() {
  14521. const {
  14522. type,
  14523. containsEsc
  14524. } = this.lookahead();
  14525. if (type === 102 && !containsEsc) {
  14526. return false;
  14527. } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) {
  14528. this.expectPlugin("explicitResourceManagement");
  14529. return true;
  14530. }
  14531. }
  14532. startsAwaitUsing() {
  14533. let next = this.nextTokenInLineStart();
  14534. if (this.isUnparsedContextual(next, "using")) {
  14535. next = this.nextTokenInLineStartSince(next + 5);
  14536. const nextCh = this.codePointAtPos(next);
  14537. if (this.chStartsBindingIdentifier(nextCh, next)) {
  14538. this.expectPlugin("explicitResourceManagement");
  14539. return true;
  14540. }
  14541. }
  14542. return false;
  14543. }
  14544. parseModuleItem() {
  14545. return this.parseStatementLike(1 | 2 | 4 | 8);
  14546. }
  14547. parseStatementListItem() {
  14548. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  14549. }
  14550. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  14551. let flags = 0;
  14552. if (this.options.annexB && !this.state.strict) {
  14553. flags |= 4;
  14554. if (allowLabeledFunction) {
  14555. flags |= 8;
  14556. }
  14557. }
  14558. return this.parseStatementLike(flags);
  14559. }
  14560. parseStatement() {
  14561. return this.parseStatementLike(0);
  14562. }
  14563. parseStatementLike(flags) {
  14564. let decorators = null;
  14565. if (this.match(26)) {
  14566. decorators = this.parseDecorators(true);
  14567. }
  14568. return this.parseStatementContent(flags, decorators);
  14569. }
  14570. parseStatementContent(flags, decorators) {
  14571. const starttype = this.state.type;
  14572. const node = this.startNode();
  14573. const allowDeclaration = !!(flags & 2);
  14574. const allowFunctionDeclaration = !!(flags & 4);
  14575. const topLevel = flags & 1;
  14576. switch (starttype) {
  14577. case 60:
  14578. return this.parseBreakContinueStatement(node, true);
  14579. case 63:
  14580. return this.parseBreakContinueStatement(node, false);
  14581. case 64:
  14582. return this.parseDebuggerStatement(node);
  14583. case 90:
  14584. return this.parseDoWhileStatement(node);
  14585. case 91:
  14586. return this.parseForStatement(node);
  14587. case 68:
  14588. if (this.lookaheadCharCode() === 46) break;
  14589. if (!allowFunctionDeclaration) {
  14590. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  14591. }
  14592. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  14593. case 80:
  14594. if (!allowDeclaration) this.unexpected();
  14595. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  14596. case 69:
  14597. return this.parseIfStatement(node);
  14598. case 70:
  14599. return this.parseReturnStatement(node);
  14600. case 71:
  14601. return this.parseSwitchStatement(node);
  14602. case 72:
  14603. return this.parseThrowStatement(node);
  14604. case 73:
  14605. return this.parseTryStatement(node);
  14606. case 96:
  14607. if (!this.state.containsEsc && this.startsAwaitUsing()) {
  14608. if (!this.isAwaitAllowed()) {
  14609. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  14610. } else if (!allowDeclaration) {
  14611. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  14612. }
  14613. this.next();
  14614. return this.parseVarStatement(node, "await using");
  14615. }
  14616. break;
  14617. case 107:
  14618. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifier()) {
  14619. break;
  14620. }
  14621. this.expectPlugin("explicitResourceManagement");
  14622. if (!this.scope.inModule && this.scope.inTopLevel) {
  14623. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  14624. } else if (!allowDeclaration) {
  14625. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14626. }
  14627. return this.parseVarStatement(node, "using");
  14628. case 100:
  14629. {
  14630. if (this.state.containsEsc) {
  14631. break;
  14632. }
  14633. const next = this.nextTokenStart();
  14634. const nextCh = this.codePointAtPos(next);
  14635. if (nextCh !== 91) {
  14636. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  14637. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  14638. break;
  14639. }
  14640. }
  14641. }
  14642. case 75:
  14643. {
  14644. if (!allowDeclaration) {
  14645. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14646. }
  14647. }
  14648. case 74:
  14649. {
  14650. const kind = this.state.value;
  14651. return this.parseVarStatement(node, kind);
  14652. }
  14653. case 92:
  14654. return this.parseWhileStatement(node);
  14655. case 76:
  14656. return this.parseWithStatement(node);
  14657. case 5:
  14658. return this.parseBlock();
  14659. case 13:
  14660. return this.parseEmptyStatement(node);
  14661. case 83:
  14662. {
  14663. const nextTokenCharCode = this.lookaheadCharCode();
  14664. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  14665. break;
  14666. }
  14667. }
  14668. case 82:
  14669. {
  14670. if (!this.options.allowImportExportEverywhere && !topLevel) {
  14671. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  14672. }
  14673. this.next();
  14674. let result;
  14675. if (starttype === 83) {
  14676. result = this.parseImport(node);
  14677. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  14678. this.sawUnambiguousESM = true;
  14679. }
  14680. } else {
  14681. result = this.parseExport(node, decorators);
  14682. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  14683. this.sawUnambiguousESM = true;
  14684. }
  14685. }
  14686. this.assertModuleNodeAllowed(result);
  14687. return result;
  14688. }
  14689. default:
  14690. {
  14691. if (this.isAsyncFunction()) {
  14692. if (!allowDeclaration) {
  14693. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  14694. }
  14695. this.next();
  14696. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  14697. }
  14698. }
  14699. }
  14700. const maybeName = this.state.value;
  14701. const expr = this.parseExpression();
  14702. if (tokenIsIdentifier(starttype) && expr.type === "Identifier" && this.eat(14)) {
  14703. return this.parseLabeledStatement(node, maybeName, expr, flags);
  14704. } else {
  14705. return this.parseExpressionStatement(node, expr, decorators);
  14706. }
  14707. }
  14708. assertModuleNodeAllowed(node) {
  14709. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  14710. this.raise(Errors.ImportOutsideModule, node);
  14711. }
  14712. }
  14713. decoratorsEnabledBeforeExport() {
  14714. if (this.hasPlugin("decorators-legacy")) return true;
  14715. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  14716. }
  14717. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  14718. if (maybeDecorators) {
  14719. if (classNode.decorators && classNode.decorators.length > 0) {
  14720. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  14721. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  14722. }
  14723. classNode.decorators.unshift(...maybeDecorators);
  14724. } else {
  14725. classNode.decorators = maybeDecorators;
  14726. }
  14727. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  14728. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  14729. }
  14730. return classNode;
  14731. }
  14732. canHaveLeadingDecorator() {
  14733. return this.match(80);
  14734. }
  14735. parseDecorators(allowExport) {
  14736. const decorators = [];
  14737. do {
  14738. decorators.push(this.parseDecorator());
  14739. } while (this.match(26));
  14740. if (this.match(82)) {
  14741. if (!allowExport) {
  14742. this.unexpected();
  14743. }
  14744. if (!this.decoratorsEnabledBeforeExport()) {
  14745. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  14746. }
  14747. } else if (!this.canHaveLeadingDecorator()) {
  14748. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  14749. }
  14750. return decorators;
  14751. }
  14752. parseDecorator() {
  14753. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  14754. const node = this.startNode();
  14755. this.next();
  14756. if (this.hasPlugin("decorators")) {
  14757. const startLoc = this.state.startLoc;
  14758. let expr;
  14759. if (this.match(10)) {
  14760. const startLoc = this.state.startLoc;
  14761. this.next();
  14762. expr = this.parseExpression();
  14763. this.expect(11);
  14764. expr = this.wrapParenthesis(startLoc, expr);
  14765. const paramsStartLoc = this.state.startLoc;
  14766. node.expression = this.parseMaybeDecoratorArguments(expr);
  14767. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  14768. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  14769. }
  14770. } else {
  14771. expr = this.parseIdentifier(false);
  14772. while (this.eat(16)) {
  14773. const node = this.startNodeAt(startLoc);
  14774. node.object = expr;
  14775. if (this.match(138)) {
  14776. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  14777. node.property = this.parsePrivateName();
  14778. } else {
  14779. node.property = this.parseIdentifier(true);
  14780. }
  14781. node.computed = false;
  14782. expr = this.finishNode(node, "MemberExpression");
  14783. }
  14784. node.expression = this.parseMaybeDecoratorArguments(expr);
  14785. }
  14786. } else {
  14787. node.expression = this.parseExprSubscripts();
  14788. }
  14789. return this.finishNode(node, "Decorator");
  14790. }
  14791. parseMaybeDecoratorArguments(expr) {
  14792. if (this.eat(10)) {
  14793. const node = this.startNodeAtNode(expr);
  14794. node.callee = expr;
  14795. node.arguments = this.parseCallExpressionArguments(11, false);
  14796. this.toReferencedList(node.arguments);
  14797. return this.finishNode(node, "CallExpression");
  14798. }
  14799. return expr;
  14800. }
  14801. parseBreakContinueStatement(node, isBreak) {
  14802. this.next();
  14803. if (this.isLineTerminator()) {
  14804. node.label = null;
  14805. } else {
  14806. node.label = this.parseIdentifier();
  14807. this.semicolon();
  14808. }
  14809. this.verifyBreakContinue(node, isBreak);
  14810. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  14811. }
  14812. verifyBreakContinue(node, isBreak) {
  14813. let i;
  14814. for (i = 0; i < this.state.labels.length; ++i) {
  14815. const lab = this.state.labels[i];
  14816. if (node.label == null || lab.name === node.label.name) {
  14817. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  14818. break;
  14819. }
  14820. if (node.label && isBreak) break;
  14821. }
  14822. }
  14823. if (i === this.state.labels.length) {
  14824. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  14825. this.raise(Errors.IllegalBreakContinue, node, {
  14826. type
  14827. });
  14828. }
  14829. }
  14830. parseDebuggerStatement(node) {
  14831. this.next();
  14832. this.semicolon();
  14833. return this.finishNode(node, "DebuggerStatement");
  14834. }
  14835. parseHeaderExpression() {
  14836. this.expect(10);
  14837. const val = this.parseExpression();
  14838. this.expect(11);
  14839. return val;
  14840. }
  14841. parseDoWhileStatement(node) {
  14842. this.next();
  14843. this.state.labels.push(loopLabel);
  14844. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  14845. this.state.labels.pop();
  14846. this.expect(92);
  14847. node.test = this.parseHeaderExpression();
  14848. this.eat(13);
  14849. return this.finishNode(node, "DoWhileStatement");
  14850. }
  14851. parseForStatement(node) {
  14852. this.next();
  14853. this.state.labels.push(loopLabel);
  14854. let awaitAt = null;
  14855. if (this.isAwaitAllowed() && this.eatContextual(96)) {
  14856. awaitAt = this.state.lastTokStartLoc;
  14857. }
  14858. this.scope.enter(0);
  14859. this.expect(10);
  14860. if (this.match(13)) {
  14861. if (awaitAt !== null) {
  14862. this.unexpected(awaitAt);
  14863. }
  14864. return this.parseFor(node, null);
  14865. }
  14866. const startsWithLet = this.isContextual(100);
  14867. {
  14868. const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing();
  14869. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf();
  14870. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  14871. if (this.match(74) || this.match(75) || isLetOrUsing) {
  14872. const initNode = this.startNode();
  14873. let kind;
  14874. if (startsWithAwaitUsing) {
  14875. kind = "await using";
  14876. if (!this.isAwaitAllowed()) {
  14877. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  14878. }
  14879. this.next();
  14880. } else {
  14881. kind = this.state.value;
  14882. }
  14883. this.next();
  14884. this.parseVar(initNode, true, kind);
  14885. const init = this.finishNode(initNode, "VariableDeclaration");
  14886. const isForIn = this.match(58);
  14887. if (isForIn && starsWithUsingDeclaration) {
  14888. this.raise(Errors.ForInUsing, init);
  14889. }
  14890. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  14891. return this.parseForIn(node, init, awaitAt);
  14892. }
  14893. if (awaitAt !== null) {
  14894. this.unexpected(awaitAt);
  14895. }
  14896. return this.parseFor(node, init);
  14897. }
  14898. }
  14899. const startsWithAsync = this.isContextual(95);
  14900. const refExpressionErrors = new ExpressionErrors();
  14901. const init = this.parseExpression(true, refExpressionErrors);
  14902. const isForOf = this.isContextual(102);
  14903. if (isForOf) {
  14904. if (startsWithLet) {
  14905. this.raise(Errors.ForOfLet, init);
  14906. }
  14907. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  14908. this.raise(Errors.ForOfAsync, init);
  14909. }
  14910. }
  14911. if (isForOf || this.match(58)) {
  14912. this.checkDestructuringPrivate(refExpressionErrors);
  14913. this.toAssignable(init, true);
  14914. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  14915. this.checkLVal(init, {
  14916. in: {
  14917. type
  14918. }
  14919. });
  14920. return this.parseForIn(node, init, awaitAt);
  14921. } else {
  14922. this.checkExpressionErrors(refExpressionErrors, true);
  14923. }
  14924. if (awaitAt !== null) {
  14925. this.unexpected(awaitAt);
  14926. }
  14927. return this.parseFor(node, init);
  14928. }
  14929. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  14930. this.next();
  14931. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  14932. }
  14933. parseIfStatement(node) {
  14934. this.next();
  14935. node.test = this.parseHeaderExpression();
  14936. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  14937. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  14938. return this.finishNode(node, "IfStatement");
  14939. }
  14940. parseReturnStatement(node) {
  14941. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  14942. this.raise(Errors.IllegalReturn, this.state.startLoc);
  14943. }
  14944. this.next();
  14945. if (this.isLineTerminator()) {
  14946. node.argument = null;
  14947. } else {
  14948. node.argument = this.parseExpression();
  14949. this.semicolon();
  14950. }
  14951. return this.finishNode(node, "ReturnStatement");
  14952. }
  14953. parseSwitchStatement(node) {
  14954. this.next();
  14955. node.discriminant = this.parseHeaderExpression();
  14956. const cases = node.cases = [];
  14957. this.expect(5);
  14958. this.state.labels.push(switchLabel);
  14959. this.scope.enter(0);
  14960. let cur;
  14961. for (let sawDefault; !this.match(8);) {
  14962. if (this.match(61) || this.match(65)) {
  14963. const isCase = this.match(61);
  14964. if (cur) this.finishNode(cur, "SwitchCase");
  14965. cases.push(cur = this.startNode());
  14966. cur.consequent = [];
  14967. this.next();
  14968. if (isCase) {
  14969. cur.test = this.parseExpression();
  14970. } else {
  14971. if (sawDefault) {
  14972. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  14973. }
  14974. sawDefault = true;
  14975. cur.test = null;
  14976. }
  14977. this.expect(14);
  14978. } else {
  14979. if (cur) {
  14980. cur.consequent.push(this.parseStatementListItem());
  14981. } else {
  14982. this.unexpected();
  14983. }
  14984. }
  14985. }
  14986. this.scope.exit();
  14987. if (cur) this.finishNode(cur, "SwitchCase");
  14988. this.next();
  14989. this.state.labels.pop();
  14990. return this.finishNode(node, "SwitchStatement");
  14991. }
  14992. parseThrowStatement(node) {
  14993. this.next();
  14994. if (this.hasPrecedingLineBreak()) {
  14995. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  14996. }
  14997. node.argument = this.parseExpression();
  14998. this.semicolon();
  14999. return this.finishNode(node, "ThrowStatement");
  15000. }
  15001. parseCatchClauseParam() {
  15002. const param = this.parseBindingAtom();
  15003. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15004. this.checkLVal(param, {
  15005. in: {
  15006. type: "CatchClause"
  15007. },
  15008. binding: 9
  15009. });
  15010. return param;
  15011. }
  15012. parseTryStatement(node) {
  15013. this.next();
  15014. node.block = this.parseBlock();
  15015. node.handler = null;
  15016. if (this.match(62)) {
  15017. const clause = this.startNode();
  15018. this.next();
  15019. if (this.match(10)) {
  15020. this.expect(10);
  15021. clause.param = this.parseCatchClauseParam();
  15022. this.expect(11);
  15023. } else {
  15024. clause.param = null;
  15025. this.scope.enter(0);
  15026. }
  15027. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15028. this.scope.exit();
  15029. node.handler = this.finishNode(clause, "CatchClause");
  15030. }
  15031. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15032. if (!node.handler && !node.finalizer) {
  15033. this.raise(Errors.NoCatchOrFinally, node);
  15034. }
  15035. return this.finishNode(node, "TryStatement");
  15036. }
  15037. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15038. this.next();
  15039. this.parseVar(node, false, kind, allowMissingInitializer);
  15040. this.semicolon();
  15041. return this.finishNode(node, "VariableDeclaration");
  15042. }
  15043. parseWhileStatement(node) {
  15044. this.next();
  15045. node.test = this.parseHeaderExpression();
  15046. this.state.labels.push(loopLabel);
  15047. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15048. this.state.labels.pop();
  15049. return this.finishNode(node, "WhileStatement");
  15050. }
  15051. parseWithStatement(node) {
  15052. if (this.state.strict) {
  15053. this.raise(Errors.StrictWith, this.state.startLoc);
  15054. }
  15055. this.next();
  15056. node.object = this.parseHeaderExpression();
  15057. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15058. return this.finishNode(node, "WithStatement");
  15059. }
  15060. parseEmptyStatement(node) {
  15061. this.next();
  15062. return this.finishNode(node, "EmptyStatement");
  15063. }
  15064. parseLabeledStatement(node, maybeName, expr, flags) {
  15065. for (const label of this.state.labels) {
  15066. if (label.name === maybeName) {
  15067. this.raise(Errors.LabelRedeclaration, expr, {
  15068. labelName: maybeName
  15069. });
  15070. }
  15071. }
  15072. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15073. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15074. const label = this.state.labels[i];
  15075. if (label.statementStart === node.start) {
  15076. label.statementStart = this.state.start;
  15077. label.kind = kind;
  15078. } else {
  15079. break;
  15080. }
  15081. }
  15082. this.state.labels.push({
  15083. name: maybeName,
  15084. kind: kind,
  15085. statementStart: this.state.start
  15086. });
  15087. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15088. this.state.labels.pop();
  15089. node.label = expr;
  15090. return this.finishNode(node, "LabeledStatement");
  15091. }
  15092. parseExpressionStatement(node, expr, decorators) {
  15093. node.expression = expr;
  15094. this.semicolon();
  15095. return this.finishNode(node, "ExpressionStatement");
  15096. }
  15097. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15098. const node = this.startNode();
  15099. if (allowDirectives) {
  15100. this.state.strictErrors.clear();
  15101. }
  15102. this.expect(5);
  15103. if (createNewLexicalScope) {
  15104. this.scope.enter(0);
  15105. }
  15106. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15107. if (createNewLexicalScope) {
  15108. this.scope.exit();
  15109. }
  15110. return this.finishNode(node, "BlockStatement");
  15111. }
  15112. isValidDirective(stmt) {
  15113. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15114. }
  15115. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15116. const body = node.body = [];
  15117. const directives = node.directives = [];
  15118. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15119. }
  15120. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15121. const oldStrict = this.state.strict;
  15122. let hasStrictModeDirective = false;
  15123. let parsedNonDirective = false;
  15124. while (!this.match(end)) {
  15125. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15126. if (directives && !parsedNonDirective) {
  15127. if (this.isValidDirective(stmt)) {
  15128. const directive = this.stmtToDirective(stmt);
  15129. directives.push(directive);
  15130. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15131. hasStrictModeDirective = true;
  15132. this.setStrict(true);
  15133. }
  15134. continue;
  15135. }
  15136. parsedNonDirective = true;
  15137. this.state.strictErrors.clear();
  15138. }
  15139. body.push(stmt);
  15140. }
  15141. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15142. if (!oldStrict) {
  15143. this.setStrict(false);
  15144. }
  15145. this.next();
  15146. }
  15147. parseFor(node, init) {
  15148. node.init = init;
  15149. this.semicolon(false);
  15150. node.test = this.match(13) ? null : this.parseExpression();
  15151. this.semicolon(false);
  15152. node.update = this.match(11) ? null : this.parseExpression();
  15153. this.expect(11);
  15154. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15155. this.scope.exit();
  15156. this.state.labels.pop();
  15157. return this.finishNode(node, "ForStatement");
  15158. }
  15159. parseForIn(node, init, awaitAt) {
  15160. const isForIn = this.match(58);
  15161. this.next();
  15162. if (isForIn) {
  15163. if (awaitAt !== null) this.unexpected(awaitAt);
  15164. } else {
  15165. node.await = awaitAt !== null;
  15166. }
  15167. 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")) {
  15168. this.raise(Errors.ForInOfLoopInitializer, init, {
  15169. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15170. });
  15171. }
  15172. if (init.type === "AssignmentPattern") {
  15173. this.raise(Errors.InvalidLhs, init, {
  15174. ancestor: {
  15175. type: "ForStatement"
  15176. }
  15177. });
  15178. }
  15179. node.left = init;
  15180. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15181. this.expect(11);
  15182. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15183. this.scope.exit();
  15184. this.state.labels.pop();
  15185. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15186. }
  15187. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15188. const declarations = node.declarations = [];
  15189. node.kind = kind;
  15190. for (;;) {
  15191. const decl = this.startNode();
  15192. this.parseVarId(decl, kind);
  15193. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15194. if (decl.init === null && !allowMissingInitializer) {
  15195. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15196. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15197. kind: "destructuring"
  15198. });
  15199. } else if (kind === "const" && !(this.match(58) || this.isContextual(102))) {
  15200. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15201. kind: "const"
  15202. });
  15203. }
  15204. }
  15205. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15206. if (!this.eat(12)) break;
  15207. }
  15208. return node;
  15209. }
  15210. parseVarId(decl, kind) {
  15211. const id = this.parseBindingAtom();
  15212. this.checkLVal(id, {
  15213. in: {
  15214. type: "VariableDeclarator"
  15215. },
  15216. binding: kind === "var" ? 5 : 8201
  15217. });
  15218. decl.id = id;
  15219. }
  15220. parseAsyncFunctionExpression(node) {
  15221. return this.parseFunction(node, 8);
  15222. }
  15223. parseFunction(node, flags = 0) {
  15224. const hangingDeclaration = flags & 2;
  15225. const isDeclaration = !!(flags & 1);
  15226. const requireId = isDeclaration && !(flags & 4);
  15227. const isAsync = !!(flags & 8);
  15228. this.initFunction(node, isAsync);
  15229. if (this.match(55)) {
  15230. if (hangingDeclaration) {
  15231. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15232. }
  15233. this.next();
  15234. node.generator = true;
  15235. }
  15236. if (isDeclaration) {
  15237. node.id = this.parseFunctionId(requireId);
  15238. }
  15239. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15240. this.state.maybeInArrowParameters = false;
  15241. this.scope.enter(2);
  15242. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15243. if (!isDeclaration) {
  15244. node.id = this.parseFunctionId();
  15245. }
  15246. this.parseFunctionParams(node, false);
  15247. this.withSmartMixTopicForbiddingContext(() => {
  15248. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15249. });
  15250. this.prodParam.exit();
  15251. this.scope.exit();
  15252. if (isDeclaration && !hangingDeclaration) {
  15253. this.registerFunctionStatementId(node);
  15254. }
  15255. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15256. return node;
  15257. }
  15258. parseFunctionId(requireId) {
  15259. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15260. }
  15261. parseFunctionParams(node, isConstructor) {
  15262. this.expect(10);
  15263. this.expressionScope.enter(newParameterDeclarationScope());
  15264. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15265. this.expressionScope.exit();
  15266. }
  15267. registerFunctionStatementId(node) {
  15268. if (!node.id) return;
  15269. 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);
  15270. }
  15271. parseClass(node, isStatement, optionalId) {
  15272. this.next();
  15273. const oldStrict = this.state.strict;
  15274. this.state.strict = true;
  15275. this.parseClassId(node, isStatement, optionalId);
  15276. this.parseClassSuper(node);
  15277. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15278. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15279. }
  15280. isClassProperty() {
  15281. return this.match(29) || this.match(13) || this.match(8);
  15282. }
  15283. isClassMethod() {
  15284. return this.match(10);
  15285. }
  15286. isNonstaticConstructor(method) {
  15287. return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor");
  15288. }
  15289. parseClassBody(hadSuperClass, oldStrict) {
  15290. this.classScope.enter();
  15291. const state = {
  15292. hadConstructor: false,
  15293. hadSuperClass
  15294. };
  15295. let decorators = [];
  15296. const classBody = this.startNode();
  15297. classBody.body = [];
  15298. this.expect(5);
  15299. this.withSmartMixTopicForbiddingContext(() => {
  15300. while (!this.match(8)) {
  15301. if (this.eat(13)) {
  15302. if (decorators.length > 0) {
  15303. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15304. }
  15305. continue;
  15306. }
  15307. if (this.match(26)) {
  15308. decorators.push(this.parseDecorator());
  15309. continue;
  15310. }
  15311. const member = this.startNode();
  15312. if (decorators.length) {
  15313. member.decorators = decorators;
  15314. this.resetStartLocationFromNode(member, decorators[0]);
  15315. decorators = [];
  15316. }
  15317. this.parseClassMember(classBody, member, state);
  15318. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15319. this.raise(Errors.DecoratorConstructor, member);
  15320. }
  15321. }
  15322. });
  15323. this.state.strict = oldStrict;
  15324. this.next();
  15325. if (decorators.length) {
  15326. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15327. }
  15328. this.classScope.exit();
  15329. return this.finishNode(classBody, "ClassBody");
  15330. }
  15331. parseClassMemberFromModifier(classBody, member) {
  15332. const key = this.parseIdentifier(true);
  15333. if (this.isClassMethod()) {
  15334. const method = member;
  15335. method.kind = "method";
  15336. method.computed = false;
  15337. method.key = key;
  15338. method.static = false;
  15339. this.pushClassMethod(classBody, method, false, false, false, false);
  15340. return true;
  15341. } else if (this.isClassProperty()) {
  15342. const prop = member;
  15343. prop.computed = false;
  15344. prop.key = key;
  15345. prop.static = false;
  15346. classBody.body.push(this.parseClassProperty(prop));
  15347. return true;
  15348. }
  15349. this.resetPreviousNodeTrailingComments(key);
  15350. return false;
  15351. }
  15352. parseClassMember(classBody, member, state) {
  15353. const isStatic = this.isContextual(106);
  15354. if (isStatic) {
  15355. if (this.parseClassMemberFromModifier(classBody, member)) {
  15356. return;
  15357. }
  15358. if (this.eat(5)) {
  15359. this.parseClassStaticBlock(classBody, member);
  15360. return;
  15361. }
  15362. }
  15363. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15364. }
  15365. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15366. const publicMethod = member;
  15367. const privateMethod = member;
  15368. const publicProp = member;
  15369. const privateProp = member;
  15370. const accessorProp = member;
  15371. const method = publicMethod;
  15372. const publicMember = publicMethod;
  15373. member.static = isStatic;
  15374. this.parsePropertyNamePrefixOperator(member);
  15375. if (this.eat(55)) {
  15376. method.kind = "method";
  15377. const isPrivateName = this.match(138);
  15378. this.parseClassElementName(method);
  15379. if (isPrivateName) {
  15380. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  15381. return;
  15382. }
  15383. if (this.isNonstaticConstructor(publicMethod)) {
  15384. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  15385. }
  15386. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  15387. return;
  15388. }
  15389. const isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
  15390. const isPrivate = this.match(138);
  15391. const key = this.parseClassElementName(member);
  15392. const maybeQuestionTokenStartLoc = this.state.startLoc;
  15393. this.parsePostMemberNameModifiers(publicMember);
  15394. if (this.isClassMethod()) {
  15395. method.kind = "method";
  15396. if (isPrivate) {
  15397. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15398. return;
  15399. }
  15400. const isConstructor = this.isNonstaticConstructor(publicMethod);
  15401. let allowsDirectSuper = false;
  15402. if (isConstructor) {
  15403. publicMethod.kind = "constructor";
  15404. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  15405. this.raise(Errors.DuplicateConstructor, key);
  15406. }
  15407. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  15408. this.raise(Errors.OverrideOnConstructor, key);
  15409. }
  15410. state.hadConstructor = true;
  15411. allowsDirectSuper = state.hadSuperClass;
  15412. }
  15413. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  15414. } else if (this.isClassProperty()) {
  15415. if (isPrivate) {
  15416. this.pushClassPrivateProperty(classBody, privateProp);
  15417. } else {
  15418. this.pushClassProperty(classBody, publicProp);
  15419. }
  15420. } else if (isContextual && key.name === "async" && !this.isLineTerminator()) {
  15421. this.resetPreviousNodeTrailingComments(key);
  15422. const isGenerator = this.eat(55);
  15423. if (publicMember.optional) {
  15424. this.unexpected(maybeQuestionTokenStartLoc);
  15425. }
  15426. method.kind = "method";
  15427. const isPrivate = this.match(138);
  15428. this.parseClassElementName(method);
  15429. this.parsePostMemberNameModifiers(publicMember);
  15430. if (isPrivate) {
  15431. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  15432. } else {
  15433. if (this.isNonstaticConstructor(publicMethod)) {
  15434. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  15435. }
  15436. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  15437. }
  15438. } else if (isContextual && (key.name === "get" || key.name === "set") && !(this.match(55) && this.isLineTerminator())) {
  15439. this.resetPreviousNodeTrailingComments(key);
  15440. method.kind = key.name;
  15441. const isPrivate = this.match(138);
  15442. this.parseClassElementName(publicMethod);
  15443. if (isPrivate) {
  15444. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15445. } else {
  15446. if (this.isNonstaticConstructor(publicMethod)) {
  15447. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  15448. }
  15449. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  15450. }
  15451. this.checkGetterSetterParams(publicMethod);
  15452. } else if (isContextual && key.name === "accessor" && !this.isLineTerminator()) {
  15453. this.expectPlugin("decoratorAutoAccessors");
  15454. this.resetPreviousNodeTrailingComments(key);
  15455. const isPrivate = this.match(138);
  15456. this.parseClassElementName(publicProp);
  15457. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  15458. } else if (this.isLineTerminator()) {
  15459. if (isPrivate) {
  15460. this.pushClassPrivateProperty(classBody, privateProp);
  15461. } else {
  15462. this.pushClassProperty(classBody, publicProp);
  15463. }
  15464. } else {
  15465. this.unexpected();
  15466. }
  15467. }
  15468. parseClassElementName(member) {
  15469. const {
  15470. type,
  15471. value
  15472. } = this.state;
  15473. if ((type === 132 || type === 133) && member.static && value === "prototype") {
  15474. this.raise(Errors.StaticPrototype, this.state.startLoc);
  15475. }
  15476. if (type === 138) {
  15477. if (value === "constructor") {
  15478. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  15479. }
  15480. const key = this.parsePrivateName();
  15481. member.key = key;
  15482. return key;
  15483. }
  15484. return this.parsePropertyName(member);
  15485. }
  15486. parseClassStaticBlock(classBody, member) {
  15487. var _member$decorators;
  15488. this.scope.enter(64 | 128 | 16);
  15489. const oldLabels = this.state.labels;
  15490. this.state.labels = [];
  15491. this.prodParam.enter(0);
  15492. const body = member.body = [];
  15493. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  15494. this.prodParam.exit();
  15495. this.scope.exit();
  15496. this.state.labels = oldLabels;
  15497. classBody.body.push(this.finishNode(member, "StaticBlock"));
  15498. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  15499. this.raise(Errors.DecoratorStaticBlock, member);
  15500. }
  15501. }
  15502. pushClassProperty(classBody, prop) {
  15503. if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
  15504. this.raise(Errors.ConstructorClassField, prop.key);
  15505. }
  15506. classBody.body.push(this.parseClassProperty(prop));
  15507. }
  15508. pushClassPrivateProperty(classBody, prop) {
  15509. const node = this.parseClassPrivateProperty(prop);
  15510. classBody.body.push(node);
  15511. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15512. }
  15513. pushClassAccessorProperty(classBody, prop, isPrivate) {
  15514. if (!isPrivate && !prop.computed) {
  15515. const key = prop.key;
  15516. if (key.name === "constructor" || key.value === "constructor") {
  15517. this.raise(Errors.ConstructorClassField, key);
  15518. }
  15519. }
  15520. const node = this.parseClassAccessorProperty(prop);
  15521. classBody.body.push(node);
  15522. if (isPrivate) {
  15523. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15524. }
  15525. }
  15526. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  15527. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  15528. }
  15529. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  15530. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  15531. classBody.body.push(node);
  15532. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  15533. this.declareClassPrivateMethodInScope(node, kind);
  15534. }
  15535. declareClassPrivateMethodInScope(node, kind) {
  15536. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  15537. }
  15538. parsePostMemberNameModifiers(methodOrProp) {}
  15539. parseClassPrivateProperty(node) {
  15540. this.parseInitializer(node);
  15541. this.semicolon();
  15542. return this.finishNode(node, "ClassPrivateProperty");
  15543. }
  15544. parseClassProperty(node) {
  15545. this.parseInitializer(node);
  15546. this.semicolon();
  15547. return this.finishNode(node, "ClassProperty");
  15548. }
  15549. parseClassAccessorProperty(node) {
  15550. this.parseInitializer(node);
  15551. this.semicolon();
  15552. return this.finishNode(node, "ClassAccessorProperty");
  15553. }
  15554. parseInitializer(node) {
  15555. this.scope.enter(64 | 16);
  15556. this.expressionScope.enter(newExpressionScope());
  15557. this.prodParam.enter(0);
  15558. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  15559. this.expressionScope.exit();
  15560. this.prodParam.exit();
  15561. this.scope.exit();
  15562. }
  15563. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  15564. if (tokenIsIdentifier(this.state.type)) {
  15565. node.id = this.parseIdentifier();
  15566. if (isStatement) {
  15567. this.declareNameFromIdentifier(node.id, bindingType);
  15568. }
  15569. } else {
  15570. if (optionalId || !isStatement) {
  15571. node.id = null;
  15572. } else {
  15573. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  15574. }
  15575. }
  15576. }
  15577. parseClassSuper(node) {
  15578. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  15579. }
  15580. parseExport(node, decorators) {
  15581. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  15582. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  15583. const parseAfterDefault = !hasDefault || this.eat(12);
  15584. const hasStar = parseAfterDefault && this.eatExportStar(node);
  15585. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  15586. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  15587. const isFromRequired = hasDefault || hasStar;
  15588. if (hasStar && !hasNamespace) {
  15589. if (hasDefault) this.unexpected();
  15590. if (decorators) {
  15591. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15592. }
  15593. this.parseExportFrom(node, true);
  15594. return this.finishNode(node, "ExportAllDeclaration");
  15595. }
  15596. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  15597. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  15598. this.unexpected(null, 5);
  15599. }
  15600. if (hasNamespace && parseAfterNamespace) {
  15601. this.unexpected(null, 98);
  15602. }
  15603. let hasDeclaration;
  15604. if (isFromRequired || hasSpecifiers) {
  15605. hasDeclaration = false;
  15606. if (decorators) {
  15607. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15608. }
  15609. this.parseExportFrom(node, isFromRequired);
  15610. } else {
  15611. hasDeclaration = this.maybeParseExportDeclaration(node);
  15612. }
  15613. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  15614. var _node2$declaration;
  15615. const node2 = node;
  15616. this.checkExport(node2, true, false, !!node2.source);
  15617. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  15618. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  15619. } else if (decorators) {
  15620. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15621. }
  15622. return this.finishNode(node2, "ExportNamedDeclaration");
  15623. }
  15624. if (this.eat(65)) {
  15625. const node2 = node;
  15626. const decl = this.parseExportDefaultExpression();
  15627. node2.declaration = decl;
  15628. if (decl.type === "ClassDeclaration") {
  15629. this.maybeTakeDecorators(decorators, decl, node2);
  15630. } else if (decorators) {
  15631. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15632. }
  15633. this.checkExport(node2, true, true);
  15634. return this.finishNode(node2, "ExportDefaultDeclaration");
  15635. }
  15636. this.unexpected(null, 5);
  15637. }
  15638. eatExportStar(node) {
  15639. return this.eat(55);
  15640. }
  15641. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  15642. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  15643. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  15644. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  15645. const specifier = this.startNodeAtNode(id);
  15646. specifier.exported = id;
  15647. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  15648. return true;
  15649. }
  15650. return false;
  15651. }
  15652. maybeParseExportNamespaceSpecifier(node) {
  15653. if (this.isContextual(93)) {
  15654. if (!node.specifiers) node.specifiers = [];
  15655. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  15656. this.next();
  15657. specifier.exported = this.parseModuleExportName();
  15658. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  15659. return true;
  15660. }
  15661. return false;
  15662. }
  15663. maybeParseExportNamedSpecifiers(node) {
  15664. if (this.match(5)) {
  15665. if (!node.specifiers) node.specifiers = [];
  15666. const isTypeExport = node.exportKind === "type";
  15667. node.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  15668. node.source = null;
  15669. node.declaration = null;
  15670. if (this.hasPlugin("importAssertions")) {
  15671. node.assertions = [];
  15672. }
  15673. return true;
  15674. }
  15675. return false;
  15676. }
  15677. maybeParseExportDeclaration(node) {
  15678. if (this.shouldParseExportDeclaration()) {
  15679. node.specifiers = [];
  15680. node.source = null;
  15681. if (this.hasPlugin("importAssertions")) {
  15682. node.assertions = [];
  15683. }
  15684. node.declaration = this.parseExportDeclaration(node);
  15685. return true;
  15686. }
  15687. return false;
  15688. }
  15689. isAsyncFunction() {
  15690. if (!this.isContextual(95)) return false;
  15691. const next = this.nextTokenInLineStart();
  15692. return this.isUnparsedContextual(next, "function");
  15693. }
  15694. parseExportDefaultExpression() {
  15695. const expr = this.startNode();
  15696. if (this.match(68)) {
  15697. this.next();
  15698. return this.parseFunction(expr, 1 | 4);
  15699. } else if (this.isAsyncFunction()) {
  15700. this.next();
  15701. this.next();
  15702. return this.parseFunction(expr, 1 | 4 | 8);
  15703. }
  15704. if (this.match(80)) {
  15705. return this.parseClass(expr, true, true);
  15706. }
  15707. if (this.match(26)) {
  15708. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15709. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15710. }
  15711. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  15712. }
  15713. if (this.match(75) || this.match(74) || this.isLet()) {
  15714. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  15715. }
  15716. const res = this.parseMaybeAssignAllowIn();
  15717. this.semicolon();
  15718. return res;
  15719. }
  15720. parseExportDeclaration(node) {
  15721. if (this.match(80)) {
  15722. const node = this.parseClass(this.startNode(), true, false);
  15723. return node;
  15724. }
  15725. return this.parseStatementListItem();
  15726. }
  15727. isExportDefaultSpecifier() {
  15728. const {
  15729. type
  15730. } = this.state;
  15731. if (tokenIsIdentifier(type)) {
  15732. if (type === 95 && !this.state.containsEsc || type === 100) {
  15733. return false;
  15734. }
  15735. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  15736. const {
  15737. type: nextType
  15738. } = this.lookahead();
  15739. if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
  15740. this.expectOnePlugin(["flow", "typescript"]);
  15741. return false;
  15742. }
  15743. }
  15744. } else if (!this.match(65)) {
  15745. return false;
  15746. }
  15747. const next = this.nextTokenStart();
  15748. const hasFrom = this.isUnparsedContextual(next, "from");
  15749. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  15750. return true;
  15751. }
  15752. if (this.match(65) && hasFrom) {
  15753. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  15754. return nextAfterFrom === 34 || nextAfterFrom === 39;
  15755. }
  15756. return false;
  15757. }
  15758. parseExportFrom(node, expect) {
  15759. if (this.eatContextual(98)) {
  15760. node.source = this.parseImportSource();
  15761. this.checkExport(node);
  15762. this.maybeParseImportAttributes(node);
  15763. this.checkJSONModuleImport(node);
  15764. } else if (expect) {
  15765. this.unexpected();
  15766. }
  15767. this.semicolon();
  15768. }
  15769. shouldParseExportDeclaration() {
  15770. const {
  15771. type
  15772. } = this.state;
  15773. if (type === 26) {
  15774. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15775. if (this.hasPlugin("decorators")) {
  15776. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15777. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15778. }
  15779. return true;
  15780. }
  15781. }
  15782. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  15783. }
  15784. checkExport(node, checkNames, isDefault, isFrom) {
  15785. if (checkNames) {
  15786. var _node$specifiers;
  15787. if (isDefault) {
  15788. this.checkDuplicateExports(node, "default");
  15789. if (this.hasPlugin("exportDefaultFrom")) {
  15790. var _declaration$extra;
  15791. const declaration = node.declaration;
  15792. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  15793. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  15794. }
  15795. }
  15796. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  15797. for (const specifier of node.specifiers) {
  15798. const {
  15799. exported
  15800. } = specifier;
  15801. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  15802. this.checkDuplicateExports(specifier, exportName);
  15803. if (!isFrom && specifier.local) {
  15804. const {
  15805. local
  15806. } = specifier;
  15807. if (local.type !== "Identifier") {
  15808. this.raise(Errors.ExportBindingIsString, specifier, {
  15809. localName: local.value,
  15810. exportName
  15811. });
  15812. } else {
  15813. this.checkReservedWord(local.name, local.loc.start, true, false);
  15814. this.scope.checkLocalExport(local);
  15815. }
  15816. }
  15817. }
  15818. } else if (node.declaration) {
  15819. if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
  15820. const id = node.declaration.id;
  15821. if (!id) throw new Error("Assertion failure");
  15822. this.checkDuplicateExports(node, id.name);
  15823. } else if (node.declaration.type === "VariableDeclaration") {
  15824. for (const declaration of node.declaration.declarations) {
  15825. this.checkDeclaration(declaration.id);
  15826. }
  15827. }
  15828. }
  15829. }
  15830. }
  15831. checkDeclaration(node) {
  15832. if (node.type === "Identifier") {
  15833. this.checkDuplicateExports(node, node.name);
  15834. } else if (node.type === "ObjectPattern") {
  15835. for (const prop of node.properties) {
  15836. this.checkDeclaration(prop);
  15837. }
  15838. } else if (node.type === "ArrayPattern") {
  15839. for (const elem of node.elements) {
  15840. if (elem) {
  15841. this.checkDeclaration(elem);
  15842. }
  15843. }
  15844. } else if (node.type === "ObjectProperty") {
  15845. this.checkDeclaration(node.value);
  15846. } else if (node.type === "RestElement") {
  15847. this.checkDeclaration(node.argument);
  15848. } else if (node.type === "AssignmentPattern") {
  15849. this.checkDeclaration(node.left);
  15850. }
  15851. }
  15852. checkDuplicateExports(node, exportName) {
  15853. if (this.exportedIdentifiers.has(exportName)) {
  15854. if (exportName === "default") {
  15855. this.raise(Errors.DuplicateDefaultExport, node);
  15856. } else {
  15857. this.raise(Errors.DuplicateExport, node, {
  15858. exportName
  15859. });
  15860. }
  15861. }
  15862. this.exportedIdentifiers.add(exportName);
  15863. }
  15864. parseExportSpecifiers(isInTypeExport) {
  15865. const nodes = [];
  15866. let first = true;
  15867. this.expect(5);
  15868. while (!this.eat(8)) {
  15869. if (first) {
  15870. first = false;
  15871. } else {
  15872. this.expect(12);
  15873. if (this.eat(8)) break;
  15874. }
  15875. const isMaybeTypeOnly = this.isContextual(130);
  15876. const isString = this.match(133);
  15877. const node = this.startNode();
  15878. node.local = this.parseModuleExportName();
  15879. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  15880. }
  15881. return nodes;
  15882. }
  15883. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  15884. if (this.eatContextual(93)) {
  15885. node.exported = this.parseModuleExportName();
  15886. } else if (isString) {
  15887. node.exported = cloneStringLiteral(node.local);
  15888. } else if (!node.exported) {
  15889. node.exported = cloneIdentifier(node.local);
  15890. }
  15891. return this.finishNode(node, "ExportSpecifier");
  15892. }
  15893. parseModuleExportName() {
  15894. if (this.match(133)) {
  15895. const result = this.parseStringLiteral(this.state.value);
  15896. const surrogate = result.value.match(loneSurrogate);
  15897. if (surrogate) {
  15898. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  15899. surrogateCharCode: surrogate[0].charCodeAt(0)
  15900. });
  15901. }
  15902. return result;
  15903. }
  15904. return this.parseIdentifier(true);
  15905. }
  15906. isJSONModuleImport(node) {
  15907. if (node.assertions != null) {
  15908. return node.assertions.some(({
  15909. key,
  15910. value
  15911. }) => {
  15912. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  15913. });
  15914. }
  15915. return false;
  15916. }
  15917. checkImportReflection(node) {
  15918. const {
  15919. specifiers
  15920. } = node;
  15921. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  15922. if (node.phase === "source") {
  15923. if (singleBindingType !== "ImportDefaultSpecifier") {
  15924. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  15925. }
  15926. } else if (node.phase === "defer") {
  15927. if (singleBindingType !== "ImportNamespaceSpecifier") {
  15928. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  15929. }
  15930. } else if (node.module) {
  15931. var _node$assertions;
  15932. if (singleBindingType !== "ImportDefaultSpecifier") {
  15933. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  15934. }
  15935. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  15936. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  15937. }
  15938. }
  15939. }
  15940. checkJSONModuleImport(node) {
  15941. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  15942. const {
  15943. specifiers
  15944. } = node;
  15945. if (specifiers != null) {
  15946. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  15947. let imported;
  15948. if (specifier.type === "ExportSpecifier") {
  15949. imported = specifier.local;
  15950. } else if (specifier.type === "ImportSpecifier") {
  15951. imported = specifier.imported;
  15952. }
  15953. if (imported !== undefined) {
  15954. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  15955. }
  15956. });
  15957. if (nonDefaultNamedSpecifier !== undefined) {
  15958. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  15959. }
  15960. }
  15961. }
  15962. }
  15963. isPotentialImportPhase(isExport) {
  15964. if (isExport) return false;
  15965. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  15966. }
  15967. applyImportPhase(node, isExport, phase, loc) {
  15968. if (isExport) {
  15969. return;
  15970. }
  15971. if (phase === "module") {
  15972. this.expectPlugin("importReflection", loc);
  15973. node.module = true;
  15974. } else if (this.hasPlugin("importReflection")) {
  15975. node.module = false;
  15976. }
  15977. if (phase === "source") {
  15978. this.expectPlugin("sourcePhaseImports", loc);
  15979. node.phase = "source";
  15980. } else if (phase === "defer") {
  15981. this.expectPlugin("deferredImportEvaluation", loc);
  15982. node.phase = "defer";
  15983. } else if (this.hasPlugin("sourcePhaseImports")) {
  15984. node.phase = null;
  15985. }
  15986. }
  15987. parseMaybeImportPhase(node, isExport) {
  15988. if (!this.isPotentialImportPhase(isExport)) {
  15989. this.applyImportPhase(node, isExport, null);
  15990. return null;
  15991. }
  15992. const phaseIdentifier = this.parseIdentifier(true);
  15993. const {
  15994. type
  15995. } = this.state;
  15996. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  15997. if (isImportPhase) {
  15998. this.resetPreviousIdentifierLeadingComments(phaseIdentifier);
  15999. this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start);
  16000. return null;
  16001. } else {
  16002. this.applyImportPhase(node, isExport, null);
  16003. return phaseIdentifier;
  16004. }
  16005. }
  16006. isPrecedingIdImportPhase(phase) {
  16007. const {
  16008. type
  16009. } = this.state;
  16010. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16011. }
  16012. parseImport(node) {
  16013. if (this.match(133)) {
  16014. return this.parseImportSourceAndAttributes(node);
  16015. }
  16016. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16017. }
  16018. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16019. node.specifiers = [];
  16020. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16021. const parseNext = !hasDefault || this.eat(12);
  16022. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16023. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16024. this.expectContextual(98);
  16025. return this.parseImportSourceAndAttributes(node);
  16026. }
  16027. parseImportSourceAndAttributes(node) {
  16028. var _node$specifiers2;
  16029. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16030. node.source = this.parseImportSource();
  16031. this.maybeParseImportAttributes(node);
  16032. this.checkImportReflection(node);
  16033. this.checkJSONModuleImport(node);
  16034. this.semicolon();
  16035. return this.finishNode(node, "ImportDeclaration");
  16036. }
  16037. parseImportSource() {
  16038. if (!this.match(133)) this.unexpected();
  16039. return this.parseExprAtom();
  16040. }
  16041. parseImportSpecifierLocal(node, specifier, type) {
  16042. specifier.local = this.parseIdentifier();
  16043. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16044. }
  16045. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16046. this.checkLVal(specifier.local, {
  16047. in: {
  16048. type
  16049. },
  16050. binding: bindingType
  16051. });
  16052. return this.finishNode(specifier, type);
  16053. }
  16054. parseImportAttributes() {
  16055. this.expect(5);
  16056. const attrs = [];
  16057. const attrNames = new Set();
  16058. do {
  16059. if (this.match(8)) {
  16060. break;
  16061. }
  16062. const node = this.startNode();
  16063. const keyName = this.state.value;
  16064. if (attrNames.has(keyName)) {
  16065. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16066. key: keyName
  16067. });
  16068. }
  16069. attrNames.add(keyName);
  16070. if (this.match(133)) {
  16071. node.key = this.parseStringLiteral(keyName);
  16072. } else {
  16073. node.key = this.parseIdentifier(true);
  16074. }
  16075. this.expect(14);
  16076. if (!this.match(133)) {
  16077. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16078. }
  16079. node.value = this.parseStringLiteral(this.state.value);
  16080. attrs.push(this.finishNode(node, "ImportAttribute"));
  16081. } while (this.eat(12));
  16082. this.expect(8);
  16083. return attrs;
  16084. }
  16085. parseModuleAttributes() {
  16086. const attrs = [];
  16087. const attributes = new Set();
  16088. do {
  16089. const node = this.startNode();
  16090. node.key = this.parseIdentifier(true);
  16091. if (node.key.name !== "type") {
  16092. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16093. }
  16094. if (attributes.has(node.key.name)) {
  16095. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16096. key: node.key.name
  16097. });
  16098. }
  16099. attributes.add(node.key.name);
  16100. this.expect(14);
  16101. if (!this.match(133)) {
  16102. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16103. }
  16104. node.value = this.parseStringLiteral(this.state.value);
  16105. attrs.push(this.finishNode(node, "ImportAttribute"));
  16106. } while (this.eat(12));
  16107. return attrs;
  16108. }
  16109. maybeParseImportAttributes(node) {
  16110. let attributes;
  16111. let useWith = false;
  16112. if (this.match(76)) {
  16113. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16114. return;
  16115. }
  16116. this.next();
  16117. {
  16118. if (this.hasPlugin("moduleAttributes")) {
  16119. attributes = this.parseModuleAttributes();
  16120. } else {
  16121. this.expectImportAttributesPlugin();
  16122. attributes = this.parseImportAttributes();
  16123. }
  16124. }
  16125. useWith = true;
  16126. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16127. if (this.hasPlugin("importAttributes")) {
  16128. if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) {
  16129. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16130. }
  16131. this.addExtra(node, "deprecatedAssertSyntax", true);
  16132. } else {
  16133. this.expectOnePlugin(["importAttributes", "importAssertions"]);
  16134. }
  16135. this.next();
  16136. attributes = this.parseImportAttributes();
  16137. } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  16138. attributes = [];
  16139. } else {
  16140. if (this.hasPlugin("moduleAttributes")) {
  16141. attributes = [];
  16142. } else return;
  16143. }
  16144. if (!useWith && this.hasPlugin("importAssertions")) {
  16145. node.assertions = attributes;
  16146. } else {
  16147. node.attributes = attributes;
  16148. }
  16149. }
  16150. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16151. if (maybeDefaultIdentifier) {
  16152. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16153. specifier.local = maybeDefaultIdentifier;
  16154. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16155. return true;
  16156. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16157. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16158. return true;
  16159. }
  16160. return false;
  16161. }
  16162. maybeParseStarImportSpecifier(node) {
  16163. if (this.match(55)) {
  16164. const specifier = this.startNode();
  16165. this.next();
  16166. this.expectContextual(93);
  16167. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16168. return true;
  16169. }
  16170. return false;
  16171. }
  16172. parseNamedImportSpecifiers(node) {
  16173. let first = true;
  16174. this.expect(5);
  16175. while (!this.eat(8)) {
  16176. if (first) {
  16177. first = false;
  16178. } else {
  16179. if (this.eat(14)) {
  16180. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16181. }
  16182. this.expect(12);
  16183. if (this.eat(8)) break;
  16184. }
  16185. const specifier = this.startNode();
  16186. const importedIsString = this.match(133);
  16187. const isMaybeTypeOnly = this.isContextual(130);
  16188. specifier.imported = this.parseModuleExportName();
  16189. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16190. node.specifiers.push(importSpecifier);
  16191. }
  16192. }
  16193. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16194. if (this.eatContextual(93)) {
  16195. specifier.local = this.parseIdentifier();
  16196. } else {
  16197. const {
  16198. imported
  16199. } = specifier;
  16200. if (importedIsString) {
  16201. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16202. importName: imported.value
  16203. });
  16204. }
  16205. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16206. if (!specifier.local) {
  16207. specifier.local = cloneIdentifier(imported);
  16208. }
  16209. }
  16210. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16211. }
  16212. isThisParam(param) {
  16213. return param.type === "Identifier" && param.name === "this";
  16214. }
  16215. }
  16216. let Parser$2 = class Parser extends StatementParser {
  16217. constructor(options, input) {
  16218. options = getOptions(options);
  16219. super(options, input);
  16220. this.options = options;
  16221. this.initializeScopes();
  16222. this.plugins = pluginsMap(this.options.plugins);
  16223. this.filename = options.sourceFilename;
  16224. }
  16225. getScopeHandler() {
  16226. return ScopeHandler;
  16227. }
  16228. parse() {
  16229. this.enterInitialScopes();
  16230. const file = this.startNode();
  16231. const program = this.startNode();
  16232. this.nextToken();
  16233. file.errors = null;
  16234. this.parseTopLevel(file, program);
  16235. file.errors = this.state.errors;
  16236. file.comments.length = this.state.commentsLen;
  16237. return file;
  16238. }
  16239. };
  16240. function pluginsMap(plugins) {
  16241. const pluginMap = new Map();
  16242. for (const plugin of plugins) {
  16243. const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
  16244. if (!pluginMap.has(name)) pluginMap.set(name, options || {});
  16245. }
  16246. return pluginMap;
  16247. }
  16248. function parse$9(input, options) {
  16249. var _options;
  16250. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16251. options = Object.assign({}, options);
  16252. try {
  16253. options.sourceType = "module";
  16254. const parser = getParser(options, input);
  16255. const ast = parser.parse();
  16256. if (parser.sawUnambiguousESM) {
  16257. return ast;
  16258. }
  16259. if (parser.ambiguousScriptDifferentAst) {
  16260. try {
  16261. options.sourceType = "script";
  16262. return getParser(options, input).parse();
  16263. } catch (_unused) {}
  16264. } else {
  16265. ast.program.sourceType = "script";
  16266. }
  16267. return ast;
  16268. } catch (moduleError) {
  16269. try {
  16270. options.sourceType = "script";
  16271. return getParser(options, input).parse();
  16272. } catch (_unused2) {}
  16273. throw moduleError;
  16274. }
  16275. } else {
  16276. return getParser(options, input).parse();
  16277. }
  16278. }
  16279. function parseExpression(input, options) {
  16280. const parser = getParser(options, input);
  16281. if (parser.options.strictMode) {
  16282. parser.state.strict = true;
  16283. }
  16284. return parser.getExpression();
  16285. }
  16286. function generateExportedTokenTypes(internalTokenTypes) {
  16287. const tokenTypes = {};
  16288. for (const typeName of Object.keys(internalTokenTypes)) {
  16289. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16290. }
  16291. return tokenTypes;
  16292. }
  16293. const tokTypes = generateExportedTokenTypes(tt);
  16294. function getParser(options, input) {
  16295. let cls = Parser$2;
  16296. if (options != null && options.plugins) {
  16297. validatePlugins(options.plugins);
  16298. cls = getParserClass(options.plugins);
  16299. }
  16300. return new cls(options, input);
  16301. }
  16302. const parserClassCache = {};
  16303. function getParserClass(pluginsFromOptions) {
  16304. const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
  16305. const key = pluginList.join("/");
  16306. let cls = parserClassCache[key];
  16307. if (!cls) {
  16308. cls = Parser$2;
  16309. for (const plugin of pluginList) {
  16310. cls = mixinPlugins[plugin](cls);
  16311. }
  16312. parserClassCache[key] = cls;
  16313. }
  16314. return cls;
  16315. }
  16316. var parse_1$1 = lib.parse = parse$9;
  16317. var parseExpression_1 = lib.parseExpression = parseExpression;
  16318. lib.tokTypes = tokTypes;
  16319. // @ts-check
  16320. /** @typedef { import('estree').BaseNode} BaseNode */
  16321. /** @typedef {{
  16322. skip: () => void;
  16323. remove: () => void;
  16324. replace: (node: BaseNode) => void;
  16325. }} WalkerContext */
  16326. class WalkerBase {
  16327. constructor() {
  16328. /** @type {boolean} */
  16329. this.should_skip = false;
  16330. /** @type {boolean} */
  16331. this.should_remove = false;
  16332. /** @type {BaseNode | null} */
  16333. this.replacement = null;
  16334. /** @type {WalkerContext} */
  16335. this.context = {
  16336. skip: () => (this.should_skip = true),
  16337. remove: () => (this.should_remove = true),
  16338. replace: (node) => (this.replacement = node)
  16339. };
  16340. }
  16341. /**
  16342. *
  16343. * @param {any} parent
  16344. * @param {string} prop
  16345. * @param {number} index
  16346. * @param {BaseNode} node
  16347. */
  16348. replace(parent, prop, index, node) {
  16349. if (parent) {
  16350. if (index !== null) {
  16351. parent[prop][index] = node;
  16352. } else {
  16353. parent[prop] = node;
  16354. }
  16355. }
  16356. }
  16357. /**
  16358. *
  16359. * @param {any} parent
  16360. * @param {string} prop
  16361. * @param {number} index
  16362. */
  16363. remove(parent, prop, index) {
  16364. if (parent) {
  16365. if (index !== null) {
  16366. parent[prop].splice(index, 1);
  16367. } else {
  16368. delete parent[prop];
  16369. }
  16370. }
  16371. }
  16372. }
  16373. // @ts-check
  16374. /** @typedef { import('estree').BaseNode} BaseNode */
  16375. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  16376. /** @typedef {(
  16377. * this: WalkerContext,
  16378. * node: BaseNode,
  16379. * parent: BaseNode,
  16380. * key: string,
  16381. * index: number
  16382. * ) => void} SyncHandler */
  16383. class SyncWalker extends WalkerBase {
  16384. /**
  16385. *
  16386. * @param {SyncHandler} enter
  16387. * @param {SyncHandler} leave
  16388. */
  16389. constructor(enter, leave) {
  16390. super();
  16391. /** @type {SyncHandler} */
  16392. this.enter = enter;
  16393. /** @type {SyncHandler} */
  16394. this.leave = leave;
  16395. }
  16396. /**
  16397. *
  16398. * @param {BaseNode} node
  16399. * @param {BaseNode} parent
  16400. * @param {string} [prop]
  16401. * @param {number} [index]
  16402. * @returns {BaseNode}
  16403. */
  16404. visit(node, parent, prop, index) {
  16405. if (node) {
  16406. if (this.enter) {
  16407. const _should_skip = this.should_skip;
  16408. const _should_remove = this.should_remove;
  16409. const _replacement = this.replacement;
  16410. this.should_skip = false;
  16411. this.should_remove = false;
  16412. this.replacement = null;
  16413. this.enter.call(this.context, node, parent, prop, index);
  16414. if (this.replacement) {
  16415. node = this.replacement;
  16416. this.replace(parent, prop, index, node);
  16417. }
  16418. if (this.should_remove) {
  16419. this.remove(parent, prop, index);
  16420. }
  16421. const skipped = this.should_skip;
  16422. const removed = this.should_remove;
  16423. this.should_skip = _should_skip;
  16424. this.should_remove = _should_remove;
  16425. this.replacement = _replacement;
  16426. if (skipped) return node;
  16427. if (removed) return null;
  16428. }
  16429. for (const key in node) {
  16430. const value = node[key];
  16431. if (typeof value !== "object") {
  16432. continue;
  16433. } else if (Array.isArray(value)) {
  16434. for (let i = 0; i < value.length; i += 1) {
  16435. if (value[i] !== null && typeof value[i].type === 'string') {
  16436. if (!this.visit(value[i], node, key, i)) {
  16437. // removed
  16438. i--;
  16439. }
  16440. }
  16441. }
  16442. } else if (value !== null && typeof value.type === "string") {
  16443. this.visit(value, node, key, null);
  16444. }
  16445. }
  16446. if (this.leave) {
  16447. const _replacement = this.replacement;
  16448. const _should_remove = this.should_remove;
  16449. this.replacement = null;
  16450. this.should_remove = false;
  16451. this.leave.call(this.context, node, parent, prop, index);
  16452. if (this.replacement) {
  16453. node = this.replacement;
  16454. this.replace(parent, prop, index, node);
  16455. }
  16456. if (this.should_remove) {
  16457. this.remove(parent, prop, index);
  16458. }
  16459. const removed = this.should_remove;
  16460. this.replacement = _replacement;
  16461. this.should_remove = _should_remove;
  16462. if (removed) return null;
  16463. }
  16464. }
  16465. return node;
  16466. }
  16467. }
  16468. // @ts-check
  16469. /** @typedef { import('estree').BaseNode} BaseNode */
  16470. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  16471. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  16472. /**
  16473. *
  16474. * @param {BaseNode} ast
  16475. * @param {{
  16476. * enter?: SyncHandler
  16477. * leave?: SyncHandler
  16478. * }} walker
  16479. * @returns {BaseNode}
  16480. */
  16481. function walk$2(ast, { enter, leave }) {
  16482. const instance = new SyncWalker(enter, leave);
  16483. return instance.visit(ast, null);
  16484. }
  16485. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  16486. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  16487. walk$2(root, {
  16488. enter(node, parent) {
  16489. parent && parentStack.push(parent);
  16490. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  16491. return this.skip();
  16492. }
  16493. if (node.type === "Identifier") {
  16494. const isLocal = !!knownIds[node.name];
  16495. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  16496. if (includeAll || isRefed && !isLocal) {
  16497. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  16498. }
  16499. } else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  16500. node.inPattern = true;
  16501. } else if (isFunctionType(node)) {
  16502. if (node.scopeIds) {
  16503. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16504. } else {
  16505. walkFunctionParams(
  16506. node,
  16507. (id) => markScopeIdentifier(node, id, knownIds)
  16508. );
  16509. }
  16510. } else if (node.type === "BlockStatement") {
  16511. if (node.scopeIds) {
  16512. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16513. } else {
  16514. walkBlockDeclarations(
  16515. node,
  16516. (id) => markScopeIdentifier(node, id, knownIds)
  16517. );
  16518. }
  16519. }
  16520. },
  16521. leave(node, parent) {
  16522. parent && parentStack.pop();
  16523. if (node !== rootExp && node.scopeIds) {
  16524. for (const id of node.scopeIds) {
  16525. knownIds[id]--;
  16526. if (knownIds[id] === 0) {
  16527. delete knownIds[id];
  16528. }
  16529. }
  16530. }
  16531. }
  16532. });
  16533. }
  16534. function isReferencedIdentifier(id, parent, parentStack) {
  16535. if (!parent) {
  16536. return true;
  16537. }
  16538. if (id.name === "arguments") {
  16539. return false;
  16540. }
  16541. if (isReferenced(id, parent)) {
  16542. return true;
  16543. }
  16544. switch (parent.type) {
  16545. case "AssignmentExpression":
  16546. case "AssignmentPattern":
  16547. return true;
  16548. case "ObjectPattern":
  16549. case "ArrayPattern":
  16550. return isInDestructureAssignment(parent, parentStack);
  16551. }
  16552. return false;
  16553. }
  16554. function isInDestructureAssignment(parent, parentStack) {
  16555. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  16556. let i = parentStack.length;
  16557. while (i--) {
  16558. const p = parentStack[i];
  16559. if (p.type === "AssignmentExpression") {
  16560. return true;
  16561. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  16562. break;
  16563. }
  16564. }
  16565. }
  16566. return false;
  16567. }
  16568. function isInNewExpression(parentStack) {
  16569. let i = parentStack.length;
  16570. while (i--) {
  16571. const p = parentStack[i];
  16572. if (p.type === "NewExpression") {
  16573. return true;
  16574. } else if (p.type !== "MemberExpression") {
  16575. break;
  16576. }
  16577. }
  16578. return false;
  16579. }
  16580. function walkFunctionParams(node, onIdent) {
  16581. for (const p of node.params) {
  16582. for (const id of extractIdentifiers$1(p)) {
  16583. onIdent(id);
  16584. }
  16585. }
  16586. }
  16587. function walkBlockDeclarations(block, onIdent) {
  16588. for (const stmt of block.body) {
  16589. if (stmt.type === "VariableDeclaration") {
  16590. if (stmt.declare)
  16591. continue;
  16592. for (const decl of stmt.declarations) {
  16593. for (const id of extractIdentifiers$1(decl.id)) {
  16594. onIdent(id);
  16595. }
  16596. }
  16597. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  16598. if (stmt.declare || !stmt.id)
  16599. continue;
  16600. onIdent(stmt.id);
  16601. } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
  16602. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  16603. if (variable && variable.type === "VariableDeclaration") {
  16604. for (const decl of variable.declarations) {
  16605. for (const id of extractIdentifiers$1(decl.id)) {
  16606. onIdent(id);
  16607. }
  16608. }
  16609. }
  16610. }
  16611. }
  16612. }
  16613. function extractIdentifiers$1(param, nodes = []) {
  16614. switch (param.type) {
  16615. case "Identifier":
  16616. nodes.push(param);
  16617. break;
  16618. case "MemberExpression":
  16619. let object = param;
  16620. while (object.type === "MemberExpression") {
  16621. object = object.object;
  16622. }
  16623. nodes.push(object);
  16624. break;
  16625. case "ObjectPattern":
  16626. for (const prop of param.properties) {
  16627. if (prop.type === "RestElement") {
  16628. extractIdentifiers$1(prop.argument, nodes);
  16629. } else {
  16630. extractIdentifiers$1(prop.value, nodes);
  16631. }
  16632. }
  16633. break;
  16634. case "ArrayPattern":
  16635. param.elements.forEach((element) => {
  16636. if (element)
  16637. extractIdentifiers$1(element, nodes);
  16638. });
  16639. break;
  16640. case "RestElement":
  16641. extractIdentifiers$1(param.argument, nodes);
  16642. break;
  16643. case "AssignmentPattern":
  16644. extractIdentifiers$1(param.left, nodes);
  16645. break;
  16646. }
  16647. return nodes;
  16648. }
  16649. function markKnownIds(name, knownIds) {
  16650. if (name in knownIds) {
  16651. knownIds[name]++;
  16652. } else {
  16653. knownIds[name] = 1;
  16654. }
  16655. }
  16656. function markScopeIdentifier(node, child, knownIds) {
  16657. const { name } = child;
  16658. if (node.scopeIds && node.scopeIds.has(name)) {
  16659. return;
  16660. }
  16661. markKnownIds(name, knownIds);
  16662. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  16663. }
  16664. const isFunctionType = (node) => {
  16665. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  16666. };
  16667. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  16668. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  16669. function isReferenced(node, parent, grandparent) {
  16670. switch (parent.type) {
  16671. case "MemberExpression":
  16672. case "OptionalMemberExpression":
  16673. if (parent.property === node) {
  16674. return !!parent.computed;
  16675. }
  16676. return parent.object === node;
  16677. case "JSXMemberExpression":
  16678. return parent.object === node;
  16679. case "VariableDeclarator":
  16680. return parent.init === node;
  16681. case "ArrowFunctionExpression":
  16682. return parent.body === node;
  16683. case "PrivateName":
  16684. return false;
  16685. case "ClassMethod":
  16686. case "ClassPrivateMethod":
  16687. case "ObjectMethod":
  16688. if (parent.key === node) {
  16689. return !!parent.computed;
  16690. }
  16691. return false;
  16692. case "ObjectProperty":
  16693. if (parent.key === node) {
  16694. return !!parent.computed;
  16695. }
  16696. return !grandparent || grandparent.type !== "ObjectPattern";
  16697. case "ClassProperty":
  16698. if (parent.key === node) {
  16699. return !!parent.computed;
  16700. }
  16701. return true;
  16702. case "ClassPrivateProperty":
  16703. return parent.key !== node;
  16704. case "ClassDeclaration":
  16705. case "ClassExpression":
  16706. return parent.superClass === node;
  16707. case "AssignmentExpression":
  16708. return parent.right === node;
  16709. case "AssignmentPattern":
  16710. return parent.right === node;
  16711. case "LabeledStatement":
  16712. return false;
  16713. case "CatchClause":
  16714. return false;
  16715. case "RestElement":
  16716. return false;
  16717. case "BreakStatement":
  16718. case "ContinueStatement":
  16719. return false;
  16720. case "FunctionDeclaration":
  16721. case "FunctionExpression":
  16722. return false;
  16723. case "ExportNamespaceSpecifier":
  16724. case "ExportDefaultSpecifier":
  16725. return false;
  16726. case "ExportSpecifier":
  16727. if (grandparent == null ? void 0 : grandparent.source) {
  16728. return false;
  16729. }
  16730. return parent.local === node;
  16731. case "ImportDefaultSpecifier":
  16732. case "ImportNamespaceSpecifier":
  16733. case "ImportSpecifier":
  16734. return false;
  16735. case "ImportAttribute":
  16736. return false;
  16737. case "JSXAttribute":
  16738. return false;
  16739. case "ObjectPattern":
  16740. case "ArrayPattern":
  16741. return false;
  16742. case "MetaProperty":
  16743. return false;
  16744. case "ObjectTypeProperty":
  16745. return parent.key !== node;
  16746. case "TSEnumMember":
  16747. return parent.id !== node;
  16748. case "TSPropertySignature":
  16749. if (parent.key === node) {
  16750. return !!parent.computed;
  16751. }
  16752. return true;
  16753. }
  16754. return true;
  16755. }
  16756. const TS_NODE_TYPES = [
  16757. "TSAsExpression",
  16758. // foo as number
  16759. "TSTypeAssertion",
  16760. // (<number>foo)
  16761. "TSNonNullExpression",
  16762. // foo!
  16763. "TSInstantiationExpression",
  16764. // foo<string>
  16765. "TSSatisfiesExpression"
  16766. // foo satisfies T
  16767. ];
  16768. function unwrapTSNode(node) {
  16769. if (TS_NODE_TYPES.includes(node.type)) {
  16770. return unwrapTSNode(node.expression);
  16771. } else {
  16772. return node;
  16773. }
  16774. }
  16775. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  16776. function isCoreComponent(tag) {
  16777. switch (tag) {
  16778. case "Teleport":
  16779. case "teleport":
  16780. return TELEPORT;
  16781. case "Suspense":
  16782. case "suspense":
  16783. return SUSPENSE;
  16784. case "KeepAlive":
  16785. case "keep-alive":
  16786. return KEEP_ALIVE;
  16787. case "BaseTransition":
  16788. case "base-transition":
  16789. return BASE_TRANSITION;
  16790. }
  16791. }
  16792. const nonIdentifierRE = /^\d|[^\$\w]/;
  16793. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  16794. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  16795. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  16796. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  16797. const isMemberExpressionBrowser = (path) => {
  16798. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  16799. let state = 0 /* inMemberExp */;
  16800. let stateStack = [];
  16801. let currentOpenBracketCount = 0;
  16802. let currentOpenParensCount = 0;
  16803. let currentStringType = null;
  16804. for (let i = 0; i < path.length; i++) {
  16805. const char = path.charAt(i);
  16806. switch (state) {
  16807. case 0 /* inMemberExp */:
  16808. if (char === "[") {
  16809. stateStack.push(state);
  16810. state = 1 /* inBrackets */;
  16811. currentOpenBracketCount++;
  16812. } else if (char === "(") {
  16813. stateStack.push(state);
  16814. state = 2 /* inParens */;
  16815. currentOpenParensCount++;
  16816. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  16817. return false;
  16818. }
  16819. break;
  16820. case 1 /* inBrackets */:
  16821. if (char === `'` || char === `"` || char === "`") {
  16822. stateStack.push(state);
  16823. state = 3 /* inString */;
  16824. currentStringType = char;
  16825. } else if (char === `[`) {
  16826. currentOpenBracketCount++;
  16827. } else if (char === `]`) {
  16828. if (!--currentOpenBracketCount) {
  16829. state = stateStack.pop();
  16830. }
  16831. }
  16832. break;
  16833. case 2 /* inParens */:
  16834. if (char === `'` || char === `"` || char === "`") {
  16835. stateStack.push(state);
  16836. state = 3 /* inString */;
  16837. currentStringType = char;
  16838. } else if (char === `(`) {
  16839. currentOpenParensCount++;
  16840. } else if (char === `)`) {
  16841. if (i === path.length - 1) {
  16842. return false;
  16843. }
  16844. if (!--currentOpenParensCount) {
  16845. state = stateStack.pop();
  16846. }
  16847. }
  16848. break;
  16849. case 3 /* inString */:
  16850. if (char === currentStringType) {
  16851. state = stateStack.pop();
  16852. currentStringType = null;
  16853. }
  16854. break;
  16855. }
  16856. }
  16857. return !currentOpenBracketCount && !currentOpenParensCount;
  16858. };
  16859. const isMemberExpressionNode = (path, context) => {
  16860. try {
  16861. let ret = parseExpression_1(path, {
  16862. plugins: context.expressionPlugins
  16863. });
  16864. ret = unwrapTSNode(ret);
  16865. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  16866. } catch (e) {
  16867. return false;
  16868. }
  16869. };
  16870. const isMemberExpression = isMemberExpressionNode;
  16871. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  16872. return advancePositionWithMutation(
  16873. {
  16874. offset: pos.offset,
  16875. line: pos.line,
  16876. column: pos.column
  16877. },
  16878. source,
  16879. numberOfCharacters
  16880. );
  16881. }
  16882. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  16883. let linesCount = 0;
  16884. let lastNewLinePos = -1;
  16885. for (let i = 0; i < numberOfCharacters; i++) {
  16886. if (source.charCodeAt(i) === 10) {
  16887. linesCount++;
  16888. lastNewLinePos = i;
  16889. }
  16890. }
  16891. pos.offset += numberOfCharacters;
  16892. pos.line += linesCount;
  16893. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  16894. return pos;
  16895. }
  16896. function assert(condition, msg) {
  16897. if (!condition) {
  16898. throw new Error(msg || `unexpected compiler condition`);
  16899. }
  16900. }
  16901. function findDir(node, name, allowEmpty = false) {
  16902. for (let i = 0; i < node.props.length; i++) {
  16903. const p = node.props[i];
  16904. if (p.type === 7 && (allowEmpty || p.exp) && (isString$2(name) ? p.name === name : name.test(p.name))) {
  16905. return p;
  16906. }
  16907. }
  16908. }
  16909. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  16910. for (let i = 0; i < node.props.length; i++) {
  16911. const p = node.props[i];
  16912. if (p.type === 6) {
  16913. if (dynamicOnly)
  16914. continue;
  16915. if (p.name === name && (p.value || allowEmpty)) {
  16916. return p;
  16917. }
  16918. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  16919. return p;
  16920. }
  16921. }
  16922. }
  16923. function isStaticArgOf(arg, name) {
  16924. return !!(arg && isStaticExp(arg) && arg.content === name);
  16925. }
  16926. function hasDynamicKeyVBind(node) {
  16927. return node.props.some(
  16928. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  16929. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  16930. !p.arg.isStatic)
  16931. // v-bind:[foo]
  16932. );
  16933. }
  16934. function isText$1(node) {
  16935. return node.type === 5 || node.type === 2;
  16936. }
  16937. function isVSlot(p) {
  16938. return p.type === 7 && p.name === "slot";
  16939. }
  16940. function isTemplateNode(node) {
  16941. return node.type === 1 && node.tagType === 3;
  16942. }
  16943. function isSlotOutlet(node) {
  16944. return node.type === 1 && node.tagType === 2;
  16945. }
  16946. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  16947. function getUnnormalizedProps(props, callPath = []) {
  16948. if (props && !isString$2(props) && props.type === 14) {
  16949. const callee = props.callee;
  16950. if (!isString$2(callee) && propsHelperSet.has(callee)) {
  16951. return getUnnormalizedProps(
  16952. props.arguments[0],
  16953. callPath.concat(props)
  16954. );
  16955. }
  16956. }
  16957. return [props, callPath];
  16958. }
  16959. function injectProp(node, prop, context) {
  16960. let propsWithInjection;
  16961. let props = node.type === 13 ? node.props : node.arguments[2];
  16962. let callPath = [];
  16963. let parentCall;
  16964. if (props && !isString$2(props) && props.type === 14) {
  16965. const ret = getUnnormalizedProps(props);
  16966. props = ret[0];
  16967. callPath = ret[1];
  16968. parentCall = callPath[callPath.length - 1];
  16969. }
  16970. if (props == null || isString$2(props)) {
  16971. propsWithInjection = createObjectExpression([prop]);
  16972. } else if (props.type === 14) {
  16973. const first = props.arguments[0];
  16974. if (!isString$2(first) && first.type === 15) {
  16975. if (!hasProp(prop, first)) {
  16976. first.properties.unshift(prop);
  16977. }
  16978. } else {
  16979. if (props.callee === TO_HANDLERS) {
  16980. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  16981. createObjectExpression([prop]),
  16982. props
  16983. ]);
  16984. } else {
  16985. props.arguments.unshift(createObjectExpression([prop]));
  16986. }
  16987. }
  16988. !propsWithInjection && (propsWithInjection = props);
  16989. } else if (props.type === 15) {
  16990. if (!hasProp(prop, props)) {
  16991. props.properties.unshift(prop);
  16992. }
  16993. propsWithInjection = props;
  16994. } else {
  16995. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  16996. createObjectExpression([prop]),
  16997. props
  16998. ]);
  16999. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17000. parentCall = callPath[callPath.length - 2];
  17001. }
  17002. }
  17003. if (node.type === 13) {
  17004. if (parentCall) {
  17005. parentCall.arguments[0] = propsWithInjection;
  17006. } else {
  17007. node.props = propsWithInjection;
  17008. }
  17009. } else {
  17010. if (parentCall) {
  17011. parentCall.arguments[0] = propsWithInjection;
  17012. } else {
  17013. node.arguments[2] = propsWithInjection;
  17014. }
  17015. }
  17016. }
  17017. function hasProp(prop, props) {
  17018. let result = false;
  17019. if (prop.key.type === 4) {
  17020. const propKeyName = prop.key.content;
  17021. result = props.properties.some(
  17022. (p) => p.key.type === 4 && p.key.content === propKeyName
  17023. );
  17024. }
  17025. return result;
  17026. }
  17027. function toValidAssetId(name, type) {
  17028. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17029. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17030. })}`;
  17031. }
  17032. function hasScopeRef(node, ids) {
  17033. if (!node || Object.keys(ids).length === 0) {
  17034. return false;
  17035. }
  17036. switch (node.type) {
  17037. case 1:
  17038. for (let i = 0; i < node.props.length; i++) {
  17039. const p = node.props[i];
  17040. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17041. return true;
  17042. }
  17043. }
  17044. return node.children.some((c) => hasScopeRef(c, ids));
  17045. case 11:
  17046. if (hasScopeRef(node.source, ids)) {
  17047. return true;
  17048. }
  17049. return node.children.some((c) => hasScopeRef(c, ids));
  17050. case 9:
  17051. return node.branches.some((b) => hasScopeRef(b, ids));
  17052. case 10:
  17053. if (hasScopeRef(node.condition, ids)) {
  17054. return true;
  17055. }
  17056. return node.children.some((c) => hasScopeRef(c, ids));
  17057. case 4:
  17058. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17059. case 8:
  17060. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17061. case 5:
  17062. case 12:
  17063. return hasScopeRef(node.content, ids);
  17064. case 2:
  17065. case 3:
  17066. return false;
  17067. default:
  17068. return false;
  17069. }
  17070. }
  17071. function getMemoedVNodeCall(node) {
  17072. if (node.type === 14 && node.callee === WITH_MEMO) {
  17073. return node.arguments[1].returns;
  17074. } else {
  17075. return node;
  17076. }
  17077. }
  17078. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  17079. const defaultParserOptions = {
  17080. parseMode: "base",
  17081. ns: 0,
  17082. delimiters: [`{{`, `}}`],
  17083. getNamespace: () => 0,
  17084. isVoidTag: NO,
  17085. isPreTag: NO,
  17086. isCustomElement: NO,
  17087. onError: defaultOnError,
  17088. onWarn: defaultOnWarn,
  17089. comments: true,
  17090. prefixIdentifiers: false
  17091. };
  17092. let currentOptions = defaultParserOptions;
  17093. let currentRoot = null;
  17094. let currentInput = "";
  17095. let currentOpenTag = null;
  17096. let currentProp = null;
  17097. let currentAttrValue = "";
  17098. let currentAttrStartIndex = -1;
  17099. let currentAttrEndIndex = -1;
  17100. let inPre = 0;
  17101. let inVPre = false;
  17102. let currentVPreBoundary = null;
  17103. const stack = [];
  17104. const tokenizer$2 = new Tokenizer$1(stack, {
  17105. onerr: emitError,
  17106. ontext(start, end) {
  17107. onText(getSlice(start, end), start, end);
  17108. },
  17109. ontextentity(char, start, end) {
  17110. onText(char, start, end);
  17111. },
  17112. oninterpolation(start, end) {
  17113. if (inVPre) {
  17114. return onText(getSlice(start, end), start, end);
  17115. }
  17116. let innerStart = start + tokenizer$2.delimiterOpen.length;
  17117. let innerEnd = end - tokenizer$2.delimiterClose.length;
  17118. while (isWhitespace$1(currentInput.charCodeAt(innerStart))) {
  17119. innerStart++;
  17120. }
  17121. while (isWhitespace$1(currentInput.charCodeAt(innerEnd - 1))) {
  17122. innerEnd--;
  17123. }
  17124. let exp = getSlice(innerStart, innerEnd);
  17125. if (exp.includes("&")) {
  17126. {
  17127. exp = decodeHTML(exp);
  17128. }
  17129. }
  17130. addNode({
  17131. type: 5,
  17132. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17133. loc: getLoc(start, end)
  17134. });
  17135. },
  17136. onopentagname(start, end) {
  17137. const name = getSlice(start, end);
  17138. currentOpenTag = {
  17139. type: 1,
  17140. tag: name,
  17141. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17142. tagType: 0,
  17143. // will be refined on tag close
  17144. props: [],
  17145. children: [],
  17146. loc: getLoc(start - 1, end),
  17147. codegenNode: void 0
  17148. };
  17149. },
  17150. onopentagend(end) {
  17151. endOpenTag(end);
  17152. },
  17153. onclosetag(start, end) {
  17154. const name = getSlice(start, end);
  17155. if (!currentOptions.isVoidTag(name)) {
  17156. let found = false;
  17157. for (let i = 0; i < stack.length; i++) {
  17158. const e = stack[i];
  17159. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17160. found = true;
  17161. if (i > 0) {
  17162. emitError(24, stack[0].loc.start.offset);
  17163. }
  17164. for (let j = 0; j <= i; j++) {
  17165. const el = stack.shift();
  17166. onCloseTag(el, end, j < i);
  17167. }
  17168. break;
  17169. }
  17170. }
  17171. if (!found) {
  17172. emitError(23, backTrack(start, 60));
  17173. }
  17174. }
  17175. },
  17176. onselfclosingtag(end) {
  17177. var _a;
  17178. const name = currentOpenTag.tag;
  17179. currentOpenTag.isSelfClosing = true;
  17180. endOpenTag(end);
  17181. if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
  17182. onCloseTag(stack.shift(), end);
  17183. }
  17184. },
  17185. onattribname(start, end) {
  17186. currentProp = {
  17187. type: 6,
  17188. name: getSlice(start, end),
  17189. nameLoc: getLoc(start, end),
  17190. value: void 0,
  17191. loc: getLoc(start)
  17192. };
  17193. },
  17194. ondirname(start, end) {
  17195. const raw = getSlice(start, end);
  17196. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  17197. if (!inVPre && name === "") {
  17198. emitError(26, start);
  17199. }
  17200. if (inVPre || name === "") {
  17201. currentProp = {
  17202. type: 6,
  17203. name: raw,
  17204. nameLoc: getLoc(start, end),
  17205. value: void 0,
  17206. loc: getLoc(start)
  17207. };
  17208. } else {
  17209. currentProp = {
  17210. type: 7,
  17211. name,
  17212. rawName: raw,
  17213. exp: void 0,
  17214. arg: void 0,
  17215. modifiers: raw === "." ? ["prop"] : [],
  17216. loc: getLoc(start)
  17217. };
  17218. if (name === "pre") {
  17219. inVPre = tokenizer$2.inVPre = true;
  17220. currentVPreBoundary = currentOpenTag;
  17221. const props = currentOpenTag.props;
  17222. for (let i = 0; i < props.length; i++) {
  17223. if (props[i].type === 7) {
  17224. props[i] = dirToAttr(props[i]);
  17225. }
  17226. }
  17227. }
  17228. }
  17229. },
  17230. ondirarg(start, end) {
  17231. if (start === end)
  17232. return;
  17233. const arg = getSlice(start, end);
  17234. if (inVPre) {
  17235. currentProp.name += arg;
  17236. setLocEnd(currentProp.nameLoc, end);
  17237. } else {
  17238. const isStatic = arg[0] !== `[`;
  17239. currentProp.arg = createExp(
  17240. isStatic ? arg : arg.slice(1, -1),
  17241. isStatic,
  17242. getLoc(start, end),
  17243. isStatic ? 3 : 0
  17244. );
  17245. }
  17246. },
  17247. ondirmodifier(start, end) {
  17248. const mod = getSlice(start, end);
  17249. if (inVPre) {
  17250. currentProp.name += "." + mod;
  17251. setLocEnd(currentProp.nameLoc, end);
  17252. } else if (currentProp.name === "slot") {
  17253. const arg = currentProp.arg;
  17254. if (arg) {
  17255. arg.content += "." + mod;
  17256. setLocEnd(arg.loc, end);
  17257. }
  17258. } else {
  17259. currentProp.modifiers.push(mod);
  17260. }
  17261. },
  17262. onattribdata(start, end) {
  17263. currentAttrValue += getSlice(start, end);
  17264. if (currentAttrStartIndex < 0)
  17265. currentAttrStartIndex = start;
  17266. currentAttrEndIndex = end;
  17267. },
  17268. onattribentity(char, start, end) {
  17269. currentAttrValue += char;
  17270. if (currentAttrStartIndex < 0)
  17271. currentAttrStartIndex = start;
  17272. currentAttrEndIndex = end;
  17273. },
  17274. onattribnameend(end) {
  17275. const start = currentProp.loc.start.offset;
  17276. const name = getSlice(start, end);
  17277. if (currentProp.type === 7) {
  17278. currentProp.rawName = name;
  17279. }
  17280. if (currentOpenTag.props.some(
  17281. (p) => (p.type === 7 ? p.rawName : p.name) === name
  17282. )) {
  17283. emitError(2, start);
  17284. }
  17285. },
  17286. onattribend(quote, end) {
  17287. if (currentOpenTag && currentProp) {
  17288. setLocEnd(currentProp.loc, end);
  17289. if (quote !== 0) {
  17290. if (currentProp.type === 6) {
  17291. if (currentProp.name === "class") {
  17292. currentAttrValue = condense(currentAttrValue).trim();
  17293. }
  17294. if (quote === 1 && !currentAttrValue) {
  17295. emitError(13, end);
  17296. }
  17297. currentProp.value = {
  17298. type: 2,
  17299. content: currentAttrValue,
  17300. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  17301. };
  17302. if (tokenizer$2.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  17303. tokenizer$2.enterRCDATA(toCharCodes(`</template`), 0);
  17304. }
  17305. } else {
  17306. let expParseMode = 0 /* Normal */;
  17307. {
  17308. if (currentProp.name === "for") {
  17309. expParseMode = 3 /* Skip */;
  17310. } else if (currentProp.name === "slot") {
  17311. expParseMode = 1 /* Params */;
  17312. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  17313. expParseMode = 2 /* Statements */;
  17314. }
  17315. }
  17316. currentProp.exp = createExp(
  17317. currentAttrValue,
  17318. false,
  17319. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  17320. 0,
  17321. expParseMode
  17322. );
  17323. if (currentProp.name === "for") {
  17324. currentProp.forParseResult = parseForExpression(currentProp.exp);
  17325. }
  17326. }
  17327. }
  17328. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  17329. currentOpenTag.props.push(currentProp);
  17330. }
  17331. }
  17332. currentAttrValue = "";
  17333. currentAttrStartIndex = currentAttrEndIndex = -1;
  17334. },
  17335. oncomment(start, end) {
  17336. if (currentOptions.comments) {
  17337. addNode({
  17338. type: 3,
  17339. content: getSlice(start, end),
  17340. loc: getLoc(start - 4, end + 3)
  17341. });
  17342. }
  17343. },
  17344. onend() {
  17345. const end = currentInput.length;
  17346. if (tokenizer$2.state !== 1) {
  17347. switch (tokenizer$2.state) {
  17348. case 5:
  17349. case 8:
  17350. emitError(5, end);
  17351. break;
  17352. case 3:
  17353. case 4:
  17354. emitError(
  17355. 25,
  17356. tokenizer$2.sectionStart
  17357. );
  17358. break;
  17359. case 28:
  17360. if (tokenizer$2.currentSequence === Sequences.CdataEnd) {
  17361. emitError(6, end);
  17362. } else {
  17363. emitError(7, end);
  17364. }
  17365. break;
  17366. case 6:
  17367. case 7:
  17368. case 9:
  17369. case 11:
  17370. case 12:
  17371. case 13:
  17372. case 14:
  17373. case 15:
  17374. case 16:
  17375. case 17:
  17376. case 18:
  17377. case 19:
  17378. case 20:
  17379. case 21:
  17380. emitError(9, end);
  17381. break;
  17382. }
  17383. }
  17384. for (let index = 0; index < stack.length; index++) {
  17385. onCloseTag(stack[index], end - 1);
  17386. emitError(24, stack[index].loc.start.offset);
  17387. }
  17388. },
  17389. oncdata(start, end) {
  17390. if (stack[0].ns !== 0) {
  17391. onText(getSlice(start, end), start, end);
  17392. } else {
  17393. emitError(1, start - 9);
  17394. }
  17395. },
  17396. onprocessinginstruction(start) {
  17397. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17398. emitError(
  17399. 21,
  17400. start - 1
  17401. );
  17402. }
  17403. }
  17404. });
  17405. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  17406. const stripParensRE = /^\(|\)$/g;
  17407. function parseForExpression(input) {
  17408. const loc = input.loc;
  17409. const exp = input.content;
  17410. const inMatch = exp.match(forAliasRE);
  17411. if (!inMatch)
  17412. return;
  17413. const [, LHS, RHS] = inMatch;
  17414. const createAliasExpression = (content, offset, asParam = false) => {
  17415. const start = loc.start.offset + offset;
  17416. const end = start + content.length;
  17417. return createExp(
  17418. content,
  17419. false,
  17420. getLoc(start, end),
  17421. 0,
  17422. asParam ? 1 /* Params */ : 0 /* Normal */
  17423. );
  17424. };
  17425. const result = {
  17426. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  17427. value: void 0,
  17428. key: void 0,
  17429. index: void 0,
  17430. finalized: false
  17431. };
  17432. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  17433. const trimmedOffset = LHS.indexOf(valueContent);
  17434. const iteratorMatch = valueContent.match(forIteratorRE);
  17435. if (iteratorMatch) {
  17436. valueContent = valueContent.replace(forIteratorRE, "").trim();
  17437. const keyContent = iteratorMatch[1].trim();
  17438. let keyOffset;
  17439. if (keyContent) {
  17440. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  17441. result.key = createAliasExpression(keyContent, keyOffset, true);
  17442. }
  17443. if (iteratorMatch[2]) {
  17444. const indexContent = iteratorMatch[2].trim();
  17445. if (indexContent) {
  17446. result.index = createAliasExpression(
  17447. indexContent,
  17448. exp.indexOf(
  17449. indexContent,
  17450. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  17451. ),
  17452. true
  17453. );
  17454. }
  17455. }
  17456. }
  17457. if (valueContent) {
  17458. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  17459. }
  17460. return result;
  17461. }
  17462. function getSlice(start, end) {
  17463. return currentInput.slice(start, end);
  17464. }
  17465. function endOpenTag(end) {
  17466. if (tokenizer$2.inSFCRoot) {
  17467. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  17468. }
  17469. addNode(currentOpenTag);
  17470. const { tag, ns } = currentOpenTag;
  17471. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17472. inPre++;
  17473. }
  17474. if (currentOptions.isVoidTag(tag)) {
  17475. onCloseTag(currentOpenTag, end);
  17476. } else {
  17477. stack.unshift(currentOpenTag);
  17478. if (ns === 1 || ns === 2) {
  17479. tokenizer$2.inXML = true;
  17480. }
  17481. }
  17482. currentOpenTag = null;
  17483. }
  17484. function onText(content, start, end) {
  17485. const parent = stack[0] || currentRoot;
  17486. const lastNode = parent.children[parent.children.length - 1];
  17487. if ((lastNode == null ? void 0 : lastNode.type) === 2) {
  17488. lastNode.content += content;
  17489. setLocEnd(lastNode.loc, end);
  17490. } else {
  17491. parent.children.push({
  17492. type: 2,
  17493. content,
  17494. loc: getLoc(start, end)
  17495. });
  17496. }
  17497. }
  17498. function onCloseTag(el, end, isImplied = false) {
  17499. if (isImplied) {
  17500. setLocEnd(el.loc, backTrack(end, 60));
  17501. } else {
  17502. setLocEnd(el.loc, end + 1);
  17503. }
  17504. if (tokenizer$2.inSFCRoot) {
  17505. if (el.children.length) {
  17506. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  17507. } else {
  17508. el.innerLoc.end = extend({}, el.innerLoc.start);
  17509. }
  17510. el.innerLoc.source = getSlice(
  17511. el.innerLoc.start.offset,
  17512. el.innerLoc.end.offset
  17513. );
  17514. }
  17515. const { tag, ns } = el;
  17516. if (!inVPre) {
  17517. if (tag === "slot") {
  17518. el.tagType = 2;
  17519. } else if (isFragmentTemplate(el)) {
  17520. el.tagType = 3;
  17521. } else if (isComponent(el)) {
  17522. el.tagType = 1;
  17523. }
  17524. }
  17525. if (!tokenizer$2.inRCDATA) {
  17526. el.children = condenseWhitespace(el.children, el.tag);
  17527. }
  17528. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17529. inPre--;
  17530. }
  17531. if (currentVPreBoundary === el) {
  17532. inVPre = tokenizer$2.inVPre = false;
  17533. currentVPreBoundary = null;
  17534. }
  17535. if (tokenizer$2.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17536. tokenizer$2.inXML = false;
  17537. }
  17538. }
  17539. function backTrack(index, c) {
  17540. let i = index;
  17541. while (currentInput.charCodeAt(i) !== c && i >= 0)
  17542. i--;
  17543. return i;
  17544. }
  17545. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  17546. function isFragmentTemplate({ tag, props }) {
  17547. if (tag === "template") {
  17548. for (let i = 0; i < props.length; i++) {
  17549. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  17550. return true;
  17551. }
  17552. }
  17553. }
  17554. return false;
  17555. }
  17556. function isComponent({ tag, props }) {
  17557. var _a;
  17558. if (currentOptions.isCustomElement(tag)) {
  17559. return false;
  17560. }
  17561. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  17562. return true;
  17563. }
  17564. for (let i = 0; i < props.length; i++) {
  17565. const p = props[i];
  17566. if (p.type === 6) {
  17567. if (p.name === "is" && p.value) {
  17568. if (p.value.content.startsWith("vue:")) {
  17569. return true;
  17570. }
  17571. }
  17572. }
  17573. }
  17574. return false;
  17575. }
  17576. function isUpperCase(c) {
  17577. return c > 64 && c < 91;
  17578. }
  17579. const windowsNewlineRE = /\r\n/g;
  17580. function condenseWhitespace(nodes, tag) {
  17581. var _a, _b;
  17582. const shouldCondense = currentOptions.whitespace !== "preserve";
  17583. let removedWhitespace = false;
  17584. for (let i = 0; i < nodes.length; i++) {
  17585. const node = nodes[i];
  17586. if (node.type === 2) {
  17587. if (!inPre) {
  17588. if (isAllWhitespace(node.content)) {
  17589. const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
  17590. const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
  17591. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  17592. removedWhitespace = true;
  17593. nodes[i] = null;
  17594. } else {
  17595. node.content = " ";
  17596. }
  17597. } else if (shouldCondense) {
  17598. node.content = condense(node.content);
  17599. }
  17600. } else {
  17601. node.content = node.content.replace(windowsNewlineRE, "\n");
  17602. }
  17603. }
  17604. }
  17605. if (inPre && tag && currentOptions.isPreTag(tag)) {
  17606. const first = nodes[0];
  17607. if (first && first.type === 2) {
  17608. first.content = first.content.replace(/^\r?\n/, "");
  17609. }
  17610. }
  17611. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  17612. }
  17613. function isAllWhitespace(str) {
  17614. for (let i = 0; i < str.length; i++) {
  17615. if (!isWhitespace$1(str.charCodeAt(i))) {
  17616. return false;
  17617. }
  17618. }
  17619. return true;
  17620. }
  17621. function hasNewlineChar(str) {
  17622. for (let i = 0; i < str.length; i++) {
  17623. const c = str.charCodeAt(i);
  17624. if (c === 10 || c === 13) {
  17625. return true;
  17626. }
  17627. }
  17628. return false;
  17629. }
  17630. function condense(str) {
  17631. let ret = "";
  17632. let prevCharIsWhitespace = false;
  17633. for (let i = 0; i < str.length; i++) {
  17634. if (isWhitespace$1(str.charCodeAt(i))) {
  17635. if (!prevCharIsWhitespace) {
  17636. ret += " ";
  17637. prevCharIsWhitespace = true;
  17638. }
  17639. } else {
  17640. ret += str[i];
  17641. prevCharIsWhitespace = false;
  17642. }
  17643. }
  17644. return ret;
  17645. }
  17646. function addNode(node) {
  17647. (stack[0] || currentRoot).children.push(node);
  17648. }
  17649. function getLoc(start, end) {
  17650. return {
  17651. start: tokenizer$2.getPos(start),
  17652. // @ts-expect-error allow late attachment
  17653. end: end == null ? end : tokenizer$2.getPos(end),
  17654. // @ts-expect-error allow late attachment
  17655. source: end == null ? end : getSlice(start, end)
  17656. };
  17657. }
  17658. function setLocEnd(loc, end) {
  17659. loc.end = tokenizer$2.getPos(end);
  17660. loc.source = getSlice(loc.start.offset, end);
  17661. }
  17662. function dirToAttr(dir) {
  17663. const attr = {
  17664. type: 6,
  17665. name: dir.rawName,
  17666. nameLoc: getLoc(
  17667. dir.loc.start.offset,
  17668. dir.loc.start.offset + dir.rawName.length
  17669. ),
  17670. value: void 0,
  17671. loc: dir.loc
  17672. };
  17673. if (dir.exp) {
  17674. const loc = dir.exp.loc;
  17675. if (loc.end.offset < dir.loc.end.offset) {
  17676. loc.start.offset--;
  17677. loc.start.column--;
  17678. loc.end.offset++;
  17679. loc.end.column++;
  17680. }
  17681. attr.value = {
  17682. type: 2,
  17683. content: dir.exp.content,
  17684. loc
  17685. };
  17686. }
  17687. return attr;
  17688. }
  17689. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  17690. const exp = createSimpleExpression(content, isStatic, loc, constType);
  17691. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  17692. if (isSimpleIdentifier(content)) {
  17693. exp.ast = null;
  17694. return exp;
  17695. }
  17696. try {
  17697. const plugins = currentOptions.expressionPlugins;
  17698. const options = {
  17699. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  17700. };
  17701. if (parseMode === 2 /* Statements */) {
  17702. exp.ast = parse_1$1(` ${content} `, options).program;
  17703. } else if (parseMode === 1 /* Params */) {
  17704. exp.ast = parseExpression_1(`(${content})=>{}`, options);
  17705. } else {
  17706. exp.ast = parseExpression_1(`(${content})`, options);
  17707. }
  17708. } catch (e) {
  17709. exp.ast = false;
  17710. emitError(45, loc.start.offset, e.message);
  17711. }
  17712. }
  17713. return exp;
  17714. }
  17715. function emitError(code, index, message) {
  17716. currentOptions.onError(
  17717. createCompilerError(code, getLoc(index, index), void 0, message)
  17718. );
  17719. }
  17720. function reset() {
  17721. tokenizer$2.reset();
  17722. currentOpenTag = null;
  17723. currentProp = null;
  17724. currentAttrValue = "";
  17725. currentAttrStartIndex = -1;
  17726. currentAttrEndIndex = -1;
  17727. stack.length = 0;
  17728. }
  17729. function baseParse(input, options) {
  17730. reset();
  17731. currentInput = input;
  17732. currentOptions = extend({}, defaultParserOptions);
  17733. if (options) {
  17734. let key;
  17735. for (key in options) {
  17736. if (options[key] != null) {
  17737. currentOptions[key] = options[key];
  17738. }
  17739. }
  17740. }
  17741. {
  17742. if (currentOptions.decodeEntities) {
  17743. console.warn(
  17744. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  17745. );
  17746. }
  17747. }
  17748. tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  17749. tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  17750. const delimiters = options == null ? void 0 : options.delimiters;
  17751. if (delimiters) {
  17752. tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
  17753. tokenizer$2.delimiterClose = toCharCodes(delimiters[1]);
  17754. }
  17755. const root = currentRoot = createRoot([], input);
  17756. tokenizer$2.parse(currentInput);
  17757. root.loc = getLoc(0, input.length);
  17758. root.children = condenseWhitespace(root.children);
  17759. currentRoot = null;
  17760. return root;
  17761. }
  17762. function hoistStatic(root, context) {
  17763. walk$1(
  17764. root,
  17765. context,
  17766. // Root node is unfortunately non-hoistable due to potential parent
  17767. // fallthrough attributes.
  17768. isSingleElementRoot(root, root.children[0])
  17769. );
  17770. }
  17771. function isSingleElementRoot(root, child) {
  17772. const { children } = root;
  17773. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  17774. }
  17775. function walk$1(node, context, doNotHoistNode = false) {
  17776. const { children } = node;
  17777. const originalCount = children.length;
  17778. let hoistedCount = 0;
  17779. for (let i = 0; i < children.length; i++) {
  17780. const child = children[i];
  17781. if (child.type === 1 && child.tagType === 0) {
  17782. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17783. if (constantType > 0) {
  17784. if (constantType >= 2) {
  17785. child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
  17786. child.codegenNode = context.hoist(child.codegenNode);
  17787. hoistedCount++;
  17788. continue;
  17789. }
  17790. } else {
  17791. const codegenNode = child.codegenNode;
  17792. if (codegenNode.type === 13) {
  17793. const flag = getPatchFlag(codegenNode);
  17794. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  17795. const props = getNodeProps(child);
  17796. if (props) {
  17797. codegenNode.props = context.hoist(props);
  17798. }
  17799. }
  17800. if (codegenNode.dynamicProps) {
  17801. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  17802. }
  17803. }
  17804. }
  17805. }
  17806. if (child.type === 1) {
  17807. const isComponent = child.tagType === 1;
  17808. if (isComponent) {
  17809. context.scopes.vSlot++;
  17810. }
  17811. walk$1(child, context);
  17812. if (isComponent) {
  17813. context.scopes.vSlot--;
  17814. }
  17815. } else if (child.type === 11) {
  17816. walk$1(child, context, child.children.length === 1);
  17817. } else if (child.type === 9) {
  17818. for (let i2 = 0; i2 < child.branches.length; i2++) {
  17819. walk$1(
  17820. child.branches[i2],
  17821. context,
  17822. child.branches[i2].children.length === 1
  17823. );
  17824. }
  17825. }
  17826. }
  17827. if (hoistedCount && context.transformHoist) {
  17828. context.transformHoist(children, context, node);
  17829. }
  17830. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  17831. const hoisted = context.hoist(
  17832. createArrayExpression(node.codegenNode.children)
  17833. );
  17834. if (context.hmr) {
  17835. hoisted.content = `[...${hoisted.content}]`;
  17836. }
  17837. node.codegenNode.children = hoisted;
  17838. }
  17839. }
  17840. function getConstantType(node, context) {
  17841. const { constantCache } = context;
  17842. switch (node.type) {
  17843. case 1:
  17844. if (node.tagType !== 0) {
  17845. return 0;
  17846. }
  17847. const cached = constantCache.get(node);
  17848. if (cached !== void 0) {
  17849. return cached;
  17850. }
  17851. const codegenNode = node.codegenNode;
  17852. if (codegenNode.type !== 13) {
  17853. return 0;
  17854. }
  17855. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  17856. return 0;
  17857. }
  17858. const flag = getPatchFlag(codegenNode);
  17859. if (!flag) {
  17860. let returnType2 = 3;
  17861. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  17862. if (generatedPropsType === 0) {
  17863. constantCache.set(node, 0);
  17864. return 0;
  17865. }
  17866. if (generatedPropsType < returnType2) {
  17867. returnType2 = generatedPropsType;
  17868. }
  17869. for (let i = 0; i < node.children.length; i++) {
  17870. const childType = getConstantType(node.children[i], context);
  17871. if (childType === 0) {
  17872. constantCache.set(node, 0);
  17873. return 0;
  17874. }
  17875. if (childType < returnType2) {
  17876. returnType2 = childType;
  17877. }
  17878. }
  17879. if (returnType2 > 1) {
  17880. for (let i = 0; i < node.props.length; i++) {
  17881. const p = node.props[i];
  17882. if (p.type === 7 && p.name === "bind" && p.exp) {
  17883. const expType = getConstantType(p.exp, context);
  17884. if (expType === 0) {
  17885. constantCache.set(node, 0);
  17886. return 0;
  17887. }
  17888. if (expType < returnType2) {
  17889. returnType2 = expType;
  17890. }
  17891. }
  17892. }
  17893. }
  17894. if (codegenNode.isBlock) {
  17895. for (let i = 0; i < node.props.length; i++) {
  17896. const p = node.props[i];
  17897. if (p.type === 7) {
  17898. constantCache.set(node, 0);
  17899. return 0;
  17900. }
  17901. }
  17902. context.removeHelper(OPEN_BLOCK);
  17903. context.removeHelper(
  17904. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  17905. );
  17906. codegenNode.isBlock = false;
  17907. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  17908. }
  17909. constantCache.set(node, returnType2);
  17910. return returnType2;
  17911. } else {
  17912. constantCache.set(node, 0);
  17913. return 0;
  17914. }
  17915. case 2:
  17916. case 3:
  17917. return 3;
  17918. case 9:
  17919. case 11:
  17920. case 10:
  17921. return 0;
  17922. case 5:
  17923. case 12:
  17924. return getConstantType(node.content, context);
  17925. case 4:
  17926. return node.constType;
  17927. case 8:
  17928. let returnType = 3;
  17929. for (let i = 0; i < node.children.length; i++) {
  17930. const child = node.children[i];
  17931. if (isString$2(child) || isSymbol$1(child)) {
  17932. continue;
  17933. }
  17934. const childType = getConstantType(child, context);
  17935. if (childType === 0) {
  17936. return 0;
  17937. } else if (childType < returnType) {
  17938. returnType = childType;
  17939. }
  17940. }
  17941. return returnType;
  17942. default:
  17943. return 0;
  17944. }
  17945. }
  17946. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  17947. NORMALIZE_CLASS,
  17948. NORMALIZE_STYLE,
  17949. NORMALIZE_PROPS,
  17950. GUARD_REACTIVE_PROPS
  17951. ]);
  17952. function getConstantTypeOfHelperCall(value, context) {
  17953. if (value.type === 14 && !isString$2(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  17954. const arg = value.arguments[0];
  17955. if (arg.type === 4) {
  17956. return getConstantType(arg, context);
  17957. } else if (arg.type === 14) {
  17958. return getConstantTypeOfHelperCall(arg, context);
  17959. }
  17960. }
  17961. return 0;
  17962. }
  17963. function getGeneratedPropsConstantType(node, context) {
  17964. let returnType = 3;
  17965. const props = getNodeProps(node);
  17966. if (props && props.type === 15) {
  17967. const { properties } = props;
  17968. for (let i = 0; i < properties.length; i++) {
  17969. const { key, value } = properties[i];
  17970. const keyType = getConstantType(key, context);
  17971. if (keyType === 0) {
  17972. return keyType;
  17973. }
  17974. if (keyType < returnType) {
  17975. returnType = keyType;
  17976. }
  17977. let valueType;
  17978. if (value.type === 4) {
  17979. valueType = getConstantType(value, context);
  17980. } else if (value.type === 14) {
  17981. valueType = getConstantTypeOfHelperCall(value, context);
  17982. } else {
  17983. valueType = 0;
  17984. }
  17985. if (valueType === 0) {
  17986. return valueType;
  17987. }
  17988. if (valueType < returnType) {
  17989. returnType = valueType;
  17990. }
  17991. }
  17992. }
  17993. return returnType;
  17994. }
  17995. function getNodeProps(node) {
  17996. const codegenNode = node.codegenNode;
  17997. if (codegenNode.type === 13) {
  17998. return codegenNode.props;
  17999. }
  18000. }
  18001. function getPatchFlag(node) {
  18002. const flag = node.patchFlag;
  18003. return flag ? parseInt(flag, 10) : void 0;
  18004. }
  18005. function createTransformContext(root, {
  18006. filename = "",
  18007. prefixIdentifiers = false,
  18008. hoistStatic: hoistStatic2 = false,
  18009. hmr = false,
  18010. cacheHandlers = false,
  18011. nodeTransforms = [],
  18012. directiveTransforms = {},
  18013. transformHoist = null,
  18014. isBuiltInComponent = NOOP,
  18015. isCustomElement = NOOP,
  18016. expressionPlugins = [],
  18017. scopeId = null,
  18018. slotted = true,
  18019. ssr = false,
  18020. inSSR = false,
  18021. ssrCssVars = ``,
  18022. bindingMetadata = EMPTY_OBJ,
  18023. inline = false,
  18024. isTS = false,
  18025. onError = defaultOnError,
  18026. onWarn = defaultOnWarn,
  18027. compatConfig
  18028. }) {
  18029. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18030. const context = {
  18031. // options
  18032. filename,
  18033. selfName: nameMatch && capitalize$1(camelize(nameMatch[1])),
  18034. prefixIdentifiers,
  18035. hoistStatic: hoistStatic2,
  18036. hmr,
  18037. cacheHandlers,
  18038. nodeTransforms,
  18039. directiveTransforms,
  18040. transformHoist,
  18041. isBuiltInComponent,
  18042. isCustomElement,
  18043. expressionPlugins,
  18044. scopeId,
  18045. slotted,
  18046. ssr,
  18047. inSSR,
  18048. ssrCssVars,
  18049. bindingMetadata,
  18050. inline,
  18051. isTS,
  18052. onError,
  18053. onWarn,
  18054. compatConfig,
  18055. // state
  18056. root,
  18057. helpers: /* @__PURE__ */ new Map(),
  18058. components: /* @__PURE__ */ new Set(),
  18059. directives: /* @__PURE__ */ new Set(),
  18060. hoists: [],
  18061. imports: [],
  18062. constantCache: /* @__PURE__ */ new WeakMap(),
  18063. temps: 0,
  18064. cached: 0,
  18065. identifiers: /* @__PURE__ */ Object.create(null),
  18066. scopes: {
  18067. vFor: 0,
  18068. vSlot: 0,
  18069. vPre: 0,
  18070. vOnce: 0
  18071. },
  18072. parent: null,
  18073. currentNode: root,
  18074. childIndex: 0,
  18075. inVOnce: false,
  18076. // methods
  18077. helper(name) {
  18078. const count = context.helpers.get(name) || 0;
  18079. context.helpers.set(name, count + 1);
  18080. return name;
  18081. },
  18082. removeHelper(name) {
  18083. const count = context.helpers.get(name);
  18084. if (count) {
  18085. const currentCount = count - 1;
  18086. if (!currentCount) {
  18087. context.helpers.delete(name);
  18088. } else {
  18089. context.helpers.set(name, currentCount);
  18090. }
  18091. }
  18092. },
  18093. helperString(name) {
  18094. return `_${helperNameMap[context.helper(name)]}`;
  18095. },
  18096. replaceNode(node) {
  18097. {
  18098. if (!context.currentNode) {
  18099. throw new Error(`Node being replaced is already removed.`);
  18100. }
  18101. if (!context.parent) {
  18102. throw new Error(`Cannot replace root node.`);
  18103. }
  18104. }
  18105. context.parent.children[context.childIndex] = context.currentNode = node;
  18106. },
  18107. removeNode(node) {
  18108. if (!context.parent) {
  18109. throw new Error(`Cannot remove root node.`);
  18110. }
  18111. const list = context.parent.children;
  18112. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18113. if (removalIndex < 0) {
  18114. throw new Error(`node being removed is not a child of current parent`);
  18115. }
  18116. if (!node || node === context.currentNode) {
  18117. context.currentNode = null;
  18118. context.onNodeRemoved();
  18119. } else {
  18120. if (context.childIndex > removalIndex) {
  18121. context.childIndex--;
  18122. context.onNodeRemoved();
  18123. }
  18124. }
  18125. context.parent.children.splice(removalIndex, 1);
  18126. },
  18127. onNodeRemoved: NOOP,
  18128. addIdentifiers(exp) {
  18129. {
  18130. if (isString$2(exp)) {
  18131. addId(exp);
  18132. } else if (exp.identifiers) {
  18133. exp.identifiers.forEach(addId);
  18134. } else if (exp.type === 4) {
  18135. addId(exp.content);
  18136. }
  18137. }
  18138. },
  18139. removeIdentifiers(exp) {
  18140. {
  18141. if (isString$2(exp)) {
  18142. removeId(exp);
  18143. } else if (exp.identifiers) {
  18144. exp.identifiers.forEach(removeId);
  18145. } else if (exp.type === 4) {
  18146. removeId(exp.content);
  18147. }
  18148. }
  18149. },
  18150. hoist(exp) {
  18151. if (isString$2(exp))
  18152. exp = createSimpleExpression(exp);
  18153. context.hoists.push(exp);
  18154. const identifier = createSimpleExpression(
  18155. `_hoisted_${context.hoists.length}`,
  18156. false,
  18157. exp.loc,
  18158. 2
  18159. );
  18160. identifier.hoisted = exp;
  18161. return identifier;
  18162. },
  18163. cache(exp, isVNode = false) {
  18164. return createCacheExpression(context.cached++, exp, isVNode);
  18165. }
  18166. };
  18167. function addId(id) {
  18168. const { identifiers } = context;
  18169. if (identifiers[id] === void 0) {
  18170. identifiers[id] = 0;
  18171. }
  18172. identifiers[id]++;
  18173. }
  18174. function removeId(id) {
  18175. context.identifiers[id]--;
  18176. }
  18177. return context;
  18178. }
  18179. function transform(root, options) {
  18180. const context = createTransformContext(root, options);
  18181. traverseNode(root, context);
  18182. if (options.hoistStatic) {
  18183. hoistStatic(root, context);
  18184. }
  18185. if (!options.ssr) {
  18186. createRootCodegen(root, context);
  18187. }
  18188. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  18189. root.components = [...context.components];
  18190. root.directives = [...context.directives];
  18191. root.imports = context.imports;
  18192. root.hoists = context.hoists;
  18193. root.temps = context.temps;
  18194. root.cached = context.cached;
  18195. root.transformed = true;
  18196. }
  18197. function createRootCodegen(root, context) {
  18198. const { helper } = context;
  18199. const { children } = root;
  18200. if (children.length === 1) {
  18201. const child = children[0];
  18202. if (isSingleElementRoot(root, child) && child.codegenNode) {
  18203. const codegenNode = child.codegenNode;
  18204. if (codegenNode.type === 13) {
  18205. convertToBlock(codegenNode, context);
  18206. }
  18207. root.codegenNode = codegenNode;
  18208. } else {
  18209. root.codegenNode = child;
  18210. }
  18211. } else if (children.length > 1) {
  18212. let patchFlag = 64;
  18213. let patchFlagText = PatchFlagNames[64];
  18214. if (children.filter((c) => c.type !== 3).length === 1) {
  18215. patchFlag |= 2048;
  18216. patchFlagText += `, ${PatchFlagNames[2048]}`;
  18217. }
  18218. root.codegenNode = createVNodeCall(
  18219. context,
  18220. helper(FRAGMENT),
  18221. void 0,
  18222. root.children,
  18223. patchFlag + (` /* ${patchFlagText} */` ),
  18224. void 0,
  18225. void 0,
  18226. true,
  18227. void 0,
  18228. false
  18229. );
  18230. } else ;
  18231. }
  18232. function traverseChildren(parent, context) {
  18233. let i = 0;
  18234. const nodeRemoved = () => {
  18235. i--;
  18236. };
  18237. for (; i < parent.children.length; i++) {
  18238. const child = parent.children[i];
  18239. if (isString$2(child))
  18240. continue;
  18241. context.parent = parent;
  18242. context.childIndex = i;
  18243. context.onNodeRemoved = nodeRemoved;
  18244. traverseNode(child, context);
  18245. }
  18246. }
  18247. function traverseNode(node, context) {
  18248. context.currentNode = node;
  18249. const { nodeTransforms } = context;
  18250. const exitFns = [];
  18251. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  18252. const onExit = nodeTransforms[i2](node, context);
  18253. if (onExit) {
  18254. if (isArray$3(onExit)) {
  18255. exitFns.push(...onExit);
  18256. } else {
  18257. exitFns.push(onExit);
  18258. }
  18259. }
  18260. if (!context.currentNode) {
  18261. return;
  18262. } else {
  18263. node = context.currentNode;
  18264. }
  18265. }
  18266. switch (node.type) {
  18267. case 3:
  18268. if (!context.ssr) {
  18269. context.helper(CREATE_COMMENT);
  18270. }
  18271. break;
  18272. case 5:
  18273. if (!context.ssr) {
  18274. context.helper(TO_DISPLAY_STRING);
  18275. }
  18276. break;
  18277. case 9:
  18278. for (let i2 = 0; i2 < node.branches.length; i2++) {
  18279. traverseNode(node.branches[i2], context);
  18280. }
  18281. break;
  18282. case 10:
  18283. case 11:
  18284. case 1:
  18285. case 0:
  18286. traverseChildren(node, context);
  18287. break;
  18288. }
  18289. context.currentNode = node;
  18290. let i = exitFns.length;
  18291. while (i--) {
  18292. exitFns[i]();
  18293. }
  18294. }
  18295. function createStructuralDirectiveTransform(name, fn) {
  18296. const matches = isString$2(name) ? (n) => n === name : (n) => name.test(n);
  18297. return (node, context) => {
  18298. if (node.type === 1) {
  18299. const { props } = node;
  18300. if (node.tagType === 3 && props.some(isVSlot)) {
  18301. return;
  18302. }
  18303. const exitFns = [];
  18304. for (let i = 0; i < props.length; i++) {
  18305. const prop = props[i];
  18306. if (prop.type === 7 && matches(prop.name)) {
  18307. props.splice(i, 1);
  18308. i--;
  18309. const onExit = fn(node, prop, context);
  18310. if (onExit)
  18311. exitFns.push(onExit);
  18312. }
  18313. }
  18314. return exitFns;
  18315. }
  18316. };
  18317. }
  18318. var sourceMap$2 = {};
  18319. var sourceMapGenerator$1 = {};
  18320. var base64Vlq$1 = {};
  18321. var base64$3 = {};
  18322. /* -*- Mode: js; js-indent-level: 2; -*- */
  18323. /*
  18324. * Copyright 2011 Mozilla Foundation and contributors
  18325. * Licensed under the New BSD license. See LICENSE or:
  18326. * http://opensource.org/licenses/BSD-3-Clause
  18327. */
  18328. var intToCharMap$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  18329. /**
  18330. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  18331. */
  18332. base64$3.encode = function (number) {
  18333. if (0 <= number && number < intToCharMap$1.length) {
  18334. return intToCharMap$1[number];
  18335. }
  18336. throw new TypeError("Must be between 0 and 63: " + number);
  18337. };
  18338. /**
  18339. * Decode a single base 64 character code digit to an integer. Returns -1 on
  18340. * failure.
  18341. */
  18342. base64$3.decode = function (charCode) {
  18343. var bigA = 65; // 'A'
  18344. var bigZ = 90; // 'Z'
  18345. var littleA = 97; // 'a'
  18346. var littleZ = 122; // 'z'
  18347. var zero = 48; // '0'
  18348. var nine = 57; // '9'
  18349. var plus = 43; // '+'
  18350. var slash = 47; // '/'
  18351. var littleOffset = 26;
  18352. var numberOffset = 52;
  18353. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  18354. if (bigA <= charCode && charCode <= bigZ) {
  18355. return (charCode - bigA);
  18356. }
  18357. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  18358. if (littleA <= charCode && charCode <= littleZ) {
  18359. return (charCode - littleA + littleOffset);
  18360. }
  18361. // 52 - 61: 0123456789
  18362. if (zero <= charCode && charCode <= nine) {
  18363. return (charCode - zero + numberOffset);
  18364. }
  18365. // 62: +
  18366. if (charCode == plus) {
  18367. return 62;
  18368. }
  18369. // 63: /
  18370. if (charCode == slash) {
  18371. return 63;
  18372. }
  18373. // Invalid base64 digit.
  18374. return -1;
  18375. };
  18376. /* -*- Mode: js; js-indent-level: 2; -*- */
  18377. /*
  18378. * Copyright 2011 Mozilla Foundation and contributors
  18379. * Licensed under the New BSD license. See LICENSE or:
  18380. * http://opensource.org/licenses/BSD-3-Clause
  18381. *
  18382. * Based on the Base 64 VLQ implementation in Closure Compiler:
  18383. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  18384. *
  18385. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  18386. * Redistribution and use in source and binary forms, with or without
  18387. * modification, are permitted provided that the following conditions are
  18388. * met:
  18389. *
  18390. * * Redistributions of source code must retain the above copyright
  18391. * notice, this list of conditions and the following disclaimer.
  18392. * * Redistributions in binary form must reproduce the above
  18393. * copyright notice, this list of conditions and the following
  18394. * disclaimer in the documentation and/or other materials provided
  18395. * with the distribution.
  18396. * * Neither the name of Google Inc. nor the names of its
  18397. * contributors may be used to endorse or promote products derived
  18398. * from this software without specific prior written permission.
  18399. *
  18400. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18401. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18402. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18403. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18404. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18405. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18406. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18407. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18408. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18409. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18410. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18411. */
  18412. var base64$2 = base64$3;
  18413. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  18414. // length quantities we use in the source map spec, the first bit is the sign,
  18415. // the next four bits are the actual value, and the 6th bit is the
  18416. // continuation bit. The continuation bit tells us whether there are more
  18417. // digits in this value following this digit.
  18418. //
  18419. // Continuation
  18420. // | Sign
  18421. // | |
  18422. // V V
  18423. // 101011
  18424. var VLQ_BASE_SHIFT$1 = 5;
  18425. // binary: 100000
  18426. var VLQ_BASE$1 = 1 << VLQ_BASE_SHIFT$1;
  18427. // binary: 011111
  18428. var VLQ_BASE_MASK$1 = VLQ_BASE$1 - 1;
  18429. // binary: 100000
  18430. var VLQ_CONTINUATION_BIT$1 = VLQ_BASE$1;
  18431. /**
  18432. * Converts from a two-complement value to a value where the sign bit is
  18433. * placed in the least significant bit. For example, as decimals:
  18434. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  18435. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  18436. */
  18437. function toVLQSigned$1(aValue) {
  18438. return aValue < 0
  18439. ? ((-aValue) << 1) + 1
  18440. : (aValue << 1) + 0;
  18441. }
  18442. /**
  18443. * Converts to a two-complement value from a value where the sign bit is
  18444. * placed in the least significant bit. For example, as decimals:
  18445. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  18446. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  18447. */
  18448. function fromVLQSigned$1(aValue) {
  18449. var isNegative = (aValue & 1) === 1;
  18450. var shifted = aValue >> 1;
  18451. return isNegative
  18452. ? -shifted
  18453. : shifted;
  18454. }
  18455. /**
  18456. * Returns the base 64 VLQ encoded value.
  18457. */
  18458. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  18459. var encoded = "";
  18460. var digit;
  18461. var vlq = toVLQSigned$1(aValue);
  18462. do {
  18463. digit = vlq & VLQ_BASE_MASK$1;
  18464. vlq >>>= VLQ_BASE_SHIFT$1;
  18465. if (vlq > 0) {
  18466. // There are still more digits in this value, so we must make sure the
  18467. // continuation bit is marked.
  18468. digit |= VLQ_CONTINUATION_BIT$1;
  18469. }
  18470. encoded += base64$2.encode(digit);
  18471. } while (vlq > 0);
  18472. return encoded;
  18473. };
  18474. /**
  18475. * Decodes the next base 64 VLQ value from the given string and returns the
  18476. * value and the rest of the string via the out parameter.
  18477. */
  18478. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  18479. var strLen = aStr.length;
  18480. var result = 0;
  18481. var shift = 0;
  18482. var continuation, digit;
  18483. do {
  18484. if (aIndex >= strLen) {
  18485. throw new Error("Expected more digits in base 64 VLQ value.");
  18486. }
  18487. digit = base64$2.decode(aStr.charCodeAt(aIndex++));
  18488. if (digit === -1) {
  18489. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  18490. }
  18491. continuation = !!(digit & VLQ_CONTINUATION_BIT$1);
  18492. digit &= VLQ_BASE_MASK$1;
  18493. result = result + (digit << shift);
  18494. shift += VLQ_BASE_SHIFT$1;
  18495. } while (continuation);
  18496. aOutParam.value = fromVLQSigned$1(result);
  18497. aOutParam.rest = aIndex;
  18498. };
  18499. var util$c = {};
  18500. /* -*- Mode: js; js-indent-level: 2; -*- */
  18501. (function (exports) {
  18502. /*
  18503. * Copyright 2011 Mozilla Foundation and contributors
  18504. * Licensed under the New BSD license. See LICENSE or:
  18505. * http://opensource.org/licenses/BSD-3-Clause
  18506. */
  18507. /**
  18508. * This is a helper function for getting values from parameter/options
  18509. * objects.
  18510. *
  18511. * @param args The object we are extracting values from
  18512. * @param name The name of the property we are getting.
  18513. * @param defaultValue An optional value to return if the property is missing
  18514. * from the object. If this is not specified and the property is missing, an
  18515. * error will be thrown.
  18516. */
  18517. function getArg(aArgs, aName, aDefaultValue) {
  18518. if (aName in aArgs) {
  18519. return aArgs[aName];
  18520. } else if (arguments.length === 3) {
  18521. return aDefaultValue;
  18522. } else {
  18523. throw new Error('"' + aName + '" is a required argument.');
  18524. }
  18525. }
  18526. exports.getArg = getArg;
  18527. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  18528. var dataUrlRegexp = /^data:.+\,.+$/;
  18529. function urlParse(aUrl) {
  18530. var match = aUrl.match(urlRegexp);
  18531. if (!match) {
  18532. return null;
  18533. }
  18534. return {
  18535. scheme: match[1],
  18536. auth: match[2],
  18537. host: match[3],
  18538. port: match[4],
  18539. path: match[5]
  18540. };
  18541. }
  18542. exports.urlParse = urlParse;
  18543. function urlGenerate(aParsedUrl) {
  18544. var url = '';
  18545. if (aParsedUrl.scheme) {
  18546. url += aParsedUrl.scheme + ':';
  18547. }
  18548. url += '//';
  18549. if (aParsedUrl.auth) {
  18550. url += aParsedUrl.auth + '@';
  18551. }
  18552. if (aParsedUrl.host) {
  18553. url += aParsedUrl.host;
  18554. }
  18555. if (aParsedUrl.port) {
  18556. url += ":" + aParsedUrl.port;
  18557. }
  18558. if (aParsedUrl.path) {
  18559. url += aParsedUrl.path;
  18560. }
  18561. return url;
  18562. }
  18563. exports.urlGenerate = urlGenerate;
  18564. var MAX_CACHED_INPUTS = 32;
  18565. /**
  18566. * Takes some function `f(input) -> result` and returns a memoized version of
  18567. * `f`.
  18568. *
  18569. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  18570. * memoization is a dumb-simple, linear least-recently-used cache.
  18571. */
  18572. function lruMemoize(f) {
  18573. var cache = [];
  18574. return function(input) {
  18575. for (var i = 0; i < cache.length; i++) {
  18576. if (cache[i].input === input) {
  18577. var temp = cache[0];
  18578. cache[0] = cache[i];
  18579. cache[i] = temp;
  18580. return cache[0].result;
  18581. }
  18582. }
  18583. var result = f(input);
  18584. cache.unshift({
  18585. input,
  18586. result,
  18587. });
  18588. if (cache.length > MAX_CACHED_INPUTS) {
  18589. cache.pop();
  18590. }
  18591. return result;
  18592. };
  18593. }
  18594. /**
  18595. * Normalizes a path, or the path portion of a URL:
  18596. *
  18597. * - Replaces consecutive slashes with one slash.
  18598. * - Removes unnecessary '.' parts.
  18599. * - Removes unnecessary '<dir>/..' parts.
  18600. *
  18601. * Based on code in the Node.js 'path' core module.
  18602. *
  18603. * @param aPath The path or url to normalize.
  18604. */
  18605. var normalize = lruMemoize(function normalize(aPath) {
  18606. var path = aPath;
  18607. var url = urlParse(aPath);
  18608. if (url) {
  18609. if (!url.path) {
  18610. return aPath;
  18611. }
  18612. path = url.path;
  18613. }
  18614. var isAbsolute = exports.isAbsolute(path);
  18615. // Split the path into parts between `/` characters. This is much faster than
  18616. // using `.split(/\/+/g)`.
  18617. var parts = [];
  18618. var start = 0;
  18619. var i = 0;
  18620. while (true) {
  18621. start = i;
  18622. i = path.indexOf("/", start);
  18623. if (i === -1) {
  18624. parts.push(path.slice(start));
  18625. break;
  18626. } else {
  18627. parts.push(path.slice(start, i));
  18628. while (i < path.length && path[i] === "/") {
  18629. i++;
  18630. }
  18631. }
  18632. }
  18633. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  18634. part = parts[i];
  18635. if (part === '.') {
  18636. parts.splice(i, 1);
  18637. } else if (part === '..') {
  18638. up++;
  18639. } else if (up > 0) {
  18640. if (part === '') {
  18641. // The first part is blank if the path is absolute. Trying to go
  18642. // above the root is a no-op. Therefore we can remove all '..' parts
  18643. // directly after the root.
  18644. parts.splice(i + 1, up);
  18645. up = 0;
  18646. } else {
  18647. parts.splice(i, 2);
  18648. up--;
  18649. }
  18650. }
  18651. }
  18652. path = parts.join('/');
  18653. if (path === '') {
  18654. path = isAbsolute ? '/' : '.';
  18655. }
  18656. if (url) {
  18657. url.path = path;
  18658. return urlGenerate(url);
  18659. }
  18660. return path;
  18661. });
  18662. exports.normalize = normalize;
  18663. /**
  18664. * Joins two paths/URLs.
  18665. *
  18666. * @param aRoot The root path or URL.
  18667. * @param aPath The path or URL to be joined with the root.
  18668. *
  18669. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  18670. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  18671. * first.
  18672. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  18673. * is updated with the result and aRoot is returned. Otherwise the result
  18674. * is returned.
  18675. * - If aPath is absolute, the result is aPath.
  18676. * - Otherwise the two paths are joined with a slash.
  18677. * - Joining for example 'http://' and 'www.example.com' is also supported.
  18678. */
  18679. function join(aRoot, aPath) {
  18680. if (aRoot === "") {
  18681. aRoot = ".";
  18682. }
  18683. if (aPath === "") {
  18684. aPath = ".";
  18685. }
  18686. var aPathUrl = urlParse(aPath);
  18687. var aRootUrl = urlParse(aRoot);
  18688. if (aRootUrl) {
  18689. aRoot = aRootUrl.path || '/';
  18690. }
  18691. // `join(foo, '//www.example.org')`
  18692. if (aPathUrl && !aPathUrl.scheme) {
  18693. if (aRootUrl) {
  18694. aPathUrl.scheme = aRootUrl.scheme;
  18695. }
  18696. return urlGenerate(aPathUrl);
  18697. }
  18698. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  18699. return aPath;
  18700. }
  18701. // `join('http://', 'www.example.com')`
  18702. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  18703. aRootUrl.host = aPath;
  18704. return urlGenerate(aRootUrl);
  18705. }
  18706. var joined = aPath.charAt(0) === '/'
  18707. ? aPath
  18708. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  18709. if (aRootUrl) {
  18710. aRootUrl.path = joined;
  18711. return urlGenerate(aRootUrl);
  18712. }
  18713. return joined;
  18714. }
  18715. exports.join = join;
  18716. exports.isAbsolute = function (aPath) {
  18717. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  18718. };
  18719. /**
  18720. * Make a path relative to a URL or another path.
  18721. *
  18722. * @param aRoot The root path or URL.
  18723. * @param aPath The path or URL to be made relative to aRoot.
  18724. */
  18725. function relative(aRoot, aPath) {
  18726. if (aRoot === "") {
  18727. aRoot = ".";
  18728. }
  18729. aRoot = aRoot.replace(/\/$/, '');
  18730. // It is possible for the path to be above the root. In this case, simply
  18731. // checking whether the root is a prefix of the path won't work. Instead, we
  18732. // need to remove components from the root one by one, until either we find
  18733. // a prefix that fits, or we run out of components to remove.
  18734. var level = 0;
  18735. while (aPath.indexOf(aRoot + '/') !== 0) {
  18736. var index = aRoot.lastIndexOf("/");
  18737. if (index < 0) {
  18738. return aPath;
  18739. }
  18740. // If the only part of the root that is left is the scheme (i.e. http://,
  18741. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  18742. // have exhausted all components, so the path is not relative to the root.
  18743. aRoot = aRoot.slice(0, index);
  18744. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  18745. return aPath;
  18746. }
  18747. ++level;
  18748. }
  18749. // Make sure we add a "../" for each component we removed from the root.
  18750. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  18751. }
  18752. exports.relative = relative;
  18753. var supportsNullProto = (function () {
  18754. var obj = Object.create(null);
  18755. return !('__proto__' in obj);
  18756. }());
  18757. function identity (s) {
  18758. return s;
  18759. }
  18760. /**
  18761. * Because behavior goes wacky when you set `__proto__` on objects, we
  18762. * have to prefix all the strings in our set with an arbitrary character.
  18763. *
  18764. * See https://github.com/mozilla/source-map/pull/31 and
  18765. * https://github.com/mozilla/source-map/issues/30
  18766. *
  18767. * @param String aStr
  18768. */
  18769. function toSetString(aStr) {
  18770. if (isProtoString(aStr)) {
  18771. return '$' + aStr;
  18772. }
  18773. return aStr;
  18774. }
  18775. exports.toSetString = supportsNullProto ? identity : toSetString;
  18776. function fromSetString(aStr) {
  18777. if (isProtoString(aStr)) {
  18778. return aStr.slice(1);
  18779. }
  18780. return aStr;
  18781. }
  18782. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  18783. function isProtoString(s) {
  18784. if (!s) {
  18785. return false;
  18786. }
  18787. var length = s.length;
  18788. if (length < 9 /* "__proto__".length */) {
  18789. return false;
  18790. }
  18791. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  18792. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  18793. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  18794. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  18795. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  18796. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  18797. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  18798. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  18799. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  18800. return false;
  18801. }
  18802. for (var i = length - 10; i >= 0; i--) {
  18803. if (s.charCodeAt(i) !== 36 /* '$' */) {
  18804. return false;
  18805. }
  18806. }
  18807. return true;
  18808. }
  18809. /**
  18810. * Comparator between two mappings where the original positions are compared.
  18811. *
  18812. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18813. * mappings with the same original source/line/column, but different generated
  18814. * line and column the same. Useful when searching for a mapping with a
  18815. * stubbed out mapping.
  18816. */
  18817. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  18818. var cmp = strcmp(mappingA.source, mappingB.source);
  18819. if (cmp !== 0) {
  18820. return cmp;
  18821. }
  18822. cmp = mappingA.originalLine - mappingB.originalLine;
  18823. if (cmp !== 0) {
  18824. return cmp;
  18825. }
  18826. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18827. if (cmp !== 0 || onlyCompareOriginal) {
  18828. return cmp;
  18829. }
  18830. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18831. if (cmp !== 0) {
  18832. return cmp;
  18833. }
  18834. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18835. if (cmp !== 0) {
  18836. return cmp;
  18837. }
  18838. return strcmp(mappingA.name, mappingB.name);
  18839. }
  18840. exports.compareByOriginalPositions = compareByOriginalPositions;
  18841. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  18842. var cmp;
  18843. cmp = mappingA.originalLine - mappingB.originalLine;
  18844. if (cmp !== 0) {
  18845. return cmp;
  18846. }
  18847. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18848. if (cmp !== 0 || onlyCompareOriginal) {
  18849. return cmp;
  18850. }
  18851. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18852. if (cmp !== 0) {
  18853. return cmp;
  18854. }
  18855. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18856. if (cmp !== 0) {
  18857. return cmp;
  18858. }
  18859. return strcmp(mappingA.name, mappingB.name);
  18860. }
  18861. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  18862. /**
  18863. * Comparator between two mappings with deflated source and name indices where
  18864. * the generated positions are compared.
  18865. *
  18866. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18867. * mappings with the same generated line and column, but different
  18868. * source/name/original line and column the same. Useful when searching for a
  18869. * mapping with a stubbed out mapping.
  18870. */
  18871. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  18872. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18873. if (cmp !== 0) {
  18874. return cmp;
  18875. }
  18876. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18877. if (cmp !== 0 || onlyCompareGenerated) {
  18878. return cmp;
  18879. }
  18880. cmp = strcmp(mappingA.source, mappingB.source);
  18881. if (cmp !== 0) {
  18882. return cmp;
  18883. }
  18884. cmp = mappingA.originalLine - mappingB.originalLine;
  18885. if (cmp !== 0) {
  18886. return cmp;
  18887. }
  18888. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18889. if (cmp !== 0) {
  18890. return cmp;
  18891. }
  18892. return strcmp(mappingA.name, mappingB.name);
  18893. }
  18894. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  18895. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  18896. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18897. if (cmp !== 0 || onlyCompareGenerated) {
  18898. return cmp;
  18899. }
  18900. cmp = strcmp(mappingA.source, mappingB.source);
  18901. if (cmp !== 0) {
  18902. return cmp;
  18903. }
  18904. cmp = mappingA.originalLine - mappingB.originalLine;
  18905. if (cmp !== 0) {
  18906. return cmp;
  18907. }
  18908. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18909. if (cmp !== 0) {
  18910. return cmp;
  18911. }
  18912. return strcmp(mappingA.name, mappingB.name);
  18913. }
  18914. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  18915. function strcmp(aStr1, aStr2) {
  18916. if (aStr1 === aStr2) {
  18917. return 0;
  18918. }
  18919. if (aStr1 === null) {
  18920. return 1; // aStr2 !== null
  18921. }
  18922. if (aStr2 === null) {
  18923. return -1; // aStr1 !== null
  18924. }
  18925. if (aStr1 > aStr2) {
  18926. return 1;
  18927. }
  18928. return -1;
  18929. }
  18930. /**
  18931. * Comparator between two mappings with inflated source and name strings where
  18932. * the generated positions are compared.
  18933. */
  18934. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  18935. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18936. if (cmp !== 0) {
  18937. return cmp;
  18938. }
  18939. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18940. if (cmp !== 0) {
  18941. return cmp;
  18942. }
  18943. cmp = strcmp(mappingA.source, mappingB.source);
  18944. if (cmp !== 0) {
  18945. return cmp;
  18946. }
  18947. cmp = mappingA.originalLine - mappingB.originalLine;
  18948. if (cmp !== 0) {
  18949. return cmp;
  18950. }
  18951. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18952. if (cmp !== 0) {
  18953. return cmp;
  18954. }
  18955. return strcmp(mappingA.name, mappingB.name);
  18956. }
  18957. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  18958. /**
  18959. * Strip any JSON XSSI avoidance prefix from the string (as documented
  18960. * in the source maps specification), and then parse the string as
  18961. * JSON.
  18962. */
  18963. function parseSourceMapInput(str) {
  18964. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  18965. }
  18966. exports.parseSourceMapInput = parseSourceMapInput;
  18967. /**
  18968. * Compute the URL of a source given the the source root, the source's
  18969. * URL, and the source map's URL.
  18970. */
  18971. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  18972. sourceURL = sourceURL || '';
  18973. if (sourceRoot) {
  18974. // This follows what Chrome does.
  18975. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  18976. sourceRoot += '/';
  18977. }
  18978. // The spec says:
  18979. // Line 4: An optional source root, useful for relocating source
  18980. // files on a server or removing repeated values in the
  18981. // “sources” entry. This value is prepended to the individual
  18982. // entries in the “source” field.
  18983. sourceURL = sourceRoot + sourceURL;
  18984. }
  18985. // Historically, SourceMapConsumer did not take the sourceMapURL as
  18986. // a parameter. This mode is still somewhat supported, which is why
  18987. // this code block is conditional. However, it's preferable to pass
  18988. // the source map URL to SourceMapConsumer, so that this function
  18989. // can implement the source URL resolution algorithm as outlined in
  18990. // the spec. This block is basically the equivalent of:
  18991. // new URL(sourceURL, sourceMapURL).toString()
  18992. // ... except it avoids using URL, which wasn't available in the
  18993. // older releases of node still supported by this library.
  18994. //
  18995. // The spec says:
  18996. // If the sources are not absolute URLs after prepending of the
  18997. // “sourceRoot”, the sources are resolved relative to the
  18998. // SourceMap (like resolving script src in a html document).
  18999. if (sourceMapURL) {
  19000. var parsed = urlParse(sourceMapURL);
  19001. if (!parsed) {
  19002. throw new Error("sourceMapURL could not be parsed");
  19003. }
  19004. if (parsed.path) {
  19005. // Strip the last path component, but keep the "/".
  19006. var index = parsed.path.lastIndexOf('/');
  19007. if (index >= 0) {
  19008. parsed.path = parsed.path.substring(0, index + 1);
  19009. }
  19010. }
  19011. sourceURL = join(urlGenerate(parsed), sourceURL);
  19012. }
  19013. return normalize(sourceURL);
  19014. }
  19015. exports.computeSourceURL = computeSourceURL;
  19016. } (util$c));
  19017. var arraySet$1 = {};
  19018. /* -*- Mode: js; js-indent-level: 2; -*- */
  19019. /*
  19020. * Copyright 2011 Mozilla Foundation and contributors
  19021. * Licensed under the New BSD license. See LICENSE or:
  19022. * http://opensource.org/licenses/BSD-3-Clause
  19023. */
  19024. var util$b = util$c;
  19025. var has$1 = Object.prototype.hasOwnProperty;
  19026. var hasNativeMap$1 = typeof Map !== "undefined";
  19027. /**
  19028. * A data structure which is a combination of an array and a set. Adding a new
  19029. * member is O(1), testing for membership is O(1), and finding the index of an
  19030. * element is O(1). Removing elements from the set is not supported. Only
  19031. * strings are supported for membership.
  19032. */
  19033. function ArraySet$5() {
  19034. this._array = [];
  19035. this._set = hasNativeMap$1 ? new Map() : Object.create(null);
  19036. }
  19037. /**
  19038. * Static method for creating ArraySet instances from an existing array.
  19039. */
  19040. ArraySet$5.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19041. var set = new ArraySet$5();
  19042. for (var i = 0, len = aArray.length; i < len; i++) {
  19043. set.add(aArray[i], aAllowDuplicates);
  19044. }
  19045. return set;
  19046. };
  19047. /**
  19048. * Return how many unique items are in this ArraySet. If duplicates have been
  19049. * added, than those do not count towards the size.
  19050. *
  19051. * @returns Number
  19052. */
  19053. ArraySet$5.prototype.size = function ArraySet_size() {
  19054. return hasNativeMap$1 ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19055. };
  19056. /**
  19057. * Add the given string to this set.
  19058. *
  19059. * @param String aStr
  19060. */
  19061. ArraySet$5.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19062. var sStr = hasNativeMap$1 ? aStr : util$b.toSetString(aStr);
  19063. var isDuplicate = hasNativeMap$1 ? this.has(aStr) : has$1.call(this._set, sStr);
  19064. var idx = this._array.length;
  19065. if (!isDuplicate || aAllowDuplicates) {
  19066. this._array.push(aStr);
  19067. }
  19068. if (!isDuplicate) {
  19069. if (hasNativeMap$1) {
  19070. this._set.set(aStr, idx);
  19071. } else {
  19072. this._set[sStr] = idx;
  19073. }
  19074. }
  19075. };
  19076. /**
  19077. * Is the given string a member of this set?
  19078. *
  19079. * @param String aStr
  19080. */
  19081. ArraySet$5.prototype.has = function ArraySet_has(aStr) {
  19082. if (hasNativeMap$1) {
  19083. return this._set.has(aStr);
  19084. } else {
  19085. var sStr = util$b.toSetString(aStr);
  19086. return has$1.call(this._set, sStr);
  19087. }
  19088. };
  19089. /**
  19090. * What is the index of the given string in the array?
  19091. *
  19092. * @param String aStr
  19093. */
  19094. ArraySet$5.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19095. if (hasNativeMap$1) {
  19096. var idx = this._set.get(aStr);
  19097. if (idx >= 0) {
  19098. return idx;
  19099. }
  19100. } else {
  19101. var sStr = util$b.toSetString(aStr);
  19102. if (has$1.call(this._set, sStr)) {
  19103. return this._set[sStr];
  19104. }
  19105. }
  19106. throw new Error('"' + aStr + '" is not in the set.');
  19107. };
  19108. /**
  19109. * What is the element at the given index?
  19110. *
  19111. * @param Number aIdx
  19112. */
  19113. ArraySet$5.prototype.at = function ArraySet_at(aIdx) {
  19114. if (aIdx >= 0 && aIdx < this._array.length) {
  19115. return this._array[aIdx];
  19116. }
  19117. throw new Error('No element indexed by ' + aIdx);
  19118. };
  19119. /**
  19120. * Returns the array representation of this set (which has the proper indices
  19121. * indicated by indexOf). Note that this is a copy of the internal array used
  19122. * for storing the members so that no one can mess with internal state.
  19123. */
  19124. ArraySet$5.prototype.toArray = function ArraySet_toArray() {
  19125. return this._array.slice();
  19126. };
  19127. arraySet$1.ArraySet = ArraySet$5;
  19128. var mappingList$1 = {};
  19129. /* -*- Mode: js; js-indent-level: 2; -*- */
  19130. /*
  19131. * Copyright 2014 Mozilla Foundation and contributors
  19132. * Licensed under the New BSD license. See LICENSE or:
  19133. * http://opensource.org/licenses/BSD-3-Clause
  19134. */
  19135. var util$a = util$c;
  19136. /**
  19137. * Determine whether mappingB is after mappingA with respect to generated
  19138. * position.
  19139. */
  19140. function generatedPositionAfter$1(mappingA, mappingB) {
  19141. // Optimized for most common case
  19142. var lineA = mappingA.generatedLine;
  19143. var lineB = mappingB.generatedLine;
  19144. var columnA = mappingA.generatedColumn;
  19145. var columnB = mappingB.generatedColumn;
  19146. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  19147. util$a.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  19148. }
  19149. /**
  19150. * A data structure to provide a sorted view of accumulated mappings in a
  19151. * performance conscious manner. It trades a neglibable overhead in general
  19152. * case for a large speedup in case of mappings being added in order.
  19153. */
  19154. function MappingList$3() {
  19155. this._array = [];
  19156. this._sorted = true;
  19157. // Serves as infimum
  19158. this._last = {generatedLine: -1, generatedColumn: 0};
  19159. }
  19160. /**
  19161. * Iterate through internal items. This method takes the same arguments that
  19162. * `Array.prototype.forEach` takes.
  19163. *
  19164. * NOTE: The order of the mappings is NOT guaranteed.
  19165. */
  19166. MappingList$3.prototype.unsortedForEach =
  19167. function MappingList_forEach(aCallback, aThisArg) {
  19168. this._array.forEach(aCallback, aThisArg);
  19169. };
  19170. /**
  19171. * Add the given source mapping.
  19172. *
  19173. * @param Object aMapping
  19174. */
  19175. MappingList$3.prototype.add = function MappingList_add(aMapping) {
  19176. if (generatedPositionAfter$1(this._last, aMapping)) {
  19177. this._last = aMapping;
  19178. this._array.push(aMapping);
  19179. } else {
  19180. this._sorted = false;
  19181. this._array.push(aMapping);
  19182. }
  19183. };
  19184. /**
  19185. * Returns the flat, sorted array of mappings. The mappings are sorted by
  19186. * generated position.
  19187. *
  19188. * WARNING: This method returns internal data without copying, for
  19189. * performance. The return value must NOT be mutated, and should be treated as
  19190. * an immutable borrow. If you want to take ownership, you must make your own
  19191. * copy.
  19192. */
  19193. MappingList$3.prototype.toArray = function MappingList_toArray() {
  19194. if (!this._sorted) {
  19195. this._array.sort(util$a.compareByGeneratedPositionsInflated);
  19196. this._sorted = true;
  19197. }
  19198. return this._array;
  19199. };
  19200. mappingList$1.MappingList = MappingList$3;
  19201. /* -*- Mode: js; js-indent-level: 2; -*- */
  19202. /*
  19203. * Copyright 2011 Mozilla Foundation and contributors
  19204. * Licensed under the New BSD license. See LICENSE or:
  19205. * http://opensource.org/licenses/BSD-3-Clause
  19206. */
  19207. var base64VLQ$3 = base64Vlq$1;
  19208. var util$9 = util$c;
  19209. var ArraySet$4 = arraySet$1.ArraySet;
  19210. var MappingList$2 = mappingList$1.MappingList;
  19211. /**
  19212. * An instance of the SourceMapGenerator represents a source map which is
  19213. * being built incrementally. You may pass an object with the following
  19214. * properties:
  19215. *
  19216. * - file: The filename of the generated source.
  19217. * - sourceRoot: A root for all relative URLs in this source map.
  19218. */
  19219. function SourceMapGenerator$8(aArgs) {
  19220. if (!aArgs) {
  19221. aArgs = {};
  19222. }
  19223. this._file = util$9.getArg(aArgs, 'file', null);
  19224. this._sourceRoot = util$9.getArg(aArgs, 'sourceRoot', null);
  19225. this._skipValidation = util$9.getArg(aArgs, 'skipValidation', false);
  19226. this._sources = new ArraySet$4();
  19227. this._names = new ArraySet$4();
  19228. this._mappings = new MappingList$2();
  19229. this._sourcesContents = null;
  19230. }
  19231. SourceMapGenerator$8.prototype._version = 3;
  19232. /**
  19233. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  19234. *
  19235. * @param aSourceMapConsumer The SourceMap.
  19236. */
  19237. SourceMapGenerator$8.fromSourceMap =
  19238. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  19239. var sourceRoot = aSourceMapConsumer.sourceRoot;
  19240. var generator = new SourceMapGenerator$8({
  19241. file: aSourceMapConsumer.file,
  19242. sourceRoot: sourceRoot
  19243. });
  19244. aSourceMapConsumer.eachMapping(function (mapping) {
  19245. var newMapping = {
  19246. generated: {
  19247. line: mapping.generatedLine,
  19248. column: mapping.generatedColumn
  19249. }
  19250. };
  19251. if (mapping.source != null) {
  19252. newMapping.source = mapping.source;
  19253. if (sourceRoot != null) {
  19254. newMapping.source = util$9.relative(sourceRoot, newMapping.source);
  19255. }
  19256. newMapping.original = {
  19257. line: mapping.originalLine,
  19258. column: mapping.originalColumn
  19259. };
  19260. if (mapping.name != null) {
  19261. newMapping.name = mapping.name;
  19262. }
  19263. }
  19264. generator.addMapping(newMapping);
  19265. });
  19266. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19267. var sourceRelative = sourceFile;
  19268. if (sourceRoot !== null) {
  19269. sourceRelative = util$9.relative(sourceRoot, sourceFile);
  19270. }
  19271. if (!generator._sources.has(sourceRelative)) {
  19272. generator._sources.add(sourceRelative);
  19273. }
  19274. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19275. if (content != null) {
  19276. generator.setSourceContent(sourceFile, content);
  19277. }
  19278. });
  19279. return generator;
  19280. };
  19281. /**
  19282. * Add a single mapping from original source line and column to the generated
  19283. * source's line and column for this source map being created. The mapping
  19284. * object should have the following properties:
  19285. *
  19286. * - generated: An object with the generated line and column positions.
  19287. * - original: An object with the original line and column positions.
  19288. * - source: The original source file (relative to the sourceRoot).
  19289. * - name: An optional original token name for this mapping.
  19290. */
  19291. SourceMapGenerator$8.prototype.addMapping =
  19292. function SourceMapGenerator_addMapping(aArgs) {
  19293. var generated = util$9.getArg(aArgs, 'generated');
  19294. var original = util$9.getArg(aArgs, 'original', null);
  19295. var source = util$9.getArg(aArgs, 'source', null);
  19296. var name = util$9.getArg(aArgs, 'name', null);
  19297. if (!this._skipValidation) {
  19298. this._validateMapping(generated, original, source, name);
  19299. }
  19300. if (source != null) {
  19301. source = String(source);
  19302. if (!this._sources.has(source)) {
  19303. this._sources.add(source);
  19304. }
  19305. }
  19306. if (name != null) {
  19307. name = String(name);
  19308. if (!this._names.has(name)) {
  19309. this._names.add(name);
  19310. }
  19311. }
  19312. this._mappings.add({
  19313. generatedLine: generated.line,
  19314. generatedColumn: generated.column,
  19315. originalLine: original != null && original.line,
  19316. originalColumn: original != null && original.column,
  19317. source: source,
  19318. name: name
  19319. });
  19320. };
  19321. /**
  19322. * Set the source content for a source file.
  19323. */
  19324. SourceMapGenerator$8.prototype.setSourceContent =
  19325. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  19326. var source = aSourceFile;
  19327. if (this._sourceRoot != null) {
  19328. source = util$9.relative(this._sourceRoot, source);
  19329. }
  19330. if (aSourceContent != null) {
  19331. // Add the source content to the _sourcesContents map.
  19332. // Create a new _sourcesContents map if the property is null.
  19333. if (!this._sourcesContents) {
  19334. this._sourcesContents = Object.create(null);
  19335. }
  19336. this._sourcesContents[util$9.toSetString(source)] = aSourceContent;
  19337. } else if (this._sourcesContents) {
  19338. // Remove the source file from the _sourcesContents map.
  19339. // If the _sourcesContents map is empty, set the property to null.
  19340. delete this._sourcesContents[util$9.toSetString(source)];
  19341. if (Object.keys(this._sourcesContents).length === 0) {
  19342. this._sourcesContents = null;
  19343. }
  19344. }
  19345. };
  19346. /**
  19347. * Applies the mappings of a sub-source-map for a specific source file to the
  19348. * source map being generated. Each mapping to the supplied source file is
  19349. * rewritten using the supplied source map. Note: The resolution for the
  19350. * resulting mappings is the minimium of this map and the supplied map.
  19351. *
  19352. * @param aSourceMapConsumer The source map to be applied.
  19353. * @param aSourceFile Optional. The filename of the source file.
  19354. * If omitted, SourceMapConsumer's file property will be used.
  19355. * @param aSourceMapPath Optional. The dirname of the path to the source map
  19356. * to be applied. If relative, it is relative to the SourceMapConsumer.
  19357. * This parameter is needed when the two source maps aren't in the same
  19358. * directory, and the source map to be applied contains relative source
  19359. * paths. If so, those relative source paths need to be rewritten
  19360. * relative to the SourceMapGenerator.
  19361. */
  19362. SourceMapGenerator$8.prototype.applySourceMap =
  19363. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  19364. var sourceFile = aSourceFile;
  19365. // If aSourceFile is omitted, we will use the file property of the SourceMap
  19366. if (aSourceFile == null) {
  19367. if (aSourceMapConsumer.file == null) {
  19368. throw new Error(
  19369. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  19370. 'or the source map\'s "file" property. Both were omitted.'
  19371. );
  19372. }
  19373. sourceFile = aSourceMapConsumer.file;
  19374. }
  19375. var sourceRoot = this._sourceRoot;
  19376. // Make "sourceFile" relative if an absolute Url is passed.
  19377. if (sourceRoot != null) {
  19378. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19379. }
  19380. // Applying the SourceMap can add and remove items from the sources and
  19381. // the names array.
  19382. var newSources = new ArraySet$4();
  19383. var newNames = new ArraySet$4();
  19384. // Find mappings for the "sourceFile"
  19385. this._mappings.unsortedForEach(function (mapping) {
  19386. if (mapping.source === sourceFile && mapping.originalLine != null) {
  19387. // Check if it can be mapped by the source map, then update the mapping.
  19388. var original = aSourceMapConsumer.originalPositionFor({
  19389. line: mapping.originalLine,
  19390. column: mapping.originalColumn
  19391. });
  19392. if (original.source != null) {
  19393. // Copy mapping
  19394. mapping.source = original.source;
  19395. if (aSourceMapPath != null) {
  19396. mapping.source = util$9.join(aSourceMapPath, mapping.source);
  19397. }
  19398. if (sourceRoot != null) {
  19399. mapping.source = util$9.relative(sourceRoot, mapping.source);
  19400. }
  19401. mapping.originalLine = original.line;
  19402. mapping.originalColumn = original.column;
  19403. if (original.name != null) {
  19404. mapping.name = original.name;
  19405. }
  19406. }
  19407. }
  19408. var source = mapping.source;
  19409. if (source != null && !newSources.has(source)) {
  19410. newSources.add(source);
  19411. }
  19412. var name = mapping.name;
  19413. if (name != null && !newNames.has(name)) {
  19414. newNames.add(name);
  19415. }
  19416. }, this);
  19417. this._sources = newSources;
  19418. this._names = newNames;
  19419. // Copy sourcesContents of applied map.
  19420. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19421. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19422. if (content != null) {
  19423. if (aSourceMapPath != null) {
  19424. sourceFile = util$9.join(aSourceMapPath, sourceFile);
  19425. }
  19426. if (sourceRoot != null) {
  19427. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19428. }
  19429. this.setSourceContent(sourceFile, content);
  19430. }
  19431. }, this);
  19432. };
  19433. /**
  19434. * A mapping can have one of the three levels of data:
  19435. *
  19436. * 1. Just the generated position.
  19437. * 2. The Generated position, original position, and original source.
  19438. * 3. Generated and original position, original source, as well as a name
  19439. * token.
  19440. *
  19441. * To maintain consistency, we validate that any new mapping being added falls
  19442. * in to one of these categories.
  19443. */
  19444. SourceMapGenerator$8.prototype._validateMapping =
  19445. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  19446. aName) {
  19447. // When aOriginal is truthy but has empty values for .line and .column,
  19448. // it is most likely a programmer error. In this case we throw a very
  19449. // specific error message to try to guide them the right way.
  19450. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  19451. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  19452. throw new Error(
  19453. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  19454. 'the original mapping entirely and only map the generated position. If so, pass ' +
  19455. 'null for the original mapping instead of an object with empty or null values.'
  19456. );
  19457. }
  19458. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19459. && aGenerated.line > 0 && aGenerated.column >= 0
  19460. && !aOriginal && !aSource && !aName) {
  19461. // Case 1.
  19462. return;
  19463. }
  19464. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19465. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  19466. && aGenerated.line > 0 && aGenerated.column >= 0
  19467. && aOriginal.line > 0 && aOriginal.column >= 0
  19468. && aSource) {
  19469. // Cases 2 and 3.
  19470. return;
  19471. }
  19472. else {
  19473. throw new Error('Invalid mapping: ' + JSON.stringify({
  19474. generated: aGenerated,
  19475. source: aSource,
  19476. original: aOriginal,
  19477. name: aName
  19478. }));
  19479. }
  19480. };
  19481. /**
  19482. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  19483. * specified by the source map format.
  19484. */
  19485. SourceMapGenerator$8.prototype._serializeMappings =
  19486. function SourceMapGenerator_serializeMappings() {
  19487. var previousGeneratedColumn = 0;
  19488. var previousGeneratedLine = 1;
  19489. var previousOriginalColumn = 0;
  19490. var previousOriginalLine = 0;
  19491. var previousName = 0;
  19492. var previousSource = 0;
  19493. var result = '';
  19494. var next;
  19495. var mapping;
  19496. var nameIdx;
  19497. var sourceIdx;
  19498. var mappings = this._mappings.toArray();
  19499. for (var i = 0, len = mappings.length; i < len; i++) {
  19500. mapping = mappings[i];
  19501. next = '';
  19502. if (mapping.generatedLine !== previousGeneratedLine) {
  19503. previousGeneratedColumn = 0;
  19504. while (mapping.generatedLine !== previousGeneratedLine) {
  19505. next += ';';
  19506. previousGeneratedLine++;
  19507. }
  19508. }
  19509. else {
  19510. if (i > 0) {
  19511. if (!util$9.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  19512. continue;
  19513. }
  19514. next += ',';
  19515. }
  19516. }
  19517. next += base64VLQ$3.encode(mapping.generatedColumn
  19518. - previousGeneratedColumn);
  19519. previousGeneratedColumn = mapping.generatedColumn;
  19520. if (mapping.source != null) {
  19521. sourceIdx = this._sources.indexOf(mapping.source);
  19522. next += base64VLQ$3.encode(sourceIdx - previousSource);
  19523. previousSource = sourceIdx;
  19524. // lines are stored 0-based in SourceMap spec version 3
  19525. next += base64VLQ$3.encode(mapping.originalLine - 1
  19526. - previousOriginalLine);
  19527. previousOriginalLine = mapping.originalLine - 1;
  19528. next += base64VLQ$3.encode(mapping.originalColumn
  19529. - previousOriginalColumn);
  19530. previousOriginalColumn = mapping.originalColumn;
  19531. if (mapping.name != null) {
  19532. nameIdx = this._names.indexOf(mapping.name);
  19533. next += base64VLQ$3.encode(nameIdx - previousName);
  19534. previousName = nameIdx;
  19535. }
  19536. }
  19537. result += next;
  19538. }
  19539. return result;
  19540. };
  19541. SourceMapGenerator$8.prototype._generateSourcesContent =
  19542. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  19543. return aSources.map(function (source) {
  19544. if (!this._sourcesContents) {
  19545. return null;
  19546. }
  19547. if (aSourceRoot != null) {
  19548. source = util$9.relative(aSourceRoot, source);
  19549. }
  19550. var key = util$9.toSetString(source);
  19551. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  19552. ? this._sourcesContents[key]
  19553. : null;
  19554. }, this);
  19555. };
  19556. /**
  19557. * Externalize the source map.
  19558. */
  19559. SourceMapGenerator$8.prototype.toJSON =
  19560. function SourceMapGenerator_toJSON() {
  19561. var map = {
  19562. version: this._version,
  19563. sources: this._sources.toArray(),
  19564. names: this._names.toArray(),
  19565. mappings: this._serializeMappings()
  19566. };
  19567. if (this._file != null) {
  19568. map.file = this._file;
  19569. }
  19570. if (this._sourceRoot != null) {
  19571. map.sourceRoot = this._sourceRoot;
  19572. }
  19573. if (this._sourcesContents) {
  19574. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  19575. }
  19576. return map;
  19577. };
  19578. /**
  19579. * Render the source map being generated to a string.
  19580. */
  19581. SourceMapGenerator$8.prototype.toString =
  19582. function SourceMapGenerator_toString() {
  19583. return JSON.stringify(this.toJSON());
  19584. };
  19585. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator$8;
  19586. var sourceMapConsumer$1 = {};
  19587. var binarySearch$3 = {};
  19588. /* -*- Mode: js; js-indent-level: 2; -*- */
  19589. (function (exports) {
  19590. /*
  19591. * Copyright 2011 Mozilla Foundation and contributors
  19592. * Licensed under the New BSD license. See LICENSE or:
  19593. * http://opensource.org/licenses/BSD-3-Clause
  19594. */
  19595. exports.GREATEST_LOWER_BOUND = 1;
  19596. exports.LEAST_UPPER_BOUND = 2;
  19597. /**
  19598. * Recursive implementation of binary search.
  19599. *
  19600. * @param aLow Indices here and lower do not contain the needle.
  19601. * @param aHigh Indices here and higher do not contain the needle.
  19602. * @param aNeedle The element being searched for.
  19603. * @param aHaystack The non-empty array being searched.
  19604. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  19605. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19606. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19607. * closest element that is smaller than or greater than the one we are
  19608. * searching for, respectively, if the exact element cannot be found.
  19609. */
  19610. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  19611. // This function terminates when one of the following is true:
  19612. //
  19613. // 1. We find the exact element we are looking for.
  19614. //
  19615. // 2. We did not find the exact element, but we can return the index of
  19616. // the next-closest element.
  19617. //
  19618. // 3. We did not find the exact element, and there is no next-closest
  19619. // element than the one we are searching for, so we return -1.
  19620. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  19621. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  19622. if (cmp === 0) {
  19623. // Found the element we are looking for.
  19624. return mid;
  19625. }
  19626. else if (cmp > 0) {
  19627. // Our needle is greater than aHaystack[mid].
  19628. if (aHigh - mid > 1) {
  19629. // The element is in the upper half.
  19630. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  19631. }
  19632. // The exact needle element was not found in this haystack. Determine if
  19633. // we are in termination case (3) or (2) and return the appropriate thing.
  19634. if (aBias == exports.LEAST_UPPER_BOUND) {
  19635. return aHigh < aHaystack.length ? aHigh : -1;
  19636. } else {
  19637. return mid;
  19638. }
  19639. }
  19640. else {
  19641. // Our needle is less than aHaystack[mid].
  19642. if (mid - aLow > 1) {
  19643. // The element is in the lower half.
  19644. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  19645. }
  19646. // we are in termination case (3) or (2) and return the appropriate thing.
  19647. if (aBias == exports.LEAST_UPPER_BOUND) {
  19648. return mid;
  19649. } else {
  19650. return aLow < 0 ? -1 : aLow;
  19651. }
  19652. }
  19653. }
  19654. /**
  19655. * This is an implementation of binary search which will always try and return
  19656. * the index of the closest element if there is no exact hit. This is because
  19657. * mappings between original and generated line/col pairs are single points,
  19658. * and there is an implicit region between each of them, so a miss just means
  19659. * that you aren't on the very start of a region.
  19660. *
  19661. * @param aNeedle The element you are looking for.
  19662. * @param aHaystack The array that is being searched.
  19663. * @param aCompare A function which takes the needle and an element in the
  19664. * array and returns -1, 0, or 1 depending on whether the needle is less
  19665. * than, equal to, or greater than the element, respectively.
  19666. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19667. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19668. * closest element that is smaller than or greater than the one we are
  19669. * searching for, respectively, if the exact element cannot be found.
  19670. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  19671. */
  19672. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  19673. if (aHaystack.length === 0) {
  19674. return -1;
  19675. }
  19676. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  19677. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  19678. if (index < 0) {
  19679. return -1;
  19680. }
  19681. // We have found either the exact element, or the next-closest element than
  19682. // the one we are searching for. However, there may be more than one such
  19683. // element. Make sure we always return the smallest of these.
  19684. while (index - 1 >= 0) {
  19685. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  19686. break;
  19687. }
  19688. --index;
  19689. }
  19690. return index;
  19691. };
  19692. } (binarySearch$3));
  19693. var quickSort$3 = {};
  19694. /* -*- Mode: js; js-indent-level: 2; -*- */
  19695. /*
  19696. * Copyright 2011 Mozilla Foundation and contributors
  19697. * Licensed under the New BSD license. See LICENSE or:
  19698. * http://opensource.org/licenses/BSD-3-Clause
  19699. */
  19700. // It turns out that some (most?) JavaScript engines don't self-host
  19701. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  19702. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  19703. // custom comparator function, calling back and forth between the VM's C++ and
  19704. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  19705. // worse generated code for the comparator function than would be optimal. In
  19706. // fact, when sorting with a comparator, these costs outweigh the benefits of
  19707. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  19708. // a ~3500ms mean speed-up in `bench/bench.html`.
  19709. function SortTemplate(comparator) {
  19710. /**
  19711. * Swap the elements indexed by `x` and `y` in the array `ary`.
  19712. *
  19713. * @param {Array} ary
  19714. * The array.
  19715. * @param {Number} x
  19716. * The index of the first item.
  19717. * @param {Number} y
  19718. * The index of the second item.
  19719. */
  19720. function swap(ary, x, y) {
  19721. var temp = ary[x];
  19722. ary[x] = ary[y];
  19723. ary[y] = temp;
  19724. }
  19725. /**
  19726. * Returns a random integer within the range `low .. high` inclusive.
  19727. *
  19728. * @param {Number} low
  19729. * The lower bound on the range.
  19730. * @param {Number} high
  19731. * The upper bound on the range.
  19732. */
  19733. function randomIntInRange(low, high) {
  19734. return Math.round(low + (Math.random() * (high - low)));
  19735. }
  19736. /**
  19737. * The Quick Sort algorithm.
  19738. *
  19739. * @param {Array} ary
  19740. * An array to sort.
  19741. * @param {function} comparator
  19742. * Function to use to compare two items.
  19743. * @param {Number} p
  19744. * Start index of the array
  19745. * @param {Number} r
  19746. * End index of the array
  19747. */
  19748. function doQuickSort(ary, comparator, p, r) {
  19749. // If our lower bound is less than our upper bound, we (1) partition the
  19750. // array into two pieces and (2) recurse on each half. If it is not, this is
  19751. // the empty array and our base case.
  19752. if (p < r) {
  19753. // (1) Partitioning.
  19754. //
  19755. // The partitioning chooses a pivot between `p` and `r` and moves all
  19756. // elements that are less than or equal to the pivot to the before it, and
  19757. // all the elements that are greater than it after it. The effect is that
  19758. // once partition is done, the pivot is in the exact place it will be when
  19759. // the array is put in sorted order, and it will not need to be moved
  19760. // again. This runs in O(n) time.
  19761. // Always choose a random pivot so that an input array which is reverse
  19762. // sorted does not cause O(n^2) running time.
  19763. var pivotIndex = randomIntInRange(p, r);
  19764. var i = p - 1;
  19765. swap(ary, pivotIndex, r);
  19766. var pivot = ary[r];
  19767. // Immediately after `j` is incremented in this loop, the following hold
  19768. // true:
  19769. //
  19770. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  19771. //
  19772. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  19773. for (var j = p; j < r; j++) {
  19774. if (comparator(ary[j], pivot, false) <= 0) {
  19775. i += 1;
  19776. swap(ary, i, j);
  19777. }
  19778. }
  19779. swap(ary, i + 1, j);
  19780. var q = i + 1;
  19781. // (2) Recurse on each half.
  19782. doQuickSort(ary, comparator, p, q - 1);
  19783. doQuickSort(ary, comparator, q + 1, r);
  19784. }
  19785. }
  19786. return doQuickSort;
  19787. }
  19788. function cloneSort(comparator) {
  19789. let template = SortTemplate.toString();
  19790. let templateFn = new Function(`return ${template}`)();
  19791. return templateFn(comparator);
  19792. }
  19793. /**
  19794. * Sort the given array in-place with the given comparator function.
  19795. *
  19796. * @param {Array} ary
  19797. * An array to sort.
  19798. * @param {function} comparator
  19799. * Function to use to compare two items.
  19800. */
  19801. let sortCache = new WeakMap();
  19802. quickSort$3.quickSort = function (ary, comparator, start = 0) {
  19803. let doQuickSort = sortCache.get(comparator);
  19804. if (doQuickSort === void 0) {
  19805. doQuickSort = cloneSort(comparator);
  19806. sortCache.set(comparator, doQuickSort);
  19807. }
  19808. doQuickSort(ary, comparator, start, ary.length - 1);
  19809. };
  19810. /* -*- Mode: js; js-indent-level: 2; -*- */
  19811. /*
  19812. * Copyright 2011 Mozilla Foundation and contributors
  19813. * Licensed under the New BSD license. See LICENSE or:
  19814. * http://opensource.org/licenses/BSD-3-Clause
  19815. */
  19816. var util$8 = util$c;
  19817. var binarySearch$2 = binarySearch$3;
  19818. var ArraySet$3 = arraySet$1.ArraySet;
  19819. var base64VLQ$2 = base64Vlq$1;
  19820. var quickSort$2 = quickSort$3.quickSort;
  19821. function SourceMapConsumer$6(aSourceMap, aSourceMapURL) {
  19822. var sourceMap = aSourceMap;
  19823. if (typeof aSourceMap === 'string') {
  19824. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  19825. }
  19826. return sourceMap.sections != null
  19827. ? new IndexedSourceMapConsumer$1(sourceMap, aSourceMapURL)
  19828. : new BasicSourceMapConsumer$1(sourceMap, aSourceMapURL);
  19829. }
  19830. SourceMapConsumer$6.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  19831. return BasicSourceMapConsumer$1.fromSourceMap(aSourceMap, aSourceMapURL);
  19832. };
  19833. /**
  19834. * The version of the source mapping spec that we are consuming.
  19835. */
  19836. SourceMapConsumer$6.prototype._version = 3;
  19837. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  19838. // parsed mapping coordinates from the source map's "mappings" attribute. They
  19839. // are lazily instantiated, accessed via the `_generatedMappings` and
  19840. // `_originalMappings` getters respectively, and we only parse the mappings
  19841. // and create these arrays once queried for a source location. We jump through
  19842. // these hoops because there can be many thousands of mappings, and parsing
  19843. // them is expensive, so we only want to do it if we must.
  19844. //
  19845. // Each object in the arrays is of the form:
  19846. //
  19847. // {
  19848. // generatedLine: The line number in the generated code,
  19849. // generatedColumn: The column number in the generated code,
  19850. // source: The path to the original source file that generated this
  19851. // chunk of code,
  19852. // originalLine: The line number in the original source that
  19853. // corresponds to this chunk of generated code,
  19854. // originalColumn: The column number in the original source that
  19855. // corresponds to this chunk of generated code,
  19856. // name: The name of the original symbol which generated this chunk of
  19857. // code.
  19858. // }
  19859. //
  19860. // All properties except for `generatedLine` and `generatedColumn` can be
  19861. // `null`.
  19862. //
  19863. // `_generatedMappings` is ordered by the generated positions.
  19864. //
  19865. // `_originalMappings` is ordered by the original positions.
  19866. SourceMapConsumer$6.prototype.__generatedMappings = null;
  19867. Object.defineProperty(SourceMapConsumer$6.prototype, '_generatedMappings', {
  19868. configurable: true,
  19869. enumerable: true,
  19870. get: function () {
  19871. if (!this.__generatedMappings) {
  19872. this._parseMappings(this._mappings, this.sourceRoot);
  19873. }
  19874. return this.__generatedMappings;
  19875. }
  19876. });
  19877. SourceMapConsumer$6.prototype.__originalMappings = null;
  19878. Object.defineProperty(SourceMapConsumer$6.prototype, '_originalMappings', {
  19879. configurable: true,
  19880. enumerable: true,
  19881. get: function () {
  19882. if (!this.__originalMappings) {
  19883. this._parseMappings(this._mappings, this.sourceRoot);
  19884. }
  19885. return this.__originalMappings;
  19886. }
  19887. });
  19888. SourceMapConsumer$6.prototype._charIsMappingSeparator =
  19889. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  19890. var c = aStr.charAt(index);
  19891. return c === ";" || c === ",";
  19892. };
  19893. /**
  19894. * Parse the mappings in a string in to a data structure which we can easily
  19895. * query (the ordered arrays in the `this.__generatedMappings` and
  19896. * `this.__originalMappings` properties).
  19897. */
  19898. SourceMapConsumer$6.prototype._parseMappings =
  19899. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  19900. throw new Error("Subclasses must implement _parseMappings");
  19901. };
  19902. SourceMapConsumer$6.GENERATED_ORDER = 1;
  19903. SourceMapConsumer$6.ORIGINAL_ORDER = 2;
  19904. SourceMapConsumer$6.GREATEST_LOWER_BOUND = 1;
  19905. SourceMapConsumer$6.LEAST_UPPER_BOUND = 2;
  19906. /**
  19907. * Iterate over each mapping between an original source/line/column and a
  19908. * generated line/column in this source map.
  19909. *
  19910. * @param Function aCallback
  19911. * The function that is called with each mapping.
  19912. * @param Object aContext
  19913. * Optional. If specified, this object will be the value of `this` every
  19914. * time that `aCallback` is called.
  19915. * @param aOrder
  19916. * Either `SourceMapConsumer.GENERATED_ORDER` or
  19917. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  19918. * iterate over the mappings sorted by the generated file's line/column
  19919. * order or the original's source/line/column order, respectively. Defaults to
  19920. * `SourceMapConsumer.GENERATED_ORDER`.
  19921. */
  19922. SourceMapConsumer$6.prototype.eachMapping =
  19923. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  19924. var context = aContext || null;
  19925. var order = aOrder || SourceMapConsumer$6.GENERATED_ORDER;
  19926. var mappings;
  19927. switch (order) {
  19928. case SourceMapConsumer$6.GENERATED_ORDER:
  19929. mappings = this._generatedMappings;
  19930. break;
  19931. case SourceMapConsumer$6.ORIGINAL_ORDER:
  19932. mappings = this._originalMappings;
  19933. break;
  19934. default:
  19935. throw new Error("Unknown order of iteration.");
  19936. }
  19937. var sourceRoot = this.sourceRoot;
  19938. var boundCallback = aCallback.bind(context);
  19939. var names = this._names;
  19940. var sources = this._sources;
  19941. var sourceMapURL = this._sourceMapURL;
  19942. for (var i = 0, n = mappings.length; i < n; i++) {
  19943. var mapping = mappings[i];
  19944. var source = mapping.source === null ? null : sources.at(mapping.source);
  19945. source = util$8.computeSourceURL(sourceRoot, source, sourceMapURL);
  19946. boundCallback({
  19947. source: source,
  19948. generatedLine: mapping.generatedLine,
  19949. generatedColumn: mapping.generatedColumn,
  19950. originalLine: mapping.originalLine,
  19951. originalColumn: mapping.originalColumn,
  19952. name: mapping.name === null ? null : names.at(mapping.name)
  19953. });
  19954. }
  19955. };
  19956. /**
  19957. * Returns all generated line and column information for the original source,
  19958. * line, and column provided. If no column is provided, returns all mappings
  19959. * corresponding to a either the line we are searching for or the next
  19960. * closest line that has any mappings. Otherwise, returns all mappings
  19961. * corresponding to the given line and either the column we are searching for
  19962. * or the next closest column that has any offsets.
  19963. *
  19964. * The only argument is an object with the following properties:
  19965. *
  19966. * - source: The filename of the original source.
  19967. * - line: The line number in the original source. The line number is 1-based.
  19968. * - column: Optional. the column number in the original source.
  19969. * The column number is 0-based.
  19970. *
  19971. * and an array of objects is returned, each with the following properties:
  19972. *
  19973. * - line: The line number in the generated source, or null. The
  19974. * line number is 1-based.
  19975. * - column: The column number in the generated source, or null.
  19976. * The column number is 0-based.
  19977. */
  19978. SourceMapConsumer$6.prototype.allGeneratedPositionsFor =
  19979. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  19980. var line = util$8.getArg(aArgs, 'line');
  19981. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  19982. // returns the index of the closest mapping less than the needle. By
  19983. // setting needle.originalColumn to 0, we thus find the last mapping for
  19984. // the given line, provided such a mapping exists.
  19985. var needle = {
  19986. source: util$8.getArg(aArgs, 'source'),
  19987. originalLine: line,
  19988. originalColumn: util$8.getArg(aArgs, 'column', 0)
  19989. };
  19990. needle.source = this._findSourceIndex(needle.source);
  19991. if (needle.source < 0) {
  19992. return [];
  19993. }
  19994. var mappings = [];
  19995. var index = this._findMapping(needle,
  19996. this._originalMappings,
  19997. "originalLine",
  19998. "originalColumn",
  19999. util$8.compareByOriginalPositions,
  20000. binarySearch$2.LEAST_UPPER_BOUND);
  20001. if (index >= 0) {
  20002. var mapping = this._originalMappings[index];
  20003. if (aArgs.column === undefined) {
  20004. var originalLine = mapping.originalLine;
  20005. // Iterate until either we run out of mappings, or we run into
  20006. // a mapping for a different line than the one we found. Since
  20007. // mappings are sorted, this is guaranteed to find all mappings for
  20008. // the line we found.
  20009. while (mapping && mapping.originalLine === originalLine) {
  20010. mappings.push({
  20011. line: util$8.getArg(mapping, 'generatedLine', null),
  20012. column: util$8.getArg(mapping, 'generatedColumn', null),
  20013. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20014. });
  20015. mapping = this._originalMappings[++index];
  20016. }
  20017. } else {
  20018. var originalColumn = mapping.originalColumn;
  20019. // Iterate until either we run out of mappings, or we run into
  20020. // a mapping for a different line than the one we were searching for.
  20021. // Since mappings are sorted, this is guaranteed to find all mappings for
  20022. // the line we are searching for.
  20023. while (mapping &&
  20024. mapping.originalLine === line &&
  20025. mapping.originalColumn == originalColumn) {
  20026. mappings.push({
  20027. line: util$8.getArg(mapping, 'generatedLine', null),
  20028. column: util$8.getArg(mapping, 'generatedColumn', null),
  20029. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20030. });
  20031. mapping = this._originalMappings[++index];
  20032. }
  20033. }
  20034. }
  20035. return mappings;
  20036. };
  20037. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer$6;
  20038. /**
  20039. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20040. * query for information about the original file positions by giving it a file
  20041. * position in the generated source.
  20042. *
  20043. * The first parameter is the raw source map (either as a JSON string, or
  20044. * already parsed to an object). According to the spec, source maps have the
  20045. * following attributes:
  20046. *
  20047. * - version: Which version of the source map spec this map is following.
  20048. * - sources: An array of URLs to the original source files.
  20049. * - names: An array of identifiers which can be referrenced by individual mappings.
  20050. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20051. * - sourcesContent: Optional. An array of contents of the original source files.
  20052. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20053. * - file: Optional. The generated file this source map is associated with.
  20054. *
  20055. * Here is an example source map, taken from the source map spec[0]:
  20056. *
  20057. * {
  20058. * version : 3,
  20059. * file: "out.js",
  20060. * sourceRoot : "",
  20061. * sources: ["foo.js", "bar.js"],
  20062. * names: ["src", "maps", "are", "fun"],
  20063. * mappings: "AA,AB;;ABCDE;"
  20064. * }
  20065. *
  20066. * The second parameter, if given, is a string whose value is the URL
  20067. * at which the source map was found. This URL is used to compute the
  20068. * sources array.
  20069. *
  20070. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  20071. */
  20072. function BasicSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20073. var sourceMap = aSourceMap;
  20074. if (typeof aSourceMap === 'string') {
  20075. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20076. }
  20077. var version = util$8.getArg(sourceMap, 'version');
  20078. var sources = util$8.getArg(sourceMap, 'sources');
  20079. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  20080. // requires the array) to play nice here.
  20081. var names = util$8.getArg(sourceMap, 'names', []);
  20082. var sourceRoot = util$8.getArg(sourceMap, 'sourceRoot', null);
  20083. var sourcesContent = util$8.getArg(sourceMap, 'sourcesContent', null);
  20084. var mappings = util$8.getArg(sourceMap, 'mappings');
  20085. var file = util$8.getArg(sourceMap, 'file', null);
  20086. // Once again, Sass deviates from the spec and supplies the version as a
  20087. // string rather than a number, so we use loose equality checking here.
  20088. if (version != this._version) {
  20089. throw new Error('Unsupported version: ' + version);
  20090. }
  20091. if (sourceRoot) {
  20092. sourceRoot = util$8.normalize(sourceRoot);
  20093. }
  20094. sources = sources
  20095. .map(String)
  20096. // Some source maps produce relative source paths like "./foo.js" instead of
  20097. // "foo.js". Normalize these first so that future comparisons will succeed.
  20098. // See bugzil.la/1090768.
  20099. .map(util$8.normalize)
  20100. // Always ensure that absolute sources are internally stored relative to
  20101. // the source root, if the source root is absolute. Not doing this would
  20102. // be particularly problematic when the source root is a prefix of the
  20103. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  20104. .map(function (source) {
  20105. return sourceRoot && util$8.isAbsolute(sourceRoot) && util$8.isAbsolute(source)
  20106. ? util$8.relative(sourceRoot, source)
  20107. : source;
  20108. });
  20109. // Pass `true` below to allow duplicate names and sources. While source maps
  20110. // are intended to be compressed and deduplicated, the TypeScript compiler
  20111. // sometimes generates source maps with duplicates in them. See Github issue
  20112. // #72 and bugzil.la/889492.
  20113. this._names = ArraySet$3.fromArray(names.map(String), true);
  20114. this._sources = ArraySet$3.fromArray(sources, true);
  20115. this._absoluteSources = this._sources.toArray().map(function (s) {
  20116. return util$8.computeSourceURL(sourceRoot, s, aSourceMapURL);
  20117. });
  20118. this.sourceRoot = sourceRoot;
  20119. this.sourcesContent = sourcesContent;
  20120. this._mappings = mappings;
  20121. this._sourceMapURL = aSourceMapURL;
  20122. this.file = file;
  20123. }
  20124. BasicSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20125. BasicSourceMapConsumer$1.prototype.consumer = SourceMapConsumer$6;
  20126. /**
  20127. * Utility function to find the index of a source. Returns -1 if not
  20128. * found.
  20129. */
  20130. BasicSourceMapConsumer$1.prototype._findSourceIndex = function(aSource) {
  20131. var relativeSource = aSource;
  20132. if (this.sourceRoot != null) {
  20133. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20134. }
  20135. if (this._sources.has(relativeSource)) {
  20136. return this._sources.indexOf(relativeSource);
  20137. }
  20138. // Maybe aSource is an absolute URL as returned by |sources|. In
  20139. // this case we can't simply undo the transform.
  20140. var i;
  20141. for (i = 0; i < this._absoluteSources.length; ++i) {
  20142. if (this._absoluteSources[i] == aSource) {
  20143. return i;
  20144. }
  20145. }
  20146. return -1;
  20147. };
  20148. /**
  20149. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  20150. *
  20151. * @param SourceMapGenerator aSourceMap
  20152. * The source map that will be consumed.
  20153. * @param String aSourceMapURL
  20154. * The URL at which the source map can be found (optional)
  20155. * @returns BasicSourceMapConsumer
  20156. */
  20157. BasicSourceMapConsumer$1.fromSourceMap =
  20158. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  20159. var smc = Object.create(BasicSourceMapConsumer$1.prototype);
  20160. var names = smc._names = ArraySet$3.fromArray(aSourceMap._names.toArray(), true);
  20161. var sources = smc._sources = ArraySet$3.fromArray(aSourceMap._sources.toArray(), true);
  20162. smc.sourceRoot = aSourceMap._sourceRoot;
  20163. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  20164. smc.sourceRoot);
  20165. smc.file = aSourceMap._file;
  20166. smc._sourceMapURL = aSourceMapURL;
  20167. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  20168. return util$8.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  20169. });
  20170. // Because we are modifying the entries (by converting string sources and
  20171. // names to indices into the sources and names ArraySets), we have to make
  20172. // a copy of the entry or else bad things happen. Shared mutable state
  20173. // strikes again! See github issue #191.
  20174. var generatedMappings = aSourceMap._mappings.toArray().slice();
  20175. var destGeneratedMappings = smc.__generatedMappings = [];
  20176. var destOriginalMappings = smc.__originalMappings = [];
  20177. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  20178. var srcMapping = generatedMappings[i];
  20179. var destMapping = new Mapping$1;
  20180. destMapping.generatedLine = srcMapping.generatedLine;
  20181. destMapping.generatedColumn = srcMapping.generatedColumn;
  20182. if (srcMapping.source) {
  20183. destMapping.source = sources.indexOf(srcMapping.source);
  20184. destMapping.originalLine = srcMapping.originalLine;
  20185. destMapping.originalColumn = srcMapping.originalColumn;
  20186. if (srcMapping.name) {
  20187. destMapping.name = names.indexOf(srcMapping.name);
  20188. }
  20189. destOriginalMappings.push(destMapping);
  20190. }
  20191. destGeneratedMappings.push(destMapping);
  20192. }
  20193. quickSort$2(smc.__originalMappings, util$8.compareByOriginalPositions);
  20194. return smc;
  20195. };
  20196. /**
  20197. * The version of the source mapping spec that we are consuming.
  20198. */
  20199. BasicSourceMapConsumer$1.prototype._version = 3;
  20200. /**
  20201. * The list of original sources.
  20202. */
  20203. Object.defineProperty(BasicSourceMapConsumer$1.prototype, 'sources', {
  20204. get: function () {
  20205. return this._absoluteSources.slice();
  20206. }
  20207. });
  20208. /**
  20209. * Provide the JIT with a nice shape / hidden class.
  20210. */
  20211. function Mapping$1() {
  20212. this.generatedLine = 0;
  20213. this.generatedColumn = 0;
  20214. this.source = null;
  20215. this.originalLine = null;
  20216. this.originalColumn = null;
  20217. this.name = null;
  20218. }
  20219. /**
  20220. * Parse the mappings in a string in to a data structure which we can easily
  20221. * query (the ordered arrays in the `this.__generatedMappings` and
  20222. * `this.__originalMappings` properties).
  20223. */
  20224. const compareGenerated = util$8.compareByGeneratedPositionsDeflatedNoLine;
  20225. function sortGenerated(array, start) {
  20226. let l = array.length;
  20227. let n = array.length - start;
  20228. if (n <= 1) {
  20229. return;
  20230. } else if (n == 2) {
  20231. let a = array[start];
  20232. let b = array[start + 1];
  20233. if (compareGenerated(a, b) > 0) {
  20234. array[start] = b;
  20235. array[start + 1] = a;
  20236. }
  20237. } else if (n < 20) {
  20238. for (let i = start; i < l; i++) {
  20239. for (let j = i; j > start; j--) {
  20240. let a = array[j - 1];
  20241. let b = array[j];
  20242. if (compareGenerated(a, b) <= 0) {
  20243. break;
  20244. }
  20245. array[j - 1] = b;
  20246. array[j] = a;
  20247. }
  20248. }
  20249. } else {
  20250. quickSort$2(array, compareGenerated, start);
  20251. }
  20252. }
  20253. BasicSourceMapConsumer$1.prototype._parseMappings =
  20254. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20255. var generatedLine = 1;
  20256. var previousGeneratedColumn = 0;
  20257. var previousOriginalLine = 0;
  20258. var previousOriginalColumn = 0;
  20259. var previousSource = 0;
  20260. var previousName = 0;
  20261. var length = aStr.length;
  20262. var index = 0;
  20263. var temp = {};
  20264. var originalMappings = [];
  20265. var generatedMappings = [];
  20266. var mapping, segment, end, value;
  20267. let subarrayStart = 0;
  20268. while (index < length) {
  20269. if (aStr.charAt(index) === ';') {
  20270. generatedLine++;
  20271. index++;
  20272. previousGeneratedColumn = 0;
  20273. sortGenerated(generatedMappings, subarrayStart);
  20274. subarrayStart = generatedMappings.length;
  20275. }
  20276. else if (aStr.charAt(index) === ',') {
  20277. index++;
  20278. }
  20279. else {
  20280. mapping = new Mapping$1();
  20281. mapping.generatedLine = generatedLine;
  20282. for (end = index; end < length; end++) {
  20283. if (this._charIsMappingSeparator(aStr, end)) {
  20284. break;
  20285. }
  20286. }
  20287. aStr.slice(index, end);
  20288. segment = [];
  20289. while (index < end) {
  20290. base64VLQ$2.decode(aStr, index, temp);
  20291. value = temp.value;
  20292. index = temp.rest;
  20293. segment.push(value);
  20294. }
  20295. if (segment.length === 2) {
  20296. throw new Error('Found a source, but no line and column');
  20297. }
  20298. if (segment.length === 3) {
  20299. throw new Error('Found a source and line, but no column');
  20300. }
  20301. // Generated column.
  20302. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  20303. previousGeneratedColumn = mapping.generatedColumn;
  20304. if (segment.length > 1) {
  20305. // Original source.
  20306. mapping.source = previousSource + segment[1];
  20307. previousSource += segment[1];
  20308. // Original line.
  20309. mapping.originalLine = previousOriginalLine + segment[2];
  20310. previousOriginalLine = mapping.originalLine;
  20311. // Lines are stored 0-based
  20312. mapping.originalLine += 1;
  20313. // Original column.
  20314. mapping.originalColumn = previousOriginalColumn + segment[3];
  20315. previousOriginalColumn = mapping.originalColumn;
  20316. if (segment.length > 4) {
  20317. // Original name.
  20318. mapping.name = previousName + segment[4];
  20319. previousName += segment[4];
  20320. }
  20321. }
  20322. generatedMappings.push(mapping);
  20323. if (typeof mapping.originalLine === 'number') {
  20324. let currentSource = mapping.source;
  20325. while (originalMappings.length <= currentSource) {
  20326. originalMappings.push(null);
  20327. }
  20328. if (originalMappings[currentSource] === null) {
  20329. originalMappings[currentSource] = [];
  20330. }
  20331. originalMappings[currentSource].push(mapping);
  20332. }
  20333. }
  20334. }
  20335. sortGenerated(generatedMappings, subarrayStart);
  20336. this.__generatedMappings = generatedMappings;
  20337. for (var i = 0; i < originalMappings.length; i++) {
  20338. if (originalMappings[i] != null) {
  20339. quickSort$2(originalMappings[i], util$8.compareByOriginalPositionsNoSource);
  20340. }
  20341. }
  20342. this.__originalMappings = [].concat(...originalMappings);
  20343. };
  20344. /**
  20345. * Find the mapping that best matches the hypothetical "needle" mapping that
  20346. * we are searching for in the given "haystack" of mappings.
  20347. */
  20348. BasicSourceMapConsumer$1.prototype._findMapping =
  20349. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  20350. aColumnName, aComparator, aBias) {
  20351. // To return the position we are searching for, we must first find the
  20352. // mapping for the given position and then return the opposite position it
  20353. // points to. Because the mappings are sorted, we can use binary search to
  20354. // find the best mapping.
  20355. if (aNeedle[aLineName] <= 0) {
  20356. throw new TypeError('Line must be greater than or equal to 1, got '
  20357. + aNeedle[aLineName]);
  20358. }
  20359. if (aNeedle[aColumnName] < 0) {
  20360. throw new TypeError('Column must be greater than or equal to 0, got '
  20361. + aNeedle[aColumnName]);
  20362. }
  20363. return binarySearch$2.search(aNeedle, aMappings, aComparator, aBias);
  20364. };
  20365. /**
  20366. * Compute the last column for each generated mapping. The last column is
  20367. * inclusive.
  20368. */
  20369. BasicSourceMapConsumer$1.prototype.computeColumnSpans =
  20370. function SourceMapConsumer_computeColumnSpans() {
  20371. for (var index = 0; index < this._generatedMappings.length; ++index) {
  20372. var mapping = this._generatedMappings[index];
  20373. // Mappings do not contain a field for the last generated columnt. We
  20374. // can come up with an optimistic estimate, however, by assuming that
  20375. // mappings are contiguous (i.e. given two consecutive mappings, the
  20376. // first mapping ends where the second one starts).
  20377. if (index + 1 < this._generatedMappings.length) {
  20378. var nextMapping = this._generatedMappings[index + 1];
  20379. if (mapping.generatedLine === nextMapping.generatedLine) {
  20380. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  20381. continue;
  20382. }
  20383. }
  20384. // The last mapping for each line spans the entire line.
  20385. mapping.lastGeneratedColumn = Infinity;
  20386. }
  20387. };
  20388. /**
  20389. * Returns the original source, line, and column information for the generated
  20390. * source's line and column positions provided. The only argument is an object
  20391. * with the following properties:
  20392. *
  20393. * - line: The line number in the generated source. The line number
  20394. * is 1-based.
  20395. * - column: The column number in the generated source. The column
  20396. * number is 0-based.
  20397. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20398. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20399. * closest element that is smaller than or greater than the one we are
  20400. * searching for, respectively, if the exact element cannot be found.
  20401. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20402. *
  20403. * and an object is returned with the following properties:
  20404. *
  20405. * - source: The original source file, or null.
  20406. * - line: The line number in the original source, or null. The
  20407. * line number is 1-based.
  20408. * - column: The column number in the original source, or null. The
  20409. * column number is 0-based.
  20410. * - name: The original identifier, or null.
  20411. */
  20412. BasicSourceMapConsumer$1.prototype.originalPositionFor =
  20413. function SourceMapConsumer_originalPositionFor(aArgs) {
  20414. var needle = {
  20415. generatedLine: util$8.getArg(aArgs, 'line'),
  20416. generatedColumn: util$8.getArg(aArgs, 'column')
  20417. };
  20418. var index = this._findMapping(
  20419. needle,
  20420. this._generatedMappings,
  20421. "generatedLine",
  20422. "generatedColumn",
  20423. util$8.compareByGeneratedPositionsDeflated,
  20424. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20425. );
  20426. if (index >= 0) {
  20427. var mapping = this._generatedMappings[index];
  20428. if (mapping.generatedLine === needle.generatedLine) {
  20429. var source = util$8.getArg(mapping, 'source', null);
  20430. if (source !== null) {
  20431. source = this._sources.at(source);
  20432. source = util$8.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  20433. }
  20434. var name = util$8.getArg(mapping, 'name', null);
  20435. if (name !== null) {
  20436. name = this._names.at(name);
  20437. }
  20438. return {
  20439. source: source,
  20440. line: util$8.getArg(mapping, 'originalLine', null),
  20441. column: util$8.getArg(mapping, 'originalColumn', null),
  20442. name: name
  20443. };
  20444. }
  20445. }
  20446. return {
  20447. source: null,
  20448. line: null,
  20449. column: null,
  20450. name: null
  20451. };
  20452. };
  20453. /**
  20454. * Return true if we have the source content for every source in the source
  20455. * map, false otherwise.
  20456. */
  20457. BasicSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20458. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  20459. if (!this.sourcesContent) {
  20460. return false;
  20461. }
  20462. return this.sourcesContent.length >= this._sources.size() &&
  20463. !this.sourcesContent.some(function (sc) { return sc == null; });
  20464. };
  20465. /**
  20466. * Returns the original source content. The only argument is the url of the
  20467. * original source file. Returns null if no original source content is
  20468. * available.
  20469. */
  20470. BasicSourceMapConsumer$1.prototype.sourceContentFor =
  20471. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20472. if (!this.sourcesContent) {
  20473. return null;
  20474. }
  20475. var index = this._findSourceIndex(aSource);
  20476. if (index >= 0) {
  20477. return this.sourcesContent[index];
  20478. }
  20479. var relativeSource = aSource;
  20480. if (this.sourceRoot != null) {
  20481. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20482. }
  20483. var url;
  20484. if (this.sourceRoot != null
  20485. && (url = util$8.urlParse(this.sourceRoot))) {
  20486. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  20487. // many users. We can help them out when they expect file:// URIs to
  20488. // behave like it would if they were running a local HTTP server. See
  20489. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  20490. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  20491. if (url.scheme == "file"
  20492. && this._sources.has(fileUriAbsPath)) {
  20493. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  20494. }
  20495. if ((!url.path || url.path == "/")
  20496. && this._sources.has("/" + relativeSource)) {
  20497. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  20498. }
  20499. }
  20500. // This function is used recursively from
  20501. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  20502. // don't want to throw if we can't find the source - we just want to
  20503. // return null, so we provide a flag to exit gracefully.
  20504. if (nullOnMissing) {
  20505. return null;
  20506. }
  20507. else {
  20508. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  20509. }
  20510. };
  20511. /**
  20512. * Returns the generated line and column information for the original source,
  20513. * line, and column positions provided. The only argument is an object with
  20514. * the following properties:
  20515. *
  20516. * - source: The filename of the original source.
  20517. * - line: The line number in the original source. The line number
  20518. * is 1-based.
  20519. * - column: The column number in the original source. The column
  20520. * number is 0-based.
  20521. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20522. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20523. * closest element that is smaller than or greater than the one we are
  20524. * searching for, respectively, if the exact element cannot be found.
  20525. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20526. *
  20527. * and an object is returned with the following properties:
  20528. *
  20529. * - line: The line number in the generated source, or null. The
  20530. * line number is 1-based.
  20531. * - column: The column number in the generated source, or null.
  20532. * The column number is 0-based.
  20533. */
  20534. BasicSourceMapConsumer$1.prototype.generatedPositionFor =
  20535. function SourceMapConsumer_generatedPositionFor(aArgs) {
  20536. var source = util$8.getArg(aArgs, 'source');
  20537. source = this._findSourceIndex(source);
  20538. if (source < 0) {
  20539. return {
  20540. line: null,
  20541. column: null,
  20542. lastColumn: null
  20543. };
  20544. }
  20545. var needle = {
  20546. source: source,
  20547. originalLine: util$8.getArg(aArgs, 'line'),
  20548. originalColumn: util$8.getArg(aArgs, 'column')
  20549. };
  20550. var index = this._findMapping(
  20551. needle,
  20552. this._originalMappings,
  20553. "originalLine",
  20554. "originalColumn",
  20555. util$8.compareByOriginalPositions,
  20556. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20557. );
  20558. if (index >= 0) {
  20559. var mapping = this._originalMappings[index];
  20560. if (mapping.source === needle.source) {
  20561. return {
  20562. line: util$8.getArg(mapping, 'generatedLine', null),
  20563. column: util$8.getArg(mapping, 'generatedColumn', null),
  20564. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20565. };
  20566. }
  20567. }
  20568. return {
  20569. line: null,
  20570. column: null,
  20571. lastColumn: null
  20572. };
  20573. };
  20574. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer$1;
  20575. /**
  20576. * An IndexedSourceMapConsumer instance represents a parsed source map which
  20577. * we can query for information. It differs from BasicSourceMapConsumer in
  20578. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  20579. * input.
  20580. *
  20581. * The first parameter is a raw source map (either as a JSON string, or already
  20582. * parsed to an object). According to the spec for indexed source maps, they
  20583. * have the following attributes:
  20584. *
  20585. * - version: Which version of the source map spec this map is following.
  20586. * - file: Optional. The generated file this source map is associated with.
  20587. * - sections: A list of section definitions.
  20588. *
  20589. * Each value under the "sections" field has two fields:
  20590. * - offset: The offset into the original specified at which this section
  20591. * begins to apply, defined as an object with a "line" and "column"
  20592. * field.
  20593. * - map: A source map definition. This source map could also be indexed,
  20594. * but doesn't have to be.
  20595. *
  20596. * Instead of the "map" field, it's also possible to have a "url" field
  20597. * specifying a URL to retrieve a source map from, but that's currently
  20598. * unsupported.
  20599. *
  20600. * Here's an example source map, taken from the source map spec[0], but
  20601. * modified to omit a section which uses the "url" field.
  20602. *
  20603. * {
  20604. * version : 3,
  20605. * file: "app.js",
  20606. * sections: [{
  20607. * offset: {line:100, column:10},
  20608. * map: {
  20609. * version : 3,
  20610. * file: "section.js",
  20611. * sources: ["foo.js", "bar.js"],
  20612. * names: ["src", "maps", "are", "fun"],
  20613. * mappings: "AAAA,E;;ABCDE;"
  20614. * }
  20615. * }],
  20616. * }
  20617. *
  20618. * The second parameter, if given, is a string whose value is the URL
  20619. * at which the source map was found. This URL is used to compute the
  20620. * sources array.
  20621. *
  20622. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  20623. */
  20624. function IndexedSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20625. var sourceMap = aSourceMap;
  20626. if (typeof aSourceMap === 'string') {
  20627. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20628. }
  20629. var version = util$8.getArg(sourceMap, 'version');
  20630. var sections = util$8.getArg(sourceMap, 'sections');
  20631. if (version != this._version) {
  20632. throw new Error('Unsupported version: ' + version);
  20633. }
  20634. this._sources = new ArraySet$3();
  20635. this._names = new ArraySet$3();
  20636. var lastOffset = {
  20637. line: -1,
  20638. column: 0
  20639. };
  20640. this._sections = sections.map(function (s) {
  20641. if (s.url) {
  20642. // The url field will require support for asynchronicity.
  20643. // See https://github.com/mozilla/source-map/issues/16
  20644. throw new Error('Support for url field in sections not implemented.');
  20645. }
  20646. var offset = util$8.getArg(s, 'offset');
  20647. var offsetLine = util$8.getArg(offset, 'line');
  20648. var offsetColumn = util$8.getArg(offset, 'column');
  20649. if (offsetLine < lastOffset.line ||
  20650. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  20651. throw new Error('Section offsets must be ordered and non-overlapping.');
  20652. }
  20653. lastOffset = offset;
  20654. return {
  20655. generatedOffset: {
  20656. // The offset fields are 0-based, but we use 1-based indices when
  20657. // encoding/decoding from VLQ.
  20658. generatedLine: offsetLine + 1,
  20659. generatedColumn: offsetColumn + 1
  20660. },
  20661. consumer: new SourceMapConsumer$6(util$8.getArg(s, 'map'), aSourceMapURL)
  20662. }
  20663. });
  20664. }
  20665. IndexedSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20666. IndexedSourceMapConsumer$1.prototype.constructor = SourceMapConsumer$6;
  20667. /**
  20668. * The version of the source mapping spec that we are consuming.
  20669. */
  20670. IndexedSourceMapConsumer$1.prototype._version = 3;
  20671. /**
  20672. * The list of original sources.
  20673. */
  20674. Object.defineProperty(IndexedSourceMapConsumer$1.prototype, 'sources', {
  20675. get: function () {
  20676. var sources = [];
  20677. for (var i = 0; i < this._sections.length; i++) {
  20678. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  20679. sources.push(this._sections[i].consumer.sources[j]);
  20680. }
  20681. }
  20682. return sources;
  20683. }
  20684. });
  20685. /**
  20686. * Returns the original source, line, and column information for the generated
  20687. * source's line and column positions provided. The only argument is an object
  20688. * with the following properties:
  20689. *
  20690. * - line: The line number in the generated source. The line number
  20691. * is 1-based.
  20692. * - column: The column number in the generated source. The column
  20693. * number is 0-based.
  20694. *
  20695. * and an object is returned with the following properties:
  20696. *
  20697. * - source: The original source file, or null.
  20698. * - line: The line number in the original source, or null. The
  20699. * line number is 1-based.
  20700. * - column: The column number in the original source, or null. The
  20701. * column number is 0-based.
  20702. * - name: The original identifier, or null.
  20703. */
  20704. IndexedSourceMapConsumer$1.prototype.originalPositionFor =
  20705. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  20706. var needle = {
  20707. generatedLine: util$8.getArg(aArgs, 'line'),
  20708. generatedColumn: util$8.getArg(aArgs, 'column')
  20709. };
  20710. // Find the section containing the generated position we're trying to map
  20711. // to an original position.
  20712. var sectionIndex = binarySearch$2.search(needle, this._sections,
  20713. function(needle, section) {
  20714. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  20715. if (cmp) {
  20716. return cmp;
  20717. }
  20718. return (needle.generatedColumn -
  20719. section.generatedOffset.generatedColumn);
  20720. });
  20721. var section = this._sections[sectionIndex];
  20722. if (!section) {
  20723. return {
  20724. source: null,
  20725. line: null,
  20726. column: null,
  20727. name: null
  20728. };
  20729. }
  20730. return section.consumer.originalPositionFor({
  20731. line: needle.generatedLine -
  20732. (section.generatedOffset.generatedLine - 1),
  20733. column: needle.generatedColumn -
  20734. (section.generatedOffset.generatedLine === needle.generatedLine
  20735. ? section.generatedOffset.generatedColumn - 1
  20736. : 0),
  20737. bias: aArgs.bias
  20738. });
  20739. };
  20740. /**
  20741. * Return true if we have the source content for every source in the source
  20742. * map, false otherwise.
  20743. */
  20744. IndexedSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20745. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  20746. return this._sections.every(function (s) {
  20747. return s.consumer.hasContentsOfAllSources();
  20748. });
  20749. };
  20750. /**
  20751. * Returns the original source content. The only argument is the url of the
  20752. * original source file. Returns null if no original source content is
  20753. * available.
  20754. */
  20755. IndexedSourceMapConsumer$1.prototype.sourceContentFor =
  20756. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20757. for (var i = 0; i < this._sections.length; i++) {
  20758. var section = this._sections[i];
  20759. var content = section.consumer.sourceContentFor(aSource, true);
  20760. if (content) {
  20761. return content;
  20762. }
  20763. }
  20764. if (nullOnMissing) {
  20765. return null;
  20766. }
  20767. else {
  20768. throw new Error('"' + aSource + '" is not in the SourceMap.');
  20769. }
  20770. };
  20771. /**
  20772. * Returns the generated line and column information for the original source,
  20773. * line, and column positions provided. The only argument is an object with
  20774. * the following properties:
  20775. *
  20776. * - source: The filename of the original source.
  20777. * - line: The line number in the original source. The line number
  20778. * is 1-based.
  20779. * - column: The column number in the original source. The column
  20780. * number is 0-based.
  20781. *
  20782. * and an object is returned with the following properties:
  20783. *
  20784. * - line: The line number in the generated source, or null. The
  20785. * line number is 1-based.
  20786. * - column: The column number in the generated source, or null.
  20787. * The column number is 0-based.
  20788. */
  20789. IndexedSourceMapConsumer$1.prototype.generatedPositionFor =
  20790. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  20791. for (var i = 0; i < this._sections.length; i++) {
  20792. var section = this._sections[i];
  20793. // Only consider this section if the requested source is in the list of
  20794. // sources of the consumer.
  20795. if (section.consumer._findSourceIndex(util$8.getArg(aArgs, 'source')) === -1) {
  20796. continue;
  20797. }
  20798. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  20799. if (generatedPosition) {
  20800. var ret = {
  20801. line: generatedPosition.line +
  20802. (section.generatedOffset.generatedLine - 1),
  20803. column: generatedPosition.column +
  20804. (section.generatedOffset.generatedLine === generatedPosition.line
  20805. ? section.generatedOffset.generatedColumn - 1
  20806. : 0)
  20807. };
  20808. return ret;
  20809. }
  20810. }
  20811. return {
  20812. line: null,
  20813. column: null
  20814. };
  20815. };
  20816. /**
  20817. * Parse the mappings in a string in to a data structure which we can easily
  20818. * query (the ordered arrays in the `this.__generatedMappings` and
  20819. * `this.__originalMappings` properties).
  20820. */
  20821. IndexedSourceMapConsumer$1.prototype._parseMappings =
  20822. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20823. this.__generatedMappings = [];
  20824. this.__originalMappings = [];
  20825. for (var i = 0; i < this._sections.length; i++) {
  20826. var section = this._sections[i];
  20827. var sectionMappings = section.consumer._generatedMappings;
  20828. for (var j = 0; j < sectionMappings.length; j++) {
  20829. var mapping = sectionMappings[j];
  20830. var source = section.consumer._sources.at(mapping.source);
  20831. source = util$8.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  20832. this._sources.add(source);
  20833. source = this._sources.indexOf(source);
  20834. var name = null;
  20835. if (mapping.name) {
  20836. name = section.consumer._names.at(mapping.name);
  20837. this._names.add(name);
  20838. name = this._names.indexOf(name);
  20839. }
  20840. // The mappings coming from the consumer for the section have
  20841. // generated positions relative to the start of the section, so we
  20842. // need to offset them to be relative to the start of the concatenated
  20843. // generated file.
  20844. var adjustedMapping = {
  20845. source: source,
  20846. generatedLine: mapping.generatedLine +
  20847. (section.generatedOffset.generatedLine - 1),
  20848. generatedColumn: mapping.generatedColumn +
  20849. (section.generatedOffset.generatedLine === mapping.generatedLine
  20850. ? section.generatedOffset.generatedColumn - 1
  20851. : 0),
  20852. originalLine: mapping.originalLine,
  20853. originalColumn: mapping.originalColumn,
  20854. name: name
  20855. };
  20856. this.__generatedMappings.push(adjustedMapping);
  20857. if (typeof adjustedMapping.originalLine === 'number') {
  20858. this.__originalMappings.push(adjustedMapping);
  20859. }
  20860. }
  20861. }
  20862. quickSort$2(this.__generatedMappings, util$8.compareByGeneratedPositionsDeflated);
  20863. quickSort$2(this.__originalMappings, util$8.compareByOriginalPositions);
  20864. };
  20865. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer$1;
  20866. var sourceNode$1 = {};
  20867. /* -*- Mode: js; js-indent-level: 2; -*- */
  20868. /*
  20869. * Copyright 2011 Mozilla Foundation and contributors
  20870. * Licensed under the New BSD license. See LICENSE or:
  20871. * http://opensource.org/licenses/BSD-3-Clause
  20872. */
  20873. var SourceMapGenerator$7 = sourceMapGenerator$1.SourceMapGenerator;
  20874. var util$7 = util$c;
  20875. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  20876. // operating systems these days (capturing the result).
  20877. var REGEX_NEWLINE$1 = /(\r?\n)/;
  20878. // Newline character code for charCodeAt() comparisons
  20879. var NEWLINE_CODE$1 = 10;
  20880. // Private symbol for identifying `SourceNode`s when multiple versions of
  20881. // the source-map library are loaded. This MUST NOT CHANGE across
  20882. // versions!
  20883. var isSourceNode$1 = "$$$isSourceNode$$$";
  20884. /**
  20885. * SourceNodes provide a way to abstract over interpolating/concatenating
  20886. * snippets of generated JavaScript source code while maintaining the line and
  20887. * column information associated with the original source code.
  20888. *
  20889. * @param aLine The original line number.
  20890. * @param aColumn The original column number.
  20891. * @param aSource The original source's filename.
  20892. * @param aChunks Optional. An array of strings which are snippets of
  20893. * generated JS, or other SourceNodes.
  20894. * @param aName The original identifier.
  20895. */
  20896. function SourceNode$1(aLine, aColumn, aSource, aChunks, aName) {
  20897. this.children = [];
  20898. this.sourceContents = {};
  20899. this.line = aLine == null ? null : aLine;
  20900. this.column = aColumn == null ? null : aColumn;
  20901. this.source = aSource == null ? null : aSource;
  20902. this.name = aName == null ? null : aName;
  20903. this[isSourceNode$1] = true;
  20904. if (aChunks != null) this.add(aChunks);
  20905. }
  20906. /**
  20907. * Creates a SourceNode from generated code and a SourceMapConsumer.
  20908. *
  20909. * @param aGeneratedCode The generated code
  20910. * @param aSourceMapConsumer The SourceMap for the generated code
  20911. * @param aRelativePath Optional. The path that relative sources in the
  20912. * SourceMapConsumer should be relative to.
  20913. */
  20914. SourceNode$1.fromStringWithSourceMap =
  20915. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  20916. // The SourceNode we want to fill with the generated code
  20917. // and the SourceMap
  20918. var node = new SourceNode$1();
  20919. // All even indices of this array are one line of the generated code,
  20920. // while all odd indices are the newlines between two adjacent lines
  20921. // (since `REGEX_NEWLINE` captures its match).
  20922. // Processed fragments are accessed by calling `shiftNextLine`.
  20923. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE$1);
  20924. var remainingLinesIndex = 0;
  20925. var shiftNextLine = function() {
  20926. var lineContents = getNextLine();
  20927. // The last line of a file might not have a newline.
  20928. var newLine = getNextLine() || "";
  20929. return lineContents + newLine;
  20930. function getNextLine() {
  20931. return remainingLinesIndex < remainingLines.length ?
  20932. remainingLines[remainingLinesIndex++] : undefined;
  20933. }
  20934. };
  20935. // We need to remember the position of "remainingLines"
  20936. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  20937. // The generate SourceNodes we need a code range.
  20938. // To extract it current and last mapping is used.
  20939. // Here we store the last mapping.
  20940. var lastMapping = null;
  20941. aSourceMapConsumer.eachMapping(function (mapping) {
  20942. if (lastMapping !== null) {
  20943. // We add the code from "lastMapping" to "mapping":
  20944. // First check if there is a new line in between.
  20945. if (lastGeneratedLine < mapping.generatedLine) {
  20946. // Associate first line with "lastMapping"
  20947. addMappingWithCode(lastMapping, shiftNextLine());
  20948. lastGeneratedLine++;
  20949. lastGeneratedColumn = 0;
  20950. // The remaining code is added without mapping
  20951. } else {
  20952. // There is no new line in between.
  20953. // Associate the code between "lastGeneratedColumn" and
  20954. // "mapping.generatedColumn" with "lastMapping"
  20955. var nextLine = remainingLines[remainingLinesIndex] || '';
  20956. var code = nextLine.substr(0, mapping.generatedColumn -
  20957. lastGeneratedColumn);
  20958. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  20959. lastGeneratedColumn);
  20960. lastGeneratedColumn = mapping.generatedColumn;
  20961. addMappingWithCode(lastMapping, code);
  20962. // No more remaining code, continue
  20963. lastMapping = mapping;
  20964. return;
  20965. }
  20966. }
  20967. // We add the generated code until the first mapping
  20968. // to the SourceNode without any mapping.
  20969. // Each line is added as separate string.
  20970. while (lastGeneratedLine < mapping.generatedLine) {
  20971. node.add(shiftNextLine());
  20972. lastGeneratedLine++;
  20973. }
  20974. if (lastGeneratedColumn < mapping.generatedColumn) {
  20975. var nextLine = remainingLines[remainingLinesIndex] || '';
  20976. node.add(nextLine.substr(0, mapping.generatedColumn));
  20977. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  20978. lastGeneratedColumn = mapping.generatedColumn;
  20979. }
  20980. lastMapping = mapping;
  20981. }, this);
  20982. // We have processed all mappings.
  20983. if (remainingLinesIndex < remainingLines.length) {
  20984. if (lastMapping) {
  20985. // Associate the remaining code in the current line with "lastMapping"
  20986. addMappingWithCode(lastMapping, shiftNextLine());
  20987. }
  20988. // and add the remaining lines without any mapping
  20989. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  20990. }
  20991. // Copy sourcesContent into SourceNode
  20992. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  20993. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  20994. if (content != null) {
  20995. if (aRelativePath != null) {
  20996. sourceFile = util$7.join(aRelativePath, sourceFile);
  20997. }
  20998. node.setSourceContent(sourceFile, content);
  20999. }
  21000. });
  21001. return node;
  21002. function addMappingWithCode(mapping, code) {
  21003. if (mapping === null || mapping.source === undefined) {
  21004. node.add(code);
  21005. } else {
  21006. var source = aRelativePath
  21007. ? util$7.join(aRelativePath, mapping.source)
  21008. : mapping.source;
  21009. node.add(new SourceNode$1(mapping.originalLine,
  21010. mapping.originalColumn,
  21011. source,
  21012. code,
  21013. mapping.name));
  21014. }
  21015. }
  21016. };
  21017. /**
  21018. * Add a chunk of generated JS to this source node.
  21019. *
  21020. * @param aChunk A string snippet of generated JS code, another instance of
  21021. * SourceNode, or an array where each member is one of those things.
  21022. */
  21023. SourceNode$1.prototype.add = function SourceNode_add(aChunk) {
  21024. if (Array.isArray(aChunk)) {
  21025. aChunk.forEach(function (chunk) {
  21026. this.add(chunk);
  21027. }, this);
  21028. }
  21029. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21030. if (aChunk) {
  21031. this.children.push(aChunk);
  21032. }
  21033. }
  21034. else {
  21035. throw new TypeError(
  21036. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21037. );
  21038. }
  21039. return this;
  21040. };
  21041. /**
  21042. * Add a chunk of generated JS to the beginning of this source node.
  21043. *
  21044. * @param aChunk A string snippet of generated JS code, another instance of
  21045. * SourceNode, or an array where each member is one of those things.
  21046. */
  21047. SourceNode$1.prototype.prepend = function SourceNode_prepend(aChunk) {
  21048. if (Array.isArray(aChunk)) {
  21049. for (var i = aChunk.length-1; i >= 0; i--) {
  21050. this.prepend(aChunk[i]);
  21051. }
  21052. }
  21053. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21054. this.children.unshift(aChunk);
  21055. }
  21056. else {
  21057. throw new TypeError(
  21058. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21059. );
  21060. }
  21061. return this;
  21062. };
  21063. /**
  21064. * Walk over the tree of JS snippets in this node and its children. The
  21065. * walking function is called once for each snippet of JS and is passed that
  21066. * snippet and the its original associated source's line/column location.
  21067. *
  21068. * @param aFn The traversal function.
  21069. */
  21070. SourceNode$1.prototype.walk = function SourceNode_walk(aFn) {
  21071. var chunk;
  21072. for (var i = 0, len = this.children.length; i < len; i++) {
  21073. chunk = this.children[i];
  21074. if (chunk[isSourceNode$1]) {
  21075. chunk.walk(aFn);
  21076. }
  21077. else {
  21078. if (chunk !== '') {
  21079. aFn(chunk, { source: this.source,
  21080. line: this.line,
  21081. column: this.column,
  21082. name: this.name });
  21083. }
  21084. }
  21085. }
  21086. };
  21087. /**
  21088. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  21089. * each of `this.children`.
  21090. *
  21091. * @param aSep The separator.
  21092. */
  21093. SourceNode$1.prototype.join = function SourceNode_join(aSep) {
  21094. var newChildren;
  21095. var i;
  21096. var len = this.children.length;
  21097. if (len > 0) {
  21098. newChildren = [];
  21099. for (i = 0; i < len-1; i++) {
  21100. newChildren.push(this.children[i]);
  21101. newChildren.push(aSep);
  21102. }
  21103. newChildren.push(this.children[i]);
  21104. this.children = newChildren;
  21105. }
  21106. return this;
  21107. };
  21108. /**
  21109. * Call String.prototype.replace on the very right-most source snippet. Useful
  21110. * for trimming whitespace from the end of a source node, etc.
  21111. *
  21112. * @param aPattern The pattern to replace.
  21113. * @param aReplacement The thing to replace the pattern with.
  21114. */
  21115. SourceNode$1.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  21116. var lastChild = this.children[this.children.length - 1];
  21117. if (lastChild[isSourceNode$1]) {
  21118. lastChild.replaceRight(aPattern, aReplacement);
  21119. }
  21120. else if (typeof lastChild === 'string') {
  21121. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  21122. }
  21123. else {
  21124. this.children.push(''.replace(aPattern, aReplacement));
  21125. }
  21126. return this;
  21127. };
  21128. /**
  21129. * Set the source content for a source file. This will be added to the SourceMapGenerator
  21130. * in the sourcesContent field.
  21131. *
  21132. * @param aSourceFile The filename of the source file
  21133. * @param aSourceContent The content of the source file
  21134. */
  21135. SourceNode$1.prototype.setSourceContent =
  21136. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  21137. this.sourceContents[util$7.toSetString(aSourceFile)] = aSourceContent;
  21138. };
  21139. /**
  21140. * Walk over the tree of SourceNodes. The walking function is called for each
  21141. * source file content and is passed the filename and source content.
  21142. *
  21143. * @param aFn The traversal function.
  21144. */
  21145. SourceNode$1.prototype.walkSourceContents =
  21146. function SourceNode_walkSourceContents(aFn) {
  21147. for (var i = 0, len = this.children.length; i < len; i++) {
  21148. if (this.children[i][isSourceNode$1]) {
  21149. this.children[i].walkSourceContents(aFn);
  21150. }
  21151. }
  21152. var sources = Object.keys(this.sourceContents);
  21153. for (var i = 0, len = sources.length; i < len; i++) {
  21154. aFn(util$7.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  21155. }
  21156. };
  21157. /**
  21158. * Return the string representation of this source node. Walks over the tree
  21159. * and concatenates all the various snippets together to one string.
  21160. */
  21161. SourceNode$1.prototype.toString = function SourceNode_toString() {
  21162. var str = "";
  21163. this.walk(function (chunk) {
  21164. str += chunk;
  21165. });
  21166. return str;
  21167. };
  21168. /**
  21169. * Returns the string representation of this source node along with a source
  21170. * map.
  21171. */
  21172. SourceNode$1.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  21173. var generated = {
  21174. code: "",
  21175. line: 1,
  21176. column: 0
  21177. };
  21178. var map = new SourceMapGenerator$7(aArgs);
  21179. var sourceMappingActive = false;
  21180. var lastOriginalSource = null;
  21181. var lastOriginalLine = null;
  21182. var lastOriginalColumn = null;
  21183. var lastOriginalName = null;
  21184. this.walk(function (chunk, original) {
  21185. generated.code += chunk;
  21186. if (original.source !== null
  21187. && original.line !== null
  21188. && original.column !== null) {
  21189. if(lastOriginalSource !== original.source
  21190. || lastOriginalLine !== original.line
  21191. || lastOriginalColumn !== original.column
  21192. || lastOriginalName !== original.name) {
  21193. map.addMapping({
  21194. source: original.source,
  21195. original: {
  21196. line: original.line,
  21197. column: original.column
  21198. },
  21199. generated: {
  21200. line: generated.line,
  21201. column: generated.column
  21202. },
  21203. name: original.name
  21204. });
  21205. }
  21206. lastOriginalSource = original.source;
  21207. lastOriginalLine = original.line;
  21208. lastOriginalColumn = original.column;
  21209. lastOriginalName = original.name;
  21210. sourceMappingActive = true;
  21211. } else if (sourceMappingActive) {
  21212. map.addMapping({
  21213. generated: {
  21214. line: generated.line,
  21215. column: generated.column
  21216. }
  21217. });
  21218. lastOriginalSource = null;
  21219. sourceMappingActive = false;
  21220. }
  21221. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  21222. if (chunk.charCodeAt(idx) === NEWLINE_CODE$1) {
  21223. generated.line++;
  21224. generated.column = 0;
  21225. // Mappings end at eol
  21226. if (idx + 1 === length) {
  21227. lastOriginalSource = null;
  21228. sourceMappingActive = false;
  21229. } else if (sourceMappingActive) {
  21230. map.addMapping({
  21231. source: original.source,
  21232. original: {
  21233. line: original.line,
  21234. column: original.column
  21235. },
  21236. generated: {
  21237. line: generated.line,
  21238. column: generated.column
  21239. },
  21240. name: original.name
  21241. });
  21242. }
  21243. } else {
  21244. generated.column++;
  21245. }
  21246. }
  21247. });
  21248. this.walkSourceContents(function (sourceFile, sourceContent) {
  21249. map.setSourceContent(sourceFile, sourceContent);
  21250. });
  21251. return { code: generated.code, map: map };
  21252. };
  21253. sourceNode$1.SourceNode = SourceNode$1;
  21254. /*
  21255. * Copyright 2009-2011 Mozilla Foundation and contributors
  21256. * Licensed under the New BSD license. See LICENSE.txt or:
  21257. * http://opensource.org/licenses/BSD-3-Clause
  21258. */
  21259. var SourceMapGenerator$6 = sourceMap$2.SourceMapGenerator = sourceMapGenerator$1.SourceMapGenerator;
  21260. var SourceMapConsumer$5 = sourceMap$2.SourceMapConsumer = sourceMapConsumer$1.SourceMapConsumer;
  21261. sourceMap$2.SourceNode = sourceNode$1.SourceNode;
  21262. const PURE_ANNOTATION = `/*#__PURE__*/`;
  21263. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  21264. function createCodegenContext(ast, {
  21265. mode = "function",
  21266. prefixIdentifiers = mode === "module",
  21267. sourceMap = false,
  21268. filename = `template.vue.html`,
  21269. scopeId = null,
  21270. optimizeImports = false,
  21271. runtimeGlobalName = `Vue`,
  21272. runtimeModuleName = `vue`,
  21273. ssrRuntimeModuleName = "vue/server-renderer",
  21274. ssr = false,
  21275. isTS = false,
  21276. inSSR = false
  21277. }) {
  21278. const context = {
  21279. mode,
  21280. prefixIdentifiers,
  21281. sourceMap,
  21282. filename,
  21283. scopeId,
  21284. optimizeImports,
  21285. runtimeGlobalName,
  21286. runtimeModuleName,
  21287. ssrRuntimeModuleName,
  21288. ssr,
  21289. isTS,
  21290. inSSR,
  21291. source: ast.source,
  21292. code: ``,
  21293. column: 1,
  21294. line: 1,
  21295. offset: 0,
  21296. indentLevel: 0,
  21297. pure: false,
  21298. map: void 0,
  21299. helper(key) {
  21300. return `_${helperNameMap[key]}`;
  21301. },
  21302. push(code, newlineIndex = -2 /* None */, node) {
  21303. context.code += code;
  21304. if (context.map) {
  21305. if (node) {
  21306. let name;
  21307. if (node.type === 4 && !node.isStatic) {
  21308. const content = node.content.replace(/^_ctx\./, "");
  21309. if (content !== node.content && isSimpleIdentifier(content)) {
  21310. name = content;
  21311. }
  21312. }
  21313. addMapping(node.loc.start, name);
  21314. }
  21315. if (newlineIndex === -3 /* Unknown */) {
  21316. advancePositionWithMutation(context, code);
  21317. } else {
  21318. context.offset += code.length;
  21319. if (newlineIndex === -2 /* None */) {
  21320. context.column += code.length;
  21321. } else {
  21322. if (newlineIndex === -1 /* End */) {
  21323. newlineIndex = code.length - 1;
  21324. }
  21325. context.line++;
  21326. context.column = code.length - newlineIndex;
  21327. }
  21328. }
  21329. if (node && node.loc !== locStub) {
  21330. addMapping(node.loc.end);
  21331. }
  21332. }
  21333. },
  21334. indent() {
  21335. newline(++context.indentLevel);
  21336. },
  21337. deindent(withoutNewLine = false) {
  21338. if (withoutNewLine) {
  21339. --context.indentLevel;
  21340. } else {
  21341. newline(--context.indentLevel);
  21342. }
  21343. },
  21344. newline() {
  21345. newline(context.indentLevel);
  21346. }
  21347. };
  21348. function newline(n) {
  21349. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  21350. }
  21351. function addMapping(loc, name = null) {
  21352. const { _names, _mappings } = context.map;
  21353. if (name !== null && !_names.has(name))
  21354. _names.add(name);
  21355. _mappings.add({
  21356. originalLine: loc.line,
  21357. originalColumn: loc.column - 1,
  21358. // source-map column is 0 based
  21359. generatedLine: context.line,
  21360. generatedColumn: context.column - 1,
  21361. source: filename,
  21362. // @ts-expect-error it is possible to be null
  21363. name
  21364. });
  21365. }
  21366. if (sourceMap) {
  21367. context.map = new SourceMapGenerator$6();
  21368. context.map.setSourceContent(filename, context.source);
  21369. context.map._sources.add(filename);
  21370. }
  21371. return context;
  21372. }
  21373. function generate(ast, options = {}) {
  21374. const context = createCodegenContext(ast, options);
  21375. if (options.onContextCreated)
  21376. options.onContextCreated(context);
  21377. const {
  21378. mode,
  21379. push,
  21380. prefixIdentifiers,
  21381. indent,
  21382. deindent,
  21383. newline,
  21384. scopeId,
  21385. ssr
  21386. } = context;
  21387. const helpers = Array.from(ast.helpers);
  21388. const hasHelpers = helpers.length > 0;
  21389. const useWithBlock = !prefixIdentifiers && mode !== "module";
  21390. const genScopeId = scopeId != null && mode === "module";
  21391. const isSetupInlined = !!options.inline;
  21392. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  21393. if (mode === "module") {
  21394. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  21395. } else {
  21396. genFunctionPreamble(ast, preambleContext);
  21397. }
  21398. const functionName = ssr ? `ssrRender` : `render`;
  21399. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  21400. if (options.bindingMetadata && !options.inline) {
  21401. args.push("$props", "$setup", "$data", "$options");
  21402. }
  21403. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  21404. if (isSetupInlined) {
  21405. push(`(${signature}) => {`);
  21406. } else {
  21407. push(`function ${functionName}(${signature}) {`);
  21408. }
  21409. indent();
  21410. if (useWithBlock) {
  21411. push(`with (_ctx) {`);
  21412. indent();
  21413. if (hasHelpers) {
  21414. push(
  21415. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  21416. `,
  21417. -1 /* End */
  21418. );
  21419. newline();
  21420. }
  21421. }
  21422. if (ast.components.length) {
  21423. genAssets(ast.components, "component", context);
  21424. if (ast.directives.length || ast.temps > 0) {
  21425. newline();
  21426. }
  21427. }
  21428. if (ast.directives.length) {
  21429. genAssets(ast.directives, "directive", context);
  21430. if (ast.temps > 0) {
  21431. newline();
  21432. }
  21433. }
  21434. if (ast.temps > 0) {
  21435. push(`let `);
  21436. for (let i = 0; i < ast.temps; i++) {
  21437. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  21438. }
  21439. }
  21440. if (ast.components.length || ast.directives.length || ast.temps) {
  21441. push(`
  21442. `, 0 /* Start */);
  21443. newline();
  21444. }
  21445. if (!ssr) {
  21446. push(`return `);
  21447. }
  21448. if (ast.codegenNode) {
  21449. genNode(ast.codegenNode, context);
  21450. } else {
  21451. push(`null`);
  21452. }
  21453. if (useWithBlock) {
  21454. deindent();
  21455. push(`}`);
  21456. }
  21457. deindent();
  21458. push(`}`);
  21459. return {
  21460. ast,
  21461. code: context.code,
  21462. preamble: isSetupInlined ? preambleContext.code : ``,
  21463. map: context.map ? context.map.toJSON() : void 0
  21464. };
  21465. }
  21466. function genFunctionPreamble(ast, context) {
  21467. const {
  21468. ssr,
  21469. prefixIdentifiers,
  21470. push,
  21471. newline,
  21472. runtimeModuleName,
  21473. runtimeGlobalName,
  21474. ssrRuntimeModuleName
  21475. } = context;
  21476. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  21477. const helpers = Array.from(ast.helpers);
  21478. if (helpers.length > 0) {
  21479. if (prefixIdentifiers) {
  21480. push(
  21481. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  21482. `,
  21483. -1 /* End */
  21484. );
  21485. } else {
  21486. push(`const _Vue = ${VueBinding}
  21487. `, -1 /* End */);
  21488. if (ast.hoists.length) {
  21489. const staticHelpers = [
  21490. CREATE_VNODE,
  21491. CREATE_ELEMENT_VNODE,
  21492. CREATE_COMMENT,
  21493. CREATE_TEXT,
  21494. CREATE_STATIC
  21495. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  21496. push(`const { ${staticHelpers} } = _Vue
  21497. `, -1 /* End */);
  21498. }
  21499. }
  21500. }
  21501. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21502. push(
  21503. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  21504. `,
  21505. -1 /* End */
  21506. );
  21507. }
  21508. genHoists(ast.hoists, context);
  21509. newline();
  21510. push(`return `);
  21511. }
  21512. function genModulePreamble(ast, context, genScopeId, inline) {
  21513. const {
  21514. push,
  21515. newline,
  21516. optimizeImports,
  21517. runtimeModuleName,
  21518. ssrRuntimeModuleName
  21519. } = context;
  21520. if (genScopeId && ast.hoists.length) {
  21521. ast.helpers.add(PUSH_SCOPE_ID);
  21522. ast.helpers.add(POP_SCOPE_ID);
  21523. }
  21524. if (ast.helpers.size) {
  21525. const helpers = Array.from(ast.helpers);
  21526. if (optimizeImports) {
  21527. push(
  21528. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21529. `,
  21530. -1 /* End */
  21531. );
  21532. push(
  21533. `
  21534. // Binding optimization for webpack code-split
  21535. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  21536. `,
  21537. -1 /* End */
  21538. );
  21539. } else {
  21540. push(
  21541. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21542. `,
  21543. -1 /* End */
  21544. );
  21545. }
  21546. }
  21547. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21548. push(
  21549. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  21550. `,
  21551. -1 /* End */
  21552. );
  21553. }
  21554. if (ast.imports.length) {
  21555. genImports(ast.imports, context);
  21556. newline();
  21557. }
  21558. genHoists(ast.hoists, context);
  21559. newline();
  21560. if (!inline) {
  21561. push(`export `);
  21562. }
  21563. }
  21564. function genAssets(assets, type, { helper, push, newline, isTS }) {
  21565. const resolver = helper(
  21566. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  21567. );
  21568. for (let i = 0; i < assets.length; i++) {
  21569. let id = assets[i];
  21570. const maybeSelfReference = id.endsWith("__self");
  21571. if (maybeSelfReference) {
  21572. id = id.slice(0, -6);
  21573. }
  21574. push(
  21575. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  21576. );
  21577. if (i < assets.length - 1) {
  21578. newline();
  21579. }
  21580. }
  21581. }
  21582. function genHoists(hoists, context) {
  21583. if (!hoists.length) {
  21584. return;
  21585. }
  21586. context.pure = true;
  21587. const { push, newline, helper, scopeId, mode } = context;
  21588. const genScopeId = scopeId != null && mode !== "function";
  21589. newline();
  21590. if (genScopeId) {
  21591. push(
  21592. `const _withScopeId = n => (${helper(
  21593. PUSH_SCOPE_ID
  21594. )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
  21595. );
  21596. newline();
  21597. }
  21598. for (let i = 0; i < hoists.length; i++) {
  21599. const exp = hoists[i];
  21600. if (exp) {
  21601. const needScopeIdWrapper = genScopeId && exp.type === 13;
  21602. push(
  21603. `const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
  21604. );
  21605. genNode(exp, context);
  21606. if (needScopeIdWrapper) {
  21607. push(`)`);
  21608. }
  21609. newline();
  21610. }
  21611. }
  21612. context.pure = false;
  21613. }
  21614. function genImports(importsOptions, context) {
  21615. if (!importsOptions.length) {
  21616. return;
  21617. }
  21618. importsOptions.forEach((imports) => {
  21619. context.push(`import `);
  21620. genNode(imports.exp, context);
  21621. context.push(` from '${imports.path}'`);
  21622. context.newline();
  21623. });
  21624. }
  21625. function isText(n) {
  21626. return isString$2(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  21627. }
  21628. function genNodeListAsArray(nodes, context) {
  21629. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  21630. context.push(`[`);
  21631. multilines && context.indent();
  21632. genNodeList(nodes, context, multilines);
  21633. multilines && context.deindent();
  21634. context.push(`]`);
  21635. }
  21636. function genNodeList(nodes, context, multilines = false, comma = true) {
  21637. const { push, newline } = context;
  21638. for (let i = 0; i < nodes.length; i++) {
  21639. const node = nodes[i];
  21640. if (isString$2(node)) {
  21641. push(node, -3 /* Unknown */);
  21642. } else if (isArray$3(node)) {
  21643. genNodeListAsArray(node, context);
  21644. } else {
  21645. genNode(node, context);
  21646. }
  21647. if (i < nodes.length - 1) {
  21648. if (multilines) {
  21649. comma && push(",");
  21650. newline();
  21651. } else {
  21652. comma && push(", ");
  21653. }
  21654. }
  21655. }
  21656. }
  21657. function genNode(node, context) {
  21658. if (isString$2(node)) {
  21659. context.push(node, -3 /* Unknown */);
  21660. return;
  21661. }
  21662. if (isSymbol$1(node)) {
  21663. context.push(context.helper(node));
  21664. return;
  21665. }
  21666. switch (node.type) {
  21667. case 1:
  21668. case 9:
  21669. case 11:
  21670. assert(
  21671. node.codegenNode != null,
  21672. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  21673. );
  21674. genNode(node.codegenNode, context);
  21675. break;
  21676. case 2:
  21677. genText(node, context);
  21678. break;
  21679. case 4:
  21680. genExpression(node, context);
  21681. break;
  21682. case 5:
  21683. genInterpolation(node, context);
  21684. break;
  21685. case 12:
  21686. genNode(node.codegenNode, context);
  21687. break;
  21688. case 8:
  21689. genCompoundExpression(node, context);
  21690. break;
  21691. case 3:
  21692. genComment(node, context);
  21693. break;
  21694. case 13:
  21695. genVNodeCall(node, context);
  21696. break;
  21697. case 14:
  21698. genCallExpression(node, context);
  21699. break;
  21700. case 15:
  21701. genObjectExpression(node, context);
  21702. break;
  21703. case 17:
  21704. genArrayExpression(node, context);
  21705. break;
  21706. case 18:
  21707. genFunctionExpression(node, context);
  21708. break;
  21709. case 19:
  21710. genConditionalExpression(node, context);
  21711. break;
  21712. case 20:
  21713. genCacheExpression(node, context);
  21714. break;
  21715. case 21:
  21716. genNodeList(node.body, context, true, false);
  21717. break;
  21718. case 22:
  21719. genTemplateLiteral(node, context);
  21720. break;
  21721. case 23:
  21722. genIfStatement(node, context);
  21723. break;
  21724. case 24:
  21725. genAssignmentExpression(node, context);
  21726. break;
  21727. case 25:
  21728. genSequenceExpression(node, context);
  21729. break;
  21730. case 26:
  21731. genReturnStatement(node, context);
  21732. break;
  21733. case 10:
  21734. break;
  21735. default:
  21736. {
  21737. assert(false, `unhandled codegen node type: ${node.type}`);
  21738. const exhaustiveCheck = node;
  21739. return exhaustiveCheck;
  21740. }
  21741. }
  21742. }
  21743. function genText(node, context) {
  21744. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  21745. }
  21746. function genExpression(node, context) {
  21747. const { content, isStatic } = node;
  21748. context.push(
  21749. isStatic ? JSON.stringify(content) : content,
  21750. -3 /* Unknown */,
  21751. node
  21752. );
  21753. }
  21754. function genInterpolation(node, context) {
  21755. const { push, helper, pure } = context;
  21756. if (pure)
  21757. push(PURE_ANNOTATION);
  21758. push(`${helper(TO_DISPLAY_STRING)}(`);
  21759. genNode(node.content, context);
  21760. push(`)`);
  21761. }
  21762. function genCompoundExpression(node, context) {
  21763. for (let i = 0; i < node.children.length; i++) {
  21764. const child = node.children[i];
  21765. if (isString$2(child)) {
  21766. context.push(child, -3 /* Unknown */);
  21767. } else {
  21768. genNode(child, context);
  21769. }
  21770. }
  21771. }
  21772. function genExpressionAsPropertyKey(node, context) {
  21773. const { push } = context;
  21774. if (node.type === 8) {
  21775. push(`[`);
  21776. genCompoundExpression(node, context);
  21777. push(`]`);
  21778. } else if (node.isStatic) {
  21779. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  21780. push(text, -2 /* None */, node);
  21781. } else {
  21782. push(`[${node.content}]`, -3 /* Unknown */, node);
  21783. }
  21784. }
  21785. function genComment(node, context) {
  21786. const { push, helper, pure } = context;
  21787. if (pure) {
  21788. push(PURE_ANNOTATION);
  21789. }
  21790. push(
  21791. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  21792. -3 /* Unknown */,
  21793. node
  21794. );
  21795. }
  21796. function genVNodeCall(node, context) {
  21797. const { push, helper, pure } = context;
  21798. const {
  21799. tag,
  21800. props,
  21801. children,
  21802. patchFlag,
  21803. dynamicProps,
  21804. directives,
  21805. isBlock,
  21806. disableTracking,
  21807. isComponent
  21808. } = node;
  21809. if (directives) {
  21810. push(helper(WITH_DIRECTIVES) + `(`);
  21811. }
  21812. if (isBlock) {
  21813. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  21814. }
  21815. if (pure) {
  21816. push(PURE_ANNOTATION);
  21817. }
  21818. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  21819. push(helper(callHelper) + `(`, -2 /* None */, node);
  21820. genNodeList(
  21821. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  21822. context
  21823. );
  21824. push(`)`);
  21825. if (isBlock) {
  21826. push(`)`);
  21827. }
  21828. if (directives) {
  21829. push(`, `);
  21830. genNode(directives, context);
  21831. push(`)`);
  21832. }
  21833. }
  21834. function genNullableArgs(args) {
  21835. let i = args.length;
  21836. while (i--) {
  21837. if (args[i] != null)
  21838. break;
  21839. }
  21840. return args.slice(0, i + 1).map((arg) => arg || `null`);
  21841. }
  21842. function genCallExpression(node, context) {
  21843. const { push, helper, pure } = context;
  21844. const callee = isString$2(node.callee) ? node.callee : helper(node.callee);
  21845. if (pure) {
  21846. push(PURE_ANNOTATION);
  21847. }
  21848. push(callee + `(`, -2 /* None */, node);
  21849. genNodeList(node.arguments, context);
  21850. push(`)`);
  21851. }
  21852. function genObjectExpression(node, context) {
  21853. const { push, indent, deindent, newline } = context;
  21854. const { properties } = node;
  21855. if (!properties.length) {
  21856. push(`{}`, -2 /* None */, node);
  21857. return;
  21858. }
  21859. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  21860. push(multilines ? `{` : `{ `);
  21861. multilines && indent();
  21862. for (let i = 0; i < properties.length; i++) {
  21863. const { key, value } = properties[i];
  21864. genExpressionAsPropertyKey(key, context);
  21865. push(`: `);
  21866. genNode(value, context);
  21867. if (i < properties.length - 1) {
  21868. push(`,`);
  21869. newline();
  21870. }
  21871. }
  21872. multilines && deindent();
  21873. push(multilines ? `}` : ` }`);
  21874. }
  21875. function genArrayExpression(node, context) {
  21876. genNodeListAsArray(node.elements, context);
  21877. }
  21878. function genFunctionExpression(node, context) {
  21879. const { push, indent, deindent } = context;
  21880. const { params, returns, body, newline, isSlot } = node;
  21881. if (isSlot) {
  21882. push(`_${helperNameMap[WITH_CTX]}(`);
  21883. }
  21884. push(`(`, -2 /* None */, node);
  21885. if (isArray$3(params)) {
  21886. genNodeList(params, context);
  21887. } else if (params) {
  21888. genNode(params, context);
  21889. }
  21890. push(`) => `);
  21891. if (newline || body) {
  21892. push(`{`);
  21893. indent();
  21894. }
  21895. if (returns) {
  21896. if (newline) {
  21897. push(`return `);
  21898. }
  21899. if (isArray$3(returns)) {
  21900. genNodeListAsArray(returns, context);
  21901. } else {
  21902. genNode(returns, context);
  21903. }
  21904. } else if (body) {
  21905. genNode(body, context);
  21906. }
  21907. if (newline || body) {
  21908. deindent();
  21909. push(`}`);
  21910. }
  21911. if (isSlot) {
  21912. push(`)`);
  21913. }
  21914. }
  21915. function genConditionalExpression(node, context) {
  21916. const { test, consequent, alternate, newline: needNewline } = node;
  21917. const { push, indent, deindent, newline } = context;
  21918. if (test.type === 4) {
  21919. const needsParens = !isSimpleIdentifier(test.content);
  21920. needsParens && push(`(`);
  21921. genExpression(test, context);
  21922. needsParens && push(`)`);
  21923. } else {
  21924. push(`(`);
  21925. genNode(test, context);
  21926. push(`)`);
  21927. }
  21928. needNewline && indent();
  21929. context.indentLevel++;
  21930. needNewline || push(` `);
  21931. push(`? `);
  21932. genNode(consequent, context);
  21933. context.indentLevel--;
  21934. needNewline && newline();
  21935. needNewline || push(` `);
  21936. push(`: `);
  21937. const isNested = alternate.type === 19;
  21938. if (!isNested) {
  21939. context.indentLevel++;
  21940. }
  21941. genNode(alternate, context);
  21942. if (!isNested) {
  21943. context.indentLevel--;
  21944. }
  21945. needNewline && deindent(
  21946. true
  21947. /* without newline */
  21948. );
  21949. }
  21950. function genCacheExpression(node, context) {
  21951. const { push, helper, indent, deindent, newline } = context;
  21952. push(`_cache[${node.index}] || (`);
  21953. if (node.isVNode) {
  21954. indent();
  21955. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  21956. newline();
  21957. }
  21958. push(`_cache[${node.index}] = `);
  21959. genNode(node.value, context);
  21960. if (node.isVNode) {
  21961. push(`,`);
  21962. newline();
  21963. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  21964. newline();
  21965. push(`_cache[${node.index}]`);
  21966. deindent();
  21967. }
  21968. push(`)`);
  21969. }
  21970. function genTemplateLiteral(node, context) {
  21971. const { push, indent, deindent } = context;
  21972. push("`");
  21973. const l = node.elements.length;
  21974. const multilines = l > 3;
  21975. for (let i = 0; i < l; i++) {
  21976. const e = node.elements[i];
  21977. if (isString$2(e)) {
  21978. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  21979. } else {
  21980. push("${");
  21981. if (multilines)
  21982. indent();
  21983. genNode(e, context);
  21984. if (multilines)
  21985. deindent();
  21986. push("}");
  21987. }
  21988. }
  21989. push("`");
  21990. }
  21991. function genIfStatement(node, context) {
  21992. const { push, indent, deindent } = context;
  21993. const { test, consequent, alternate } = node;
  21994. push(`if (`);
  21995. genNode(test, context);
  21996. push(`) {`);
  21997. indent();
  21998. genNode(consequent, context);
  21999. deindent();
  22000. push(`}`);
  22001. if (alternate) {
  22002. push(` else `);
  22003. if (alternate.type === 23) {
  22004. genIfStatement(alternate, context);
  22005. } else {
  22006. push(`{`);
  22007. indent();
  22008. genNode(alternate, context);
  22009. deindent();
  22010. push(`}`);
  22011. }
  22012. }
  22013. }
  22014. function genAssignmentExpression(node, context) {
  22015. genNode(node.left, context);
  22016. context.push(` = `);
  22017. genNode(node.right, context);
  22018. }
  22019. function genSequenceExpression(node, context) {
  22020. context.push(`(`);
  22021. genNodeList(node.expressions, context);
  22022. context.push(`)`);
  22023. }
  22024. function genReturnStatement({ returns }, context) {
  22025. context.push(`return `);
  22026. if (isArray$3(returns)) {
  22027. genNodeListAsArray(returns, context);
  22028. } else {
  22029. genNode(returns, context);
  22030. }
  22031. }
  22032. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22033. const constantBailRE = /\w\s*\(|\.[^\d]/;
  22034. const transformExpression = (node, context) => {
  22035. if (node.type === 5) {
  22036. node.content = processExpression(
  22037. node.content,
  22038. context
  22039. );
  22040. } else if (node.type === 1) {
  22041. for (let i = 0; i < node.props.length; i++) {
  22042. const dir = node.props[i];
  22043. if (dir.type === 7 && dir.name !== "for") {
  22044. const exp = dir.exp;
  22045. const arg = dir.arg;
  22046. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  22047. dir.exp = processExpression(
  22048. exp,
  22049. context,
  22050. // slot args must be processed as function params
  22051. dir.name === "slot"
  22052. );
  22053. }
  22054. if (arg && arg.type === 4 && !arg.isStatic) {
  22055. dir.arg = processExpression(arg, context);
  22056. }
  22057. }
  22058. }
  22059. }
  22060. };
  22061. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  22062. if (!context.prefixIdentifiers || !node.content.trim()) {
  22063. return node;
  22064. }
  22065. const { inline, bindingMetadata } = context;
  22066. const rewriteIdentifier = (raw, parent, id) => {
  22067. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  22068. if (inline) {
  22069. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  22070. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  22071. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  22072. const isNewExpression = parent && isInNewExpression(parentStack);
  22073. const wrapWithUnref = (raw2) => {
  22074. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  22075. return isNewExpression ? `(${wrapped})` : wrapped;
  22076. };
  22077. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  22078. return raw;
  22079. } else if (type === "setup-ref") {
  22080. return `${raw}.value`;
  22081. } else if (type === "setup-maybe-ref") {
  22082. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  22083. } else if (type === "setup-let") {
  22084. if (isAssignmentLVal) {
  22085. const { right: rVal, operator } = parent;
  22086. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  22087. const rExpString = stringifyExpression(
  22088. processExpression(
  22089. createSimpleExpression(rExp, false),
  22090. context,
  22091. false,
  22092. false,
  22093. knownIds
  22094. )
  22095. );
  22096. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22097. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  22098. } else if (isUpdateArg) {
  22099. id.start = parent.start;
  22100. id.end = parent.end;
  22101. const { prefix: isPrefix, operator } = parent;
  22102. const prefix = isPrefix ? operator : ``;
  22103. const postfix = isPrefix ? `` : operator;
  22104. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22105. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  22106. } else if (isDestructureAssignment) {
  22107. return raw;
  22108. } else {
  22109. return wrapWithUnref(raw);
  22110. }
  22111. } else if (type === "props") {
  22112. return genPropsAccessExp(raw);
  22113. } else if (type === "props-aliased") {
  22114. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  22115. }
  22116. } else {
  22117. if (type && type.startsWith("setup") || type === "literal-const") {
  22118. return `$setup.${raw}`;
  22119. } else if (type === "props-aliased") {
  22120. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  22121. } else if (type) {
  22122. return `$${type}.${raw}`;
  22123. }
  22124. }
  22125. return `_ctx.${raw}`;
  22126. };
  22127. const rawExp = node.content;
  22128. const bailConstant = constantBailRE.test(rawExp);
  22129. let ast = node.ast;
  22130. if (ast === false) {
  22131. return node;
  22132. }
  22133. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  22134. const isScopeVarReference = context.identifiers[rawExp];
  22135. const isAllowedGlobal = isGloballyAllowed(rawExp);
  22136. const isLiteral = isLiteralWhitelisted(rawExp);
  22137. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  22138. if (isConst(bindingMetadata[rawExp])) {
  22139. node.constType = 1;
  22140. }
  22141. node.content = rewriteIdentifier(rawExp);
  22142. } else if (!isScopeVarReference) {
  22143. if (isLiteral) {
  22144. node.constType = 3;
  22145. } else {
  22146. node.constType = 2;
  22147. }
  22148. }
  22149. return node;
  22150. }
  22151. if (!ast) {
  22152. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  22153. try {
  22154. ast = parse_1$1(source, {
  22155. plugins: context.expressionPlugins
  22156. }).program;
  22157. } catch (e) {
  22158. context.onError(
  22159. createCompilerError(
  22160. 45,
  22161. node.loc,
  22162. void 0,
  22163. e.message
  22164. )
  22165. );
  22166. return node;
  22167. }
  22168. }
  22169. const ids = [];
  22170. const parentStack = [];
  22171. const knownIds = Object.create(context.identifiers);
  22172. walkIdentifiers(
  22173. ast,
  22174. (node2, parent, _, isReferenced, isLocal) => {
  22175. if (isStaticPropertyKey(node2, parent)) {
  22176. return;
  22177. }
  22178. const needPrefix = isReferenced && canPrefix(node2);
  22179. if (needPrefix && !isLocal) {
  22180. if (isStaticProperty(parent) && parent.shorthand) {
  22181. node2.prefix = `${node2.name}: `;
  22182. }
  22183. node2.name = rewriteIdentifier(node2.name, parent, node2);
  22184. ids.push(node2);
  22185. } else {
  22186. if (!(needPrefix && isLocal) && !bailConstant) {
  22187. node2.isConstant = true;
  22188. }
  22189. ids.push(node2);
  22190. }
  22191. },
  22192. true,
  22193. // invoke on ALL identifiers
  22194. parentStack,
  22195. knownIds
  22196. );
  22197. const children = [];
  22198. ids.sort((a, b) => a.start - b.start);
  22199. ids.forEach((id, i) => {
  22200. const start = id.start - 1;
  22201. const end = id.end - 1;
  22202. const last = ids[i - 1];
  22203. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  22204. if (leadingText.length || id.prefix) {
  22205. children.push(leadingText + (id.prefix || ``));
  22206. }
  22207. const source = rawExp.slice(start, end);
  22208. children.push(
  22209. createSimpleExpression(
  22210. id.name,
  22211. false,
  22212. {
  22213. start: advancePositionWithClone(node.loc.start, source, start),
  22214. end: advancePositionWithClone(node.loc.start, source, end),
  22215. source
  22216. },
  22217. id.isConstant ? 3 : 0
  22218. )
  22219. );
  22220. if (i === ids.length - 1 && end < rawExp.length) {
  22221. children.push(rawExp.slice(end));
  22222. }
  22223. });
  22224. let ret;
  22225. if (children.length) {
  22226. ret = createCompoundExpression(children, node.loc);
  22227. ret.ast = ast;
  22228. } else {
  22229. ret = node;
  22230. ret.constType = bailConstant ? 0 : 3;
  22231. }
  22232. ret.identifiers = Object.keys(knownIds);
  22233. return ret;
  22234. }
  22235. function canPrefix(id) {
  22236. if (isGloballyAllowed(id.name)) {
  22237. return false;
  22238. }
  22239. if (id.name === "require") {
  22240. return false;
  22241. }
  22242. return true;
  22243. }
  22244. function stringifyExpression(exp) {
  22245. if (isString$2(exp)) {
  22246. return exp;
  22247. } else if (exp.type === 4) {
  22248. return exp.content;
  22249. } else {
  22250. return exp.children.map(stringifyExpression).join("");
  22251. }
  22252. }
  22253. function isConst(type) {
  22254. return type === "setup-const" || type === "literal-const";
  22255. }
  22256. const transformIf = createStructuralDirectiveTransform(
  22257. /^(if|else|else-if)$/,
  22258. (node, dir, context) => {
  22259. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  22260. const siblings = context.parent.children;
  22261. let i = siblings.indexOf(ifNode);
  22262. let key = 0;
  22263. while (i-- >= 0) {
  22264. const sibling = siblings[i];
  22265. if (sibling && sibling.type === 9) {
  22266. key += sibling.branches.length;
  22267. }
  22268. }
  22269. return () => {
  22270. if (isRoot) {
  22271. ifNode.codegenNode = createCodegenNodeForBranch(
  22272. branch,
  22273. key,
  22274. context
  22275. );
  22276. } else {
  22277. const parentCondition = getParentCondition(ifNode.codegenNode);
  22278. parentCondition.alternate = createCodegenNodeForBranch(
  22279. branch,
  22280. key + ifNode.branches.length - 1,
  22281. context
  22282. );
  22283. }
  22284. };
  22285. });
  22286. }
  22287. );
  22288. function processIf(node, dir, context, processCodegen) {
  22289. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  22290. const loc = dir.exp ? dir.exp.loc : node.loc;
  22291. context.onError(
  22292. createCompilerError(28, dir.loc)
  22293. );
  22294. dir.exp = createSimpleExpression(`true`, false, loc);
  22295. }
  22296. if (context.prefixIdentifiers && dir.exp) {
  22297. dir.exp = processExpression(dir.exp, context);
  22298. }
  22299. if (dir.name === "if") {
  22300. const branch = createIfBranch(node, dir);
  22301. const ifNode = {
  22302. type: 9,
  22303. loc: node.loc,
  22304. branches: [branch]
  22305. };
  22306. context.replaceNode(ifNode);
  22307. if (processCodegen) {
  22308. return processCodegen(ifNode, branch, true);
  22309. }
  22310. } else {
  22311. const siblings = context.parent.children;
  22312. const comments = [];
  22313. let i = siblings.indexOf(node);
  22314. while (i-- >= -1) {
  22315. const sibling = siblings[i];
  22316. if (sibling && sibling.type === 3) {
  22317. context.removeNode(sibling);
  22318. comments.unshift(sibling);
  22319. continue;
  22320. }
  22321. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  22322. context.removeNode(sibling);
  22323. continue;
  22324. }
  22325. if (sibling && sibling.type === 9) {
  22326. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  22327. context.onError(
  22328. createCompilerError(30, node.loc)
  22329. );
  22330. }
  22331. context.removeNode();
  22332. const branch = createIfBranch(node, dir);
  22333. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  22334. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  22335. branch.children = [...comments, ...branch.children];
  22336. }
  22337. {
  22338. const key = branch.userKey;
  22339. if (key) {
  22340. sibling.branches.forEach(({ userKey }) => {
  22341. if (isSameKey(userKey, key)) {
  22342. context.onError(
  22343. createCompilerError(
  22344. 29,
  22345. branch.userKey.loc
  22346. )
  22347. );
  22348. }
  22349. });
  22350. }
  22351. }
  22352. sibling.branches.push(branch);
  22353. const onExit = processCodegen && processCodegen(sibling, branch, false);
  22354. traverseNode(branch, context);
  22355. if (onExit)
  22356. onExit();
  22357. context.currentNode = null;
  22358. } else {
  22359. context.onError(
  22360. createCompilerError(30, node.loc)
  22361. );
  22362. }
  22363. break;
  22364. }
  22365. }
  22366. }
  22367. function createIfBranch(node, dir) {
  22368. const isTemplateIf = node.tagType === 3;
  22369. return {
  22370. type: 10,
  22371. loc: node.loc,
  22372. condition: dir.name === "else" ? void 0 : dir.exp,
  22373. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  22374. userKey: findProp(node, `key`),
  22375. isTemplateIf
  22376. };
  22377. }
  22378. function createCodegenNodeForBranch(branch, keyIndex, context) {
  22379. if (branch.condition) {
  22380. return createConditionalExpression(
  22381. branch.condition,
  22382. createChildrenCodegenNode(branch, keyIndex, context),
  22383. // make sure to pass in asBlock: true so that the comment node call
  22384. // closes the current block.
  22385. createCallExpression(context.helper(CREATE_COMMENT), [
  22386. '"v-if"' ,
  22387. "true"
  22388. ])
  22389. );
  22390. } else {
  22391. return createChildrenCodegenNode(branch, keyIndex, context);
  22392. }
  22393. }
  22394. function createChildrenCodegenNode(branch, keyIndex, context) {
  22395. const { helper } = context;
  22396. const keyProperty = createObjectProperty(
  22397. `key`,
  22398. createSimpleExpression(
  22399. `${keyIndex}`,
  22400. false,
  22401. locStub,
  22402. 2
  22403. )
  22404. );
  22405. const { children } = branch;
  22406. const firstChild = children[0];
  22407. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  22408. if (needFragmentWrapper) {
  22409. if (children.length === 1 && firstChild.type === 11) {
  22410. const vnodeCall = firstChild.codegenNode;
  22411. injectProp(vnodeCall, keyProperty, context);
  22412. return vnodeCall;
  22413. } else {
  22414. let patchFlag = 64;
  22415. let patchFlagText = PatchFlagNames[64];
  22416. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  22417. patchFlag |= 2048;
  22418. patchFlagText += `, ${PatchFlagNames[2048]}`;
  22419. }
  22420. return createVNodeCall(
  22421. context,
  22422. helper(FRAGMENT),
  22423. createObjectExpression([keyProperty]),
  22424. children,
  22425. patchFlag + (` /* ${patchFlagText} */` ),
  22426. void 0,
  22427. void 0,
  22428. true,
  22429. false,
  22430. false,
  22431. branch.loc
  22432. );
  22433. }
  22434. } else {
  22435. const ret = firstChild.codegenNode;
  22436. const vnodeCall = getMemoedVNodeCall(ret);
  22437. if (vnodeCall.type === 13) {
  22438. convertToBlock(vnodeCall, context);
  22439. }
  22440. injectProp(vnodeCall, keyProperty, context);
  22441. return ret;
  22442. }
  22443. }
  22444. function isSameKey(a, b) {
  22445. if (!a || a.type !== b.type) {
  22446. return false;
  22447. }
  22448. if (a.type === 6) {
  22449. if (a.value.content !== b.value.content) {
  22450. return false;
  22451. }
  22452. } else {
  22453. const exp = a.exp;
  22454. const branchExp = b.exp;
  22455. if (exp.type !== branchExp.type) {
  22456. return false;
  22457. }
  22458. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  22459. return false;
  22460. }
  22461. }
  22462. return true;
  22463. }
  22464. function getParentCondition(node) {
  22465. while (true) {
  22466. if (node.type === 19) {
  22467. if (node.alternate.type === 19) {
  22468. node = node.alternate;
  22469. } else {
  22470. return node;
  22471. }
  22472. } else if (node.type === 20) {
  22473. node = node.value;
  22474. }
  22475. }
  22476. }
  22477. const transformFor = createStructuralDirectiveTransform(
  22478. "for",
  22479. (node, dir, context) => {
  22480. const { helper, removeHelper } = context;
  22481. return processFor(node, dir, context, (forNode) => {
  22482. const renderExp = createCallExpression(helper(RENDER_LIST), [
  22483. forNode.source
  22484. ]);
  22485. const isTemplate = isTemplateNode(node);
  22486. const memo = findDir(node, "memo");
  22487. const keyProp = findProp(node, `key`);
  22488. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  22489. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  22490. if (isTemplate) {
  22491. if (memo) {
  22492. memo.exp = processExpression(
  22493. memo.exp,
  22494. context
  22495. );
  22496. }
  22497. if (keyProperty && keyProp.type !== 6) {
  22498. keyProperty.value = processExpression(
  22499. keyProperty.value,
  22500. context
  22501. );
  22502. }
  22503. }
  22504. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  22505. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  22506. forNode.codegenNode = createVNodeCall(
  22507. context,
  22508. helper(FRAGMENT),
  22509. void 0,
  22510. renderExp,
  22511. fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
  22512. void 0,
  22513. void 0,
  22514. true,
  22515. !isStableFragment,
  22516. false,
  22517. node.loc
  22518. );
  22519. return () => {
  22520. let childBlock;
  22521. const { children } = forNode;
  22522. if (isTemplate) {
  22523. node.children.some((c) => {
  22524. if (c.type === 1) {
  22525. const key = findProp(c, "key");
  22526. if (key) {
  22527. context.onError(
  22528. createCompilerError(
  22529. 33,
  22530. key.loc
  22531. )
  22532. );
  22533. return true;
  22534. }
  22535. }
  22536. });
  22537. }
  22538. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  22539. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  22540. if (slotOutlet) {
  22541. childBlock = slotOutlet.codegenNode;
  22542. if (isTemplate && keyProperty) {
  22543. injectProp(childBlock, keyProperty, context);
  22544. }
  22545. } else if (needFragmentWrapper) {
  22546. childBlock = createVNodeCall(
  22547. context,
  22548. helper(FRAGMENT),
  22549. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  22550. node.children,
  22551. 64 + (` /* ${PatchFlagNames[64]} */` ),
  22552. void 0,
  22553. void 0,
  22554. true,
  22555. void 0,
  22556. false
  22557. );
  22558. } else {
  22559. childBlock = children[0].codegenNode;
  22560. if (isTemplate && keyProperty) {
  22561. injectProp(childBlock, keyProperty, context);
  22562. }
  22563. if (childBlock.isBlock !== !isStableFragment) {
  22564. if (childBlock.isBlock) {
  22565. removeHelper(OPEN_BLOCK);
  22566. removeHelper(
  22567. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  22568. );
  22569. } else {
  22570. removeHelper(
  22571. getVNodeHelper(context.inSSR, childBlock.isComponent)
  22572. );
  22573. }
  22574. }
  22575. childBlock.isBlock = !isStableFragment;
  22576. if (childBlock.isBlock) {
  22577. helper(OPEN_BLOCK);
  22578. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  22579. } else {
  22580. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  22581. }
  22582. }
  22583. if (memo) {
  22584. const loop = createFunctionExpression(
  22585. createForLoopParams(forNode.parseResult, [
  22586. createSimpleExpression(`_cached`)
  22587. ])
  22588. );
  22589. loop.body = createBlockStatement([
  22590. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  22591. createCompoundExpression([
  22592. `if (_cached`,
  22593. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  22594. ` && ${context.helperString(
  22595. IS_MEMO_SAME
  22596. )}(_cached, _memo)) return _cached`
  22597. ]),
  22598. createCompoundExpression([`const _item = `, childBlock]),
  22599. createSimpleExpression(`_item.memo = _memo`),
  22600. createSimpleExpression(`return _item`)
  22601. ]);
  22602. renderExp.arguments.push(
  22603. loop,
  22604. createSimpleExpression(`_cache`),
  22605. createSimpleExpression(String(context.cached++))
  22606. );
  22607. } else {
  22608. renderExp.arguments.push(
  22609. createFunctionExpression(
  22610. createForLoopParams(forNode.parseResult),
  22611. childBlock,
  22612. true
  22613. )
  22614. );
  22615. }
  22616. };
  22617. });
  22618. }
  22619. );
  22620. function processFor(node, dir, context, processCodegen) {
  22621. if (!dir.exp) {
  22622. context.onError(
  22623. createCompilerError(31, dir.loc)
  22624. );
  22625. return;
  22626. }
  22627. const parseResult = dir.forParseResult;
  22628. if (!parseResult) {
  22629. context.onError(
  22630. createCompilerError(32, dir.loc)
  22631. );
  22632. return;
  22633. }
  22634. finalizeForParseResult(parseResult, context);
  22635. const { addIdentifiers, removeIdentifiers, scopes } = context;
  22636. const { source, value, key, index } = parseResult;
  22637. const forNode = {
  22638. type: 11,
  22639. loc: dir.loc,
  22640. source,
  22641. valueAlias: value,
  22642. keyAlias: key,
  22643. objectIndexAlias: index,
  22644. parseResult,
  22645. children: isTemplateNode(node) ? node.children : [node]
  22646. };
  22647. context.replaceNode(forNode);
  22648. scopes.vFor++;
  22649. if (context.prefixIdentifiers) {
  22650. value && addIdentifiers(value);
  22651. key && addIdentifiers(key);
  22652. index && addIdentifiers(index);
  22653. }
  22654. const onExit = processCodegen && processCodegen(forNode);
  22655. return () => {
  22656. scopes.vFor--;
  22657. if (context.prefixIdentifiers) {
  22658. value && removeIdentifiers(value);
  22659. key && removeIdentifiers(key);
  22660. index && removeIdentifiers(index);
  22661. }
  22662. if (onExit)
  22663. onExit();
  22664. };
  22665. }
  22666. function finalizeForParseResult(result, context) {
  22667. if (result.finalized)
  22668. return;
  22669. if (context.prefixIdentifiers) {
  22670. result.source = processExpression(
  22671. result.source,
  22672. context
  22673. );
  22674. if (result.key) {
  22675. result.key = processExpression(
  22676. result.key,
  22677. context,
  22678. true
  22679. );
  22680. }
  22681. if (result.index) {
  22682. result.index = processExpression(
  22683. result.index,
  22684. context,
  22685. true
  22686. );
  22687. }
  22688. if (result.value) {
  22689. result.value = processExpression(
  22690. result.value,
  22691. context,
  22692. true
  22693. );
  22694. }
  22695. }
  22696. result.finalized = true;
  22697. }
  22698. function createForLoopParams({ value, key, index }, memoArgs = []) {
  22699. return createParamsList([value, key, index, ...memoArgs]);
  22700. }
  22701. function createParamsList(args) {
  22702. let i = args.length;
  22703. while (i--) {
  22704. if (args[i])
  22705. break;
  22706. }
  22707. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  22708. }
  22709. const defaultFallback = createSimpleExpression(`undefined`, false);
  22710. const trackSlotScopes = (node, context) => {
  22711. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  22712. const vSlot = findDir(node, "slot");
  22713. if (vSlot) {
  22714. const slotProps = vSlot.exp;
  22715. if (context.prefixIdentifiers) {
  22716. slotProps && context.addIdentifiers(slotProps);
  22717. }
  22718. context.scopes.vSlot++;
  22719. return () => {
  22720. if (context.prefixIdentifiers) {
  22721. slotProps && context.removeIdentifiers(slotProps);
  22722. }
  22723. context.scopes.vSlot--;
  22724. };
  22725. }
  22726. }
  22727. };
  22728. const trackVForSlotScopes = (node, context) => {
  22729. let vFor;
  22730. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  22731. const result = vFor.forParseResult;
  22732. if (result) {
  22733. finalizeForParseResult(result, context);
  22734. const { value, key, index } = result;
  22735. const { addIdentifiers, removeIdentifiers } = context;
  22736. value && addIdentifiers(value);
  22737. key && addIdentifiers(key);
  22738. index && addIdentifiers(index);
  22739. return () => {
  22740. value && removeIdentifiers(value);
  22741. key && removeIdentifiers(key);
  22742. index && removeIdentifiers(index);
  22743. };
  22744. }
  22745. }
  22746. };
  22747. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  22748. props,
  22749. children,
  22750. false,
  22751. true,
  22752. children.length ? children[0].loc : loc
  22753. );
  22754. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  22755. context.helper(WITH_CTX);
  22756. const { children, loc } = node;
  22757. const slotsProperties = [];
  22758. const dynamicSlots = [];
  22759. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  22760. if (!context.ssr && context.prefixIdentifiers) {
  22761. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  22762. }
  22763. const onComponentSlot = findDir(node, "slot", true);
  22764. if (onComponentSlot) {
  22765. const { arg, exp } = onComponentSlot;
  22766. if (arg && !isStaticExp(arg)) {
  22767. hasDynamicSlots = true;
  22768. }
  22769. slotsProperties.push(
  22770. createObjectProperty(
  22771. arg || createSimpleExpression("default", true),
  22772. buildSlotFn(exp, void 0, children, loc)
  22773. )
  22774. );
  22775. }
  22776. let hasTemplateSlots = false;
  22777. let hasNamedDefaultSlot = false;
  22778. const implicitDefaultChildren = [];
  22779. const seenSlotNames = /* @__PURE__ */ new Set();
  22780. let conditionalBranchIndex = 0;
  22781. for (let i = 0; i < children.length; i++) {
  22782. const slotElement = children[i];
  22783. let slotDir;
  22784. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  22785. if (slotElement.type !== 3) {
  22786. implicitDefaultChildren.push(slotElement);
  22787. }
  22788. continue;
  22789. }
  22790. if (onComponentSlot) {
  22791. context.onError(
  22792. createCompilerError(37, slotDir.loc)
  22793. );
  22794. break;
  22795. }
  22796. hasTemplateSlots = true;
  22797. const { children: slotChildren, loc: slotLoc } = slotElement;
  22798. const {
  22799. arg: slotName = createSimpleExpression(`default`, true),
  22800. exp: slotProps,
  22801. loc: dirLoc
  22802. } = slotDir;
  22803. let staticSlotName;
  22804. if (isStaticExp(slotName)) {
  22805. staticSlotName = slotName ? slotName.content : `default`;
  22806. } else {
  22807. hasDynamicSlots = true;
  22808. }
  22809. const vFor = findDir(slotElement, "for");
  22810. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  22811. let vIf;
  22812. let vElse;
  22813. if (vIf = findDir(slotElement, "if")) {
  22814. hasDynamicSlots = true;
  22815. dynamicSlots.push(
  22816. createConditionalExpression(
  22817. vIf.exp,
  22818. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  22819. defaultFallback
  22820. )
  22821. );
  22822. } else if (vElse = findDir(
  22823. slotElement,
  22824. /^else(-if)?$/,
  22825. true
  22826. /* allowEmpty */
  22827. )) {
  22828. let j = i;
  22829. let prev;
  22830. while (j--) {
  22831. prev = children[j];
  22832. if (prev.type !== 3) {
  22833. break;
  22834. }
  22835. }
  22836. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  22837. children.splice(i, 1);
  22838. i--;
  22839. let conditional = dynamicSlots[dynamicSlots.length - 1];
  22840. while (conditional.alternate.type === 19) {
  22841. conditional = conditional.alternate;
  22842. }
  22843. conditional.alternate = vElse.exp ? createConditionalExpression(
  22844. vElse.exp,
  22845. buildDynamicSlot(
  22846. slotName,
  22847. slotFunction,
  22848. conditionalBranchIndex++
  22849. ),
  22850. defaultFallback
  22851. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  22852. } else {
  22853. context.onError(
  22854. createCompilerError(30, vElse.loc)
  22855. );
  22856. }
  22857. } else if (vFor) {
  22858. hasDynamicSlots = true;
  22859. const parseResult = vFor.forParseResult;
  22860. if (parseResult) {
  22861. finalizeForParseResult(parseResult, context);
  22862. dynamicSlots.push(
  22863. createCallExpression(context.helper(RENDER_LIST), [
  22864. parseResult.source,
  22865. createFunctionExpression(
  22866. createForLoopParams(parseResult),
  22867. buildDynamicSlot(slotName, slotFunction),
  22868. true
  22869. )
  22870. ])
  22871. );
  22872. } else {
  22873. context.onError(
  22874. createCompilerError(
  22875. 32,
  22876. vFor.loc
  22877. )
  22878. );
  22879. }
  22880. } else {
  22881. if (staticSlotName) {
  22882. if (seenSlotNames.has(staticSlotName)) {
  22883. context.onError(
  22884. createCompilerError(
  22885. 38,
  22886. dirLoc
  22887. )
  22888. );
  22889. continue;
  22890. }
  22891. seenSlotNames.add(staticSlotName);
  22892. if (staticSlotName === "default") {
  22893. hasNamedDefaultSlot = true;
  22894. }
  22895. }
  22896. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  22897. }
  22898. }
  22899. if (!onComponentSlot) {
  22900. const buildDefaultSlotProperty = (props, children2) => {
  22901. const fn = buildSlotFn(props, void 0, children2, loc);
  22902. return createObjectProperty(`default`, fn);
  22903. };
  22904. if (!hasTemplateSlots) {
  22905. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  22906. } else if (implicitDefaultChildren.length && // #3766
  22907. // with whitespace: 'preserve', whitespaces between slots will end up in
  22908. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  22909. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  22910. if (hasNamedDefaultSlot) {
  22911. context.onError(
  22912. createCompilerError(
  22913. 39,
  22914. implicitDefaultChildren[0].loc
  22915. )
  22916. );
  22917. } else {
  22918. slotsProperties.push(
  22919. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  22920. );
  22921. }
  22922. }
  22923. }
  22924. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  22925. let slots = createObjectExpression(
  22926. slotsProperties.concat(
  22927. createObjectProperty(
  22928. `_`,
  22929. // 2 = compiled but dynamic = can skip normalization, but must run diff
  22930. // 1 = compiled and static = can skip normalization AND diff as optimized
  22931. createSimpleExpression(
  22932. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  22933. false
  22934. )
  22935. )
  22936. ),
  22937. loc
  22938. );
  22939. if (dynamicSlots.length) {
  22940. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  22941. slots,
  22942. createArrayExpression(dynamicSlots)
  22943. ]);
  22944. }
  22945. return {
  22946. slots,
  22947. hasDynamicSlots
  22948. };
  22949. }
  22950. function buildDynamicSlot(name, fn, index) {
  22951. const props = [
  22952. createObjectProperty(`name`, name),
  22953. createObjectProperty(`fn`, fn)
  22954. ];
  22955. if (index != null) {
  22956. props.push(
  22957. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  22958. );
  22959. }
  22960. return createObjectExpression(props);
  22961. }
  22962. function hasForwardedSlots(children) {
  22963. for (let i = 0; i < children.length; i++) {
  22964. const child = children[i];
  22965. switch (child.type) {
  22966. case 1:
  22967. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  22968. return true;
  22969. }
  22970. break;
  22971. case 9:
  22972. if (hasForwardedSlots(child.branches))
  22973. return true;
  22974. break;
  22975. case 10:
  22976. case 11:
  22977. if (hasForwardedSlots(child.children))
  22978. return true;
  22979. break;
  22980. }
  22981. }
  22982. return false;
  22983. }
  22984. function isNonWhitespaceContent(node) {
  22985. if (node.type !== 2 && node.type !== 12)
  22986. return true;
  22987. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  22988. }
  22989. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  22990. const transformElement = (node, context) => {
  22991. return function postTransformElement() {
  22992. node = context.currentNode;
  22993. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  22994. return;
  22995. }
  22996. const { tag, props } = node;
  22997. const isComponent = node.tagType === 1;
  22998. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  22999. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23000. let vnodeProps;
  23001. let vnodeChildren;
  23002. let vnodePatchFlag;
  23003. let patchFlag = 0;
  23004. let vnodeDynamicProps;
  23005. let dynamicPropNames;
  23006. let vnodeDirectives;
  23007. let shouldUseBlock = (
  23008. // dynamic component may resolve to plain elements
  23009. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23010. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23011. // This is technically web-specific, but splitting the logic out of core
  23012. // leads to too much unnecessary complexity.
  23013. (tag === "svg" || tag === "foreignObject")
  23014. );
  23015. if (props.length > 0) {
  23016. const propsBuildResult = buildProps(
  23017. node,
  23018. context,
  23019. void 0,
  23020. isComponent,
  23021. isDynamicComponent
  23022. );
  23023. vnodeProps = propsBuildResult.props;
  23024. patchFlag = propsBuildResult.patchFlag;
  23025. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23026. const directives = propsBuildResult.directives;
  23027. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23028. directives.map((dir) => buildDirectiveArgs(dir, context))
  23029. ) : void 0;
  23030. if (propsBuildResult.shouldUseBlock) {
  23031. shouldUseBlock = true;
  23032. }
  23033. }
  23034. if (node.children.length > 0) {
  23035. if (vnodeTag === KEEP_ALIVE) {
  23036. shouldUseBlock = true;
  23037. patchFlag |= 1024;
  23038. if (node.children.length > 1) {
  23039. context.onError(
  23040. createCompilerError(46, {
  23041. start: node.children[0].loc.start,
  23042. end: node.children[node.children.length - 1].loc.end,
  23043. source: ""
  23044. })
  23045. );
  23046. }
  23047. }
  23048. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  23049. vnodeTag !== TELEPORT && // explained above.
  23050. vnodeTag !== KEEP_ALIVE;
  23051. if (shouldBuildAsSlots) {
  23052. const { slots, hasDynamicSlots } = buildSlots(node, context);
  23053. vnodeChildren = slots;
  23054. if (hasDynamicSlots) {
  23055. patchFlag |= 1024;
  23056. }
  23057. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  23058. const child = node.children[0];
  23059. const type = child.type;
  23060. const hasDynamicTextChild = type === 5 || type === 8;
  23061. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  23062. patchFlag |= 1;
  23063. }
  23064. if (hasDynamicTextChild || type === 2) {
  23065. vnodeChildren = child;
  23066. } else {
  23067. vnodeChildren = node.children;
  23068. }
  23069. } else {
  23070. vnodeChildren = node.children;
  23071. }
  23072. }
  23073. if (patchFlag !== 0) {
  23074. {
  23075. if (patchFlag < 0) {
  23076. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  23077. } else {
  23078. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  23079. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  23080. }
  23081. }
  23082. if (dynamicPropNames && dynamicPropNames.length) {
  23083. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  23084. }
  23085. }
  23086. node.codegenNode = createVNodeCall(
  23087. context,
  23088. vnodeTag,
  23089. vnodeProps,
  23090. vnodeChildren,
  23091. vnodePatchFlag,
  23092. vnodeDynamicProps,
  23093. vnodeDirectives,
  23094. !!shouldUseBlock,
  23095. false,
  23096. isComponent,
  23097. node.loc
  23098. );
  23099. };
  23100. };
  23101. function resolveComponentType(node, context, ssr = false) {
  23102. let { tag } = node;
  23103. const isExplicitDynamic = isComponentTag(tag);
  23104. const isProp = findProp(node, "is");
  23105. if (isProp) {
  23106. if (isExplicitDynamic || false) {
  23107. const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
  23108. if (exp) {
  23109. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  23110. exp
  23111. ]);
  23112. }
  23113. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  23114. tag = isProp.value.content.slice(4);
  23115. }
  23116. }
  23117. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  23118. if (builtIn) {
  23119. if (!ssr)
  23120. context.helper(builtIn);
  23121. return builtIn;
  23122. }
  23123. {
  23124. const fromSetup = resolveSetupReference(tag, context);
  23125. if (fromSetup) {
  23126. return fromSetup;
  23127. }
  23128. const dotIndex = tag.indexOf(".");
  23129. if (dotIndex > 0) {
  23130. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  23131. if (ns) {
  23132. return ns + tag.slice(dotIndex);
  23133. }
  23134. }
  23135. }
  23136. if (context.selfName && capitalize$1(camelize(tag)) === context.selfName) {
  23137. context.helper(RESOLVE_COMPONENT);
  23138. context.components.add(tag + `__self`);
  23139. return toValidAssetId(tag, `component`);
  23140. }
  23141. context.helper(RESOLVE_COMPONENT);
  23142. context.components.add(tag);
  23143. return toValidAssetId(tag, `component`);
  23144. }
  23145. function resolveSetupReference(name, context) {
  23146. const bindings = context.bindingMetadata;
  23147. if (!bindings || bindings.__isScriptSetup === false) {
  23148. return;
  23149. }
  23150. const camelName = camelize(name);
  23151. const PascalName = capitalize$1(camelName);
  23152. const checkType = (type) => {
  23153. if (bindings[name] === type) {
  23154. return name;
  23155. }
  23156. if (bindings[camelName] === type) {
  23157. return camelName;
  23158. }
  23159. if (bindings[PascalName] === type) {
  23160. return PascalName;
  23161. }
  23162. };
  23163. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  23164. if (fromConst) {
  23165. return context.inline ? (
  23166. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  23167. fromConst
  23168. ) : `$setup[${JSON.stringify(fromConst)}]`;
  23169. }
  23170. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  23171. if (fromMaybeRef) {
  23172. return context.inline ? (
  23173. // setup scope bindings that may be refs need to be unrefed
  23174. `${context.helperString(UNREF)}(${fromMaybeRef})`
  23175. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  23176. }
  23177. const fromProps = checkType("props");
  23178. if (fromProps) {
  23179. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  23180. }
  23181. }
  23182. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  23183. const { tag, loc: elementLoc, children } = node;
  23184. let properties = [];
  23185. const mergeArgs = [];
  23186. const runtimeDirectives = [];
  23187. const hasChildren = children.length > 0;
  23188. let shouldUseBlock = false;
  23189. let patchFlag = 0;
  23190. let hasRef = false;
  23191. let hasClassBinding = false;
  23192. let hasStyleBinding = false;
  23193. let hasHydrationEventBinding = false;
  23194. let hasDynamicKeys = false;
  23195. let hasVnodeHook = false;
  23196. const dynamicPropNames = [];
  23197. const pushMergeArg = (arg) => {
  23198. if (properties.length) {
  23199. mergeArgs.push(
  23200. createObjectExpression(dedupeProperties(properties), elementLoc)
  23201. );
  23202. properties = [];
  23203. }
  23204. if (arg)
  23205. mergeArgs.push(arg);
  23206. };
  23207. const analyzePatchFlag = ({ key, value }) => {
  23208. if (isStaticExp(key)) {
  23209. const name = key.content;
  23210. const isEventHandler = isOn(name);
  23211. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  23212. // dedicated fast path.
  23213. name.toLowerCase() !== "onclick" && // omit v-model handlers
  23214. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  23215. !isReservedProp(name)) {
  23216. hasHydrationEventBinding = true;
  23217. }
  23218. if (isEventHandler && isReservedProp(name)) {
  23219. hasVnodeHook = true;
  23220. }
  23221. if (isEventHandler && value.type === 14) {
  23222. value = value.arguments[0];
  23223. }
  23224. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  23225. return;
  23226. }
  23227. if (name === "ref") {
  23228. hasRef = true;
  23229. } else if (name === "class") {
  23230. hasClassBinding = true;
  23231. } else if (name === "style") {
  23232. hasStyleBinding = true;
  23233. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  23234. dynamicPropNames.push(name);
  23235. }
  23236. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  23237. dynamicPropNames.push(name);
  23238. }
  23239. } else {
  23240. hasDynamicKeys = true;
  23241. }
  23242. };
  23243. for (let i = 0; i < props.length; i++) {
  23244. const prop = props[i];
  23245. if (prop.type === 6) {
  23246. const { loc, name, nameLoc, value } = prop;
  23247. let isStatic = true;
  23248. if (name === "ref") {
  23249. hasRef = true;
  23250. if (context.scopes.vFor > 0) {
  23251. properties.push(
  23252. createObjectProperty(
  23253. createSimpleExpression("ref_for", true),
  23254. createSimpleExpression("true")
  23255. )
  23256. );
  23257. }
  23258. if (value && context.inline) {
  23259. const binding = context.bindingMetadata[value.content];
  23260. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  23261. isStatic = false;
  23262. properties.push(
  23263. createObjectProperty(
  23264. createSimpleExpression("ref_key", true),
  23265. createSimpleExpression(value.content, true, value.loc)
  23266. )
  23267. );
  23268. }
  23269. }
  23270. }
  23271. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  23272. continue;
  23273. }
  23274. properties.push(
  23275. createObjectProperty(
  23276. createSimpleExpression(name, true, nameLoc),
  23277. createSimpleExpression(
  23278. value ? value.content : "",
  23279. isStatic,
  23280. value ? value.loc : loc
  23281. )
  23282. )
  23283. );
  23284. } else {
  23285. const { name, arg, exp, loc, modifiers } = prop;
  23286. const isVBind = name === "bind";
  23287. const isVOn = name === "on";
  23288. if (name === "slot") {
  23289. if (!isComponent) {
  23290. context.onError(
  23291. createCompilerError(40, loc)
  23292. );
  23293. }
  23294. continue;
  23295. }
  23296. if (name === "once" || name === "memo") {
  23297. continue;
  23298. }
  23299. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  23300. continue;
  23301. }
  23302. if (isVOn && ssr) {
  23303. continue;
  23304. }
  23305. if (
  23306. // #938: elements with dynamic keys should be forced into blocks
  23307. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  23308. // before children
  23309. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  23310. ) {
  23311. shouldUseBlock = true;
  23312. }
  23313. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  23314. properties.push(
  23315. createObjectProperty(
  23316. createSimpleExpression("ref_for", true),
  23317. createSimpleExpression("true")
  23318. )
  23319. );
  23320. }
  23321. if (!arg && (isVBind || isVOn)) {
  23322. hasDynamicKeys = true;
  23323. if (exp) {
  23324. if (isVBind) {
  23325. pushMergeArg();
  23326. mergeArgs.push(exp);
  23327. } else {
  23328. pushMergeArg({
  23329. type: 14,
  23330. loc,
  23331. callee: context.helper(TO_HANDLERS),
  23332. arguments: isComponent ? [exp] : [exp, `true`]
  23333. });
  23334. }
  23335. } else {
  23336. context.onError(
  23337. createCompilerError(
  23338. isVBind ? 34 : 35,
  23339. loc
  23340. )
  23341. );
  23342. }
  23343. continue;
  23344. }
  23345. if (isVBind && modifiers.includes("prop")) {
  23346. patchFlag |= 32;
  23347. }
  23348. const directiveTransform = context.directiveTransforms[name];
  23349. if (directiveTransform) {
  23350. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  23351. !ssr && props2.forEach(analyzePatchFlag);
  23352. if (isVOn && arg && !isStaticExp(arg)) {
  23353. pushMergeArg(createObjectExpression(props2, elementLoc));
  23354. } else {
  23355. properties.push(...props2);
  23356. }
  23357. if (needRuntime) {
  23358. runtimeDirectives.push(prop);
  23359. if (isSymbol$1(needRuntime)) {
  23360. directiveImportMap.set(prop, needRuntime);
  23361. }
  23362. }
  23363. } else if (!isBuiltInDirective(name)) {
  23364. runtimeDirectives.push(prop);
  23365. if (hasChildren) {
  23366. shouldUseBlock = true;
  23367. }
  23368. }
  23369. }
  23370. }
  23371. let propsExpression = void 0;
  23372. if (mergeArgs.length) {
  23373. pushMergeArg();
  23374. if (mergeArgs.length > 1) {
  23375. propsExpression = createCallExpression(
  23376. context.helper(MERGE_PROPS),
  23377. mergeArgs,
  23378. elementLoc
  23379. );
  23380. } else {
  23381. propsExpression = mergeArgs[0];
  23382. }
  23383. } else if (properties.length) {
  23384. propsExpression = createObjectExpression(
  23385. dedupeProperties(properties),
  23386. elementLoc
  23387. );
  23388. }
  23389. if (hasDynamicKeys) {
  23390. patchFlag |= 16;
  23391. } else {
  23392. if (hasClassBinding && !isComponent) {
  23393. patchFlag |= 2;
  23394. }
  23395. if (hasStyleBinding && !isComponent) {
  23396. patchFlag |= 4;
  23397. }
  23398. if (dynamicPropNames.length) {
  23399. patchFlag |= 8;
  23400. }
  23401. if (hasHydrationEventBinding) {
  23402. patchFlag |= 32;
  23403. }
  23404. }
  23405. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  23406. patchFlag |= 512;
  23407. }
  23408. if (!context.inSSR && propsExpression) {
  23409. switch (propsExpression.type) {
  23410. case 15:
  23411. let classKeyIndex = -1;
  23412. let styleKeyIndex = -1;
  23413. let hasDynamicKey = false;
  23414. for (let i = 0; i < propsExpression.properties.length; i++) {
  23415. const key = propsExpression.properties[i].key;
  23416. if (isStaticExp(key)) {
  23417. if (key.content === "class") {
  23418. classKeyIndex = i;
  23419. } else if (key.content === "style") {
  23420. styleKeyIndex = i;
  23421. }
  23422. } else if (!key.isHandlerKey) {
  23423. hasDynamicKey = true;
  23424. }
  23425. }
  23426. const classProp = propsExpression.properties[classKeyIndex];
  23427. const styleProp = propsExpression.properties[styleKeyIndex];
  23428. if (!hasDynamicKey) {
  23429. if (classProp && !isStaticExp(classProp.value)) {
  23430. classProp.value = createCallExpression(
  23431. context.helper(NORMALIZE_CLASS),
  23432. [classProp.value]
  23433. );
  23434. }
  23435. if (styleProp && // the static style is compiled into an object,
  23436. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  23437. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  23438. // v-bind:style with static literal object
  23439. styleProp.value.type === 17)) {
  23440. styleProp.value = createCallExpression(
  23441. context.helper(NORMALIZE_STYLE),
  23442. [styleProp.value]
  23443. );
  23444. }
  23445. } else {
  23446. propsExpression = createCallExpression(
  23447. context.helper(NORMALIZE_PROPS),
  23448. [propsExpression]
  23449. );
  23450. }
  23451. break;
  23452. case 14:
  23453. break;
  23454. default:
  23455. propsExpression = createCallExpression(
  23456. context.helper(NORMALIZE_PROPS),
  23457. [
  23458. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  23459. propsExpression
  23460. ])
  23461. ]
  23462. );
  23463. break;
  23464. }
  23465. }
  23466. return {
  23467. props: propsExpression,
  23468. directives: runtimeDirectives,
  23469. patchFlag,
  23470. dynamicPropNames,
  23471. shouldUseBlock
  23472. };
  23473. }
  23474. function dedupeProperties(properties) {
  23475. const knownProps = /* @__PURE__ */ new Map();
  23476. const deduped = [];
  23477. for (let i = 0; i < properties.length; i++) {
  23478. const prop = properties[i];
  23479. if (prop.key.type === 8 || !prop.key.isStatic) {
  23480. deduped.push(prop);
  23481. continue;
  23482. }
  23483. const name = prop.key.content;
  23484. const existing = knownProps.get(name);
  23485. if (existing) {
  23486. if (name === "style" || name === "class" || isOn(name)) {
  23487. mergeAsArray(existing, prop);
  23488. }
  23489. } else {
  23490. knownProps.set(name, prop);
  23491. deduped.push(prop);
  23492. }
  23493. }
  23494. return deduped;
  23495. }
  23496. function mergeAsArray(existing, incoming) {
  23497. if (existing.value.type === 17) {
  23498. existing.value.elements.push(incoming.value);
  23499. } else {
  23500. existing.value = createArrayExpression(
  23501. [existing.value, incoming.value],
  23502. existing.loc
  23503. );
  23504. }
  23505. }
  23506. function buildDirectiveArgs(dir, context) {
  23507. const dirArgs = [];
  23508. const runtime = directiveImportMap.get(dir);
  23509. if (runtime) {
  23510. dirArgs.push(context.helperString(runtime));
  23511. } else {
  23512. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  23513. if (fromSetup) {
  23514. dirArgs.push(fromSetup);
  23515. } else {
  23516. context.helper(RESOLVE_DIRECTIVE);
  23517. context.directives.add(dir.name);
  23518. dirArgs.push(toValidAssetId(dir.name, `directive`));
  23519. }
  23520. }
  23521. const { loc } = dir;
  23522. if (dir.exp)
  23523. dirArgs.push(dir.exp);
  23524. if (dir.arg) {
  23525. if (!dir.exp) {
  23526. dirArgs.push(`void 0`);
  23527. }
  23528. dirArgs.push(dir.arg);
  23529. }
  23530. if (Object.keys(dir.modifiers).length) {
  23531. if (!dir.arg) {
  23532. if (!dir.exp) {
  23533. dirArgs.push(`void 0`);
  23534. }
  23535. dirArgs.push(`void 0`);
  23536. }
  23537. const trueExpression = createSimpleExpression(`true`, false, loc);
  23538. dirArgs.push(
  23539. createObjectExpression(
  23540. dir.modifiers.map(
  23541. (modifier) => createObjectProperty(modifier, trueExpression)
  23542. ),
  23543. loc
  23544. )
  23545. );
  23546. }
  23547. return createArrayExpression(dirArgs, dir.loc);
  23548. }
  23549. function stringifyDynamicPropNames(props) {
  23550. let propsNamesString = `[`;
  23551. for (let i = 0, l = props.length; i < l; i++) {
  23552. propsNamesString += JSON.stringify(props[i]);
  23553. if (i < l - 1)
  23554. propsNamesString += ", ";
  23555. }
  23556. return propsNamesString + `]`;
  23557. }
  23558. function isComponentTag(tag) {
  23559. return tag === "component" || tag === "Component";
  23560. }
  23561. const transformSlotOutlet = (node, context) => {
  23562. if (isSlotOutlet(node)) {
  23563. const { children, loc } = node;
  23564. const { slotName, slotProps } = processSlotOutlet(node, context);
  23565. const slotArgs = [
  23566. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  23567. slotName,
  23568. "{}",
  23569. "undefined",
  23570. "true"
  23571. ];
  23572. let expectedLen = 2;
  23573. if (slotProps) {
  23574. slotArgs[2] = slotProps;
  23575. expectedLen = 3;
  23576. }
  23577. if (children.length) {
  23578. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  23579. expectedLen = 4;
  23580. }
  23581. if (context.scopeId && !context.slotted) {
  23582. expectedLen = 5;
  23583. }
  23584. slotArgs.splice(expectedLen);
  23585. node.codegenNode = createCallExpression(
  23586. context.helper(RENDER_SLOT),
  23587. slotArgs,
  23588. loc
  23589. );
  23590. }
  23591. };
  23592. function processSlotOutlet(node, context) {
  23593. let slotName = `"default"`;
  23594. let slotProps = void 0;
  23595. const nonNameProps = [];
  23596. for (let i = 0; i < node.props.length; i++) {
  23597. const p = node.props[i];
  23598. if (p.type === 6) {
  23599. if (p.value) {
  23600. if (p.name === "name") {
  23601. slotName = JSON.stringify(p.value.content);
  23602. } else {
  23603. p.name = camelize(p.name);
  23604. nonNameProps.push(p);
  23605. }
  23606. }
  23607. } else {
  23608. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  23609. if (p.exp) {
  23610. slotName = p.exp;
  23611. } else if (p.arg && p.arg.type === 4) {
  23612. const name = camelize(p.arg.content);
  23613. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  23614. {
  23615. slotName = p.exp = processExpression(p.exp, context);
  23616. }
  23617. }
  23618. } else {
  23619. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  23620. p.arg.content = camelize(p.arg.content);
  23621. }
  23622. nonNameProps.push(p);
  23623. }
  23624. }
  23625. }
  23626. if (nonNameProps.length > 0) {
  23627. const { props, directives } = buildProps(
  23628. node,
  23629. context,
  23630. nonNameProps,
  23631. false,
  23632. false
  23633. );
  23634. slotProps = props;
  23635. if (directives.length) {
  23636. context.onError(
  23637. createCompilerError(
  23638. 36,
  23639. directives[0].loc
  23640. )
  23641. );
  23642. }
  23643. }
  23644. return {
  23645. slotName,
  23646. slotProps
  23647. };
  23648. }
  23649. const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  23650. const transformOn$1 = (dir, node, context, augmentor) => {
  23651. const { loc, modifiers, arg } = dir;
  23652. if (!dir.exp && !modifiers.length) {
  23653. context.onError(createCompilerError(35, loc));
  23654. }
  23655. let eventName;
  23656. if (arg.type === 4) {
  23657. if (arg.isStatic) {
  23658. let rawName = arg.content;
  23659. if (rawName.startsWith("vnode")) {
  23660. context.onError(createCompilerError(51, arg.loc));
  23661. }
  23662. if (rawName.startsWith("vue:")) {
  23663. rawName = `vnode-${rawName.slice(4)}`;
  23664. }
  23665. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  23666. // for non-element and vnode lifecycle event listeners, auto convert
  23667. // it to camelCase. See issue #2249
  23668. toHandlerKey(camelize(rawName))
  23669. ) : (
  23670. // preserve case for plain element listeners that have uppercase
  23671. // letters, as these may be custom elements' custom events
  23672. `on:${rawName}`
  23673. );
  23674. eventName = createSimpleExpression(eventString, true, arg.loc);
  23675. } else {
  23676. eventName = createCompoundExpression([
  23677. `${context.helperString(TO_HANDLER_KEY)}(`,
  23678. arg,
  23679. `)`
  23680. ]);
  23681. }
  23682. } else {
  23683. eventName = arg;
  23684. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  23685. eventName.children.push(`)`);
  23686. }
  23687. let exp = dir.exp;
  23688. if (exp && !exp.content.trim()) {
  23689. exp = void 0;
  23690. }
  23691. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  23692. if (exp) {
  23693. const isMemberExp = isMemberExpression(exp.content, context);
  23694. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  23695. const hasMultipleStatements = exp.content.includes(`;`);
  23696. if (context.prefixIdentifiers) {
  23697. isInlineStatement && context.addIdentifiers(`$event`);
  23698. exp = dir.exp = processExpression(
  23699. exp,
  23700. context,
  23701. false,
  23702. hasMultipleStatements
  23703. );
  23704. isInlineStatement && context.removeIdentifiers(`$event`);
  23705. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  23706. !context.inVOnce && // runtime constants don't need to be cached
  23707. // (this is analyzed by compileScript in SFC <script setup>)
  23708. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  23709. // we need to use the original function to preserve arity,
  23710. // e.g. <transition> relies on checking cb.length to determine
  23711. // transition end handling. Inline function is ok since its arity
  23712. // is preserved even when cached.
  23713. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  23714. // it must be passed fresh to avoid stale values.
  23715. !hasScopeRef(exp, context.identifiers);
  23716. if (shouldCache && isMemberExp) {
  23717. if (exp.type === 4) {
  23718. exp.content = `${exp.content} && ${exp.content}(...args)`;
  23719. } else {
  23720. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  23721. }
  23722. }
  23723. }
  23724. if (isInlineStatement || shouldCache && isMemberExp) {
  23725. exp = createCompoundExpression([
  23726. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  23727. //@ts-ignore
  23728. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  23729. exp,
  23730. hasMultipleStatements ? `}` : `)`
  23731. ]);
  23732. }
  23733. }
  23734. let ret = {
  23735. props: [
  23736. createObjectProperty(
  23737. eventName,
  23738. exp || createSimpleExpression(`() => {}`, false, loc)
  23739. )
  23740. ]
  23741. };
  23742. if (augmentor) {
  23743. ret = augmentor(ret);
  23744. }
  23745. if (shouldCache) {
  23746. ret.props[0].value = context.cache(ret.props[0].value);
  23747. }
  23748. ret.props.forEach((p) => p.key.isHandlerKey = true);
  23749. return ret;
  23750. };
  23751. const transformBind = (dir, _node, context) => {
  23752. const { modifiers, loc } = dir;
  23753. const arg = dir.arg;
  23754. let { exp } = dir;
  23755. if (exp && exp.type === 4 && !exp.content.trim()) {
  23756. {
  23757. context.onError(
  23758. createCompilerError(34, loc)
  23759. );
  23760. return {
  23761. props: [
  23762. createObjectProperty(arg, createSimpleExpression("", true, loc))
  23763. ]
  23764. };
  23765. }
  23766. }
  23767. if (!exp) {
  23768. if (arg.type !== 4 || !arg.isStatic) {
  23769. context.onError(
  23770. createCompilerError(
  23771. 52,
  23772. arg.loc
  23773. )
  23774. );
  23775. return {
  23776. props: [
  23777. createObjectProperty(arg, createSimpleExpression("", true, loc))
  23778. ]
  23779. };
  23780. }
  23781. const propName = camelize(arg.content);
  23782. exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
  23783. {
  23784. exp = dir.exp = processExpression(exp, context);
  23785. }
  23786. }
  23787. if (arg.type !== 4) {
  23788. arg.children.unshift(`(`);
  23789. arg.children.push(`) || ""`);
  23790. } else if (!arg.isStatic) {
  23791. arg.content = `${arg.content} || ""`;
  23792. }
  23793. if (modifiers.includes("camel")) {
  23794. if (arg.type === 4) {
  23795. if (arg.isStatic) {
  23796. arg.content = camelize(arg.content);
  23797. } else {
  23798. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  23799. }
  23800. } else {
  23801. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  23802. arg.children.push(`)`);
  23803. }
  23804. }
  23805. if (!context.inSSR) {
  23806. if (modifiers.includes("prop")) {
  23807. injectPrefix(arg, ".");
  23808. }
  23809. if (modifiers.includes("attr")) {
  23810. injectPrefix(arg, "^");
  23811. }
  23812. }
  23813. return {
  23814. props: [createObjectProperty(arg, exp)]
  23815. };
  23816. };
  23817. const injectPrefix = (arg, prefix) => {
  23818. if (arg.type === 4) {
  23819. if (arg.isStatic) {
  23820. arg.content = prefix + arg.content;
  23821. } else {
  23822. arg.content = `\`${prefix}\${${arg.content}}\``;
  23823. }
  23824. } else {
  23825. arg.children.unshift(`'${prefix}' + (`);
  23826. arg.children.push(`)`);
  23827. }
  23828. };
  23829. const transformText = (node, context) => {
  23830. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  23831. return () => {
  23832. const children = node.children;
  23833. let currentContainer = void 0;
  23834. let hasText = false;
  23835. for (let i = 0; i < children.length; i++) {
  23836. const child = children[i];
  23837. if (isText$1(child)) {
  23838. hasText = true;
  23839. for (let j = i + 1; j < children.length; j++) {
  23840. const next = children[j];
  23841. if (isText$1(next)) {
  23842. if (!currentContainer) {
  23843. currentContainer = children[i] = createCompoundExpression(
  23844. [child],
  23845. child.loc
  23846. );
  23847. }
  23848. currentContainer.children.push(` + `, next);
  23849. children.splice(j, 1);
  23850. j--;
  23851. } else {
  23852. currentContainer = void 0;
  23853. break;
  23854. }
  23855. }
  23856. }
  23857. }
  23858. if (!hasText || // if this is a plain element with a single text child, leave it
  23859. // as-is since the runtime has dedicated fast path for this by directly
  23860. // setting textContent of the element.
  23861. // for component root it's always normalized anyway.
  23862. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  23863. // custom directives can potentially add DOM elements arbitrarily,
  23864. // we need to avoid setting textContent of the element at runtime
  23865. // to avoid accidentally overwriting the DOM elements added
  23866. // by the user through custom directives.
  23867. !node.props.find(
  23868. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  23869. ) && // in compat mode, <template> tags with no special directives
  23870. // will be rendered as a fragment so its children must be
  23871. // converted into vnodes.
  23872. true)) {
  23873. return;
  23874. }
  23875. for (let i = 0; i < children.length; i++) {
  23876. const child = children[i];
  23877. if (isText$1(child) || child.type === 8) {
  23878. const callArgs = [];
  23879. if (child.type !== 2 || child.content !== " ") {
  23880. callArgs.push(child);
  23881. }
  23882. if (!context.ssr && getConstantType(child, context) === 0) {
  23883. callArgs.push(
  23884. 1 + (` /* ${PatchFlagNames[1]} */` )
  23885. );
  23886. }
  23887. children[i] = {
  23888. type: 12,
  23889. content: child,
  23890. loc: child.loc,
  23891. codegenNode: createCallExpression(
  23892. context.helper(CREATE_TEXT),
  23893. callArgs
  23894. )
  23895. };
  23896. }
  23897. }
  23898. };
  23899. }
  23900. };
  23901. const seen$1 = /* @__PURE__ */ new WeakSet();
  23902. const transformOnce = (node, context) => {
  23903. if (node.type === 1 && findDir(node, "once", true)) {
  23904. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  23905. return;
  23906. }
  23907. seen$1.add(node);
  23908. context.inVOnce = true;
  23909. context.helper(SET_BLOCK_TRACKING);
  23910. return () => {
  23911. context.inVOnce = false;
  23912. const cur = context.currentNode;
  23913. if (cur.codegenNode) {
  23914. cur.codegenNode = context.cache(
  23915. cur.codegenNode,
  23916. true
  23917. /* isVNode */
  23918. );
  23919. }
  23920. };
  23921. }
  23922. };
  23923. const transformModel$1 = (dir, node, context) => {
  23924. const { exp, arg } = dir;
  23925. if (!exp) {
  23926. context.onError(
  23927. createCompilerError(41, dir.loc)
  23928. );
  23929. return createTransformProps();
  23930. }
  23931. const rawExp = exp.loc.source;
  23932. const expString = exp.type === 4 ? exp.content : rawExp;
  23933. const bindingType = context.bindingMetadata[rawExp];
  23934. if (bindingType === "props" || bindingType === "props-aliased") {
  23935. context.onError(createCompilerError(44, exp.loc));
  23936. return createTransformProps();
  23937. }
  23938. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  23939. if (!expString.trim() || !isMemberExpression(expString, context) && !maybeRef) {
  23940. context.onError(
  23941. createCompilerError(42, exp.loc)
  23942. );
  23943. return createTransformProps();
  23944. }
  23945. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  23946. context.onError(
  23947. createCompilerError(43, exp.loc)
  23948. );
  23949. return createTransformProps();
  23950. }
  23951. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  23952. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  23953. let assignmentExp;
  23954. const eventArg = context.isTS ? `($event: any)` : `$event`;
  23955. if (maybeRef) {
  23956. if (bindingType === "setup-ref") {
  23957. assignmentExp = createCompoundExpression([
  23958. `${eventArg} => ((`,
  23959. createSimpleExpression(rawExp, false, exp.loc),
  23960. `).value = $event)`
  23961. ]);
  23962. } else {
  23963. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  23964. assignmentExp = createCompoundExpression([
  23965. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  23966. createSimpleExpression(rawExp, false, exp.loc),
  23967. `).value = $event : ${altAssignment})`
  23968. ]);
  23969. }
  23970. } else {
  23971. assignmentExp = createCompoundExpression([
  23972. `${eventArg} => ((`,
  23973. exp,
  23974. `) = $event)`
  23975. ]);
  23976. }
  23977. const props = [
  23978. // modelValue: foo
  23979. createObjectProperty(propName, dir.exp),
  23980. // "onUpdate:modelValue": $event => (foo = $event)
  23981. createObjectProperty(eventName, assignmentExp)
  23982. ];
  23983. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  23984. props[1].value = context.cache(props[1].value);
  23985. }
  23986. if (dir.modifiers.length && node.tagType === 1) {
  23987. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  23988. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  23989. props.push(
  23990. createObjectProperty(
  23991. modifiersKey,
  23992. createSimpleExpression(
  23993. `{ ${modifiers} }`,
  23994. false,
  23995. dir.loc,
  23996. 2
  23997. )
  23998. )
  23999. );
  24000. }
  24001. return createTransformProps(props);
  24002. };
  24003. function createTransformProps(props = []) {
  24004. return { props };
  24005. }
  24006. const seen = /* @__PURE__ */ new WeakSet();
  24007. const transformMemo = (node, context) => {
  24008. if (node.type === 1) {
  24009. const dir = findDir(node, "memo");
  24010. if (!dir || seen.has(node)) {
  24011. return;
  24012. }
  24013. seen.add(node);
  24014. return () => {
  24015. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24016. if (codegenNode && codegenNode.type === 13) {
  24017. if (node.tagType !== 1) {
  24018. convertToBlock(codegenNode, context);
  24019. }
  24020. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24021. dir.exp,
  24022. createFunctionExpression(void 0, codegenNode),
  24023. `_cache`,
  24024. String(context.cached++)
  24025. ]);
  24026. }
  24027. };
  24028. }
  24029. };
  24030. function getBaseTransformPreset(prefixIdentifiers) {
  24031. return [
  24032. [
  24033. transformOnce,
  24034. transformIf,
  24035. transformMemo,
  24036. transformFor,
  24037. ...[],
  24038. ...prefixIdentifiers ? [
  24039. // order is important
  24040. trackVForSlotScopes,
  24041. transformExpression
  24042. ] : [],
  24043. transformSlotOutlet,
  24044. transformElement,
  24045. trackSlotScopes,
  24046. transformText
  24047. ],
  24048. {
  24049. on: transformOn$1,
  24050. bind: transformBind,
  24051. model: transformModel$1
  24052. }
  24053. ];
  24054. }
  24055. function baseCompile(source, options = {}) {
  24056. const onError = options.onError || defaultOnError;
  24057. const isModuleMode = options.mode === "module";
  24058. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  24059. if (!prefixIdentifiers && options.cacheHandlers) {
  24060. onError(createCompilerError(49));
  24061. }
  24062. if (options.scopeId && !isModuleMode) {
  24063. onError(createCompilerError(50));
  24064. }
  24065. const resolvedOptions = extend({}, options, {
  24066. prefixIdentifiers
  24067. });
  24068. const ast = isString$2(source) ? baseParse(source, resolvedOptions) : source;
  24069. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  24070. if (options.isTS) {
  24071. const { expressionPlugins } = options;
  24072. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  24073. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  24074. }
  24075. }
  24076. transform(
  24077. ast,
  24078. extend({}, resolvedOptions, {
  24079. nodeTransforms: [
  24080. ...nodeTransforms,
  24081. ...options.nodeTransforms || []
  24082. // user transforms
  24083. ],
  24084. directiveTransforms: extend(
  24085. {},
  24086. directiveTransforms,
  24087. options.directiveTransforms || {}
  24088. // user transforms
  24089. )
  24090. })
  24091. );
  24092. return generate(ast, resolvedOptions);
  24093. }
  24094. const BindingTypes = {
  24095. "DATA": "data",
  24096. "PROPS": "props",
  24097. "PROPS_ALIASED": "props-aliased",
  24098. "SETUP_LET": "setup-let",
  24099. "SETUP_CONST": "setup-const",
  24100. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  24101. "SETUP_MAYBE_REF": "setup-maybe-ref",
  24102. "SETUP_REF": "setup-ref",
  24103. "OPTIONS": "options",
  24104. "LITERAL_CONST": "literal-const"
  24105. };
  24106. const noopDirectiveTransform = () => ({ props: [] });
  24107. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  24108. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  24109. const V_MODEL_TEXT = Symbol(`vModelText` );
  24110. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  24111. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  24112. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  24113. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  24114. const V_SHOW = Symbol(`vShow` );
  24115. const TRANSITION = Symbol(`Transition` );
  24116. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  24117. registerRuntimeHelpers({
  24118. [V_MODEL_RADIO]: `vModelRadio`,
  24119. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  24120. [V_MODEL_TEXT]: `vModelText`,
  24121. [V_MODEL_SELECT]: `vModelSelect`,
  24122. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  24123. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  24124. [V_ON_WITH_KEYS]: `withKeys`,
  24125. [V_SHOW]: `vShow`,
  24126. [TRANSITION]: `Transition`,
  24127. [TRANSITION_GROUP]: `TransitionGroup`
  24128. });
  24129. const parserOptions = {
  24130. parseMode: "html",
  24131. isVoidTag,
  24132. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  24133. isPreTag: (tag) => tag === "pre",
  24134. decodeEntities: void 0,
  24135. isBuiltInComponent: (tag) => {
  24136. if (tag === "Transition" || tag === "transition") {
  24137. return TRANSITION;
  24138. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  24139. return TRANSITION_GROUP;
  24140. }
  24141. },
  24142. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  24143. getNamespace(tag, parent, rootNamespace) {
  24144. let ns = parent ? parent.ns : rootNamespace;
  24145. if (parent && ns === 2) {
  24146. if (parent.tag === "annotation-xml") {
  24147. if (tag === "svg") {
  24148. return 1;
  24149. }
  24150. if (parent.props.some(
  24151. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  24152. )) {
  24153. ns = 0;
  24154. }
  24155. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  24156. ns = 0;
  24157. }
  24158. } else if (parent && ns === 1) {
  24159. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  24160. ns = 0;
  24161. }
  24162. }
  24163. if (ns === 0) {
  24164. if (tag === "svg") {
  24165. return 1;
  24166. }
  24167. if (tag === "math") {
  24168. return 2;
  24169. }
  24170. }
  24171. return ns;
  24172. }
  24173. };
  24174. const transformStyle = (node) => {
  24175. if (node.type === 1) {
  24176. node.props.forEach((p, i) => {
  24177. if (p.type === 6 && p.name === "style" && p.value) {
  24178. node.props[i] = {
  24179. type: 7,
  24180. name: `bind`,
  24181. arg: createSimpleExpression(`style`, true, p.loc),
  24182. exp: parseInlineCSS(p.value.content, p.loc),
  24183. modifiers: [],
  24184. loc: p.loc
  24185. };
  24186. }
  24187. });
  24188. }
  24189. };
  24190. const parseInlineCSS = (cssText, loc) => {
  24191. const normalized = parseStringStyle(cssText);
  24192. return createSimpleExpression(
  24193. JSON.stringify(normalized),
  24194. false,
  24195. loc,
  24196. 3
  24197. );
  24198. };
  24199. function createDOMCompilerError(code, loc) {
  24200. return createCompilerError(
  24201. code,
  24202. loc,
  24203. DOMErrorMessages
  24204. );
  24205. }
  24206. const DOMErrorCodes = {
  24207. "X_V_HTML_NO_EXPRESSION": 53,
  24208. "53": "X_V_HTML_NO_EXPRESSION",
  24209. "X_V_HTML_WITH_CHILDREN": 54,
  24210. "54": "X_V_HTML_WITH_CHILDREN",
  24211. "X_V_TEXT_NO_EXPRESSION": 55,
  24212. "55": "X_V_TEXT_NO_EXPRESSION",
  24213. "X_V_TEXT_WITH_CHILDREN": 56,
  24214. "56": "X_V_TEXT_WITH_CHILDREN",
  24215. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  24216. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  24217. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  24218. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  24219. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  24220. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  24221. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  24222. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  24223. "X_V_SHOW_NO_EXPRESSION": 61,
  24224. "61": "X_V_SHOW_NO_EXPRESSION",
  24225. "X_TRANSITION_INVALID_CHILDREN": 62,
  24226. "62": "X_TRANSITION_INVALID_CHILDREN",
  24227. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  24228. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  24229. "__EXTEND_POINT__": 64,
  24230. "64": "__EXTEND_POINT__"
  24231. };
  24232. const DOMErrorMessages = {
  24233. [53]: `v-html is missing expression.`,
  24234. [54]: `v-html will override element children.`,
  24235. [55]: `v-text is missing expression.`,
  24236. [56]: `v-text will override element children.`,
  24237. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  24238. [58]: `v-model argument is not supported on plain elements.`,
  24239. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  24240. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  24241. [61]: `v-show is missing expression.`,
  24242. [62]: `<Transition> expects exactly one child element or component.`,
  24243. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  24244. };
  24245. const transformVHtml = (dir, node, context) => {
  24246. const { exp, loc } = dir;
  24247. if (!exp) {
  24248. context.onError(
  24249. createDOMCompilerError(53, loc)
  24250. );
  24251. }
  24252. if (node.children.length) {
  24253. context.onError(
  24254. createDOMCompilerError(54, loc)
  24255. );
  24256. node.children.length = 0;
  24257. }
  24258. return {
  24259. props: [
  24260. createObjectProperty(
  24261. createSimpleExpression(`innerHTML`, true, loc),
  24262. exp || createSimpleExpression("", true)
  24263. )
  24264. ]
  24265. };
  24266. };
  24267. const transformVText = (dir, node, context) => {
  24268. const { exp, loc } = dir;
  24269. if (!exp) {
  24270. context.onError(
  24271. createDOMCompilerError(55, loc)
  24272. );
  24273. }
  24274. if (node.children.length) {
  24275. context.onError(
  24276. createDOMCompilerError(56, loc)
  24277. );
  24278. node.children.length = 0;
  24279. }
  24280. return {
  24281. props: [
  24282. createObjectProperty(
  24283. createSimpleExpression(`textContent`, true),
  24284. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  24285. context.helperString(TO_DISPLAY_STRING),
  24286. [exp],
  24287. loc
  24288. ) : createSimpleExpression("", true)
  24289. )
  24290. ]
  24291. };
  24292. };
  24293. const transformModel = (dir, node, context) => {
  24294. const baseResult = transformModel$1(dir, node, context);
  24295. if (!baseResult.props.length || node.tagType === 1) {
  24296. return baseResult;
  24297. }
  24298. if (dir.arg) {
  24299. context.onError(
  24300. createDOMCompilerError(
  24301. 58,
  24302. dir.arg.loc
  24303. )
  24304. );
  24305. }
  24306. function checkDuplicatedValue() {
  24307. const value = findDir(node, "bind");
  24308. if (value && isStaticArgOf(value.arg, "value")) {
  24309. context.onError(
  24310. createDOMCompilerError(
  24311. 60,
  24312. value.loc
  24313. )
  24314. );
  24315. }
  24316. }
  24317. const { tag } = node;
  24318. const isCustomElement = context.isCustomElement(tag);
  24319. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  24320. let directiveToUse = V_MODEL_TEXT;
  24321. let isInvalidType = false;
  24322. if (tag === "input" || isCustomElement) {
  24323. const type = findProp(node, `type`);
  24324. if (type) {
  24325. if (type.type === 7) {
  24326. directiveToUse = V_MODEL_DYNAMIC;
  24327. } else if (type.value) {
  24328. switch (type.value.content) {
  24329. case "radio":
  24330. directiveToUse = V_MODEL_RADIO;
  24331. break;
  24332. case "checkbox":
  24333. directiveToUse = V_MODEL_CHECKBOX;
  24334. break;
  24335. case "file":
  24336. isInvalidType = true;
  24337. context.onError(
  24338. createDOMCompilerError(
  24339. 59,
  24340. dir.loc
  24341. )
  24342. );
  24343. break;
  24344. default:
  24345. checkDuplicatedValue();
  24346. break;
  24347. }
  24348. }
  24349. } else if (hasDynamicKeyVBind(node)) {
  24350. directiveToUse = V_MODEL_DYNAMIC;
  24351. } else {
  24352. checkDuplicatedValue();
  24353. }
  24354. } else if (tag === "select") {
  24355. directiveToUse = V_MODEL_SELECT;
  24356. } else {
  24357. checkDuplicatedValue();
  24358. }
  24359. if (!isInvalidType) {
  24360. baseResult.needRuntime = context.helper(directiveToUse);
  24361. }
  24362. } else {
  24363. context.onError(
  24364. createDOMCompilerError(
  24365. 57,
  24366. dir.loc
  24367. )
  24368. );
  24369. }
  24370. baseResult.props = baseResult.props.filter(
  24371. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  24372. );
  24373. return baseResult;
  24374. };
  24375. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  24376. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  24377. // event propagation management
  24378. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  24379. );
  24380. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  24381. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  24382. `onkeyup,onkeydown,onkeypress`,
  24383. true
  24384. );
  24385. const resolveModifiers = (key, modifiers, context, loc) => {
  24386. const keyModifiers = [];
  24387. const nonKeyModifiers = [];
  24388. const eventOptionModifiers = [];
  24389. for (let i = 0; i < modifiers.length; i++) {
  24390. const modifier = modifiers[i];
  24391. if (isEventOptionModifier(modifier)) {
  24392. eventOptionModifiers.push(modifier);
  24393. } else {
  24394. if (maybeKeyModifier(modifier)) {
  24395. if (isStaticExp(key)) {
  24396. if (isKeyboardEvent(key.content)) {
  24397. keyModifiers.push(modifier);
  24398. } else {
  24399. nonKeyModifiers.push(modifier);
  24400. }
  24401. } else {
  24402. keyModifiers.push(modifier);
  24403. nonKeyModifiers.push(modifier);
  24404. }
  24405. } else {
  24406. if (isNonKeyModifier(modifier)) {
  24407. nonKeyModifiers.push(modifier);
  24408. } else {
  24409. keyModifiers.push(modifier);
  24410. }
  24411. }
  24412. }
  24413. }
  24414. return {
  24415. keyModifiers,
  24416. nonKeyModifiers,
  24417. eventOptionModifiers
  24418. };
  24419. };
  24420. const transformClick = (key, event) => {
  24421. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  24422. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  24423. `(`,
  24424. key,
  24425. `) === "onClick" ? "${event}" : (`,
  24426. key,
  24427. `)`
  24428. ]) : key;
  24429. };
  24430. const transformOn = (dir, node, context) => {
  24431. return transformOn$1(dir, node, context, (baseResult) => {
  24432. const { modifiers } = dir;
  24433. if (!modifiers.length)
  24434. return baseResult;
  24435. let { key, value: handlerExp } = baseResult.props[0];
  24436. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  24437. if (nonKeyModifiers.includes("right")) {
  24438. key = transformClick(key, `onContextmenu`);
  24439. }
  24440. if (nonKeyModifiers.includes("middle")) {
  24441. key = transformClick(key, `onMouseup`);
  24442. }
  24443. if (nonKeyModifiers.length) {
  24444. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  24445. handlerExp,
  24446. JSON.stringify(nonKeyModifiers)
  24447. ]);
  24448. }
  24449. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  24450. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  24451. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  24452. handlerExp,
  24453. JSON.stringify(keyModifiers)
  24454. ]);
  24455. }
  24456. if (eventOptionModifiers.length) {
  24457. const modifierPostfix = eventOptionModifiers.map(capitalize$1).join("");
  24458. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  24459. }
  24460. return {
  24461. props: [createObjectProperty(key, handlerExp)]
  24462. };
  24463. });
  24464. };
  24465. const transformShow = (dir, node, context) => {
  24466. const { exp, loc } = dir;
  24467. if (!exp) {
  24468. context.onError(
  24469. createDOMCompilerError(61, loc)
  24470. );
  24471. }
  24472. return {
  24473. props: [],
  24474. needRuntime: context.helper(V_SHOW)
  24475. };
  24476. };
  24477. const transformTransition = (node, context) => {
  24478. if (node.type === 1 && node.tagType === 1) {
  24479. const component = context.isBuiltInComponent(node.tag);
  24480. if (component === TRANSITION) {
  24481. return () => {
  24482. if (!node.children.length) {
  24483. return;
  24484. }
  24485. if (hasMultipleChildren(node)) {
  24486. context.onError(
  24487. createDOMCompilerError(
  24488. 62,
  24489. {
  24490. start: node.children[0].loc.start,
  24491. end: node.children[node.children.length - 1].loc.end,
  24492. source: ""
  24493. }
  24494. )
  24495. );
  24496. }
  24497. const child = node.children[0];
  24498. if (child.type === 1) {
  24499. for (const p of child.props) {
  24500. if (p.type === 7 && p.name === "show") {
  24501. node.props.push({
  24502. type: 6,
  24503. name: "persisted",
  24504. nameLoc: node.loc,
  24505. value: void 0,
  24506. loc: node.loc
  24507. });
  24508. }
  24509. }
  24510. }
  24511. };
  24512. }
  24513. }
  24514. };
  24515. function hasMultipleChildren(node) {
  24516. const children = node.children = node.children.filter(
  24517. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  24518. );
  24519. const child = children[0];
  24520. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  24521. }
  24522. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  24523. const stringifyStatic = (children, context, parent) => {
  24524. if (context.scopes.vSlot > 0) {
  24525. return;
  24526. }
  24527. let nc = 0;
  24528. let ec = 0;
  24529. const currentChunk = [];
  24530. const stringifyCurrentChunk = (currentIndex) => {
  24531. if (nc >= 20 || ec >= 5) {
  24532. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  24533. JSON.stringify(
  24534. currentChunk.map((node) => stringifyNode(node, context)).join("")
  24535. ).replace(expReplaceRE, `" + $1 + "`),
  24536. // the 2nd argument indicates the number of DOM nodes this static vnode
  24537. // will insert / hydrate
  24538. String(currentChunk.length)
  24539. ]);
  24540. replaceHoist(currentChunk[0], staticCall, context);
  24541. if (currentChunk.length > 1) {
  24542. for (let i2 = 1; i2 < currentChunk.length; i2++) {
  24543. replaceHoist(currentChunk[i2], null, context);
  24544. }
  24545. const deleteCount = currentChunk.length - 1;
  24546. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  24547. return deleteCount;
  24548. }
  24549. }
  24550. return 0;
  24551. };
  24552. let i = 0;
  24553. for (; i < children.length; i++) {
  24554. const child = children[i];
  24555. const hoisted = getHoistedNode(child);
  24556. if (hoisted) {
  24557. const node = child;
  24558. const result = analyzeNode(node);
  24559. if (result) {
  24560. nc += result[0];
  24561. ec += result[1];
  24562. currentChunk.push(node);
  24563. continue;
  24564. }
  24565. }
  24566. i -= stringifyCurrentChunk(i);
  24567. nc = 0;
  24568. ec = 0;
  24569. currentChunk.length = 0;
  24570. }
  24571. stringifyCurrentChunk(i);
  24572. };
  24573. const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
  24574. const dataAriaRE = /^(data|aria)-/;
  24575. const isStringifiableAttr = (name, ns) => {
  24576. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
  24577. };
  24578. const replaceHoist = (node, replacement, context) => {
  24579. const hoistToReplace = node.codegenNode.hoisted;
  24580. context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
  24581. };
  24582. const isNonStringifiable = /* @__PURE__ */ makeMap(
  24583. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  24584. );
  24585. function analyzeNode(node) {
  24586. if (node.type === 1 && isNonStringifiable(node.tag)) {
  24587. return false;
  24588. }
  24589. if (node.type === 12) {
  24590. return [1, 0];
  24591. }
  24592. let nc = 1;
  24593. let ec = node.props.length > 0 ? 1 : 0;
  24594. let bailed = false;
  24595. const bail = () => {
  24596. bailed = true;
  24597. return false;
  24598. };
  24599. function walk(node2) {
  24600. for (let i = 0; i < node2.props.length; i++) {
  24601. const p = node2.props[i];
  24602. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  24603. return bail();
  24604. }
  24605. if (p.type === 7 && p.name === "bind") {
  24606. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  24607. return bail();
  24608. }
  24609. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  24610. return bail();
  24611. }
  24612. }
  24613. }
  24614. for (let i = 0; i < node2.children.length; i++) {
  24615. nc++;
  24616. const child = node2.children[i];
  24617. if (child.type === 1) {
  24618. if (child.props.length > 0) {
  24619. ec++;
  24620. }
  24621. walk(child);
  24622. if (bailed) {
  24623. return false;
  24624. }
  24625. }
  24626. }
  24627. return true;
  24628. }
  24629. return walk(node) ? [nc, ec] : false;
  24630. }
  24631. function stringifyNode(node, context) {
  24632. if (isString$2(node)) {
  24633. return node;
  24634. }
  24635. if (isSymbol$1(node)) {
  24636. return ``;
  24637. }
  24638. switch (node.type) {
  24639. case 1:
  24640. return stringifyElement(node, context);
  24641. case 2:
  24642. return escapeHtml(node.content);
  24643. case 3:
  24644. return `<!--${escapeHtml(node.content)}-->`;
  24645. case 5:
  24646. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  24647. case 8:
  24648. return escapeHtml(evaluateConstant(node));
  24649. case 12:
  24650. return stringifyNode(node.content, context);
  24651. default:
  24652. return "";
  24653. }
  24654. }
  24655. function stringifyElement(node, context) {
  24656. let res = `<${node.tag}`;
  24657. let innerHTML = "";
  24658. for (let i = 0; i < node.props.length; i++) {
  24659. const p = node.props[i];
  24660. if (p.type === 6) {
  24661. res += ` ${p.name}`;
  24662. if (p.value) {
  24663. res += `="${escapeHtml(p.value.content)}"`;
  24664. }
  24665. } else if (p.type === 7) {
  24666. if (p.name === "bind") {
  24667. const exp = p.exp;
  24668. if (exp.content[0] === "_") {
  24669. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  24670. continue;
  24671. }
  24672. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  24673. continue;
  24674. }
  24675. let evaluated = evaluateConstant(exp);
  24676. if (evaluated != null) {
  24677. const arg = p.arg && p.arg.content;
  24678. if (arg === "class") {
  24679. evaluated = normalizeClass(evaluated);
  24680. } else if (arg === "style") {
  24681. evaluated = stringifyStyle(normalizeStyle(evaluated));
  24682. }
  24683. res += ` ${p.arg.content}="${escapeHtml(
  24684. evaluated
  24685. )}"`;
  24686. }
  24687. } else if (p.name === "html") {
  24688. innerHTML = evaluateConstant(p.exp);
  24689. } else if (p.name === "text") {
  24690. innerHTML = escapeHtml(
  24691. toDisplayString(evaluateConstant(p.exp))
  24692. );
  24693. }
  24694. }
  24695. }
  24696. if (context.scopeId) {
  24697. res += ` ${context.scopeId}`;
  24698. }
  24699. res += `>`;
  24700. if (innerHTML) {
  24701. res += innerHTML;
  24702. } else {
  24703. for (let i = 0; i < node.children.length; i++) {
  24704. res += stringifyNode(node.children[i], context);
  24705. }
  24706. }
  24707. if (!isVoidTag(node.tag)) {
  24708. res += `</${node.tag}>`;
  24709. }
  24710. return res;
  24711. }
  24712. function evaluateConstant(exp) {
  24713. if (exp.type === 4) {
  24714. return new Function(`return (${exp.content})`)();
  24715. } else {
  24716. let res = ``;
  24717. exp.children.forEach((c) => {
  24718. if (isString$2(c) || isSymbol$1(c)) {
  24719. return;
  24720. }
  24721. if (c.type === 2) {
  24722. res += c.content;
  24723. } else if (c.type === 5) {
  24724. res += toDisplayString(evaluateConstant(c.content));
  24725. } else {
  24726. res += evaluateConstant(c);
  24727. }
  24728. });
  24729. return res;
  24730. }
  24731. }
  24732. const ignoreSideEffectTags = (node, context) => {
  24733. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  24734. context.onError(
  24735. createDOMCompilerError(
  24736. 63,
  24737. node.loc
  24738. )
  24739. );
  24740. context.removeNode();
  24741. }
  24742. };
  24743. const DOMNodeTransforms = [
  24744. transformStyle,
  24745. ...[transformTransition]
  24746. ];
  24747. const DOMDirectiveTransforms = {
  24748. cloak: noopDirectiveTransform,
  24749. html: transformVHtml,
  24750. text: transformVText,
  24751. model: transformModel,
  24752. // override compiler-core
  24753. on: transformOn,
  24754. // override compiler-core
  24755. show: transformShow
  24756. };
  24757. function compile$1(src, options = {}) {
  24758. return baseCompile(
  24759. src,
  24760. extend({}, parserOptions, options, {
  24761. nodeTransforms: [
  24762. // ignore <script> and <tag>
  24763. // this is not put inside DOMNodeTransforms because that list is used
  24764. // by compiler-ssr to generate vnode fallback branches
  24765. ignoreSideEffectTags,
  24766. ...DOMNodeTransforms,
  24767. ...options.nodeTransforms || []
  24768. ],
  24769. directiveTransforms: extend(
  24770. {},
  24771. DOMDirectiveTransforms,
  24772. options.directiveTransforms || {}
  24773. ),
  24774. transformHoist: stringifyStatic
  24775. })
  24776. );
  24777. }
  24778. function parse$8(template, options = {}) {
  24779. return baseParse(template, extend({}, parserOptions, options));
  24780. }
  24781. var CompilerDOM = /*#__PURE__*/Object.freeze({
  24782. __proto__: null,
  24783. BASE_TRANSITION: BASE_TRANSITION,
  24784. BindingTypes: BindingTypes,
  24785. CAMELIZE: CAMELIZE,
  24786. CAPITALIZE: CAPITALIZE,
  24787. CREATE_BLOCK: CREATE_BLOCK,
  24788. CREATE_COMMENT: CREATE_COMMENT,
  24789. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  24790. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  24791. CREATE_SLOTS: CREATE_SLOTS,
  24792. CREATE_STATIC: CREATE_STATIC,
  24793. CREATE_TEXT: CREATE_TEXT,
  24794. CREATE_VNODE: CREATE_VNODE,
  24795. CompilerDeprecationTypes: CompilerDeprecationTypes,
  24796. ConstantTypes: ConstantTypes,
  24797. DOMDirectiveTransforms: DOMDirectiveTransforms,
  24798. DOMErrorCodes: DOMErrorCodes,
  24799. DOMErrorMessages: DOMErrorMessages,
  24800. DOMNodeTransforms: DOMNodeTransforms,
  24801. ElementTypes: ElementTypes,
  24802. ErrorCodes: ErrorCodes,
  24803. FRAGMENT: FRAGMENT,
  24804. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  24805. IS_MEMO_SAME: IS_MEMO_SAME,
  24806. IS_REF: IS_REF,
  24807. KEEP_ALIVE: KEEP_ALIVE,
  24808. MERGE_PROPS: MERGE_PROPS,
  24809. NORMALIZE_CLASS: NORMALIZE_CLASS,
  24810. NORMALIZE_PROPS: NORMALIZE_PROPS,
  24811. NORMALIZE_STYLE: NORMALIZE_STYLE,
  24812. Namespaces: Namespaces,
  24813. NodeTypes: NodeTypes,
  24814. OPEN_BLOCK: OPEN_BLOCK,
  24815. POP_SCOPE_ID: POP_SCOPE_ID,
  24816. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  24817. RENDER_LIST: RENDER_LIST,
  24818. RENDER_SLOT: RENDER_SLOT,
  24819. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  24820. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  24821. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  24822. RESOLVE_FILTER: RESOLVE_FILTER,
  24823. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  24824. SUSPENSE: SUSPENSE,
  24825. TELEPORT: TELEPORT,
  24826. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  24827. TO_HANDLERS: TO_HANDLERS,
  24828. TO_HANDLER_KEY: TO_HANDLER_KEY,
  24829. TRANSITION: TRANSITION,
  24830. TRANSITION_GROUP: TRANSITION_GROUP,
  24831. TS_NODE_TYPES: TS_NODE_TYPES,
  24832. UNREF: UNREF,
  24833. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  24834. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  24835. V_MODEL_RADIO: V_MODEL_RADIO,
  24836. V_MODEL_SELECT: V_MODEL_SELECT,
  24837. V_MODEL_TEXT: V_MODEL_TEXT,
  24838. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  24839. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  24840. V_SHOW: V_SHOW,
  24841. WITH_CTX: WITH_CTX,
  24842. WITH_DIRECTIVES: WITH_DIRECTIVES,
  24843. WITH_MEMO: WITH_MEMO,
  24844. advancePositionWithClone: advancePositionWithClone,
  24845. advancePositionWithMutation: advancePositionWithMutation,
  24846. assert: assert,
  24847. baseCompile: baseCompile,
  24848. baseParse: baseParse,
  24849. buildDirectiveArgs: buildDirectiveArgs,
  24850. buildProps: buildProps,
  24851. buildSlots: buildSlots,
  24852. checkCompatEnabled: checkCompatEnabled,
  24853. compile: compile$1,
  24854. convertToBlock: convertToBlock,
  24855. createArrayExpression: createArrayExpression,
  24856. createAssignmentExpression: createAssignmentExpression,
  24857. createBlockStatement: createBlockStatement,
  24858. createCacheExpression: createCacheExpression,
  24859. createCallExpression: createCallExpression,
  24860. createCompilerError: createCompilerError,
  24861. createCompoundExpression: createCompoundExpression,
  24862. createConditionalExpression: createConditionalExpression,
  24863. createDOMCompilerError: createDOMCompilerError,
  24864. createForLoopParams: createForLoopParams,
  24865. createFunctionExpression: createFunctionExpression,
  24866. createIfStatement: createIfStatement,
  24867. createInterpolation: createInterpolation,
  24868. createObjectExpression: createObjectExpression,
  24869. createObjectProperty: createObjectProperty,
  24870. createReturnStatement: createReturnStatement,
  24871. createRoot: createRoot,
  24872. createSequenceExpression: createSequenceExpression,
  24873. createSimpleExpression: createSimpleExpression,
  24874. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  24875. createTemplateLiteral: createTemplateLiteral,
  24876. createTransformContext: createTransformContext,
  24877. createVNodeCall: createVNodeCall,
  24878. errorMessages: errorMessages$1,
  24879. extractIdentifiers: extractIdentifiers$1,
  24880. findDir: findDir,
  24881. findProp: findProp,
  24882. forAliasRE: forAliasRE,
  24883. generate: generate,
  24884. generateCodeFrame: generateCodeFrame,
  24885. getBaseTransformPreset: getBaseTransformPreset,
  24886. getConstantType: getConstantType,
  24887. getMemoedVNodeCall: getMemoedVNodeCall,
  24888. getVNodeBlockHelper: getVNodeBlockHelper,
  24889. getVNodeHelper: getVNodeHelper,
  24890. hasDynamicKeyVBind: hasDynamicKeyVBind,
  24891. hasScopeRef: hasScopeRef,
  24892. helperNameMap: helperNameMap,
  24893. injectProp: injectProp,
  24894. isCoreComponent: isCoreComponent,
  24895. isFunctionType: isFunctionType,
  24896. isInDestructureAssignment: isInDestructureAssignment,
  24897. isInNewExpression: isInNewExpression,
  24898. isMemberExpression: isMemberExpression,
  24899. isMemberExpressionBrowser: isMemberExpressionBrowser,
  24900. isMemberExpressionNode: isMemberExpressionNode,
  24901. isReferencedIdentifier: isReferencedIdentifier,
  24902. isSimpleIdentifier: isSimpleIdentifier,
  24903. isSlotOutlet: isSlotOutlet,
  24904. isStaticArgOf: isStaticArgOf,
  24905. isStaticExp: isStaticExp,
  24906. isStaticProperty: isStaticProperty,
  24907. isStaticPropertyKey: isStaticPropertyKey,
  24908. isTemplateNode: isTemplateNode,
  24909. isText: isText$1,
  24910. isVSlot: isVSlot,
  24911. locStub: locStub,
  24912. noopDirectiveTransform: noopDirectiveTransform,
  24913. parse: parse$8,
  24914. parserOptions: parserOptions,
  24915. processExpression: processExpression,
  24916. processFor: processFor,
  24917. processIf: processIf,
  24918. processSlotOutlet: processSlotOutlet,
  24919. registerRuntimeHelpers: registerRuntimeHelpers,
  24920. resolveComponentType: resolveComponentType,
  24921. stringifyExpression: stringifyExpression,
  24922. toValidAssetId: toValidAssetId,
  24923. trackSlotScopes: trackSlotScopes,
  24924. trackVForSlotScopes: trackVForSlotScopes,
  24925. transform: transform,
  24926. transformBind: transformBind,
  24927. transformElement: transformElement,
  24928. transformExpression: transformExpression,
  24929. transformModel: transformModel$1,
  24930. transformOn: transformOn$1,
  24931. transformStyle: transformStyle,
  24932. traverseNode: traverseNode,
  24933. unwrapTSNode: unwrapTSNode,
  24934. walkBlockDeclarations: walkBlockDeclarations,
  24935. walkFunctionParams: walkFunctionParams,
  24936. walkIdentifiers: walkIdentifiers,
  24937. warnDeprecation: warnDeprecation
  24938. });
  24939. // Copyright Joyent, Inc. and other Node contributors.
  24940. //
  24941. // Permission is hereby granted, free of charge, to any person obtaining a
  24942. // copy of this software and associated documentation files (the
  24943. // "Software"), to deal in the Software without restriction, including
  24944. // without limitation the rights to use, copy, modify, merge, publish,
  24945. // distribute, sublicense, and/or sell copies of the Software, and to permit
  24946. // persons to whom the Software is furnished to do so, subject to the
  24947. // following conditions:
  24948. //
  24949. // The above copyright notice and this permission notice shall be included
  24950. // in all copies or substantial portions of the Software.
  24951. //
  24952. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24953. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24954. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  24955. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24956. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24957. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24958. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  24959. // resolves . and .. elements in a path array with directory names there
  24960. // must be no slashes, empty elements, or device names (c:\) in the array
  24961. // (so also no leading and trailing slashes - it does not distinguish
  24962. // relative and absolute paths)
  24963. function normalizeArray(parts, allowAboveRoot) {
  24964. // if the path tries to go above the root, `up` ends up > 0
  24965. var up = 0;
  24966. for (var i = parts.length - 1; i >= 0; i--) {
  24967. var last = parts[i];
  24968. if (last === '.') {
  24969. parts.splice(i, 1);
  24970. } else if (last === '..') {
  24971. parts.splice(i, 1);
  24972. up++;
  24973. } else if (up) {
  24974. parts.splice(i, 1);
  24975. up--;
  24976. }
  24977. }
  24978. // if the path is allowed to go above the root, restore leading ..s
  24979. if (allowAboveRoot) {
  24980. for (; up--; up) {
  24981. parts.unshift('..');
  24982. }
  24983. }
  24984. return parts;
  24985. }
  24986. // Split a filename into [root, dir, basename, ext], unix version
  24987. // 'root' is just a slash, or nothing.
  24988. var splitPathRe =
  24989. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  24990. var splitPath = function(filename) {
  24991. return splitPathRe.exec(filename).slice(1);
  24992. };
  24993. // path.resolve([from ...], to)
  24994. // posix version
  24995. function resolve$2() {
  24996. var resolvedPath = '',
  24997. resolvedAbsolute = false;
  24998. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  24999. var path = (i >= 0) ? arguments[i] : '/';
  25000. // Skip empty and invalid entries
  25001. if (typeof path !== 'string') {
  25002. throw new TypeError('Arguments to path.resolve must be strings');
  25003. } else if (!path) {
  25004. continue;
  25005. }
  25006. resolvedPath = path + '/' + resolvedPath;
  25007. resolvedAbsolute = path.charAt(0) === '/';
  25008. }
  25009. // At this point the path should be resolved to a full absolute path, but
  25010. // handle relative paths to be safe (might happen when process.cwd() fails)
  25011. // Normalize the path
  25012. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  25013. return !!p;
  25014. }), !resolvedAbsolute).join('/');
  25015. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  25016. }
  25017. // path.normalize(path)
  25018. // posix version
  25019. function normalize$1(path) {
  25020. var isPathAbsolute = isAbsolute$1(path),
  25021. trailingSlash = substr(path, -1) === '/';
  25022. // Normalize the path
  25023. path = normalizeArray(filter(path.split('/'), function(p) {
  25024. return !!p;
  25025. }), !isPathAbsolute).join('/');
  25026. if (!path && !isPathAbsolute) {
  25027. path = '.';
  25028. }
  25029. if (path && trailingSlash) {
  25030. path += '/';
  25031. }
  25032. return (isPathAbsolute ? '/' : '') + path;
  25033. }
  25034. // posix version
  25035. function isAbsolute$1(path) {
  25036. return path.charAt(0) === '/';
  25037. }
  25038. // posix version
  25039. function join$1() {
  25040. var paths = Array.prototype.slice.call(arguments, 0);
  25041. return normalize$1(filter(paths, function(p, index) {
  25042. if (typeof p !== 'string') {
  25043. throw new TypeError('Arguments to path.join must be strings');
  25044. }
  25045. return p;
  25046. }).join('/'));
  25047. }
  25048. // path.relative(from, to)
  25049. // posix version
  25050. function relative$1(from, to) {
  25051. from = resolve$2(from).substr(1);
  25052. to = resolve$2(to).substr(1);
  25053. function trim(arr) {
  25054. var start = 0;
  25055. for (; start < arr.length; start++) {
  25056. if (arr[start] !== '') break;
  25057. }
  25058. var end = arr.length - 1;
  25059. for (; end >= 0; end--) {
  25060. if (arr[end] !== '') break;
  25061. }
  25062. if (start > end) return [];
  25063. return arr.slice(start, end - start + 1);
  25064. }
  25065. var fromParts = trim(from.split('/'));
  25066. var toParts = trim(to.split('/'));
  25067. var length = Math.min(fromParts.length, toParts.length);
  25068. var samePartsLength = length;
  25069. for (var i = 0; i < length; i++) {
  25070. if (fromParts[i] !== toParts[i]) {
  25071. samePartsLength = i;
  25072. break;
  25073. }
  25074. }
  25075. var outputParts = [];
  25076. for (var i = samePartsLength; i < fromParts.length; i++) {
  25077. outputParts.push('..');
  25078. }
  25079. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  25080. return outputParts.join('/');
  25081. }
  25082. var sep$1 = '/';
  25083. var delimiter$1 = ':';
  25084. function dirname$2(path) {
  25085. var result = splitPath(path),
  25086. root = result[0],
  25087. dir = result[1];
  25088. if (!root && !dir) {
  25089. // No dirname whatsoever
  25090. return '.';
  25091. }
  25092. if (dir) {
  25093. // It has a dirname, strip trailing slash
  25094. dir = dir.substr(0, dir.length - 1);
  25095. }
  25096. return root + dir;
  25097. }
  25098. function basename(path, ext) {
  25099. var f = splitPath(path)[2];
  25100. // TODO: make this comparison case-insensitive on windows?
  25101. if (ext && f.substr(-1 * ext.length) === ext) {
  25102. f = f.substr(0, f.length - ext.length);
  25103. }
  25104. return f;
  25105. }
  25106. function extname(path) {
  25107. return splitPath(path)[3];
  25108. }
  25109. var path = {
  25110. extname: extname,
  25111. basename: basename,
  25112. dirname: dirname$2,
  25113. sep: sep$1,
  25114. delimiter: delimiter$1,
  25115. relative: relative$1,
  25116. join: join$1,
  25117. isAbsolute: isAbsolute$1,
  25118. normalize: normalize$1,
  25119. resolve: resolve$2
  25120. };
  25121. function filter (xs, f) {
  25122. if (xs.filter) return xs.filter(f);
  25123. var res = [];
  25124. for (var i = 0; i < xs.length; i++) {
  25125. if (f(xs[i], i, xs)) res.push(xs[i]);
  25126. }
  25127. return res;
  25128. }
  25129. // String.prototype.substr - negative index don't work in IE8
  25130. var substr = 'ab'.substr(-1) === 'b' ?
  25131. function (str, start, len) { return str.substr(start, len) } :
  25132. function (str, start, len) {
  25133. if (start < 0) start = str.length + start;
  25134. return str.substr(start, len);
  25135. }
  25136. ;
  25137. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  25138. __proto__: null,
  25139. basename: basename,
  25140. default: path,
  25141. delimiter: delimiter$1,
  25142. dirname: dirname$2,
  25143. extname: extname,
  25144. isAbsolute: isAbsolute$1,
  25145. join: join$1,
  25146. normalize: normalize$1,
  25147. relative: relative$1,
  25148. resolve: resolve$2,
  25149. sep: sep$1
  25150. });
  25151. const UNKNOWN_TYPE = "Unknown";
  25152. function resolveObjectKey(node, computed) {
  25153. switch (node.type) {
  25154. case "StringLiteral":
  25155. case "NumericLiteral":
  25156. return String(node.value);
  25157. case "Identifier":
  25158. if (!computed)
  25159. return node.name;
  25160. }
  25161. return void 0;
  25162. }
  25163. function concatStrings(strs) {
  25164. return strs.filter((s) => !!s).join(", ");
  25165. }
  25166. function isLiteralNode(node) {
  25167. return node.type.endsWith("Literal");
  25168. }
  25169. function isCallOf(node, test) {
  25170. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  25171. }
  25172. function toRuntimeTypeString(types) {
  25173. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  25174. }
  25175. function getImportedName(specifier) {
  25176. if (specifier.type === "ImportSpecifier")
  25177. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  25178. else if (specifier.type === "ImportNamespaceSpecifier")
  25179. return "*";
  25180. return "default";
  25181. }
  25182. function getId(node) {
  25183. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  25184. }
  25185. const normalize = (path.posix || path).normalize;
  25186. const windowsSlashRE = /\\/g;
  25187. function normalizePath(p) {
  25188. return normalize(p.replace(windowsSlashRE, "/"));
  25189. }
  25190. const joinPaths = (path.posix || path).join;
  25191. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  25192. function getEscapedPropName(key) {
  25193. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  25194. }
  25195. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  25196. function getEscapedCssVarName(key, doubleEscape) {
  25197. return key.replace(
  25198. cssVarNameEscapeSymbolsRE,
  25199. (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
  25200. );
  25201. }
  25202. function pad$1 (hash, len) {
  25203. while (hash.length < len) {
  25204. hash = '0' + hash;
  25205. }
  25206. return hash;
  25207. }
  25208. function fold (hash, text) {
  25209. var i;
  25210. var chr;
  25211. var len;
  25212. if (text.length === 0) {
  25213. return hash;
  25214. }
  25215. for (i = 0, len = text.length; i < len; i++) {
  25216. chr = text.charCodeAt(i);
  25217. hash = ((hash << 5) - hash) + chr;
  25218. hash |= 0;
  25219. }
  25220. return hash < 0 ? hash * -2 : hash;
  25221. }
  25222. function foldObject (hash, o, seen) {
  25223. return Object.keys(o).sort().reduce(foldKey, hash);
  25224. function foldKey (hash, key) {
  25225. return foldValue(hash, o[key], key, seen);
  25226. }
  25227. }
  25228. function foldValue (input, value, key, seen) {
  25229. var hash = fold(fold(fold(input, key), toString$2(value)), typeof value);
  25230. if (value === null) {
  25231. return fold(hash, 'null');
  25232. }
  25233. if (value === undefined) {
  25234. return fold(hash, 'undefined');
  25235. }
  25236. if (typeof value === 'object' || typeof value === 'function') {
  25237. if (seen.indexOf(value) !== -1) {
  25238. return fold(hash, '[Circular]' + key);
  25239. }
  25240. seen.push(value);
  25241. var objHash = foldObject(hash, value, seen);
  25242. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  25243. return objHash;
  25244. }
  25245. try {
  25246. return fold(objHash, String(value.valueOf()))
  25247. } catch (err) {
  25248. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  25249. }
  25250. }
  25251. return fold(hash, value.toString());
  25252. }
  25253. function toString$2 (o) {
  25254. return Object.prototype.toString.call(o);
  25255. }
  25256. function sum (o) {
  25257. return pad$1(foldValue(0, o, '', []).toString(16), 8);
  25258. }
  25259. var hashSum = sum;
  25260. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSum);
  25261. const CSS_VARS_HELPER = `useCssVars`;
  25262. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  25263. return `{
  25264. ${vars.map(
  25265. (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  25266. ).join(",\n ")}
  25267. }`;
  25268. }
  25269. function genVarName(id, raw, isProd, isSSR = false) {
  25270. if (isProd) {
  25271. return hash(id + raw);
  25272. } else {
  25273. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  25274. }
  25275. }
  25276. function normalizeExpression(exp) {
  25277. exp = exp.trim();
  25278. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  25279. return exp.slice(1, -1);
  25280. }
  25281. return exp;
  25282. }
  25283. const vBindRE = /v-bind\s*\(/g;
  25284. function parseCssVars(sfc) {
  25285. const vars = [];
  25286. sfc.styles.forEach((style) => {
  25287. let match;
  25288. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  25289. while (match = vBindRE.exec(content)) {
  25290. const start = match.index + match[0].length;
  25291. const end = lexBinding(content, start);
  25292. if (end !== null) {
  25293. const variable = normalizeExpression(content.slice(start, end));
  25294. if (!vars.includes(variable)) {
  25295. vars.push(variable);
  25296. }
  25297. }
  25298. }
  25299. });
  25300. return vars;
  25301. }
  25302. function lexBinding(content, start) {
  25303. let state = 0 /* inParens */;
  25304. let parenDepth = 0;
  25305. for (let i = start; i < content.length; i++) {
  25306. const char = content.charAt(i);
  25307. switch (state) {
  25308. case 0 /* inParens */:
  25309. if (char === `'`) {
  25310. state = 1 /* inSingleQuoteString */;
  25311. } else if (char === `"`) {
  25312. state = 2 /* inDoubleQuoteString */;
  25313. } else if (char === `(`) {
  25314. parenDepth++;
  25315. } else if (char === `)`) {
  25316. if (parenDepth > 0) {
  25317. parenDepth--;
  25318. } else {
  25319. return i;
  25320. }
  25321. }
  25322. break;
  25323. case 1 /* inSingleQuoteString */:
  25324. if (char === `'`) {
  25325. state = 0 /* inParens */;
  25326. }
  25327. break;
  25328. case 2 /* inDoubleQuoteString */:
  25329. if (char === `"`) {
  25330. state = 0 /* inParens */;
  25331. }
  25332. break;
  25333. }
  25334. }
  25335. return null;
  25336. }
  25337. const cssVarsPlugin = (opts) => {
  25338. const { id, isProd } = opts;
  25339. return {
  25340. postcssPlugin: "vue-sfc-vars",
  25341. Declaration(decl) {
  25342. const value = decl.value;
  25343. if (vBindRE.test(value)) {
  25344. vBindRE.lastIndex = 0;
  25345. let transformed = "";
  25346. let lastIndex = 0;
  25347. let match;
  25348. while (match = vBindRE.exec(value)) {
  25349. const start = match.index + match[0].length;
  25350. const end = lexBinding(value, start);
  25351. if (end !== null) {
  25352. const variable = normalizeExpression(value.slice(start, end));
  25353. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  25354. lastIndex = end + 1;
  25355. }
  25356. }
  25357. decl.value = transformed + value.slice(lastIndex);
  25358. }
  25359. }
  25360. };
  25361. };
  25362. cssVarsPlugin.postcss = true;
  25363. function genCssVarsCode(vars, bindings, id, isProd) {
  25364. const varsExp = genCssVarsFromList(vars, id, isProd);
  25365. const exp = createSimpleExpression(varsExp, false);
  25366. const context = createTransformContext(createRoot([]), {
  25367. prefixIdentifiers: true,
  25368. inline: true,
  25369. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  25370. });
  25371. const transformed = processExpression(exp, context);
  25372. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  25373. return typeof c === "string" ? c : c.content;
  25374. }).join("");
  25375. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  25376. }
  25377. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  25378. return `
  25379. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  25380. const __injectCSSVars__ = () => {
  25381. ${genCssVarsCode(
  25382. cssVars,
  25383. bindings,
  25384. id,
  25385. isProd
  25386. )}}
  25387. const __setup__ = ${defaultVar}.setup
  25388. ${defaultVar}.setup = __setup__
  25389. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  25390. : __injectCSSVars__
  25391. `;
  25392. }
  25393. var global$1 = (typeof global !== "undefined" ? global :
  25394. typeof self !== "undefined" ? self :
  25395. typeof window !== "undefined" ? window : {});
  25396. // shim for using process in browser
  25397. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  25398. function defaultSetTimout() {
  25399. throw new Error('setTimeout has not been defined');
  25400. }
  25401. function defaultClearTimeout () {
  25402. throw new Error('clearTimeout has not been defined');
  25403. }
  25404. var cachedSetTimeout = defaultSetTimout;
  25405. var cachedClearTimeout = defaultClearTimeout;
  25406. if (typeof global$1.setTimeout === 'function') {
  25407. cachedSetTimeout = setTimeout;
  25408. }
  25409. if (typeof global$1.clearTimeout === 'function') {
  25410. cachedClearTimeout = clearTimeout;
  25411. }
  25412. function runTimeout(fun) {
  25413. if (cachedSetTimeout === setTimeout) {
  25414. //normal enviroments in sane situations
  25415. return setTimeout(fun, 0);
  25416. }
  25417. // if setTimeout wasn't available but was latter defined
  25418. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  25419. cachedSetTimeout = setTimeout;
  25420. return setTimeout(fun, 0);
  25421. }
  25422. try {
  25423. // when when somebody has screwed with setTimeout but no I.E. maddness
  25424. return cachedSetTimeout(fun, 0);
  25425. } catch(e){
  25426. try {
  25427. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25428. return cachedSetTimeout.call(null, fun, 0);
  25429. } catch(e){
  25430. // 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
  25431. return cachedSetTimeout.call(this, fun, 0);
  25432. }
  25433. }
  25434. }
  25435. function runClearTimeout(marker) {
  25436. if (cachedClearTimeout === clearTimeout) {
  25437. //normal enviroments in sane situations
  25438. return clearTimeout(marker);
  25439. }
  25440. // if clearTimeout wasn't available but was latter defined
  25441. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  25442. cachedClearTimeout = clearTimeout;
  25443. return clearTimeout(marker);
  25444. }
  25445. try {
  25446. // when when somebody has screwed with setTimeout but no I.E. maddness
  25447. return cachedClearTimeout(marker);
  25448. } catch (e){
  25449. try {
  25450. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25451. return cachedClearTimeout.call(null, marker);
  25452. } catch (e){
  25453. // 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.
  25454. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  25455. return cachedClearTimeout.call(this, marker);
  25456. }
  25457. }
  25458. }
  25459. var queue = [];
  25460. var draining = false;
  25461. var currentQueue;
  25462. var queueIndex = -1;
  25463. function cleanUpNextTick() {
  25464. if (!draining || !currentQueue) {
  25465. return;
  25466. }
  25467. draining = false;
  25468. if (currentQueue.length) {
  25469. queue = currentQueue.concat(queue);
  25470. } else {
  25471. queueIndex = -1;
  25472. }
  25473. if (queue.length) {
  25474. drainQueue();
  25475. }
  25476. }
  25477. function drainQueue() {
  25478. if (draining) {
  25479. return;
  25480. }
  25481. var timeout = runTimeout(cleanUpNextTick);
  25482. draining = true;
  25483. var len = queue.length;
  25484. while(len) {
  25485. currentQueue = queue;
  25486. queue = [];
  25487. while (++queueIndex < len) {
  25488. if (currentQueue) {
  25489. currentQueue[queueIndex].run();
  25490. }
  25491. }
  25492. queueIndex = -1;
  25493. len = queue.length;
  25494. }
  25495. currentQueue = null;
  25496. draining = false;
  25497. runClearTimeout(timeout);
  25498. }
  25499. function nextTick(fun) {
  25500. var args = new Array(arguments.length - 1);
  25501. if (arguments.length > 1) {
  25502. for (var i = 1; i < arguments.length; i++) {
  25503. args[i - 1] = arguments[i];
  25504. }
  25505. }
  25506. queue.push(new Item(fun, args));
  25507. if (queue.length === 1 && !draining) {
  25508. runTimeout(drainQueue);
  25509. }
  25510. }
  25511. // v8 likes predictible objects
  25512. function Item(fun, array) {
  25513. this.fun = fun;
  25514. this.array = array;
  25515. }
  25516. Item.prototype.run = function () {
  25517. this.fun.apply(null, this.array);
  25518. };
  25519. var title = 'browser';
  25520. var platform = 'browser';
  25521. var browser = true;
  25522. var env = {};
  25523. var argv = [];
  25524. var version$1 = ''; // empty string to avoid regexp issues
  25525. var versions = {};
  25526. var release = {};
  25527. var config = {};
  25528. function noop() {}
  25529. var on = noop;
  25530. var addListener = noop;
  25531. var once = noop;
  25532. var off = noop;
  25533. var removeListener = noop;
  25534. var removeAllListeners = noop;
  25535. var emit = noop;
  25536. function binding(name) {
  25537. throw new Error('process.binding is not supported');
  25538. }
  25539. function cwd () { return '/' }
  25540. function chdir (dir) {
  25541. throw new Error('process.chdir is not supported');
  25542. }function umask() { return 0; }
  25543. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  25544. var performance = global$1.performance || {};
  25545. var performanceNow =
  25546. performance.now ||
  25547. performance.mozNow ||
  25548. performance.msNow ||
  25549. performance.oNow ||
  25550. performance.webkitNow ||
  25551. function(){ return (new Date()).getTime() };
  25552. // generate timestamp or delta
  25553. // see http://nodejs.org/api/process.html#process_process_hrtime
  25554. function hrtime(previousTimestamp){
  25555. var clocktime = performanceNow.call(performance)*1e-3;
  25556. var seconds = Math.floor(clocktime);
  25557. var nanoseconds = Math.floor((clocktime%1)*1e9);
  25558. if (previousTimestamp) {
  25559. seconds = seconds - previousTimestamp[0];
  25560. nanoseconds = nanoseconds - previousTimestamp[1];
  25561. if (nanoseconds<0) {
  25562. seconds--;
  25563. nanoseconds += 1e9;
  25564. }
  25565. }
  25566. return [seconds,nanoseconds]
  25567. }
  25568. var startTime = new Date();
  25569. function uptime() {
  25570. var currentTime = new Date();
  25571. var dif = currentTime - startTime;
  25572. return dif / 1000;
  25573. }
  25574. var browser$1 = {
  25575. nextTick: nextTick,
  25576. title: title,
  25577. browser: browser,
  25578. env: env,
  25579. argv: argv,
  25580. version: version$1,
  25581. versions: versions,
  25582. on: on,
  25583. addListener: addListener,
  25584. once: once,
  25585. off: off,
  25586. removeListener: removeListener,
  25587. removeAllListeners: removeAllListeners,
  25588. emit: emit,
  25589. binding: binding,
  25590. cwd: cwd,
  25591. chdir: chdir,
  25592. umask: umask,
  25593. hrtime: hrtime,
  25594. platform: platform,
  25595. release: release,
  25596. config: config,
  25597. uptime: uptime
  25598. };
  25599. function createCache(max = 500) {
  25600. {
  25601. return /* @__PURE__ */ new Map();
  25602. }
  25603. }
  25604. function isImportUsed(local, sfc) {
  25605. return resolveTemplateUsedIdentifiers(sfc).has(local);
  25606. }
  25607. const templateUsageCheckCache = createCache();
  25608. function resolveTemplateUsedIdentifiers(sfc) {
  25609. const { content, ast } = sfc.template;
  25610. const cached = templateUsageCheckCache.get(content);
  25611. if (cached) {
  25612. return cached;
  25613. }
  25614. const ids = /* @__PURE__ */ new Set();
  25615. ast.children.forEach(walk);
  25616. function walk(node) {
  25617. var _a;
  25618. switch (node.type) {
  25619. case 1:
  25620. let tag = node.tag;
  25621. if (tag.includes("."))
  25622. tag = tag.split(".")[0].trim();
  25623. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  25624. ids.add(camelize(tag));
  25625. ids.add(capitalize$1(camelize(tag)));
  25626. }
  25627. for (let i = 0; i < node.props.length; i++) {
  25628. const prop = node.props[i];
  25629. if (prop.type === 7) {
  25630. if (!isBuiltInDirective(prop.name)) {
  25631. ids.add(`v${capitalize$1(camelize(prop.name))}`);
  25632. }
  25633. if (prop.arg && !prop.arg.isStatic) {
  25634. extractIdentifiers(ids, prop.arg);
  25635. }
  25636. if (prop.name === "for") {
  25637. extractIdentifiers(ids, prop.forParseResult.source);
  25638. } else if (prop.exp) {
  25639. extractIdentifiers(ids, prop.exp);
  25640. }
  25641. }
  25642. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  25643. ids.add(prop.value.content);
  25644. }
  25645. }
  25646. node.children.forEach(walk);
  25647. break;
  25648. case 5:
  25649. extractIdentifiers(ids, node.content);
  25650. break;
  25651. }
  25652. }
  25653. templateUsageCheckCache.set(content, ids);
  25654. return ids;
  25655. }
  25656. function extractIdentifiers(ids, node) {
  25657. if (node.ast) {
  25658. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  25659. } else if (node.ast === null) {
  25660. ids.add(node.content);
  25661. }
  25662. }
  25663. var __defProp$a = Object.defineProperty;
  25664. var __defProps$9 = Object.defineProperties;
  25665. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  25666. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  25667. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  25668. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  25669. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  25670. var __spreadValues$a = (a, b) => {
  25671. for (var prop in b || (b = {}))
  25672. if (__hasOwnProp$a.call(b, prop))
  25673. __defNormalProp$a(a, prop, b[prop]);
  25674. if (__getOwnPropSymbols$a)
  25675. for (var prop of __getOwnPropSymbols$a(b)) {
  25676. if (__propIsEnum$a.call(b, prop))
  25677. __defNormalProp$a(a, prop, b[prop]);
  25678. }
  25679. return a;
  25680. };
  25681. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  25682. const DEFAULT_FILENAME = "anonymous.vue";
  25683. const parseCache$1 = createCache();
  25684. function genCacheKey(source, options) {
  25685. var _a;
  25686. return source + JSON.stringify(
  25687. __spreadProps$9(__spreadValues$a({}, options), {
  25688. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  25689. }),
  25690. (_, val) => typeof val === "function" ? val.toString() : val
  25691. );
  25692. }
  25693. function parse$7(source, options = {}) {
  25694. const sourceKey = genCacheKey(source, options);
  25695. const cache = parseCache$1.get(sourceKey);
  25696. if (cache) {
  25697. return cache;
  25698. }
  25699. const {
  25700. sourceMap = true,
  25701. filename = DEFAULT_FILENAME,
  25702. sourceRoot = "",
  25703. pad = false,
  25704. ignoreEmpty = true,
  25705. compiler = CompilerDOM,
  25706. templateParseOptions = {},
  25707. parseExpressions = true
  25708. } = options;
  25709. const descriptor = {
  25710. filename,
  25711. source,
  25712. template: null,
  25713. script: null,
  25714. scriptSetup: null,
  25715. styles: [],
  25716. customBlocks: [],
  25717. cssVars: [],
  25718. slotted: false,
  25719. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  25720. };
  25721. const errors = [];
  25722. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  25723. parseMode: "sfc",
  25724. prefixIdentifiers: parseExpressions
  25725. }, templateParseOptions), {
  25726. onError: (e) => {
  25727. errors.push(e);
  25728. }
  25729. }));
  25730. ast.children.forEach((node) => {
  25731. if (node.type !== 1) {
  25732. return;
  25733. }
  25734. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  25735. return;
  25736. }
  25737. switch (node.tag) {
  25738. case "template":
  25739. if (!descriptor.template) {
  25740. const templateBlock = descriptor.template = createBlock(
  25741. node,
  25742. source,
  25743. false
  25744. );
  25745. if (!templateBlock.attrs.src) {
  25746. templateBlock.ast = createRoot(node.children, source);
  25747. }
  25748. if (templateBlock.attrs.functional) {
  25749. const err = new SyntaxError(
  25750. `<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.`
  25751. );
  25752. err.loc = node.props.find(
  25753. (p) => p.type === 6 && p.name === "functional"
  25754. ).loc;
  25755. errors.push(err);
  25756. }
  25757. } else {
  25758. errors.push(createDuplicateBlockError(node));
  25759. }
  25760. break;
  25761. case "script":
  25762. const scriptBlock = createBlock(node, source, pad);
  25763. const isSetup = !!scriptBlock.attrs.setup;
  25764. if (isSetup && !descriptor.scriptSetup) {
  25765. descriptor.scriptSetup = scriptBlock;
  25766. break;
  25767. }
  25768. if (!isSetup && !descriptor.script) {
  25769. descriptor.script = scriptBlock;
  25770. break;
  25771. }
  25772. errors.push(createDuplicateBlockError(node, isSetup));
  25773. break;
  25774. case "style":
  25775. const styleBlock = createBlock(node, source, pad);
  25776. if (styleBlock.attrs.vars) {
  25777. errors.push(
  25778. new SyntaxError(
  25779. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  25780. )
  25781. );
  25782. }
  25783. descriptor.styles.push(styleBlock);
  25784. break;
  25785. default:
  25786. descriptor.customBlocks.push(createBlock(node, source, pad));
  25787. break;
  25788. }
  25789. });
  25790. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  25791. errors.push(
  25792. new SyntaxError(
  25793. `At least one <template> or <script> is required in a single file component.`
  25794. )
  25795. );
  25796. }
  25797. if (descriptor.scriptSetup) {
  25798. if (descriptor.scriptSetup.src) {
  25799. errors.push(
  25800. new SyntaxError(
  25801. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  25802. )
  25803. );
  25804. descriptor.scriptSetup = null;
  25805. }
  25806. if (descriptor.script && descriptor.script.src) {
  25807. errors.push(
  25808. new SyntaxError(
  25809. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  25810. )
  25811. );
  25812. descriptor.script = null;
  25813. }
  25814. }
  25815. let templateColumnOffset = 0;
  25816. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  25817. [descriptor.template.content, templateColumnOffset] = dedent(
  25818. descriptor.template.content
  25819. );
  25820. }
  25821. if (sourceMap) {
  25822. const genMap = (block, columnOffset = 0) => {
  25823. if (block && !block.src) {
  25824. block.map = generateSourceMap(
  25825. filename,
  25826. source,
  25827. block.content,
  25828. sourceRoot,
  25829. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  25830. columnOffset
  25831. );
  25832. }
  25833. };
  25834. genMap(descriptor.template, templateColumnOffset);
  25835. genMap(descriptor.script);
  25836. descriptor.styles.forEach((s) => genMap(s));
  25837. descriptor.customBlocks.forEach((s) => genMap(s));
  25838. }
  25839. descriptor.cssVars = parseCssVars(descriptor);
  25840. const slottedRE = /(?:::v-|:)slotted\(/;
  25841. descriptor.slotted = descriptor.styles.some(
  25842. (s) => s.scoped && slottedRE.test(s.content)
  25843. );
  25844. const result = {
  25845. descriptor,
  25846. errors
  25847. };
  25848. parseCache$1.set(sourceKey, result);
  25849. return result;
  25850. }
  25851. function createDuplicateBlockError(node, isScriptSetup = false) {
  25852. const err = new SyntaxError(
  25853. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  25854. );
  25855. err.loc = node.loc;
  25856. return err;
  25857. }
  25858. function createBlock(node, source, pad) {
  25859. const type = node.tag;
  25860. const loc = node.innerLoc;
  25861. const attrs = {};
  25862. const block = {
  25863. type,
  25864. content: source.slice(loc.start.offset, loc.end.offset),
  25865. loc,
  25866. attrs
  25867. };
  25868. if (pad) {
  25869. block.content = padContent(source, block, pad) + block.content;
  25870. }
  25871. node.props.forEach((p) => {
  25872. if (p.type === 6) {
  25873. const name = p.name;
  25874. attrs[name] = p.value ? p.value.content || true : true;
  25875. if (name === "lang") {
  25876. block.lang = p.value && p.value.content;
  25877. } else if (name === "src") {
  25878. block.src = p.value && p.value.content;
  25879. } else if (type === "style") {
  25880. if (name === "scoped") {
  25881. block.scoped = true;
  25882. } else if (name === "module") {
  25883. block.module = attrs[name];
  25884. }
  25885. } else if (type === "script" && name === "setup") {
  25886. block.setup = attrs.setup;
  25887. }
  25888. }
  25889. });
  25890. return block;
  25891. }
  25892. const splitRE = /\r?\n/g;
  25893. const emptyRE = /^(?:\/\/)?\s*$/;
  25894. const replaceRE = /./g;
  25895. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  25896. const map = new SourceMapGenerator$6({
  25897. file: filename.replace(/\\/g, "/"),
  25898. sourceRoot: sourceRoot.replace(/\\/g, "/")
  25899. });
  25900. map.setSourceContent(filename, source);
  25901. map._sources.add(filename);
  25902. generated.split(splitRE).forEach((line, index) => {
  25903. if (!emptyRE.test(line)) {
  25904. const originalLine = index + 1 + lineOffset;
  25905. const generatedLine = index + 1;
  25906. for (let i = 0; i < line.length; i++) {
  25907. if (!/\s/.test(line[i])) {
  25908. map._mappings.add({
  25909. originalLine,
  25910. originalColumn: i + columnOffset,
  25911. generatedLine,
  25912. generatedColumn: i,
  25913. source: filename,
  25914. // @ts-expect-error
  25915. name: null
  25916. });
  25917. }
  25918. }
  25919. }
  25920. });
  25921. return map.toJSON();
  25922. }
  25923. function padContent(content, block, pad) {
  25924. content = content.slice(0, block.loc.start.offset);
  25925. if (pad === "space") {
  25926. return content.replace(replaceRE, " ");
  25927. } else {
  25928. const offset = content.split(splitRE).length;
  25929. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  25930. return Array(offset).join(padChar);
  25931. }
  25932. }
  25933. function hasSrc(node) {
  25934. return node.props.some((p) => {
  25935. if (p.type !== 6) {
  25936. return false;
  25937. }
  25938. return p.name === "src";
  25939. });
  25940. }
  25941. function isEmpty(node) {
  25942. for (let i = 0; i < node.children.length; i++) {
  25943. const child = node.children[i];
  25944. if (child.type !== 2 || child.content.trim() !== "") {
  25945. return false;
  25946. }
  25947. }
  25948. return true;
  25949. }
  25950. function hmrShouldReload(prevImports, next) {
  25951. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  25952. return false;
  25953. }
  25954. for (const key in prevImports) {
  25955. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  25956. return true;
  25957. }
  25958. }
  25959. return false;
  25960. }
  25961. function dedent(s) {
  25962. const lines = s.split("\n");
  25963. const minIndent = lines.reduce(function(minIndent2, line) {
  25964. var _a, _b;
  25965. if (line.trim() === "") {
  25966. return minIndent2;
  25967. }
  25968. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  25969. return Math.min(indent, minIndent2);
  25970. }, Infinity);
  25971. if (minIndent === 0) {
  25972. return [s, minIndent];
  25973. }
  25974. return [
  25975. lines.map(function(line) {
  25976. return line.slice(minIndent);
  25977. }).join("\n"),
  25978. minIndent
  25979. ];
  25980. }
  25981. /*! https://mths.be/punycode v1.4.1 by @mathias */
  25982. /** Highest positive signed 32-bit float value */
  25983. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  25984. /** Bootstring parameters */
  25985. var base = 36;
  25986. var tMin = 1;
  25987. var tMax = 26;
  25988. var skew = 38;
  25989. var damp = 700;
  25990. var initialBias = 72;
  25991. var initialN = 128; // 0x80
  25992. var delimiter = '-'; // '\x2D'
  25993. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  25994. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  25995. /** Error messages */
  25996. var errors = {
  25997. 'overflow': 'Overflow: input needs wider integers to process',
  25998. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  25999. 'invalid-input': 'Invalid input'
  26000. };
  26001. /** Convenience shortcuts */
  26002. var baseMinusTMin = base - tMin;
  26003. var floor = Math.floor;
  26004. var stringFromCharCode = String.fromCharCode;
  26005. /*--------------------------------------------------------------------------*/
  26006. /**
  26007. * A generic error utility function.
  26008. * @private
  26009. * @param {String} type The error type.
  26010. * @returns {Error} Throws a `RangeError` with the applicable error message.
  26011. */
  26012. function error(type) {
  26013. throw new RangeError(errors[type]);
  26014. }
  26015. /**
  26016. * A generic `Array#map` utility function.
  26017. * @private
  26018. * @param {Array} array The array to iterate over.
  26019. * @param {Function} callback The function that gets called for every array
  26020. * item.
  26021. * @returns {Array} A new array of values returned by the callback function.
  26022. */
  26023. function map$1(array, fn) {
  26024. var length = array.length;
  26025. var result = [];
  26026. while (length--) {
  26027. result[length] = fn(array[length]);
  26028. }
  26029. return result;
  26030. }
  26031. /**
  26032. * A simple `Array#map`-like wrapper to work with domain name strings or email
  26033. * addresses.
  26034. * @private
  26035. * @param {String} domain The domain name or email address.
  26036. * @param {Function} callback The function that gets called for every
  26037. * character.
  26038. * @returns {Array} A new string of characters returned by the callback
  26039. * function.
  26040. */
  26041. function mapDomain(string, fn) {
  26042. var parts = string.split('@');
  26043. var result = '';
  26044. if (parts.length > 1) {
  26045. // In email addresses, only the domain name should be punycoded. Leave
  26046. // the local part (i.e. everything up to `@`) intact.
  26047. result = parts[0] + '@';
  26048. string = parts[1];
  26049. }
  26050. // Avoid `split(regex)` for IE8 compatibility. See #17.
  26051. string = string.replace(regexSeparators, '\x2E');
  26052. var labels = string.split('.');
  26053. var encoded = map$1(labels, fn).join('.');
  26054. return result + encoded;
  26055. }
  26056. /**
  26057. * Creates an array containing the numeric code points of each Unicode
  26058. * character in the string. While JavaScript uses UCS-2 internally,
  26059. * this function will convert a pair of surrogate halves (each of which
  26060. * UCS-2 exposes as separate characters) into a single code point,
  26061. * matching UTF-16.
  26062. * @see `punycode.ucs2.encode`
  26063. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  26064. * @memberOf punycode.ucs2
  26065. * @name decode
  26066. * @param {String} string The Unicode input string (UCS-2).
  26067. * @returns {Array} The new array of code points.
  26068. */
  26069. function ucs2decode(string) {
  26070. var output = [],
  26071. counter = 0,
  26072. length = string.length,
  26073. value,
  26074. extra;
  26075. while (counter < length) {
  26076. value = string.charCodeAt(counter++);
  26077. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  26078. // high surrogate, and there is a next character
  26079. extra = string.charCodeAt(counter++);
  26080. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  26081. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  26082. } else {
  26083. // unmatched surrogate; only append this code unit, in case the next
  26084. // code unit is the high surrogate of a surrogate pair
  26085. output.push(value);
  26086. counter--;
  26087. }
  26088. } else {
  26089. output.push(value);
  26090. }
  26091. }
  26092. return output;
  26093. }
  26094. /**
  26095. * Converts a digit/integer into a basic code point.
  26096. * @see `basicToDigit()`
  26097. * @private
  26098. * @param {Number} digit The numeric value of a basic code point.
  26099. * @returns {Number} The basic code point whose value (when used for
  26100. * representing integers) is `digit`, which needs to be in the range
  26101. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  26102. * used; else, the lowercase form is used. The behavior is undefined
  26103. * if `flag` is non-zero and `digit` has no uppercase form.
  26104. */
  26105. function digitToBasic(digit, flag) {
  26106. // 0..25 map to ASCII a..z or A..Z
  26107. // 26..35 map to ASCII 0..9
  26108. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  26109. }
  26110. /**
  26111. * Bias adaptation function as per section 3.4 of RFC 3492.
  26112. * https://tools.ietf.org/html/rfc3492#section-3.4
  26113. * @private
  26114. */
  26115. function adapt(delta, numPoints, firstTime) {
  26116. var k = 0;
  26117. delta = firstTime ? floor(delta / damp) : delta >> 1;
  26118. delta += floor(delta / numPoints);
  26119. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  26120. delta = floor(delta / baseMinusTMin);
  26121. }
  26122. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  26123. }
  26124. /**
  26125. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  26126. * Punycode string of ASCII-only symbols.
  26127. * @memberOf punycode
  26128. * @param {String} input The string of Unicode symbols.
  26129. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  26130. */
  26131. function encode$1(input) {
  26132. var n,
  26133. delta,
  26134. handledCPCount,
  26135. basicLength,
  26136. bias,
  26137. j,
  26138. m,
  26139. q,
  26140. k,
  26141. t,
  26142. currentValue,
  26143. output = [],
  26144. /** `inputLength` will hold the number of code points in `input`. */
  26145. inputLength,
  26146. /** Cached calculation results */
  26147. handledCPCountPlusOne,
  26148. baseMinusT,
  26149. qMinusT;
  26150. // Convert the input in UCS-2 to Unicode
  26151. input = ucs2decode(input);
  26152. // Cache the length
  26153. inputLength = input.length;
  26154. // Initialize the state
  26155. n = initialN;
  26156. delta = 0;
  26157. bias = initialBias;
  26158. // Handle the basic code points
  26159. for (j = 0; j < inputLength; ++j) {
  26160. currentValue = input[j];
  26161. if (currentValue < 0x80) {
  26162. output.push(stringFromCharCode(currentValue));
  26163. }
  26164. }
  26165. handledCPCount = basicLength = output.length;
  26166. // `handledCPCount` is the number of code points that have been handled;
  26167. // `basicLength` is the number of basic code points.
  26168. // Finish the basic string - if it is not empty - with a delimiter
  26169. if (basicLength) {
  26170. output.push(delimiter);
  26171. }
  26172. // Main encoding loop:
  26173. while (handledCPCount < inputLength) {
  26174. // All non-basic code points < n have been handled already. Find the next
  26175. // larger one:
  26176. for (m = maxInt, j = 0; j < inputLength; ++j) {
  26177. currentValue = input[j];
  26178. if (currentValue >= n && currentValue < m) {
  26179. m = currentValue;
  26180. }
  26181. }
  26182. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  26183. // but guard against overflow
  26184. handledCPCountPlusOne = handledCPCount + 1;
  26185. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  26186. error('overflow');
  26187. }
  26188. delta += (m - n) * handledCPCountPlusOne;
  26189. n = m;
  26190. for (j = 0; j < inputLength; ++j) {
  26191. currentValue = input[j];
  26192. if (currentValue < n && ++delta > maxInt) {
  26193. error('overflow');
  26194. }
  26195. if (currentValue == n) {
  26196. // Represent delta as a generalized variable-length integer
  26197. for (q = delta, k = base; /* no condition */ ; k += base) {
  26198. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  26199. if (q < t) {
  26200. break;
  26201. }
  26202. qMinusT = q - t;
  26203. baseMinusT = base - t;
  26204. output.push(
  26205. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  26206. );
  26207. q = floor(qMinusT / baseMinusT);
  26208. }
  26209. output.push(stringFromCharCode(digitToBasic(q, 0)));
  26210. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  26211. delta = 0;
  26212. ++handledCPCount;
  26213. }
  26214. }
  26215. ++delta;
  26216. ++n;
  26217. }
  26218. return output.join('');
  26219. }
  26220. /**
  26221. * Converts a Unicode string representing a domain name or an email address to
  26222. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  26223. * i.e. it doesn't matter if you call it with a domain that's already in
  26224. * ASCII.
  26225. * @memberOf punycode
  26226. * @param {String} input The domain name or email address to convert, as a
  26227. * Unicode string.
  26228. * @returns {String} The Punycode representation of the given domain name or
  26229. * email address.
  26230. */
  26231. function toASCII(input) {
  26232. return mapDomain(input, function(string) {
  26233. return regexNonASCII.test(string) ?
  26234. 'xn--' + encode$1(string) :
  26235. string;
  26236. });
  26237. }
  26238. var lookup = [];
  26239. var revLookup = [];
  26240. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26241. var inited = false;
  26242. function init () {
  26243. inited = true;
  26244. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26245. for (var i = 0, len = code.length; i < len; ++i) {
  26246. lookup[i] = code[i];
  26247. revLookup[code.charCodeAt(i)] = i;
  26248. }
  26249. revLookup['-'.charCodeAt(0)] = 62;
  26250. revLookup['_'.charCodeAt(0)] = 63;
  26251. }
  26252. function toByteArray (b64) {
  26253. if (!inited) {
  26254. init();
  26255. }
  26256. var i, j, l, tmp, placeHolders, arr;
  26257. var len = b64.length;
  26258. if (len % 4 > 0) {
  26259. throw new Error('Invalid string. Length must be a multiple of 4')
  26260. }
  26261. // the number of equal signs (place holders)
  26262. // if there are two placeholders, than the two characters before it
  26263. // represent one byte
  26264. // if there is only one, then the three characters before it represent 2 bytes
  26265. // this is just a cheap hack to not do indexOf twice
  26266. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  26267. // base64 is 4/3 + up to two characters of the original data
  26268. arr = new Arr(len * 3 / 4 - placeHolders);
  26269. // if there are placeholders, only get up to the last complete 4 chars
  26270. l = placeHolders > 0 ? len - 4 : len;
  26271. var L = 0;
  26272. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  26273. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  26274. arr[L++] = (tmp >> 16) & 0xFF;
  26275. arr[L++] = (tmp >> 8) & 0xFF;
  26276. arr[L++] = tmp & 0xFF;
  26277. }
  26278. if (placeHolders === 2) {
  26279. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  26280. arr[L++] = tmp & 0xFF;
  26281. } else if (placeHolders === 1) {
  26282. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  26283. arr[L++] = (tmp >> 8) & 0xFF;
  26284. arr[L++] = tmp & 0xFF;
  26285. }
  26286. return arr
  26287. }
  26288. function tripletToBase64 (num) {
  26289. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  26290. }
  26291. function encodeChunk (uint8, start, end) {
  26292. var tmp;
  26293. var output = [];
  26294. for (var i = start; i < end; i += 3) {
  26295. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  26296. output.push(tripletToBase64(tmp));
  26297. }
  26298. return output.join('')
  26299. }
  26300. function fromByteArray (uint8) {
  26301. if (!inited) {
  26302. init();
  26303. }
  26304. var tmp;
  26305. var len = uint8.length;
  26306. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26307. var output = '';
  26308. var parts = [];
  26309. var maxChunkLength = 16383; // must be multiple of 3
  26310. // go through the array every three bytes, we'll deal with trailing stuff later
  26311. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26312. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  26313. }
  26314. // pad the end with zeros, but make sure to not forget the extra bytes
  26315. if (extraBytes === 1) {
  26316. tmp = uint8[len - 1];
  26317. output += lookup[tmp >> 2];
  26318. output += lookup[(tmp << 4) & 0x3F];
  26319. output += '==';
  26320. } else if (extraBytes === 2) {
  26321. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  26322. output += lookup[tmp >> 10];
  26323. output += lookup[(tmp >> 4) & 0x3F];
  26324. output += lookup[(tmp << 2) & 0x3F];
  26325. output += '=';
  26326. }
  26327. parts.push(output);
  26328. return parts.join('')
  26329. }
  26330. function read (buffer, offset, isLE, mLen, nBytes) {
  26331. var e, m;
  26332. var eLen = nBytes * 8 - mLen - 1;
  26333. var eMax = (1 << eLen) - 1;
  26334. var eBias = eMax >> 1;
  26335. var nBits = -7;
  26336. var i = isLE ? (nBytes - 1) : 0;
  26337. var d = isLE ? -1 : 1;
  26338. var s = buffer[offset + i];
  26339. i += d;
  26340. e = s & ((1 << (-nBits)) - 1);
  26341. s >>= (-nBits);
  26342. nBits += eLen;
  26343. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26344. m = e & ((1 << (-nBits)) - 1);
  26345. e >>= (-nBits);
  26346. nBits += mLen;
  26347. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26348. if (e === 0) {
  26349. e = 1 - eBias;
  26350. } else if (e === eMax) {
  26351. return m ? NaN : ((s ? -1 : 1) * Infinity)
  26352. } else {
  26353. m = m + Math.pow(2, mLen);
  26354. e = e - eBias;
  26355. }
  26356. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  26357. }
  26358. function write (buffer, value, offset, isLE, mLen, nBytes) {
  26359. var e, m, c;
  26360. var eLen = nBytes * 8 - mLen - 1;
  26361. var eMax = (1 << eLen) - 1;
  26362. var eBias = eMax >> 1;
  26363. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  26364. var i = isLE ? 0 : (nBytes - 1);
  26365. var d = isLE ? 1 : -1;
  26366. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  26367. value = Math.abs(value);
  26368. if (isNaN(value) || value === Infinity) {
  26369. m = isNaN(value) ? 1 : 0;
  26370. e = eMax;
  26371. } else {
  26372. e = Math.floor(Math.log(value) / Math.LN2);
  26373. if (value * (c = Math.pow(2, -e)) < 1) {
  26374. e--;
  26375. c *= 2;
  26376. }
  26377. if (e + eBias >= 1) {
  26378. value += rt / c;
  26379. } else {
  26380. value += rt * Math.pow(2, 1 - eBias);
  26381. }
  26382. if (value * c >= 2) {
  26383. e++;
  26384. c /= 2;
  26385. }
  26386. if (e + eBias >= eMax) {
  26387. m = 0;
  26388. e = eMax;
  26389. } else if (e + eBias >= 1) {
  26390. m = (value * c - 1) * Math.pow(2, mLen);
  26391. e = e + eBias;
  26392. } else {
  26393. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  26394. e = 0;
  26395. }
  26396. }
  26397. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  26398. e = (e << mLen) | m;
  26399. eLen += mLen;
  26400. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  26401. buffer[offset + i - d] |= s * 128;
  26402. }
  26403. var toString$1 = {}.toString;
  26404. var isArray$2 = Array.isArray || function (arr) {
  26405. return toString$1.call(arr) == '[object Array]';
  26406. };
  26407. /*!
  26408. * The buffer module from node.js, for the browser.
  26409. *
  26410. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  26411. * @license MIT
  26412. */
  26413. /* eslint-disable no-proto */
  26414. var INSPECT_MAX_BYTES = 50;
  26415. /**
  26416. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  26417. * === true Use Uint8Array implementation (fastest)
  26418. * === false Use Object implementation (most compatible, even IE6)
  26419. *
  26420. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  26421. * Opera 11.6+, iOS 4.2+.
  26422. *
  26423. * Due to various browser bugs, sometimes the Object implementation will be used even
  26424. * when the browser supports typed arrays.
  26425. *
  26426. * Note:
  26427. *
  26428. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  26429. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  26430. *
  26431. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  26432. *
  26433. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  26434. * incorrect length in some situations.
  26435. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  26436. * get the Object implementation, which is slower but behaves correctly.
  26437. */
  26438. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  26439. ? global$1.TYPED_ARRAY_SUPPORT
  26440. : true;
  26441. /*
  26442. * Export kMaxLength after typed array support is determined.
  26443. */
  26444. kMaxLength();
  26445. function kMaxLength () {
  26446. return Buffer$1.TYPED_ARRAY_SUPPORT
  26447. ? 0x7fffffff
  26448. : 0x3fffffff
  26449. }
  26450. function createBuffer (that, length) {
  26451. if (kMaxLength() < length) {
  26452. throw new RangeError('Invalid typed array length')
  26453. }
  26454. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26455. // Return an augmented `Uint8Array` instance, for best performance
  26456. that = new Uint8Array(length);
  26457. that.__proto__ = Buffer$1.prototype;
  26458. } else {
  26459. // Fallback: Return an object instance of the Buffer class
  26460. if (that === null) {
  26461. that = new Buffer$1(length);
  26462. }
  26463. that.length = length;
  26464. }
  26465. return that
  26466. }
  26467. /**
  26468. * The Buffer constructor returns instances of `Uint8Array` that have their
  26469. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  26470. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  26471. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  26472. * returns a single octet.
  26473. *
  26474. * The `Uint8Array` prototype remains unmodified.
  26475. */
  26476. function Buffer$1 (arg, encodingOrOffset, length) {
  26477. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  26478. return new Buffer$1(arg, encodingOrOffset, length)
  26479. }
  26480. // Common case.
  26481. if (typeof arg === 'number') {
  26482. if (typeof encodingOrOffset === 'string') {
  26483. throw new Error(
  26484. 'If encoding is specified then the first argument must be a string'
  26485. )
  26486. }
  26487. return allocUnsafe(this, arg)
  26488. }
  26489. return from(this, arg, encodingOrOffset, length)
  26490. }
  26491. Buffer$1.poolSize = 8192; // not used by this implementation
  26492. // TODO: Legacy, not needed anymore. Remove in next major version.
  26493. Buffer$1._augment = function (arr) {
  26494. arr.__proto__ = Buffer$1.prototype;
  26495. return arr
  26496. };
  26497. function from (that, value, encodingOrOffset, length) {
  26498. if (typeof value === 'number') {
  26499. throw new TypeError('"value" argument must not be a number')
  26500. }
  26501. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  26502. return fromArrayBuffer(that, value, encodingOrOffset, length)
  26503. }
  26504. if (typeof value === 'string') {
  26505. return fromString(that, value, encodingOrOffset)
  26506. }
  26507. return fromObject(that, value)
  26508. }
  26509. /**
  26510. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  26511. * if value is a number.
  26512. * Buffer.from(str[, encoding])
  26513. * Buffer.from(array)
  26514. * Buffer.from(buffer)
  26515. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  26516. **/
  26517. Buffer$1.from = function (value, encodingOrOffset, length) {
  26518. return from(null, value, encodingOrOffset, length)
  26519. };
  26520. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26521. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  26522. Buffer$1.__proto__ = Uint8Array;
  26523. if (typeof Symbol !== 'undefined' && Symbol.species &&
  26524. Buffer$1[Symbol.species] === Buffer$1) ;
  26525. }
  26526. function assertSize (size) {
  26527. if (typeof size !== 'number') {
  26528. throw new TypeError('"size" argument must be a number')
  26529. } else if (size < 0) {
  26530. throw new RangeError('"size" argument must not be negative')
  26531. }
  26532. }
  26533. function alloc (that, size, fill, encoding) {
  26534. assertSize(size);
  26535. if (size <= 0) {
  26536. return createBuffer(that, size)
  26537. }
  26538. if (fill !== undefined) {
  26539. // Only pay attention to encoding if it's a string. This
  26540. // prevents accidentally sending in a number that would
  26541. // be interpretted as a start offset.
  26542. return typeof encoding === 'string'
  26543. ? createBuffer(that, size).fill(fill, encoding)
  26544. : createBuffer(that, size).fill(fill)
  26545. }
  26546. return createBuffer(that, size)
  26547. }
  26548. /**
  26549. * Creates a new filled Buffer instance.
  26550. * alloc(size[, fill[, encoding]])
  26551. **/
  26552. Buffer$1.alloc = function (size, fill, encoding) {
  26553. return alloc(null, size, fill, encoding)
  26554. };
  26555. function allocUnsafe (that, size) {
  26556. assertSize(size);
  26557. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  26558. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  26559. for (var i = 0; i < size; ++i) {
  26560. that[i] = 0;
  26561. }
  26562. }
  26563. return that
  26564. }
  26565. /**
  26566. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  26567. * */
  26568. Buffer$1.allocUnsafe = function (size) {
  26569. return allocUnsafe(null, size)
  26570. };
  26571. /**
  26572. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  26573. */
  26574. Buffer$1.allocUnsafeSlow = function (size) {
  26575. return allocUnsafe(null, size)
  26576. };
  26577. function fromString (that, string, encoding) {
  26578. if (typeof encoding !== 'string' || encoding === '') {
  26579. encoding = 'utf8';
  26580. }
  26581. if (!Buffer$1.isEncoding(encoding)) {
  26582. throw new TypeError('"encoding" must be a valid string encoding')
  26583. }
  26584. var length = byteLength(string, encoding) | 0;
  26585. that = createBuffer(that, length);
  26586. var actual = that.write(string, encoding);
  26587. if (actual !== length) {
  26588. // Writing a hex string, for example, that contains invalid characters will
  26589. // cause everything after the first invalid character to be ignored. (e.g.
  26590. // 'abxxcd' will be treated as 'ab')
  26591. that = that.slice(0, actual);
  26592. }
  26593. return that
  26594. }
  26595. function fromArrayLike (that, array) {
  26596. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  26597. that = createBuffer(that, length);
  26598. for (var i = 0; i < length; i += 1) {
  26599. that[i] = array[i] & 255;
  26600. }
  26601. return that
  26602. }
  26603. function fromArrayBuffer (that, array, byteOffset, length) {
  26604. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  26605. if (byteOffset < 0 || array.byteLength < byteOffset) {
  26606. throw new RangeError('\'offset\' is out of bounds')
  26607. }
  26608. if (array.byteLength < byteOffset + (length || 0)) {
  26609. throw new RangeError('\'length\' is out of bounds')
  26610. }
  26611. if (byteOffset === undefined && length === undefined) {
  26612. array = new Uint8Array(array);
  26613. } else if (length === undefined) {
  26614. array = new Uint8Array(array, byteOffset);
  26615. } else {
  26616. array = new Uint8Array(array, byteOffset, length);
  26617. }
  26618. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26619. // Return an augmented `Uint8Array` instance, for best performance
  26620. that = array;
  26621. that.__proto__ = Buffer$1.prototype;
  26622. } else {
  26623. // Fallback: Return an object instance of the Buffer class
  26624. that = fromArrayLike(that, array);
  26625. }
  26626. return that
  26627. }
  26628. function fromObject (that, obj) {
  26629. if (internalIsBuffer(obj)) {
  26630. var len = checked(obj.length) | 0;
  26631. that = createBuffer(that, len);
  26632. if (that.length === 0) {
  26633. return that
  26634. }
  26635. obj.copy(that, 0, 0, len);
  26636. return that
  26637. }
  26638. if (obj) {
  26639. if ((typeof ArrayBuffer !== 'undefined' &&
  26640. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  26641. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  26642. return createBuffer(that, 0)
  26643. }
  26644. return fromArrayLike(that, obj)
  26645. }
  26646. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  26647. return fromArrayLike(that, obj.data)
  26648. }
  26649. }
  26650. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  26651. }
  26652. function checked (length) {
  26653. // Note: cannot use `length < kMaxLength()` here because that fails when
  26654. // length is NaN (which is otherwise coerced to zero.)
  26655. if (length >= kMaxLength()) {
  26656. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  26657. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  26658. }
  26659. return length | 0
  26660. }
  26661. Buffer$1.isBuffer = isBuffer$1;
  26662. function internalIsBuffer (b) {
  26663. return !!(b != null && b._isBuffer)
  26664. }
  26665. Buffer$1.compare = function compare (a, b) {
  26666. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  26667. throw new TypeError('Arguments must be Buffers')
  26668. }
  26669. if (a === b) return 0
  26670. var x = a.length;
  26671. var y = b.length;
  26672. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  26673. if (a[i] !== b[i]) {
  26674. x = a[i];
  26675. y = b[i];
  26676. break
  26677. }
  26678. }
  26679. if (x < y) return -1
  26680. if (y < x) return 1
  26681. return 0
  26682. };
  26683. Buffer$1.isEncoding = function isEncoding (encoding) {
  26684. switch (String(encoding).toLowerCase()) {
  26685. case 'hex':
  26686. case 'utf8':
  26687. case 'utf-8':
  26688. case 'ascii':
  26689. case 'latin1':
  26690. case 'binary':
  26691. case 'base64':
  26692. case 'ucs2':
  26693. case 'ucs-2':
  26694. case 'utf16le':
  26695. case 'utf-16le':
  26696. return true
  26697. default:
  26698. return false
  26699. }
  26700. };
  26701. Buffer$1.concat = function concat (list, length) {
  26702. if (!isArray$2(list)) {
  26703. throw new TypeError('"list" argument must be an Array of Buffers')
  26704. }
  26705. if (list.length === 0) {
  26706. return Buffer$1.alloc(0)
  26707. }
  26708. var i;
  26709. if (length === undefined) {
  26710. length = 0;
  26711. for (i = 0; i < list.length; ++i) {
  26712. length += list[i].length;
  26713. }
  26714. }
  26715. var buffer = Buffer$1.allocUnsafe(length);
  26716. var pos = 0;
  26717. for (i = 0; i < list.length; ++i) {
  26718. var buf = list[i];
  26719. if (!internalIsBuffer(buf)) {
  26720. throw new TypeError('"list" argument must be an Array of Buffers')
  26721. }
  26722. buf.copy(buffer, pos);
  26723. pos += buf.length;
  26724. }
  26725. return buffer
  26726. };
  26727. function byteLength (string, encoding) {
  26728. if (internalIsBuffer(string)) {
  26729. return string.length
  26730. }
  26731. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  26732. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  26733. return string.byteLength
  26734. }
  26735. if (typeof string !== 'string') {
  26736. string = '' + string;
  26737. }
  26738. var len = string.length;
  26739. if (len === 0) return 0
  26740. // Use a for loop to avoid recursion
  26741. var loweredCase = false;
  26742. for (;;) {
  26743. switch (encoding) {
  26744. case 'ascii':
  26745. case 'latin1':
  26746. case 'binary':
  26747. return len
  26748. case 'utf8':
  26749. case 'utf-8':
  26750. case undefined:
  26751. return utf8ToBytes(string).length
  26752. case 'ucs2':
  26753. case 'ucs-2':
  26754. case 'utf16le':
  26755. case 'utf-16le':
  26756. return len * 2
  26757. case 'hex':
  26758. return len >>> 1
  26759. case 'base64':
  26760. return base64ToBytes(string).length
  26761. default:
  26762. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  26763. encoding = ('' + encoding).toLowerCase();
  26764. loweredCase = true;
  26765. }
  26766. }
  26767. }
  26768. Buffer$1.byteLength = byteLength;
  26769. function slowToString (encoding, start, end) {
  26770. var loweredCase = false;
  26771. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  26772. // property of a typed array.
  26773. // This behaves neither like String nor Uint8Array in that we set start/end
  26774. // to their upper/lower bounds if the value passed is out of range.
  26775. // undefined is handled specially as per ECMA-262 6th Edition,
  26776. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  26777. if (start === undefined || start < 0) {
  26778. start = 0;
  26779. }
  26780. // Return early if start > this.length. Done here to prevent potential uint32
  26781. // coercion fail below.
  26782. if (start > this.length) {
  26783. return ''
  26784. }
  26785. if (end === undefined || end > this.length) {
  26786. end = this.length;
  26787. }
  26788. if (end <= 0) {
  26789. return ''
  26790. }
  26791. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  26792. end >>>= 0;
  26793. start >>>= 0;
  26794. if (end <= start) {
  26795. return ''
  26796. }
  26797. if (!encoding) encoding = 'utf8';
  26798. while (true) {
  26799. switch (encoding) {
  26800. case 'hex':
  26801. return hexSlice(this, start, end)
  26802. case 'utf8':
  26803. case 'utf-8':
  26804. return utf8Slice(this, start, end)
  26805. case 'ascii':
  26806. return asciiSlice(this, start, end)
  26807. case 'latin1':
  26808. case 'binary':
  26809. return latin1Slice(this, start, end)
  26810. case 'base64':
  26811. return base64Slice(this, start, end)
  26812. case 'ucs2':
  26813. case 'ucs-2':
  26814. case 'utf16le':
  26815. case 'utf-16le':
  26816. return utf16leSlice(this, start, end)
  26817. default:
  26818. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  26819. encoding = (encoding + '').toLowerCase();
  26820. loweredCase = true;
  26821. }
  26822. }
  26823. }
  26824. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  26825. // Buffer instances.
  26826. Buffer$1.prototype._isBuffer = true;
  26827. function swap$1 (b, n, m) {
  26828. var i = b[n];
  26829. b[n] = b[m];
  26830. b[m] = i;
  26831. }
  26832. Buffer$1.prototype.swap16 = function swap16 () {
  26833. var len = this.length;
  26834. if (len % 2 !== 0) {
  26835. throw new RangeError('Buffer size must be a multiple of 16-bits')
  26836. }
  26837. for (var i = 0; i < len; i += 2) {
  26838. swap$1(this, i, i + 1);
  26839. }
  26840. return this
  26841. };
  26842. Buffer$1.prototype.swap32 = function swap32 () {
  26843. var len = this.length;
  26844. if (len % 4 !== 0) {
  26845. throw new RangeError('Buffer size must be a multiple of 32-bits')
  26846. }
  26847. for (var i = 0; i < len; i += 4) {
  26848. swap$1(this, i, i + 3);
  26849. swap$1(this, i + 1, i + 2);
  26850. }
  26851. return this
  26852. };
  26853. Buffer$1.prototype.swap64 = function swap64 () {
  26854. var len = this.length;
  26855. if (len % 8 !== 0) {
  26856. throw new RangeError('Buffer size must be a multiple of 64-bits')
  26857. }
  26858. for (var i = 0; i < len; i += 8) {
  26859. swap$1(this, i, i + 7);
  26860. swap$1(this, i + 1, i + 6);
  26861. swap$1(this, i + 2, i + 5);
  26862. swap$1(this, i + 3, i + 4);
  26863. }
  26864. return this
  26865. };
  26866. Buffer$1.prototype.toString = function toString () {
  26867. var length = this.length | 0;
  26868. if (length === 0) return ''
  26869. if (arguments.length === 0) return utf8Slice(this, 0, length)
  26870. return slowToString.apply(this, arguments)
  26871. };
  26872. Buffer$1.prototype.equals = function equals (b) {
  26873. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  26874. if (this === b) return true
  26875. return Buffer$1.compare(this, b) === 0
  26876. };
  26877. Buffer$1.prototype.inspect = function inspect () {
  26878. var str = '';
  26879. var max = INSPECT_MAX_BYTES;
  26880. if (this.length > 0) {
  26881. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  26882. if (this.length > max) str += ' ... ';
  26883. }
  26884. return '<Buffer ' + str + '>'
  26885. };
  26886. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  26887. if (!internalIsBuffer(target)) {
  26888. throw new TypeError('Argument must be a Buffer')
  26889. }
  26890. if (start === undefined) {
  26891. start = 0;
  26892. }
  26893. if (end === undefined) {
  26894. end = target ? target.length : 0;
  26895. }
  26896. if (thisStart === undefined) {
  26897. thisStart = 0;
  26898. }
  26899. if (thisEnd === undefined) {
  26900. thisEnd = this.length;
  26901. }
  26902. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  26903. throw new RangeError('out of range index')
  26904. }
  26905. if (thisStart >= thisEnd && start >= end) {
  26906. return 0
  26907. }
  26908. if (thisStart >= thisEnd) {
  26909. return -1
  26910. }
  26911. if (start >= end) {
  26912. return 1
  26913. }
  26914. start >>>= 0;
  26915. end >>>= 0;
  26916. thisStart >>>= 0;
  26917. thisEnd >>>= 0;
  26918. if (this === target) return 0
  26919. var x = thisEnd - thisStart;
  26920. var y = end - start;
  26921. var len = Math.min(x, y);
  26922. var thisCopy = this.slice(thisStart, thisEnd);
  26923. var targetCopy = target.slice(start, end);
  26924. for (var i = 0; i < len; ++i) {
  26925. if (thisCopy[i] !== targetCopy[i]) {
  26926. x = thisCopy[i];
  26927. y = targetCopy[i];
  26928. break
  26929. }
  26930. }
  26931. if (x < y) return -1
  26932. if (y < x) return 1
  26933. return 0
  26934. };
  26935. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  26936. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  26937. //
  26938. // Arguments:
  26939. // - buffer - a Buffer to search
  26940. // - val - a string, Buffer, or number
  26941. // - byteOffset - an index into `buffer`; will be clamped to an int32
  26942. // - encoding - an optional encoding, relevant is val is a string
  26943. // - dir - true for indexOf, false for lastIndexOf
  26944. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  26945. // Empty buffer means no match
  26946. if (buffer.length === 0) return -1
  26947. // Normalize byteOffset
  26948. if (typeof byteOffset === 'string') {
  26949. encoding = byteOffset;
  26950. byteOffset = 0;
  26951. } else if (byteOffset > 0x7fffffff) {
  26952. byteOffset = 0x7fffffff;
  26953. } else if (byteOffset < -0x80000000) {
  26954. byteOffset = -0x80000000;
  26955. }
  26956. byteOffset = +byteOffset; // Coerce to Number.
  26957. if (isNaN(byteOffset)) {
  26958. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  26959. byteOffset = dir ? 0 : (buffer.length - 1);
  26960. }
  26961. // Normalize byteOffset: negative offsets start from the end of the buffer
  26962. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  26963. if (byteOffset >= buffer.length) {
  26964. if (dir) return -1
  26965. else byteOffset = buffer.length - 1;
  26966. } else if (byteOffset < 0) {
  26967. if (dir) byteOffset = 0;
  26968. else return -1
  26969. }
  26970. // Normalize val
  26971. if (typeof val === 'string') {
  26972. val = Buffer$1.from(val, encoding);
  26973. }
  26974. // Finally, search either indexOf (if dir is true) or lastIndexOf
  26975. if (internalIsBuffer(val)) {
  26976. // Special case: looking for empty string/buffer always fails
  26977. if (val.length === 0) {
  26978. return -1
  26979. }
  26980. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  26981. } else if (typeof val === 'number') {
  26982. val = val & 0xFF; // Search for a byte value [0-255]
  26983. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  26984. typeof Uint8Array.prototype.indexOf === 'function') {
  26985. if (dir) {
  26986. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  26987. } else {
  26988. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  26989. }
  26990. }
  26991. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  26992. }
  26993. throw new TypeError('val must be string, number or Buffer')
  26994. }
  26995. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  26996. var indexSize = 1;
  26997. var arrLength = arr.length;
  26998. var valLength = val.length;
  26999. if (encoding !== undefined) {
  27000. encoding = String(encoding).toLowerCase();
  27001. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  27002. encoding === 'utf16le' || encoding === 'utf-16le') {
  27003. if (arr.length < 2 || val.length < 2) {
  27004. return -1
  27005. }
  27006. indexSize = 2;
  27007. arrLength /= 2;
  27008. valLength /= 2;
  27009. byteOffset /= 2;
  27010. }
  27011. }
  27012. function read (buf, i) {
  27013. if (indexSize === 1) {
  27014. return buf[i]
  27015. } else {
  27016. return buf.readUInt16BE(i * indexSize)
  27017. }
  27018. }
  27019. var i;
  27020. if (dir) {
  27021. var foundIndex = -1;
  27022. for (i = byteOffset; i < arrLength; i++) {
  27023. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  27024. if (foundIndex === -1) foundIndex = i;
  27025. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  27026. } else {
  27027. if (foundIndex !== -1) i -= i - foundIndex;
  27028. foundIndex = -1;
  27029. }
  27030. }
  27031. } else {
  27032. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  27033. for (i = byteOffset; i >= 0; i--) {
  27034. var found = true;
  27035. for (var j = 0; j < valLength; j++) {
  27036. if (read(arr, i + j) !== read(val, j)) {
  27037. found = false;
  27038. break
  27039. }
  27040. }
  27041. if (found) return i
  27042. }
  27043. }
  27044. return -1
  27045. }
  27046. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  27047. return this.indexOf(val, byteOffset, encoding) !== -1
  27048. };
  27049. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  27050. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  27051. };
  27052. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  27053. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  27054. };
  27055. function hexWrite (buf, string, offset, length) {
  27056. offset = Number(offset) || 0;
  27057. var remaining = buf.length - offset;
  27058. if (!length) {
  27059. length = remaining;
  27060. } else {
  27061. length = Number(length);
  27062. if (length > remaining) {
  27063. length = remaining;
  27064. }
  27065. }
  27066. // must be an even number of digits
  27067. var strLen = string.length;
  27068. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  27069. if (length > strLen / 2) {
  27070. length = strLen / 2;
  27071. }
  27072. for (var i = 0; i < length; ++i) {
  27073. var parsed = parseInt(string.substr(i * 2, 2), 16);
  27074. if (isNaN(parsed)) return i
  27075. buf[offset + i] = parsed;
  27076. }
  27077. return i
  27078. }
  27079. function utf8Write (buf, string, offset, length) {
  27080. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  27081. }
  27082. function asciiWrite (buf, string, offset, length) {
  27083. return blitBuffer(asciiToBytes(string), buf, offset, length)
  27084. }
  27085. function latin1Write (buf, string, offset, length) {
  27086. return asciiWrite(buf, string, offset, length)
  27087. }
  27088. function base64Write (buf, string, offset, length) {
  27089. return blitBuffer(base64ToBytes(string), buf, offset, length)
  27090. }
  27091. function ucs2Write (buf, string, offset, length) {
  27092. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  27093. }
  27094. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  27095. // Buffer#write(string)
  27096. if (offset === undefined) {
  27097. encoding = 'utf8';
  27098. length = this.length;
  27099. offset = 0;
  27100. // Buffer#write(string, encoding)
  27101. } else if (length === undefined && typeof offset === 'string') {
  27102. encoding = offset;
  27103. length = this.length;
  27104. offset = 0;
  27105. // Buffer#write(string, offset[, length][, encoding])
  27106. } else if (isFinite(offset)) {
  27107. offset = offset | 0;
  27108. if (isFinite(length)) {
  27109. length = length | 0;
  27110. if (encoding === undefined) encoding = 'utf8';
  27111. } else {
  27112. encoding = length;
  27113. length = undefined;
  27114. }
  27115. // legacy write(string, encoding, offset, length) - remove in v0.13
  27116. } else {
  27117. throw new Error(
  27118. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  27119. )
  27120. }
  27121. var remaining = this.length - offset;
  27122. if (length === undefined || length > remaining) length = remaining;
  27123. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  27124. throw new RangeError('Attempt to write outside buffer bounds')
  27125. }
  27126. if (!encoding) encoding = 'utf8';
  27127. var loweredCase = false;
  27128. for (;;) {
  27129. switch (encoding) {
  27130. case 'hex':
  27131. return hexWrite(this, string, offset, length)
  27132. case 'utf8':
  27133. case 'utf-8':
  27134. return utf8Write(this, string, offset, length)
  27135. case 'ascii':
  27136. return asciiWrite(this, string, offset, length)
  27137. case 'latin1':
  27138. case 'binary':
  27139. return latin1Write(this, string, offset, length)
  27140. case 'base64':
  27141. // Warning: maxLength not taken into account in base64Write
  27142. return base64Write(this, string, offset, length)
  27143. case 'ucs2':
  27144. case 'ucs-2':
  27145. case 'utf16le':
  27146. case 'utf-16le':
  27147. return ucs2Write(this, string, offset, length)
  27148. default:
  27149. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27150. encoding = ('' + encoding).toLowerCase();
  27151. loweredCase = true;
  27152. }
  27153. }
  27154. };
  27155. Buffer$1.prototype.toJSON = function toJSON () {
  27156. return {
  27157. type: 'Buffer',
  27158. data: Array.prototype.slice.call(this._arr || this, 0)
  27159. }
  27160. };
  27161. function base64Slice (buf, start, end) {
  27162. if (start === 0 && end === buf.length) {
  27163. return fromByteArray(buf)
  27164. } else {
  27165. return fromByteArray(buf.slice(start, end))
  27166. }
  27167. }
  27168. function utf8Slice (buf, start, end) {
  27169. end = Math.min(buf.length, end);
  27170. var res = [];
  27171. var i = start;
  27172. while (i < end) {
  27173. var firstByte = buf[i];
  27174. var codePoint = null;
  27175. var bytesPerSequence = (firstByte > 0xEF) ? 4
  27176. : (firstByte > 0xDF) ? 3
  27177. : (firstByte > 0xBF) ? 2
  27178. : 1;
  27179. if (i + bytesPerSequence <= end) {
  27180. var secondByte, thirdByte, fourthByte, tempCodePoint;
  27181. switch (bytesPerSequence) {
  27182. case 1:
  27183. if (firstByte < 0x80) {
  27184. codePoint = firstByte;
  27185. }
  27186. break
  27187. case 2:
  27188. secondByte = buf[i + 1];
  27189. if ((secondByte & 0xC0) === 0x80) {
  27190. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  27191. if (tempCodePoint > 0x7F) {
  27192. codePoint = tempCodePoint;
  27193. }
  27194. }
  27195. break
  27196. case 3:
  27197. secondByte = buf[i + 1];
  27198. thirdByte = buf[i + 2];
  27199. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  27200. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  27201. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  27202. codePoint = tempCodePoint;
  27203. }
  27204. }
  27205. break
  27206. case 4:
  27207. secondByte = buf[i + 1];
  27208. thirdByte = buf[i + 2];
  27209. fourthByte = buf[i + 3];
  27210. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  27211. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  27212. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  27213. codePoint = tempCodePoint;
  27214. }
  27215. }
  27216. }
  27217. }
  27218. if (codePoint === null) {
  27219. // we did not generate a valid codePoint so insert a
  27220. // replacement char (U+FFFD) and advance only 1 byte
  27221. codePoint = 0xFFFD;
  27222. bytesPerSequence = 1;
  27223. } else if (codePoint > 0xFFFF) {
  27224. // encode to utf16 (surrogate pair dance)
  27225. codePoint -= 0x10000;
  27226. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  27227. codePoint = 0xDC00 | codePoint & 0x3FF;
  27228. }
  27229. res.push(codePoint);
  27230. i += bytesPerSequence;
  27231. }
  27232. return decodeCodePointsArray(res)
  27233. }
  27234. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  27235. // the lowest limit is Chrome, with 0x10000 args.
  27236. // We go 1 magnitude less, for safety
  27237. var MAX_ARGUMENTS_LENGTH = 0x1000;
  27238. function decodeCodePointsArray (codePoints) {
  27239. var len = codePoints.length;
  27240. if (len <= MAX_ARGUMENTS_LENGTH) {
  27241. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  27242. }
  27243. // Decode in chunks to avoid "call stack size exceeded".
  27244. var res = '';
  27245. var i = 0;
  27246. while (i < len) {
  27247. res += String.fromCharCode.apply(
  27248. String,
  27249. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  27250. );
  27251. }
  27252. return res
  27253. }
  27254. function asciiSlice (buf, start, end) {
  27255. var ret = '';
  27256. end = Math.min(buf.length, end);
  27257. for (var i = start; i < end; ++i) {
  27258. ret += String.fromCharCode(buf[i] & 0x7F);
  27259. }
  27260. return ret
  27261. }
  27262. function latin1Slice (buf, start, end) {
  27263. var ret = '';
  27264. end = Math.min(buf.length, end);
  27265. for (var i = start; i < end; ++i) {
  27266. ret += String.fromCharCode(buf[i]);
  27267. }
  27268. return ret
  27269. }
  27270. function hexSlice (buf, start, end) {
  27271. var len = buf.length;
  27272. if (!start || start < 0) start = 0;
  27273. if (!end || end < 0 || end > len) end = len;
  27274. var out = '';
  27275. for (var i = start; i < end; ++i) {
  27276. out += toHex(buf[i]);
  27277. }
  27278. return out
  27279. }
  27280. function utf16leSlice (buf, start, end) {
  27281. var bytes = buf.slice(start, end);
  27282. var res = '';
  27283. for (var i = 0; i < bytes.length; i += 2) {
  27284. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  27285. }
  27286. return res
  27287. }
  27288. Buffer$1.prototype.slice = function slice (start, end) {
  27289. var len = this.length;
  27290. start = ~~start;
  27291. end = end === undefined ? len : ~~end;
  27292. if (start < 0) {
  27293. start += len;
  27294. if (start < 0) start = 0;
  27295. } else if (start > len) {
  27296. start = len;
  27297. }
  27298. if (end < 0) {
  27299. end += len;
  27300. if (end < 0) end = 0;
  27301. } else if (end > len) {
  27302. end = len;
  27303. }
  27304. if (end < start) end = start;
  27305. var newBuf;
  27306. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27307. newBuf = this.subarray(start, end);
  27308. newBuf.__proto__ = Buffer$1.prototype;
  27309. } else {
  27310. var sliceLen = end - start;
  27311. newBuf = new Buffer$1(sliceLen, undefined);
  27312. for (var i = 0; i < sliceLen; ++i) {
  27313. newBuf[i] = this[i + start];
  27314. }
  27315. }
  27316. return newBuf
  27317. };
  27318. /*
  27319. * Need to make sure that buffer isn't trying to write out of bounds.
  27320. */
  27321. function checkOffset (offset, ext, length) {
  27322. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  27323. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  27324. }
  27325. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  27326. offset = offset | 0;
  27327. byteLength = byteLength | 0;
  27328. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27329. var val = this[offset];
  27330. var mul = 1;
  27331. var i = 0;
  27332. while (++i < byteLength && (mul *= 0x100)) {
  27333. val += this[offset + i] * mul;
  27334. }
  27335. return val
  27336. };
  27337. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  27338. offset = offset | 0;
  27339. byteLength = byteLength | 0;
  27340. if (!noAssert) {
  27341. checkOffset(offset, byteLength, this.length);
  27342. }
  27343. var val = this[offset + --byteLength];
  27344. var mul = 1;
  27345. while (byteLength > 0 && (mul *= 0x100)) {
  27346. val += this[offset + --byteLength] * mul;
  27347. }
  27348. return val
  27349. };
  27350. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  27351. if (!noAssert) checkOffset(offset, 1, this.length);
  27352. return this[offset]
  27353. };
  27354. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  27355. if (!noAssert) checkOffset(offset, 2, this.length);
  27356. return this[offset] | (this[offset + 1] << 8)
  27357. };
  27358. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  27359. if (!noAssert) checkOffset(offset, 2, this.length);
  27360. return (this[offset] << 8) | this[offset + 1]
  27361. };
  27362. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  27363. if (!noAssert) checkOffset(offset, 4, this.length);
  27364. return ((this[offset]) |
  27365. (this[offset + 1] << 8) |
  27366. (this[offset + 2] << 16)) +
  27367. (this[offset + 3] * 0x1000000)
  27368. };
  27369. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  27370. if (!noAssert) checkOffset(offset, 4, this.length);
  27371. return (this[offset] * 0x1000000) +
  27372. ((this[offset + 1] << 16) |
  27373. (this[offset + 2] << 8) |
  27374. this[offset + 3])
  27375. };
  27376. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  27377. offset = offset | 0;
  27378. byteLength = byteLength | 0;
  27379. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27380. var val = this[offset];
  27381. var mul = 1;
  27382. var i = 0;
  27383. while (++i < byteLength && (mul *= 0x100)) {
  27384. val += this[offset + i] * mul;
  27385. }
  27386. mul *= 0x80;
  27387. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27388. return val
  27389. };
  27390. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  27391. offset = offset | 0;
  27392. byteLength = byteLength | 0;
  27393. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27394. var i = byteLength;
  27395. var mul = 1;
  27396. var val = this[offset + --i];
  27397. while (i > 0 && (mul *= 0x100)) {
  27398. val += this[offset + --i] * mul;
  27399. }
  27400. mul *= 0x80;
  27401. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27402. return val
  27403. };
  27404. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  27405. if (!noAssert) checkOffset(offset, 1, this.length);
  27406. if (!(this[offset] & 0x80)) return (this[offset])
  27407. return ((0xff - this[offset] + 1) * -1)
  27408. };
  27409. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  27410. if (!noAssert) checkOffset(offset, 2, this.length);
  27411. var val = this[offset] | (this[offset + 1] << 8);
  27412. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27413. };
  27414. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  27415. if (!noAssert) checkOffset(offset, 2, this.length);
  27416. var val = this[offset + 1] | (this[offset] << 8);
  27417. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27418. };
  27419. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  27420. if (!noAssert) checkOffset(offset, 4, this.length);
  27421. return (this[offset]) |
  27422. (this[offset + 1] << 8) |
  27423. (this[offset + 2] << 16) |
  27424. (this[offset + 3] << 24)
  27425. };
  27426. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  27427. if (!noAssert) checkOffset(offset, 4, this.length);
  27428. return (this[offset] << 24) |
  27429. (this[offset + 1] << 16) |
  27430. (this[offset + 2] << 8) |
  27431. (this[offset + 3])
  27432. };
  27433. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  27434. if (!noAssert) checkOffset(offset, 4, this.length);
  27435. return read(this, offset, true, 23, 4)
  27436. };
  27437. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  27438. if (!noAssert) checkOffset(offset, 4, this.length);
  27439. return read(this, offset, false, 23, 4)
  27440. };
  27441. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  27442. if (!noAssert) checkOffset(offset, 8, this.length);
  27443. return read(this, offset, true, 52, 8)
  27444. };
  27445. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  27446. if (!noAssert) checkOffset(offset, 8, this.length);
  27447. return read(this, offset, false, 52, 8)
  27448. };
  27449. function checkInt (buf, value, offset, ext, max, min) {
  27450. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  27451. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  27452. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27453. }
  27454. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  27455. value = +value;
  27456. offset = offset | 0;
  27457. byteLength = byteLength | 0;
  27458. if (!noAssert) {
  27459. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27460. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27461. }
  27462. var mul = 1;
  27463. var i = 0;
  27464. this[offset] = value & 0xFF;
  27465. while (++i < byteLength && (mul *= 0x100)) {
  27466. this[offset + i] = (value / mul) & 0xFF;
  27467. }
  27468. return offset + byteLength
  27469. };
  27470. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  27471. value = +value;
  27472. offset = offset | 0;
  27473. byteLength = byteLength | 0;
  27474. if (!noAssert) {
  27475. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27476. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27477. }
  27478. var i = byteLength - 1;
  27479. var mul = 1;
  27480. this[offset + i] = value & 0xFF;
  27481. while (--i >= 0 && (mul *= 0x100)) {
  27482. this[offset + i] = (value / mul) & 0xFF;
  27483. }
  27484. return offset + byteLength
  27485. };
  27486. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  27487. value = +value;
  27488. offset = offset | 0;
  27489. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  27490. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27491. this[offset] = (value & 0xff);
  27492. return offset + 1
  27493. };
  27494. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  27495. if (value < 0) value = 0xffff + value + 1;
  27496. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  27497. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  27498. (littleEndian ? i : 1 - i) * 8;
  27499. }
  27500. }
  27501. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  27502. value = +value;
  27503. offset = offset | 0;
  27504. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27505. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27506. this[offset] = (value & 0xff);
  27507. this[offset + 1] = (value >>> 8);
  27508. } else {
  27509. objectWriteUInt16(this, value, offset, true);
  27510. }
  27511. return offset + 2
  27512. };
  27513. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  27514. value = +value;
  27515. offset = offset | 0;
  27516. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27517. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27518. this[offset] = (value >>> 8);
  27519. this[offset + 1] = (value & 0xff);
  27520. } else {
  27521. objectWriteUInt16(this, value, offset, false);
  27522. }
  27523. return offset + 2
  27524. };
  27525. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  27526. if (value < 0) value = 0xffffffff + value + 1;
  27527. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  27528. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  27529. }
  27530. }
  27531. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  27532. value = +value;
  27533. offset = offset | 0;
  27534. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27535. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27536. this[offset + 3] = (value >>> 24);
  27537. this[offset + 2] = (value >>> 16);
  27538. this[offset + 1] = (value >>> 8);
  27539. this[offset] = (value & 0xff);
  27540. } else {
  27541. objectWriteUInt32(this, value, offset, true);
  27542. }
  27543. return offset + 4
  27544. };
  27545. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  27546. value = +value;
  27547. offset = offset | 0;
  27548. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27549. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27550. this[offset] = (value >>> 24);
  27551. this[offset + 1] = (value >>> 16);
  27552. this[offset + 2] = (value >>> 8);
  27553. this[offset + 3] = (value & 0xff);
  27554. } else {
  27555. objectWriteUInt32(this, value, offset, false);
  27556. }
  27557. return offset + 4
  27558. };
  27559. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  27560. value = +value;
  27561. offset = offset | 0;
  27562. if (!noAssert) {
  27563. var limit = Math.pow(2, 8 * byteLength - 1);
  27564. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27565. }
  27566. var i = 0;
  27567. var mul = 1;
  27568. var sub = 0;
  27569. this[offset] = value & 0xFF;
  27570. while (++i < byteLength && (mul *= 0x100)) {
  27571. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  27572. sub = 1;
  27573. }
  27574. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27575. }
  27576. return offset + byteLength
  27577. };
  27578. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  27579. value = +value;
  27580. offset = offset | 0;
  27581. if (!noAssert) {
  27582. var limit = Math.pow(2, 8 * byteLength - 1);
  27583. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27584. }
  27585. var i = byteLength - 1;
  27586. var mul = 1;
  27587. var sub = 0;
  27588. this[offset + i] = value & 0xFF;
  27589. while (--i >= 0 && (mul *= 0x100)) {
  27590. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  27591. sub = 1;
  27592. }
  27593. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27594. }
  27595. return offset + byteLength
  27596. };
  27597. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  27598. value = +value;
  27599. offset = offset | 0;
  27600. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  27601. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27602. if (value < 0) value = 0xff + value + 1;
  27603. this[offset] = (value & 0xff);
  27604. return offset + 1
  27605. };
  27606. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  27607. value = +value;
  27608. offset = offset | 0;
  27609. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27610. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27611. this[offset] = (value & 0xff);
  27612. this[offset + 1] = (value >>> 8);
  27613. } else {
  27614. objectWriteUInt16(this, value, offset, true);
  27615. }
  27616. return offset + 2
  27617. };
  27618. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  27619. value = +value;
  27620. offset = offset | 0;
  27621. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27622. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27623. this[offset] = (value >>> 8);
  27624. this[offset + 1] = (value & 0xff);
  27625. } else {
  27626. objectWriteUInt16(this, value, offset, false);
  27627. }
  27628. return offset + 2
  27629. };
  27630. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  27631. value = +value;
  27632. offset = offset | 0;
  27633. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27634. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27635. this[offset] = (value & 0xff);
  27636. this[offset + 1] = (value >>> 8);
  27637. this[offset + 2] = (value >>> 16);
  27638. this[offset + 3] = (value >>> 24);
  27639. } else {
  27640. objectWriteUInt32(this, value, offset, true);
  27641. }
  27642. return offset + 4
  27643. };
  27644. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  27645. value = +value;
  27646. offset = offset | 0;
  27647. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27648. if (value < 0) value = 0xffffffff + value + 1;
  27649. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27650. this[offset] = (value >>> 24);
  27651. this[offset + 1] = (value >>> 16);
  27652. this[offset + 2] = (value >>> 8);
  27653. this[offset + 3] = (value & 0xff);
  27654. } else {
  27655. objectWriteUInt32(this, value, offset, false);
  27656. }
  27657. return offset + 4
  27658. };
  27659. function checkIEEE754 (buf, value, offset, ext, max, min) {
  27660. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27661. if (offset < 0) throw new RangeError('Index out of range')
  27662. }
  27663. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  27664. if (!noAssert) {
  27665. checkIEEE754(buf, value, offset, 4);
  27666. }
  27667. write(buf, value, offset, littleEndian, 23, 4);
  27668. return offset + 4
  27669. }
  27670. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  27671. return writeFloat(this, value, offset, true, noAssert)
  27672. };
  27673. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  27674. return writeFloat(this, value, offset, false, noAssert)
  27675. };
  27676. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  27677. if (!noAssert) {
  27678. checkIEEE754(buf, value, offset, 8);
  27679. }
  27680. write(buf, value, offset, littleEndian, 52, 8);
  27681. return offset + 8
  27682. }
  27683. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  27684. return writeDouble(this, value, offset, true, noAssert)
  27685. };
  27686. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  27687. return writeDouble(this, value, offset, false, noAssert)
  27688. };
  27689. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  27690. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  27691. if (!start) start = 0;
  27692. if (!end && end !== 0) end = this.length;
  27693. if (targetStart >= target.length) targetStart = target.length;
  27694. if (!targetStart) targetStart = 0;
  27695. if (end > 0 && end < start) end = start;
  27696. // Copy 0 bytes; we're done
  27697. if (end === start) return 0
  27698. if (target.length === 0 || this.length === 0) return 0
  27699. // Fatal error conditions
  27700. if (targetStart < 0) {
  27701. throw new RangeError('targetStart out of bounds')
  27702. }
  27703. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  27704. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  27705. // Are we oob?
  27706. if (end > this.length) end = this.length;
  27707. if (target.length - targetStart < end - start) {
  27708. end = target.length - targetStart + start;
  27709. }
  27710. var len = end - start;
  27711. var i;
  27712. if (this === target && start < targetStart && targetStart < end) {
  27713. // descending copy from end
  27714. for (i = len - 1; i >= 0; --i) {
  27715. target[i + targetStart] = this[i + start];
  27716. }
  27717. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  27718. // ascending copy from start
  27719. for (i = 0; i < len; ++i) {
  27720. target[i + targetStart] = this[i + start];
  27721. }
  27722. } else {
  27723. Uint8Array.prototype.set.call(
  27724. target,
  27725. this.subarray(start, start + len),
  27726. targetStart
  27727. );
  27728. }
  27729. return len
  27730. };
  27731. // Usage:
  27732. // buffer.fill(number[, offset[, end]])
  27733. // buffer.fill(buffer[, offset[, end]])
  27734. // buffer.fill(string[, offset[, end]][, encoding])
  27735. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  27736. // Handle string cases:
  27737. if (typeof val === 'string') {
  27738. if (typeof start === 'string') {
  27739. encoding = start;
  27740. start = 0;
  27741. end = this.length;
  27742. } else if (typeof end === 'string') {
  27743. encoding = end;
  27744. end = this.length;
  27745. }
  27746. if (val.length === 1) {
  27747. var code = val.charCodeAt(0);
  27748. if (code < 256) {
  27749. val = code;
  27750. }
  27751. }
  27752. if (encoding !== undefined && typeof encoding !== 'string') {
  27753. throw new TypeError('encoding must be a string')
  27754. }
  27755. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  27756. throw new TypeError('Unknown encoding: ' + encoding)
  27757. }
  27758. } else if (typeof val === 'number') {
  27759. val = val & 255;
  27760. }
  27761. // Invalid ranges are not set to a default, so can range check early.
  27762. if (start < 0 || this.length < start || this.length < end) {
  27763. throw new RangeError('Out of range index')
  27764. }
  27765. if (end <= start) {
  27766. return this
  27767. }
  27768. start = start >>> 0;
  27769. end = end === undefined ? this.length : end >>> 0;
  27770. if (!val) val = 0;
  27771. var i;
  27772. if (typeof val === 'number') {
  27773. for (i = start; i < end; ++i) {
  27774. this[i] = val;
  27775. }
  27776. } else {
  27777. var bytes = internalIsBuffer(val)
  27778. ? val
  27779. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  27780. var len = bytes.length;
  27781. for (i = 0; i < end - start; ++i) {
  27782. this[i + start] = bytes[i % len];
  27783. }
  27784. }
  27785. return this
  27786. };
  27787. // HELPER FUNCTIONS
  27788. // ================
  27789. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  27790. function base64clean (str) {
  27791. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  27792. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  27793. // Node converts strings with length < 2 to ''
  27794. if (str.length < 2) return ''
  27795. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  27796. while (str.length % 4 !== 0) {
  27797. str = str + '=';
  27798. }
  27799. return str
  27800. }
  27801. function stringtrim (str) {
  27802. if (str.trim) return str.trim()
  27803. return str.replace(/^\s+|\s+$/g, '')
  27804. }
  27805. function toHex (n) {
  27806. if (n < 16) return '0' + n.toString(16)
  27807. return n.toString(16)
  27808. }
  27809. function utf8ToBytes (string, units) {
  27810. units = units || Infinity;
  27811. var codePoint;
  27812. var length = string.length;
  27813. var leadSurrogate = null;
  27814. var bytes = [];
  27815. for (var i = 0; i < length; ++i) {
  27816. codePoint = string.charCodeAt(i);
  27817. // is surrogate component
  27818. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  27819. // last char was a lead
  27820. if (!leadSurrogate) {
  27821. // no lead yet
  27822. if (codePoint > 0xDBFF) {
  27823. // unexpected trail
  27824. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27825. continue
  27826. } else if (i + 1 === length) {
  27827. // unpaired lead
  27828. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27829. continue
  27830. }
  27831. // valid lead
  27832. leadSurrogate = codePoint;
  27833. continue
  27834. }
  27835. // 2 leads in a row
  27836. if (codePoint < 0xDC00) {
  27837. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27838. leadSurrogate = codePoint;
  27839. continue
  27840. }
  27841. // valid surrogate pair
  27842. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  27843. } else if (leadSurrogate) {
  27844. // valid bmp char, but last char was a lead
  27845. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27846. }
  27847. leadSurrogate = null;
  27848. // encode utf8
  27849. if (codePoint < 0x80) {
  27850. if ((units -= 1) < 0) break
  27851. bytes.push(codePoint);
  27852. } else if (codePoint < 0x800) {
  27853. if ((units -= 2) < 0) break
  27854. bytes.push(
  27855. codePoint >> 0x6 | 0xC0,
  27856. codePoint & 0x3F | 0x80
  27857. );
  27858. } else if (codePoint < 0x10000) {
  27859. if ((units -= 3) < 0) break
  27860. bytes.push(
  27861. codePoint >> 0xC | 0xE0,
  27862. codePoint >> 0x6 & 0x3F | 0x80,
  27863. codePoint & 0x3F | 0x80
  27864. );
  27865. } else if (codePoint < 0x110000) {
  27866. if ((units -= 4) < 0) break
  27867. bytes.push(
  27868. codePoint >> 0x12 | 0xF0,
  27869. codePoint >> 0xC & 0x3F | 0x80,
  27870. codePoint >> 0x6 & 0x3F | 0x80,
  27871. codePoint & 0x3F | 0x80
  27872. );
  27873. } else {
  27874. throw new Error('Invalid code point')
  27875. }
  27876. }
  27877. return bytes
  27878. }
  27879. function asciiToBytes (str) {
  27880. var byteArray = [];
  27881. for (var i = 0; i < str.length; ++i) {
  27882. // Node's code seems to be doing this and not & 0x7F..
  27883. byteArray.push(str.charCodeAt(i) & 0xFF);
  27884. }
  27885. return byteArray
  27886. }
  27887. function utf16leToBytes (str, units) {
  27888. var c, hi, lo;
  27889. var byteArray = [];
  27890. for (var i = 0; i < str.length; ++i) {
  27891. if ((units -= 2) < 0) break
  27892. c = str.charCodeAt(i);
  27893. hi = c >> 8;
  27894. lo = c % 256;
  27895. byteArray.push(lo);
  27896. byteArray.push(hi);
  27897. }
  27898. return byteArray
  27899. }
  27900. function base64ToBytes (str) {
  27901. return toByteArray(base64clean(str))
  27902. }
  27903. function blitBuffer (src, dst, offset, length) {
  27904. for (var i = 0; i < length; ++i) {
  27905. if ((i + offset >= dst.length) || (i >= src.length)) break
  27906. dst[i + offset] = src[i];
  27907. }
  27908. return i
  27909. }
  27910. function isnan (val) {
  27911. return val !== val // eslint-disable-line no-self-compare
  27912. }
  27913. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  27914. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27915. // Object.prototype.constructor. Remove this eventually
  27916. function isBuffer$1(obj) {
  27917. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  27918. }
  27919. function isFastBuffer (obj) {
  27920. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27921. }
  27922. // For Node v0.10 support. Remove this eventually.
  27923. function isSlowBuffer (obj) {
  27924. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  27925. }
  27926. var inherits;
  27927. if (typeof Object.create === 'function'){
  27928. inherits = function inherits(ctor, superCtor) {
  27929. // implementation from standard node.js 'util' module
  27930. ctor.super_ = superCtor;
  27931. ctor.prototype = Object.create(superCtor.prototype, {
  27932. constructor: {
  27933. value: ctor,
  27934. enumerable: false,
  27935. writable: true,
  27936. configurable: true
  27937. }
  27938. });
  27939. };
  27940. } else {
  27941. inherits = function inherits(ctor, superCtor) {
  27942. ctor.super_ = superCtor;
  27943. var TempCtor = function () {};
  27944. TempCtor.prototype = superCtor.prototype;
  27945. ctor.prototype = new TempCtor();
  27946. ctor.prototype.constructor = ctor;
  27947. };
  27948. }
  27949. var inherits$1 = inherits;
  27950. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  27951. function getOwnPropertyDescriptors(obj) {
  27952. var keys = Object.keys(obj);
  27953. var descriptors = {};
  27954. for (var i = 0; i < keys.length; i++) {
  27955. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  27956. }
  27957. return descriptors;
  27958. };
  27959. var formatRegExp = /%[sdj%]/g;
  27960. function format$1(f) {
  27961. if (!isString$1(f)) {
  27962. var objects = [];
  27963. for (var i = 0; i < arguments.length; i++) {
  27964. objects.push(inspect(arguments[i]));
  27965. }
  27966. return objects.join(' ');
  27967. }
  27968. var i = 1;
  27969. var args = arguments;
  27970. var len = args.length;
  27971. var str = String(f).replace(formatRegExp, function(x) {
  27972. if (x === '%%') return '%';
  27973. if (i >= len) return x;
  27974. switch (x) {
  27975. case '%s': return String(args[i++]);
  27976. case '%d': return Number(args[i++]);
  27977. case '%j':
  27978. try {
  27979. return JSON.stringify(args[i++]);
  27980. } catch (_) {
  27981. return '[Circular]';
  27982. }
  27983. default:
  27984. return x;
  27985. }
  27986. });
  27987. for (var x = args[i]; i < len; x = args[++i]) {
  27988. if (isNull(x) || !isObject$1(x)) {
  27989. str += ' ' + x;
  27990. } else {
  27991. str += ' ' + inspect(x);
  27992. }
  27993. }
  27994. return str;
  27995. }
  27996. // Mark that a method should not be used.
  27997. // Returns a modified function which warns once by default.
  27998. // If --no-deprecation is set, then it is a no-op.
  27999. function deprecate(fn, msg) {
  28000. // Allow for deprecating things in the process of starting up.
  28001. if (isUndefined(global$1.process)) {
  28002. return function() {
  28003. return deprecate(fn, msg).apply(this, arguments);
  28004. };
  28005. }
  28006. if (browser$1.noDeprecation === true) {
  28007. return fn;
  28008. }
  28009. var warned = false;
  28010. function deprecated() {
  28011. if (!warned) {
  28012. if (browser$1.throwDeprecation) {
  28013. throw new Error(msg);
  28014. } else if (browser$1.traceDeprecation) {
  28015. console.trace(msg);
  28016. } else {
  28017. console.error(msg);
  28018. }
  28019. warned = true;
  28020. }
  28021. return fn.apply(this, arguments);
  28022. }
  28023. return deprecated;
  28024. }
  28025. var debugs = {};
  28026. var debugEnviron;
  28027. function debuglog(set) {
  28028. if (isUndefined(debugEnviron))
  28029. debugEnviron = browser$1.env.NODE_DEBUG || '';
  28030. set = set.toUpperCase();
  28031. if (!debugs[set]) {
  28032. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  28033. var pid = 0;
  28034. debugs[set] = function() {
  28035. var msg = format$1.apply(null, arguments);
  28036. console.error('%s %d: %s', set, pid, msg);
  28037. };
  28038. } else {
  28039. debugs[set] = function() {};
  28040. }
  28041. }
  28042. return debugs[set];
  28043. }
  28044. /**
  28045. * Echos the value of a value. Trys to print the value out
  28046. * in the best way possible given the different types.
  28047. *
  28048. * @param {Object} obj The object to print out.
  28049. * @param {Object} opts Optional options object that alters the output.
  28050. */
  28051. /* legacy: obj, showHidden, depth, colors*/
  28052. function inspect(obj, opts) {
  28053. // default options
  28054. var ctx = {
  28055. seen: [],
  28056. stylize: stylizeNoColor
  28057. };
  28058. // legacy...
  28059. if (arguments.length >= 3) ctx.depth = arguments[2];
  28060. if (arguments.length >= 4) ctx.colors = arguments[3];
  28061. if (isBoolean(opts)) {
  28062. // legacy...
  28063. ctx.showHidden = opts;
  28064. } else if (opts) {
  28065. // got an "options" object
  28066. _extend(ctx, opts);
  28067. }
  28068. // set default options
  28069. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  28070. if (isUndefined(ctx.depth)) ctx.depth = 2;
  28071. if (isUndefined(ctx.colors)) ctx.colors = false;
  28072. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  28073. if (ctx.colors) ctx.stylize = stylizeWithColor;
  28074. return formatValue(ctx, obj, ctx.depth);
  28075. }
  28076. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28077. inspect.colors = {
  28078. 'bold' : [1, 22],
  28079. 'italic' : [3, 23],
  28080. 'underline' : [4, 24],
  28081. 'inverse' : [7, 27],
  28082. 'white' : [37, 39],
  28083. 'grey' : [90, 39],
  28084. 'black' : [30, 39],
  28085. 'blue' : [34, 39],
  28086. 'cyan' : [36, 39],
  28087. 'green' : [32, 39],
  28088. 'magenta' : [35, 39],
  28089. 'red' : [31, 39],
  28090. 'yellow' : [33, 39]
  28091. };
  28092. // Don't use 'blue' not visible on cmd.exe
  28093. inspect.styles = {
  28094. 'special': 'cyan',
  28095. 'number': 'yellow',
  28096. 'boolean': 'yellow',
  28097. 'undefined': 'grey',
  28098. 'null': 'bold',
  28099. 'string': 'green',
  28100. 'date': 'magenta',
  28101. // "name": intentionally not styling
  28102. 'regexp': 'red'
  28103. };
  28104. function stylizeWithColor(str, styleType) {
  28105. var style = inspect.styles[styleType];
  28106. if (style) {
  28107. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  28108. '\u001b[' + inspect.colors[style][1] + 'm';
  28109. } else {
  28110. return str;
  28111. }
  28112. }
  28113. function stylizeNoColor(str, styleType) {
  28114. return str;
  28115. }
  28116. function arrayToHash(array) {
  28117. var hash = {};
  28118. array.forEach(function(val, idx) {
  28119. hash[val] = true;
  28120. });
  28121. return hash;
  28122. }
  28123. function formatValue(ctx, value, recurseTimes) {
  28124. // Provide a hook for user-specified inspect functions.
  28125. // Check that value is an object with an inspect function on it
  28126. if (ctx.customInspect &&
  28127. value &&
  28128. isFunction(value.inspect) &&
  28129. // Filter out the util module, it's inspect function is special
  28130. value.inspect !== inspect &&
  28131. // Also filter out any prototype objects using the circular check.
  28132. !(value.constructor && value.constructor.prototype === value)) {
  28133. var ret = value.inspect(recurseTimes, ctx);
  28134. if (!isString$1(ret)) {
  28135. ret = formatValue(ctx, ret, recurseTimes);
  28136. }
  28137. return ret;
  28138. }
  28139. // Primitive types cannot have properties
  28140. var primitive = formatPrimitive(ctx, value);
  28141. if (primitive) {
  28142. return primitive;
  28143. }
  28144. // Look up the keys of the object.
  28145. var keys = Object.keys(value);
  28146. var visibleKeys = arrayToHash(keys);
  28147. if (ctx.showHidden) {
  28148. keys = Object.getOwnPropertyNames(value);
  28149. }
  28150. // IE doesn't make error fields non-enumerable
  28151. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  28152. if (isError(value)
  28153. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  28154. return formatError(value);
  28155. }
  28156. // Some type of object without properties can be shortcutted.
  28157. if (keys.length === 0) {
  28158. if (isFunction(value)) {
  28159. var name = value.name ? ': ' + value.name : '';
  28160. return ctx.stylize('[Function' + name + ']', 'special');
  28161. }
  28162. if (isRegExp(value)) {
  28163. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28164. }
  28165. if (isDate(value)) {
  28166. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  28167. }
  28168. if (isError(value)) {
  28169. return formatError(value);
  28170. }
  28171. }
  28172. var base = '', array = false, braces = ['{', '}'];
  28173. // Make Array say that they are Array
  28174. if (isArray$1(value)) {
  28175. array = true;
  28176. braces = ['[', ']'];
  28177. }
  28178. // Make functions say that they are functions
  28179. if (isFunction(value)) {
  28180. var n = value.name ? ': ' + value.name : '';
  28181. base = ' [Function' + n + ']';
  28182. }
  28183. // Make RegExps say that they are RegExps
  28184. if (isRegExp(value)) {
  28185. base = ' ' + RegExp.prototype.toString.call(value);
  28186. }
  28187. // Make dates with properties first say the date
  28188. if (isDate(value)) {
  28189. base = ' ' + Date.prototype.toUTCString.call(value);
  28190. }
  28191. // Make error with message first say the error
  28192. if (isError(value)) {
  28193. base = ' ' + formatError(value);
  28194. }
  28195. if (keys.length === 0 && (!array || value.length == 0)) {
  28196. return braces[0] + base + braces[1];
  28197. }
  28198. if (recurseTimes < 0) {
  28199. if (isRegExp(value)) {
  28200. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28201. } else {
  28202. return ctx.stylize('[Object]', 'special');
  28203. }
  28204. }
  28205. ctx.seen.push(value);
  28206. var output;
  28207. if (array) {
  28208. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  28209. } else {
  28210. output = keys.map(function(key) {
  28211. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  28212. });
  28213. }
  28214. ctx.seen.pop();
  28215. return reduceToSingleString(output, base, braces);
  28216. }
  28217. function formatPrimitive(ctx, value) {
  28218. if (isUndefined(value))
  28219. return ctx.stylize('undefined', 'undefined');
  28220. if (isString$1(value)) {
  28221. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  28222. .replace(/'/g, "\\'")
  28223. .replace(/\\"/g, '"') + '\'';
  28224. return ctx.stylize(simple, 'string');
  28225. }
  28226. if (isNumber(value))
  28227. return ctx.stylize('' + value, 'number');
  28228. if (isBoolean(value))
  28229. return ctx.stylize('' + value, 'boolean');
  28230. // For some reason typeof null is "object", so special case here.
  28231. if (isNull(value))
  28232. return ctx.stylize('null', 'null');
  28233. }
  28234. function formatError(value) {
  28235. return '[' + Error.prototype.toString.call(value) + ']';
  28236. }
  28237. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  28238. var output = [];
  28239. for (var i = 0, l = value.length; i < l; ++i) {
  28240. if (hasOwnProperty$2(value, String(i))) {
  28241. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28242. String(i), true));
  28243. } else {
  28244. output.push('');
  28245. }
  28246. }
  28247. keys.forEach(function(key) {
  28248. if (!key.match(/^\d+$/)) {
  28249. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28250. key, true));
  28251. }
  28252. });
  28253. return output;
  28254. }
  28255. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  28256. var name, str, desc;
  28257. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  28258. if (desc.get) {
  28259. if (desc.set) {
  28260. str = ctx.stylize('[Getter/Setter]', 'special');
  28261. } else {
  28262. str = ctx.stylize('[Getter]', 'special');
  28263. }
  28264. } else {
  28265. if (desc.set) {
  28266. str = ctx.stylize('[Setter]', 'special');
  28267. }
  28268. }
  28269. if (!hasOwnProperty$2(visibleKeys, key)) {
  28270. name = '[' + key + ']';
  28271. }
  28272. if (!str) {
  28273. if (ctx.seen.indexOf(desc.value) < 0) {
  28274. if (isNull(recurseTimes)) {
  28275. str = formatValue(ctx, desc.value, null);
  28276. } else {
  28277. str = formatValue(ctx, desc.value, recurseTimes - 1);
  28278. }
  28279. if (str.indexOf('\n') > -1) {
  28280. if (array) {
  28281. str = str.split('\n').map(function(line) {
  28282. return ' ' + line;
  28283. }).join('\n').substr(2);
  28284. } else {
  28285. str = '\n' + str.split('\n').map(function(line) {
  28286. return ' ' + line;
  28287. }).join('\n');
  28288. }
  28289. }
  28290. } else {
  28291. str = ctx.stylize('[Circular]', 'special');
  28292. }
  28293. }
  28294. if (isUndefined(name)) {
  28295. if (array && key.match(/^\d+$/)) {
  28296. return str;
  28297. }
  28298. name = JSON.stringify('' + key);
  28299. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  28300. name = name.substr(1, name.length - 2);
  28301. name = ctx.stylize(name, 'name');
  28302. } else {
  28303. name = name.replace(/'/g, "\\'")
  28304. .replace(/\\"/g, '"')
  28305. .replace(/(^"|"$)/g, "'");
  28306. name = ctx.stylize(name, 'string');
  28307. }
  28308. }
  28309. return name + ': ' + str;
  28310. }
  28311. function reduceToSingleString(output, base, braces) {
  28312. var length = output.reduce(function(prev, cur) {
  28313. if (cur.indexOf('\n') >= 0) ;
  28314. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  28315. }, 0);
  28316. if (length > 60) {
  28317. return braces[0] +
  28318. (base === '' ? '' : base + '\n ') +
  28319. ' ' +
  28320. output.join(',\n ') +
  28321. ' ' +
  28322. braces[1];
  28323. }
  28324. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  28325. }
  28326. // NOTE: These type checking functions intentionally don't use `instanceof`
  28327. // because it is fragile and can be easily faked with `Object.create()`.
  28328. function isArray$1(ar) {
  28329. return Array.isArray(ar);
  28330. }
  28331. function isBoolean(arg) {
  28332. return typeof arg === 'boolean';
  28333. }
  28334. function isNull(arg) {
  28335. return arg === null;
  28336. }
  28337. function isNullOrUndefined(arg) {
  28338. return arg == null;
  28339. }
  28340. function isNumber(arg) {
  28341. return typeof arg === 'number';
  28342. }
  28343. function isString$1(arg) {
  28344. return typeof arg === 'string';
  28345. }
  28346. function isSymbol(arg) {
  28347. return typeof arg === 'symbol';
  28348. }
  28349. function isUndefined(arg) {
  28350. return arg === void 0;
  28351. }
  28352. function isRegExp(re) {
  28353. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  28354. }
  28355. function isObject$1(arg) {
  28356. return typeof arg === 'object' && arg !== null;
  28357. }
  28358. function isDate(d) {
  28359. return isObject$1(d) && objectToString(d) === '[object Date]';
  28360. }
  28361. function isError(e) {
  28362. return isObject$1(e) &&
  28363. (objectToString(e) === '[object Error]' || e instanceof Error);
  28364. }
  28365. function isFunction(arg) {
  28366. return typeof arg === 'function';
  28367. }
  28368. function isPrimitive(arg) {
  28369. return arg === null ||
  28370. typeof arg === 'boolean' ||
  28371. typeof arg === 'number' ||
  28372. typeof arg === 'string' ||
  28373. typeof arg === 'symbol' || // ES6 symbol
  28374. typeof arg === 'undefined';
  28375. }
  28376. function isBuffer(maybeBuf) {
  28377. return Buffer$1.isBuffer(maybeBuf);
  28378. }
  28379. function objectToString(o) {
  28380. return Object.prototype.toString.call(o);
  28381. }
  28382. function pad(n) {
  28383. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  28384. }
  28385. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  28386. 'Oct', 'Nov', 'Dec'];
  28387. // 26 Feb 16:19:34
  28388. function timestamp() {
  28389. var d = new Date();
  28390. var time = [pad(d.getHours()),
  28391. pad(d.getMinutes()),
  28392. pad(d.getSeconds())].join(':');
  28393. return [d.getDate(), months[d.getMonth()], time].join(' ');
  28394. }
  28395. // log is just a thin wrapper to console.log that prepends a timestamp
  28396. function log() {
  28397. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  28398. }
  28399. function _extend(origin, add) {
  28400. // Don't do anything if add isn't an object
  28401. if (!add || !isObject$1(add)) return origin;
  28402. var keys = Object.keys(add);
  28403. var i = keys.length;
  28404. while (i--) {
  28405. origin[keys[i]] = add[keys[i]];
  28406. }
  28407. return origin;
  28408. }
  28409. function hasOwnProperty$2(obj, prop) {
  28410. return Object.prototype.hasOwnProperty.call(obj, prop);
  28411. }
  28412. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  28413. function promisify(original) {
  28414. if (typeof original !== 'function')
  28415. throw new TypeError('The "original" argument must be of type Function');
  28416. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  28417. var fn = original[kCustomPromisifiedSymbol];
  28418. if (typeof fn !== 'function') {
  28419. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  28420. }
  28421. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28422. value: fn, enumerable: false, writable: false, configurable: true
  28423. });
  28424. return fn;
  28425. }
  28426. function fn() {
  28427. var promiseResolve, promiseReject;
  28428. var promise = new Promise(function (resolve, reject) {
  28429. promiseResolve = resolve;
  28430. promiseReject = reject;
  28431. });
  28432. var args = [];
  28433. for (var i = 0; i < arguments.length; i++) {
  28434. args.push(arguments[i]);
  28435. }
  28436. args.push(function (err, value) {
  28437. if (err) {
  28438. promiseReject(err);
  28439. } else {
  28440. promiseResolve(value);
  28441. }
  28442. });
  28443. try {
  28444. original.apply(this, args);
  28445. } catch (err) {
  28446. promiseReject(err);
  28447. }
  28448. return promise;
  28449. }
  28450. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  28451. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28452. value: fn, enumerable: false, writable: false, configurable: true
  28453. });
  28454. return Object.defineProperties(
  28455. fn,
  28456. getOwnPropertyDescriptors(original)
  28457. );
  28458. }
  28459. promisify.custom = kCustomPromisifiedSymbol;
  28460. function callbackifyOnRejected(reason, cb) {
  28461. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  28462. // Because `null` is a special error value in callbacks which means "no error
  28463. // occurred", we error-wrap so the callback consumer can distinguish between
  28464. // "the promise rejected with null" or "the promise fulfilled with undefined".
  28465. if (!reason) {
  28466. var newReason = new Error('Promise was rejected with a falsy value');
  28467. newReason.reason = reason;
  28468. reason = newReason;
  28469. }
  28470. return cb(reason);
  28471. }
  28472. function callbackify(original) {
  28473. if (typeof original !== 'function') {
  28474. throw new TypeError('The "original" argument must be of type Function');
  28475. }
  28476. // We DO NOT return the promise as it gives the user a false sense that
  28477. // the promise is actually somehow related to the callback's execution
  28478. // and that the callback throwing will reject the promise.
  28479. function callbackified() {
  28480. var args = [];
  28481. for (var i = 0; i < arguments.length; i++) {
  28482. args.push(arguments[i]);
  28483. }
  28484. var maybeCb = args.pop();
  28485. if (typeof maybeCb !== 'function') {
  28486. throw new TypeError('The last argument must be of type Function');
  28487. }
  28488. var self = this;
  28489. var cb = function() {
  28490. return maybeCb.apply(self, arguments);
  28491. };
  28492. // In true node style we process the callback on `nextTick` with all the
  28493. // implications (stack, `uncaughtException`, `async_hooks`)
  28494. original.apply(this, args)
  28495. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  28496. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  28497. }
  28498. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  28499. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  28500. return callbackified;
  28501. }
  28502. var _polyfillNode_util = {
  28503. inherits: inherits$1,
  28504. _extend: _extend,
  28505. log: log,
  28506. isBuffer: isBuffer,
  28507. isPrimitive: isPrimitive,
  28508. isFunction: isFunction,
  28509. isError: isError,
  28510. isDate: isDate,
  28511. isObject: isObject$1,
  28512. isRegExp: isRegExp,
  28513. isUndefined: isUndefined,
  28514. isSymbol: isSymbol,
  28515. isString: isString$1,
  28516. isNumber: isNumber,
  28517. isNullOrUndefined: isNullOrUndefined,
  28518. isNull: isNull,
  28519. isBoolean: isBoolean,
  28520. isArray: isArray$1,
  28521. inspect: inspect,
  28522. deprecate: deprecate,
  28523. format: format$1,
  28524. debuglog: debuglog,
  28525. promisify: promisify,
  28526. callbackify: callbackify,
  28527. };
  28528. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  28529. __proto__: null,
  28530. _extend: _extend,
  28531. callbackify: callbackify,
  28532. debuglog: debuglog,
  28533. default: _polyfillNode_util,
  28534. deprecate: deprecate,
  28535. format: format$1,
  28536. inherits: inherits$1,
  28537. inspect: inspect,
  28538. isArray: isArray$1,
  28539. isBoolean: isBoolean,
  28540. isBuffer: isBuffer,
  28541. isDate: isDate,
  28542. isError: isError,
  28543. isFunction: isFunction,
  28544. isNull: isNull,
  28545. isNullOrUndefined: isNullOrUndefined,
  28546. isNumber: isNumber,
  28547. isObject: isObject$1,
  28548. isPrimitive: isPrimitive,
  28549. isRegExp: isRegExp,
  28550. isString: isString$1,
  28551. isSymbol: isSymbol,
  28552. isUndefined: isUndefined,
  28553. log: log,
  28554. promisify: promisify
  28555. });
  28556. // Copyright Joyent, Inc. and other Node contributors.
  28557. //
  28558. // Permission is hereby granted, free of charge, to any person obtaining a
  28559. // copy of this software and associated documentation files (the
  28560. // "Software"), to deal in the Software without restriction, including
  28561. // without limitation the rights to use, copy, modify, merge, publish,
  28562. // distribute, sublicense, and/or sell copies of the Software, and to permit
  28563. // persons to whom the Software is furnished to do so, subject to the
  28564. // following conditions:
  28565. //
  28566. // The above copyright notice and this permission notice shall be included
  28567. // in all copies or substantial portions of the Software.
  28568. //
  28569. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  28570. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28571. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  28572. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  28573. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28574. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  28575. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  28576. // If obj.hasOwnProperty has been overridden, then calling
  28577. // obj.hasOwnProperty(prop) will break.
  28578. // See: https://github.com/joyent/node/issues/1707
  28579. function hasOwnProperty$1(obj, prop) {
  28580. return Object.prototype.hasOwnProperty.call(obj, prop);
  28581. }
  28582. var isArray = Array.isArray || function (xs) {
  28583. return Object.prototype.toString.call(xs) === '[object Array]';
  28584. };
  28585. function stringifyPrimitive(v) {
  28586. switch (typeof v) {
  28587. case 'string':
  28588. return v;
  28589. case 'boolean':
  28590. return v ? 'true' : 'false';
  28591. case 'number':
  28592. return isFinite(v) ? v : '';
  28593. default:
  28594. return '';
  28595. }
  28596. }
  28597. function stringify$5 (obj, sep, eq, name) {
  28598. sep = sep || '&';
  28599. eq = eq || '=';
  28600. if (obj === null) {
  28601. obj = undefined;
  28602. }
  28603. if (typeof obj === 'object') {
  28604. return map(objectKeys(obj), function(k) {
  28605. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  28606. if (isArray(obj[k])) {
  28607. return map(obj[k], function(v) {
  28608. return ks + encodeURIComponent(stringifyPrimitive(v));
  28609. }).join(sep);
  28610. } else {
  28611. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  28612. }
  28613. }).join(sep);
  28614. }
  28615. if (!name) return '';
  28616. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  28617. encodeURIComponent(stringifyPrimitive(obj));
  28618. }
  28619. function map (xs, f) {
  28620. if (xs.map) return xs.map(f);
  28621. var res = [];
  28622. for (var i = 0; i < xs.length; i++) {
  28623. res.push(f(xs[i], i));
  28624. }
  28625. return res;
  28626. }
  28627. var objectKeys = Object.keys || function (obj) {
  28628. var res = [];
  28629. for (var key in obj) {
  28630. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  28631. }
  28632. return res;
  28633. };
  28634. function parse$6(qs, sep, eq, options) {
  28635. sep = sep || '&';
  28636. eq = eq || '=';
  28637. var obj = {};
  28638. if (typeof qs !== 'string' || qs.length === 0) {
  28639. return obj;
  28640. }
  28641. var regexp = /\+/g;
  28642. qs = qs.split(sep);
  28643. var maxKeys = 1000;
  28644. if (options && typeof options.maxKeys === 'number') {
  28645. maxKeys = options.maxKeys;
  28646. }
  28647. var len = qs.length;
  28648. // maxKeys <= 0 means that we should not limit keys count
  28649. if (maxKeys > 0 && len > maxKeys) {
  28650. len = maxKeys;
  28651. }
  28652. for (var i = 0; i < len; ++i) {
  28653. var x = qs[i].replace(regexp, '%20'),
  28654. idx = x.indexOf(eq),
  28655. kstr, vstr, k, v;
  28656. if (idx >= 0) {
  28657. kstr = x.substr(0, idx);
  28658. vstr = x.substr(idx + 1);
  28659. } else {
  28660. kstr = x;
  28661. vstr = '';
  28662. }
  28663. k = decodeURIComponent(kstr);
  28664. v = decodeURIComponent(vstr);
  28665. if (!hasOwnProperty$1(obj, k)) {
  28666. obj[k] = v;
  28667. } else if (isArray(obj[k])) {
  28668. obj[k].push(v);
  28669. } else {
  28670. obj[k] = [obj[k], v];
  28671. }
  28672. }
  28673. return obj;
  28674. }
  28675. // WHATWG API
  28676. const URL$1 = global$1.URL;
  28677. const URLSearchParams = global$1.URLSearchParams;
  28678. var _polyfillNode_url = {
  28679. parse: urlParse,
  28680. resolve: urlResolve,
  28681. resolveObject: urlResolveObject,
  28682. fileURLToPath: urlFileURLToPath,
  28683. format: urlFormat,
  28684. Url: Url,
  28685. // WHATWG API
  28686. URL: URL$1,
  28687. URLSearchParams,
  28688. };
  28689. function Url() {
  28690. this.protocol = null;
  28691. this.slashes = null;
  28692. this.auth = null;
  28693. this.host = null;
  28694. this.port = null;
  28695. this.hostname = null;
  28696. this.hash = null;
  28697. this.search = null;
  28698. this.query = null;
  28699. this.pathname = null;
  28700. this.path = null;
  28701. this.href = null;
  28702. }
  28703. // Reference: RFC 3986, RFC 1808, RFC 2396
  28704. // define these here so at least they only have to be
  28705. // compiled once on the first module load.
  28706. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  28707. portPattern = /:[0-9]*$/,
  28708. // Special case for a simple path URL
  28709. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  28710. // RFC 2396: characters reserved for delimiting URLs.
  28711. // We actually just auto-escape these.
  28712. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  28713. // RFC 2396: characters not allowed for various reasons.
  28714. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  28715. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  28716. autoEscape = ['\''].concat(unwise),
  28717. // Characters that are never ever allowed in a hostname.
  28718. // Note that any invalid chars are also handled, but these
  28719. // are the ones that are *expected* to be seen, so we fast-path
  28720. // them.
  28721. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  28722. hostEndingChars = ['/', '?', '#'],
  28723. hostnameMaxLen = 255,
  28724. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  28725. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  28726. // protocols that can allow "unsafe" and "unwise" chars.
  28727. unsafeProtocol = {
  28728. 'javascript': true,
  28729. 'javascript:': true
  28730. },
  28731. // protocols that never have a hostname.
  28732. hostlessProtocol = {
  28733. 'javascript': true,
  28734. 'javascript:': true
  28735. },
  28736. // protocols that always contain a // bit.
  28737. slashedProtocol = {
  28738. 'http': true,
  28739. 'https': true,
  28740. 'ftp': true,
  28741. 'gopher': true,
  28742. 'file': true,
  28743. 'http:': true,
  28744. 'https:': true,
  28745. 'ftp:': true,
  28746. 'gopher:': true,
  28747. 'file:': true
  28748. };
  28749. function urlParse(url, parseQueryString, slashesDenoteHost) {
  28750. if (url && isObject$1(url) && url instanceof Url) return url;
  28751. var u = new Url;
  28752. u.parse(url, parseQueryString, slashesDenoteHost);
  28753. return u;
  28754. }
  28755. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  28756. return parse$5(this, url, parseQueryString, slashesDenoteHost);
  28757. };
  28758. function parse$5(self, url, parseQueryString, slashesDenoteHost) {
  28759. if (!isString$1(url)) {
  28760. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  28761. }
  28762. // Copy chrome, IE, opera backslash-handling behavior.
  28763. // Back slashes before the query string get converted to forward slashes
  28764. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  28765. var queryIndex = url.indexOf('?'),
  28766. splitter =
  28767. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  28768. uSplit = url.split(splitter),
  28769. slashRegex = /\\/g;
  28770. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  28771. url = uSplit.join(splitter);
  28772. var rest = url;
  28773. // trim before proceeding.
  28774. // This is to support parse stuff like " http://foo.com \n"
  28775. rest = rest.trim();
  28776. if (!slashesDenoteHost && url.split('#').length === 1) {
  28777. // Try fast path regexp
  28778. var simplePath = simplePathPattern.exec(rest);
  28779. if (simplePath) {
  28780. self.path = rest;
  28781. self.href = rest;
  28782. self.pathname = simplePath[1];
  28783. if (simplePath[2]) {
  28784. self.search = simplePath[2];
  28785. if (parseQueryString) {
  28786. self.query = parse$6(self.search.substr(1));
  28787. } else {
  28788. self.query = self.search.substr(1);
  28789. }
  28790. } else if (parseQueryString) {
  28791. self.search = '';
  28792. self.query = {};
  28793. }
  28794. return self;
  28795. }
  28796. }
  28797. var proto = protocolPattern.exec(rest);
  28798. if (proto) {
  28799. proto = proto[0];
  28800. var lowerProto = proto.toLowerCase();
  28801. self.protocol = lowerProto;
  28802. rest = rest.substr(proto.length);
  28803. }
  28804. // figure out if it's got a host
  28805. // user@server is *always* interpreted as a hostname, and url
  28806. // resolution will treat //foo/bar as host=foo,path=bar because that's
  28807. // how the browser resolves relative URLs.
  28808. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  28809. var slashes = rest.substr(0, 2) === '//';
  28810. if (slashes && !(proto && hostlessProtocol[proto])) {
  28811. rest = rest.substr(2);
  28812. self.slashes = true;
  28813. }
  28814. }
  28815. var i, hec, l, p;
  28816. if (!hostlessProtocol[proto] &&
  28817. (slashes || (proto && !slashedProtocol[proto]))) {
  28818. // there's a hostname.
  28819. // the first instance of /, ?, ;, or # ends the host.
  28820. //
  28821. // If there is an @ in the hostname, then non-host chars *are* allowed
  28822. // to the left of the last @ sign, unless some host-ending character
  28823. // comes *before* the @-sign.
  28824. // URLs are obnoxious.
  28825. //
  28826. // ex:
  28827. // http://a@b@c/ => user:a@b host:c
  28828. // http://a@b?@c => user:a host:c path:/?@c
  28829. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  28830. // Review our test case against browsers more comprehensively.
  28831. // find the first instance of any hostEndingChars
  28832. var hostEnd = -1;
  28833. for (i = 0; i < hostEndingChars.length; i++) {
  28834. hec = rest.indexOf(hostEndingChars[i]);
  28835. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28836. hostEnd = hec;
  28837. }
  28838. // at this point, either we have an explicit point where the
  28839. // auth portion cannot go past, or the last @ char is the decider.
  28840. var auth, atSign;
  28841. if (hostEnd === -1) {
  28842. // atSign can be anywhere.
  28843. atSign = rest.lastIndexOf('@');
  28844. } else {
  28845. // atSign must be in auth portion.
  28846. // http://a@b/c@d => host:b auth:a path:/c@d
  28847. atSign = rest.lastIndexOf('@', hostEnd);
  28848. }
  28849. // Now we have a portion which is definitely the auth.
  28850. // Pull that off.
  28851. if (atSign !== -1) {
  28852. auth = rest.slice(0, atSign);
  28853. rest = rest.slice(atSign + 1);
  28854. self.auth = decodeURIComponent(auth);
  28855. }
  28856. // the host is the remaining to the left of the first non-host char
  28857. hostEnd = -1;
  28858. for (i = 0; i < nonHostChars.length; i++) {
  28859. hec = rest.indexOf(nonHostChars[i]);
  28860. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28861. hostEnd = hec;
  28862. }
  28863. // if we still have not hit it, then the entire thing is a host.
  28864. if (hostEnd === -1)
  28865. hostEnd = rest.length;
  28866. self.host = rest.slice(0, hostEnd);
  28867. rest = rest.slice(hostEnd);
  28868. // pull out port.
  28869. parseHost(self);
  28870. // we've indicated that there is a hostname,
  28871. // so even if it's empty, it has to be present.
  28872. self.hostname = self.hostname || '';
  28873. // if hostname begins with [ and ends with ]
  28874. // assume that it's an IPv6 address.
  28875. var ipv6Hostname = self.hostname[0] === '[' &&
  28876. self.hostname[self.hostname.length - 1] === ']';
  28877. // validate a little.
  28878. if (!ipv6Hostname) {
  28879. var hostparts = self.hostname.split(/\./);
  28880. for (i = 0, l = hostparts.length; i < l; i++) {
  28881. var part = hostparts[i];
  28882. if (!part) continue;
  28883. if (!part.match(hostnamePartPattern)) {
  28884. var newpart = '';
  28885. for (var j = 0, k = part.length; j < k; j++) {
  28886. if (part.charCodeAt(j) > 127) {
  28887. // we replace non-ASCII char with a temporary placeholder
  28888. // we need this to make sure size of hostname is not
  28889. // broken by replacing non-ASCII by nothing
  28890. newpart += 'x';
  28891. } else {
  28892. newpart += part[j];
  28893. }
  28894. }
  28895. // we test again with ASCII char only
  28896. if (!newpart.match(hostnamePartPattern)) {
  28897. var validParts = hostparts.slice(0, i);
  28898. var notHost = hostparts.slice(i + 1);
  28899. var bit = part.match(hostnamePartStart);
  28900. if (bit) {
  28901. validParts.push(bit[1]);
  28902. notHost.unshift(bit[2]);
  28903. }
  28904. if (notHost.length) {
  28905. rest = '/' + notHost.join('.') + rest;
  28906. }
  28907. self.hostname = validParts.join('.');
  28908. break;
  28909. }
  28910. }
  28911. }
  28912. }
  28913. if (self.hostname.length > hostnameMaxLen) {
  28914. self.hostname = '';
  28915. } else {
  28916. // hostnames are always lower case.
  28917. self.hostname = self.hostname.toLowerCase();
  28918. }
  28919. if (!ipv6Hostname) {
  28920. // IDNA Support: Returns a punycoded representation of "domain".
  28921. // It only converts parts of the domain name that
  28922. // have non-ASCII characters, i.e. it doesn't matter if
  28923. // you call it with a domain that already is ASCII-only.
  28924. self.hostname = toASCII(self.hostname);
  28925. }
  28926. p = self.port ? ':' + self.port : '';
  28927. var h = self.hostname || '';
  28928. self.host = h + p;
  28929. self.href += self.host;
  28930. // strip [ and ] from the hostname
  28931. // the host field still retains them, though
  28932. if (ipv6Hostname) {
  28933. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  28934. if (rest[0] !== '/') {
  28935. rest = '/' + rest;
  28936. }
  28937. }
  28938. }
  28939. // now rest is set to the post-host stuff.
  28940. // chop off any delim chars.
  28941. if (!unsafeProtocol[lowerProto]) {
  28942. // First, make 100% sure that any "autoEscape" chars get
  28943. // escaped, even if encodeURIComponent doesn't think they
  28944. // need to be.
  28945. for (i = 0, l = autoEscape.length; i < l; i++) {
  28946. var ae = autoEscape[i];
  28947. if (rest.indexOf(ae) === -1)
  28948. continue;
  28949. var esc = encodeURIComponent(ae);
  28950. if (esc === ae) {
  28951. esc = escape(ae);
  28952. }
  28953. rest = rest.split(ae).join(esc);
  28954. }
  28955. }
  28956. // chop off from the tail first.
  28957. var hash = rest.indexOf('#');
  28958. if (hash !== -1) {
  28959. // got a fragment string.
  28960. self.hash = rest.substr(hash);
  28961. rest = rest.slice(0, hash);
  28962. }
  28963. var qm = rest.indexOf('?');
  28964. if (qm !== -1) {
  28965. self.search = rest.substr(qm);
  28966. self.query = rest.substr(qm + 1);
  28967. if (parseQueryString) {
  28968. self.query = parse$6(self.query);
  28969. }
  28970. rest = rest.slice(0, qm);
  28971. } else if (parseQueryString) {
  28972. // no query string, but parseQueryString still requested
  28973. self.search = '';
  28974. self.query = {};
  28975. }
  28976. if (rest) self.pathname = rest;
  28977. if (slashedProtocol[lowerProto] &&
  28978. self.hostname && !self.pathname) {
  28979. self.pathname = '/';
  28980. }
  28981. //to support http.request
  28982. if (self.pathname || self.search) {
  28983. p = self.pathname || '';
  28984. var s = self.search || '';
  28985. self.path = p + s;
  28986. }
  28987. // finally, reconstruct the href based on what has been validated.
  28988. self.href = format(self);
  28989. return self;
  28990. }
  28991. function urlFileURLToPath(path) {
  28992. if (typeof path === 'string')
  28993. path = new Url().parse(path);
  28994. else if (!(path instanceof Url))
  28995. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  28996. if (path.protocol !== 'file:')
  28997. throw new TypeError('The URL must be of scheme file');
  28998. return getPathFromURLPosix(path);
  28999. }
  29000. function getPathFromURLPosix(url) {
  29001. const pathname = url.pathname;
  29002. for (let n = 0; n < pathname.length; n++) {
  29003. if (pathname[n] === '%') {
  29004. const third = pathname.codePointAt(n + 2) | 0x20;
  29005. if (pathname[n + 1] === '2' && third === 102) {
  29006. throw new TypeError(
  29007. 'must not include encoded / characters'
  29008. );
  29009. }
  29010. }
  29011. }
  29012. return decodeURIComponent(pathname);
  29013. }
  29014. // format a parsed object into a url string
  29015. function urlFormat(obj) {
  29016. // ensure it's an object, and not a string url.
  29017. // If it's an obj, this is a no-op.
  29018. // this way, you can call url_format() on strings
  29019. // to clean up potentially wonky urls.
  29020. if (isString$1(obj)) obj = parse$5({}, obj);
  29021. return format(obj);
  29022. }
  29023. function format(self) {
  29024. var auth = self.auth || '';
  29025. if (auth) {
  29026. auth = encodeURIComponent(auth);
  29027. auth = auth.replace(/%3A/i, ':');
  29028. auth += '@';
  29029. }
  29030. var protocol = self.protocol || '',
  29031. pathname = self.pathname || '',
  29032. hash = self.hash || '',
  29033. host = false,
  29034. query = '';
  29035. if (self.host) {
  29036. host = auth + self.host;
  29037. } else if (self.hostname) {
  29038. host = auth + (self.hostname.indexOf(':') === -1 ?
  29039. self.hostname :
  29040. '[' + this.hostname + ']');
  29041. if (self.port) {
  29042. host += ':' + self.port;
  29043. }
  29044. }
  29045. if (self.query &&
  29046. isObject$1(self.query) &&
  29047. Object.keys(self.query).length) {
  29048. query = stringify$5(self.query);
  29049. }
  29050. var search = self.search || (query && ('?' + query)) || '';
  29051. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  29052. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  29053. // unless they had them to begin with.
  29054. if (self.slashes ||
  29055. (!protocol || slashedProtocol[protocol]) && host !== false) {
  29056. host = '//' + (host || '');
  29057. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  29058. } else if (!host) {
  29059. host = '';
  29060. }
  29061. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  29062. if (search && search.charAt(0) !== '?') search = '?' + search;
  29063. pathname = pathname.replace(/[?#]/g, function(match) {
  29064. return encodeURIComponent(match);
  29065. });
  29066. search = search.replace('#', '%23');
  29067. return protocol + host + pathname + search + hash;
  29068. }
  29069. Url.prototype.format = function() {
  29070. return format(this);
  29071. };
  29072. function urlResolve(source, relative) {
  29073. return urlParse(source, false, true).resolve(relative);
  29074. }
  29075. Url.prototype.resolve = function(relative) {
  29076. return this.resolveObject(urlParse(relative, false, true)).format();
  29077. };
  29078. function urlResolveObject(source, relative) {
  29079. if (!source) return relative;
  29080. return urlParse(source, false, true).resolveObject(relative);
  29081. }
  29082. Url.prototype.resolveObject = function(relative) {
  29083. if (isString$1(relative)) {
  29084. var rel = new Url();
  29085. rel.parse(relative, false, true);
  29086. relative = rel;
  29087. }
  29088. var result = new Url();
  29089. var tkeys = Object.keys(this);
  29090. for (var tk = 0; tk < tkeys.length; tk++) {
  29091. var tkey = tkeys[tk];
  29092. result[tkey] = this[tkey];
  29093. }
  29094. // hash is always overridden, no matter what.
  29095. // even href="" will remove it.
  29096. result.hash = relative.hash;
  29097. // if the relative url is empty, then there's nothing left to do here.
  29098. if (relative.href === '') {
  29099. result.href = result.format();
  29100. return result;
  29101. }
  29102. // hrefs like //foo/bar always cut to the protocol.
  29103. if (relative.slashes && !relative.protocol) {
  29104. // take everything except the protocol from relative
  29105. var rkeys = Object.keys(relative);
  29106. for (var rk = 0; rk < rkeys.length; rk++) {
  29107. var rkey = rkeys[rk];
  29108. if (rkey !== 'protocol')
  29109. result[rkey] = relative[rkey];
  29110. }
  29111. //urlParse appends trailing / to urls like http://www.example.com
  29112. if (slashedProtocol[result.protocol] &&
  29113. result.hostname && !result.pathname) {
  29114. result.path = result.pathname = '/';
  29115. }
  29116. result.href = result.format();
  29117. return result;
  29118. }
  29119. var relPath;
  29120. if (relative.protocol && relative.protocol !== result.protocol) {
  29121. // if it's a known url protocol, then changing
  29122. // the protocol does weird things
  29123. // first, if it's not file:, then we MUST have a host,
  29124. // and if there was a path
  29125. // to begin with, then we MUST have a path.
  29126. // if it is file:, then the host is dropped,
  29127. // because that's known to be hostless.
  29128. // anything else is assumed to be absolute.
  29129. if (!slashedProtocol[relative.protocol]) {
  29130. var keys = Object.keys(relative);
  29131. for (var v = 0; v < keys.length; v++) {
  29132. var k = keys[v];
  29133. result[k] = relative[k];
  29134. }
  29135. result.href = result.format();
  29136. return result;
  29137. }
  29138. result.protocol = relative.protocol;
  29139. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  29140. relPath = (relative.pathname || '').split('/');
  29141. while (relPath.length && !(relative.host = relPath.shift()));
  29142. if (!relative.host) relative.host = '';
  29143. if (!relative.hostname) relative.hostname = '';
  29144. if (relPath[0] !== '') relPath.unshift('');
  29145. if (relPath.length < 2) relPath.unshift('');
  29146. result.pathname = relPath.join('/');
  29147. } else {
  29148. result.pathname = relative.pathname;
  29149. }
  29150. result.search = relative.search;
  29151. result.query = relative.query;
  29152. result.host = relative.host || '';
  29153. result.auth = relative.auth;
  29154. result.hostname = relative.hostname || relative.host;
  29155. result.port = relative.port;
  29156. // to support http.request
  29157. if (result.pathname || result.search) {
  29158. var p = result.pathname || '';
  29159. var s = result.search || '';
  29160. result.path = p + s;
  29161. }
  29162. result.slashes = result.slashes || relative.slashes;
  29163. result.href = result.format();
  29164. return result;
  29165. }
  29166. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  29167. isRelAbs = (
  29168. relative.host ||
  29169. relative.pathname && relative.pathname.charAt(0) === '/'
  29170. ),
  29171. mustEndAbs = (isRelAbs || isSourceAbs ||
  29172. (result.host && relative.pathname)),
  29173. removeAllDots = mustEndAbs,
  29174. srcPath = result.pathname && result.pathname.split('/') || [],
  29175. psychotic = result.protocol && !slashedProtocol[result.protocol];
  29176. relPath = relative.pathname && relative.pathname.split('/') || [];
  29177. // if the url is a non-slashed url, then relative
  29178. // links like ../.. should be able
  29179. // to crawl up to the hostname, as well. This is strange.
  29180. // result.protocol has already been set by now.
  29181. // Later on, put the first path part into the host field.
  29182. if (psychotic) {
  29183. result.hostname = '';
  29184. result.port = null;
  29185. if (result.host) {
  29186. if (srcPath[0] === '') srcPath[0] = result.host;
  29187. else srcPath.unshift(result.host);
  29188. }
  29189. result.host = '';
  29190. if (relative.protocol) {
  29191. relative.hostname = null;
  29192. relative.port = null;
  29193. if (relative.host) {
  29194. if (relPath[0] === '') relPath[0] = relative.host;
  29195. else relPath.unshift(relative.host);
  29196. }
  29197. relative.host = null;
  29198. }
  29199. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  29200. }
  29201. var authInHost;
  29202. if (isRelAbs) {
  29203. // it's absolute.
  29204. result.host = (relative.host || relative.host === '') ?
  29205. relative.host : result.host;
  29206. result.hostname = (relative.hostname || relative.hostname === '') ?
  29207. relative.hostname : result.hostname;
  29208. result.search = relative.search;
  29209. result.query = relative.query;
  29210. srcPath = relPath;
  29211. // fall through to the dot-handling below.
  29212. } else if (relPath.length) {
  29213. // it's relative
  29214. // throw away the existing file, and take the new path instead.
  29215. if (!srcPath) srcPath = [];
  29216. srcPath.pop();
  29217. srcPath = srcPath.concat(relPath);
  29218. result.search = relative.search;
  29219. result.query = relative.query;
  29220. } else if (!isNullOrUndefined(relative.search)) {
  29221. // just pull out the search.
  29222. // like href='?foo'.
  29223. // Put this after the other two cases because it simplifies the booleans
  29224. if (psychotic) {
  29225. result.hostname = result.host = srcPath.shift();
  29226. //occationaly the auth can get stuck only in host
  29227. //this especially happens in cases like
  29228. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29229. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29230. result.host.split('@') : false;
  29231. if (authInHost) {
  29232. result.auth = authInHost.shift();
  29233. result.host = result.hostname = authInHost.shift();
  29234. }
  29235. }
  29236. result.search = relative.search;
  29237. result.query = relative.query;
  29238. //to support http.request
  29239. if (!isNull(result.pathname) || !isNull(result.search)) {
  29240. result.path = (result.pathname ? result.pathname : '') +
  29241. (result.search ? result.search : '');
  29242. }
  29243. result.href = result.format();
  29244. return result;
  29245. }
  29246. if (!srcPath.length) {
  29247. // no path at all. easy.
  29248. // we've already handled the other stuff above.
  29249. result.pathname = null;
  29250. //to support http.request
  29251. if (result.search) {
  29252. result.path = '/' + result.search;
  29253. } else {
  29254. result.path = null;
  29255. }
  29256. result.href = result.format();
  29257. return result;
  29258. }
  29259. // if a url ENDs in . or .., then it must get a trailing slash.
  29260. // however, if it ends in anything else non-slashy,
  29261. // then it must NOT get a trailing slash.
  29262. var last = srcPath.slice(-1)[0];
  29263. var hasTrailingSlash = (
  29264. (result.host || relative.host || srcPath.length > 1) &&
  29265. (last === '.' || last === '..') || last === '');
  29266. // strip single dots, resolve double dots to parent dir
  29267. // if the path tries to go above the root, `up` ends up > 0
  29268. var up = 0;
  29269. for (var i = srcPath.length; i >= 0; i--) {
  29270. last = srcPath[i];
  29271. if (last === '.') {
  29272. srcPath.splice(i, 1);
  29273. } else if (last === '..') {
  29274. srcPath.splice(i, 1);
  29275. up++;
  29276. } else if (up) {
  29277. srcPath.splice(i, 1);
  29278. up--;
  29279. }
  29280. }
  29281. // if the path is allowed to go above the root, restore leading ..s
  29282. if (!mustEndAbs && !removeAllDots) {
  29283. for (; up--; up) {
  29284. srcPath.unshift('..');
  29285. }
  29286. }
  29287. if (mustEndAbs && srcPath[0] !== '' &&
  29288. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  29289. srcPath.unshift('');
  29290. }
  29291. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  29292. srcPath.push('');
  29293. }
  29294. var isAbsolute = srcPath[0] === '' ||
  29295. (srcPath[0] && srcPath[0].charAt(0) === '/');
  29296. // put the host back
  29297. if (psychotic) {
  29298. result.hostname = result.host = isAbsolute ? '' :
  29299. srcPath.length ? srcPath.shift() : '';
  29300. //occationaly the auth can get stuck only in host
  29301. //this especially happens in cases like
  29302. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29303. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29304. result.host.split('@') : false;
  29305. if (authInHost) {
  29306. result.auth = authInHost.shift();
  29307. result.host = result.hostname = authInHost.shift();
  29308. }
  29309. }
  29310. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  29311. if (mustEndAbs && !isAbsolute) {
  29312. srcPath.unshift('');
  29313. }
  29314. if (!srcPath.length) {
  29315. result.pathname = null;
  29316. result.path = null;
  29317. } else {
  29318. result.pathname = srcPath.join('/');
  29319. }
  29320. //to support request.http
  29321. if (!isNull(result.pathname) || !isNull(result.search)) {
  29322. result.path = (result.pathname ? result.pathname : '') +
  29323. (result.search ? result.search : '');
  29324. }
  29325. result.auth = relative.auth || result.auth;
  29326. result.slashes = result.slashes || relative.slashes;
  29327. result.href = result.format();
  29328. return result;
  29329. };
  29330. Url.prototype.parseHost = function() {
  29331. return parseHost(this);
  29332. };
  29333. function parseHost(self) {
  29334. var host = self.host;
  29335. var port = portPattern.exec(host);
  29336. if (port) {
  29337. port = port[0];
  29338. if (port !== ':') {
  29339. self.port = port.substr(1);
  29340. }
  29341. host = host.substr(0, host.length - port.length);
  29342. }
  29343. if (host) self.hostname = host;
  29344. }
  29345. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  29346. __proto__: null,
  29347. URL: URL$1,
  29348. URLSearchParams: URLSearchParams,
  29349. Url: Url,
  29350. default: _polyfillNode_url,
  29351. fileURLToPath: urlFileURLToPath,
  29352. format: urlFormat,
  29353. parse: urlParse,
  29354. resolve: urlResolve,
  29355. resolveObject: urlResolveObject
  29356. });
  29357. function isRelativeUrl(url) {
  29358. const firstChar = url.charAt(0);
  29359. return firstChar === "." || firstChar === "~" || firstChar === "@";
  29360. }
  29361. const externalRE = /^(https?:)?\/\//;
  29362. function isExternalUrl(url) {
  29363. return externalRE.test(url);
  29364. }
  29365. const dataUrlRE = /^\s*data:/i;
  29366. function isDataUrl(url) {
  29367. return dataUrlRE.test(url);
  29368. }
  29369. function parseUrl(url) {
  29370. const firstChar = url.charAt(0);
  29371. if (firstChar === "~") {
  29372. const secondChar = url.charAt(1);
  29373. url = url.slice(secondChar === "/" ? 2 : 1);
  29374. }
  29375. return parseUriParts(url);
  29376. }
  29377. function parseUriParts(urlString) {
  29378. return urlParse(isString$2(urlString) ? urlString : "", false, true);
  29379. }
  29380. var __defProp$9 = Object.defineProperty;
  29381. var __defProps$8 = Object.defineProperties;
  29382. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  29383. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  29384. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  29385. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  29386. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  29387. var __spreadValues$9 = (a, b) => {
  29388. for (var prop in b || (b = {}))
  29389. if (__hasOwnProp$9.call(b, prop))
  29390. __defNormalProp$9(a, prop, b[prop]);
  29391. if (__getOwnPropSymbols$9)
  29392. for (var prop of __getOwnPropSymbols$9(b)) {
  29393. if (__propIsEnum$9.call(b, prop))
  29394. __defNormalProp$9(a, prop, b[prop]);
  29395. }
  29396. return a;
  29397. };
  29398. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  29399. const defaultAssetUrlOptions = {
  29400. base: null,
  29401. includeAbsolute: false,
  29402. tags: {
  29403. video: ["src", "poster"],
  29404. source: ["src"],
  29405. img: ["src"],
  29406. image: ["xlink:href", "href"],
  29407. use: ["xlink:href", "href"]
  29408. }
  29409. };
  29410. const normalizeOptions = (options) => {
  29411. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  29412. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  29413. tags: options
  29414. });
  29415. }
  29416. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  29417. };
  29418. const createAssetUrlTransformWithOptions = (options) => {
  29419. return (node, context) => transformAssetUrl(node, context, options);
  29420. };
  29421. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  29422. if (node.type === 1) {
  29423. if (!node.props.length) {
  29424. return;
  29425. }
  29426. const tags = options.tags || defaultAssetUrlOptions.tags;
  29427. const attrs = tags[node.tag];
  29428. const wildCardAttrs = tags["*"];
  29429. if (!attrs && !wildCardAttrs) {
  29430. return;
  29431. }
  29432. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  29433. node.props.forEach((attr, index) => {
  29434. 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)) {
  29435. return;
  29436. }
  29437. const url = parseUrl(attr.value.content);
  29438. if (options.base && attr.value.content[0] === ".") {
  29439. const base = parseUrl(options.base);
  29440. const protocol = base.protocol || "";
  29441. const host = base.host ? protocol + "//" + base.host : "";
  29442. const basePath = base.path || "/";
  29443. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  29444. return;
  29445. }
  29446. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  29447. node.props[index] = {
  29448. type: 7,
  29449. name: "bind",
  29450. arg: createSimpleExpression(attr.name, true, attr.loc),
  29451. exp,
  29452. modifiers: [],
  29453. loc: attr.loc
  29454. };
  29455. });
  29456. }
  29457. };
  29458. function getImportsExpressionExp(path2, hash, loc, context) {
  29459. if (path2) {
  29460. let name;
  29461. let exp;
  29462. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  29463. if (existingIndex > -1) {
  29464. name = `_imports_${existingIndex}`;
  29465. exp = context.imports[existingIndex].exp;
  29466. } else {
  29467. name = `_imports_${context.imports.length}`;
  29468. exp = createSimpleExpression(
  29469. name,
  29470. false,
  29471. loc,
  29472. 3
  29473. );
  29474. context.imports.push({
  29475. exp,
  29476. path: decodeURIComponent(path2)
  29477. });
  29478. }
  29479. if (!hash) {
  29480. return exp;
  29481. }
  29482. const hashExp = `${name} + '${hash}'`;
  29483. const finalExp = createSimpleExpression(
  29484. hashExp,
  29485. false,
  29486. loc,
  29487. 3
  29488. );
  29489. if (!context.hoistStatic) {
  29490. return finalExp;
  29491. }
  29492. const existingHoistIndex = context.hoists.findIndex((h) => {
  29493. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  29494. });
  29495. if (existingHoistIndex > -1) {
  29496. return createSimpleExpression(
  29497. `_hoisted_${existingHoistIndex + 1}`,
  29498. false,
  29499. loc,
  29500. 3
  29501. );
  29502. }
  29503. return context.hoist(finalExp);
  29504. } else {
  29505. return createSimpleExpression(`''`, false, loc, 3);
  29506. }
  29507. }
  29508. const srcsetTags = ["img", "source"];
  29509. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  29510. const createSrcsetTransformWithOptions = (options) => {
  29511. return (node, context) => transformSrcset(node, context, options);
  29512. };
  29513. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  29514. if (node.type === 1) {
  29515. if (srcsetTags.includes(node.tag) && node.props.length) {
  29516. node.props.forEach((attr, index) => {
  29517. if (attr.name === "srcset" && attr.type === 6) {
  29518. if (!attr.value)
  29519. return;
  29520. const value = attr.value.content;
  29521. if (!value)
  29522. return;
  29523. const imageCandidates = value.split(",").map((s) => {
  29524. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  29525. return { url, descriptor };
  29526. });
  29527. for (let i = 0; i < imageCandidates.length; i++) {
  29528. const { url } = imageCandidates[i];
  29529. if (isDataUrl(url)) {
  29530. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  29531. imageCandidates.splice(i, 1);
  29532. }
  29533. }
  29534. const shouldProcessUrl = (url) => {
  29535. return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  29536. };
  29537. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  29538. return;
  29539. }
  29540. if (options.base) {
  29541. const base = options.base;
  29542. const set = [];
  29543. let needImportTransform = false;
  29544. imageCandidates.forEach((candidate) => {
  29545. let { url, descriptor } = candidate;
  29546. descriptor = descriptor ? ` ${descriptor}` : ``;
  29547. if (url[0] === ".") {
  29548. candidate.url = (path.posix || path).join(base, url);
  29549. set.push(candidate.url + descriptor);
  29550. } else if (shouldProcessUrl(url)) {
  29551. needImportTransform = true;
  29552. } else {
  29553. set.push(url + descriptor);
  29554. }
  29555. });
  29556. if (!needImportTransform) {
  29557. attr.value.content = set.join(", ");
  29558. return;
  29559. }
  29560. }
  29561. const compoundExpression = createCompoundExpression([], attr.loc);
  29562. imageCandidates.forEach(({ url, descriptor }, index2) => {
  29563. if (shouldProcessUrl(url)) {
  29564. const { path: path2 } = parseUrl(url);
  29565. let exp2;
  29566. if (path2) {
  29567. const existingImportsIndex = context.imports.findIndex(
  29568. (i) => i.path === path2
  29569. );
  29570. if (existingImportsIndex > -1) {
  29571. exp2 = createSimpleExpression(
  29572. `_imports_${existingImportsIndex}`,
  29573. false,
  29574. attr.loc,
  29575. 3
  29576. );
  29577. } else {
  29578. exp2 = createSimpleExpression(
  29579. `_imports_${context.imports.length}`,
  29580. false,
  29581. attr.loc,
  29582. 3
  29583. );
  29584. context.imports.push({ exp: exp2, path: path2 });
  29585. }
  29586. compoundExpression.children.push(exp2);
  29587. }
  29588. } else {
  29589. const exp2 = createSimpleExpression(
  29590. `"${url}"`,
  29591. false,
  29592. attr.loc,
  29593. 3
  29594. );
  29595. compoundExpression.children.push(exp2);
  29596. }
  29597. const isNotLast = imageCandidates.length - 1 > index2;
  29598. if (descriptor && isNotLast) {
  29599. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  29600. } else if (descriptor) {
  29601. compoundExpression.children.push(` + ' ${descriptor}'`);
  29602. } else if (isNotLast) {
  29603. compoundExpression.children.push(` + ', ' + `);
  29604. }
  29605. });
  29606. let exp = compoundExpression;
  29607. if (context.hoistStatic) {
  29608. exp = context.hoist(compoundExpression);
  29609. exp.constType = 3;
  29610. }
  29611. node.props[index] = {
  29612. type: 7,
  29613. name: "bind",
  29614. arg: createSimpleExpression("srcset", true, attr.loc),
  29615. exp,
  29616. modifiers: [],
  29617. loc: attr.loc
  29618. };
  29619. }
  29620. });
  29621. }
  29622. }
  29623. };
  29624. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  29625. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  29626. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  29627. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  29628. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  29629. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  29630. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  29631. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  29632. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  29633. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  29634. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  29635. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
  29636. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  29637. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  29638. const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
  29639. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
  29640. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  29641. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  29642. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  29643. const ssrHelpers = {
  29644. [SSR_INTERPOLATE]: `ssrInterpolate`,
  29645. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  29646. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  29647. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  29648. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  29649. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  29650. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  29651. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  29652. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  29653. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  29654. [SSR_RENDER_LIST]: `ssrRenderList`,
  29655. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  29656. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  29657. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  29658. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  29659. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  29660. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  29661. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  29662. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  29663. };
  29664. registerRuntimeHelpers(ssrHelpers);
  29665. const ssrTransformIf = createStructuralDirectiveTransform(
  29666. /^(if|else|else-if)$/,
  29667. processIf
  29668. );
  29669. function ssrProcessIf(node, context, disableNestedFragments = false) {
  29670. const [rootBranch] = node.branches;
  29671. const ifStatement = createIfStatement(
  29672. rootBranch.condition,
  29673. processIfBranch(rootBranch, context, disableNestedFragments)
  29674. );
  29675. context.pushStatement(ifStatement);
  29676. let currentIf = ifStatement;
  29677. for (let i = 1; i < node.branches.length; i++) {
  29678. const branch = node.branches[i];
  29679. const branchBlockStatement = processIfBranch(
  29680. branch,
  29681. context,
  29682. disableNestedFragments
  29683. );
  29684. if (branch.condition) {
  29685. currentIf = currentIf.alternate = createIfStatement(
  29686. branch.condition,
  29687. branchBlockStatement
  29688. );
  29689. } else {
  29690. currentIf.alternate = branchBlockStatement;
  29691. }
  29692. }
  29693. if (!currentIf.alternate) {
  29694. currentIf.alternate = createBlockStatement([
  29695. createCallExpression(`_push`, ["`<!---->`"])
  29696. ]);
  29697. }
  29698. }
  29699. function processIfBranch(branch, context, disableNestedFragments = false) {
  29700. const { children } = branch;
  29701. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  29702. !(children.length === 1 && children[0].type === 11);
  29703. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  29704. }
  29705. const ssrTransformFor = createStructuralDirectiveTransform(
  29706. "for",
  29707. processFor
  29708. );
  29709. function ssrProcessFor(node, context, disableNestedFragments = false) {
  29710. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  29711. const renderLoop = createFunctionExpression(
  29712. createForLoopParams(node.parseResult)
  29713. );
  29714. renderLoop.body = processChildrenAsStatement(
  29715. node,
  29716. context,
  29717. needFragmentWrapper
  29718. );
  29719. if (!disableNestedFragments) {
  29720. context.pushStringPart(`<!--[-->`);
  29721. }
  29722. context.pushStatement(
  29723. createCallExpression(context.helper(SSR_RENDER_LIST), [
  29724. node.source,
  29725. renderLoop
  29726. ])
  29727. );
  29728. if (!disableNestedFragments) {
  29729. context.pushStringPart(`<!--]-->`);
  29730. }
  29731. }
  29732. const ssrTransformSlotOutlet = (node, context) => {
  29733. if (isSlotOutlet(node)) {
  29734. const { slotName, slotProps } = processSlotOutlet(node, context);
  29735. const args = [
  29736. `_ctx.$slots`,
  29737. slotName,
  29738. slotProps || `{}`,
  29739. // fallback content placeholder. will be replaced in the process phase
  29740. `null`,
  29741. `_push`,
  29742. `_parent`
  29743. ];
  29744. if (context.scopeId && context.slotted !== false) {
  29745. args.push(`"${context.scopeId}-s"`);
  29746. }
  29747. let method = SSR_RENDER_SLOT;
  29748. const parent = context.parent;
  29749. let componentType;
  29750. 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) {
  29751. method = SSR_RENDER_SLOT_INNER;
  29752. if (!(context.scopeId && context.slotted !== false)) {
  29753. args.push("null");
  29754. }
  29755. args.push("true");
  29756. }
  29757. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  29758. }
  29759. };
  29760. function ssrProcessSlotOutlet(node, context) {
  29761. const renderCall = node.ssrCodegenNode;
  29762. if (node.children.length) {
  29763. const fallbackRenderFn = createFunctionExpression([]);
  29764. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  29765. renderCall.arguments[3] = fallbackRenderFn;
  29766. }
  29767. if (context.withSlotScopeId) {
  29768. const slotScopeId = renderCall.arguments[6];
  29769. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  29770. }
  29771. context.pushStatement(node.ssrCodegenNode);
  29772. }
  29773. function createSSRCompilerError(code, loc) {
  29774. return createCompilerError(code, loc, SSRErrorMessages);
  29775. }
  29776. const SSRErrorMessages = {
  29777. [65]: `Unsafe attribute name for SSR.`,
  29778. [66]: `Missing the 'to' prop on teleport element.`,
  29779. [67]: `Invalid AST node during SSR transform.`
  29780. };
  29781. function ssrProcessTeleport(node, context) {
  29782. const targetProp = findProp(node, "to");
  29783. if (!targetProp) {
  29784. context.onError(
  29785. createSSRCompilerError(66, node.loc)
  29786. );
  29787. return;
  29788. }
  29789. let target;
  29790. if (targetProp.type === 6) {
  29791. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  29792. } else {
  29793. target = targetProp.exp;
  29794. }
  29795. if (!target) {
  29796. context.onError(
  29797. createSSRCompilerError(
  29798. 66,
  29799. targetProp.loc
  29800. )
  29801. );
  29802. return;
  29803. }
  29804. const disabledProp = findProp(
  29805. node,
  29806. "disabled",
  29807. false,
  29808. true
  29809. /* allow empty */
  29810. );
  29811. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  29812. const contentRenderFn = createFunctionExpression(
  29813. [`_push`],
  29814. void 0,
  29815. // Body is added later
  29816. true,
  29817. // newline
  29818. false,
  29819. // isSlot
  29820. node.loc
  29821. );
  29822. contentRenderFn.body = processChildrenAsStatement(node, context);
  29823. context.pushStatement(
  29824. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  29825. `_push`,
  29826. contentRenderFn,
  29827. target,
  29828. disabled,
  29829. `_parent`
  29830. ])
  29831. );
  29832. }
  29833. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  29834. function ssrTransformSuspense(node, context) {
  29835. return () => {
  29836. if (node.children.length) {
  29837. const wipEntry = {
  29838. slotsExp: null,
  29839. // to be immediately set
  29840. wipSlots: []
  29841. };
  29842. wipMap$3.set(node, wipEntry);
  29843. wipEntry.slotsExp = buildSlots(
  29844. node,
  29845. context,
  29846. (_props, _vForExp, children, loc) => {
  29847. const fn = createFunctionExpression(
  29848. [],
  29849. void 0,
  29850. // no return, assign body later
  29851. true,
  29852. // newline
  29853. false,
  29854. // suspense slots are not treated as normal slots
  29855. loc
  29856. );
  29857. wipEntry.wipSlots.push({
  29858. fn,
  29859. children
  29860. });
  29861. return fn;
  29862. }
  29863. ).slots;
  29864. }
  29865. };
  29866. }
  29867. function ssrProcessSuspense(node, context) {
  29868. const wipEntry = wipMap$3.get(node);
  29869. if (!wipEntry) {
  29870. return;
  29871. }
  29872. const { slotsExp, wipSlots } = wipEntry;
  29873. for (let i = 0; i < wipSlots.length; i++) {
  29874. const slot = wipSlots[i];
  29875. slot.fn.body = processChildrenAsStatement(slot, context);
  29876. }
  29877. context.pushStatement(
  29878. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  29879. `_push`,
  29880. slotsExp
  29881. ])
  29882. );
  29883. }
  29884. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  29885. const ssrTransformElement = (node, context) => {
  29886. if (node.type !== 1 || node.tagType !== 0) {
  29887. return;
  29888. }
  29889. return function ssrPostTransformElement() {
  29890. const openTag = [`<${node.tag}`];
  29891. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  29892. const hasDynamicVBind = hasDynamicKeyVBind(node);
  29893. const hasCustomDir = node.props.some(
  29894. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  29895. );
  29896. const needMergeProps = hasDynamicVBind || hasCustomDir;
  29897. if (needMergeProps) {
  29898. const { props, directives } = buildProps(
  29899. node,
  29900. context,
  29901. node.props,
  29902. false,
  29903. false,
  29904. true
  29905. );
  29906. if (props || directives.length) {
  29907. const mergedProps = buildSSRProps(props, directives, context);
  29908. const propsExp = createCallExpression(
  29909. context.helper(SSR_RENDER_ATTRS),
  29910. [mergedProps]
  29911. );
  29912. if (node.tag === "textarea") {
  29913. const existingText = node.children[0];
  29914. if (!existingText || existingText.type !== 5) {
  29915. const tempId = `_temp${context.temps++}`;
  29916. propsExp.arguments = [
  29917. createAssignmentExpression(
  29918. createSimpleExpression(tempId, false),
  29919. mergedProps
  29920. )
  29921. ];
  29922. rawChildrenMap.set(
  29923. node,
  29924. createCallExpression(context.helper(SSR_INTERPOLATE), [
  29925. createConditionalExpression(
  29926. createSimpleExpression(`"value" in ${tempId}`, false),
  29927. createSimpleExpression(`${tempId}.value`, false),
  29928. createSimpleExpression(
  29929. existingText ? existingText.content : ``,
  29930. true
  29931. ),
  29932. false
  29933. )
  29934. ])
  29935. );
  29936. }
  29937. } else if (node.tag === "input") {
  29938. const vModel = findVModel(node);
  29939. if (vModel) {
  29940. const tempId = `_temp${context.temps++}`;
  29941. const tempExp = createSimpleExpression(tempId, false);
  29942. propsExp.arguments = [
  29943. createSequenceExpression([
  29944. createAssignmentExpression(tempExp, mergedProps),
  29945. createCallExpression(context.helper(MERGE_PROPS), [
  29946. tempExp,
  29947. createCallExpression(
  29948. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  29949. [
  29950. tempExp,
  29951. // existing props
  29952. vModel.exp
  29953. // model
  29954. ]
  29955. )
  29956. ])
  29957. ])
  29958. ];
  29959. }
  29960. }
  29961. if (needTagForRuntime) {
  29962. propsExp.arguments.push(`"${node.tag}"`);
  29963. }
  29964. openTag.push(propsExp);
  29965. }
  29966. }
  29967. let dynamicClassBinding = void 0;
  29968. let staticClassBinding = void 0;
  29969. let dynamicStyleBinding = void 0;
  29970. for (let i = 0; i < node.props.length; i++) {
  29971. const prop = node.props[i];
  29972. if (node.tag === "input" && isTrueFalseValue(prop)) {
  29973. continue;
  29974. }
  29975. if (prop.type === 7) {
  29976. if (prop.name === "html" && prop.exp) {
  29977. rawChildrenMap.set(node, prop.exp);
  29978. } else if (prop.name === "text" && prop.exp) {
  29979. node.children = [createInterpolation(prop.exp, prop.loc)];
  29980. } else if (prop.name === "slot") {
  29981. context.onError(
  29982. createCompilerError(40, prop.loc)
  29983. );
  29984. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  29985. if (!needMergeProps) {
  29986. node.children = [createInterpolation(prop.exp, prop.loc)];
  29987. }
  29988. } else if (!needMergeProps && prop.name !== "on") {
  29989. const directiveTransform = context.directiveTransforms[prop.name];
  29990. if (directiveTransform) {
  29991. const { props, ssrTagParts } = directiveTransform(
  29992. prop,
  29993. node,
  29994. context
  29995. );
  29996. if (ssrTagParts) {
  29997. openTag.push(...ssrTagParts);
  29998. }
  29999. for (let j = 0; j < props.length; j++) {
  30000. const { key, value } = props[j];
  30001. if (isStaticExp(key)) {
  30002. let attrName = key.content;
  30003. if (attrName === "key" || attrName === "ref") {
  30004. continue;
  30005. }
  30006. if (attrName === "class") {
  30007. openTag.push(
  30008. ` class="`,
  30009. dynamicClassBinding = createCallExpression(
  30010. context.helper(SSR_RENDER_CLASS),
  30011. [value]
  30012. ),
  30013. `"`
  30014. );
  30015. } else if (attrName === "style") {
  30016. if (dynamicStyleBinding) {
  30017. mergeCall(dynamicStyleBinding, value);
  30018. } else {
  30019. openTag.push(
  30020. ` style="`,
  30021. dynamicStyleBinding = createCallExpression(
  30022. context.helper(SSR_RENDER_STYLE),
  30023. [value]
  30024. ),
  30025. `"`
  30026. );
  30027. }
  30028. } else {
  30029. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  30030. if (isBooleanAttr(attrName)) {
  30031. openTag.push(
  30032. createConditionalExpression(
  30033. createCallExpression(
  30034. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  30035. [value]
  30036. ),
  30037. createSimpleExpression(" " + attrName, true),
  30038. createSimpleExpression("", true),
  30039. false
  30040. )
  30041. );
  30042. } else if (isSSRSafeAttrName(attrName)) {
  30043. openTag.push(
  30044. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  30045. key,
  30046. value
  30047. ])
  30048. );
  30049. } else {
  30050. context.onError(
  30051. createSSRCompilerError(
  30052. 65,
  30053. key.loc
  30054. )
  30055. );
  30056. }
  30057. }
  30058. } else {
  30059. const args = [key, value];
  30060. if (needTagForRuntime) {
  30061. args.push(`"${node.tag}"`);
  30062. }
  30063. openTag.push(
  30064. createCallExpression(
  30065. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  30066. args
  30067. )
  30068. );
  30069. }
  30070. }
  30071. }
  30072. }
  30073. } else {
  30074. const name = prop.name;
  30075. if (node.tag === "textarea" && name === "value" && prop.value) {
  30076. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  30077. } else if (!needMergeProps) {
  30078. if (name === "key" || name === "ref") {
  30079. continue;
  30080. }
  30081. if (name === "class" && prop.value) {
  30082. staticClassBinding = JSON.stringify(prop.value.content);
  30083. }
  30084. openTag.push(
  30085. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  30086. );
  30087. }
  30088. }
  30089. }
  30090. if (dynamicClassBinding && staticClassBinding) {
  30091. mergeCall(dynamicClassBinding, staticClassBinding);
  30092. removeStaticBinding(openTag, "class");
  30093. }
  30094. if (context.scopeId) {
  30095. openTag.push(` ${context.scopeId}`);
  30096. }
  30097. node.ssrCodegenNode = createTemplateLiteral(openTag);
  30098. };
  30099. };
  30100. function buildSSRProps(props, directives, context) {
  30101. let mergePropsArgs = [];
  30102. if (props) {
  30103. if (props.type === 14) {
  30104. mergePropsArgs = props.arguments;
  30105. } else {
  30106. mergePropsArgs.push(props);
  30107. }
  30108. }
  30109. if (directives.length) {
  30110. for (const dir of directives) {
  30111. mergePropsArgs.push(
  30112. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  30113. `_ctx`,
  30114. ...buildDirectiveArgs(dir, context).elements
  30115. ])
  30116. );
  30117. }
  30118. }
  30119. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  30120. }
  30121. function isTrueFalseValue(prop) {
  30122. if (prop.type === 7) {
  30123. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  30124. } else {
  30125. return prop.name === "true-value" || prop.name === "false-value";
  30126. }
  30127. }
  30128. function isTextareaWithValue(node, prop) {
  30129. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  30130. }
  30131. function mergeCall(call, arg) {
  30132. const existing = call.arguments[0];
  30133. if (existing.type === 17) {
  30134. existing.elements.push(arg);
  30135. } else {
  30136. call.arguments[0] = createArrayExpression([existing, arg]);
  30137. }
  30138. }
  30139. function removeStaticBinding(tag, binding) {
  30140. const regExp = new RegExp(`^ ${binding}=".+"$`);
  30141. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  30142. if (i > -1) {
  30143. tag.splice(i, 1);
  30144. }
  30145. }
  30146. function findVModel(node) {
  30147. return node.props.find(
  30148. (p) => p.type === 7 && p.name === "model" && p.exp
  30149. );
  30150. }
  30151. function ssrProcessElement(node, context) {
  30152. const isVoidTag = context.options.isVoidTag || NO;
  30153. const elementsToAdd = node.ssrCodegenNode.elements;
  30154. for (let j = 0; j < elementsToAdd.length; j++) {
  30155. context.pushStringPart(elementsToAdd[j]);
  30156. }
  30157. if (context.withSlotScopeId) {
  30158. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  30159. }
  30160. context.pushStringPart(`>`);
  30161. const rawChildren = rawChildrenMap.get(node);
  30162. if (rawChildren) {
  30163. context.pushStringPart(rawChildren);
  30164. } else if (node.children.length) {
  30165. processChildren(node, context);
  30166. }
  30167. if (!isVoidTag(node.tag)) {
  30168. context.pushStringPart(`</${node.tag}>`);
  30169. }
  30170. }
  30171. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  30172. function ssrTransformTransitionGroup(node, context) {
  30173. return () => {
  30174. const tag = findProp(node, "tag");
  30175. if (tag) {
  30176. const otherProps = node.props.filter((p) => p !== tag);
  30177. const { props, directives } = buildProps(
  30178. node,
  30179. context,
  30180. otherProps,
  30181. true,
  30182. false,
  30183. true
  30184. );
  30185. let propsExp = null;
  30186. if (props || directives.length) {
  30187. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  30188. buildSSRProps(props, directives, context)
  30189. ]);
  30190. }
  30191. wipMap$2.set(node, {
  30192. tag,
  30193. propsExp,
  30194. scopeId: context.scopeId || null
  30195. });
  30196. }
  30197. };
  30198. }
  30199. function ssrProcessTransitionGroup(node, context) {
  30200. const entry = wipMap$2.get(node);
  30201. if (entry) {
  30202. const { tag, propsExp, scopeId } = entry;
  30203. if (tag.type === 7) {
  30204. context.pushStringPart(`<`);
  30205. context.pushStringPart(tag.exp);
  30206. if (propsExp) {
  30207. context.pushStringPart(propsExp);
  30208. }
  30209. if (scopeId) {
  30210. context.pushStringPart(` ${scopeId}`);
  30211. }
  30212. context.pushStringPart(`>`);
  30213. processChildren(
  30214. node,
  30215. context,
  30216. false,
  30217. /**
  30218. * TransitionGroup has the special runtime behavior of flattening and
  30219. * concatenating all children into a single fragment (in order for them to
  30220. * be patched using the same key map) so we need to account for that here
  30221. * by disabling nested fragment wrappers from being generated.
  30222. */
  30223. true
  30224. );
  30225. context.pushStringPart(`</`);
  30226. context.pushStringPart(tag.exp);
  30227. context.pushStringPart(`>`);
  30228. } else {
  30229. context.pushStringPart(`<${tag.value.content}`);
  30230. if (propsExp) {
  30231. context.pushStringPart(propsExp);
  30232. }
  30233. if (scopeId) {
  30234. context.pushStringPart(` ${scopeId}`);
  30235. }
  30236. context.pushStringPart(`>`);
  30237. processChildren(node, context, false, true);
  30238. context.pushStringPart(`</${tag.value.content}>`);
  30239. }
  30240. } else {
  30241. processChildren(node, context, true, true);
  30242. }
  30243. }
  30244. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  30245. function ssrTransformTransition(node, context) {
  30246. return () => {
  30247. const appear = findProp(node, "appear", false, true);
  30248. wipMap$1.set(node, !!appear);
  30249. };
  30250. }
  30251. function ssrProcessTransition(node, context) {
  30252. node.children = node.children.filter((c) => c.type !== 3);
  30253. const appear = wipMap$1.get(node);
  30254. if (appear) {
  30255. context.pushStringPart(`<template>`);
  30256. processChildren(node, context, false, true);
  30257. context.pushStringPart(`</template>`);
  30258. } else {
  30259. processChildren(node, context, false, true);
  30260. }
  30261. }
  30262. var __defProp$8 = Object.defineProperty;
  30263. var __defProps$7 = Object.defineProperties;
  30264. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  30265. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  30266. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  30267. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  30268. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30269. var __spreadValues$8 = (a, b) => {
  30270. for (var prop in b || (b = {}))
  30271. if (__hasOwnProp$8.call(b, prop))
  30272. __defNormalProp$8(a, prop, b[prop]);
  30273. if (__getOwnPropSymbols$8)
  30274. for (var prop of __getOwnPropSymbols$8(b)) {
  30275. if (__propIsEnum$8.call(b, prop))
  30276. __defNormalProp$8(a, prop, b[prop]);
  30277. }
  30278. return a;
  30279. };
  30280. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  30281. const wipMap = /* @__PURE__ */ new WeakMap();
  30282. const WIP_SLOT = Symbol();
  30283. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  30284. const ssrTransformComponent = (node, context) => {
  30285. if (node.type !== 1 || node.tagType !== 1) {
  30286. return;
  30287. }
  30288. const component = resolveComponentType(
  30289. node,
  30290. context,
  30291. true
  30292. /* ssr */
  30293. );
  30294. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  30295. componentTypeMap.set(node, component);
  30296. if (isSymbol$1(component)) {
  30297. if (component === SUSPENSE) {
  30298. return ssrTransformSuspense(node, context);
  30299. } else if (component === TRANSITION_GROUP) {
  30300. return ssrTransformTransitionGroup(node, context);
  30301. } else if (component === TRANSITION) {
  30302. return ssrTransformTransition(node);
  30303. }
  30304. return;
  30305. }
  30306. const vnodeBranches = [];
  30307. const clonedNode = clone(node);
  30308. return function ssrPostTransformComponent() {
  30309. if (clonedNode.children.length) {
  30310. buildSlots(clonedNode, context, (props, vFor, children) => {
  30311. vnodeBranches.push(
  30312. createVNodeSlotBranch(props, vFor, children, context)
  30313. );
  30314. return createFunctionExpression(void 0);
  30315. });
  30316. }
  30317. let propsExp = `null`;
  30318. if (node.props.length) {
  30319. const { props, directives } = buildProps(
  30320. node,
  30321. context,
  30322. void 0,
  30323. true,
  30324. isDynamicComponent
  30325. );
  30326. if (props || directives.length) {
  30327. propsExp = buildSSRProps(props, directives, context);
  30328. }
  30329. }
  30330. const wipEntries = [];
  30331. wipMap.set(node, wipEntries);
  30332. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  30333. const param0 = props && stringifyExpression(props) || `_`;
  30334. const fn = createFunctionExpression(
  30335. [param0, `_push`, `_parent`, `_scopeId`],
  30336. void 0,
  30337. // no return, assign body later
  30338. true,
  30339. // newline
  30340. true,
  30341. // isSlot
  30342. loc
  30343. );
  30344. wipEntries.push({
  30345. type: WIP_SLOT,
  30346. fn,
  30347. children,
  30348. // also collect the corresponding vnode branch built earlier
  30349. vnodeBranch: vnodeBranches[wipEntries.length]
  30350. });
  30351. return fn;
  30352. };
  30353. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  30354. if (typeof component !== "string") {
  30355. node.ssrCodegenNode = createCallExpression(
  30356. context.helper(SSR_RENDER_VNODE),
  30357. [
  30358. `_push`,
  30359. createCallExpression(context.helper(CREATE_VNODE), [
  30360. component,
  30361. propsExp,
  30362. slots
  30363. ]),
  30364. `_parent`
  30365. ]
  30366. );
  30367. } else {
  30368. node.ssrCodegenNode = createCallExpression(
  30369. context.helper(SSR_RENDER_COMPONENT),
  30370. [component, propsExp, slots, `_parent`]
  30371. );
  30372. }
  30373. };
  30374. };
  30375. function ssrProcessComponent(node, context, parent) {
  30376. const component = componentTypeMap.get(node);
  30377. if (!node.ssrCodegenNode) {
  30378. if (component === TELEPORT) {
  30379. return ssrProcessTeleport(node, context);
  30380. } else if (component === SUSPENSE) {
  30381. return ssrProcessSuspense(node, context);
  30382. } else if (component === TRANSITION_GROUP) {
  30383. return ssrProcessTransitionGroup(node, context);
  30384. } else {
  30385. if (parent.type === WIP_SLOT) {
  30386. context.pushStringPart(``);
  30387. }
  30388. if (component === TRANSITION) {
  30389. return ssrProcessTransition(node, context);
  30390. }
  30391. processChildren(node, context);
  30392. }
  30393. } else {
  30394. const wipEntries = wipMap.get(node) || [];
  30395. for (let i = 0; i < wipEntries.length; i++) {
  30396. const { fn, vnodeBranch } = wipEntries[i];
  30397. fn.body = createIfStatement(
  30398. createSimpleExpression(`_push`, false),
  30399. processChildrenAsStatement(
  30400. wipEntries[i],
  30401. context,
  30402. false,
  30403. true
  30404. ),
  30405. vnodeBranch
  30406. );
  30407. }
  30408. if (context.withSlotScopeId) {
  30409. node.ssrCodegenNode.arguments.push(`_scopeId`);
  30410. }
  30411. if (typeof component === "string") {
  30412. context.pushStatement(
  30413. createCallExpression(`_push`, [node.ssrCodegenNode])
  30414. );
  30415. } else {
  30416. context.pushStatement(node.ssrCodegenNode);
  30417. }
  30418. }
  30419. }
  30420. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  30421. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  30422. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  30423. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  30424. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  30425. const rawOptions = rawOptionsMap.get(parentContext.root);
  30426. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  30427. // overwrite with vnode-based transforms
  30428. nodeTransforms: [
  30429. ...vnodeNodeTransforms,
  30430. ...rawOptions.nodeTransforms || []
  30431. ],
  30432. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  30433. });
  30434. const wrapperProps = [];
  30435. if (slotProps) {
  30436. wrapperProps.push({
  30437. type: 7,
  30438. name: "slot",
  30439. exp: slotProps,
  30440. arg: void 0,
  30441. modifiers: [],
  30442. loc: locStub
  30443. });
  30444. }
  30445. if (vFor) {
  30446. wrapperProps.push(extend({}, vFor));
  30447. }
  30448. const wrapperNode = {
  30449. type: 1,
  30450. ns: 0,
  30451. tag: "template",
  30452. tagType: 3,
  30453. props: wrapperProps,
  30454. children,
  30455. loc: locStub,
  30456. codegenNode: void 0
  30457. };
  30458. subTransform(wrapperNode, subOptions, parentContext);
  30459. return createReturnStatement(children);
  30460. }
  30461. function subTransform(node, options, parentContext) {
  30462. const childRoot = createRoot([node]);
  30463. const childContext = createTransformContext(childRoot, options);
  30464. childContext.ssr = false;
  30465. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  30466. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  30467. childContext.imports = parentContext.imports;
  30468. traverseNode(childRoot, childContext);
  30469. ["helpers", "components", "directives"].forEach((key) => {
  30470. childContext[key].forEach((value, helperKey) => {
  30471. if (key === "helpers") {
  30472. const parentCount = parentContext.helpers.get(helperKey);
  30473. if (parentCount === void 0) {
  30474. parentContext.helpers.set(helperKey, value);
  30475. } else {
  30476. parentContext.helpers.set(helperKey, value + parentCount);
  30477. }
  30478. } else {
  30479. parentContext[key].add(value);
  30480. }
  30481. });
  30482. });
  30483. }
  30484. function clone(v) {
  30485. if (isArray$3(v)) {
  30486. return v.map(clone);
  30487. } else if (isPlainObject(v)) {
  30488. const res = {};
  30489. for (const key in v) {
  30490. res[key] = clone(v[key]);
  30491. }
  30492. return res;
  30493. } else {
  30494. return v;
  30495. }
  30496. }
  30497. function ssrCodegenTransform(ast, options) {
  30498. const context = createSSRTransformContext(ast, options);
  30499. if (options.ssrCssVars) {
  30500. const cssContext = createTransformContext(createRoot([]), options);
  30501. const varsExp = processExpression(
  30502. createSimpleExpression(options.ssrCssVars, false),
  30503. cssContext
  30504. );
  30505. context.body.push(
  30506. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  30507. );
  30508. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  30509. ast.helpers.add(helper);
  30510. });
  30511. }
  30512. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  30513. processChildren(ast, context, isFragment);
  30514. ast.codegenNode = createBlockStatement(context.body);
  30515. ast.ssrHelpers = Array.from(
  30516. /* @__PURE__ */ new Set([
  30517. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  30518. ...context.helpers
  30519. ])
  30520. );
  30521. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  30522. }
  30523. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  30524. const body = [];
  30525. let currentString = null;
  30526. return {
  30527. root,
  30528. options,
  30529. body,
  30530. helpers,
  30531. withSlotScopeId,
  30532. onError: options.onError || ((e) => {
  30533. throw e;
  30534. }),
  30535. helper(name) {
  30536. helpers.add(name);
  30537. return name;
  30538. },
  30539. pushStringPart(part) {
  30540. if (!currentString) {
  30541. const currentCall = createCallExpression(`_push`);
  30542. body.push(currentCall);
  30543. currentString = createTemplateLiteral([]);
  30544. currentCall.arguments.push(currentString);
  30545. }
  30546. const bufferedElements = currentString.elements;
  30547. const lastItem = bufferedElements[bufferedElements.length - 1];
  30548. if (isString$2(part) && isString$2(lastItem)) {
  30549. bufferedElements[bufferedElements.length - 1] += part;
  30550. } else {
  30551. bufferedElements.push(part);
  30552. }
  30553. },
  30554. pushStatement(statement) {
  30555. currentString = null;
  30556. body.push(statement);
  30557. }
  30558. };
  30559. }
  30560. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  30561. return createSSRTransformContext(
  30562. parent.root,
  30563. parent.options,
  30564. parent.helpers,
  30565. withSlotScopeId
  30566. );
  30567. }
  30568. function processChildren(parent, context, asFragment = false, disableNestedFragments = false) {
  30569. if (asFragment) {
  30570. context.pushStringPart(`<!--[-->`);
  30571. }
  30572. const { children } = parent;
  30573. for (let i = 0; i < children.length; i++) {
  30574. const child = children[i];
  30575. switch (child.type) {
  30576. case 1:
  30577. switch (child.tagType) {
  30578. case 0:
  30579. ssrProcessElement(child, context);
  30580. break;
  30581. case 1:
  30582. ssrProcessComponent(child, context, parent);
  30583. break;
  30584. case 2:
  30585. ssrProcessSlotOutlet(child, context);
  30586. break;
  30587. case 3:
  30588. break;
  30589. default:
  30590. context.onError(
  30591. createSSRCompilerError(
  30592. 67,
  30593. child.loc
  30594. )
  30595. );
  30596. const exhaustiveCheck2 = child;
  30597. return exhaustiveCheck2;
  30598. }
  30599. break;
  30600. case 2:
  30601. context.pushStringPart(escapeHtml(child.content));
  30602. break;
  30603. case 3:
  30604. context.pushStringPart(`<!--${child.content}-->`);
  30605. break;
  30606. case 5:
  30607. context.pushStringPart(
  30608. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30609. child.content
  30610. ])
  30611. );
  30612. break;
  30613. case 9:
  30614. ssrProcessIf(child, context, disableNestedFragments);
  30615. break;
  30616. case 11:
  30617. ssrProcessFor(child, context, disableNestedFragments);
  30618. break;
  30619. case 10:
  30620. break;
  30621. case 12:
  30622. case 8:
  30623. break;
  30624. default:
  30625. context.onError(
  30626. createSSRCompilerError(
  30627. 67,
  30628. child.loc
  30629. )
  30630. );
  30631. const exhaustiveCheck = child;
  30632. return exhaustiveCheck;
  30633. }
  30634. }
  30635. if (asFragment) {
  30636. context.pushStringPart(`<!--]-->`);
  30637. }
  30638. }
  30639. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  30640. const childContext = createChildContext(parentContext, withSlotScopeId);
  30641. processChildren(parent, childContext, asFragment);
  30642. return createBlockStatement(childContext.body);
  30643. }
  30644. const ssrTransformModel = (dir, node, context) => {
  30645. const model = dir.exp;
  30646. function checkDuplicatedValue() {
  30647. const value = findProp(node, "value");
  30648. if (value) {
  30649. context.onError(
  30650. createDOMCompilerError(
  30651. 60,
  30652. value.loc
  30653. )
  30654. );
  30655. }
  30656. }
  30657. function processOption(plainNode) {
  30658. if (plainNode.tag === "option") {
  30659. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  30660. const value = findValueBinding(plainNode);
  30661. plainNode.ssrCodegenNode.elements.push(
  30662. createConditionalExpression(
  30663. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  30664. createConditionalExpression(
  30665. createCallExpression(`Array.isArray`, [model]),
  30666. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30667. model,
  30668. value
  30669. ]),
  30670. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30671. model,
  30672. value
  30673. ])
  30674. )
  30675. ]),
  30676. createSimpleExpression(" selected", true),
  30677. createSimpleExpression("", true),
  30678. false
  30679. )
  30680. );
  30681. }
  30682. } else if (plainNode.tag === "optgroup") {
  30683. plainNode.children.forEach(
  30684. (option) => processOption(option)
  30685. );
  30686. }
  30687. }
  30688. if (node.tagType === 0) {
  30689. const res = { props: [] };
  30690. const defaultProps = [
  30691. // default value binding for text type inputs
  30692. createObjectProperty(`value`, model)
  30693. ];
  30694. if (node.tag === "input") {
  30695. const type = findProp(node, "type");
  30696. if (type) {
  30697. const value = findValueBinding(node);
  30698. if (type.type === 7) {
  30699. res.ssrTagParts = [
  30700. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  30701. type.exp,
  30702. model,
  30703. value
  30704. ])
  30705. ];
  30706. } else if (type.value) {
  30707. switch (type.value.content) {
  30708. case "radio":
  30709. res.props = [
  30710. createObjectProperty(
  30711. `checked`,
  30712. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30713. model,
  30714. value
  30715. ])
  30716. )
  30717. ];
  30718. break;
  30719. case "checkbox":
  30720. const trueValueBinding = findProp(node, "true-value");
  30721. if (trueValueBinding) {
  30722. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  30723. res.props = [
  30724. createObjectProperty(
  30725. `checked`,
  30726. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30727. model,
  30728. trueValue
  30729. ])
  30730. )
  30731. ];
  30732. } else {
  30733. res.props = [
  30734. createObjectProperty(
  30735. `checked`,
  30736. createConditionalExpression(
  30737. createCallExpression(`Array.isArray`, [model]),
  30738. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30739. model,
  30740. value
  30741. ]),
  30742. model
  30743. )
  30744. )
  30745. ];
  30746. }
  30747. break;
  30748. case "file":
  30749. context.onError(
  30750. createDOMCompilerError(
  30751. 59,
  30752. dir.loc
  30753. )
  30754. );
  30755. break;
  30756. default:
  30757. checkDuplicatedValue();
  30758. res.props = defaultProps;
  30759. break;
  30760. }
  30761. }
  30762. } else if (hasDynamicKeyVBind(node)) ; else {
  30763. checkDuplicatedValue();
  30764. res.props = defaultProps;
  30765. }
  30766. } else if (node.tag === "textarea") {
  30767. checkDuplicatedValue();
  30768. node.children = [createInterpolation(model, model.loc)];
  30769. } else if (node.tag === "select") {
  30770. node.children.forEach((child) => {
  30771. if (child.type === 1) {
  30772. processOption(child);
  30773. }
  30774. });
  30775. } else {
  30776. context.onError(
  30777. createDOMCompilerError(
  30778. 57,
  30779. dir.loc
  30780. )
  30781. );
  30782. }
  30783. return res;
  30784. } else {
  30785. return transformModel$1(dir, node, context);
  30786. }
  30787. };
  30788. function findValueBinding(node) {
  30789. const valueBinding = findProp(node, "value");
  30790. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  30791. }
  30792. const ssrTransformShow = (dir, node, context) => {
  30793. if (!dir.exp) {
  30794. context.onError(
  30795. createDOMCompilerError(61)
  30796. );
  30797. }
  30798. return {
  30799. props: [
  30800. createObjectProperty(
  30801. `style`,
  30802. createConditionalExpression(
  30803. dir.exp,
  30804. createSimpleExpression(`null`, false),
  30805. createObjectExpression([
  30806. createObjectProperty(
  30807. `display`,
  30808. createSimpleExpression(`none`, true)
  30809. )
  30810. ]),
  30811. false
  30812. )
  30813. )
  30814. ]
  30815. };
  30816. };
  30817. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  30818. const hasSingleChild = (node) => filterChild(node).length === 1;
  30819. const ssrInjectFallthroughAttrs = (node, context) => {
  30820. if (node.type === 0) {
  30821. context.identifiers._attrs = 1;
  30822. }
  30823. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  30824. const rootChildren = filterChild(context.root);
  30825. if (rootChildren.length === 1 && rootChildren[0] === node) {
  30826. if (hasSingleChild(node)) {
  30827. injectFallthroughAttrs(node.children[0]);
  30828. }
  30829. return;
  30830. }
  30831. }
  30832. const parent = context.parent;
  30833. if (!parent || parent.type !== 0) {
  30834. return;
  30835. }
  30836. if (node.type === 10 && hasSingleChild(node)) {
  30837. let hasEncounteredIf = false;
  30838. for (const c of filterChild(parent)) {
  30839. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  30840. if (hasEncounteredIf)
  30841. return;
  30842. hasEncounteredIf = true;
  30843. } else if (
  30844. // node before v-if
  30845. !hasEncounteredIf || // non else nodes
  30846. !(c.type === 1 && findDir(c, /else/, true))
  30847. ) {
  30848. return;
  30849. }
  30850. }
  30851. injectFallthroughAttrs(node.children[0]);
  30852. } else if (hasSingleChild(parent)) {
  30853. injectFallthroughAttrs(node);
  30854. }
  30855. };
  30856. function injectFallthroughAttrs(node) {
  30857. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30858. node.props.push({
  30859. type: 7,
  30860. name: "bind",
  30861. arg: void 0,
  30862. exp: createSimpleExpression(`_attrs`, false),
  30863. modifiers: [],
  30864. loc: locStub
  30865. });
  30866. }
  30867. }
  30868. const ssrInjectCssVars = (node, context) => {
  30869. if (!context.ssrCssVars) {
  30870. return;
  30871. }
  30872. if (node.type === 0) {
  30873. context.identifiers._cssVars = 1;
  30874. }
  30875. const parent = context.parent;
  30876. if (!parent || parent.type !== 0) {
  30877. return;
  30878. }
  30879. if (node.type === 10) {
  30880. for (const child of node.children) {
  30881. injectCssVars(child);
  30882. }
  30883. } else {
  30884. injectCssVars(node);
  30885. }
  30886. };
  30887. function injectCssVars(node) {
  30888. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30889. if (node.tag === "suspense" || node.tag === "Suspense") {
  30890. for (const child of node.children) {
  30891. if (child.type === 1 && child.tagType === 3) {
  30892. child.children.forEach(injectCssVars);
  30893. } else {
  30894. injectCssVars(child);
  30895. }
  30896. }
  30897. } else {
  30898. node.props.push({
  30899. type: 7,
  30900. name: "bind",
  30901. arg: void 0,
  30902. exp: createSimpleExpression(`_cssVars`, false),
  30903. modifiers: [],
  30904. loc: locStub
  30905. });
  30906. }
  30907. }
  30908. }
  30909. var __defProp$7 = Object.defineProperty;
  30910. var __defProps$6 = Object.defineProperties;
  30911. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  30912. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  30913. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  30914. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  30915. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30916. var __spreadValues$7 = (a, b) => {
  30917. for (var prop in b || (b = {}))
  30918. if (__hasOwnProp$7.call(b, prop))
  30919. __defNormalProp$7(a, prop, b[prop]);
  30920. if (__getOwnPropSymbols$7)
  30921. for (var prop of __getOwnPropSymbols$7(b)) {
  30922. if (__propIsEnum$7.call(b, prop))
  30923. __defNormalProp$7(a, prop, b[prop]);
  30924. }
  30925. return a;
  30926. };
  30927. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  30928. function compile(source, options = {}) {
  30929. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  30930. ssr: true,
  30931. inSSR: true,
  30932. scopeId: options.mode === "function" ? null : options.scopeId,
  30933. // always prefix since compiler-ssr doesn't have size concern
  30934. prefixIdentifiers: true,
  30935. // disable optimizations that are unnecessary for ssr
  30936. cacheHandlers: false,
  30937. hoistStatic: false
  30938. });
  30939. const ast = typeof source === "string" ? baseParse(source, options) : source;
  30940. rawOptionsMap.set(ast, options);
  30941. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  30942. hoistStatic: false,
  30943. nodeTransforms: [
  30944. ssrTransformIf,
  30945. ssrTransformFor,
  30946. trackVForSlotScopes,
  30947. transformExpression,
  30948. ssrTransformSlotOutlet,
  30949. ssrInjectFallthroughAttrs,
  30950. ssrInjectCssVars,
  30951. ssrTransformElement,
  30952. ssrTransformComponent,
  30953. trackSlotScopes,
  30954. transformStyle,
  30955. ...options.nodeTransforms || []
  30956. // user transforms
  30957. ],
  30958. directiveTransforms: __spreadValues$7({
  30959. // reusing core v-bind
  30960. bind: transformBind,
  30961. on: transformOn$1,
  30962. // model and show have dedicated SSR handling
  30963. model: ssrTransformModel,
  30964. show: ssrTransformShow,
  30965. // the following are ignored during SSR
  30966. // on: noopDirectiveTransform,
  30967. cloak: noopDirectiveTransform,
  30968. once: noopDirectiveTransform,
  30969. memo: noopDirectiveTransform
  30970. }, options.directiveTransforms || {})
  30971. }));
  30972. ssrCodegenTransform(ast, options);
  30973. return generate(ast, options);
  30974. }
  30975. var CompilerSSR = /*#__PURE__*/Object.freeze({
  30976. __proto__: null,
  30977. compile: compile
  30978. });
  30979. var _polyfillNode_fs = {};
  30980. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  30981. __proto__: null,
  30982. default: _polyfillNode_fs
  30983. });
  30984. var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  30985. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  30986. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  30987. const hasWarned = {};
  30988. function warnOnce$3(msg) {
  30989. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  30990. if (!isNodeProd && true && !hasWarned[msg]) {
  30991. hasWarned[msg] = true;
  30992. warn(msg);
  30993. }
  30994. }
  30995. function warn(msg) {
  30996. console.warn(
  30997. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  30998. `
  30999. );
  31000. }
  31001. var __defProp$6 = Object.defineProperty;
  31002. var __defProps$5 = Object.defineProperties;
  31003. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  31004. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  31005. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  31006. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  31007. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31008. var __spreadValues$6 = (a, b) => {
  31009. for (var prop in b || (b = {}))
  31010. if (__hasOwnProp$6.call(b, prop))
  31011. __defNormalProp$6(a, prop, b[prop]);
  31012. if (__getOwnPropSymbols$6)
  31013. for (var prop of __getOwnPropSymbols$6(b)) {
  31014. if (__propIsEnum$6.call(b, prop))
  31015. __defNormalProp$6(a, prop, b[prop]);
  31016. }
  31017. return a;
  31018. };
  31019. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  31020. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  31021. let res = "";
  31022. let err = null;
  31023. preprocessor.render(
  31024. source,
  31025. __spreadValues$6({ filename }, preprocessOptions),
  31026. (_err, _res) => {
  31027. if (_err)
  31028. err = _err;
  31029. res = _res;
  31030. }
  31031. );
  31032. if (err)
  31033. throw err;
  31034. return res;
  31035. }
  31036. function compileTemplate(options) {
  31037. const { preprocessLang, preprocessCustomRequire } = options;
  31038. if (preprocessLang && !preprocessCustomRequire) {
  31039. throw new Error(
  31040. `[@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 }.`
  31041. );
  31042. }
  31043. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  31044. if (preprocessor) {
  31045. try {
  31046. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  31047. source: preprocess$1(options, preprocessor),
  31048. ast: void 0
  31049. // invalidate AST if template goes through preprocessor
  31050. }));
  31051. } catch (e) {
  31052. return {
  31053. code: `export default function render() {}`,
  31054. source: options.source,
  31055. tips: [],
  31056. errors: [e]
  31057. };
  31058. }
  31059. } else if (preprocessLang) {
  31060. return {
  31061. code: `export default function render() {}`,
  31062. source: options.source,
  31063. tips: [
  31064. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  31065. ],
  31066. errors: [
  31067. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  31068. ]
  31069. };
  31070. } else {
  31071. return doCompileTemplate(options);
  31072. }
  31073. }
  31074. function doCompileTemplate({
  31075. filename,
  31076. id,
  31077. scoped,
  31078. slotted,
  31079. inMap,
  31080. source,
  31081. ast: inAST,
  31082. ssr = false,
  31083. ssrCssVars,
  31084. isProd = false,
  31085. compiler,
  31086. compilerOptions = {},
  31087. transformAssetUrls
  31088. }) {
  31089. const errors = [];
  31090. const warnings = [];
  31091. let nodeTransforms = [];
  31092. if (isObject$2(transformAssetUrls)) {
  31093. const assetOptions = normalizeOptions(transformAssetUrls);
  31094. nodeTransforms = [
  31095. createAssetUrlTransformWithOptions(assetOptions),
  31096. createSrcsetTransformWithOptions(assetOptions)
  31097. ];
  31098. } else if (transformAssetUrls !== false) {
  31099. nodeTransforms = [transformAssetUrl, transformSrcset];
  31100. }
  31101. if (ssr && !ssrCssVars) {
  31102. warnOnce$3(
  31103. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.\`.`
  31104. );
  31105. }
  31106. if (!id) {
  31107. warnOnce$3(`compileTemplate now requires the \`id\` option.\`.`);
  31108. id = "";
  31109. }
  31110. const shortId = id.replace(/^data-v-/, "");
  31111. const longId = `data-v-${shortId}`;
  31112. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  31113. compiler = compiler || defaultCompiler;
  31114. if (compiler !== defaultCompiler) {
  31115. inAST = void 0;
  31116. }
  31117. if (inAST == null ? void 0 : inAST.transformed) {
  31118. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  31119. prefixIdentifiers: true
  31120. }, compilerOptions), {
  31121. parseMode: "sfc",
  31122. onError: (e) => errors.push(e)
  31123. }));
  31124. const template = newAST.children.find(
  31125. (node) => node.type === 1 && node.tag === "template"
  31126. );
  31127. inAST = createRoot(template.children, inAST.source);
  31128. }
  31129. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  31130. mode: "module",
  31131. prefixIdentifiers: true,
  31132. hoistStatic: true,
  31133. cacheHandlers: true,
  31134. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  31135. scopeId: scoped ? longId : void 0,
  31136. slotted,
  31137. sourceMap: true
  31138. }, compilerOptions), {
  31139. hmr: !isProd,
  31140. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  31141. filename,
  31142. onError: (e) => errors.push(e),
  31143. onWarn: (w) => warnings.push(w)
  31144. }));
  31145. if (inMap && !inAST) {
  31146. if (map) {
  31147. map = mapLines(inMap, map);
  31148. }
  31149. if (errors.length) {
  31150. patchErrors(errors, source, inMap);
  31151. }
  31152. }
  31153. const tips = warnings.map((w) => {
  31154. let msg = w.message;
  31155. if (w.loc) {
  31156. msg += `
  31157. ${generateCodeFrame(
  31158. (inAST == null ? void 0 : inAST.source) || source,
  31159. w.loc.start.offset,
  31160. w.loc.end.offset
  31161. )}`;
  31162. }
  31163. return msg;
  31164. });
  31165. return { code, ast, preamble, source, errors, tips, map };
  31166. }
  31167. function mapLines(oldMap, newMap) {
  31168. if (!oldMap)
  31169. return newMap;
  31170. if (!newMap)
  31171. return oldMap;
  31172. const oldMapConsumer = new SourceMapConsumer$5(oldMap);
  31173. const newMapConsumer = new SourceMapConsumer$5(newMap);
  31174. const mergedMapGenerator = new SourceMapGenerator$6();
  31175. newMapConsumer.eachMapping((m) => {
  31176. if (m.originalLine == null) {
  31177. return;
  31178. }
  31179. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  31180. line: m.originalLine,
  31181. column: m.originalColumn
  31182. });
  31183. if (origPosInOldMap.source == null) {
  31184. return;
  31185. }
  31186. mergedMapGenerator.addMapping({
  31187. generated: {
  31188. line: m.generatedLine,
  31189. column: m.generatedColumn
  31190. },
  31191. original: {
  31192. line: origPosInOldMap.line,
  31193. // map line
  31194. // use current column, since the oldMap produced by @vue/compiler-sfc
  31195. // does not
  31196. column: m.originalColumn
  31197. },
  31198. source: origPosInOldMap.source,
  31199. name: origPosInOldMap.name
  31200. });
  31201. });
  31202. const generator = mergedMapGenerator;
  31203. oldMapConsumer.sources.forEach((sourceFile) => {
  31204. generator._sources.add(sourceFile);
  31205. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  31206. if (sourceContent != null) {
  31207. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  31208. }
  31209. });
  31210. generator._sourceRoot = oldMap.sourceRoot;
  31211. generator._file = oldMap.file;
  31212. return generator.toJSON();
  31213. }
  31214. function patchErrors(errors, source, inMap) {
  31215. const originalSource = inMap.sourcesContent[0];
  31216. const offset = originalSource.indexOf(source);
  31217. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  31218. errors.forEach((err) => {
  31219. if (err.loc) {
  31220. err.loc.start.line += lineOffset;
  31221. err.loc.start.offset += offset;
  31222. if (err.loc.end !== err.loc.start) {
  31223. err.loc.end.line += lineOffset;
  31224. err.loc.end.offset += offset;
  31225. }
  31226. }
  31227. });
  31228. }
  31229. var picocolors = {exports: {}};
  31230. // MIT lisence
  31231. // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
  31232. function isatty() {
  31233. return false;
  31234. }
  31235. function ReadStream() {
  31236. throw new Error('tty.ReadStream is not implemented');
  31237. }
  31238. function WriteStream() {
  31239. throw new Error('tty.ReadStream is not implemented');
  31240. }
  31241. var _polyfillNode_tty = {
  31242. isatty: isatty,
  31243. ReadStream: ReadStream,
  31244. WriteStream: WriteStream
  31245. };
  31246. var _polyfillNode_tty$1 = /*#__PURE__*/Object.freeze({
  31247. __proto__: null,
  31248. ReadStream: ReadStream,
  31249. WriteStream: WriteStream,
  31250. default: _polyfillNode_tty,
  31251. isatty: isatty
  31252. });
  31253. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_tty$1);
  31254. let tty = require$$0;
  31255. let isColorSupported =
  31256. !("NO_COLOR" in ({}) || browser$1.argv.includes("--no-color")) &&
  31257. ("FORCE_COLOR" in ({}) ||
  31258. browser$1.argv.includes("--color") ||
  31259. "" === "win32" ||
  31260. (tty.isatty(1) && browser$1.env.TERM !== "dumb") ||
  31261. "CI" in ({}));
  31262. let formatter =
  31263. (open, close, replace = open) =>
  31264. input => {
  31265. let string = "" + input;
  31266. let index = string.indexOf(close, open.length);
  31267. return ~index
  31268. ? open + replaceClose(string, close, replace, index) + close
  31269. : open + string + close
  31270. };
  31271. let replaceClose = (string, close, replace, index) => {
  31272. let start = string.substring(0, index) + replace;
  31273. let end = string.substring(index + close.length);
  31274. let nextIndex = end.indexOf(close);
  31275. return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
  31276. };
  31277. let createColors = (enabled = isColorSupported) => ({
  31278. isColorSupported: enabled,
  31279. reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
  31280. bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
  31281. dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
  31282. italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
  31283. underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
  31284. inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
  31285. hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
  31286. strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
  31287. black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
  31288. red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
  31289. green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
  31290. yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
  31291. blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
  31292. magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
  31293. cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
  31294. white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
  31295. gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
  31296. bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
  31297. bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
  31298. bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
  31299. bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
  31300. bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
  31301. bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
  31302. bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
  31303. bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
  31304. });
  31305. picocolors.exports = createColors();
  31306. picocolors.exports.createColors = createColors;
  31307. var picocolorsExports = picocolors.exports;
  31308. const SINGLE_QUOTE = "'".charCodeAt(0);
  31309. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  31310. const BACKSLASH = '\\'.charCodeAt(0);
  31311. const SLASH = '/'.charCodeAt(0);
  31312. const NEWLINE = '\n'.charCodeAt(0);
  31313. const SPACE = ' '.charCodeAt(0);
  31314. const FEED = '\f'.charCodeAt(0);
  31315. const TAB = '\t'.charCodeAt(0);
  31316. const CR = '\r'.charCodeAt(0);
  31317. const OPEN_SQUARE = '['.charCodeAt(0);
  31318. const CLOSE_SQUARE = ']'.charCodeAt(0);
  31319. const OPEN_PARENTHESES = '('.charCodeAt(0);
  31320. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  31321. const OPEN_CURLY = '{'.charCodeAt(0);
  31322. const CLOSE_CURLY = '}'.charCodeAt(0);
  31323. const SEMICOLON = ';'.charCodeAt(0);
  31324. const ASTERISK = '*'.charCodeAt(0);
  31325. const COLON = ':'.charCodeAt(0);
  31326. const AT = '@'.charCodeAt(0);
  31327. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  31328. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  31329. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  31330. const RE_HEX_ESCAPE = /[\da-f]/i;
  31331. var tokenize$1 = function tokenizer(input, options = {}) {
  31332. let css = input.css.valueOf();
  31333. let ignore = options.ignoreErrors;
  31334. let code, next, quote, content, escape;
  31335. let escaped, escapePos, prev, n, currentToken;
  31336. let length = css.length;
  31337. let pos = 0;
  31338. let buffer = [];
  31339. let returned = [];
  31340. function position() {
  31341. return pos
  31342. }
  31343. function unclosed(what) {
  31344. throw input.error('Unclosed ' + what, pos)
  31345. }
  31346. function endOfFile() {
  31347. return returned.length === 0 && pos >= length
  31348. }
  31349. function nextToken(opts) {
  31350. if (returned.length) return returned.pop()
  31351. if (pos >= length) return
  31352. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  31353. code = css.charCodeAt(pos);
  31354. switch (code) {
  31355. case NEWLINE:
  31356. case SPACE:
  31357. case TAB:
  31358. case CR:
  31359. case FEED: {
  31360. next = pos;
  31361. do {
  31362. next += 1;
  31363. code = css.charCodeAt(next);
  31364. } while (
  31365. code === SPACE ||
  31366. code === NEWLINE ||
  31367. code === TAB ||
  31368. code === CR ||
  31369. code === FEED
  31370. )
  31371. currentToken = ['space', css.slice(pos, next)];
  31372. pos = next - 1;
  31373. break
  31374. }
  31375. case OPEN_SQUARE:
  31376. case CLOSE_SQUARE:
  31377. case OPEN_CURLY:
  31378. case CLOSE_CURLY:
  31379. case COLON:
  31380. case SEMICOLON:
  31381. case CLOSE_PARENTHESES: {
  31382. let controlChar = String.fromCharCode(code);
  31383. currentToken = [controlChar, controlChar, pos];
  31384. break
  31385. }
  31386. case OPEN_PARENTHESES: {
  31387. prev = buffer.length ? buffer.pop()[1] : '';
  31388. n = css.charCodeAt(pos + 1);
  31389. if (
  31390. prev === 'url' &&
  31391. n !== SINGLE_QUOTE &&
  31392. n !== DOUBLE_QUOTE &&
  31393. n !== SPACE &&
  31394. n !== NEWLINE &&
  31395. n !== TAB &&
  31396. n !== FEED &&
  31397. n !== CR
  31398. ) {
  31399. next = pos;
  31400. do {
  31401. escaped = false;
  31402. next = css.indexOf(')', next + 1);
  31403. if (next === -1) {
  31404. if (ignore || ignoreUnclosed) {
  31405. next = pos;
  31406. break
  31407. } else {
  31408. unclosed('bracket');
  31409. }
  31410. }
  31411. escapePos = next;
  31412. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31413. escapePos -= 1;
  31414. escaped = !escaped;
  31415. }
  31416. } while (escaped)
  31417. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  31418. pos = next;
  31419. } else {
  31420. next = css.indexOf(')', pos + 1);
  31421. content = css.slice(pos, next + 1);
  31422. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  31423. currentToken = ['(', '(', pos];
  31424. } else {
  31425. currentToken = ['brackets', content, pos, next];
  31426. pos = next;
  31427. }
  31428. }
  31429. break
  31430. }
  31431. case SINGLE_QUOTE:
  31432. case DOUBLE_QUOTE: {
  31433. quote = code === SINGLE_QUOTE ? "'" : '"';
  31434. next = pos;
  31435. do {
  31436. escaped = false;
  31437. next = css.indexOf(quote, next + 1);
  31438. if (next === -1) {
  31439. if (ignore || ignoreUnclosed) {
  31440. next = pos + 1;
  31441. break
  31442. } else {
  31443. unclosed('string');
  31444. }
  31445. }
  31446. escapePos = next;
  31447. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31448. escapePos -= 1;
  31449. escaped = !escaped;
  31450. }
  31451. } while (escaped)
  31452. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  31453. pos = next;
  31454. break
  31455. }
  31456. case AT: {
  31457. RE_AT_END.lastIndex = pos + 1;
  31458. RE_AT_END.test(css);
  31459. if (RE_AT_END.lastIndex === 0) {
  31460. next = css.length - 1;
  31461. } else {
  31462. next = RE_AT_END.lastIndex - 2;
  31463. }
  31464. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  31465. pos = next;
  31466. break
  31467. }
  31468. case BACKSLASH: {
  31469. next = pos;
  31470. escape = true;
  31471. while (css.charCodeAt(next + 1) === BACKSLASH) {
  31472. next += 1;
  31473. escape = !escape;
  31474. }
  31475. code = css.charCodeAt(next + 1);
  31476. if (
  31477. escape &&
  31478. code !== SLASH &&
  31479. code !== SPACE &&
  31480. code !== NEWLINE &&
  31481. code !== TAB &&
  31482. code !== CR &&
  31483. code !== FEED
  31484. ) {
  31485. next += 1;
  31486. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  31487. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  31488. next += 1;
  31489. }
  31490. if (css.charCodeAt(next + 1) === SPACE) {
  31491. next += 1;
  31492. }
  31493. }
  31494. }
  31495. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31496. pos = next;
  31497. break
  31498. }
  31499. default: {
  31500. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  31501. next = css.indexOf('*/', pos + 2) + 1;
  31502. if (next === 0) {
  31503. if (ignore || ignoreUnclosed) {
  31504. next = css.length;
  31505. } else {
  31506. unclosed('comment');
  31507. }
  31508. }
  31509. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  31510. pos = next;
  31511. } else {
  31512. RE_WORD_END.lastIndex = pos + 1;
  31513. RE_WORD_END.test(css);
  31514. if (RE_WORD_END.lastIndex === 0) {
  31515. next = css.length - 1;
  31516. } else {
  31517. next = RE_WORD_END.lastIndex - 2;
  31518. }
  31519. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31520. buffer.push(currentToken);
  31521. pos = next;
  31522. }
  31523. break
  31524. }
  31525. }
  31526. pos++;
  31527. return currentToken
  31528. }
  31529. function back(token) {
  31530. returned.push(token);
  31531. }
  31532. return {
  31533. back,
  31534. endOfFile,
  31535. nextToken,
  31536. position
  31537. }
  31538. };
  31539. let pico$1 = picocolorsExports;
  31540. let tokenizer$1 = tokenize$1;
  31541. let Input$5;
  31542. function registerInput(dependant) {
  31543. Input$5 = dependant;
  31544. }
  31545. const HIGHLIGHT_THEME = {
  31546. ';': pico$1.yellow,
  31547. ':': pico$1.yellow,
  31548. '(': pico$1.cyan,
  31549. ')': pico$1.cyan,
  31550. '[': pico$1.yellow,
  31551. ']': pico$1.yellow,
  31552. '{': pico$1.yellow,
  31553. '}': pico$1.yellow,
  31554. 'at-word': pico$1.cyan,
  31555. 'brackets': pico$1.cyan,
  31556. 'call': pico$1.cyan,
  31557. 'class': pico$1.yellow,
  31558. 'comment': pico$1.gray,
  31559. 'hash': pico$1.magenta,
  31560. 'string': pico$1.green
  31561. };
  31562. function getTokenType([type, value], processor) {
  31563. if (type === 'word') {
  31564. if (value[0] === '.') {
  31565. return 'class'
  31566. }
  31567. if (value[0] === '#') {
  31568. return 'hash'
  31569. }
  31570. }
  31571. if (!processor.endOfFile()) {
  31572. let next = processor.nextToken();
  31573. processor.back(next);
  31574. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  31575. }
  31576. return type
  31577. }
  31578. function terminalHighlight$2(css) {
  31579. let processor = tokenizer$1(new Input$5(css), { ignoreErrors: true });
  31580. let result = '';
  31581. while (!processor.endOfFile()) {
  31582. let token = processor.nextToken();
  31583. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  31584. if (color) {
  31585. result += token[1]
  31586. .split(/\r?\n/)
  31587. .map(i => color(i))
  31588. .join('\n');
  31589. } else {
  31590. result += token[1];
  31591. }
  31592. }
  31593. return result
  31594. }
  31595. terminalHighlight$2.registerInput = registerInput;
  31596. var terminalHighlight_1 = terminalHighlight$2;
  31597. let pico = picocolorsExports;
  31598. let terminalHighlight$1 = terminalHighlight_1;
  31599. let CssSyntaxError$3 = class CssSyntaxError extends Error {
  31600. constructor(message, line, column, source, file, plugin) {
  31601. super(message);
  31602. this.name = 'CssSyntaxError';
  31603. this.reason = message;
  31604. if (file) {
  31605. this.file = file;
  31606. }
  31607. if (source) {
  31608. this.source = source;
  31609. }
  31610. if (plugin) {
  31611. this.plugin = plugin;
  31612. }
  31613. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  31614. if (typeof line === 'number') {
  31615. this.line = line;
  31616. this.column = column;
  31617. } else {
  31618. this.line = line.line;
  31619. this.column = line.column;
  31620. this.endLine = column.line;
  31621. this.endColumn = column.column;
  31622. }
  31623. }
  31624. this.setMessage();
  31625. if (Error.captureStackTrace) {
  31626. Error.captureStackTrace(this, CssSyntaxError);
  31627. }
  31628. }
  31629. setMessage() {
  31630. this.message = this.plugin ? this.plugin + ': ' : '';
  31631. this.message += this.file ? this.file : '<css input>';
  31632. if (typeof this.line !== 'undefined') {
  31633. this.message += ':' + this.line + ':' + this.column;
  31634. }
  31635. this.message += ': ' + this.reason;
  31636. }
  31637. showSourceCode(color) {
  31638. if (!this.source) return ''
  31639. let css = this.source;
  31640. if (color == null) color = pico.isColorSupported;
  31641. if (terminalHighlight$1) {
  31642. if (color) css = terminalHighlight$1(css);
  31643. }
  31644. let lines = css.split(/\r?\n/);
  31645. let start = Math.max(this.line - 3, 0);
  31646. let end = Math.min(this.line + 2, lines.length);
  31647. let maxWidth = String(end).length;
  31648. let mark, aside;
  31649. if (color) {
  31650. let { bold, gray, red } = pico.createColors(true);
  31651. mark = text => bold(red(text));
  31652. aside = text => gray(text);
  31653. } else {
  31654. mark = aside = str => str;
  31655. }
  31656. return lines
  31657. .slice(start, end)
  31658. .map((line, index) => {
  31659. let number = start + 1 + index;
  31660. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  31661. if (number === this.line) {
  31662. let spacing =
  31663. aside(gutter.replace(/\d/g, ' ')) +
  31664. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  31665. return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
  31666. }
  31667. return ' ' + aside(gutter) + line
  31668. })
  31669. .join('\n')
  31670. }
  31671. toString() {
  31672. let code = this.showSourceCode();
  31673. if (code) {
  31674. code = '\n\n' + code + '\n';
  31675. }
  31676. return this.name + ': ' + this.message + code
  31677. }
  31678. };
  31679. var cssSyntaxError = CssSyntaxError$3;
  31680. CssSyntaxError$3.default = CssSyntaxError$3;
  31681. var symbols = {};
  31682. symbols.isClean = Symbol('isClean');
  31683. symbols.my = Symbol('my');
  31684. const DEFAULT_RAW = {
  31685. after: '\n',
  31686. beforeClose: '\n',
  31687. beforeComment: '\n',
  31688. beforeDecl: '\n',
  31689. beforeOpen: ' ',
  31690. beforeRule: '\n',
  31691. colon: ': ',
  31692. commentLeft: ' ',
  31693. commentRight: ' ',
  31694. emptyBody: '',
  31695. indent: ' ',
  31696. semicolon: false
  31697. };
  31698. function capitalize(str) {
  31699. return str[0].toUpperCase() + str.slice(1)
  31700. }
  31701. let Stringifier$2 = class Stringifier {
  31702. constructor(builder) {
  31703. this.builder = builder;
  31704. }
  31705. atrule(node, semicolon) {
  31706. let name = '@' + node.name;
  31707. let params = node.params ? this.rawValue(node, 'params') : '';
  31708. if (typeof node.raws.afterName !== 'undefined') {
  31709. name += node.raws.afterName;
  31710. } else if (params) {
  31711. name += ' ';
  31712. }
  31713. if (node.nodes) {
  31714. this.block(node, name + params);
  31715. } else {
  31716. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  31717. this.builder(name + params + end, node);
  31718. }
  31719. }
  31720. beforeAfter(node, detect) {
  31721. let value;
  31722. if (node.type === 'decl') {
  31723. value = this.raw(node, null, 'beforeDecl');
  31724. } else if (node.type === 'comment') {
  31725. value = this.raw(node, null, 'beforeComment');
  31726. } else if (detect === 'before') {
  31727. value = this.raw(node, null, 'beforeRule');
  31728. } else {
  31729. value = this.raw(node, null, 'beforeClose');
  31730. }
  31731. let buf = node.parent;
  31732. let depth = 0;
  31733. while (buf && buf.type !== 'root') {
  31734. depth += 1;
  31735. buf = buf.parent;
  31736. }
  31737. if (value.includes('\n')) {
  31738. let indent = this.raw(node, null, 'indent');
  31739. if (indent.length) {
  31740. for (let step = 0; step < depth; step++) value += indent;
  31741. }
  31742. }
  31743. return value
  31744. }
  31745. block(node, start) {
  31746. let between = this.raw(node, 'between', 'beforeOpen');
  31747. this.builder(start + between + '{', node, 'start');
  31748. let after;
  31749. if (node.nodes && node.nodes.length) {
  31750. this.body(node);
  31751. after = this.raw(node, 'after');
  31752. } else {
  31753. after = this.raw(node, 'after', 'emptyBody');
  31754. }
  31755. if (after) this.builder(after);
  31756. this.builder('}', node, 'end');
  31757. }
  31758. body(node) {
  31759. let last = node.nodes.length - 1;
  31760. while (last > 0) {
  31761. if (node.nodes[last].type !== 'comment') break
  31762. last -= 1;
  31763. }
  31764. let semicolon = this.raw(node, 'semicolon');
  31765. for (let i = 0; i < node.nodes.length; i++) {
  31766. let child = node.nodes[i];
  31767. let before = this.raw(child, 'before');
  31768. if (before) this.builder(before);
  31769. this.stringify(child, last !== i || semicolon);
  31770. }
  31771. }
  31772. comment(node) {
  31773. let left = this.raw(node, 'left', 'commentLeft');
  31774. let right = this.raw(node, 'right', 'commentRight');
  31775. this.builder('/*' + left + node.text + right + '*/', node);
  31776. }
  31777. decl(node, semicolon) {
  31778. let between = this.raw(node, 'between', 'colon');
  31779. let string = node.prop + between + this.rawValue(node, 'value');
  31780. if (node.important) {
  31781. string += node.raws.important || ' !important';
  31782. }
  31783. if (semicolon) string += ';';
  31784. this.builder(string, node);
  31785. }
  31786. document(node) {
  31787. this.body(node);
  31788. }
  31789. raw(node, own, detect) {
  31790. let value;
  31791. if (!detect) detect = own;
  31792. // Already had
  31793. if (own) {
  31794. value = node.raws[own];
  31795. if (typeof value !== 'undefined') return value
  31796. }
  31797. let parent = node.parent;
  31798. if (detect === 'before') {
  31799. // Hack for first rule in CSS
  31800. if (!parent || (parent.type === 'root' && parent.first === node)) {
  31801. return ''
  31802. }
  31803. // `root` nodes in `document` should use only their own raws
  31804. if (parent && parent.type === 'document') {
  31805. return ''
  31806. }
  31807. }
  31808. // Floating child without parent
  31809. if (!parent) return DEFAULT_RAW[detect]
  31810. // Detect style by other nodes
  31811. let root = node.root();
  31812. if (!root.rawCache) root.rawCache = {};
  31813. if (typeof root.rawCache[detect] !== 'undefined') {
  31814. return root.rawCache[detect]
  31815. }
  31816. if (detect === 'before' || detect === 'after') {
  31817. return this.beforeAfter(node, detect)
  31818. } else {
  31819. let method = 'raw' + capitalize(detect);
  31820. if (this[method]) {
  31821. value = this[method](root, node);
  31822. } else {
  31823. root.walk(i => {
  31824. value = i.raws[own];
  31825. if (typeof value !== 'undefined') return false
  31826. });
  31827. }
  31828. }
  31829. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  31830. root.rawCache[detect] = value;
  31831. return value
  31832. }
  31833. rawBeforeClose(root) {
  31834. let value;
  31835. root.walk(i => {
  31836. if (i.nodes && i.nodes.length > 0) {
  31837. if (typeof i.raws.after !== 'undefined') {
  31838. value = i.raws.after;
  31839. if (value.includes('\n')) {
  31840. value = value.replace(/[^\n]+$/, '');
  31841. }
  31842. return false
  31843. }
  31844. }
  31845. });
  31846. if (value) value = value.replace(/\S/g, '');
  31847. return value
  31848. }
  31849. rawBeforeComment(root, node) {
  31850. let value;
  31851. root.walkComments(i => {
  31852. if (typeof i.raws.before !== 'undefined') {
  31853. value = i.raws.before;
  31854. if (value.includes('\n')) {
  31855. value = value.replace(/[^\n]+$/, '');
  31856. }
  31857. return false
  31858. }
  31859. });
  31860. if (typeof value === 'undefined') {
  31861. value = this.raw(node, null, 'beforeDecl');
  31862. } else if (value) {
  31863. value = value.replace(/\S/g, '');
  31864. }
  31865. return value
  31866. }
  31867. rawBeforeDecl(root, node) {
  31868. let value;
  31869. root.walkDecls(i => {
  31870. if (typeof i.raws.before !== 'undefined') {
  31871. value = i.raws.before;
  31872. if (value.includes('\n')) {
  31873. value = value.replace(/[^\n]+$/, '');
  31874. }
  31875. return false
  31876. }
  31877. });
  31878. if (typeof value === 'undefined') {
  31879. value = this.raw(node, null, 'beforeRule');
  31880. } else if (value) {
  31881. value = value.replace(/\S/g, '');
  31882. }
  31883. return value
  31884. }
  31885. rawBeforeOpen(root) {
  31886. let value;
  31887. root.walk(i => {
  31888. if (i.type !== 'decl') {
  31889. value = i.raws.between;
  31890. if (typeof value !== 'undefined') return false
  31891. }
  31892. });
  31893. return value
  31894. }
  31895. rawBeforeRule(root) {
  31896. let value;
  31897. root.walk(i => {
  31898. if (i.nodes && (i.parent !== root || root.first !== i)) {
  31899. if (typeof i.raws.before !== 'undefined') {
  31900. value = i.raws.before;
  31901. if (value.includes('\n')) {
  31902. value = value.replace(/[^\n]+$/, '');
  31903. }
  31904. return false
  31905. }
  31906. }
  31907. });
  31908. if (value) value = value.replace(/\S/g, '');
  31909. return value
  31910. }
  31911. rawColon(root) {
  31912. let value;
  31913. root.walkDecls(i => {
  31914. if (typeof i.raws.between !== 'undefined') {
  31915. value = i.raws.between.replace(/[^\s:]/g, '');
  31916. return false
  31917. }
  31918. });
  31919. return value
  31920. }
  31921. rawEmptyBody(root) {
  31922. let value;
  31923. root.walk(i => {
  31924. if (i.nodes && i.nodes.length === 0) {
  31925. value = i.raws.after;
  31926. if (typeof value !== 'undefined') return false
  31927. }
  31928. });
  31929. return value
  31930. }
  31931. rawIndent(root) {
  31932. if (root.raws.indent) return root.raws.indent
  31933. let value;
  31934. root.walk(i => {
  31935. let p = i.parent;
  31936. if (p && p !== root && p.parent && p.parent === root) {
  31937. if (typeof i.raws.before !== 'undefined') {
  31938. let parts = i.raws.before.split('\n');
  31939. value = parts[parts.length - 1];
  31940. value = value.replace(/\S/g, '');
  31941. return false
  31942. }
  31943. }
  31944. });
  31945. return value
  31946. }
  31947. rawSemicolon(root) {
  31948. let value;
  31949. root.walk(i => {
  31950. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  31951. value = i.raws.semicolon;
  31952. if (typeof value !== 'undefined') return false
  31953. }
  31954. });
  31955. return value
  31956. }
  31957. rawValue(node, prop) {
  31958. let value = node[prop];
  31959. let raw = node.raws[prop];
  31960. if (raw && raw.value === value) {
  31961. return raw.raw
  31962. }
  31963. return value
  31964. }
  31965. root(node) {
  31966. this.body(node);
  31967. if (node.raws.after) this.builder(node.raws.after);
  31968. }
  31969. rule(node) {
  31970. this.block(node, this.rawValue(node, 'selector'));
  31971. if (node.raws.ownSemicolon) {
  31972. this.builder(node.raws.ownSemicolon, node, 'end');
  31973. }
  31974. }
  31975. stringify(node, semicolon) {
  31976. /* c8 ignore start */
  31977. if (!this[node.type]) {
  31978. throw new Error(
  31979. 'Unknown AST node type ' +
  31980. node.type +
  31981. '. ' +
  31982. 'Maybe you need to change PostCSS stringifier.'
  31983. )
  31984. }
  31985. /* c8 ignore stop */
  31986. this[node.type](node, semicolon);
  31987. }
  31988. };
  31989. var stringifier = Stringifier$2;
  31990. Stringifier$2.default = Stringifier$2;
  31991. let Stringifier$1 = stringifier;
  31992. function stringify$4(node, builder) {
  31993. let str = new Stringifier$1(builder);
  31994. str.stringify(node);
  31995. }
  31996. var stringify_1 = stringify$4;
  31997. stringify$4.default = stringify$4;
  31998. let { isClean: isClean$2, my: my$2 } = symbols;
  31999. let CssSyntaxError$2 = cssSyntaxError;
  32000. let Stringifier = stringifier;
  32001. let stringify$3 = stringify_1;
  32002. function cloneNode(obj, parent) {
  32003. let cloned = new obj.constructor();
  32004. for (let i in obj) {
  32005. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  32006. /* c8 ignore next 2 */
  32007. continue
  32008. }
  32009. if (i === 'proxyCache') continue
  32010. let value = obj[i];
  32011. let type = typeof value;
  32012. if (i === 'parent' && type === 'object') {
  32013. if (parent) cloned[i] = parent;
  32014. } else if (i === 'source') {
  32015. cloned[i] = value;
  32016. } else if (Array.isArray(value)) {
  32017. cloned[i] = value.map(j => cloneNode(j, cloned));
  32018. } else {
  32019. if (type === 'object' && value !== null) value = cloneNode(value);
  32020. cloned[i] = value;
  32021. }
  32022. }
  32023. return cloned
  32024. }
  32025. let Node$4 = class Node {
  32026. constructor(defaults = {}) {
  32027. this.raws = {};
  32028. this[isClean$2] = false;
  32029. this[my$2] = true;
  32030. for (let name in defaults) {
  32031. if (name === 'nodes') {
  32032. this.nodes = [];
  32033. for (let node of defaults[name]) {
  32034. if (typeof node.clone === 'function') {
  32035. this.append(node.clone());
  32036. } else {
  32037. this.append(node);
  32038. }
  32039. }
  32040. } else {
  32041. this[name] = defaults[name];
  32042. }
  32043. }
  32044. }
  32045. addToError(error) {
  32046. error.postcssNode = this;
  32047. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  32048. let s = this.source;
  32049. error.stack = error.stack.replace(
  32050. /\n\s{4}at /,
  32051. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  32052. );
  32053. }
  32054. return error
  32055. }
  32056. after(add) {
  32057. this.parent.insertAfter(this, add);
  32058. return this
  32059. }
  32060. assign(overrides = {}) {
  32061. for (let name in overrides) {
  32062. this[name] = overrides[name];
  32063. }
  32064. return this
  32065. }
  32066. before(add) {
  32067. this.parent.insertBefore(this, add);
  32068. return this
  32069. }
  32070. cleanRaws(keepBetween) {
  32071. delete this.raws.before;
  32072. delete this.raws.after;
  32073. if (!keepBetween) delete this.raws.between;
  32074. }
  32075. clone(overrides = {}) {
  32076. let cloned = cloneNode(this);
  32077. for (let name in overrides) {
  32078. cloned[name] = overrides[name];
  32079. }
  32080. return cloned
  32081. }
  32082. cloneAfter(overrides = {}) {
  32083. let cloned = this.clone(overrides);
  32084. this.parent.insertAfter(this, cloned);
  32085. return cloned
  32086. }
  32087. cloneBefore(overrides = {}) {
  32088. let cloned = this.clone(overrides);
  32089. this.parent.insertBefore(this, cloned);
  32090. return cloned
  32091. }
  32092. error(message, opts = {}) {
  32093. if (this.source) {
  32094. let { end, start } = this.rangeBy(opts);
  32095. return this.source.input.error(
  32096. message,
  32097. { column: start.column, line: start.line },
  32098. { column: end.column, line: end.line },
  32099. opts
  32100. )
  32101. }
  32102. return new CssSyntaxError$2(message)
  32103. }
  32104. getProxyProcessor() {
  32105. return {
  32106. get(node, prop) {
  32107. if (prop === 'proxyOf') {
  32108. return node
  32109. } else if (prop === 'root') {
  32110. return () => node.root().toProxy()
  32111. } else {
  32112. return node[prop]
  32113. }
  32114. },
  32115. set(node, prop, value) {
  32116. if (node[prop] === value) return true
  32117. node[prop] = value;
  32118. if (
  32119. prop === 'prop' ||
  32120. prop === 'value' ||
  32121. prop === 'name' ||
  32122. prop === 'params' ||
  32123. prop === 'important' ||
  32124. /* c8 ignore next */
  32125. prop === 'text'
  32126. ) {
  32127. node.markDirty();
  32128. }
  32129. return true
  32130. }
  32131. }
  32132. }
  32133. markDirty() {
  32134. if (this[isClean$2]) {
  32135. this[isClean$2] = false;
  32136. let next = this;
  32137. while ((next = next.parent)) {
  32138. next[isClean$2] = false;
  32139. }
  32140. }
  32141. }
  32142. next() {
  32143. if (!this.parent) return undefined
  32144. let index = this.parent.index(this);
  32145. return this.parent.nodes[index + 1]
  32146. }
  32147. positionBy(opts, stringRepresentation) {
  32148. let pos = this.source.start;
  32149. if (opts.index) {
  32150. pos = this.positionInside(opts.index, stringRepresentation);
  32151. } else if (opts.word) {
  32152. stringRepresentation = this.toString();
  32153. let index = stringRepresentation.indexOf(opts.word);
  32154. if (index !== -1) pos = this.positionInside(index, stringRepresentation);
  32155. }
  32156. return pos
  32157. }
  32158. positionInside(index, stringRepresentation) {
  32159. let string = stringRepresentation || this.toString();
  32160. let column = this.source.start.column;
  32161. let line = this.source.start.line;
  32162. for (let i = 0; i < index; i++) {
  32163. if (string[i] === '\n') {
  32164. column = 1;
  32165. line += 1;
  32166. } else {
  32167. column += 1;
  32168. }
  32169. }
  32170. return { column, line }
  32171. }
  32172. prev() {
  32173. if (!this.parent) return undefined
  32174. let index = this.parent.index(this);
  32175. return this.parent.nodes[index - 1]
  32176. }
  32177. rangeBy(opts) {
  32178. let start = {
  32179. column: this.source.start.column,
  32180. line: this.source.start.line
  32181. };
  32182. let end = this.source.end
  32183. ? {
  32184. column: this.source.end.column + 1,
  32185. line: this.source.end.line
  32186. }
  32187. : {
  32188. column: start.column + 1,
  32189. line: start.line
  32190. };
  32191. if (opts.word) {
  32192. let stringRepresentation = this.toString();
  32193. let index = stringRepresentation.indexOf(opts.word);
  32194. if (index !== -1) {
  32195. start = this.positionInside(index, stringRepresentation);
  32196. end = this.positionInside(index + opts.word.length, stringRepresentation);
  32197. }
  32198. } else {
  32199. if (opts.start) {
  32200. start = {
  32201. column: opts.start.column,
  32202. line: opts.start.line
  32203. };
  32204. } else if (opts.index) {
  32205. start = this.positionInside(opts.index);
  32206. }
  32207. if (opts.end) {
  32208. end = {
  32209. column: opts.end.column,
  32210. line: opts.end.line
  32211. };
  32212. } else if (opts.endIndex) {
  32213. end = this.positionInside(opts.endIndex);
  32214. } else if (opts.index) {
  32215. end = this.positionInside(opts.index + 1);
  32216. }
  32217. }
  32218. if (
  32219. end.line < start.line ||
  32220. (end.line === start.line && end.column <= start.column)
  32221. ) {
  32222. end = { column: start.column + 1, line: start.line };
  32223. }
  32224. return { end, start }
  32225. }
  32226. raw(prop, defaultType) {
  32227. let str = new Stringifier();
  32228. return str.raw(this, prop, defaultType)
  32229. }
  32230. remove() {
  32231. if (this.parent) {
  32232. this.parent.removeChild(this);
  32233. }
  32234. this.parent = undefined;
  32235. return this
  32236. }
  32237. replaceWith(...nodes) {
  32238. if (this.parent) {
  32239. let bookmark = this;
  32240. let foundSelf = false;
  32241. for (let node of nodes) {
  32242. if (node === this) {
  32243. foundSelf = true;
  32244. } else if (foundSelf) {
  32245. this.parent.insertAfter(bookmark, node);
  32246. bookmark = node;
  32247. } else {
  32248. this.parent.insertBefore(bookmark, node);
  32249. }
  32250. }
  32251. if (!foundSelf) {
  32252. this.remove();
  32253. }
  32254. }
  32255. return this
  32256. }
  32257. root() {
  32258. let result = this;
  32259. while (result.parent && result.parent.type !== 'document') {
  32260. result = result.parent;
  32261. }
  32262. return result
  32263. }
  32264. toJSON(_, inputs) {
  32265. let fixed = {};
  32266. let emitInputs = inputs == null;
  32267. inputs = inputs || new Map();
  32268. let inputsNextIndex = 0;
  32269. for (let name in this) {
  32270. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  32271. /* c8 ignore next 2 */
  32272. continue
  32273. }
  32274. if (name === 'parent' || name === 'proxyCache') continue
  32275. let value = this[name];
  32276. if (Array.isArray(value)) {
  32277. fixed[name] = value.map(i => {
  32278. if (typeof i === 'object' && i.toJSON) {
  32279. return i.toJSON(null, inputs)
  32280. } else {
  32281. return i
  32282. }
  32283. });
  32284. } else if (typeof value === 'object' && value.toJSON) {
  32285. fixed[name] = value.toJSON(null, inputs);
  32286. } else if (name === 'source') {
  32287. let inputId = inputs.get(value.input);
  32288. if (inputId == null) {
  32289. inputId = inputsNextIndex;
  32290. inputs.set(value.input, inputsNextIndex);
  32291. inputsNextIndex++;
  32292. }
  32293. fixed[name] = {
  32294. end: value.end,
  32295. inputId,
  32296. start: value.start
  32297. };
  32298. } else {
  32299. fixed[name] = value;
  32300. }
  32301. }
  32302. if (emitInputs) {
  32303. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  32304. }
  32305. return fixed
  32306. }
  32307. toProxy() {
  32308. if (!this.proxyCache) {
  32309. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  32310. }
  32311. return this.proxyCache
  32312. }
  32313. toString(stringifier = stringify$3) {
  32314. if (stringifier.stringify) stringifier = stringifier.stringify;
  32315. let result = '';
  32316. stringifier(this, i => {
  32317. result += i;
  32318. });
  32319. return result
  32320. }
  32321. warn(result, text, opts) {
  32322. let data = { node: this };
  32323. for (let i in opts) data[i] = opts[i];
  32324. return result.warn(text, data)
  32325. }
  32326. get proxyOf() {
  32327. return this
  32328. }
  32329. };
  32330. var node$2 = Node$4;
  32331. Node$4.default = Node$4;
  32332. let Node$3 = node$2;
  32333. let Declaration$4 = class Declaration extends Node$3 {
  32334. constructor(defaults) {
  32335. if (
  32336. defaults &&
  32337. typeof defaults.value !== 'undefined' &&
  32338. typeof defaults.value !== 'string'
  32339. ) {
  32340. defaults = { ...defaults, value: String(defaults.value) };
  32341. }
  32342. super(defaults);
  32343. this.type = 'decl';
  32344. }
  32345. get variable() {
  32346. return this.prop.startsWith('--') || this.prop[0] === '$'
  32347. }
  32348. };
  32349. var declaration = Declaration$4;
  32350. Declaration$4.default = Declaration$4;
  32351. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  32352. let urlAlphabet =
  32353. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  32354. let customAlphabet = (alphabet, defaultSize = 21) => {
  32355. return (size = defaultSize) => {
  32356. let id = '';
  32357. let i = size;
  32358. while (i--) {
  32359. id += alphabet[(Math.random() * alphabet.length) | 0];
  32360. }
  32361. return id
  32362. }
  32363. };
  32364. let nanoid$1 = (size = 21) => {
  32365. let id = '';
  32366. let i = size;
  32367. while (i--) {
  32368. id += urlAlphabet[(Math.random() * 64) | 0];
  32369. }
  32370. return id
  32371. };
  32372. var nonSecure = { nanoid: nanoid$1, customAlphabet };
  32373. let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
  32374. let { existsSync, readFileSync } = require$$0$2;
  32375. let { dirname: dirname$1, join } = require$$1;
  32376. function fromBase64(str) {
  32377. if (Buffer$1) {
  32378. return Buffer$1.from(str, 'base64').toString()
  32379. } else {
  32380. /* c8 ignore next 2 */
  32381. return window.atob(str)
  32382. }
  32383. }
  32384. let PreviousMap$2 = class PreviousMap {
  32385. constructor(css, opts) {
  32386. if (opts.map === false) return
  32387. this.loadAnnotation(css);
  32388. this.inline = this.startWith(this.annotation, 'data:');
  32389. let prev = opts.map ? opts.map.prev : undefined;
  32390. let text = this.loadMap(opts.from, prev);
  32391. if (!this.mapFile && opts.from) {
  32392. this.mapFile = opts.from;
  32393. }
  32394. if (this.mapFile) this.root = dirname$1(this.mapFile);
  32395. if (text) this.text = text;
  32396. }
  32397. consumer() {
  32398. if (!this.consumerCache) {
  32399. this.consumerCache = new SourceMapConsumer$4(this.text);
  32400. }
  32401. return this.consumerCache
  32402. }
  32403. decodeInline(text) {
  32404. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  32405. let baseUri = /^data:application\/json;base64,/;
  32406. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  32407. let uri = /^data:application\/json,/;
  32408. if (charsetUri.test(text) || uri.test(text)) {
  32409. return decodeURIComponent(text.substr(RegExp.lastMatch.length))
  32410. }
  32411. if (baseCharsetUri.test(text) || baseUri.test(text)) {
  32412. return fromBase64(text.substr(RegExp.lastMatch.length))
  32413. }
  32414. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  32415. throw new Error('Unsupported source map encoding ' + encoding)
  32416. }
  32417. getAnnotationURL(sourceMapString) {
  32418. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  32419. }
  32420. isMap(map) {
  32421. if (typeof map !== 'object') return false
  32422. return (
  32423. typeof map.mappings === 'string' ||
  32424. typeof map._mappings === 'string' ||
  32425. Array.isArray(map.sections)
  32426. )
  32427. }
  32428. loadAnnotation(css) {
  32429. let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
  32430. if (!comments) return
  32431. // sourceMappingURLs from comments, strings, etc.
  32432. let start = css.lastIndexOf(comments.pop());
  32433. let end = css.indexOf('*/', start);
  32434. if (start > -1 && end > -1) {
  32435. // Locate the last sourceMappingURL to avoid pickin
  32436. this.annotation = this.getAnnotationURL(css.substring(start, end));
  32437. }
  32438. }
  32439. loadFile(path) {
  32440. this.root = dirname$1(path);
  32441. if (existsSync(path)) {
  32442. this.mapFile = path;
  32443. return readFileSync(path, 'utf-8').toString().trim()
  32444. }
  32445. }
  32446. loadMap(file, prev) {
  32447. if (prev === false) return false
  32448. if (prev) {
  32449. if (typeof prev === 'string') {
  32450. return prev
  32451. } else if (typeof prev === 'function') {
  32452. let prevPath = prev(file);
  32453. if (prevPath) {
  32454. let map = this.loadFile(prevPath);
  32455. if (!map) {
  32456. throw new Error(
  32457. 'Unable to load previous source map: ' + prevPath.toString()
  32458. )
  32459. }
  32460. return map
  32461. }
  32462. } else if (prev instanceof SourceMapConsumer$4) {
  32463. return SourceMapGenerator$5.fromSourceMap(prev).toString()
  32464. } else if (prev instanceof SourceMapGenerator$5) {
  32465. return prev.toString()
  32466. } else if (this.isMap(prev)) {
  32467. return JSON.stringify(prev)
  32468. } else {
  32469. throw new Error(
  32470. 'Unsupported previous source map format: ' + prev.toString()
  32471. )
  32472. }
  32473. } else if (this.inline) {
  32474. return this.decodeInline(this.annotation)
  32475. } else if (this.annotation) {
  32476. let map = this.annotation;
  32477. if (file) map = join(dirname$1(file), map);
  32478. return this.loadFile(map)
  32479. }
  32480. }
  32481. startWith(string, start) {
  32482. if (!string) return false
  32483. return string.substr(0, start.length) === start
  32484. }
  32485. withContent() {
  32486. return !!(
  32487. this.consumer().sourcesContent &&
  32488. this.consumer().sourcesContent.length > 0
  32489. )
  32490. }
  32491. };
  32492. var previousMap = PreviousMap$2;
  32493. PreviousMap$2.default = PreviousMap$2;
  32494. let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
  32495. let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
  32496. let { isAbsolute, resolve: resolve$1 } = require$$1;
  32497. let { nanoid } = nonSecure;
  32498. let terminalHighlight = terminalHighlight_1;
  32499. let CssSyntaxError$1 = cssSyntaxError;
  32500. let PreviousMap$1 = previousMap;
  32501. let fromOffsetCache = Symbol('fromOffsetCache');
  32502. let sourceMapAvailable$1 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$4);
  32503. let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
  32504. let Input$4 = class Input {
  32505. constructor(css, opts = {}) {
  32506. if (
  32507. css === null ||
  32508. typeof css === 'undefined' ||
  32509. (typeof css === 'object' && !css.toString)
  32510. ) {
  32511. throw new Error(`PostCSS received ${css} instead of CSS string`)
  32512. }
  32513. this.css = css.toString();
  32514. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  32515. this.hasBOM = true;
  32516. this.css = this.css.slice(1);
  32517. } else {
  32518. this.hasBOM = false;
  32519. }
  32520. if (opts.from) {
  32521. if (
  32522. !pathAvailable$1 ||
  32523. /^\w+:\/\//.test(opts.from) ||
  32524. isAbsolute(opts.from)
  32525. ) {
  32526. this.file = opts.from;
  32527. } else {
  32528. this.file = resolve$1(opts.from);
  32529. }
  32530. }
  32531. if (pathAvailable$1 && sourceMapAvailable$1) {
  32532. let map = new PreviousMap$1(this.css, opts);
  32533. if (map.text) {
  32534. this.map = map;
  32535. let file = map.consumer().file;
  32536. if (!this.file && file) this.file = this.mapResolve(file);
  32537. }
  32538. }
  32539. if (!this.file) {
  32540. this.id = '<input css ' + nanoid(6) + '>';
  32541. }
  32542. if (this.map) this.map.file = this.from;
  32543. }
  32544. error(message, line, column, opts = {}) {
  32545. let result, endLine, endColumn;
  32546. if (line && typeof line === 'object') {
  32547. let start = line;
  32548. let end = column;
  32549. if (typeof start.offset === 'number') {
  32550. let pos = this.fromOffset(start.offset);
  32551. line = pos.line;
  32552. column = pos.col;
  32553. } else {
  32554. line = start.line;
  32555. column = start.column;
  32556. }
  32557. if (typeof end.offset === 'number') {
  32558. let pos = this.fromOffset(end.offset);
  32559. endLine = pos.line;
  32560. endColumn = pos.col;
  32561. } else {
  32562. endLine = end.line;
  32563. endColumn = end.column;
  32564. }
  32565. } else if (!column) {
  32566. let pos = this.fromOffset(line);
  32567. line = pos.line;
  32568. column = pos.col;
  32569. }
  32570. let origin = this.origin(line, column, endLine, endColumn);
  32571. if (origin) {
  32572. result = new CssSyntaxError$1(
  32573. message,
  32574. origin.endLine === undefined
  32575. ? origin.line
  32576. : { column: origin.column, line: origin.line },
  32577. origin.endLine === undefined
  32578. ? origin.column
  32579. : { column: origin.endColumn, line: origin.endLine },
  32580. origin.source,
  32581. origin.file,
  32582. opts.plugin
  32583. );
  32584. } else {
  32585. result = new CssSyntaxError$1(
  32586. message,
  32587. endLine === undefined ? line : { column, line },
  32588. endLine === undefined ? column : { column: endColumn, line: endLine },
  32589. this.css,
  32590. this.file,
  32591. opts.plugin
  32592. );
  32593. }
  32594. result.input = { column, endColumn, endLine, line, source: this.css };
  32595. if (this.file) {
  32596. if (pathToFileURL$1) {
  32597. result.input.url = pathToFileURL$1(this.file).toString();
  32598. }
  32599. result.input.file = this.file;
  32600. }
  32601. return result
  32602. }
  32603. fromOffset(offset) {
  32604. let lastLine, lineToIndex;
  32605. if (!this[fromOffsetCache]) {
  32606. let lines = this.css.split('\n');
  32607. lineToIndex = new Array(lines.length);
  32608. let prevIndex = 0;
  32609. for (let i = 0, l = lines.length; i < l; i++) {
  32610. lineToIndex[i] = prevIndex;
  32611. prevIndex += lines[i].length + 1;
  32612. }
  32613. this[fromOffsetCache] = lineToIndex;
  32614. } else {
  32615. lineToIndex = this[fromOffsetCache];
  32616. }
  32617. lastLine = lineToIndex[lineToIndex.length - 1];
  32618. let min = 0;
  32619. if (offset >= lastLine) {
  32620. min = lineToIndex.length - 1;
  32621. } else {
  32622. let max = lineToIndex.length - 2;
  32623. let mid;
  32624. while (min < max) {
  32625. mid = min + ((max - min) >> 1);
  32626. if (offset < lineToIndex[mid]) {
  32627. max = mid - 1;
  32628. } else if (offset >= lineToIndex[mid + 1]) {
  32629. min = mid + 1;
  32630. } else {
  32631. min = mid;
  32632. break
  32633. }
  32634. }
  32635. }
  32636. return {
  32637. col: offset - lineToIndex[min] + 1,
  32638. line: min + 1
  32639. }
  32640. }
  32641. mapResolve(file) {
  32642. if (/^\w+:\/\//.test(file)) {
  32643. return file
  32644. }
  32645. return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
  32646. }
  32647. origin(line, column, endLine, endColumn) {
  32648. if (!this.map) return false
  32649. let consumer = this.map.consumer();
  32650. let from = consumer.originalPositionFor({ column, line });
  32651. if (!from.source) return false
  32652. let to;
  32653. if (typeof endLine === 'number') {
  32654. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  32655. }
  32656. let fromUrl;
  32657. if (isAbsolute(from.source)) {
  32658. fromUrl = pathToFileURL$1(from.source);
  32659. } else {
  32660. fromUrl = new URL(
  32661. from.source,
  32662. this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
  32663. );
  32664. }
  32665. let result = {
  32666. column: from.column,
  32667. endColumn: to && to.column,
  32668. endLine: to && to.line,
  32669. line: from.line,
  32670. url: fromUrl.toString()
  32671. };
  32672. if (fromUrl.protocol === 'file:') {
  32673. if (fileURLToPath) {
  32674. result.file = fileURLToPath(fromUrl);
  32675. } else {
  32676. /* c8 ignore next 2 */
  32677. throw new Error(`file: protocol is not available in this PostCSS build`)
  32678. }
  32679. }
  32680. let source = consumer.sourceContentFor(from.source);
  32681. if (source) result.source = source;
  32682. return result
  32683. }
  32684. toJSON() {
  32685. let json = {};
  32686. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  32687. if (this[name] != null) {
  32688. json[name] = this[name];
  32689. }
  32690. }
  32691. if (this.map) {
  32692. json.map = { ...this.map };
  32693. if (json.map.consumerCache) {
  32694. json.map.consumerCache = undefined;
  32695. }
  32696. }
  32697. return json
  32698. }
  32699. get from() {
  32700. return this.file || this.id
  32701. }
  32702. };
  32703. var input = Input$4;
  32704. Input$4.default = Input$4;
  32705. if (terminalHighlight && terminalHighlight.registerInput) {
  32706. terminalHighlight.registerInput(Input$4);
  32707. }
  32708. let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
  32709. let { dirname, relative, resolve, sep } = require$$1;
  32710. let { pathToFileURL } = require$$2;
  32711. let Input$3 = input;
  32712. let sourceMapAvailable = Boolean(SourceMapConsumer$2 && SourceMapGenerator$3);
  32713. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  32714. let MapGenerator$2 = class MapGenerator {
  32715. constructor(stringify, root, opts, cssString) {
  32716. this.stringify = stringify;
  32717. this.mapOpts = opts.map || {};
  32718. this.root = root;
  32719. this.opts = opts;
  32720. this.css = cssString;
  32721. this.originalCSS = cssString;
  32722. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  32723. this.memoizedFileURLs = new Map();
  32724. this.memoizedPaths = new Map();
  32725. this.memoizedURLs = new Map();
  32726. }
  32727. addAnnotation() {
  32728. let content;
  32729. if (this.isInline()) {
  32730. content =
  32731. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  32732. } else if (typeof this.mapOpts.annotation === 'string') {
  32733. content = this.mapOpts.annotation;
  32734. } else if (typeof this.mapOpts.annotation === 'function') {
  32735. content = this.mapOpts.annotation(this.opts.to, this.root);
  32736. } else {
  32737. content = this.outputFile() + '.map';
  32738. }
  32739. let eol = '\n';
  32740. if (this.css.includes('\r\n')) eol = '\r\n';
  32741. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  32742. }
  32743. applyPrevMaps() {
  32744. for (let prev of this.previous()) {
  32745. let from = this.toUrl(this.path(prev.file));
  32746. let root = prev.root || dirname(prev.file);
  32747. let map;
  32748. if (this.mapOpts.sourcesContent === false) {
  32749. map = new SourceMapConsumer$2(prev.text);
  32750. if (map.sourcesContent) {
  32751. map.sourcesContent = null;
  32752. }
  32753. } else {
  32754. map = prev.consumer();
  32755. }
  32756. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  32757. }
  32758. }
  32759. clearAnnotation() {
  32760. if (this.mapOpts.annotation === false) return
  32761. if (this.root) {
  32762. let node;
  32763. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  32764. node = this.root.nodes[i];
  32765. if (node.type !== 'comment') continue
  32766. if (node.text.indexOf('# sourceMappingURL=') === 0) {
  32767. this.root.removeChild(i);
  32768. }
  32769. }
  32770. } else if (this.css) {
  32771. this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '');
  32772. }
  32773. }
  32774. generate() {
  32775. this.clearAnnotation();
  32776. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  32777. return this.generateMap()
  32778. } else {
  32779. let result = '';
  32780. this.stringify(this.root, i => {
  32781. result += i;
  32782. });
  32783. return [result]
  32784. }
  32785. }
  32786. generateMap() {
  32787. if (this.root) {
  32788. this.generateString();
  32789. } else if (this.previous().length === 1) {
  32790. let prev = this.previous()[0].consumer();
  32791. prev.file = this.outputFile();
  32792. this.map = SourceMapGenerator$3.fromSourceMap(prev);
  32793. } else {
  32794. this.map = new SourceMapGenerator$3({ file: this.outputFile() });
  32795. this.map.addMapping({
  32796. generated: { column: 0, line: 1 },
  32797. original: { column: 0, line: 1 },
  32798. source: this.opts.from
  32799. ? this.toUrl(this.path(this.opts.from))
  32800. : '<no source>'
  32801. });
  32802. }
  32803. if (this.isSourcesContent()) this.setSourcesContent();
  32804. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  32805. if (this.isAnnotation()) this.addAnnotation();
  32806. if (this.isInline()) {
  32807. return [this.css]
  32808. } else {
  32809. return [this.css, this.map]
  32810. }
  32811. }
  32812. generateString() {
  32813. this.css = '';
  32814. this.map = new SourceMapGenerator$3({ file: this.outputFile() });
  32815. let line = 1;
  32816. let column = 1;
  32817. let noSource = '<no source>';
  32818. let mapping = {
  32819. generated: { column: 0, line: 0 },
  32820. original: { column: 0, line: 0 },
  32821. source: ''
  32822. };
  32823. let lines, last;
  32824. this.stringify(this.root, (str, node, type) => {
  32825. this.css += str;
  32826. if (node && type !== 'end') {
  32827. mapping.generated.line = line;
  32828. mapping.generated.column = column - 1;
  32829. if (node.source && node.source.start) {
  32830. mapping.source = this.sourcePath(node);
  32831. mapping.original.line = node.source.start.line;
  32832. mapping.original.column = node.source.start.column - 1;
  32833. this.map.addMapping(mapping);
  32834. } else {
  32835. mapping.source = noSource;
  32836. mapping.original.line = 1;
  32837. mapping.original.column = 0;
  32838. this.map.addMapping(mapping);
  32839. }
  32840. }
  32841. lines = str.match(/\n/g);
  32842. if (lines) {
  32843. line += lines.length;
  32844. last = str.lastIndexOf('\n');
  32845. column = str.length - last;
  32846. } else {
  32847. column += str.length;
  32848. }
  32849. if (node && type !== 'start') {
  32850. let p = node.parent || { raws: {} };
  32851. let childless =
  32852. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  32853. if (!childless || node !== p.last || p.raws.semicolon) {
  32854. if (node.source && node.source.end) {
  32855. mapping.source = this.sourcePath(node);
  32856. mapping.original.line = node.source.end.line;
  32857. mapping.original.column = node.source.end.column - 1;
  32858. mapping.generated.line = line;
  32859. mapping.generated.column = column - 2;
  32860. this.map.addMapping(mapping);
  32861. } else {
  32862. mapping.source = noSource;
  32863. mapping.original.line = 1;
  32864. mapping.original.column = 0;
  32865. mapping.generated.line = line;
  32866. mapping.generated.column = column - 1;
  32867. this.map.addMapping(mapping);
  32868. }
  32869. }
  32870. }
  32871. });
  32872. }
  32873. isAnnotation() {
  32874. if (this.isInline()) {
  32875. return true
  32876. }
  32877. if (typeof this.mapOpts.annotation !== 'undefined') {
  32878. return this.mapOpts.annotation
  32879. }
  32880. if (this.previous().length) {
  32881. return this.previous().some(i => i.annotation)
  32882. }
  32883. return true
  32884. }
  32885. isInline() {
  32886. if (typeof this.mapOpts.inline !== 'undefined') {
  32887. return this.mapOpts.inline
  32888. }
  32889. let annotation = this.mapOpts.annotation;
  32890. if (typeof annotation !== 'undefined' && annotation !== true) {
  32891. return false
  32892. }
  32893. if (this.previous().length) {
  32894. return this.previous().some(i => i.inline)
  32895. }
  32896. return true
  32897. }
  32898. isMap() {
  32899. if (typeof this.opts.map !== 'undefined') {
  32900. return !!this.opts.map
  32901. }
  32902. return this.previous().length > 0
  32903. }
  32904. isSourcesContent() {
  32905. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  32906. return this.mapOpts.sourcesContent
  32907. }
  32908. if (this.previous().length) {
  32909. return this.previous().some(i => i.withContent())
  32910. }
  32911. return true
  32912. }
  32913. outputFile() {
  32914. if (this.opts.to) {
  32915. return this.path(this.opts.to)
  32916. } else if (this.opts.from) {
  32917. return this.path(this.opts.from)
  32918. } else {
  32919. return 'to.css'
  32920. }
  32921. }
  32922. path(file) {
  32923. if (this.mapOpts.absolute) return file
  32924. if (file.charCodeAt(0) === 60 /* `<` */) return file
  32925. if (/^\w+:\/\//.test(file)) return file
  32926. let cached = this.memoizedPaths.get(file);
  32927. if (cached) return cached
  32928. let from = this.opts.to ? dirname(this.opts.to) : '.';
  32929. if (typeof this.mapOpts.annotation === 'string') {
  32930. from = dirname(resolve(from, this.mapOpts.annotation));
  32931. }
  32932. let path = relative(from, file);
  32933. this.memoizedPaths.set(file, path);
  32934. return path
  32935. }
  32936. previous() {
  32937. if (!this.previousMaps) {
  32938. this.previousMaps = [];
  32939. if (this.root) {
  32940. this.root.walk(node => {
  32941. if (node.source && node.source.input.map) {
  32942. let map = node.source.input.map;
  32943. if (!this.previousMaps.includes(map)) {
  32944. this.previousMaps.push(map);
  32945. }
  32946. }
  32947. });
  32948. } else {
  32949. let input = new Input$3(this.originalCSS, this.opts);
  32950. if (input.map) this.previousMaps.push(input.map);
  32951. }
  32952. }
  32953. return this.previousMaps
  32954. }
  32955. setSourcesContent() {
  32956. let already = {};
  32957. if (this.root) {
  32958. this.root.walk(node => {
  32959. if (node.source) {
  32960. let from = node.source.input.from;
  32961. if (from && !already[from]) {
  32962. already[from] = true;
  32963. let fromUrl = this.usesFileUrls
  32964. ? this.toFileUrl(from)
  32965. : this.toUrl(this.path(from));
  32966. this.map.setSourceContent(fromUrl, node.source.input.css);
  32967. }
  32968. }
  32969. });
  32970. } else if (this.css) {
  32971. let from = this.opts.from
  32972. ? this.toUrl(this.path(this.opts.from))
  32973. : '<no source>';
  32974. this.map.setSourceContent(from, this.css);
  32975. }
  32976. }
  32977. sourcePath(node) {
  32978. if (this.mapOpts.from) {
  32979. return this.toUrl(this.mapOpts.from)
  32980. } else if (this.usesFileUrls) {
  32981. return this.toFileUrl(node.source.input.from)
  32982. } else {
  32983. return this.toUrl(this.path(node.source.input.from))
  32984. }
  32985. }
  32986. toBase64(str) {
  32987. if (Buffer$1) {
  32988. return Buffer$1.from(str).toString('base64')
  32989. } else {
  32990. return window.btoa(unescape(encodeURIComponent(str)))
  32991. }
  32992. }
  32993. toFileUrl(path) {
  32994. let cached = this.memoizedFileURLs.get(path);
  32995. if (cached) return cached
  32996. if (pathToFileURL) {
  32997. let fileURL = pathToFileURL(path).toString();
  32998. this.memoizedFileURLs.set(path, fileURL);
  32999. return fileURL
  33000. } else {
  33001. throw new Error(
  33002. '`map.absolute` option is not available in this PostCSS build'
  33003. )
  33004. }
  33005. }
  33006. toUrl(path) {
  33007. let cached = this.memoizedURLs.get(path);
  33008. if (cached) return cached
  33009. if (sep === '\\') {
  33010. path = path.replace(/\\/g, '/');
  33011. }
  33012. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  33013. this.memoizedURLs.set(path, url);
  33014. return url
  33015. }
  33016. };
  33017. var mapGenerator = MapGenerator$2;
  33018. let Node$2 = node$2;
  33019. let Comment$4 = class Comment extends Node$2 {
  33020. constructor(defaults) {
  33021. super(defaults);
  33022. this.type = 'comment';
  33023. }
  33024. };
  33025. var comment$3 = Comment$4;
  33026. Comment$4.default = Comment$4;
  33027. let { isClean: isClean$1, my: my$1 } = symbols;
  33028. let Declaration$3 = declaration;
  33029. let Comment$3 = comment$3;
  33030. let Node$1 = node$2;
  33031. let parse$4, Rule$4, AtRule$4, Root$6;
  33032. function cleanSource(nodes) {
  33033. return nodes.map(i => {
  33034. if (i.nodes) i.nodes = cleanSource(i.nodes);
  33035. delete i.source;
  33036. return i
  33037. })
  33038. }
  33039. function markDirtyUp(node) {
  33040. node[isClean$1] = false;
  33041. if (node.proxyOf.nodes) {
  33042. for (let i of node.proxyOf.nodes) {
  33043. markDirtyUp(i);
  33044. }
  33045. }
  33046. }
  33047. let Container$7 = class Container extends Node$1 {
  33048. append(...children) {
  33049. for (let child of children) {
  33050. let nodes = this.normalize(child, this.last);
  33051. for (let node of nodes) this.proxyOf.nodes.push(node);
  33052. }
  33053. this.markDirty();
  33054. return this
  33055. }
  33056. cleanRaws(keepBetween) {
  33057. super.cleanRaws(keepBetween);
  33058. if (this.nodes) {
  33059. for (let node of this.nodes) node.cleanRaws(keepBetween);
  33060. }
  33061. }
  33062. each(callback) {
  33063. if (!this.proxyOf.nodes) return undefined
  33064. let iterator = this.getIterator();
  33065. let index, result;
  33066. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33067. index = this.indexes[iterator];
  33068. result = callback(this.proxyOf.nodes[index], index);
  33069. if (result === false) break
  33070. this.indexes[iterator] += 1;
  33071. }
  33072. delete this.indexes[iterator];
  33073. return result
  33074. }
  33075. every(condition) {
  33076. return this.nodes.every(condition)
  33077. }
  33078. getIterator() {
  33079. if (!this.lastEach) this.lastEach = 0;
  33080. if (!this.indexes) this.indexes = {};
  33081. this.lastEach += 1;
  33082. let iterator = this.lastEach;
  33083. this.indexes[iterator] = 0;
  33084. return iterator
  33085. }
  33086. getProxyProcessor() {
  33087. return {
  33088. get(node, prop) {
  33089. if (prop === 'proxyOf') {
  33090. return node
  33091. } else if (!node[prop]) {
  33092. return node[prop]
  33093. } else if (
  33094. prop === 'each' ||
  33095. (typeof prop === 'string' && prop.startsWith('walk'))
  33096. ) {
  33097. return (...args) => {
  33098. return node[prop](
  33099. ...args.map(i => {
  33100. if (typeof i === 'function') {
  33101. return (child, index) => i(child.toProxy(), index)
  33102. } else {
  33103. return i
  33104. }
  33105. })
  33106. )
  33107. }
  33108. } else if (prop === 'every' || prop === 'some') {
  33109. return cb => {
  33110. return node[prop]((child, ...other) =>
  33111. cb(child.toProxy(), ...other)
  33112. )
  33113. }
  33114. } else if (prop === 'root') {
  33115. return () => node.root().toProxy()
  33116. } else if (prop === 'nodes') {
  33117. return node.nodes.map(i => i.toProxy())
  33118. } else if (prop === 'first' || prop === 'last') {
  33119. return node[prop].toProxy()
  33120. } else {
  33121. return node[prop]
  33122. }
  33123. },
  33124. set(node, prop, value) {
  33125. if (node[prop] === value) return true
  33126. node[prop] = value;
  33127. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33128. node.markDirty();
  33129. }
  33130. return true
  33131. }
  33132. }
  33133. }
  33134. index(child) {
  33135. if (typeof child === 'number') return child
  33136. if (child.proxyOf) child = child.proxyOf;
  33137. return this.proxyOf.nodes.indexOf(child)
  33138. }
  33139. insertAfter(exist, add) {
  33140. let existIndex = this.index(exist);
  33141. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33142. existIndex = this.index(exist);
  33143. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33144. let index;
  33145. for (let id in this.indexes) {
  33146. index = this.indexes[id];
  33147. if (existIndex < index) {
  33148. this.indexes[id] = index + nodes.length;
  33149. }
  33150. }
  33151. this.markDirty();
  33152. return this
  33153. }
  33154. insertBefore(exist, add) {
  33155. let existIndex = this.index(exist);
  33156. let type = existIndex === 0 ? 'prepend' : false;
  33157. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
  33158. existIndex = this.index(exist);
  33159. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33160. let index;
  33161. for (let id in this.indexes) {
  33162. index = this.indexes[id];
  33163. if (existIndex <= index) {
  33164. this.indexes[id] = index + nodes.length;
  33165. }
  33166. }
  33167. this.markDirty();
  33168. return this
  33169. }
  33170. normalize(nodes, sample) {
  33171. if (typeof nodes === 'string') {
  33172. nodes = cleanSource(parse$4(nodes).nodes);
  33173. } else if (typeof nodes === 'undefined') {
  33174. nodes = [];
  33175. } else if (Array.isArray(nodes)) {
  33176. nodes = nodes.slice(0);
  33177. for (let i of nodes) {
  33178. if (i.parent) i.parent.removeChild(i, 'ignore');
  33179. }
  33180. } else if (nodes.type === 'root' && this.type !== 'document') {
  33181. nodes = nodes.nodes.slice(0);
  33182. for (let i of nodes) {
  33183. if (i.parent) i.parent.removeChild(i, 'ignore');
  33184. }
  33185. } else if (nodes.type) {
  33186. nodes = [nodes];
  33187. } else if (nodes.prop) {
  33188. if (typeof nodes.value === 'undefined') {
  33189. throw new Error('Value field is missed in node creation')
  33190. } else if (typeof nodes.value !== 'string') {
  33191. nodes.value = String(nodes.value);
  33192. }
  33193. nodes = [new Declaration$3(nodes)];
  33194. } else if (nodes.selector) {
  33195. nodes = [new Rule$4(nodes)];
  33196. } else if (nodes.name) {
  33197. nodes = [new AtRule$4(nodes)];
  33198. } else if (nodes.text) {
  33199. nodes = [new Comment$3(nodes)];
  33200. } else {
  33201. throw new Error('Unknown node type in node creation')
  33202. }
  33203. let processed = nodes.map(i => {
  33204. /* c8 ignore next */
  33205. if (!i[my$1]) Container.rebuild(i);
  33206. i = i.proxyOf;
  33207. if (i.parent) i.parent.removeChild(i);
  33208. if (i[isClean$1]) markDirtyUp(i);
  33209. if (typeof i.raws.before === 'undefined') {
  33210. if (sample && typeof sample.raws.before !== 'undefined') {
  33211. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33212. }
  33213. }
  33214. i.parent = this.proxyOf;
  33215. return i
  33216. });
  33217. return processed
  33218. }
  33219. prepend(...children) {
  33220. children = children.reverse();
  33221. for (let child of children) {
  33222. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33223. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33224. for (let id in this.indexes) {
  33225. this.indexes[id] = this.indexes[id] + nodes.length;
  33226. }
  33227. }
  33228. this.markDirty();
  33229. return this
  33230. }
  33231. push(child) {
  33232. child.parent = this;
  33233. this.proxyOf.nodes.push(child);
  33234. return this
  33235. }
  33236. removeAll() {
  33237. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33238. this.proxyOf.nodes = [];
  33239. this.markDirty();
  33240. return this
  33241. }
  33242. removeChild(child) {
  33243. child = this.index(child);
  33244. this.proxyOf.nodes[child].parent = undefined;
  33245. this.proxyOf.nodes.splice(child, 1);
  33246. let index;
  33247. for (let id in this.indexes) {
  33248. index = this.indexes[id];
  33249. if (index >= child) {
  33250. this.indexes[id] = index - 1;
  33251. }
  33252. }
  33253. this.markDirty();
  33254. return this
  33255. }
  33256. replaceValues(pattern, opts, callback) {
  33257. if (!callback) {
  33258. callback = opts;
  33259. opts = {};
  33260. }
  33261. this.walkDecls(decl => {
  33262. if (opts.props && !opts.props.includes(decl.prop)) return
  33263. if (opts.fast && !decl.value.includes(opts.fast)) return
  33264. decl.value = decl.value.replace(pattern, callback);
  33265. });
  33266. this.markDirty();
  33267. return this
  33268. }
  33269. some(condition) {
  33270. return this.nodes.some(condition)
  33271. }
  33272. walk(callback) {
  33273. return this.each((child, i) => {
  33274. let result;
  33275. try {
  33276. result = callback(child, i);
  33277. } catch (e) {
  33278. throw child.addToError(e)
  33279. }
  33280. if (result !== false && child.walk) {
  33281. result = child.walk(callback);
  33282. }
  33283. return result
  33284. })
  33285. }
  33286. walkAtRules(name, callback) {
  33287. if (!callback) {
  33288. callback = name;
  33289. return this.walk((child, i) => {
  33290. if (child.type === 'atrule') {
  33291. return callback(child, i)
  33292. }
  33293. })
  33294. }
  33295. if (name instanceof RegExp) {
  33296. return this.walk((child, i) => {
  33297. if (child.type === 'atrule' && name.test(child.name)) {
  33298. return callback(child, i)
  33299. }
  33300. })
  33301. }
  33302. return this.walk((child, i) => {
  33303. if (child.type === 'atrule' && child.name === name) {
  33304. return callback(child, i)
  33305. }
  33306. })
  33307. }
  33308. walkComments(callback) {
  33309. return this.walk((child, i) => {
  33310. if (child.type === 'comment') {
  33311. return callback(child, i)
  33312. }
  33313. })
  33314. }
  33315. walkDecls(prop, callback) {
  33316. if (!callback) {
  33317. callback = prop;
  33318. return this.walk((child, i) => {
  33319. if (child.type === 'decl') {
  33320. return callback(child, i)
  33321. }
  33322. })
  33323. }
  33324. if (prop instanceof RegExp) {
  33325. return this.walk((child, i) => {
  33326. if (child.type === 'decl' && prop.test(child.prop)) {
  33327. return callback(child, i)
  33328. }
  33329. })
  33330. }
  33331. return this.walk((child, i) => {
  33332. if (child.type === 'decl' && child.prop === prop) {
  33333. return callback(child, i)
  33334. }
  33335. })
  33336. }
  33337. walkRules(selector, callback) {
  33338. if (!callback) {
  33339. callback = selector;
  33340. return this.walk((child, i) => {
  33341. if (child.type === 'rule') {
  33342. return callback(child, i)
  33343. }
  33344. })
  33345. }
  33346. if (selector instanceof RegExp) {
  33347. return this.walk((child, i) => {
  33348. if (child.type === 'rule' && selector.test(child.selector)) {
  33349. return callback(child, i)
  33350. }
  33351. })
  33352. }
  33353. return this.walk((child, i) => {
  33354. if (child.type === 'rule' && child.selector === selector) {
  33355. return callback(child, i)
  33356. }
  33357. })
  33358. }
  33359. get first() {
  33360. if (!this.proxyOf.nodes) return undefined
  33361. return this.proxyOf.nodes[0]
  33362. }
  33363. get last() {
  33364. if (!this.proxyOf.nodes) return undefined
  33365. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33366. }
  33367. };
  33368. Container$7.registerParse = dependant => {
  33369. parse$4 = dependant;
  33370. };
  33371. Container$7.registerRule = dependant => {
  33372. Rule$4 = dependant;
  33373. };
  33374. Container$7.registerAtRule = dependant => {
  33375. AtRule$4 = dependant;
  33376. };
  33377. Container$7.registerRoot = dependant => {
  33378. Root$6 = dependant;
  33379. };
  33380. var container$1 = Container$7;
  33381. Container$7.default = Container$7;
  33382. /* c8 ignore start */
  33383. Container$7.rebuild = node => {
  33384. if (node.type === 'atrule') {
  33385. Object.setPrototypeOf(node, AtRule$4.prototype);
  33386. } else if (node.type === 'rule') {
  33387. Object.setPrototypeOf(node, Rule$4.prototype);
  33388. } else if (node.type === 'decl') {
  33389. Object.setPrototypeOf(node, Declaration$3.prototype);
  33390. } else if (node.type === 'comment') {
  33391. Object.setPrototypeOf(node, Comment$3.prototype);
  33392. } else if (node.type === 'root') {
  33393. Object.setPrototypeOf(node, Root$6.prototype);
  33394. }
  33395. node[my$1] = true;
  33396. if (node.nodes) {
  33397. node.nodes.forEach(child => {
  33398. Container$7.rebuild(child);
  33399. });
  33400. }
  33401. };
  33402. let Container$6 = container$1;
  33403. let LazyResult$4, Processor$3;
  33404. let Document$3 = class Document extends Container$6 {
  33405. constructor(defaults) {
  33406. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  33407. super({ type: 'document', ...defaults });
  33408. if (!this.nodes) {
  33409. this.nodes = [];
  33410. }
  33411. }
  33412. toResult(opts = {}) {
  33413. let lazy = new LazyResult$4(new Processor$3(), this, opts);
  33414. return lazy.stringify()
  33415. }
  33416. };
  33417. Document$3.registerLazyResult = dependant => {
  33418. LazyResult$4 = dependant;
  33419. };
  33420. Document$3.registerProcessor = dependant => {
  33421. Processor$3 = dependant;
  33422. };
  33423. var document = Document$3;
  33424. Document$3.default = Document$3;
  33425. /* eslint-disable no-console */
  33426. let printed = {};
  33427. var warnOnce$2 = function warnOnce(message) {
  33428. if (printed[message]) return
  33429. printed[message] = true;
  33430. if (typeof console !== 'undefined' && console.warn) {
  33431. console.warn(message);
  33432. }
  33433. };
  33434. let Warning$2 = class Warning {
  33435. constructor(text, opts = {}) {
  33436. this.type = 'warning';
  33437. this.text = text;
  33438. if (opts.node && opts.node.source) {
  33439. let range = opts.node.rangeBy(opts);
  33440. this.line = range.start.line;
  33441. this.column = range.start.column;
  33442. this.endLine = range.end.line;
  33443. this.endColumn = range.end.column;
  33444. }
  33445. for (let opt in opts) this[opt] = opts[opt];
  33446. }
  33447. toString() {
  33448. if (this.node) {
  33449. return this.node.error(this.text, {
  33450. index: this.index,
  33451. plugin: this.plugin,
  33452. word: this.word
  33453. }).message
  33454. }
  33455. if (this.plugin) {
  33456. return this.plugin + ': ' + this.text
  33457. }
  33458. return this.text
  33459. }
  33460. };
  33461. var warning = Warning$2;
  33462. Warning$2.default = Warning$2;
  33463. let Warning$1 = warning;
  33464. let Result$3 = class Result {
  33465. constructor(processor, root, opts) {
  33466. this.processor = processor;
  33467. this.messages = [];
  33468. this.root = root;
  33469. this.opts = opts;
  33470. this.css = undefined;
  33471. this.map = undefined;
  33472. }
  33473. toString() {
  33474. return this.css
  33475. }
  33476. warn(text, opts = {}) {
  33477. if (!opts.plugin) {
  33478. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  33479. opts.plugin = this.lastPlugin.postcssPlugin;
  33480. }
  33481. }
  33482. let warning = new Warning$1(text, opts);
  33483. this.messages.push(warning);
  33484. return warning
  33485. }
  33486. warnings() {
  33487. return this.messages.filter(i => i.type === 'warning')
  33488. }
  33489. get content() {
  33490. return this.css
  33491. }
  33492. };
  33493. var result = Result$3;
  33494. Result$3.default = Result$3;
  33495. let Container$5 = container$1;
  33496. let AtRule$3 = class AtRule extends Container$5 {
  33497. constructor(defaults) {
  33498. super(defaults);
  33499. this.type = 'atrule';
  33500. }
  33501. append(...children) {
  33502. if (!this.proxyOf.nodes) this.nodes = [];
  33503. return super.append(...children)
  33504. }
  33505. prepend(...children) {
  33506. if (!this.proxyOf.nodes) this.nodes = [];
  33507. return super.prepend(...children)
  33508. }
  33509. };
  33510. var atRule = AtRule$3;
  33511. AtRule$3.default = AtRule$3;
  33512. Container$5.registerAtRule(AtRule$3);
  33513. let Container$4 = container$1;
  33514. let LazyResult$3, Processor$2;
  33515. let Root$5 = class Root extends Container$4 {
  33516. constructor(defaults) {
  33517. super(defaults);
  33518. this.type = 'root';
  33519. if (!this.nodes) this.nodes = [];
  33520. }
  33521. normalize(child, sample, type) {
  33522. let nodes = super.normalize(child);
  33523. if (sample) {
  33524. if (type === 'prepend') {
  33525. if (this.nodes.length > 1) {
  33526. sample.raws.before = this.nodes[1].raws.before;
  33527. } else {
  33528. delete sample.raws.before;
  33529. }
  33530. } else if (this.first !== sample) {
  33531. for (let node of nodes) {
  33532. node.raws.before = sample.raws.before;
  33533. }
  33534. }
  33535. }
  33536. return nodes
  33537. }
  33538. removeChild(child, ignore) {
  33539. let index = this.index(child);
  33540. if (!ignore && index === 0 && this.nodes.length > 1) {
  33541. this.nodes[1].raws.before = this.nodes[index].raws.before;
  33542. }
  33543. return super.removeChild(child)
  33544. }
  33545. toResult(opts = {}) {
  33546. let lazy = new LazyResult$3(new Processor$2(), this, opts);
  33547. return lazy.stringify()
  33548. }
  33549. };
  33550. Root$5.registerLazyResult = dependant => {
  33551. LazyResult$3 = dependant;
  33552. };
  33553. Root$5.registerProcessor = dependant => {
  33554. Processor$2 = dependant;
  33555. };
  33556. var root$2 = Root$5;
  33557. Root$5.default = Root$5;
  33558. Container$4.registerRoot(Root$5);
  33559. let list$2 = {
  33560. comma(string) {
  33561. return list$2.split(string, [','], true)
  33562. },
  33563. space(string) {
  33564. let spaces = [' ', '\n', '\t'];
  33565. return list$2.split(string, spaces)
  33566. },
  33567. split(string, separators, last) {
  33568. let array = [];
  33569. let current = '';
  33570. let split = false;
  33571. let func = 0;
  33572. let inQuote = false;
  33573. let prevQuote = '';
  33574. let escape = false;
  33575. for (let letter of string) {
  33576. if (escape) {
  33577. escape = false;
  33578. } else if (letter === '\\') {
  33579. escape = true;
  33580. } else if (inQuote) {
  33581. if (letter === prevQuote) {
  33582. inQuote = false;
  33583. }
  33584. } else if (letter === '"' || letter === "'") {
  33585. inQuote = true;
  33586. prevQuote = letter;
  33587. } else if (letter === '(') {
  33588. func += 1;
  33589. } else if (letter === ')') {
  33590. if (func > 0) func -= 1;
  33591. } else if (func === 0) {
  33592. if (separators.includes(letter)) split = true;
  33593. }
  33594. if (split) {
  33595. if (current !== '') array.push(current.trim());
  33596. current = '';
  33597. split = false;
  33598. } else {
  33599. current += letter;
  33600. }
  33601. }
  33602. if (last || current !== '') array.push(current.trim());
  33603. return array
  33604. }
  33605. };
  33606. var list_1 = list$2;
  33607. list$2.default = list$2;
  33608. let Container$3 = container$1;
  33609. let list$1 = list_1;
  33610. let Rule$3 = class Rule extends Container$3 {
  33611. constructor(defaults) {
  33612. super(defaults);
  33613. this.type = 'rule';
  33614. if (!this.nodes) this.nodes = [];
  33615. }
  33616. get selectors() {
  33617. return list$1.comma(this.selector)
  33618. }
  33619. set selectors(values) {
  33620. let match = this.selector ? this.selector.match(/,\s*/) : null;
  33621. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  33622. this.selector = values.join(sep);
  33623. }
  33624. };
  33625. var rule = Rule$3;
  33626. Rule$3.default = Rule$3;
  33627. Container$3.registerRule(Rule$3);
  33628. let Declaration$2 = declaration;
  33629. let tokenizer = tokenize$1;
  33630. let Comment$2 = comment$3;
  33631. let AtRule$2 = atRule;
  33632. let Root$4 = root$2;
  33633. let Rule$2 = rule;
  33634. const SAFE_COMMENT_NEIGHBOR = {
  33635. empty: true,
  33636. space: true
  33637. };
  33638. function findLastWithPosition(tokens) {
  33639. for (let i = tokens.length - 1; i >= 0; i--) {
  33640. let token = tokens[i];
  33641. let pos = token[3] || token[2];
  33642. if (pos) return pos
  33643. }
  33644. }
  33645. let Parser$1 = class Parser {
  33646. constructor(input) {
  33647. this.input = input;
  33648. this.root = new Root$4();
  33649. this.current = this.root;
  33650. this.spaces = '';
  33651. this.semicolon = false;
  33652. this.createTokenizer();
  33653. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  33654. }
  33655. atrule(token) {
  33656. let node = new AtRule$2();
  33657. node.name = token[1].slice(1);
  33658. if (node.name === '') {
  33659. this.unnamedAtrule(node, token);
  33660. }
  33661. this.init(node, token[2]);
  33662. let type;
  33663. let prev;
  33664. let shift;
  33665. let last = false;
  33666. let open = false;
  33667. let params = [];
  33668. let brackets = [];
  33669. while (!this.tokenizer.endOfFile()) {
  33670. token = this.tokenizer.nextToken();
  33671. type = token[0];
  33672. if (type === '(' || type === '[') {
  33673. brackets.push(type === '(' ? ')' : ']');
  33674. } else if (type === '{' && brackets.length > 0) {
  33675. brackets.push('}');
  33676. } else if (type === brackets[brackets.length - 1]) {
  33677. brackets.pop();
  33678. }
  33679. if (brackets.length === 0) {
  33680. if (type === ';') {
  33681. node.source.end = this.getPosition(token[2]);
  33682. node.source.end.offset++;
  33683. this.semicolon = true;
  33684. break
  33685. } else if (type === '{') {
  33686. open = true;
  33687. break
  33688. } else if (type === '}') {
  33689. if (params.length > 0) {
  33690. shift = params.length - 1;
  33691. prev = params[shift];
  33692. while (prev && prev[0] === 'space') {
  33693. prev = params[--shift];
  33694. }
  33695. if (prev) {
  33696. node.source.end = this.getPosition(prev[3] || prev[2]);
  33697. node.source.end.offset++;
  33698. }
  33699. }
  33700. this.end(token);
  33701. break
  33702. } else {
  33703. params.push(token);
  33704. }
  33705. } else {
  33706. params.push(token);
  33707. }
  33708. if (this.tokenizer.endOfFile()) {
  33709. last = true;
  33710. break
  33711. }
  33712. }
  33713. node.raws.between = this.spacesAndCommentsFromEnd(params);
  33714. if (params.length) {
  33715. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  33716. this.raw(node, 'params', params);
  33717. if (last) {
  33718. token = params[params.length - 1];
  33719. node.source.end = this.getPosition(token[3] || token[2]);
  33720. node.source.end.offset++;
  33721. this.spaces = node.raws.between;
  33722. node.raws.between = '';
  33723. }
  33724. } else {
  33725. node.raws.afterName = '';
  33726. node.params = '';
  33727. }
  33728. if (open) {
  33729. node.nodes = [];
  33730. this.current = node;
  33731. }
  33732. }
  33733. checkMissedSemicolon(tokens) {
  33734. let colon = this.colon(tokens);
  33735. if (colon === false) return
  33736. let founded = 0;
  33737. let token;
  33738. for (let j = colon - 1; j >= 0; j--) {
  33739. token = tokens[j];
  33740. if (token[0] !== 'space') {
  33741. founded += 1;
  33742. if (founded === 2) break
  33743. }
  33744. }
  33745. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  33746. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  33747. // And because we need it after that one we do +1 to get the next one.
  33748. throw this.input.error(
  33749. 'Missed semicolon',
  33750. token[0] === 'word' ? token[3] + 1 : token[2]
  33751. )
  33752. }
  33753. colon(tokens) {
  33754. let brackets = 0;
  33755. let token, type, prev;
  33756. for (let [i, element] of tokens.entries()) {
  33757. token = element;
  33758. type = token[0];
  33759. if (type === '(') {
  33760. brackets += 1;
  33761. }
  33762. if (type === ')') {
  33763. brackets -= 1;
  33764. }
  33765. if (brackets === 0 && type === ':') {
  33766. if (!prev) {
  33767. this.doubleColon(token);
  33768. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  33769. continue
  33770. } else {
  33771. return i
  33772. }
  33773. }
  33774. prev = token;
  33775. }
  33776. return false
  33777. }
  33778. comment(token) {
  33779. let node = new Comment$2();
  33780. this.init(node, token[2]);
  33781. node.source.end = this.getPosition(token[3] || token[2]);
  33782. node.source.end.offset++;
  33783. let text = token[1].slice(2, -2);
  33784. if (/^\s*$/.test(text)) {
  33785. node.text = '';
  33786. node.raws.left = text;
  33787. node.raws.right = '';
  33788. } else {
  33789. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  33790. node.text = match[2];
  33791. node.raws.left = match[1];
  33792. node.raws.right = match[3];
  33793. }
  33794. }
  33795. createTokenizer() {
  33796. this.tokenizer = tokenizer(this.input);
  33797. }
  33798. decl(tokens, customProperty) {
  33799. let node = new Declaration$2();
  33800. this.init(node, tokens[0][2]);
  33801. let last = tokens[tokens.length - 1];
  33802. if (last[0] === ';') {
  33803. this.semicolon = true;
  33804. tokens.pop();
  33805. }
  33806. node.source.end = this.getPosition(
  33807. last[3] || last[2] || findLastWithPosition(tokens)
  33808. );
  33809. node.source.end.offset++;
  33810. while (tokens[0][0] !== 'word') {
  33811. if (tokens.length === 1) this.unknownWord(tokens);
  33812. node.raws.before += tokens.shift()[1];
  33813. }
  33814. node.source.start = this.getPosition(tokens[0][2]);
  33815. node.prop = '';
  33816. while (tokens.length) {
  33817. let type = tokens[0][0];
  33818. if (type === ':' || type === 'space' || type === 'comment') {
  33819. break
  33820. }
  33821. node.prop += tokens.shift()[1];
  33822. }
  33823. node.raws.between = '';
  33824. let token;
  33825. while (tokens.length) {
  33826. token = tokens.shift();
  33827. if (token[0] === ':') {
  33828. node.raws.between += token[1];
  33829. break
  33830. } else {
  33831. if (token[0] === 'word' && /\w/.test(token[1])) {
  33832. this.unknownWord([token]);
  33833. }
  33834. node.raws.between += token[1];
  33835. }
  33836. }
  33837. if (node.prop[0] === '_' || node.prop[0] === '*') {
  33838. node.raws.before += node.prop[0];
  33839. node.prop = node.prop.slice(1);
  33840. }
  33841. let firstSpaces = [];
  33842. let next;
  33843. while (tokens.length) {
  33844. next = tokens[0][0];
  33845. if (next !== 'space' && next !== 'comment') break
  33846. firstSpaces.push(tokens.shift());
  33847. }
  33848. this.precheckMissedSemicolon(tokens);
  33849. for (let i = tokens.length - 1; i >= 0; i--) {
  33850. token = tokens[i];
  33851. if (token[1].toLowerCase() === '!important') {
  33852. node.important = true;
  33853. let string = this.stringFrom(tokens, i);
  33854. string = this.spacesFromEnd(tokens) + string;
  33855. if (string !== ' !important') node.raws.important = string;
  33856. break
  33857. } else if (token[1].toLowerCase() === 'important') {
  33858. let cache = tokens.slice(0);
  33859. let str = '';
  33860. for (let j = i; j > 0; j--) {
  33861. let type = cache[j][0];
  33862. if (str.trim().indexOf('!') === 0 && type !== 'space') {
  33863. break
  33864. }
  33865. str = cache.pop()[1] + str;
  33866. }
  33867. if (str.trim().indexOf('!') === 0) {
  33868. node.important = true;
  33869. node.raws.important = str;
  33870. tokens = cache;
  33871. }
  33872. }
  33873. if (token[0] !== 'space' && token[0] !== 'comment') {
  33874. break
  33875. }
  33876. }
  33877. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  33878. if (hasWord) {
  33879. node.raws.between += firstSpaces.map(i => i[1]).join('');
  33880. firstSpaces = [];
  33881. }
  33882. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  33883. if (node.value.includes(':') && !customProperty) {
  33884. this.checkMissedSemicolon(tokens);
  33885. }
  33886. }
  33887. doubleColon(token) {
  33888. throw this.input.error(
  33889. 'Double colon',
  33890. { offset: token[2] },
  33891. { offset: token[2] + token[1].length }
  33892. )
  33893. }
  33894. emptyRule(token) {
  33895. let node = new Rule$2();
  33896. this.init(node, token[2]);
  33897. node.selector = '';
  33898. node.raws.between = '';
  33899. this.current = node;
  33900. }
  33901. end(token) {
  33902. if (this.current.nodes && this.current.nodes.length) {
  33903. this.current.raws.semicolon = this.semicolon;
  33904. }
  33905. this.semicolon = false;
  33906. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  33907. this.spaces = '';
  33908. if (this.current.parent) {
  33909. this.current.source.end = this.getPosition(token[2]);
  33910. this.current.source.end.offset++;
  33911. this.current = this.current.parent;
  33912. } else {
  33913. this.unexpectedClose(token);
  33914. }
  33915. }
  33916. endFile() {
  33917. if (this.current.parent) this.unclosedBlock();
  33918. if (this.current.nodes && this.current.nodes.length) {
  33919. this.current.raws.semicolon = this.semicolon;
  33920. }
  33921. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  33922. this.root.source.end = this.getPosition(this.tokenizer.position());
  33923. }
  33924. freeSemicolon(token) {
  33925. this.spaces += token[1];
  33926. if (this.current.nodes) {
  33927. let prev = this.current.nodes[this.current.nodes.length - 1];
  33928. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  33929. prev.raws.ownSemicolon = this.spaces;
  33930. this.spaces = '';
  33931. }
  33932. }
  33933. }
  33934. // Helpers
  33935. getPosition(offset) {
  33936. let pos = this.input.fromOffset(offset);
  33937. return {
  33938. column: pos.col,
  33939. line: pos.line,
  33940. offset
  33941. }
  33942. }
  33943. init(node, offset) {
  33944. this.current.push(node);
  33945. node.source = {
  33946. input: this.input,
  33947. start: this.getPosition(offset)
  33948. };
  33949. node.raws.before = this.spaces;
  33950. this.spaces = '';
  33951. if (node.type !== 'comment') this.semicolon = false;
  33952. }
  33953. other(start) {
  33954. let end = false;
  33955. let type = null;
  33956. let colon = false;
  33957. let bracket = null;
  33958. let brackets = [];
  33959. let customProperty = start[1].startsWith('--');
  33960. let tokens = [];
  33961. let token = start;
  33962. while (token) {
  33963. type = token[0];
  33964. tokens.push(token);
  33965. if (type === '(' || type === '[') {
  33966. if (!bracket) bracket = token;
  33967. brackets.push(type === '(' ? ')' : ']');
  33968. } else if (customProperty && colon && type === '{') {
  33969. if (!bracket) bracket = token;
  33970. brackets.push('}');
  33971. } else if (brackets.length === 0) {
  33972. if (type === ';') {
  33973. if (colon) {
  33974. this.decl(tokens, customProperty);
  33975. return
  33976. } else {
  33977. break
  33978. }
  33979. } else if (type === '{') {
  33980. this.rule(tokens);
  33981. return
  33982. } else if (type === '}') {
  33983. this.tokenizer.back(tokens.pop());
  33984. end = true;
  33985. break
  33986. } else if (type === ':') {
  33987. colon = true;
  33988. }
  33989. } else if (type === brackets[brackets.length - 1]) {
  33990. brackets.pop();
  33991. if (brackets.length === 0) bracket = null;
  33992. }
  33993. token = this.tokenizer.nextToken();
  33994. }
  33995. if (this.tokenizer.endOfFile()) end = true;
  33996. if (brackets.length > 0) this.unclosedBracket(bracket);
  33997. if (end && colon) {
  33998. if (!customProperty) {
  33999. while (tokens.length) {
  34000. token = tokens[tokens.length - 1][0];
  34001. if (token !== 'space' && token !== 'comment') break
  34002. this.tokenizer.back(tokens.pop());
  34003. }
  34004. }
  34005. this.decl(tokens, customProperty);
  34006. } else {
  34007. this.unknownWord(tokens);
  34008. }
  34009. }
  34010. parse() {
  34011. let token;
  34012. while (!this.tokenizer.endOfFile()) {
  34013. token = this.tokenizer.nextToken();
  34014. switch (token[0]) {
  34015. case 'space':
  34016. this.spaces += token[1];
  34017. break
  34018. case ';':
  34019. this.freeSemicolon(token);
  34020. break
  34021. case '}':
  34022. this.end(token);
  34023. break
  34024. case 'comment':
  34025. this.comment(token);
  34026. break
  34027. case 'at-word':
  34028. this.atrule(token);
  34029. break
  34030. case '{':
  34031. this.emptyRule(token);
  34032. break
  34033. default:
  34034. this.other(token);
  34035. break
  34036. }
  34037. }
  34038. this.endFile();
  34039. }
  34040. precheckMissedSemicolon(/* tokens */) {
  34041. // Hook for Safe Parser
  34042. }
  34043. raw(node, prop, tokens, customProperty) {
  34044. let token, type;
  34045. let length = tokens.length;
  34046. let value = '';
  34047. let clean = true;
  34048. let next, prev;
  34049. for (let i = 0; i < length; i += 1) {
  34050. token = tokens[i];
  34051. type = token[0];
  34052. if (type === 'space' && i === length - 1 && !customProperty) {
  34053. clean = false;
  34054. } else if (type === 'comment') {
  34055. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  34056. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  34057. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  34058. if (value.slice(-1) === ',') {
  34059. clean = false;
  34060. } else {
  34061. value += token[1];
  34062. }
  34063. } else {
  34064. clean = false;
  34065. }
  34066. } else {
  34067. value += token[1];
  34068. }
  34069. }
  34070. if (!clean) {
  34071. let raw = tokens.reduce((all, i) => all + i[1], '');
  34072. node.raws[prop] = { raw, value };
  34073. }
  34074. node[prop] = value;
  34075. }
  34076. rule(tokens) {
  34077. tokens.pop();
  34078. let node = new Rule$2();
  34079. this.init(node, tokens[0][2]);
  34080. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  34081. this.raw(node, 'selector', tokens);
  34082. this.current = node;
  34083. }
  34084. spacesAndCommentsFromEnd(tokens) {
  34085. let lastTokenType;
  34086. let spaces = '';
  34087. while (tokens.length) {
  34088. lastTokenType = tokens[tokens.length - 1][0];
  34089. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  34090. spaces = tokens.pop()[1] + spaces;
  34091. }
  34092. return spaces
  34093. }
  34094. // Errors
  34095. spacesAndCommentsFromStart(tokens) {
  34096. let next;
  34097. let spaces = '';
  34098. while (tokens.length) {
  34099. next = tokens[0][0];
  34100. if (next !== 'space' && next !== 'comment') break
  34101. spaces += tokens.shift()[1];
  34102. }
  34103. return spaces
  34104. }
  34105. spacesFromEnd(tokens) {
  34106. let lastTokenType;
  34107. let spaces = '';
  34108. while (tokens.length) {
  34109. lastTokenType = tokens[tokens.length - 1][0];
  34110. if (lastTokenType !== 'space') break
  34111. spaces = tokens.pop()[1] + spaces;
  34112. }
  34113. return spaces
  34114. }
  34115. stringFrom(tokens, from) {
  34116. let result = '';
  34117. for (let i = from; i < tokens.length; i++) {
  34118. result += tokens[i][1];
  34119. }
  34120. tokens.splice(from, tokens.length - from);
  34121. return result
  34122. }
  34123. unclosedBlock() {
  34124. let pos = this.current.source.start;
  34125. throw this.input.error('Unclosed block', pos.line, pos.column)
  34126. }
  34127. unclosedBracket(bracket) {
  34128. throw this.input.error(
  34129. 'Unclosed bracket',
  34130. { offset: bracket[2] },
  34131. { offset: bracket[2] + 1 }
  34132. )
  34133. }
  34134. unexpectedClose(token) {
  34135. throw this.input.error(
  34136. 'Unexpected }',
  34137. { offset: token[2] },
  34138. { offset: token[2] + 1 }
  34139. )
  34140. }
  34141. unknownWord(tokens) {
  34142. throw this.input.error(
  34143. 'Unknown word',
  34144. { offset: tokens[0][2] },
  34145. { offset: tokens[0][2] + tokens[0][1].length }
  34146. )
  34147. }
  34148. unnamedAtrule(node, token) {
  34149. throw this.input.error(
  34150. 'At-rule without name',
  34151. { offset: token[2] },
  34152. { offset: token[2] + token[1].length }
  34153. )
  34154. }
  34155. };
  34156. var parser$1 = Parser$1;
  34157. let Container$2 = container$1;
  34158. let Parser = parser$1;
  34159. let Input$2 = input;
  34160. function parse$3(css, opts) {
  34161. let input = new Input$2(css, opts);
  34162. let parser = new Parser(input);
  34163. try {
  34164. parser.parse();
  34165. } catch (e) {
  34166. if (browser$1.env.NODE_ENV !== 'production') {
  34167. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  34168. if (/\.scss$/i.test(opts.from)) {
  34169. e.message +=
  34170. '\nYou tried to parse SCSS with ' +
  34171. 'the standard CSS parser; ' +
  34172. 'try again with the postcss-scss parser';
  34173. } else if (/\.sass/i.test(opts.from)) {
  34174. e.message +=
  34175. '\nYou tried to parse Sass with ' +
  34176. 'the standard CSS parser; ' +
  34177. 'try again with the postcss-sass parser';
  34178. } else if (/\.less$/i.test(opts.from)) {
  34179. e.message +=
  34180. '\nYou tried to parse Less with ' +
  34181. 'the standard CSS parser; ' +
  34182. 'try again with the postcss-less parser';
  34183. }
  34184. }
  34185. }
  34186. throw e
  34187. }
  34188. return parser.root
  34189. }
  34190. var parse_1 = parse$3;
  34191. parse$3.default = parse$3;
  34192. Container$2.registerParse(parse$3);
  34193. let { isClean, my } = symbols;
  34194. let MapGenerator$1 = mapGenerator;
  34195. let stringify$2 = stringify_1;
  34196. let Container$1 = container$1;
  34197. let Document$2 = document;
  34198. let warnOnce$1 = warnOnce$2;
  34199. let Result$2 = result;
  34200. let parse$2 = parse_1;
  34201. let Root$3 = root$2;
  34202. const TYPE_TO_CLASS_NAME = {
  34203. atrule: 'AtRule',
  34204. comment: 'Comment',
  34205. decl: 'Declaration',
  34206. document: 'Document',
  34207. root: 'Root',
  34208. rule: 'Rule'
  34209. };
  34210. const PLUGIN_PROPS = {
  34211. AtRule: true,
  34212. AtRuleExit: true,
  34213. Comment: true,
  34214. CommentExit: true,
  34215. Declaration: true,
  34216. DeclarationExit: true,
  34217. Document: true,
  34218. DocumentExit: true,
  34219. Once: true,
  34220. OnceExit: true,
  34221. postcssPlugin: true,
  34222. prepare: true,
  34223. Root: true,
  34224. RootExit: true,
  34225. Rule: true,
  34226. RuleExit: true
  34227. };
  34228. const NOT_VISITORS = {
  34229. Once: true,
  34230. postcssPlugin: true,
  34231. prepare: true
  34232. };
  34233. const CHILDREN = 0;
  34234. function isPromise(obj) {
  34235. return typeof obj === 'object' && typeof obj.then === 'function'
  34236. }
  34237. function getEvents(node) {
  34238. let key = false;
  34239. let type = TYPE_TO_CLASS_NAME[node.type];
  34240. if (node.type === 'decl') {
  34241. key = node.prop.toLowerCase();
  34242. } else if (node.type === 'atrule') {
  34243. key = node.name.toLowerCase();
  34244. }
  34245. if (key && node.append) {
  34246. return [
  34247. type,
  34248. type + '-' + key,
  34249. CHILDREN,
  34250. type + 'Exit',
  34251. type + 'Exit-' + key
  34252. ]
  34253. } else if (key) {
  34254. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  34255. } else if (node.append) {
  34256. return [type, CHILDREN, type + 'Exit']
  34257. } else {
  34258. return [type, type + 'Exit']
  34259. }
  34260. }
  34261. function toStack(node) {
  34262. let events;
  34263. if (node.type === 'document') {
  34264. events = ['Document', CHILDREN, 'DocumentExit'];
  34265. } else if (node.type === 'root') {
  34266. events = ['Root', CHILDREN, 'RootExit'];
  34267. } else {
  34268. events = getEvents(node);
  34269. }
  34270. return {
  34271. eventIndex: 0,
  34272. events,
  34273. iterator: 0,
  34274. node,
  34275. visitorIndex: 0,
  34276. visitors: []
  34277. }
  34278. }
  34279. function cleanMarks(node) {
  34280. node[isClean] = false;
  34281. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  34282. return node
  34283. }
  34284. let postcss$2 = {};
  34285. let LazyResult$2 = class LazyResult {
  34286. constructor(processor, css, opts) {
  34287. this.stringified = false;
  34288. this.processed = false;
  34289. let root;
  34290. if (
  34291. typeof css === 'object' &&
  34292. css !== null &&
  34293. (css.type === 'root' || css.type === 'document')
  34294. ) {
  34295. root = cleanMarks(css);
  34296. } else if (css instanceof LazyResult || css instanceof Result$2) {
  34297. root = cleanMarks(css.root);
  34298. if (css.map) {
  34299. if (typeof opts.map === 'undefined') opts.map = {};
  34300. if (!opts.map.inline) opts.map.inline = false;
  34301. opts.map.prev = css.map;
  34302. }
  34303. } else {
  34304. let parser = parse$2;
  34305. if (opts.syntax) parser = opts.syntax.parse;
  34306. if (opts.parser) parser = opts.parser;
  34307. if (parser.parse) parser = parser.parse;
  34308. try {
  34309. root = parser(css, opts);
  34310. } catch (error) {
  34311. this.processed = true;
  34312. this.error = error;
  34313. }
  34314. if (root && !root[my]) {
  34315. /* c8 ignore next 2 */
  34316. Container$1.rebuild(root);
  34317. }
  34318. }
  34319. this.result = new Result$2(processor, root, opts);
  34320. this.helpers = { ...postcss$2, postcss: postcss$2, result: this.result };
  34321. this.plugins = this.processor.plugins.map(plugin => {
  34322. if (typeof plugin === 'object' && plugin.prepare) {
  34323. return { ...plugin, ...plugin.prepare(this.result) }
  34324. } else {
  34325. return plugin
  34326. }
  34327. });
  34328. }
  34329. async() {
  34330. if (this.error) return Promise.reject(this.error)
  34331. if (this.processed) return Promise.resolve(this.result)
  34332. if (!this.processing) {
  34333. this.processing = this.runAsync();
  34334. }
  34335. return this.processing
  34336. }
  34337. catch(onRejected) {
  34338. return this.async().catch(onRejected)
  34339. }
  34340. finally(onFinally) {
  34341. return this.async().then(onFinally, onFinally)
  34342. }
  34343. getAsyncError() {
  34344. throw new Error('Use process(css).then(cb) to work with async plugins')
  34345. }
  34346. handleError(error, node) {
  34347. let plugin = this.result.lastPlugin;
  34348. try {
  34349. if (node) node.addToError(error);
  34350. this.error = error;
  34351. if (error.name === 'CssSyntaxError' && !error.plugin) {
  34352. error.plugin = plugin.postcssPlugin;
  34353. error.setMessage();
  34354. } else if (plugin.postcssVersion) {
  34355. if (browser$1.env.NODE_ENV !== 'production') {
  34356. let pluginName = plugin.postcssPlugin;
  34357. let pluginVer = plugin.postcssVersion;
  34358. let runtimeVer = this.result.processor.version;
  34359. let a = pluginVer.split('.');
  34360. let b = runtimeVer.split('.');
  34361. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  34362. // eslint-disable-next-line no-console
  34363. console.error(
  34364. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  34365. 'version is ' +
  34366. runtimeVer +
  34367. ', but ' +
  34368. pluginName +
  34369. ' uses ' +
  34370. pluginVer +
  34371. '. Perhaps this is the source of the error below.'
  34372. );
  34373. }
  34374. }
  34375. }
  34376. } catch (err) {
  34377. /* c8 ignore next 3 */
  34378. // eslint-disable-next-line no-console
  34379. if (console && console.error) console.error(err);
  34380. }
  34381. return error
  34382. }
  34383. prepareVisitors() {
  34384. this.listeners = {};
  34385. let add = (plugin, type, cb) => {
  34386. if (!this.listeners[type]) this.listeners[type] = [];
  34387. this.listeners[type].push([plugin, cb]);
  34388. };
  34389. for (let plugin of this.plugins) {
  34390. if (typeof plugin === 'object') {
  34391. for (let event in plugin) {
  34392. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  34393. throw new Error(
  34394. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  34395. `Try to update PostCSS (${this.processor.version} now).`
  34396. )
  34397. }
  34398. if (!NOT_VISITORS[event]) {
  34399. if (typeof plugin[event] === 'object') {
  34400. for (let filter in plugin[event]) {
  34401. if (filter === '*') {
  34402. add(plugin, event, plugin[event][filter]);
  34403. } else {
  34404. add(
  34405. plugin,
  34406. event + '-' + filter.toLowerCase(),
  34407. plugin[event][filter]
  34408. );
  34409. }
  34410. }
  34411. } else if (typeof plugin[event] === 'function') {
  34412. add(plugin, event, plugin[event]);
  34413. }
  34414. }
  34415. }
  34416. }
  34417. }
  34418. this.hasListener = Object.keys(this.listeners).length > 0;
  34419. }
  34420. async runAsync() {
  34421. this.plugin = 0;
  34422. for (let i = 0; i < this.plugins.length; i++) {
  34423. let plugin = this.plugins[i];
  34424. let promise = this.runOnRoot(plugin);
  34425. if (isPromise(promise)) {
  34426. try {
  34427. await promise;
  34428. } catch (error) {
  34429. throw this.handleError(error)
  34430. }
  34431. }
  34432. }
  34433. this.prepareVisitors();
  34434. if (this.hasListener) {
  34435. let root = this.result.root;
  34436. while (!root[isClean]) {
  34437. root[isClean] = true;
  34438. let stack = [toStack(root)];
  34439. while (stack.length > 0) {
  34440. let promise = this.visitTick(stack);
  34441. if (isPromise(promise)) {
  34442. try {
  34443. await promise;
  34444. } catch (e) {
  34445. let node = stack[stack.length - 1].node;
  34446. throw this.handleError(e, node)
  34447. }
  34448. }
  34449. }
  34450. }
  34451. if (this.listeners.OnceExit) {
  34452. for (let [plugin, visitor] of this.listeners.OnceExit) {
  34453. this.result.lastPlugin = plugin;
  34454. try {
  34455. if (root.type === 'document') {
  34456. let roots = root.nodes.map(subRoot =>
  34457. visitor(subRoot, this.helpers)
  34458. );
  34459. await Promise.all(roots);
  34460. } else {
  34461. await visitor(root, this.helpers);
  34462. }
  34463. } catch (e) {
  34464. throw this.handleError(e)
  34465. }
  34466. }
  34467. }
  34468. }
  34469. this.processed = true;
  34470. return this.stringify()
  34471. }
  34472. runOnRoot(plugin) {
  34473. this.result.lastPlugin = plugin;
  34474. try {
  34475. if (typeof plugin === 'object' && plugin.Once) {
  34476. if (this.result.root.type === 'document') {
  34477. let roots = this.result.root.nodes.map(root =>
  34478. plugin.Once(root, this.helpers)
  34479. );
  34480. if (isPromise(roots[0])) {
  34481. return Promise.all(roots)
  34482. }
  34483. return roots
  34484. }
  34485. return plugin.Once(this.result.root, this.helpers)
  34486. } else if (typeof plugin === 'function') {
  34487. return plugin(this.result.root, this.result)
  34488. }
  34489. } catch (error) {
  34490. throw this.handleError(error)
  34491. }
  34492. }
  34493. stringify() {
  34494. if (this.error) throw this.error
  34495. if (this.stringified) return this.result
  34496. this.stringified = true;
  34497. this.sync();
  34498. let opts = this.result.opts;
  34499. let str = stringify$2;
  34500. if (opts.syntax) str = opts.syntax.stringify;
  34501. if (opts.stringifier) str = opts.stringifier;
  34502. if (str.stringify) str = str.stringify;
  34503. let map = new MapGenerator$1(str, this.result.root, this.result.opts);
  34504. let data = map.generate();
  34505. this.result.css = data[0];
  34506. this.result.map = data[1];
  34507. return this.result
  34508. }
  34509. sync() {
  34510. if (this.error) throw this.error
  34511. if (this.processed) return this.result
  34512. this.processed = true;
  34513. if (this.processing) {
  34514. throw this.getAsyncError()
  34515. }
  34516. for (let plugin of this.plugins) {
  34517. let promise = this.runOnRoot(plugin);
  34518. if (isPromise(promise)) {
  34519. throw this.getAsyncError()
  34520. }
  34521. }
  34522. this.prepareVisitors();
  34523. if (this.hasListener) {
  34524. let root = this.result.root;
  34525. while (!root[isClean]) {
  34526. root[isClean] = true;
  34527. this.walkSync(root);
  34528. }
  34529. if (this.listeners.OnceExit) {
  34530. if (root.type === 'document') {
  34531. for (let subRoot of root.nodes) {
  34532. this.visitSync(this.listeners.OnceExit, subRoot);
  34533. }
  34534. } else {
  34535. this.visitSync(this.listeners.OnceExit, root);
  34536. }
  34537. }
  34538. }
  34539. return this.result
  34540. }
  34541. then(onFulfilled, onRejected) {
  34542. if (browser$1.env.NODE_ENV !== 'production') {
  34543. if (!('from' in this.opts)) {
  34544. warnOnce$1(
  34545. 'Without `from` option PostCSS could generate wrong source map ' +
  34546. 'and will not find Browserslist config. Set it to CSS file path ' +
  34547. 'or to `undefined` to prevent this warning.'
  34548. );
  34549. }
  34550. }
  34551. return this.async().then(onFulfilled, onRejected)
  34552. }
  34553. toString() {
  34554. return this.css
  34555. }
  34556. visitSync(visitors, node) {
  34557. for (let [plugin, visitor] of visitors) {
  34558. this.result.lastPlugin = plugin;
  34559. let promise;
  34560. try {
  34561. promise = visitor(node, this.helpers);
  34562. } catch (e) {
  34563. throw this.handleError(e, node.proxyOf)
  34564. }
  34565. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34566. return true
  34567. }
  34568. if (isPromise(promise)) {
  34569. throw this.getAsyncError()
  34570. }
  34571. }
  34572. }
  34573. visitTick(stack) {
  34574. let visit = stack[stack.length - 1];
  34575. let { node, visitors } = visit;
  34576. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34577. stack.pop();
  34578. return
  34579. }
  34580. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  34581. let [plugin, visitor] = visitors[visit.visitorIndex];
  34582. visit.visitorIndex += 1;
  34583. if (visit.visitorIndex === visitors.length) {
  34584. visit.visitors = [];
  34585. visit.visitorIndex = 0;
  34586. }
  34587. this.result.lastPlugin = plugin;
  34588. try {
  34589. return visitor(node.toProxy(), this.helpers)
  34590. } catch (e) {
  34591. throw this.handleError(e, node)
  34592. }
  34593. }
  34594. if (visit.iterator !== 0) {
  34595. let iterator = visit.iterator;
  34596. let child;
  34597. while ((child = node.nodes[node.indexes[iterator]])) {
  34598. node.indexes[iterator] += 1;
  34599. if (!child[isClean]) {
  34600. child[isClean] = true;
  34601. stack.push(toStack(child));
  34602. return
  34603. }
  34604. }
  34605. visit.iterator = 0;
  34606. delete node.indexes[iterator];
  34607. }
  34608. let events = visit.events;
  34609. while (visit.eventIndex < events.length) {
  34610. let event = events[visit.eventIndex];
  34611. visit.eventIndex += 1;
  34612. if (event === CHILDREN) {
  34613. if (node.nodes && node.nodes.length) {
  34614. node[isClean] = true;
  34615. visit.iterator = node.getIterator();
  34616. }
  34617. return
  34618. } else if (this.listeners[event]) {
  34619. visit.visitors = this.listeners[event];
  34620. return
  34621. }
  34622. }
  34623. stack.pop();
  34624. }
  34625. walkSync(node) {
  34626. node[isClean] = true;
  34627. let events = getEvents(node);
  34628. for (let event of events) {
  34629. if (event === CHILDREN) {
  34630. if (node.nodes) {
  34631. node.each(child => {
  34632. if (!child[isClean]) this.walkSync(child);
  34633. });
  34634. }
  34635. } else {
  34636. let visitors = this.listeners[event];
  34637. if (visitors) {
  34638. if (this.visitSync(visitors, node.toProxy())) return
  34639. }
  34640. }
  34641. }
  34642. }
  34643. warnings() {
  34644. return this.sync().warnings()
  34645. }
  34646. get content() {
  34647. return this.stringify().content
  34648. }
  34649. get css() {
  34650. return this.stringify().css
  34651. }
  34652. get map() {
  34653. return this.stringify().map
  34654. }
  34655. get messages() {
  34656. return this.sync().messages
  34657. }
  34658. get opts() {
  34659. return this.result.opts
  34660. }
  34661. get processor() {
  34662. return this.result.processor
  34663. }
  34664. get root() {
  34665. return this.sync().root
  34666. }
  34667. get [Symbol.toStringTag]() {
  34668. return 'LazyResult'
  34669. }
  34670. };
  34671. LazyResult$2.registerPostcss = dependant => {
  34672. postcss$2 = dependant;
  34673. };
  34674. var lazyResult = LazyResult$2;
  34675. LazyResult$2.default = LazyResult$2;
  34676. Root$3.registerLazyResult(LazyResult$2);
  34677. Document$2.registerLazyResult(LazyResult$2);
  34678. let MapGenerator = mapGenerator;
  34679. let stringify$1 = stringify_1;
  34680. let warnOnce = warnOnce$2;
  34681. let parse$1 = parse_1;
  34682. const Result$1 = result;
  34683. let NoWorkResult$1 = class NoWorkResult {
  34684. constructor(processor, css, opts) {
  34685. css = css.toString();
  34686. this.stringified = false;
  34687. this._processor = processor;
  34688. this._css = css;
  34689. this._opts = opts;
  34690. this._map = undefined;
  34691. let root;
  34692. let str = stringify$1;
  34693. this.result = new Result$1(this._processor, root, this._opts);
  34694. this.result.css = css;
  34695. let self = this;
  34696. Object.defineProperty(this.result, 'root', {
  34697. get() {
  34698. return self.root
  34699. }
  34700. });
  34701. let map = new MapGenerator(str, root, this._opts, css);
  34702. if (map.isMap()) {
  34703. let [generatedCSS, generatedMap] = map.generate();
  34704. if (generatedCSS) {
  34705. this.result.css = generatedCSS;
  34706. }
  34707. if (generatedMap) {
  34708. this.result.map = generatedMap;
  34709. }
  34710. } else {
  34711. map.clearAnnotation();
  34712. this.result.css = map.css;
  34713. }
  34714. }
  34715. async() {
  34716. if (this.error) return Promise.reject(this.error)
  34717. return Promise.resolve(this.result)
  34718. }
  34719. catch(onRejected) {
  34720. return this.async().catch(onRejected)
  34721. }
  34722. finally(onFinally) {
  34723. return this.async().then(onFinally, onFinally)
  34724. }
  34725. sync() {
  34726. if (this.error) throw this.error
  34727. return this.result
  34728. }
  34729. then(onFulfilled, onRejected) {
  34730. if (browser$1.env.NODE_ENV !== 'production') {
  34731. if (!('from' in this._opts)) {
  34732. warnOnce(
  34733. 'Without `from` option PostCSS could generate wrong source map ' +
  34734. 'and will not find Browserslist config. Set it to CSS file path ' +
  34735. 'or to `undefined` to prevent this warning.'
  34736. );
  34737. }
  34738. }
  34739. return this.async().then(onFulfilled, onRejected)
  34740. }
  34741. toString() {
  34742. return this._css
  34743. }
  34744. warnings() {
  34745. return []
  34746. }
  34747. get content() {
  34748. return this.result.css
  34749. }
  34750. get css() {
  34751. return this.result.css
  34752. }
  34753. get map() {
  34754. return this.result.map
  34755. }
  34756. get messages() {
  34757. return []
  34758. }
  34759. get opts() {
  34760. return this.result.opts
  34761. }
  34762. get processor() {
  34763. return this.result.processor
  34764. }
  34765. get root() {
  34766. if (this._root) {
  34767. return this._root
  34768. }
  34769. let root;
  34770. let parser = parse$1;
  34771. try {
  34772. root = parser(this._css, this._opts);
  34773. } catch (error) {
  34774. this.error = error;
  34775. }
  34776. if (this.error) {
  34777. throw this.error
  34778. } else {
  34779. this._root = root;
  34780. return root
  34781. }
  34782. }
  34783. get [Symbol.toStringTag]() {
  34784. return 'NoWorkResult'
  34785. }
  34786. };
  34787. var noWorkResult = NoWorkResult$1;
  34788. NoWorkResult$1.default = NoWorkResult$1;
  34789. let NoWorkResult = noWorkResult;
  34790. let LazyResult$1 = lazyResult;
  34791. let Document$1 = document;
  34792. let Root$2 = root$2;
  34793. let Processor$1 = class Processor {
  34794. constructor(plugins = []) {
  34795. this.version = '8.4.35';
  34796. this.plugins = this.normalize(plugins);
  34797. }
  34798. normalize(plugins) {
  34799. let normalized = [];
  34800. for (let i of plugins) {
  34801. if (i.postcss === true) {
  34802. i = i();
  34803. } else if (i.postcss) {
  34804. i = i.postcss;
  34805. }
  34806. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  34807. normalized = normalized.concat(i.plugins);
  34808. } else if (typeof i === 'object' && i.postcssPlugin) {
  34809. normalized.push(i);
  34810. } else if (typeof i === 'function') {
  34811. normalized.push(i);
  34812. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  34813. if (browser$1.env.NODE_ENV !== 'production') {
  34814. throw new Error(
  34815. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  34816. 'one of the syntax/parser/stringifier options as outlined ' +
  34817. 'in your PostCSS runner documentation.'
  34818. )
  34819. }
  34820. } else {
  34821. throw new Error(i + ' is not a PostCSS plugin')
  34822. }
  34823. }
  34824. return normalized
  34825. }
  34826. process(css, opts = {}) {
  34827. if (
  34828. !this.plugins.length &&
  34829. !opts.parser &&
  34830. !opts.stringifier &&
  34831. !opts.syntax
  34832. ) {
  34833. return new NoWorkResult(this, css, opts)
  34834. } else {
  34835. return new LazyResult$1(this, css, opts)
  34836. }
  34837. }
  34838. use(plugin) {
  34839. this.plugins = this.plugins.concat(this.normalize([plugin]));
  34840. return this
  34841. }
  34842. };
  34843. var processor$1 = Processor$1;
  34844. Processor$1.default = Processor$1;
  34845. Root$2.registerProcessor(Processor$1);
  34846. Document$1.registerProcessor(Processor$1);
  34847. let Declaration$1 = declaration;
  34848. let PreviousMap = previousMap;
  34849. let Comment$1 = comment$3;
  34850. let AtRule$1 = atRule;
  34851. let Input$1 = input;
  34852. let Root$1 = root$2;
  34853. let Rule$1 = rule;
  34854. function fromJSON$1(json, inputs) {
  34855. if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
  34856. let { inputs: ownInputs, ...defaults } = json;
  34857. if (ownInputs) {
  34858. inputs = [];
  34859. for (let input of ownInputs) {
  34860. let inputHydrated = { ...input, __proto__: Input$1.prototype };
  34861. if (inputHydrated.map) {
  34862. inputHydrated.map = {
  34863. ...inputHydrated.map,
  34864. __proto__: PreviousMap.prototype
  34865. };
  34866. }
  34867. inputs.push(inputHydrated);
  34868. }
  34869. }
  34870. if (defaults.nodes) {
  34871. defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
  34872. }
  34873. if (defaults.source) {
  34874. let { inputId, ...source } = defaults.source;
  34875. defaults.source = source;
  34876. if (inputId != null) {
  34877. defaults.source.input = inputs[inputId];
  34878. }
  34879. }
  34880. if (defaults.type === 'root') {
  34881. return new Root$1(defaults)
  34882. } else if (defaults.type === 'decl') {
  34883. return new Declaration$1(defaults)
  34884. } else if (defaults.type === 'rule') {
  34885. return new Rule$1(defaults)
  34886. } else if (defaults.type === 'comment') {
  34887. return new Comment$1(defaults)
  34888. } else if (defaults.type === 'atrule') {
  34889. return new AtRule$1(defaults)
  34890. } else {
  34891. throw new Error('Unknown node type: ' + json.type)
  34892. }
  34893. }
  34894. var fromJSON_1 = fromJSON$1;
  34895. fromJSON$1.default = fromJSON$1;
  34896. let CssSyntaxError = cssSyntaxError;
  34897. let Declaration = declaration;
  34898. let LazyResult = lazyResult;
  34899. let Container = container$1;
  34900. let Processor = processor$1;
  34901. let stringify = stringify_1;
  34902. let fromJSON = fromJSON_1;
  34903. let Document = document;
  34904. let Warning = warning;
  34905. let Comment = comment$3;
  34906. let AtRule = atRule;
  34907. let Result = result;
  34908. let Input = input;
  34909. let parse = parse_1;
  34910. let list = list_1;
  34911. let Rule = rule;
  34912. let Root = root$2;
  34913. let Node = node$2;
  34914. function postcss(...plugins) {
  34915. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  34916. plugins = plugins[0];
  34917. }
  34918. return new Processor(plugins)
  34919. }
  34920. postcss.plugin = function plugin(name, initializer) {
  34921. let warningPrinted = false;
  34922. function creator(...args) {
  34923. // eslint-disable-next-line no-console
  34924. if (console && console.warn && !warningPrinted) {
  34925. warningPrinted = true;
  34926. // eslint-disable-next-line no-console
  34927. console.warn(
  34928. name +
  34929. ': postcss.plugin was deprecated. Migration guide:\n' +
  34930. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  34931. );
  34932. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  34933. /* c8 ignore next 7 */
  34934. // eslint-disable-next-line no-console
  34935. console.warn(
  34936. name +
  34937. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  34938. 'https://www.w3ctech.com/topic/2226'
  34939. );
  34940. }
  34941. }
  34942. let transformer = initializer(...args);
  34943. transformer.postcssPlugin = name;
  34944. transformer.postcssVersion = new Processor().version;
  34945. return transformer
  34946. }
  34947. let cache;
  34948. Object.defineProperty(creator, 'postcss', {
  34949. get() {
  34950. if (!cache) cache = creator();
  34951. return cache
  34952. }
  34953. });
  34954. creator.process = function (css, processOpts, pluginOpts) {
  34955. return postcss([creator(pluginOpts)]).process(css, processOpts)
  34956. };
  34957. return creator
  34958. };
  34959. postcss.stringify = stringify;
  34960. postcss.parse = parse;
  34961. postcss.fromJSON = fromJSON;
  34962. postcss.list = list;
  34963. postcss.comment = defaults => new Comment(defaults);
  34964. postcss.atRule = defaults => new AtRule(defaults);
  34965. postcss.decl = defaults => new Declaration(defaults);
  34966. postcss.rule = defaults => new Rule(defaults);
  34967. postcss.root = defaults => new Root(defaults);
  34968. postcss.document = defaults => new Document(defaults);
  34969. postcss.CssSyntaxError = CssSyntaxError;
  34970. postcss.Declaration = Declaration;
  34971. postcss.Container = Container;
  34972. postcss.Processor = Processor;
  34973. postcss.Document = Document;
  34974. postcss.Comment = Comment;
  34975. postcss.Warning = Warning;
  34976. postcss.AtRule = AtRule;
  34977. postcss.Result = Result;
  34978. postcss.Input = Input;
  34979. postcss.Rule = Rule;
  34980. postcss.Root = Root;
  34981. postcss.Node = Node;
  34982. LazyResult.registerPostcss(postcss);
  34983. var postcss_1 = postcss;
  34984. postcss.default = postcss;
  34985. var postcss$1 = /*@__PURE__*/getDefaultExportFromCjs(postcss_1);
  34986. postcss$1.stringify;
  34987. postcss$1.fromJSON;
  34988. postcss$1.plugin;
  34989. postcss$1.parse;
  34990. postcss$1.list;
  34991. postcss$1.document;
  34992. postcss$1.comment;
  34993. postcss$1.atRule;
  34994. postcss$1.rule;
  34995. postcss$1.decl;
  34996. postcss$1.root;
  34997. postcss$1.CssSyntaxError;
  34998. postcss$1.Declaration;
  34999. postcss$1.Container;
  35000. postcss$1.Processor;
  35001. postcss$1.Document;
  35002. postcss$1.Comment;
  35003. postcss$1.Warning;
  35004. postcss$1.AtRule;
  35005. postcss$1.Result;
  35006. postcss$1.Input;
  35007. postcss$1.Rule;
  35008. postcss$1.Root;
  35009. postcss$1.Node;
  35010. const trimPlugin = () => {
  35011. return {
  35012. postcssPlugin: "vue-sfc-trim",
  35013. Once(root) {
  35014. root.walk(({ type, raws }) => {
  35015. if (type === "rule" || type === "atrule") {
  35016. if (raws.before)
  35017. raws.before = "\n";
  35018. if ("after" in raws && raws.after)
  35019. raws.after = "\n";
  35020. }
  35021. });
  35022. }
  35023. };
  35024. };
  35025. trimPlugin.postcss = true;
  35026. var dist = {exports: {}};
  35027. var processor = {exports: {}};
  35028. var parser = {exports: {}};
  35029. var root$1 = {exports: {}};
  35030. var container = {exports: {}};
  35031. var node$1 = {exports: {}};
  35032. var util$6 = {};
  35033. var unesc = {exports: {}};
  35034. (function (module, exports) {
  35035. exports.__esModule = true;
  35036. exports["default"] = unesc;
  35037. // Many thanks for this post which made this migration much easier.
  35038. // https://mathiasbynens.be/notes/css-escapes
  35039. /**
  35040. *
  35041. * @param {string} str
  35042. * @returns {[string, number]|undefined}
  35043. */
  35044. function gobbleHex(str) {
  35045. var lower = str.toLowerCase();
  35046. var hex = '';
  35047. var spaceTerminated = false;
  35048. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  35049. var code = lower.charCodeAt(i);
  35050. // check to see if we are dealing with a valid hex char [a-f|0-9]
  35051. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  35052. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  35053. spaceTerminated = code === 32;
  35054. if (!valid) {
  35055. break;
  35056. }
  35057. hex += lower[i];
  35058. }
  35059. if (hex.length === 0) {
  35060. return undefined;
  35061. }
  35062. var codePoint = parseInt(hex, 16);
  35063. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  35064. // Add special case for
  35065. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  35066. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  35067. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  35068. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  35069. }
  35070. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  35071. }
  35072. var CONTAINS_ESCAPE = /\\/;
  35073. function unesc(str) {
  35074. var needToProcess = CONTAINS_ESCAPE.test(str);
  35075. if (!needToProcess) {
  35076. return str;
  35077. }
  35078. var ret = "";
  35079. for (var i = 0; i < str.length; i++) {
  35080. if (str[i] === "\\") {
  35081. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  35082. if (gobbled !== undefined) {
  35083. ret += gobbled[0];
  35084. i += gobbled[1];
  35085. continue;
  35086. }
  35087. // Retain a pair of \\ if double escaped `\\\\`
  35088. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  35089. if (str[i + 1] === "\\") {
  35090. ret += "\\";
  35091. i++;
  35092. continue;
  35093. }
  35094. // if \\ is at the end of the string retain it
  35095. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  35096. if (str.length === i + 1) {
  35097. ret += str[i];
  35098. }
  35099. continue;
  35100. }
  35101. ret += str[i];
  35102. }
  35103. return ret;
  35104. }
  35105. module.exports = exports.default;
  35106. } (unesc, unesc.exports));
  35107. var unescExports = unesc.exports;
  35108. var getProp = {exports: {}};
  35109. (function (module, exports) {
  35110. exports.__esModule = true;
  35111. exports["default"] = getProp;
  35112. function getProp(obj) {
  35113. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35114. props[_key - 1] = arguments[_key];
  35115. }
  35116. while (props.length > 0) {
  35117. var prop = props.shift();
  35118. if (!obj[prop]) {
  35119. return undefined;
  35120. }
  35121. obj = obj[prop];
  35122. }
  35123. return obj;
  35124. }
  35125. module.exports = exports.default;
  35126. } (getProp, getProp.exports));
  35127. var getPropExports = getProp.exports;
  35128. var ensureObject = {exports: {}};
  35129. (function (module, exports) {
  35130. exports.__esModule = true;
  35131. exports["default"] = ensureObject;
  35132. function ensureObject(obj) {
  35133. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35134. props[_key - 1] = arguments[_key];
  35135. }
  35136. while (props.length > 0) {
  35137. var prop = props.shift();
  35138. if (!obj[prop]) {
  35139. obj[prop] = {};
  35140. }
  35141. obj = obj[prop];
  35142. }
  35143. }
  35144. module.exports = exports.default;
  35145. } (ensureObject, ensureObject.exports));
  35146. var ensureObjectExports = ensureObject.exports;
  35147. var stripComments = {exports: {}};
  35148. (function (module, exports) {
  35149. exports.__esModule = true;
  35150. exports["default"] = stripComments;
  35151. function stripComments(str) {
  35152. var s = "";
  35153. var commentStart = str.indexOf("/*");
  35154. var lastEnd = 0;
  35155. while (commentStart >= 0) {
  35156. s = s + str.slice(lastEnd, commentStart);
  35157. var commentEnd = str.indexOf("*/", commentStart + 2);
  35158. if (commentEnd < 0) {
  35159. return s;
  35160. }
  35161. lastEnd = commentEnd + 2;
  35162. commentStart = str.indexOf("/*", lastEnd);
  35163. }
  35164. s = s + str.slice(lastEnd);
  35165. return s;
  35166. }
  35167. module.exports = exports.default;
  35168. } (stripComments, stripComments.exports));
  35169. var stripCommentsExports = stripComments.exports;
  35170. util$6.__esModule = true;
  35171. util$6.unesc = util$6.stripComments = util$6.getProp = util$6.ensureObject = void 0;
  35172. var _unesc = _interopRequireDefault$1(unescExports);
  35173. util$6.unesc = _unesc["default"];
  35174. var _getProp = _interopRequireDefault$1(getPropExports);
  35175. util$6.getProp = _getProp["default"];
  35176. var _ensureObject = _interopRequireDefault$1(ensureObjectExports);
  35177. util$6.ensureObject = _ensureObject["default"];
  35178. var _stripComments = _interopRequireDefault$1(stripCommentsExports);
  35179. util$6.stripComments = _stripComments["default"];
  35180. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35181. (function (module, exports) {
  35182. exports.__esModule = true;
  35183. exports["default"] = void 0;
  35184. var _util = util$6;
  35185. 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); } }
  35186. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35187. var cloneNode = function cloneNode(obj, parent) {
  35188. if (typeof obj !== 'object' || obj === null) {
  35189. return obj;
  35190. }
  35191. var cloned = new obj.constructor();
  35192. for (var i in obj) {
  35193. if (!obj.hasOwnProperty(i)) {
  35194. continue;
  35195. }
  35196. var value = obj[i];
  35197. var type = typeof value;
  35198. if (i === 'parent' && type === 'object') {
  35199. if (parent) {
  35200. cloned[i] = parent;
  35201. }
  35202. } else if (value instanceof Array) {
  35203. cloned[i] = value.map(function (j) {
  35204. return cloneNode(j, cloned);
  35205. });
  35206. } else {
  35207. cloned[i] = cloneNode(value, cloned);
  35208. }
  35209. }
  35210. return cloned;
  35211. };
  35212. var Node = /*#__PURE__*/function () {
  35213. function Node(opts) {
  35214. if (opts === void 0) {
  35215. opts = {};
  35216. }
  35217. Object.assign(this, opts);
  35218. this.spaces = this.spaces || {};
  35219. this.spaces.before = this.spaces.before || '';
  35220. this.spaces.after = this.spaces.after || '';
  35221. }
  35222. var _proto = Node.prototype;
  35223. _proto.remove = function remove() {
  35224. if (this.parent) {
  35225. this.parent.removeChild(this);
  35226. }
  35227. this.parent = undefined;
  35228. return this;
  35229. };
  35230. _proto.replaceWith = function replaceWith() {
  35231. if (this.parent) {
  35232. for (var index in arguments) {
  35233. this.parent.insertBefore(this, arguments[index]);
  35234. }
  35235. this.remove();
  35236. }
  35237. return this;
  35238. };
  35239. _proto.next = function next() {
  35240. return this.parent.at(this.parent.index(this) + 1);
  35241. };
  35242. _proto.prev = function prev() {
  35243. return this.parent.at(this.parent.index(this) - 1);
  35244. };
  35245. _proto.clone = function clone(overrides) {
  35246. if (overrides === void 0) {
  35247. overrides = {};
  35248. }
  35249. var cloned = cloneNode(this);
  35250. for (var name in overrides) {
  35251. cloned[name] = overrides[name];
  35252. }
  35253. return cloned;
  35254. }
  35255. /**
  35256. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35257. * This allows non standard syntax to be appended to an existing property
  35258. * by specifying the escaped value. By specifying the escaped value,
  35259. * illegal characters are allowed to be directly inserted into css output.
  35260. * @param {string} name the property to set
  35261. * @param {any} value the unescaped value of the property
  35262. * @param {string} valueEscaped optional. the escaped value of the property.
  35263. */;
  35264. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  35265. if (!this.raws) {
  35266. this.raws = {};
  35267. }
  35268. var originalValue = this[name];
  35269. var originalEscaped = this.raws[name];
  35270. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  35271. if (originalEscaped || valueEscaped !== value) {
  35272. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  35273. } else {
  35274. delete this.raws[name]; // delete any escaped value that was created by the setter.
  35275. }
  35276. }
  35277. /**
  35278. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35279. * This allows the escaped value to be specified directly, allowing illegal
  35280. * characters to be directly inserted into css output.
  35281. * @param {string} name the property to set
  35282. * @param {any} value the unescaped value of the property
  35283. * @param {string} valueEscaped the escaped value of the property.
  35284. */;
  35285. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  35286. if (!this.raws) {
  35287. this.raws = {};
  35288. }
  35289. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35290. this.raws[name] = valueEscaped;
  35291. }
  35292. /**
  35293. * When you want a value to passed through to CSS directly. This method
  35294. * deletes the corresponding raw value causing the stringifier to fallback
  35295. * to the unescaped value.
  35296. * @param {string} name the property to set.
  35297. * @param {any} value The value that is both escaped and unescaped.
  35298. */;
  35299. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  35300. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35301. if (this.raws) {
  35302. delete this.raws[name];
  35303. }
  35304. }
  35305. /**
  35306. *
  35307. * @param {number} line The number (starting with 1)
  35308. * @param {number} column The column number (starting with 1)
  35309. */;
  35310. _proto.isAtPosition = function isAtPosition(line, column) {
  35311. if (this.source && this.source.start && this.source.end) {
  35312. if (this.source.start.line > line) {
  35313. return false;
  35314. }
  35315. if (this.source.end.line < line) {
  35316. return false;
  35317. }
  35318. if (this.source.start.line === line && this.source.start.column > column) {
  35319. return false;
  35320. }
  35321. if (this.source.end.line === line && this.source.end.column < column) {
  35322. return false;
  35323. }
  35324. return true;
  35325. }
  35326. return undefined;
  35327. };
  35328. _proto.stringifyProperty = function stringifyProperty(name) {
  35329. return this.raws && this.raws[name] || this[name];
  35330. };
  35331. _proto.valueToString = function valueToString() {
  35332. return String(this.stringifyProperty("value"));
  35333. };
  35334. _proto.toString = function toString() {
  35335. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  35336. };
  35337. _createClass(Node, [{
  35338. key: "rawSpaceBefore",
  35339. get: function get() {
  35340. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  35341. if (rawSpace === undefined) {
  35342. rawSpace = this.spaces && this.spaces.before;
  35343. }
  35344. return rawSpace || "";
  35345. },
  35346. set: function set(raw) {
  35347. (0, _util.ensureObject)(this, "raws", "spaces");
  35348. this.raws.spaces.before = raw;
  35349. }
  35350. }, {
  35351. key: "rawSpaceAfter",
  35352. get: function get() {
  35353. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  35354. if (rawSpace === undefined) {
  35355. rawSpace = this.spaces.after;
  35356. }
  35357. return rawSpace || "";
  35358. },
  35359. set: function set(raw) {
  35360. (0, _util.ensureObject)(this, "raws", "spaces");
  35361. this.raws.spaces.after = raw;
  35362. }
  35363. }]);
  35364. return Node;
  35365. }();
  35366. exports["default"] = Node;
  35367. module.exports = exports.default;
  35368. } (node$1, node$1.exports));
  35369. var nodeExports = node$1.exports;
  35370. var types = {};
  35371. types.__esModule = true;
  35372. 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;
  35373. var TAG = 'tag';
  35374. types.TAG = TAG;
  35375. var STRING = 'string';
  35376. types.STRING = STRING;
  35377. var SELECTOR = 'selector';
  35378. types.SELECTOR = SELECTOR;
  35379. var ROOT = 'root';
  35380. types.ROOT = ROOT;
  35381. var PSEUDO = 'pseudo';
  35382. types.PSEUDO = PSEUDO;
  35383. var NESTING = 'nesting';
  35384. types.NESTING = NESTING;
  35385. var ID = 'id';
  35386. types.ID = ID;
  35387. var COMMENT = 'comment';
  35388. types.COMMENT = COMMENT;
  35389. var COMBINATOR = 'combinator';
  35390. types.COMBINATOR = COMBINATOR;
  35391. var CLASS = 'class';
  35392. types.CLASS = CLASS;
  35393. var ATTRIBUTE = 'attribute';
  35394. types.ATTRIBUTE = ATTRIBUTE;
  35395. var UNIVERSAL = 'universal';
  35396. types.UNIVERSAL = UNIVERSAL;
  35397. (function (module, exports) {
  35398. exports.__esModule = true;
  35399. exports["default"] = void 0;
  35400. var _node = _interopRequireDefault(nodeExports);
  35401. var types$1 = _interopRequireWildcard(types);
  35402. 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); }
  35403. 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; }
  35404. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35405. 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."); }
  35406. 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); }
  35407. 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; }
  35408. 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); } }
  35409. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35410. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35411. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35412. var Container = /*#__PURE__*/function (_Node) {
  35413. _inheritsLoose(Container, _Node);
  35414. function Container(opts) {
  35415. var _this;
  35416. _this = _Node.call(this, opts) || this;
  35417. if (!_this.nodes) {
  35418. _this.nodes = [];
  35419. }
  35420. return _this;
  35421. }
  35422. var _proto = Container.prototype;
  35423. _proto.append = function append(selector) {
  35424. selector.parent = this;
  35425. this.nodes.push(selector);
  35426. return this;
  35427. };
  35428. _proto.prepend = function prepend(selector) {
  35429. selector.parent = this;
  35430. this.nodes.unshift(selector);
  35431. return this;
  35432. };
  35433. _proto.at = function at(index) {
  35434. return this.nodes[index];
  35435. };
  35436. _proto.index = function index(child) {
  35437. if (typeof child === 'number') {
  35438. return child;
  35439. }
  35440. return this.nodes.indexOf(child);
  35441. };
  35442. _proto.removeChild = function removeChild(child) {
  35443. child = this.index(child);
  35444. this.at(child).parent = undefined;
  35445. this.nodes.splice(child, 1);
  35446. var index;
  35447. for (var id in this.indexes) {
  35448. index = this.indexes[id];
  35449. if (index >= child) {
  35450. this.indexes[id] = index - 1;
  35451. }
  35452. }
  35453. return this;
  35454. };
  35455. _proto.removeAll = function removeAll() {
  35456. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  35457. var node = _step.value;
  35458. node.parent = undefined;
  35459. }
  35460. this.nodes = [];
  35461. return this;
  35462. };
  35463. _proto.empty = function empty() {
  35464. return this.removeAll();
  35465. };
  35466. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  35467. newNode.parent = this;
  35468. var oldIndex = this.index(oldNode);
  35469. this.nodes.splice(oldIndex + 1, 0, newNode);
  35470. newNode.parent = this;
  35471. var index;
  35472. for (var id in this.indexes) {
  35473. index = this.indexes[id];
  35474. if (oldIndex <= index) {
  35475. this.indexes[id] = index + 1;
  35476. }
  35477. }
  35478. return this;
  35479. };
  35480. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  35481. newNode.parent = this;
  35482. var oldIndex = this.index(oldNode);
  35483. this.nodes.splice(oldIndex, 0, newNode);
  35484. newNode.parent = this;
  35485. var index;
  35486. for (var id in this.indexes) {
  35487. index = this.indexes[id];
  35488. if (index <= oldIndex) {
  35489. this.indexes[id] = index + 1;
  35490. }
  35491. }
  35492. return this;
  35493. };
  35494. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  35495. var found = undefined;
  35496. this.each(function (node) {
  35497. if (node.atPosition) {
  35498. var foundChild = node.atPosition(line, col);
  35499. if (foundChild) {
  35500. found = foundChild;
  35501. return false;
  35502. }
  35503. } else if (node.isAtPosition(line, col)) {
  35504. found = node;
  35505. return false;
  35506. }
  35507. });
  35508. return found;
  35509. }
  35510. /**
  35511. * Return the most specific node at the line and column number given.
  35512. * The source location is based on the original parsed location, locations aren't
  35513. * updated as selector nodes are mutated.
  35514. *
  35515. * Note that this location is relative to the location of the first character
  35516. * of the selector, and not the location of the selector in the overall document
  35517. * when used in conjunction with postcss.
  35518. *
  35519. * If not found, returns undefined.
  35520. * @param {number} line The line number of the node to find. (1-based index)
  35521. * @param {number} col The column number of the node to find. (1-based index)
  35522. */;
  35523. _proto.atPosition = function atPosition(line, col) {
  35524. if (this.isAtPosition(line, col)) {
  35525. return this._findChildAtPosition(line, col) || this;
  35526. } else {
  35527. return undefined;
  35528. }
  35529. };
  35530. _proto._inferEndPosition = function _inferEndPosition() {
  35531. if (this.last && this.last.source && this.last.source.end) {
  35532. this.source = this.source || {};
  35533. this.source.end = this.source.end || {};
  35534. Object.assign(this.source.end, this.last.source.end);
  35535. }
  35536. };
  35537. _proto.each = function each(callback) {
  35538. if (!this.lastEach) {
  35539. this.lastEach = 0;
  35540. }
  35541. if (!this.indexes) {
  35542. this.indexes = {};
  35543. }
  35544. this.lastEach++;
  35545. var id = this.lastEach;
  35546. this.indexes[id] = 0;
  35547. if (!this.length) {
  35548. return undefined;
  35549. }
  35550. var index, result;
  35551. while (this.indexes[id] < this.length) {
  35552. index = this.indexes[id];
  35553. result = callback(this.at(index), index);
  35554. if (result === false) {
  35555. break;
  35556. }
  35557. this.indexes[id] += 1;
  35558. }
  35559. delete this.indexes[id];
  35560. if (result === false) {
  35561. return false;
  35562. }
  35563. };
  35564. _proto.walk = function walk(callback) {
  35565. return this.each(function (node, i) {
  35566. var result = callback(node, i);
  35567. if (result !== false && node.length) {
  35568. result = node.walk(callback);
  35569. }
  35570. if (result === false) {
  35571. return false;
  35572. }
  35573. });
  35574. };
  35575. _proto.walkAttributes = function walkAttributes(callback) {
  35576. var _this2 = this;
  35577. return this.walk(function (selector) {
  35578. if (selector.type === types$1.ATTRIBUTE) {
  35579. return callback.call(_this2, selector);
  35580. }
  35581. });
  35582. };
  35583. _proto.walkClasses = function walkClasses(callback) {
  35584. var _this3 = this;
  35585. return this.walk(function (selector) {
  35586. if (selector.type === types$1.CLASS) {
  35587. return callback.call(_this3, selector);
  35588. }
  35589. });
  35590. };
  35591. _proto.walkCombinators = function walkCombinators(callback) {
  35592. var _this4 = this;
  35593. return this.walk(function (selector) {
  35594. if (selector.type === types$1.COMBINATOR) {
  35595. return callback.call(_this4, selector);
  35596. }
  35597. });
  35598. };
  35599. _proto.walkComments = function walkComments(callback) {
  35600. var _this5 = this;
  35601. return this.walk(function (selector) {
  35602. if (selector.type === types$1.COMMENT) {
  35603. return callback.call(_this5, selector);
  35604. }
  35605. });
  35606. };
  35607. _proto.walkIds = function walkIds(callback) {
  35608. var _this6 = this;
  35609. return this.walk(function (selector) {
  35610. if (selector.type === types$1.ID) {
  35611. return callback.call(_this6, selector);
  35612. }
  35613. });
  35614. };
  35615. _proto.walkNesting = function walkNesting(callback) {
  35616. var _this7 = this;
  35617. return this.walk(function (selector) {
  35618. if (selector.type === types$1.NESTING) {
  35619. return callback.call(_this7, selector);
  35620. }
  35621. });
  35622. };
  35623. _proto.walkPseudos = function walkPseudos(callback) {
  35624. var _this8 = this;
  35625. return this.walk(function (selector) {
  35626. if (selector.type === types$1.PSEUDO) {
  35627. return callback.call(_this8, selector);
  35628. }
  35629. });
  35630. };
  35631. _proto.walkTags = function walkTags(callback) {
  35632. var _this9 = this;
  35633. return this.walk(function (selector) {
  35634. if (selector.type === types$1.TAG) {
  35635. return callback.call(_this9, selector);
  35636. }
  35637. });
  35638. };
  35639. _proto.walkUniversals = function walkUniversals(callback) {
  35640. var _this10 = this;
  35641. return this.walk(function (selector) {
  35642. if (selector.type === types$1.UNIVERSAL) {
  35643. return callback.call(_this10, selector);
  35644. }
  35645. });
  35646. };
  35647. _proto.split = function split(callback) {
  35648. var _this11 = this;
  35649. var current = [];
  35650. return this.reduce(function (memo, node, index) {
  35651. var split = callback.call(_this11, node);
  35652. current.push(node);
  35653. if (split) {
  35654. memo.push(current);
  35655. current = [];
  35656. } else if (index === _this11.length - 1) {
  35657. memo.push(current);
  35658. }
  35659. return memo;
  35660. }, []);
  35661. };
  35662. _proto.map = function map(callback) {
  35663. return this.nodes.map(callback);
  35664. };
  35665. _proto.reduce = function reduce(callback, memo) {
  35666. return this.nodes.reduce(callback, memo);
  35667. };
  35668. _proto.every = function every(callback) {
  35669. return this.nodes.every(callback);
  35670. };
  35671. _proto.some = function some(callback) {
  35672. return this.nodes.some(callback);
  35673. };
  35674. _proto.filter = function filter(callback) {
  35675. return this.nodes.filter(callback);
  35676. };
  35677. _proto.sort = function sort(callback) {
  35678. return this.nodes.sort(callback);
  35679. };
  35680. _proto.toString = function toString() {
  35681. return this.map(String).join('');
  35682. };
  35683. _createClass(Container, [{
  35684. key: "first",
  35685. get: function get() {
  35686. return this.at(0);
  35687. }
  35688. }, {
  35689. key: "last",
  35690. get: function get() {
  35691. return this.at(this.length - 1);
  35692. }
  35693. }, {
  35694. key: "length",
  35695. get: function get() {
  35696. return this.nodes.length;
  35697. }
  35698. }]);
  35699. return Container;
  35700. }(_node["default"]);
  35701. exports["default"] = Container;
  35702. module.exports = exports.default;
  35703. } (container, container.exports));
  35704. var containerExports = container.exports;
  35705. (function (module, exports) {
  35706. exports.__esModule = true;
  35707. exports["default"] = void 0;
  35708. var _container = _interopRequireDefault(containerExports);
  35709. var _types = types;
  35710. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35711. 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); } }
  35712. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35713. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35714. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35715. var Root = /*#__PURE__*/function (_Container) {
  35716. _inheritsLoose(Root, _Container);
  35717. function Root(opts) {
  35718. var _this;
  35719. _this = _Container.call(this, opts) || this;
  35720. _this.type = _types.ROOT;
  35721. return _this;
  35722. }
  35723. var _proto = Root.prototype;
  35724. _proto.toString = function toString() {
  35725. var str = this.reduce(function (memo, selector) {
  35726. memo.push(String(selector));
  35727. return memo;
  35728. }, []).join(',');
  35729. return this.trailingComma ? str + ',' : str;
  35730. };
  35731. _proto.error = function error(message, options) {
  35732. if (this._error) {
  35733. return this._error(message, options);
  35734. } else {
  35735. return new Error(message);
  35736. }
  35737. };
  35738. _createClass(Root, [{
  35739. key: "errorGenerator",
  35740. set: function set(handler) {
  35741. this._error = handler;
  35742. }
  35743. }]);
  35744. return Root;
  35745. }(_container["default"]);
  35746. exports["default"] = Root;
  35747. module.exports = exports.default;
  35748. } (root$1, root$1.exports));
  35749. var rootExports = root$1.exports;
  35750. var selector$1 = {exports: {}};
  35751. (function (module, exports) {
  35752. exports.__esModule = true;
  35753. exports["default"] = void 0;
  35754. var _container = _interopRequireDefault(containerExports);
  35755. var _types = types;
  35756. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35757. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35758. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35759. var Selector = /*#__PURE__*/function (_Container) {
  35760. _inheritsLoose(Selector, _Container);
  35761. function Selector(opts) {
  35762. var _this;
  35763. _this = _Container.call(this, opts) || this;
  35764. _this.type = _types.SELECTOR;
  35765. return _this;
  35766. }
  35767. return Selector;
  35768. }(_container["default"]);
  35769. exports["default"] = Selector;
  35770. module.exports = exports.default;
  35771. } (selector$1, selector$1.exports));
  35772. var selectorExports = selector$1.exports;
  35773. var className$1 = {exports: {}};
  35774. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  35775. var object = {};
  35776. var hasOwnProperty = object.hasOwnProperty;
  35777. var merge$2 = function merge(options, defaults) {
  35778. if (!options) {
  35779. return defaults;
  35780. }
  35781. var result = {};
  35782. for (var key in defaults) {
  35783. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  35784. // only recognized option names are used.
  35785. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  35786. }
  35787. return result;
  35788. };
  35789. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  35790. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  35791. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  35792. // https://mathiasbynens.be/notes/css-escapes#css
  35793. var cssesc = function cssesc(string, options) {
  35794. options = merge$2(options, cssesc.options);
  35795. if (options.quotes != 'single' && options.quotes != 'double') {
  35796. options.quotes = 'single';
  35797. }
  35798. var quote = options.quotes == 'double' ? '"' : '\'';
  35799. var isIdentifier = options.isIdentifier;
  35800. var firstChar = string.charAt(0);
  35801. var output = '';
  35802. var counter = 0;
  35803. var length = string.length;
  35804. while (counter < length) {
  35805. var character = string.charAt(counter++);
  35806. var codePoint = character.charCodeAt();
  35807. var value = void 0;
  35808. // If it’s not a printable ASCII character…
  35809. if (codePoint < 0x20 || codePoint > 0x7E) {
  35810. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  35811. // It’s a high surrogate, and there is a next character.
  35812. var extra = string.charCodeAt(counter++);
  35813. if ((extra & 0xFC00) == 0xDC00) {
  35814. // next character is low surrogate
  35815. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  35816. } else {
  35817. // It’s an unmatched surrogate; only append this code unit, in case
  35818. // the next code unit is the high surrogate of a surrogate pair.
  35819. counter--;
  35820. }
  35821. }
  35822. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35823. } else {
  35824. if (options.escapeEverything) {
  35825. if (regexAnySingleEscape.test(character)) {
  35826. value = '\\' + character;
  35827. } else {
  35828. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35829. }
  35830. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  35831. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35832. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  35833. value = '\\' + character;
  35834. } else {
  35835. value = character;
  35836. }
  35837. }
  35838. output += value;
  35839. }
  35840. if (isIdentifier) {
  35841. if (/^-[-\d]/.test(output)) {
  35842. output = '\\-' + output.slice(1);
  35843. } else if (/\d/.test(firstChar)) {
  35844. output = '\\3' + firstChar + ' ' + output.slice(1);
  35845. }
  35846. }
  35847. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  35848. // since they’re redundant. Note that this is only possible if the escape
  35849. // sequence isn’t preceded by an odd number of backslashes.
  35850. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  35851. if ($1 && $1.length % 2) {
  35852. // It’s not safe to remove the space, so don’t.
  35853. return $0;
  35854. }
  35855. // Strip the space.
  35856. return ($1 || '') + $2;
  35857. });
  35858. if (!isIdentifier && options.wrap) {
  35859. return quote + output + quote;
  35860. }
  35861. return output;
  35862. };
  35863. // Expose default options (so they can be overridden globally).
  35864. cssesc.options = {
  35865. 'escapeEverything': false,
  35866. 'isIdentifier': false,
  35867. 'quotes': 'single',
  35868. 'wrap': false
  35869. };
  35870. cssesc.version = '3.0.0';
  35871. var cssesc_1 = cssesc;
  35872. (function (module, exports) {
  35873. exports.__esModule = true;
  35874. exports["default"] = void 0;
  35875. var _cssesc = _interopRequireDefault(cssesc_1);
  35876. var _util = util$6;
  35877. var _node = _interopRequireDefault(nodeExports);
  35878. var _types = types;
  35879. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35880. 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); } }
  35881. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35882. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35883. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35884. var ClassName = /*#__PURE__*/function (_Node) {
  35885. _inheritsLoose(ClassName, _Node);
  35886. function ClassName(opts) {
  35887. var _this;
  35888. _this = _Node.call(this, opts) || this;
  35889. _this.type = _types.CLASS;
  35890. _this._constructed = true;
  35891. return _this;
  35892. }
  35893. var _proto = ClassName.prototype;
  35894. _proto.valueToString = function valueToString() {
  35895. return '.' + _Node.prototype.valueToString.call(this);
  35896. };
  35897. _createClass(ClassName, [{
  35898. key: "value",
  35899. get: function get() {
  35900. return this._value;
  35901. },
  35902. set: function set(v) {
  35903. if (this._constructed) {
  35904. var escaped = (0, _cssesc["default"])(v, {
  35905. isIdentifier: true
  35906. });
  35907. if (escaped !== v) {
  35908. (0, _util.ensureObject)(this, "raws");
  35909. this.raws.value = escaped;
  35910. } else if (this.raws) {
  35911. delete this.raws.value;
  35912. }
  35913. }
  35914. this._value = v;
  35915. }
  35916. }]);
  35917. return ClassName;
  35918. }(_node["default"]);
  35919. exports["default"] = ClassName;
  35920. module.exports = exports.default;
  35921. } (className$1, className$1.exports));
  35922. var classNameExports = className$1.exports;
  35923. var comment$2 = {exports: {}};
  35924. (function (module, exports) {
  35925. exports.__esModule = true;
  35926. exports["default"] = void 0;
  35927. var _node = _interopRequireDefault(nodeExports);
  35928. var _types = types;
  35929. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35930. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35931. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35932. var Comment = /*#__PURE__*/function (_Node) {
  35933. _inheritsLoose(Comment, _Node);
  35934. function Comment(opts) {
  35935. var _this;
  35936. _this = _Node.call(this, opts) || this;
  35937. _this.type = _types.COMMENT;
  35938. return _this;
  35939. }
  35940. return Comment;
  35941. }(_node["default"]);
  35942. exports["default"] = Comment;
  35943. module.exports = exports.default;
  35944. } (comment$2, comment$2.exports));
  35945. var commentExports = comment$2.exports;
  35946. var id$1 = {exports: {}};
  35947. (function (module, exports) {
  35948. exports.__esModule = true;
  35949. exports["default"] = void 0;
  35950. var _node = _interopRequireDefault(nodeExports);
  35951. var _types = types;
  35952. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35953. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35954. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35955. var ID = /*#__PURE__*/function (_Node) {
  35956. _inheritsLoose(ID, _Node);
  35957. function ID(opts) {
  35958. var _this;
  35959. _this = _Node.call(this, opts) || this;
  35960. _this.type = _types.ID;
  35961. return _this;
  35962. }
  35963. var _proto = ID.prototype;
  35964. _proto.valueToString = function valueToString() {
  35965. return '#' + _Node.prototype.valueToString.call(this);
  35966. };
  35967. return ID;
  35968. }(_node["default"]);
  35969. exports["default"] = ID;
  35970. module.exports = exports.default;
  35971. } (id$1, id$1.exports));
  35972. var idExports = id$1.exports;
  35973. var tag$1 = {exports: {}};
  35974. var namespace = {exports: {}};
  35975. (function (module, exports) {
  35976. exports.__esModule = true;
  35977. exports["default"] = void 0;
  35978. var _cssesc = _interopRequireDefault(cssesc_1);
  35979. var _util = util$6;
  35980. var _node = _interopRequireDefault(nodeExports);
  35981. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35982. 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); } }
  35983. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35984. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35985. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35986. var Namespace = /*#__PURE__*/function (_Node) {
  35987. _inheritsLoose(Namespace, _Node);
  35988. function Namespace() {
  35989. return _Node.apply(this, arguments) || this;
  35990. }
  35991. var _proto = Namespace.prototype;
  35992. _proto.qualifiedName = function qualifiedName(value) {
  35993. if (this.namespace) {
  35994. return this.namespaceString + "|" + value;
  35995. } else {
  35996. return value;
  35997. }
  35998. };
  35999. _proto.valueToString = function valueToString() {
  36000. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  36001. };
  36002. _createClass(Namespace, [{
  36003. key: "namespace",
  36004. get: function get() {
  36005. return this._namespace;
  36006. },
  36007. set: function set(namespace) {
  36008. if (namespace === true || namespace === "*" || namespace === "&") {
  36009. this._namespace = namespace;
  36010. if (this.raws) {
  36011. delete this.raws.namespace;
  36012. }
  36013. return;
  36014. }
  36015. var escaped = (0, _cssesc["default"])(namespace, {
  36016. isIdentifier: true
  36017. });
  36018. this._namespace = namespace;
  36019. if (escaped !== namespace) {
  36020. (0, _util.ensureObject)(this, "raws");
  36021. this.raws.namespace = escaped;
  36022. } else if (this.raws) {
  36023. delete this.raws.namespace;
  36024. }
  36025. }
  36026. }, {
  36027. key: "ns",
  36028. get: function get() {
  36029. return this._namespace;
  36030. },
  36031. set: function set(namespace) {
  36032. this.namespace = namespace;
  36033. }
  36034. }, {
  36035. key: "namespaceString",
  36036. get: function get() {
  36037. if (this.namespace) {
  36038. var ns = this.stringifyProperty("namespace");
  36039. if (ns === true) {
  36040. return '';
  36041. } else {
  36042. return ns;
  36043. }
  36044. } else {
  36045. return '';
  36046. }
  36047. }
  36048. }]);
  36049. return Namespace;
  36050. }(_node["default"]);
  36051. exports["default"] = Namespace;
  36052. module.exports = exports.default;
  36053. } (namespace, namespace.exports));
  36054. var namespaceExports = namespace.exports;
  36055. (function (module, exports) {
  36056. exports.__esModule = true;
  36057. exports["default"] = void 0;
  36058. var _namespace = _interopRequireDefault(namespaceExports);
  36059. var _types = types;
  36060. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36061. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36062. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36063. var Tag = /*#__PURE__*/function (_Namespace) {
  36064. _inheritsLoose(Tag, _Namespace);
  36065. function Tag(opts) {
  36066. var _this;
  36067. _this = _Namespace.call(this, opts) || this;
  36068. _this.type = _types.TAG;
  36069. return _this;
  36070. }
  36071. return Tag;
  36072. }(_namespace["default"]);
  36073. exports["default"] = Tag;
  36074. module.exports = exports.default;
  36075. } (tag$1, tag$1.exports));
  36076. var tagExports = tag$1.exports;
  36077. var string$1 = {exports: {}};
  36078. (function (module, exports) {
  36079. exports.__esModule = true;
  36080. exports["default"] = void 0;
  36081. var _node = _interopRequireDefault(nodeExports);
  36082. var _types = types;
  36083. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36084. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36085. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36086. var String = /*#__PURE__*/function (_Node) {
  36087. _inheritsLoose(String, _Node);
  36088. function String(opts) {
  36089. var _this;
  36090. _this = _Node.call(this, opts) || this;
  36091. _this.type = _types.STRING;
  36092. return _this;
  36093. }
  36094. return String;
  36095. }(_node["default"]);
  36096. exports["default"] = String;
  36097. module.exports = exports.default;
  36098. } (string$1, string$1.exports));
  36099. var stringExports = string$1.exports;
  36100. var pseudo$1 = {exports: {}};
  36101. (function (module, exports) {
  36102. exports.__esModule = true;
  36103. exports["default"] = void 0;
  36104. var _container = _interopRequireDefault(containerExports);
  36105. var _types = types;
  36106. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36107. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36108. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36109. var Pseudo = /*#__PURE__*/function (_Container) {
  36110. _inheritsLoose(Pseudo, _Container);
  36111. function Pseudo(opts) {
  36112. var _this;
  36113. _this = _Container.call(this, opts) || this;
  36114. _this.type = _types.PSEUDO;
  36115. return _this;
  36116. }
  36117. var _proto = Pseudo.prototype;
  36118. _proto.toString = function toString() {
  36119. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  36120. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  36121. };
  36122. return Pseudo;
  36123. }(_container["default"]);
  36124. exports["default"] = Pseudo;
  36125. module.exports = exports.default;
  36126. } (pseudo$1, pseudo$1.exports));
  36127. var pseudoExports = pseudo$1.exports;
  36128. var attribute$1 = {};
  36129. /**
  36130. * For Node.js, simply re-export the core `util.deprecate` function.
  36131. */
  36132. var node = require$$0$1.deprecate;
  36133. (function (exports) {
  36134. exports.__esModule = true;
  36135. exports["default"] = void 0;
  36136. exports.unescapeValue = unescapeValue;
  36137. var _cssesc = _interopRequireDefault(cssesc_1);
  36138. var _unesc = _interopRequireDefault(unescExports);
  36139. var _namespace = _interopRequireDefault(namespaceExports);
  36140. var _types = types;
  36141. var _CSSESC_QUOTE_OPTIONS;
  36142. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36143. 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); } }
  36144. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36145. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36146. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36147. var deprecate = node;
  36148. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  36149. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  36150. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  36151. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  36152. function unescapeValue(value) {
  36153. var deprecatedUsage = false;
  36154. var quoteMark = null;
  36155. var unescaped = value;
  36156. var m = unescaped.match(WRAPPED_IN_QUOTES);
  36157. if (m) {
  36158. quoteMark = m[1];
  36159. unescaped = m[2];
  36160. }
  36161. unescaped = (0, _unesc["default"])(unescaped);
  36162. if (unescaped !== value) {
  36163. deprecatedUsage = true;
  36164. }
  36165. return {
  36166. deprecatedUsage: deprecatedUsage,
  36167. unescaped: unescaped,
  36168. quoteMark: quoteMark
  36169. };
  36170. }
  36171. function handleDeprecatedContructorOpts(opts) {
  36172. if (opts.quoteMark !== undefined) {
  36173. return opts;
  36174. }
  36175. if (opts.value === undefined) {
  36176. return opts;
  36177. }
  36178. warnOfDeprecatedConstructor();
  36179. var _unescapeValue = unescapeValue(opts.value),
  36180. quoteMark = _unescapeValue.quoteMark,
  36181. unescaped = _unescapeValue.unescaped;
  36182. if (!opts.raws) {
  36183. opts.raws = {};
  36184. }
  36185. if (opts.raws.value === undefined) {
  36186. opts.raws.value = opts.value;
  36187. }
  36188. opts.value = unescaped;
  36189. opts.quoteMark = quoteMark;
  36190. return opts;
  36191. }
  36192. var Attribute = /*#__PURE__*/function (_Namespace) {
  36193. _inheritsLoose(Attribute, _Namespace);
  36194. function Attribute(opts) {
  36195. var _this;
  36196. if (opts === void 0) {
  36197. opts = {};
  36198. }
  36199. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  36200. _this.type = _types.ATTRIBUTE;
  36201. _this.raws = _this.raws || {};
  36202. Object.defineProperty(_this.raws, 'unquoted', {
  36203. get: deprecate(function () {
  36204. return _this.value;
  36205. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  36206. set: deprecate(function () {
  36207. return _this.value;
  36208. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  36209. });
  36210. _this._constructed = true;
  36211. return _this;
  36212. }
  36213. /**
  36214. * Returns the Attribute's value quoted such that it would be legal to use
  36215. * in the value of a css file. The original value's quotation setting
  36216. * used for stringification is left unchanged. See `setValue(value, options)`
  36217. * if you want to control the quote settings of a new value for the attribute.
  36218. *
  36219. * You can also change the quotation used for the current value by setting quoteMark.
  36220. *
  36221. * Options:
  36222. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  36223. * option is not set, the original value for quoteMark will be used. If
  36224. * indeterminate, a double quote is used. The legal values are:
  36225. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  36226. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  36227. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  36228. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  36229. * over the quoteMark option value.
  36230. * * smart {boolean} - if true, will select a quote mark based on the value
  36231. * and the other options specified here. See the `smartQuoteMark()`
  36232. * method.
  36233. **/
  36234. var _proto = Attribute.prototype;
  36235. _proto.getQuotedValue = function getQuotedValue(options) {
  36236. if (options === void 0) {
  36237. options = {};
  36238. }
  36239. var quoteMark = this._determineQuoteMark(options);
  36240. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  36241. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  36242. return escaped;
  36243. };
  36244. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  36245. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  36246. }
  36247. /**
  36248. * Set the unescaped value with the specified quotation options. The value
  36249. * provided must not include any wrapping quote marks -- those quotes will
  36250. * be interpreted as part of the value and escaped accordingly.
  36251. */;
  36252. _proto.setValue = function setValue(value, options) {
  36253. if (options === void 0) {
  36254. options = {};
  36255. }
  36256. this._value = value;
  36257. this._quoteMark = this._determineQuoteMark(options);
  36258. this._syncRawValue();
  36259. }
  36260. /**
  36261. * Intelligently select a quoteMark value based on the value's contents. If
  36262. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  36263. * mark will be picked that minimizes the number of escapes.
  36264. *
  36265. * If there's no clear winner, the quote mark from these options is used,
  36266. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  36267. * true). If the quoteMark is unspecified, a double quote is used.
  36268. *
  36269. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  36270. * from the quoteValue method.
  36271. */;
  36272. _proto.smartQuoteMark = function smartQuoteMark(options) {
  36273. var v = this.value;
  36274. var numSingleQuotes = v.replace(/[^']/g, '').length;
  36275. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  36276. if (numSingleQuotes + numDoubleQuotes === 0) {
  36277. var escaped = (0, _cssesc["default"])(v, {
  36278. isIdentifier: true
  36279. });
  36280. if (escaped === v) {
  36281. return Attribute.NO_QUOTE;
  36282. } else {
  36283. var pref = this.preferredQuoteMark(options);
  36284. if (pref === Attribute.NO_QUOTE) {
  36285. // pick a quote mark that isn't none and see if it's smaller
  36286. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  36287. var opts = CSSESC_QUOTE_OPTIONS[quote];
  36288. var quoteValue = (0, _cssesc["default"])(v, opts);
  36289. if (quoteValue.length < escaped.length) {
  36290. return quote;
  36291. }
  36292. }
  36293. return pref;
  36294. }
  36295. } else if (numDoubleQuotes === numSingleQuotes) {
  36296. return this.preferredQuoteMark(options);
  36297. } else if (numDoubleQuotes < numSingleQuotes) {
  36298. return Attribute.DOUBLE_QUOTE;
  36299. } else {
  36300. return Attribute.SINGLE_QUOTE;
  36301. }
  36302. }
  36303. /**
  36304. * Selects the preferred quote mark based on the options and the current quote mark value.
  36305. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  36306. * instead.
  36307. */;
  36308. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  36309. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  36310. if (quoteMark === undefined) {
  36311. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  36312. }
  36313. if (quoteMark === undefined) {
  36314. quoteMark = Attribute.DOUBLE_QUOTE;
  36315. }
  36316. return quoteMark;
  36317. };
  36318. _proto._syncRawValue = function _syncRawValue() {
  36319. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  36320. if (rawValue === this._value) {
  36321. if (this.raws) {
  36322. delete this.raws.value;
  36323. }
  36324. } else {
  36325. this.raws.value = rawValue;
  36326. }
  36327. };
  36328. _proto._handleEscapes = function _handleEscapes(prop, value) {
  36329. if (this._constructed) {
  36330. var escaped = (0, _cssesc["default"])(value, {
  36331. isIdentifier: true
  36332. });
  36333. if (escaped !== value) {
  36334. this.raws[prop] = escaped;
  36335. } else {
  36336. delete this.raws[prop];
  36337. }
  36338. }
  36339. };
  36340. _proto._spacesFor = function _spacesFor(name) {
  36341. var attrSpaces = {
  36342. before: '',
  36343. after: ''
  36344. };
  36345. var spaces = this.spaces[name] || {};
  36346. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  36347. return Object.assign(attrSpaces, spaces, rawSpaces);
  36348. };
  36349. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  36350. if (spaceName === void 0) {
  36351. spaceName = name;
  36352. }
  36353. if (concat === void 0) {
  36354. concat = defaultAttrConcat;
  36355. }
  36356. var attrSpaces = this._spacesFor(spaceName);
  36357. return concat(this.stringifyProperty(name), attrSpaces);
  36358. }
  36359. /**
  36360. * returns the offset of the attribute part specified relative to the
  36361. * start of the node of the output string.
  36362. *
  36363. * * "ns" - alias for "namespace"
  36364. * * "namespace" - the namespace if it exists.
  36365. * * "attribute" - the attribute name
  36366. * * "attributeNS" - the start of the attribute or its namespace
  36367. * * "operator" - the match operator of the attribute
  36368. * * "value" - The value (string or identifier)
  36369. * * "insensitive" - the case insensitivity flag;
  36370. * @param part One of the possible values inside an attribute.
  36371. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  36372. */;
  36373. _proto.offsetOf = function offsetOf(name) {
  36374. var count = 1;
  36375. var attributeSpaces = this._spacesFor("attribute");
  36376. count += attributeSpaces.before.length;
  36377. if (name === "namespace" || name === "ns") {
  36378. return this.namespace ? count : -1;
  36379. }
  36380. if (name === "attributeNS") {
  36381. return count;
  36382. }
  36383. count += this.namespaceString.length;
  36384. if (this.namespace) {
  36385. count += 1;
  36386. }
  36387. if (name === "attribute") {
  36388. return count;
  36389. }
  36390. count += this.stringifyProperty("attribute").length;
  36391. count += attributeSpaces.after.length;
  36392. var operatorSpaces = this._spacesFor("operator");
  36393. count += operatorSpaces.before.length;
  36394. var operator = this.stringifyProperty("operator");
  36395. if (name === "operator") {
  36396. return operator ? count : -1;
  36397. }
  36398. count += operator.length;
  36399. count += operatorSpaces.after.length;
  36400. var valueSpaces = this._spacesFor("value");
  36401. count += valueSpaces.before.length;
  36402. var value = this.stringifyProperty("value");
  36403. if (name === "value") {
  36404. return value ? count : -1;
  36405. }
  36406. count += value.length;
  36407. count += valueSpaces.after.length;
  36408. var insensitiveSpaces = this._spacesFor("insensitive");
  36409. count += insensitiveSpaces.before.length;
  36410. if (name === "insensitive") {
  36411. return this.insensitive ? count : -1;
  36412. }
  36413. return -1;
  36414. };
  36415. _proto.toString = function toString() {
  36416. var _this2 = this;
  36417. var selector = [this.rawSpaceBefore, '['];
  36418. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  36419. if (this.operator && (this.value || this.value === '')) {
  36420. selector.push(this._stringFor('operator'));
  36421. selector.push(this._stringFor('value'));
  36422. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  36423. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  36424. attrSpaces.before = " ";
  36425. }
  36426. return defaultAttrConcat(attrValue, attrSpaces);
  36427. }));
  36428. }
  36429. selector.push(']');
  36430. selector.push(this.rawSpaceAfter);
  36431. return selector.join('');
  36432. };
  36433. _createClass(Attribute, [{
  36434. key: "quoted",
  36435. get: function get() {
  36436. var qm = this.quoteMark;
  36437. return qm === "'" || qm === '"';
  36438. },
  36439. set: function set(value) {
  36440. warnOfDeprecatedQuotedAssignment();
  36441. }
  36442. /**
  36443. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  36444. * returns `null` if the value is not quoted.
  36445. * returns `undefined` if the quotation state is unknown (this can happen when
  36446. * the attribute is constructed without specifying a quote mark.)
  36447. */
  36448. }, {
  36449. key: "quoteMark",
  36450. get: function get() {
  36451. return this._quoteMark;
  36452. }
  36453. /**
  36454. * Set the quote mark to be used by this attribute's value.
  36455. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  36456. * value is updated accordingly.
  36457. *
  36458. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  36459. */,
  36460. set: function set(quoteMark) {
  36461. if (!this._constructed) {
  36462. this._quoteMark = quoteMark;
  36463. return;
  36464. }
  36465. if (this._quoteMark !== quoteMark) {
  36466. this._quoteMark = quoteMark;
  36467. this._syncRawValue();
  36468. }
  36469. }
  36470. }, {
  36471. key: "qualifiedAttribute",
  36472. get: function get() {
  36473. return this.qualifiedName(this.raws.attribute || this.attribute);
  36474. }
  36475. }, {
  36476. key: "insensitiveFlag",
  36477. get: function get() {
  36478. return this.insensitive ? 'i' : '';
  36479. }
  36480. }, {
  36481. key: "value",
  36482. get: function get() {
  36483. return this._value;
  36484. },
  36485. set:
  36486. /**
  36487. * Before 3.0, the value had to be set to an escaped value including any wrapped
  36488. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  36489. * is unescaped during parsing and any quote marks are removed.
  36490. *
  36491. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  36492. * a deprecation warning is raised when the new value contains any characters that would
  36493. * require escaping (including if it contains wrapped quotes).
  36494. *
  36495. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  36496. * how the new value is quoted.
  36497. */
  36498. function set(v) {
  36499. if (this._constructed) {
  36500. var _unescapeValue2 = unescapeValue(v),
  36501. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  36502. unescaped = _unescapeValue2.unescaped,
  36503. quoteMark = _unescapeValue2.quoteMark;
  36504. if (deprecatedUsage) {
  36505. warnOfDeprecatedValueAssignment();
  36506. }
  36507. if (unescaped === this._value && quoteMark === this._quoteMark) {
  36508. return;
  36509. }
  36510. this._value = unescaped;
  36511. this._quoteMark = quoteMark;
  36512. this._syncRawValue();
  36513. } else {
  36514. this._value = v;
  36515. }
  36516. }
  36517. }, {
  36518. key: "insensitive",
  36519. get: function get() {
  36520. return this._insensitive;
  36521. }
  36522. /**
  36523. * Set the case insensitive flag.
  36524. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  36525. * of the attribute is updated accordingly.
  36526. *
  36527. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  36528. */,
  36529. set: function set(insensitive) {
  36530. if (!insensitive) {
  36531. this._insensitive = false;
  36532. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  36533. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  36534. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  36535. this.raws.insensitiveFlag = undefined;
  36536. }
  36537. }
  36538. this._insensitive = insensitive;
  36539. }
  36540. }, {
  36541. key: "attribute",
  36542. get: function get() {
  36543. return this._attribute;
  36544. },
  36545. set: function set(name) {
  36546. this._handleEscapes("attribute", name);
  36547. this._attribute = name;
  36548. }
  36549. }]);
  36550. return Attribute;
  36551. }(_namespace["default"]);
  36552. exports["default"] = Attribute;
  36553. Attribute.NO_QUOTE = null;
  36554. Attribute.SINGLE_QUOTE = "'";
  36555. Attribute.DOUBLE_QUOTE = '"';
  36556. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  36557. "'": {
  36558. quotes: 'single',
  36559. wrap: true
  36560. },
  36561. '"': {
  36562. quotes: 'double',
  36563. wrap: true
  36564. }
  36565. }, _CSSESC_QUOTE_OPTIONS[null] = {
  36566. isIdentifier: true
  36567. }, _CSSESC_QUOTE_OPTIONS);
  36568. function defaultAttrConcat(attrValue, attrSpaces) {
  36569. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  36570. }
  36571. } (attribute$1));
  36572. var universal$1 = {exports: {}};
  36573. (function (module, exports) {
  36574. exports.__esModule = true;
  36575. exports["default"] = void 0;
  36576. var _namespace = _interopRequireDefault(namespaceExports);
  36577. var _types = types;
  36578. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36579. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36580. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36581. var Universal = /*#__PURE__*/function (_Namespace) {
  36582. _inheritsLoose(Universal, _Namespace);
  36583. function Universal(opts) {
  36584. var _this;
  36585. _this = _Namespace.call(this, opts) || this;
  36586. _this.type = _types.UNIVERSAL;
  36587. _this.value = '*';
  36588. return _this;
  36589. }
  36590. return Universal;
  36591. }(_namespace["default"]);
  36592. exports["default"] = Universal;
  36593. module.exports = exports.default;
  36594. } (universal$1, universal$1.exports));
  36595. var universalExports = universal$1.exports;
  36596. var combinator$2 = {exports: {}};
  36597. (function (module, exports) {
  36598. exports.__esModule = true;
  36599. exports["default"] = void 0;
  36600. var _node = _interopRequireDefault(nodeExports);
  36601. var _types = types;
  36602. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36603. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36604. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36605. var Combinator = /*#__PURE__*/function (_Node) {
  36606. _inheritsLoose(Combinator, _Node);
  36607. function Combinator(opts) {
  36608. var _this;
  36609. _this = _Node.call(this, opts) || this;
  36610. _this.type = _types.COMBINATOR;
  36611. return _this;
  36612. }
  36613. return Combinator;
  36614. }(_node["default"]);
  36615. exports["default"] = Combinator;
  36616. module.exports = exports.default;
  36617. } (combinator$2, combinator$2.exports));
  36618. var combinatorExports = combinator$2.exports;
  36619. var nesting$1 = {exports: {}};
  36620. (function (module, exports) {
  36621. exports.__esModule = true;
  36622. exports["default"] = void 0;
  36623. var _node = _interopRequireDefault(nodeExports);
  36624. var _types = types;
  36625. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36626. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36627. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36628. var Nesting = /*#__PURE__*/function (_Node) {
  36629. _inheritsLoose(Nesting, _Node);
  36630. function Nesting(opts) {
  36631. var _this;
  36632. _this = _Node.call(this, opts) || this;
  36633. _this.type = _types.NESTING;
  36634. _this.value = '&';
  36635. return _this;
  36636. }
  36637. return Nesting;
  36638. }(_node["default"]);
  36639. exports["default"] = Nesting;
  36640. module.exports = exports.default;
  36641. } (nesting$1, nesting$1.exports));
  36642. var nestingExports = nesting$1.exports;
  36643. var sortAscending = {exports: {}};
  36644. (function (module, exports) {
  36645. exports.__esModule = true;
  36646. exports["default"] = sortAscending;
  36647. function sortAscending(list) {
  36648. return list.sort(function (a, b) {
  36649. return a - b;
  36650. });
  36651. }
  36652. module.exports = exports.default;
  36653. } (sortAscending, sortAscending.exports));
  36654. var sortAscendingExports = sortAscending.exports;
  36655. var tokenize = {};
  36656. var tokenTypes = {};
  36657. tokenTypes.__esModule = true;
  36658. 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;
  36659. var ampersand = 38; // `&`.charCodeAt(0);
  36660. tokenTypes.ampersand = ampersand;
  36661. var asterisk = 42; // `*`.charCodeAt(0);
  36662. tokenTypes.asterisk = asterisk;
  36663. var at = 64; // `@`.charCodeAt(0);
  36664. tokenTypes.at = at;
  36665. var comma$1 = 44; // `,`.charCodeAt(0);
  36666. tokenTypes.comma = comma$1;
  36667. var colon = 58; // `:`.charCodeAt(0);
  36668. tokenTypes.colon = colon;
  36669. var semicolon$1 = 59; // `;`.charCodeAt(0);
  36670. tokenTypes.semicolon = semicolon$1;
  36671. var openParenthesis = 40; // `(`.charCodeAt(0);
  36672. tokenTypes.openParenthesis = openParenthesis;
  36673. var closeParenthesis = 41; // `)`.charCodeAt(0);
  36674. tokenTypes.closeParenthesis = closeParenthesis;
  36675. var openSquare = 91; // `[`.charCodeAt(0);
  36676. tokenTypes.openSquare = openSquare;
  36677. var closeSquare = 93; // `]`.charCodeAt(0);
  36678. tokenTypes.closeSquare = closeSquare;
  36679. var dollar = 36; // `$`.charCodeAt(0);
  36680. tokenTypes.dollar = dollar;
  36681. var tilde = 126; // `~`.charCodeAt(0);
  36682. tokenTypes.tilde = tilde;
  36683. var caret = 94; // `^`.charCodeAt(0);
  36684. tokenTypes.caret = caret;
  36685. var plus = 43; // `+`.charCodeAt(0);
  36686. tokenTypes.plus = plus;
  36687. var equals = 61; // `=`.charCodeAt(0);
  36688. tokenTypes.equals = equals;
  36689. var pipe = 124; // `|`.charCodeAt(0);
  36690. tokenTypes.pipe = pipe;
  36691. var greaterThan = 62; // `>`.charCodeAt(0);
  36692. tokenTypes.greaterThan = greaterThan;
  36693. var space = 32; // ` `.charCodeAt(0);
  36694. tokenTypes.space = space;
  36695. var singleQuote = 39; // `'`.charCodeAt(0);
  36696. tokenTypes.singleQuote = singleQuote;
  36697. var doubleQuote = 34; // `"`.charCodeAt(0);
  36698. tokenTypes.doubleQuote = doubleQuote;
  36699. var slash = 47; // `/`.charCodeAt(0);
  36700. tokenTypes.slash = slash;
  36701. var bang = 33; // `!`.charCodeAt(0);
  36702. tokenTypes.bang = bang;
  36703. var backslash = 92; // '\\'.charCodeAt(0);
  36704. tokenTypes.backslash = backslash;
  36705. var cr = 13; // '\r'.charCodeAt(0);
  36706. tokenTypes.cr = cr;
  36707. var feed = 12; // '\f'.charCodeAt(0);
  36708. tokenTypes.feed = feed;
  36709. var newline = 10; // '\n'.charCodeAt(0);
  36710. tokenTypes.newline = newline;
  36711. var tab = 9; // '\t'.charCodeAt(0);
  36712. // Expose aliases primarily for readability.
  36713. tokenTypes.tab = tab;
  36714. var str = singleQuote;
  36715. // No good single character representation!
  36716. tokenTypes.str = str;
  36717. var comment$1 = -1;
  36718. tokenTypes.comment = comment$1;
  36719. var word = -2;
  36720. tokenTypes.word = word;
  36721. var combinator$1 = -3;
  36722. tokenTypes.combinator = combinator$1;
  36723. (function (exports) {
  36724. exports.__esModule = true;
  36725. exports.FIELDS = void 0;
  36726. exports["default"] = tokenize;
  36727. var t = _interopRequireWildcard(tokenTypes);
  36728. var _unescapable, _wordDelimiters;
  36729. 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); }
  36730. 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; }
  36731. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  36732. 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);
  36733. var hex = {};
  36734. var hexChars = "0123456789abcdefABCDEF";
  36735. for (var i = 0; i < hexChars.length; i++) {
  36736. hex[hexChars.charCodeAt(i)] = true;
  36737. }
  36738. /**
  36739. * Returns the last index of the bar css word
  36740. * @param {string} css The string in which the word begins
  36741. * @param {number} start The index into the string where word's first letter occurs
  36742. */
  36743. function consumeWord(css, start) {
  36744. var next = start;
  36745. var code;
  36746. do {
  36747. code = css.charCodeAt(next);
  36748. if (wordDelimiters[code]) {
  36749. return next - 1;
  36750. } else if (code === t.backslash) {
  36751. next = consumeEscape(css, next) + 1;
  36752. } else {
  36753. // All other characters are part of the word
  36754. next++;
  36755. }
  36756. } while (next < css.length);
  36757. return next - 1;
  36758. }
  36759. /**
  36760. * Returns the last index of the escape sequence
  36761. * @param {string} css The string in which the sequence begins
  36762. * @param {number} start The index into the string where escape character (`\`) occurs.
  36763. */
  36764. function consumeEscape(css, start) {
  36765. var next = start;
  36766. var code = css.charCodeAt(next + 1);
  36767. if (unescapable[code]) ; else if (hex[code]) {
  36768. var hexDigits = 0;
  36769. // consume up to 6 hex chars
  36770. do {
  36771. next++;
  36772. hexDigits++;
  36773. code = css.charCodeAt(next + 1);
  36774. } while (hex[code] && hexDigits < 6);
  36775. // if fewer than 6 hex chars, a trailing space ends the escape
  36776. if (hexDigits < 6 && code === t.space) {
  36777. next++;
  36778. }
  36779. } else {
  36780. // the next char is part of the current word
  36781. next++;
  36782. }
  36783. return next;
  36784. }
  36785. var FIELDS = {
  36786. TYPE: 0,
  36787. START_LINE: 1,
  36788. START_COL: 2,
  36789. END_LINE: 3,
  36790. END_COL: 4,
  36791. START_POS: 5,
  36792. END_POS: 6
  36793. };
  36794. exports.FIELDS = FIELDS;
  36795. function tokenize(input) {
  36796. var tokens = [];
  36797. var css = input.css.valueOf();
  36798. var _css = css,
  36799. length = _css.length;
  36800. var offset = -1;
  36801. var line = 1;
  36802. var start = 0;
  36803. var end = 0;
  36804. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  36805. function unclosed(what, fix) {
  36806. if (input.safe) {
  36807. // fyi: this is never set to true.
  36808. css += fix;
  36809. next = css.length - 1;
  36810. } else {
  36811. throw input.error('Unclosed ' + what, line, start - offset, start);
  36812. }
  36813. }
  36814. while (start < length) {
  36815. code = css.charCodeAt(start);
  36816. if (code === t.newline) {
  36817. offset = start;
  36818. line += 1;
  36819. }
  36820. switch (code) {
  36821. case t.space:
  36822. case t.tab:
  36823. case t.newline:
  36824. case t.cr:
  36825. case t.feed:
  36826. next = start;
  36827. do {
  36828. next += 1;
  36829. code = css.charCodeAt(next);
  36830. if (code === t.newline) {
  36831. offset = next;
  36832. line += 1;
  36833. }
  36834. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  36835. tokenType = t.space;
  36836. endLine = line;
  36837. endColumn = next - offset - 1;
  36838. end = next;
  36839. break;
  36840. case t.plus:
  36841. case t.greaterThan:
  36842. case t.tilde:
  36843. case t.pipe:
  36844. next = start;
  36845. do {
  36846. next += 1;
  36847. code = css.charCodeAt(next);
  36848. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  36849. tokenType = t.combinator;
  36850. endLine = line;
  36851. endColumn = start - offset;
  36852. end = next;
  36853. break;
  36854. // Consume these characters as single tokens.
  36855. case t.asterisk:
  36856. case t.ampersand:
  36857. case t.bang:
  36858. case t.comma:
  36859. case t.equals:
  36860. case t.dollar:
  36861. case t.caret:
  36862. case t.openSquare:
  36863. case t.closeSquare:
  36864. case t.colon:
  36865. case t.semicolon:
  36866. case t.openParenthesis:
  36867. case t.closeParenthesis:
  36868. next = start;
  36869. tokenType = code;
  36870. endLine = line;
  36871. endColumn = start - offset;
  36872. end = next + 1;
  36873. break;
  36874. case t.singleQuote:
  36875. case t.doubleQuote:
  36876. quote = code === t.singleQuote ? "'" : '"';
  36877. next = start;
  36878. do {
  36879. escaped = false;
  36880. next = css.indexOf(quote, next + 1);
  36881. if (next === -1) {
  36882. unclosed('quote', quote);
  36883. }
  36884. escapePos = next;
  36885. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  36886. escapePos -= 1;
  36887. escaped = !escaped;
  36888. }
  36889. } while (escaped);
  36890. tokenType = t.str;
  36891. endLine = line;
  36892. endColumn = start - offset;
  36893. end = next + 1;
  36894. break;
  36895. default:
  36896. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  36897. next = css.indexOf('*/', start + 2) + 1;
  36898. if (next === 0) {
  36899. unclosed('comment', '*/');
  36900. }
  36901. content = css.slice(start, next + 1);
  36902. lines = content.split('\n');
  36903. last = lines.length - 1;
  36904. if (last > 0) {
  36905. nextLine = line + last;
  36906. nextOffset = next - lines[last].length;
  36907. } else {
  36908. nextLine = line;
  36909. nextOffset = offset;
  36910. }
  36911. tokenType = t.comment;
  36912. line = nextLine;
  36913. endLine = nextLine;
  36914. endColumn = next - nextOffset;
  36915. } else if (code === t.slash) {
  36916. next = start;
  36917. tokenType = code;
  36918. endLine = line;
  36919. endColumn = start - offset;
  36920. end = next + 1;
  36921. } else {
  36922. next = consumeWord(css, start);
  36923. tokenType = t.word;
  36924. endLine = line;
  36925. endColumn = next - offset;
  36926. }
  36927. end = next + 1;
  36928. break;
  36929. }
  36930. // Ensure that the token structure remains consistent
  36931. tokens.push([tokenType,
  36932. // [0] Token type
  36933. line,
  36934. // [1] Starting line
  36935. start - offset,
  36936. // [2] Starting column
  36937. endLine,
  36938. // [3] Ending line
  36939. endColumn,
  36940. // [4] Ending column
  36941. start,
  36942. // [5] Start position / Source index
  36943. end // [6] End position
  36944. ]);
  36945. // Reset offset for the next token
  36946. if (nextOffset) {
  36947. offset = nextOffset;
  36948. nextOffset = null;
  36949. }
  36950. start = end;
  36951. }
  36952. return tokens;
  36953. }
  36954. } (tokenize));
  36955. (function (module, exports) {
  36956. exports.__esModule = true;
  36957. exports["default"] = void 0;
  36958. var _root = _interopRequireDefault(rootExports);
  36959. var _selector = _interopRequireDefault(selectorExports);
  36960. var _className = _interopRequireDefault(classNameExports);
  36961. var _comment = _interopRequireDefault(commentExports);
  36962. var _id = _interopRequireDefault(idExports);
  36963. var _tag = _interopRequireDefault(tagExports);
  36964. var _string = _interopRequireDefault(stringExports);
  36965. var _pseudo = _interopRequireDefault(pseudoExports);
  36966. var _attribute = _interopRequireWildcard(attribute$1);
  36967. var _universal = _interopRequireDefault(universalExports);
  36968. var _combinator = _interopRequireDefault(combinatorExports);
  36969. var _nesting = _interopRequireDefault(nestingExports);
  36970. var _sortAscending = _interopRequireDefault(sortAscendingExports);
  36971. var _tokenize = _interopRequireWildcard(tokenize);
  36972. var tokens = _interopRequireWildcard(tokenTypes);
  36973. var types$1 = _interopRequireWildcard(types);
  36974. var _util = util$6;
  36975. var _WHITESPACE_TOKENS, _Object$assign;
  36976. 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); }
  36977. 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; }
  36978. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36979. 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); } }
  36980. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36981. 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);
  36982. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  36983. function tokenStart(token) {
  36984. return {
  36985. line: token[_tokenize.FIELDS.START_LINE],
  36986. column: token[_tokenize.FIELDS.START_COL]
  36987. };
  36988. }
  36989. function tokenEnd(token) {
  36990. return {
  36991. line: token[_tokenize.FIELDS.END_LINE],
  36992. column: token[_tokenize.FIELDS.END_COL]
  36993. };
  36994. }
  36995. function getSource(startLine, startColumn, endLine, endColumn) {
  36996. return {
  36997. start: {
  36998. line: startLine,
  36999. column: startColumn
  37000. },
  37001. end: {
  37002. line: endLine,
  37003. column: endColumn
  37004. }
  37005. };
  37006. }
  37007. function getTokenSource(token) {
  37008. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  37009. }
  37010. function getTokenSourceSpan(startToken, endToken) {
  37011. if (!startToken) {
  37012. return undefined;
  37013. }
  37014. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  37015. }
  37016. function unescapeProp(node, prop) {
  37017. var value = node[prop];
  37018. if (typeof value !== "string") {
  37019. return;
  37020. }
  37021. if (value.indexOf("\\") !== -1) {
  37022. (0, _util.ensureObject)(node, 'raws');
  37023. node[prop] = (0, _util.unesc)(value);
  37024. if (node.raws[prop] === undefined) {
  37025. node.raws[prop] = value;
  37026. }
  37027. }
  37028. return node;
  37029. }
  37030. function indexesOf(array, item) {
  37031. var i = -1;
  37032. var indexes = [];
  37033. while ((i = array.indexOf(item, i + 1)) !== -1) {
  37034. indexes.push(i);
  37035. }
  37036. return indexes;
  37037. }
  37038. function uniqs() {
  37039. var list = Array.prototype.concat.apply([], arguments);
  37040. return list.filter(function (item, i) {
  37041. return i === list.indexOf(item);
  37042. });
  37043. }
  37044. var Parser = /*#__PURE__*/function () {
  37045. function Parser(rule, options) {
  37046. if (options === void 0) {
  37047. options = {};
  37048. }
  37049. this.rule = rule;
  37050. this.options = Object.assign({
  37051. lossy: false,
  37052. safe: false
  37053. }, options);
  37054. this.position = 0;
  37055. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  37056. this.tokens = (0, _tokenize["default"])({
  37057. css: this.css,
  37058. error: this._errorGenerator(),
  37059. safe: this.options.safe
  37060. });
  37061. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  37062. this.root = new _root["default"]({
  37063. source: rootSource
  37064. });
  37065. this.root.errorGenerator = this._errorGenerator();
  37066. var selector = new _selector["default"]({
  37067. source: {
  37068. start: {
  37069. line: 1,
  37070. column: 1
  37071. }
  37072. }
  37073. });
  37074. this.root.append(selector);
  37075. this.current = selector;
  37076. this.loop();
  37077. }
  37078. var _proto = Parser.prototype;
  37079. _proto._errorGenerator = function _errorGenerator() {
  37080. var _this = this;
  37081. return function (message, errorOptions) {
  37082. if (typeof _this.rule === 'string') {
  37083. return new Error(message);
  37084. }
  37085. return _this.rule.error(message, errorOptions);
  37086. };
  37087. };
  37088. _proto.attribute = function attribute() {
  37089. var attr = [];
  37090. var startingToken = this.currToken;
  37091. this.position++;
  37092. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37093. attr.push(this.currToken);
  37094. this.position++;
  37095. }
  37096. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37097. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37098. }
  37099. var len = attr.length;
  37100. var node = {
  37101. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  37102. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37103. };
  37104. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  37105. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  37106. }
  37107. var pos = 0;
  37108. var spaceBefore = '';
  37109. var commentBefore = '';
  37110. var lastAdded = null;
  37111. var spaceAfterMeaningfulToken = false;
  37112. while (pos < len) {
  37113. var token = attr[pos];
  37114. var content = this.content(token);
  37115. var next = attr[pos + 1];
  37116. switch (token[_tokenize.FIELDS.TYPE]) {
  37117. case tokens.space:
  37118. // if (
  37119. // len === 1 ||
  37120. // pos === 0 && this.content(next) === '|'
  37121. // ) {
  37122. // return this.expected('attribute', token[TOKEN.START_POS], content);
  37123. // }
  37124. spaceAfterMeaningfulToken = true;
  37125. if (this.options.lossy) {
  37126. break;
  37127. }
  37128. if (lastAdded) {
  37129. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  37130. var prevContent = node.spaces[lastAdded].after || '';
  37131. node.spaces[lastAdded].after = prevContent + content;
  37132. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  37133. if (existingComment) {
  37134. node.raws.spaces[lastAdded].after = existingComment + content;
  37135. }
  37136. } else {
  37137. spaceBefore = spaceBefore + content;
  37138. commentBefore = commentBefore + content;
  37139. }
  37140. break;
  37141. case tokens.asterisk:
  37142. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37143. node.operator = content;
  37144. lastAdded = 'operator';
  37145. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  37146. if (spaceBefore) {
  37147. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37148. node.spaces.attribute.before = spaceBefore;
  37149. spaceBefore = '';
  37150. }
  37151. if (commentBefore) {
  37152. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37153. node.raws.spaces.attribute.before = spaceBefore;
  37154. commentBefore = '';
  37155. }
  37156. node.namespace = (node.namespace || "") + content;
  37157. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  37158. if (rawValue) {
  37159. node.raws.namespace += content;
  37160. }
  37161. lastAdded = 'namespace';
  37162. }
  37163. spaceAfterMeaningfulToken = false;
  37164. break;
  37165. case tokens.dollar:
  37166. if (lastAdded === "value") {
  37167. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  37168. node.value += "$";
  37169. if (oldRawValue) {
  37170. node.raws.value = oldRawValue + "$";
  37171. }
  37172. break;
  37173. }
  37174. // Falls through
  37175. case tokens.caret:
  37176. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37177. node.operator = content;
  37178. lastAdded = 'operator';
  37179. }
  37180. spaceAfterMeaningfulToken = false;
  37181. break;
  37182. case tokens.combinator:
  37183. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37184. node.operator = content;
  37185. lastAdded = 'operator';
  37186. }
  37187. if (content !== '|') {
  37188. spaceAfterMeaningfulToken = false;
  37189. break;
  37190. }
  37191. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37192. node.operator = content;
  37193. lastAdded = 'operator';
  37194. } else if (!node.namespace && !node.attribute) {
  37195. node.namespace = true;
  37196. }
  37197. spaceAfterMeaningfulToken = false;
  37198. break;
  37199. case tokens.word:
  37200. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  37201. // this look-ahead probably fails with comment nodes involved.
  37202. !node.operator && !node.namespace) {
  37203. node.namespace = content;
  37204. lastAdded = 'namespace';
  37205. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  37206. if (spaceBefore) {
  37207. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37208. node.spaces.attribute.before = spaceBefore;
  37209. spaceBefore = '';
  37210. }
  37211. if (commentBefore) {
  37212. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37213. node.raws.spaces.attribute.before = commentBefore;
  37214. commentBefore = '';
  37215. }
  37216. node.attribute = (node.attribute || "") + content;
  37217. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  37218. if (_rawValue) {
  37219. node.raws.attribute += content;
  37220. }
  37221. lastAdded = 'attribute';
  37222. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  37223. var _unescaped = (0, _util.unesc)(content);
  37224. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  37225. var oldValue = node.value || '';
  37226. node.value = oldValue + _unescaped;
  37227. node.quoteMark = null;
  37228. if (_unescaped !== content || _oldRawValue) {
  37229. (0, _util.ensureObject)(node, 'raws');
  37230. node.raws.value = (_oldRawValue || oldValue) + content;
  37231. }
  37232. lastAdded = 'value';
  37233. } else {
  37234. var insensitive = content === 'i' || content === "I";
  37235. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  37236. node.insensitive = insensitive;
  37237. if (!insensitive || content === "I") {
  37238. (0, _util.ensureObject)(node, 'raws');
  37239. node.raws.insensitiveFlag = content;
  37240. }
  37241. lastAdded = 'insensitive';
  37242. if (spaceBefore) {
  37243. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  37244. node.spaces.insensitive.before = spaceBefore;
  37245. spaceBefore = '';
  37246. }
  37247. if (commentBefore) {
  37248. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  37249. node.raws.spaces.insensitive.before = commentBefore;
  37250. commentBefore = '';
  37251. }
  37252. } else if (node.value || node.value === '') {
  37253. lastAdded = 'value';
  37254. node.value += content;
  37255. if (node.raws.value) {
  37256. node.raws.value += content;
  37257. }
  37258. }
  37259. }
  37260. spaceAfterMeaningfulToken = false;
  37261. break;
  37262. case tokens.str:
  37263. if (!node.attribute || !node.operator) {
  37264. return this.error("Expected an attribute followed by an operator preceding the string.", {
  37265. index: token[_tokenize.FIELDS.START_POS]
  37266. });
  37267. }
  37268. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  37269. unescaped = _unescapeValue.unescaped,
  37270. quoteMark = _unescapeValue.quoteMark;
  37271. node.value = unescaped;
  37272. node.quoteMark = quoteMark;
  37273. lastAdded = 'value';
  37274. (0, _util.ensureObject)(node, 'raws');
  37275. node.raws.value = content;
  37276. spaceAfterMeaningfulToken = false;
  37277. break;
  37278. case tokens.equals:
  37279. if (!node.attribute) {
  37280. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  37281. }
  37282. if (node.value) {
  37283. return this.error('Unexpected "=" found; an operator was already defined.', {
  37284. index: token[_tokenize.FIELDS.START_POS]
  37285. });
  37286. }
  37287. node.operator = node.operator ? node.operator + content : content;
  37288. lastAdded = 'operator';
  37289. spaceAfterMeaningfulToken = false;
  37290. break;
  37291. case tokens.comment:
  37292. if (lastAdded) {
  37293. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  37294. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  37295. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  37296. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  37297. node.raws.spaces[lastAdded].after = rawLastComment + content;
  37298. } else {
  37299. var lastValue = node[lastAdded] || '';
  37300. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  37301. (0, _util.ensureObject)(node, 'raws');
  37302. node.raws[lastAdded] = rawLastValue + content;
  37303. }
  37304. } else {
  37305. commentBefore = commentBefore + content;
  37306. }
  37307. break;
  37308. default:
  37309. return this.error("Unexpected \"" + content + "\" found.", {
  37310. index: token[_tokenize.FIELDS.START_POS]
  37311. });
  37312. }
  37313. pos++;
  37314. }
  37315. unescapeProp(node, "attribute");
  37316. unescapeProp(node, "namespace");
  37317. this.newNode(new _attribute["default"](node));
  37318. this.position++;
  37319. }
  37320. /**
  37321. * return a node containing meaningless garbage up to (but not including) the specified token position.
  37322. * if the token position is negative, all remaining tokens are consumed.
  37323. *
  37324. * This returns an array containing a single string node if all whitespace,
  37325. * otherwise an array of comment nodes with space before and after.
  37326. *
  37327. * These tokens are not added to the current selector, the caller can add them or use them to amend
  37328. * a previous node's space metadata.
  37329. *
  37330. * In lossy mode, this returns only comments.
  37331. */;
  37332. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  37333. if (stopPosition < 0) {
  37334. stopPosition = this.tokens.length;
  37335. }
  37336. var startPosition = this.position;
  37337. var nodes = [];
  37338. var space = "";
  37339. var lastComment = undefined;
  37340. do {
  37341. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  37342. if (!this.options.lossy) {
  37343. space += this.content();
  37344. }
  37345. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  37346. var spaces = {};
  37347. if (space) {
  37348. spaces.before = space;
  37349. space = "";
  37350. }
  37351. lastComment = new _comment["default"]({
  37352. value: this.content(),
  37353. source: getTokenSource(this.currToken),
  37354. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37355. spaces: spaces
  37356. });
  37357. nodes.push(lastComment);
  37358. }
  37359. } while (++this.position < stopPosition);
  37360. if (space) {
  37361. if (lastComment) {
  37362. lastComment.spaces.after = space;
  37363. } else if (!this.options.lossy) {
  37364. var firstToken = this.tokens[startPosition];
  37365. var lastToken = this.tokens[this.position - 1];
  37366. nodes.push(new _string["default"]({
  37367. value: '',
  37368. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  37369. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37370. spaces: {
  37371. before: space,
  37372. after: ''
  37373. }
  37374. }));
  37375. }
  37376. }
  37377. return nodes;
  37378. }
  37379. /**
  37380. *
  37381. * @param {*} nodes
  37382. */;
  37383. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  37384. var _this2 = this;
  37385. if (requiredSpace === void 0) {
  37386. requiredSpace = false;
  37387. }
  37388. var space = "";
  37389. var rawSpace = "";
  37390. nodes.forEach(function (n) {
  37391. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  37392. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  37393. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  37394. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  37395. });
  37396. if (rawSpace === space) {
  37397. rawSpace = undefined;
  37398. }
  37399. var result = {
  37400. space: space,
  37401. rawSpace: rawSpace
  37402. };
  37403. return result;
  37404. };
  37405. _proto.isNamedCombinator = function isNamedCombinator(position) {
  37406. if (position === void 0) {
  37407. position = this.position;
  37408. }
  37409. 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;
  37410. };
  37411. _proto.namedCombinator = function namedCombinator() {
  37412. if (this.isNamedCombinator()) {
  37413. var nameRaw = this.content(this.tokens[this.position + 1]);
  37414. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  37415. var raws = {};
  37416. if (name !== nameRaw) {
  37417. raws.value = "/" + nameRaw + "/";
  37418. }
  37419. var node = new _combinator["default"]({
  37420. value: "/" + name + "/",
  37421. 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]),
  37422. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37423. raws: raws
  37424. });
  37425. this.position = this.position + 3;
  37426. return node;
  37427. } else {
  37428. this.unexpected();
  37429. }
  37430. };
  37431. _proto.combinator = function combinator() {
  37432. var _this3 = this;
  37433. if (this.content() === '|') {
  37434. return this.namespace();
  37435. }
  37436. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  37437. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  37438. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  37439. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37440. if (nodes.length > 0) {
  37441. var last = this.current.last;
  37442. if (last) {
  37443. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  37444. space = _this$convertWhitespa.space,
  37445. rawSpace = _this$convertWhitespa.rawSpace;
  37446. if (rawSpace !== undefined) {
  37447. last.rawSpaceAfter += rawSpace;
  37448. }
  37449. last.spaces.after += space;
  37450. } else {
  37451. nodes.forEach(function (n) {
  37452. return _this3.newNode(n);
  37453. });
  37454. }
  37455. }
  37456. return;
  37457. }
  37458. var firstToken = this.currToken;
  37459. var spaceOrDescendantSelectorNodes = undefined;
  37460. if (nextSigTokenPos > this.position) {
  37461. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37462. }
  37463. var node;
  37464. if (this.isNamedCombinator()) {
  37465. node = this.namedCombinator();
  37466. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  37467. node = new _combinator["default"]({
  37468. value: this.content(),
  37469. source: getTokenSource(this.currToken),
  37470. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  37471. });
  37472. this.position++;
  37473. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  37474. this.unexpected();
  37475. }
  37476. if (node) {
  37477. if (spaceOrDescendantSelectorNodes) {
  37478. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  37479. _space = _this$convertWhitespa2.space,
  37480. _rawSpace = _this$convertWhitespa2.rawSpace;
  37481. node.spaces.before = _space;
  37482. node.rawSpaceBefore = _rawSpace;
  37483. }
  37484. } else {
  37485. // descendant combinator
  37486. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  37487. _space2 = _this$convertWhitespa3.space,
  37488. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  37489. if (!_rawSpace2) {
  37490. _rawSpace2 = _space2;
  37491. }
  37492. var spaces = {};
  37493. var raws = {
  37494. spaces: {}
  37495. };
  37496. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  37497. spaces.before = _space2.slice(0, _space2.length - 1);
  37498. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  37499. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  37500. spaces.after = _space2.slice(1);
  37501. raws.spaces.after = _rawSpace2.slice(1);
  37502. } else {
  37503. raws.value = _rawSpace2;
  37504. }
  37505. node = new _combinator["default"]({
  37506. value: ' ',
  37507. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  37508. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37509. spaces: spaces,
  37510. raws: raws
  37511. });
  37512. }
  37513. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  37514. node.spaces.after = this.optionalSpace(this.content());
  37515. this.position++;
  37516. }
  37517. return this.newNode(node);
  37518. };
  37519. _proto.comma = function comma() {
  37520. if (this.position === this.tokens.length - 1) {
  37521. this.root.trailingComma = true;
  37522. this.position++;
  37523. return;
  37524. }
  37525. this.current._inferEndPosition();
  37526. var selector = new _selector["default"]({
  37527. source: {
  37528. start: tokenStart(this.tokens[this.position + 1])
  37529. }
  37530. });
  37531. this.current.parent.append(selector);
  37532. this.current = selector;
  37533. this.position++;
  37534. };
  37535. _proto.comment = function comment() {
  37536. var current = this.currToken;
  37537. this.newNode(new _comment["default"]({
  37538. value: this.content(),
  37539. source: getTokenSource(current),
  37540. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37541. }));
  37542. this.position++;
  37543. };
  37544. _proto.error = function error(message, opts) {
  37545. throw this.root.error(message, opts);
  37546. };
  37547. _proto.missingBackslash = function missingBackslash() {
  37548. return this.error('Expected a backslash preceding the semicolon.', {
  37549. index: this.currToken[_tokenize.FIELDS.START_POS]
  37550. });
  37551. };
  37552. _proto.missingParenthesis = function missingParenthesis() {
  37553. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37554. };
  37555. _proto.missingSquareBracket = function missingSquareBracket() {
  37556. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37557. };
  37558. _proto.unexpected = function unexpected() {
  37559. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  37560. };
  37561. _proto.unexpectedPipe = function unexpectedPipe() {
  37562. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  37563. };
  37564. _proto.namespace = function namespace() {
  37565. var before = this.prevToken && this.content(this.prevToken) || true;
  37566. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37567. this.position++;
  37568. return this.word(before);
  37569. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  37570. this.position++;
  37571. return this.universal(before);
  37572. }
  37573. this.unexpectedPipe();
  37574. };
  37575. _proto.nesting = function nesting() {
  37576. if (this.nextToken) {
  37577. var nextContent = this.content(this.nextToken);
  37578. if (nextContent === "|") {
  37579. this.position++;
  37580. return;
  37581. }
  37582. }
  37583. var current = this.currToken;
  37584. this.newNode(new _nesting["default"]({
  37585. value: this.content(),
  37586. source: getTokenSource(current),
  37587. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37588. }));
  37589. this.position++;
  37590. };
  37591. _proto.parentheses = function parentheses() {
  37592. var last = this.current.last;
  37593. var unbalanced = 1;
  37594. this.position++;
  37595. if (last && last.type === types$1.PSEUDO) {
  37596. var selector = new _selector["default"]({
  37597. source: {
  37598. start: tokenStart(this.tokens[this.position - 1])
  37599. }
  37600. });
  37601. var cache = this.current;
  37602. last.append(selector);
  37603. this.current = selector;
  37604. while (this.position < this.tokens.length && unbalanced) {
  37605. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37606. unbalanced++;
  37607. }
  37608. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37609. unbalanced--;
  37610. }
  37611. if (unbalanced) {
  37612. this.parse();
  37613. } else {
  37614. this.current.source.end = tokenEnd(this.currToken);
  37615. this.current.parent.source.end = tokenEnd(this.currToken);
  37616. this.position++;
  37617. }
  37618. }
  37619. this.current = cache;
  37620. } else {
  37621. // I think this case should be an error. It's used to implement a basic parse of media queries
  37622. // but I don't think it's a good idea.
  37623. var parenStart = this.currToken;
  37624. var parenValue = "(";
  37625. var parenEnd;
  37626. while (this.position < this.tokens.length && unbalanced) {
  37627. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37628. unbalanced++;
  37629. }
  37630. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37631. unbalanced--;
  37632. }
  37633. parenEnd = this.currToken;
  37634. parenValue += this.parseParenthesisToken(this.currToken);
  37635. this.position++;
  37636. }
  37637. if (last) {
  37638. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  37639. } else {
  37640. this.newNode(new _string["default"]({
  37641. value: parenValue,
  37642. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  37643. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  37644. }));
  37645. }
  37646. }
  37647. if (unbalanced) {
  37648. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37649. }
  37650. };
  37651. _proto.pseudo = function pseudo() {
  37652. var _this4 = this;
  37653. var pseudoStr = '';
  37654. var startingToken = this.currToken;
  37655. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  37656. pseudoStr += this.content();
  37657. this.position++;
  37658. }
  37659. if (!this.currToken) {
  37660. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  37661. }
  37662. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37663. this.splitWord(false, function (first, length) {
  37664. pseudoStr += first;
  37665. _this4.newNode(new _pseudo["default"]({
  37666. value: pseudoStr,
  37667. source: getTokenSourceSpan(startingToken, _this4.currToken),
  37668. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37669. }));
  37670. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37671. _this4.error('Misplaced parenthesis.', {
  37672. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  37673. });
  37674. }
  37675. });
  37676. } else {
  37677. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  37678. }
  37679. };
  37680. _proto.space = function space() {
  37681. var content = this.content();
  37682. // Handle space before and after the selector
  37683. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  37684. return node.type === 'comment';
  37685. })) {
  37686. this.spaces = this.optionalSpace(content);
  37687. this.position++;
  37688. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37689. this.current.last.spaces.after = this.optionalSpace(content);
  37690. this.position++;
  37691. } else {
  37692. this.combinator();
  37693. }
  37694. };
  37695. _proto.string = function string() {
  37696. var current = this.currToken;
  37697. this.newNode(new _string["default"]({
  37698. value: this.content(),
  37699. source: getTokenSource(current),
  37700. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37701. }));
  37702. this.position++;
  37703. };
  37704. _proto.universal = function universal(namespace) {
  37705. var nextToken = this.nextToken;
  37706. if (nextToken && this.content(nextToken) === '|') {
  37707. this.position++;
  37708. return this.namespace();
  37709. }
  37710. var current = this.currToken;
  37711. this.newNode(new _universal["default"]({
  37712. value: this.content(),
  37713. source: getTokenSource(current),
  37714. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37715. }), namespace);
  37716. this.position++;
  37717. };
  37718. _proto.splitWord = function splitWord(namespace, firstCallback) {
  37719. var _this5 = this;
  37720. var nextToken = this.nextToken;
  37721. var word = this.content();
  37722. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  37723. this.position++;
  37724. var current = this.content();
  37725. word += current;
  37726. if (current.lastIndexOf('\\') === current.length - 1) {
  37727. var next = this.nextToken;
  37728. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  37729. word += this.requiredSpace(this.content(next));
  37730. this.position++;
  37731. }
  37732. }
  37733. nextToken = this.nextToken;
  37734. }
  37735. var hasClass = indexesOf(word, '.').filter(function (i) {
  37736. // Allow escaped dot within class name
  37737. var escapedDot = word[i - 1] === '\\';
  37738. // Allow decimal numbers percent in @keyframes
  37739. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  37740. return !escapedDot && !isKeyframesPercent;
  37741. });
  37742. var hasId = indexesOf(word, '#').filter(function (i) {
  37743. return word[i - 1] !== '\\';
  37744. });
  37745. // Eliminate Sass interpolations from the list of id indexes
  37746. var interpolations = indexesOf(word, '#{');
  37747. if (interpolations.length) {
  37748. hasId = hasId.filter(function (hashIndex) {
  37749. return !~interpolations.indexOf(hashIndex);
  37750. });
  37751. }
  37752. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  37753. indices.forEach(function (ind, i) {
  37754. var index = indices[i + 1] || word.length;
  37755. var value = word.slice(ind, index);
  37756. if (i === 0 && firstCallback) {
  37757. return firstCallback.call(_this5, value, indices.length);
  37758. }
  37759. var node;
  37760. var current = _this5.currToken;
  37761. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  37762. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  37763. if (~hasClass.indexOf(ind)) {
  37764. var classNameOpts = {
  37765. value: value.slice(1),
  37766. source: source,
  37767. sourceIndex: sourceIndex
  37768. };
  37769. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  37770. } else if (~hasId.indexOf(ind)) {
  37771. var idOpts = {
  37772. value: value.slice(1),
  37773. source: source,
  37774. sourceIndex: sourceIndex
  37775. };
  37776. node = new _id["default"](unescapeProp(idOpts, "value"));
  37777. } else {
  37778. var tagOpts = {
  37779. value: value,
  37780. source: source,
  37781. sourceIndex: sourceIndex
  37782. };
  37783. unescapeProp(tagOpts, "value");
  37784. node = new _tag["default"](tagOpts);
  37785. }
  37786. _this5.newNode(node, namespace);
  37787. // Ensure that the namespace is used only once
  37788. namespace = null;
  37789. });
  37790. this.position++;
  37791. };
  37792. _proto.word = function word(namespace) {
  37793. var nextToken = this.nextToken;
  37794. if (nextToken && this.content(nextToken) === '|') {
  37795. this.position++;
  37796. return this.namespace();
  37797. }
  37798. return this.splitWord(namespace);
  37799. };
  37800. _proto.loop = function loop() {
  37801. while (this.position < this.tokens.length) {
  37802. this.parse(true);
  37803. }
  37804. this.current._inferEndPosition();
  37805. return this.root;
  37806. };
  37807. _proto.parse = function parse(throwOnParenthesis) {
  37808. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  37809. case tokens.space:
  37810. this.space();
  37811. break;
  37812. case tokens.comment:
  37813. this.comment();
  37814. break;
  37815. case tokens.openParenthesis:
  37816. this.parentheses();
  37817. break;
  37818. case tokens.closeParenthesis:
  37819. if (throwOnParenthesis) {
  37820. this.missingParenthesis();
  37821. }
  37822. break;
  37823. case tokens.openSquare:
  37824. this.attribute();
  37825. break;
  37826. case tokens.dollar:
  37827. case tokens.caret:
  37828. case tokens.equals:
  37829. case tokens.word:
  37830. this.word();
  37831. break;
  37832. case tokens.colon:
  37833. this.pseudo();
  37834. break;
  37835. case tokens.comma:
  37836. this.comma();
  37837. break;
  37838. case tokens.asterisk:
  37839. this.universal();
  37840. break;
  37841. case tokens.ampersand:
  37842. this.nesting();
  37843. break;
  37844. case tokens.slash:
  37845. case tokens.combinator:
  37846. this.combinator();
  37847. break;
  37848. case tokens.str:
  37849. this.string();
  37850. break;
  37851. // These cases throw; no break needed.
  37852. case tokens.closeSquare:
  37853. this.missingSquareBracket();
  37854. case tokens.semicolon:
  37855. this.missingBackslash();
  37856. default:
  37857. this.unexpected();
  37858. }
  37859. }
  37860. /**
  37861. * Helpers
  37862. */;
  37863. _proto.expected = function expected(description, index, found) {
  37864. if (Array.isArray(description)) {
  37865. var last = description.pop();
  37866. description = description.join(', ') + " or " + last;
  37867. }
  37868. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  37869. if (!found) {
  37870. return this.error("Expected " + an + " " + description + ".", {
  37871. index: index
  37872. });
  37873. }
  37874. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  37875. index: index
  37876. });
  37877. };
  37878. _proto.requiredSpace = function requiredSpace(space) {
  37879. return this.options.lossy ? ' ' : space;
  37880. };
  37881. _proto.optionalSpace = function optionalSpace(space) {
  37882. return this.options.lossy ? '' : space;
  37883. };
  37884. _proto.lossySpace = function lossySpace(space, required) {
  37885. if (this.options.lossy) {
  37886. return required ? ' ' : '';
  37887. } else {
  37888. return space;
  37889. }
  37890. };
  37891. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  37892. var content = this.content(token);
  37893. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  37894. return this.requiredSpace(content);
  37895. } else {
  37896. return content;
  37897. }
  37898. };
  37899. _proto.newNode = function newNode(node, namespace) {
  37900. if (namespace) {
  37901. if (/^ +$/.test(namespace)) {
  37902. if (!this.options.lossy) {
  37903. this.spaces = (this.spaces || '') + namespace;
  37904. }
  37905. namespace = true;
  37906. }
  37907. node.namespace = namespace;
  37908. unescapeProp(node, "namespace");
  37909. }
  37910. if (this.spaces) {
  37911. node.spaces.before = this.spaces;
  37912. this.spaces = '';
  37913. }
  37914. return this.current.append(node);
  37915. };
  37916. _proto.content = function content(token) {
  37917. if (token === void 0) {
  37918. token = this.currToken;
  37919. }
  37920. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  37921. };
  37922. /**
  37923. * returns the index of the next non-whitespace, non-comment token.
  37924. * returns -1 if no meaningful token is found.
  37925. */
  37926. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  37927. if (startPosition === void 0) {
  37928. startPosition = this.position + 1;
  37929. }
  37930. var searchPosition = startPosition;
  37931. while (searchPosition < this.tokens.length) {
  37932. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  37933. searchPosition++;
  37934. continue;
  37935. } else {
  37936. return searchPosition;
  37937. }
  37938. }
  37939. return -1;
  37940. };
  37941. _createClass(Parser, [{
  37942. key: "currToken",
  37943. get: function get() {
  37944. return this.tokens[this.position];
  37945. }
  37946. }, {
  37947. key: "nextToken",
  37948. get: function get() {
  37949. return this.tokens[this.position + 1];
  37950. }
  37951. }, {
  37952. key: "prevToken",
  37953. get: function get() {
  37954. return this.tokens[this.position - 1];
  37955. }
  37956. }]);
  37957. return Parser;
  37958. }();
  37959. exports["default"] = Parser;
  37960. module.exports = exports.default;
  37961. } (parser, parser.exports));
  37962. var parserExports = parser.exports;
  37963. (function (module, exports) {
  37964. exports.__esModule = true;
  37965. exports["default"] = void 0;
  37966. var _parser = _interopRequireDefault(parserExports);
  37967. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37968. var Processor = /*#__PURE__*/function () {
  37969. function Processor(func, options) {
  37970. this.func = func || function noop() {};
  37971. this.funcRes = null;
  37972. this.options = options;
  37973. }
  37974. var _proto = Processor.prototype;
  37975. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  37976. if (options === void 0) {
  37977. options = {};
  37978. }
  37979. var merged = Object.assign({}, this.options, options);
  37980. if (merged.updateSelector === false) {
  37981. return false;
  37982. } else {
  37983. return typeof rule !== "string";
  37984. }
  37985. };
  37986. _proto._isLossy = function _isLossy(options) {
  37987. if (options === void 0) {
  37988. options = {};
  37989. }
  37990. var merged = Object.assign({}, this.options, options);
  37991. if (merged.lossless === false) {
  37992. return true;
  37993. } else {
  37994. return false;
  37995. }
  37996. };
  37997. _proto._root = function _root(rule, options) {
  37998. if (options === void 0) {
  37999. options = {};
  38000. }
  38001. var parser = new _parser["default"](rule, this._parseOptions(options));
  38002. return parser.root;
  38003. };
  38004. _proto._parseOptions = function _parseOptions(options) {
  38005. return {
  38006. lossy: this._isLossy(options)
  38007. };
  38008. };
  38009. _proto._run = function _run(rule, options) {
  38010. var _this = this;
  38011. if (options === void 0) {
  38012. options = {};
  38013. }
  38014. return new Promise(function (resolve, reject) {
  38015. try {
  38016. var root = _this._root(rule, options);
  38017. Promise.resolve(_this.func(root)).then(function (transform) {
  38018. var string = undefined;
  38019. if (_this._shouldUpdateSelector(rule, options)) {
  38020. string = root.toString();
  38021. rule.selector = string;
  38022. }
  38023. return {
  38024. transform: transform,
  38025. root: root,
  38026. string: string
  38027. };
  38028. }).then(resolve, reject);
  38029. } catch (e) {
  38030. reject(e);
  38031. return;
  38032. }
  38033. });
  38034. };
  38035. _proto._runSync = function _runSync(rule, options) {
  38036. if (options === void 0) {
  38037. options = {};
  38038. }
  38039. var root = this._root(rule, options);
  38040. var transform = this.func(root);
  38041. if (transform && typeof transform.then === "function") {
  38042. throw new Error("Selector processor returned a promise to a synchronous call.");
  38043. }
  38044. var string = undefined;
  38045. if (options.updateSelector && typeof rule !== "string") {
  38046. string = root.toString();
  38047. rule.selector = string;
  38048. }
  38049. return {
  38050. transform: transform,
  38051. root: root,
  38052. string: string
  38053. };
  38054. }
  38055. /**
  38056. * Process rule into a selector AST.
  38057. *
  38058. * @param rule {postcss.Rule | string} The css selector to be processed
  38059. * @param options The options for processing
  38060. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  38061. */;
  38062. _proto.ast = function ast(rule, options) {
  38063. return this._run(rule, options).then(function (result) {
  38064. return result.root;
  38065. });
  38066. }
  38067. /**
  38068. * Process rule into a selector AST synchronously.
  38069. *
  38070. * @param rule {postcss.Rule | string} The css selector to be processed
  38071. * @param options The options for processing
  38072. * @returns {parser.Root} The AST of the selector after processing it.
  38073. */;
  38074. _proto.astSync = function astSync(rule, options) {
  38075. return this._runSync(rule, options).root;
  38076. }
  38077. /**
  38078. * Process a selector into a transformed value asynchronously
  38079. *
  38080. * @param rule {postcss.Rule | string} The css selector to be processed
  38081. * @param options The options for processing
  38082. * @returns {Promise<any>} The value returned by the processor.
  38083. */;
  38084. _proto.transform = function transform(rule, options) {
  38085. return this._run(rule, options).then(function (result) {
  38086. return result.transform;
  38087. });
  38088. }
  38089. /**
  38090. * Process a selector into a transformed value synchronously.
  38091. *
  38092. * @param rule {postcss.Rule | string} The css selector to be processed
  38093. * @param options The options for processing
  38094. * @returns {any} The value returned by the processor.
  38095. */;
  38096. _proto.transformSync = function transformSync(rule, options) {
  38097. return this._runSync(rule, options).transform;
  38098. }
  38099. /**
  38100. * Process a selector into a new selector string asynchronously.
  38101. *
  38102. * @param rule {postcss.Rule | string} The css selector to be processed
  38103. * @param options The options for processing
  38104. * @returns {string} the selector after processing.
  38105. */;
  38106. _proto.process = function process(rule, options) {
  38107. return this._run(rule, options).then(function (result) {
  38108. return result.string || result.root.toString();
  38109. });
  38110. }
  38111. /**
  38112. * Process a selector into a new selector string synchronously.
  38113. *
  38114. * @param rule {postcss.Rule | string} The css selector to be processed
  38115. * @param options The options for processing
  38116. * @returns {string} the selector after processing.
  38117. */;
  38118. _proto.processSync = function processSync(rule, options) {
  38119. var result = this._runSync(rule, options);
  38120. return result.string || result.root.toString();
  38121. };
  38122. return Processor;
  38123. }();
  38124. exports["default"] = Processor;
  38125. module.exports = exports.default;
  38126. } (processor, processor.exports));
  38127. var processorExports = processor.exports;
  38128. var selectors = {};
  38129. var constructors = {};
  38130. constructors.__esModule = true;
  38131. 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;
  38132. var _attribute = _interopRequireDefault(attribute$1);
  38133. var _className = _interopRequireDefault(classNameExports);
  38134. var _combinator = _interopRequireDefault(combinatorExports);
  38135. var _comment = _interopRequireDefault(commentExports);
  38136. var _id = _interopRequireDefault(idExports);
  38137. var _nesting = _interopRequireDefault(nestingExports);
  38138. var _pseudo = _interopRequireDefault(pseudoExports);
  38139. var _root = _interopRequireDefault(rootExports);
  38140. var _selector = _interopRequireDefault(selectorExports);
  38141. var _string = _interopRequireDefault(stringExports);
  38142. var _tag = _interopRequireDefault(tagExports);
  38143. var _universal = _interopRequireDefault(universalExports);
  38144. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38145. var attribute = function attribute(opts) {
  38146. return new _attribute["default"](opts);
  38147. };
  38148. constructors.attribute = attribute;
  38149. var className = function className(opts) {
  38150. return new _className["default"](opts);
  38151. };
  38152. constructors.className = className;
  38153. var combinator = function combinator(opts) {
  38154. return new _combinator["default"](opts);
  38155. };
  38156. constructors.combinator = combinator;
  38157. var comment = function comment(opts) {
  38158. return new _comment["default"](opts);
  38159. };
  38160. constructors.comment = comment;
  38161. var id = function id(opts) {
  38162. return new _id["default"](opts);
  38163. };
  38164. constructors.id = id;
  38165. var nesting = function nesting(opts) {
  38166. return new _nesting["default"](opts);
  38167. };
  38168. constructors.nesting = nesting;
  38169. var pseudo = function pseudo(opts) {
  38170. return new _pseudo["default"](opts);
  38171. };
  38172. constructors.pseudo = pseudo;
  38173. var root = function root(opts) {
  38174. return new _root["default"](opts);
  38175. };
  38176. constructors.root = root;
  38177. var selector = function selector(opts) {
  38178. return new _selector["default"](opts);
  38179. };
  38180. constructors.selector = selector;
  38181. var string = function string(opts) {
  38182. return new _string["default"](opts);
  38183. };
  38184. constructors.string = string;
  38185. var tag = function tag(opts) {
  38186. return new _tag["default"](opts);
  38187. };
  38188. constructors.tag = tag;
  38189. var universal = function universal(opts) {
  38190. return new _universal["default"](opts);
  38191. };
  38192. constructors.universal = universal;
  38193. var guards = {};
  38194. guards.__esModule = true;
  38195. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  38196. guards.isContainer = isContainer;
  38197. guards.isIdentifier = void 0;
  38198. guards.isNamespace = isNamespace;
  38199. guards.isNesting = void 0;
  38200. guards.isNode = isNode;
  38201. guards.isPseudo = void 0;
  38202. guards.isPseudoClass = isPseudoClass;
  38203. guards.isPseudoElement = isPseudoElement;
  38204. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  38205. var _types = types;
  38206. var _IS_TYPE;
  38207. 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);
  38208. function isNode(node) {
  38209. return typeof node === "object" && IS_TYPE[node.type];
  38210. }
  38211. function isNodeType(type, node) {
  38212. return isNode(node) && node.type === type;
  38213. }
  38214. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  38215. guards.isAttribute = isAttribute;
  38216. var isClassName = isNodeType.bind(null, _types.CLASS);
  38217. guards.isClassName = isClassName;
  38218. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  38219. guards.isCombinator = isCombinator;
  38220. var isComment = isNodeType.bind(null, _types.COMMENT);
  38221. guards.isComment = isComment;
  38222. var isIdentifier = isNodeType.bind(null, _types.ID);
  38223. guards.isIdentifier = isIdentifier;
  38224. var isNesting = isNodeType.bind(null, _types.NESTING);
  38225. guards.isNesting = isNesting;
  38226. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  38227. guards.isPseudo = isPseudo;
  38228. var isRoot = isNodeType.bind(null, _types.ROOT);
  38229. guards.isRoot = isRoot;
  38230. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  38231. guards.isSelector = isSelector;
  38232. var isString = isNodeType.bind(null, _types.STRING);
  38233. guards.isString = isString;
  38234. var isTag = isNodeType.bind(null, _types.TAG);
  38235. guards.isTag = isTag;
  38236. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  38237. guards.isUniversal = isUniversal;
  38238. function isPseudoElement(node) {
  38239. 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");
  38240. }
  38241. function isPseudoClass(node) {
  38242. return isPseudo(node) && !isPseudoElement(node);
  38243. }
  38244. function isContainer(node) {
  38245. return !!(isNode(node) && node.walk);
  38246. }
  38247. function isNamespace(node) {
  38248. return isAttribute(node) || isTag(node);
  38249. }
  38250. (function (exports) {
  38251. exports.__esModule = true;
  38252. var _types = types;
  38253. Object.keys(_types).forEach(function (key) {
  38254. if (key === "default" || key === "__esModule") return;
  38255. if (key in exports && exports[key] === _types[key]) return;
  38256. exports[key] = _types[key];
  38257. });
  38258. var _constructors = constructors;
  38259. Object.keys(_constructors).forEach(function (key) {
  38260. if (key === "default" || key === "__esModule") return;
  38261. if (key in exports && exports[key] === _constructors[key]) return;
  38262. exports[key] = _constructors[key];
  38263. });
  38264. var _guards = guards;
  38265. Object.keys(_guards).forEach(function (key) {
  38266. if (key === "default" || key === "__esModule") return;
  38267. if (key in exports && exports[key] === _guards[key]) return;
  38268. exports[key] = _guards[key];
  38269. });
  38270. } (selectors));
  38271. (function (module, exports) {
  38272. exports.__esModule = true;
  38273. exports["default"] = void 0;
  38274. var _processor = _interopRequireDefault(processorExports);
  38275. var selectors$1 = _interopRequireWildcard(selectors);
  38276. 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); }
  38277. 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; }
  38278. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38279. var parser = function parser(processor) {
  38280. return new _processor["default"](processor);
  38281. };
  38282. Object.assign(parser, selectors$1);
  38283. delete parser.__esModule;
  38284. var _default = parser;
  38285. exports["default"] = _default;
  38286. module.exports = exports.default;
  38287. } (dist, dist.exports));
  38288. var distExports = dist.exports;
  38289. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  38290. const animationNameRE = /^(-\w+-)?animation-name$/;
  38291. const animationRE = /^(-\w+-)?animation$/;
  38292. const scopedPlugin = (id = "") => {
  38293. const keyframes = /* @__PURE__ */ Object.create(null);
  38294. const shortId = id.replace(/^data-v-/, "");
  38295. return {
  38296. postcssPlugin: "vue-sfc-scoped",
  38297. Rule(rule) {
  38298. processRule(id, rule);
  38299. },
  38300. AtRule(node) {
  38301. if (/-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  38302. keyframes[node.params] = node.params = node.params + "-" + shortId;
  38303. }
  38304. },
  38305. OnceExit(root) {
  38306. if (Object.keys(keyframes).length) {
  38307. root.walkDecls((decl) => {
  38308. if (animationNameRE.test(decl.prop)) {
  38309. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  38310. }
  38311. if (animationRE.test(decl.prop)) {
  38312. decl.value = decl.value.split(",").map((v) => {
  38313. const vals = v.trim().split(/\s+/);
  38314. const i = vals.findIndex((val) => keyframes[val]);
  38315. if (i !== -1) {
  38316. vals.splice(i, 1, keyframes[vals[i]]);
  38317. return vals.join(" ");
  38318. } else {
  38319. return v;
  38320. }
  38321. }).join(",");
  38322. }
  38323. });
  38324. }
  38325. }
  38326. };
  38327. };
  38328. const processedRules = /* @__PURE__ */ new WeakSet();
  38329. function processRule(id, rule) {
  38330. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && /-?keyframes$/.test(rule.parent.name)) {
  38331. return;
  38332. }
  38333. processedRules.add(rule);
  38334. rule.selector = selectorParser((selectorRoot) => {
  38335. selectorRoot.each((selector) => {
  38336. rewriteSelector(id, selector, selectorRoot);
  38337. });
  38338. }).processSync(rule.selector);
  38339. }
  38340. function rewriteSelector(id, selector, selectorRoot, slotted = false) {
  38341. let node = null;
  38342. let shouldInject = true;
  38343. selector.each((n) => {
  38344. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  38345. n.value = " ";
  38346. n.spaces.before = n.spaces.after = "";
  38347. warn(
  38348. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  38349. );
  38350. return false;
  38351. }
  38352. if (n.type === "pseudo") {
  38353. const { value } = n;
  38354. if (value === ":deep" || value === "::v-deep") {
  38355. if (n.nodes.length) {
  38356. let last = n;
  38357. n.nodes[0].each((ss) => {
  38358. selector.insertAfter(last, ss);
  38359. last = ss;
  38360. });
  38361. const prev = selector.at(selector.index(n) - 1);
  38362. if (!prev || !isSpaceCombinator(prev)) {
  38363. selector.insertAfter(
  38364. n,
  38365. selectorParser.combinator({
  38366. value: " "
  38367. })
  38368. );
  38369. }
  38370. selector.removeChild(n);
  38371. } else {
  38372. warn(
  38373. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  38374. );
  38375. const prev = selector.at(selector.index(n) - 1);
  38376. if (prev && isSpaceCombinator(prev)) {
  38377. selector.removeChild(prev);
  38378. }
  38379. selector.removeChild(n);
  38380. }
  38381. return false;
  38382. }
  38383. if (value === ":slotted" || value === "::v-slotted") {
  38384. rewriteSelector(
  38385. id,
  38386. n.nodes[0],
  38387. selectorRoot,
  38388. true
  38389. /* slotted */
  38390. );
  38391. let last = n;
  38392. n.nodes[0].each((ss) => {
  38393. selector.insertAfter(last, ss);
  38394. last = ss;
  38395. });
  38396. selector.removeChild(n);
  38397. shouldInject = false;
  38398. return false;
  38399. }
  38400. if (value === ":global" || value === "::v-global") {
  38401. selectorRoot.insertAfter(selector, n.nodes[0]);
  38402. selectorRoot.removeChild(selector);
  38403. return false;
  38404. }
  38405. }
  38406. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
  38407. node = n;
  38408. }
  38409. });
  38410. if (node) {
  38411. const { type, value } = node;
  38412. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  38413. node.nodes.forEach(
  38414. (value2) => rewriteSelector(id, value2, selectorRoot, slotted)
  38415. );
  38416. shouldInject = false;
  38417. }
  38418. }
  38419. if (node) {
  38420. node.spaces.after = "";
  38421. } else {
  38422. selector.first.spaces.before = "";
  38423. }
  38424. if (shouldInject) {
  38425. const idToAdd = slotted ? id + "-s" : id;
  38426. selector.insertAfter(
  38427. // If node is null it means we need to inject [id] at the start
  38428. // insertAfter can handle `null` here
  38429. node,
  38430. selectorParser.attribute({
  38431. attribute: idToAdd,
  38432. value: idToAdd,
  38433. raws: {},
  38434. quoteMark: `"`
  38435. })
  38436. );
  38437. }
  38438. }
  38439. function isSpaceCombinator(node) {
  38440. return node.type === "combinator" && /^\s+$/.test(node.value);
  38441. }
  38442. scopedPlugin.postcss = true;
  38443. var sourceMap$1 = {};
  38444. var sourceMapGenerator = {};
  38445. var base64Vlq = {};
  38446. var base64$1 = {};
  38447. /* -*- Mode: js; js-indent-level: 2; -*- */
  38448. /*
  38449. * Copyright 2011 Mozilla Foundation and contributors
  38450. * Licensed under the New BSD license. See LICENSE or:
  38451. * http://opensource.org/licenses/BSD-3-Clause
  38452. */
  38453. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  38454. /**
  38455. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  38456. */
  38457. base64$1.encode = function (number) {
  38458. if (0 <= number && number < intToCharMap.length) {
  38459. return intToCharMap[number];
  38460. }
  38461. throw new TypeError("Must be between 0 and 63: " + number);
  38462. };
  38463. /**
  38464. * Decode a single base 64 character code digit to an integer. Returns -1 on
  38465. * failure.
  38466. */
  38467. base64$1.decode = function (charCode) {
  38468. var bigA = 65; // 'A'
  38469. var bigZ = 90; // 'Z'
  38470. var littleA = 97; // 'a'
  38471. var littleZ = 122; // 'z'
  38472. var zero = 48; // '0'
  38473. var nine = 57; // '9'
  38474. var plus = 43; // '+'
  38475. var slash = 47; // '/'
  38476. var littleOffset = 26;
  38477. var numberOffset = 52;
  38478. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  38479. if (bigA <= charCode && charCode <= bigZ) {
  38480. return (charCode - bigA);
  38481. }
  38482. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  38483. if (littleA <= charCode && charCode <= littleZ) {
  38484. return (charCode - littleA + littleOffset);
  38485. }
  38486. // 52 - 61: 0123456789
  38487. if (zero <= charCode && charCode <= nine) {
  38488. return (charCode - zero + numberOffset);
  38489. }
  38490. // 62: +
  38491. if (charCode == plus) {
  38492. return 62;
  38493. }
  38494. // 63: /
  38495. if (charCode == slash) {
  38496. return 63;
  38497. }
  38498. // Invalid base64 digit.
  38499. return -1;
  38500. };
  38501. /* -*- Mode: js; js-indent-level: 2; -*- */
  38502. /*
  38503. * Copyright 2011 Mozilla Foundation and contributors
  38504. * Licensed under the New BSD license. See LICENSE or:
  38505. * http://opensource.org/licenses/BSD-3-Clause
  38506. *
  38507. * Based on the Base 64 VLQ implementation in Closure Compiler:
  38508. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  38509. *
  38510. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  38511. * Redistribution and use in source and binary forms, with or without
  38512. * modification, are permitted provided that the following conditions are
  38513. * met:
  38514. *
  38515. * * Redistributions of source code must retain the above copyright
  38516. * notice, this list of conditions and the following disclaimer.
  38517. * * Redistributions in binary form must reproduce the above
  38518. * copyright notice, this list of conditions and the following
  38519. * disclaimer in the documentation and/or other materials provided
  38520. * with the distribution.
  38521. * * Neither the name of Google Inc. nor the names of its
  38522. * contributors may be used to endorse or promote products derived
  38523. * from this software without specific prior written permission.
  38524. *
  38525. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  38526. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38527. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  38528. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38529. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  38530. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  38531. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  38532. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  38533. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38534. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38535. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38536. */
  38537. var base64 = base64$1;
  38538. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  38539. // length quantities we use in the source map spec, the first bit is the sign,
  38540. // the next four bits are the actual value, and the 6th bit is the
  38541. // continuation bit. The continuation bit tells us whether there are more
  38542. // digits in this value following this digit.
  38543. //
  38544. // Continuation
  38545. // | Sign
  38546. // | |
  38547. // V V
  38548. // 101011
  38549. var VLQ_BASE_SHIFT = 5;
  38550. // binary: 100000
  38551. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  38552. // binary: 011111
  38553. var VLQ_BASE_MASK = VLQ_BASE - 1;
  38554. // binary: 100000
  38555. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  38556. /**
  38557. * Converts from a two-complement value to a value where the sign bit is
  38558. * placed in the least significant bit. For example, as decimals:
  38559. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  38560. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  38561. */
  38562. function toVLQSigned(aValue) {
  38563. return aValue < 0
  38564. ? ((-aValue) << 1) + 1
  38565. : (aValue << 1) + 0;
  38566. }
  38567. /**
  38568. * Converts to a two-complement value from a value where the sign bit is
  38569. * placed in the least significant bit. For example, as decimals:
  38570. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  38571. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  38572. */
  38573. function fromVLQSigned(aValue) {
  38574. var isNegative = (aValue & 1) === 1;
  38575. var shifted = aValue >> 1;
  38576. return isNegative
  38577. ? -shifted
  38578. : shifted;
  38579. }
  38580. /**
  38581. * Returns the base 64 VLQ encoded value.
  38582. */
  38583. base64Vlq.encode = function base64VLQ_encode(aValue) {
  38584. var encoded = "";
  38585. var digit;
  38586. var vlq = toVLQSigned(aValue);
  38587. do {
  38588. digit = vlq & VLQ_BASE_MASK;
  38589. vlq >>>= VLQ_BASE_SHIFT;
  38590. if (vlq > 0) {
  38591. // There are still more digits in this value, so we must make sure the
  38592. // continuation bit is marked.
  38593. digit |= VLQ_CONTINUATION_BIT;
  38594. }
  38595. encoded += base64.encode(digit);
  38596. } while (vlq > 0);
  38597. return encoded;
  38598. };
  38599. /**
  38600. * Decodes the next base 64 VLQ value from the given string and returns the
  38601. * value and the rest of the string via the out parameter.
  38602. */
  38603. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  38604. var strLen = aStr.length;
  38605. var result = 0;
  38606. var shift = 0;
  38607. var continuation, digit;
  38608. do {
  38609. if (aIndex >= strLen) {
  38610. throw new Error("Expected more digits in base 64 VLQ value.");
  38611. }
  38612. digit = base64.decode(aStr.charCodeAt(aIndex++));
  38613. if (digit === -1) {
  38614. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  38615. }
  38616. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  38617. digit &= VLQ_BASE_MASK;
  38618. result = result + (digit << shift);
  38619. shift += VLQ_BASE_SHIFT;
  38620. } while (continuation);
  38621. aOutParam.value = fromVLQSigned(result);
  38622. aOutParam.rest = aIndex;
  38623. };
  38624. var util$5 = {};
  38625. /* -*- Mode: js; js-indent-level: 2; -*- */
  38626. (function (exports) {
  38627. /*
  38628. * Copyright 2011 Mozilla Foundation and contributors
  38629. * Licensed under the New BSD license. See LICENSE or:
  38630. * http://opensource.org/licenses/BSD-3-Clause
  38631. */
  38632. /**
  38633. * This is a helper function for getting values from parameter/options
  38634. * objects.
  38635. *
  38636. * @param args The object we are extracting values from
  38637. * @param name The name of the property we are getting.
  38638. * @param defaultValue An optional value to return if the property is missing
  38639. * from the object. If this is not specified and the property is missing, an
  38640. * error will be thrown.
  38641. */
  38642. function getArg(aArgs, aName, aDefaultValue) {
  38643. if (aName in aArgs) {
  38644. return aArgs[aName];
  38645. } else if (arguments.length === 3) {
  38646. return aDefaultValue;
  38647. } else {
  38648. throw new Error('"' + aName + '" is a required argument.');
  38649. }
  38650. }
  38651. exports.getArg = getArg;
  38652. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  38653. var dataUrlRegexp = /^data:.+\,.+$/;
  38654. function urlParse(aUrl) {
  38655. var match = aUrl.match(urlRegexp);
  38656. if (!match) {
  38657. return null;
  38658. }
  38659. return {
  38660. scheme: match[1],
  38661. auth: match[2],
  38662. host: match[3],
  38663. port: match[4],
  38664. path: match[5]
  38665. };
  38666. }
  38667. exports.urlParse = urlParse;
  38668. function urlGenerate(aParsedUrl) {
  38669. var url = '';
  38670. if (aParsedUrl.scheme) {
  38671. url += aParsedUrl.scheme + ':';
  38672. }
  38673. url += '//';
  38674. if (aParsedUrl.auth) {
  38675. url += aParsedUrl.auth + '@';
  38676. }
  38677. if (aParsedUrl.host) {
  38678. url += aParsedUrl.host;
  38679. }
  38680. if (aParsedUrl.port) {
  38681. url += ":" + aParsedUrl.port;
  38682. }
  38683. if (aParsedUrl.path) {
  38684. url += aParsedUrl.path;
  38685. }
  38686. return url;
  38687. }
  38688. exports.urlGenerate = urlGenerate;
  38689. /**
  38690. * Normalizes a path, or the path portion of a URL:
  38691. *
  38692. * - Replaces consecutive slashes with one slash.
  38693. * - Removes unnecessary '.' parts.
  38694. * - Removes unnecessary '<dir>/..' parts.
  38695. *
  38696. * Based on code in the Node.js 'path' core module.
  38697. *
  38698. * @param aPath The path or url to normalize.
  38699. */
  38700. function normalize(aPath) {
  38701. var path = aPath;
  38702. var url = urlParse(aPath);
  38703. if (url) {
  38704. if (!url.path) {
  38705. return aPath;
  38706. }
  38707. path = url.path;
  38708. }
  38709. var isAbsolute = exports.isAbsolute(path);
  38710. var parts = path.split(/\/+/);
  38711. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  38712. part = parts[i];
  38713. if (part === '.') {
  38714. parts.splice(i, 1);
  38715. } else if (part === '..') {
  38716. up++;
  38717. } else if (up > 0) {
  38718. if (part === '') {
  38719. // The first part is blank if the path is absolute. Trying to go
  38720. // above the root is a no-op. Therefore we can remove all '..' parts
  38721. // directly after the root.
  38722. parts.splice(i + 1, up);
  38723. up = 0;
  38724. } else {
  38725. parts.splice(i, 2);
  38726. up--;
  38727. }
  38728. }
  38729. }
  38730. path = parts.join('/');
  38731. if (path === '') {
  38732. path = isAbsolute ? '/' : '.';
  38733. }
  38734. if (url) {
  38735. url.path = path;
  38736. return urlGenerate(url);
  38737. }
  38738. return path;
  38739. }
  38740. exports.normalize = normalize;
  38741. /**
  38742. * Joins two paths/URLs.
  38743. *
  38744. * @param aRoot The root path or URL.
  38745. * @param aPath The path or URL to be joined with the root.
  38746. *
  38747. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  38748. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  38749. * first.
  38750. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  38751. * is updated with the result and aRoot is returned. Otherwise the result
  38752. * is returned.
  38753. * - If aPath is absolute, the result is aPath.
  38754. * - Otherwise the two paths are joined with a slash.
  38755. * - Joining for example 'http://' and 'www.example.com' is also supported.
  38756. */
  38757. function join(aRoot, aPath) {
  38758. if (aRoot === "") {
  38759. aRoot = ".";
  38760. }
  38761. if (aPath === "") {
  38762. aPath = ".";
  38763. }
  38764. var aPathUrl = urlParse(aPath);
  38765. var aRootUrl = urlParse(aRoot);
  38766. if (aRootUrl) {
  38767. aRoot = aRootUrl.path || '/';
  38768. }
  38769. // `join(foo, '//www.example.org')`
  38770. if (aPathUrl && !aPathUrl.scheme) {
  38771. if (aRootUrl) {
  38772. aPathUrl.scheme = aRootUrl.scheme;
  38773. }
  38774. return urlGenerate(aPathUrl);
  38775. }
  38776. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  38777. return aPath;
  38778. }
  38779. // `join('http://', 'www.example.com')`
  38780. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  38781. aRootUrl.host = aPath;
  38782. return urlGenerate(aRootUrl);
  38783. }
  38784. var joined = aPath.charAt(0) === '/'
  38785. ? aPath
  38786. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  38787. if (aRootUrl) {
  38788. aRootUrl.path = joined;
  38789. return urlGenerate(aRootUrl);
  38790. }
  38791. return joined;
  38792. }
  38793. exports.join = join;
  38794. exports.isAbsolute = function (aPath) {
  38795. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  38796. };
  38797. /**
  38798. * Make a path relative to a URL or another path.
  38799. *
  38800. * @param aRoot The root path or URL.
  38801. * @param aPath The path or URL to be made relative to aRoot.
  38802. */
  38803. function relative(aRoot, aPath) {
  38804. if (aRoot === "") {
  38805. aRoot = ".";
  38806. }
  38807. aRoot = aRoot.replace(/\/$/, '');
  38808. // It is possible for the path to be above the root. In this case, simply
  38809. // checking whether the root is a prefix of the path won't work. Instead, we
  38810. // need to remove components from the root one by one, until either we find
  38811. // a prefix that fits, or we run out of components to remove.
  38812. var level = 0;
  38813. while (aPath.indexOf(aRoot + '/') !== 0) {
  38814. var index = aRoot.lastIndexOf("/");
  38815. if (index < 0) {
  38816. return aPath;
  38817. }
  38818. // If the only part of the root that is left is the scheme (i.e. http://,
  38819. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  38820. // have exhausted all components, so the path is not relative to the root.
  38821. aRoot = aRoot.slice(0, index);
  38822. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  38823. return aPath;
  38824. }
  38825. ++level;
  38826. }
  38827. // Make sure we add a "../" for each component we removed from the root.
  38828. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  38829. }
  38830. exports.relative = relative;
  38831. var supportsNullProto = (function () {
  38832. var obj = Object.create(null);
  38833. return !('__proto__' in obj);
  38834. }());
  38835. function identity (s) {
  38836. return s;
  38837. }
  38838. /**
  38839. * Because behavior goes wacky when you set `__proto__` on objects, we
  38840. * have to prefix all the strings in our set with an arbitrary character.
  38841. *
  38842. * See https://github.com/mozilla/source-map/pull/31 and
  38843. * https://github.com/mozilla/source-map/issues/30
  38844. *
  38845. * @param String aStr
  38846. */
  38847. function toSetString(aStr) {
  38848. if (isProtoString(aStr)) {
  38849. return '$' + aStr;
  38850. }
  38851. return aStr;
  38852. }
  38853. exports.toSetString = supportsNullProto ? identity : toSetString;
  38854. function fromSetString(aStr) {
  38855. if (isProtoString(aStr)) {
  38856. return aStr.slice(1);
  38857. }
  38858. return aStr;
  38859. }
  38860. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  38861. function isProtoString(s) {
  38862. if (!s) {
  38863. return false;
  38864. }
  38865. var length = s.length;
  38866. if (length < 9 /* "__proto__".length */) {
  38867. return false;
  38868. }
  38869. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  38870. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  38871. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  38872. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  38873. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  38874. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  38875. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  38876. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  38877. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  38878. return false;
  38879. }
  38880. for (var i = length - 10; i >= 0; i--) {
  38881. if (s.charCodeAt(i) !== 36 /* '$' */) {
  38882. return false;
  38883. }
  38884. }
  38885. return true;
  38886. }
  38887. /**
  38888. * Comparator between two mappings where the original positions are compared.
  38889. *
  38890. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  38891. * mappings with the same original source/line/column, but different generated
  38892. * line and column the same. Useful when searching for a mapping with a
  38893. * stubbed out mapping.
  38894. */
  38895. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  38896. var cmp = strcmp(mappingA.source, mappingB.source);
  38897. if (cmp !== 0) {
  38898. return cmp;
  38899. }
  38900. cmp = mappingA.originalLine - mappingB.originalLine;
  38901. if (cmp !== 0) {
  38902. return cmp;
  38903. }
  38904. cmp = mappingA.originalColumn - mappingB.originalColumn;
  38905. if (cmp !== 0 || onlyCompareOriginal) {
  38906. return cmp;
  38907. }
  38908. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  38909. if (cmp !== 0) {
  38910. return cmp;
  38911. }
  38912. cmp = mappingA.generatedLine - mappingB.generatedLine;
  38913. if (cmp !== 0) {
  38914. return cmp;
  38915. }
  38916. return strcmp(mappingA.name, mappingB.name);
  38917. }
  38918. exports.compareByOriginalPositions = compareByOriginalPositions;
  38919. /**
  38920. * Comparator between two mappings with deflated source and name indices where
  38921. * the generated positions are compared.
  38922. *
  38923. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  38924. * mappings with the same generated line and column, but different
  38925. * source/name/original line and column the same. Useful when searching for a
  38926. * mapping with a stubbed out mapping.
  38927. */
  38928. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  38929. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  38930. if (cmp !== 0) {
  38931. return cmp;
  38932. }
  38933. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  38934. if (cmp !== 0 || onlyCompareGenerated) {
  38935. return cmp;
  38936. }
  38937. cmp = strcmp(mappingA.source, mappingB.source);
  38938. if (cmp !== 0) {
  38939. return cmp;
  38940. }
  38941. cmp = mappingA.originalLine - mappingB.originalLine;
  38942. if (cmp !== 0) {
  38943. return cmp;
  38944. }
  38945. cmp = mappingA.originalColumn - mappingB.originalColumn;
  38946. if (cmp !== 0) {
  38947. return cmp;
  38948. }
  38949. return strcmp(mappingA.name, mappingB.name);
  38950. }
  38951. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  38952. function strcmp(aStr1, aStr2) {
  38953. if (aStr1 === aStr2) {
  38954. return 0;
  38955. }
  38956. if (aStr1 === null) {
  38957. return 1; // aStr2 !== null
  38958. }
  38959. if (aStr2 === null) {
  38960. return -1; // aStr1 !== null
  38961. }
  38962. if (aStr1 > aStr2) {
  38963. return 1;
  38964. }
  38965. return -1;
  38966. }
  38967. /**
  38968. * Comparator between two mappings with inflated source and name strings where
  38969. * the generated positions are compared.
  38970. */
  38971. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  38972. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  38973. if (cmp !== 0) {
  38974. return cmp;
  38975. }
  38976. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  38977. if (cmp !== 0) {
  38978. return cmp;
  38979. }
  38980. cmp = strcmp(mappingA.source, mappingB.source);
  38981. if (cmp !== 0) {
  38982. return cmp;
  38983. }
  38984. cmp = mappingA.originalLine - mappingB.originalLine;
  38985. if (cmp !== 0) {
  38986. return cmp;
  38987. }
  38988. cmp = mappingA.originalColumn - mappingB.originalColumn;
  38989. if (cmp !== 0) {
  38990. return cmp;
  38991. }
  38992. return strcmp(mappingA.name, mappingB.name);
  38993. }
  38994. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  38995. /**
  38996. * Strip any JSON XSSI avoidance prefix from the string (as documented
  38997. * in the source maps specification), and then parse the string as
  38998. * JSON.
  38999. */
  39000. function parseSourceMapInput(str) {
  39001. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  39002. }
  39003. exports.parseSourceMapInput = parseSourceMapInput;
  39004. /**
  39005. * Compute the URL of a source given the the source root, the source's
  39006. * URL, and the source map's URL.
  39007. */
  39008. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  39009. sourceURL = sourceURL || '';
  39010. if (sourceRoot) {
  39011. // This follows what Chrome does.
  39012. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  39013. sourceRoot += '/';
  39014. }
  39015. // The spec says:
  39016. // Line 4: An optional source root, useful for relocating source
  39017. // files on a server or removing repeated values in the
  39018. // “sources” entry. This value is prepended to the individual
  39019. // entries in the “source” field.
  39020. sourceURL = sourceRoot + sourceURL;
  39021. }
  39022. // Historically, SourceMapConsumer did not take the sourceMapURL as
  39023. // a parameter. This mode is still somewhat supported, which is why
  39024. // this code block is conditional. However, it's preferable to pass
  39025. // the source map URL to SourceMapConsumer, so that this function
  39026. // can implement the source URL resolution algorithm as outlined in
  39027. // the spec. This block is basically the equivalent of:
  39028. // new URL(sourceURL, sourceMapURL).toString()
  39029. // ... except it avoids using URL, which wasn't available in the
  39030. // older releases of node still supported by this library.
  39031. //
  39032. // The spec says:
  39033. // If the sources are not absolute URLs after prepending of the
  39034. // “sourceRoot”, the sources are resolved relative to the
  39035. // SourceMap (like resolving script src in a html document).
  39036. if (sourceMapURL) {
  39037. var parsed = urlParse(sourceMapURL);
  39038. if (!parsed) {
  39039. throw new Error("sourceMapURL could not be parsed");
  39040. }
  39041. if (parsed.path) {
  39042. // Strip the last path component, but keep the "/".
  39043. var index = parsed.path.lastIndexOf('/');
  39044. if (index >= 0) {
  39045. parsed.path = parsed.path.substring(0, index + 1);
  39046. }
  39047. }
  39048. sourceURL = join(urlGenerate(parsed), sourceURL);
  39049. }
  39050. return normalize(sourceURL);
  39051. }
  39052. exports.computeSourceURL = computeSourceURL;
  39053. } (util$5));
  39054. var arraySet = {};
  39055. /* -*- Mode: js; js-indent-level: 2; -*- */
  39056. /*
  39057. * Copyright 2011 Mozilla Foundation and contributors
  39058. * Licensed under the New BSD license. See LICENSE or:
  39059. * http://opensource.org/licenses/BSD-3-Clause
  39060. */
  39061. var util$4 = util$5;
  39062. var has = Object.prototype.hasOwnProperty;
  39063. var hasNativeMap = typeof Map !== "undefined";
  39064. /**
  39065. * A data structure which is a combination of an array and a set. Adding a new
  39066. * member is O(1), testing for membership is O(1), and finding the index of an
  39067. * element is O(1). Removing elements from the set is not supported. Only
  39068. * strings are supported for membership.
  39069. */
  39070. function ArraySet$2() {
  39071. this._array = [];
  39072. this._set = hasNativeMap ? new Map() : Object.create(null);
  39073. }
  39074. /**
  39075. * Static method for creating ArraySet instances from an existing array.
  39076. */
  39077. ArraySet$2.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  39078. var set = new ArraySet$2();
  39079. for (var i = 0, len = aArray.length; i < len; i++) {
  39080. set.add(aArray[i], aAllowDuplicates);
  39081. }
  39082. return set;
  39083. };
  39084. /**
  39085. * Return how many unique items are in this ArraySet. If duplicates have been
  39086. * added, than those do not count towards the size.
  39087. *
  39088. * @returns Number
  39089. */
  39090. ArraySet$2.prototype.size = function ArraySet_size() {
  39091. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  39092. };
  39093. /**
  39094. * Add the given string to this set.
  39095. *
  39096. * @param String aStr
  39097. */
  39098. ArraySet$2.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  39099. var sStr = hasNativeMap ? aStr : util$4.toSetString(aStr);
  39100. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  39101. var idx = this._array.length;
  39102. if (!isDuplicate || aAllowDuplicates) {
  39103. this._array.push(aStr);
  39104. }
  39105. if (!isDuplicate) {
  39106. if (hasNativeMap) {
  39107. this._set.set(aStr, idx);
  39108. } else {
  39109. this._set[sStr] = idx;
  39110. }
  39111. }
  39112. };
  39113. /**
  39114. * Is the given string a member of this set?
  39115. *
  39116. * @param String aStr
  39117. */
  39118. ArraySet$2.prototype.has = function ArraySet_has(aStr) {
  39119. if (hasNativeMap) {
  39120. return this._set.has(aStr);
  39121. } else {
  39122. var sStr = util$4.toSetString(aStr);
  39123. return has.call(this._set, sStr);
  39124. }
  39125. };
  39126. /**
  39127. * What is the index of the given string in the array?
  39128. *
  39129. * @param String aStr
  39130. */
  39131. ArraySet$2.prototype.indexOf = function ArraySet_indexOf(aStr) {
  39132. if (hasNativeMap) {
  39133. var idx = this._set.get(aStr);
  39134. if (idx >= 0) {
  39135. return idx;
  39136. }
  39137. } else {
  39138. var sStr = util$4.toSetString(aStr);
  39139. if (has.call(this._set, sStr)) {
  39140. return this._set[sStr];
  39141. }
  39142. }
  39143. throw new Error('"' + aStr + '" is not in the set.');
  39144. };
  39145. /**
  39146. * What is the element at the given index?
  39147. *
  39148. * @param Number aIdx
  39149. */
  39150. ArraySet$2.prototype.at = function ArraySet_at(aIdx) {
  39151. if (aIdx >= 0 && aIdx < this._array.length) {
  39152. return this._array[aIdx];
  39153. }
  39154. throw new Error('No element indexed by ' + aIdx);
  39155. };
  39156. /**
  39157. * Returns the array representation of this set (which has the proper indices
  39158. * indicated by indexOf). Note that this is a copy of the internal array used
  39159. * for storing the members so that no one can mess with internal state.
  39160. */
  39161. ArraySet$2.prototype.toArray = function ArraySet_toArray() {
  39162. return this._array.slice();
  39163. };
  39164. arraySet.ArraySet = ArraySet$2;
  39165. var mappingList = {};
  39166. /* -*- Mode: js; js-indent-level: 2; -*- */
  39167. /*
  39168. * Copyright 2014 Mozilla Foundation and contributors
  39169. * Licensed under the New BSD license. See LICENSE or:
  39170. * http://opensource.org/licenses/BSD-3-Clause
  39171. */
  39172. var util$3 = util$5;
  39173. /**
  39174. * Determine whether mappingB is after mappingA with respect to generated
  39175. * position.
  39176. */
  39177. function generatedPositionAfter(mappingA, mappingB) {
  39178. // Optimized for most common case
  39179. var lineA = mappingA.generatedLine;
  39180. var lineB = mappingB.generatedLine;
  39181. var columnA = mappingA.generatedColumn;
  39182. var columnB = mappingB.generatedColumn;
  39183. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  39184. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  39185. }
  39186. /**
  39187. * A data structure to provide a sorted view of accumulated mappings in a
  39188. * performance conscious manner. It trades a neglibable overhead in general
  39189. * case for a large speedup in case of mappings being added in order.
  39190. */
  39191. function MappingList$1() {
  39192. this._array = [];
  39193. this._sorted = true;
  39194. // Serves as infimum
  39195. this._last = {generatedLine: -1, generatedColumn: 0};
  39196. }
  39197. /**
  39198. * Iterate through internal items. This method takes the same arguments that
  39199. * `Array.prototype.forEach` takes.
  39200. *
  39201. * NOTE: The order of the mappings is NOT guaranteed.
  39202. */
  39203. MappingList$1.prototype.unsortedForEach =
  39204. function MappingList_forEach(aCallback, aThisArg) {
  39205. this._array.forEach(aCallback, aThisArg);
  39206. };
  39207. /**
  39208. * Add the given source mapping.
  39209. *
  39210. * @param Object aMapping
  39211. */
  39212. MappingList$1.prototype.add = function MappingList_add(aMapping) {
  39213. if (generatedPositionAfter(this._last, aMapping)) {
  39214. this._last = aMapping;
  39215. this._array.push(aMapping);
  39216. } else {
  39217. this._sorted = false;
  39218. this._array.push(aMapping);
  39219. }
  39220. };
  39221. /**
  39222. * Returns the flat, sorted array of mappings. The mappings are sorted by
  39223. * generated position.
  39224. *
  39225. * WARNING: This method returns internal data without copying, for
  39226. * performance. The return value must NOT be mutated, and should be treated as
  39227. * an immutable borrow. If you want to take ownership, you must make your own
  39228. * copy.
  39229. */
  39230. MappingList$1.prototype.toArray = function MappingList_toArray() {
  39231. if (!this._sorted) {
  39232. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  39233. this._sorted = true;
  39234. }
  39235. return this._array;
  39236. };
  39237. mappingList.MappingList = MappingList$1;
  39238. /* -*- Mode: js; js-indent-level: 2; -*- */
  39239. /*
  39240. * Copyright 2011 Mozilla Foundation and contributors
  39241. * Licensed under the New BSD license. See LICENSE or:
  39242. * http://opensource.org/licenses/BSD-3-Clause
  39243. */
  39244. var base64VLQ$1 = base64Vlq;
  39245. var util$2 = util$5;
  39246. var ArraySet$1 = arraySet.ArraySet;
  39247. var MappingList = mappingList.MappingList;
  39248. /**
  39249. * An instance of the SourceMapGenerator represents a source map which is
  39250. * being built incrementally. You may pass an object with the following
  39251. * properties:
  39252. *
  39253. * - file: The filename of the generated source.
  39254. * - sourceRoot: A root for all relative URLs in this source map.
  39255. */
  39256. function SourceMapGenerator$2(aArgs) {
  39257. if (!aArgs) {
  39258. aArgs = {};
  39259. }
  39260. this._file = util$2.getArg(aArgs, 'file', null);
  39261. this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
  39262. this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
  39263. this._sources = new ArraySet$1();
  39264. this._names = new ArraySet$1();
  39265. this._mappings = new MappingList();
  39266. this._sourcesContents = null;
  39267. }
  39268. SourceMapGenerator$2.prototype._version = 3;
  39269. /**
  39270. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  39271. *
  39272. * @param aSourceMapConsumer The SourceMap.
  39273. */
  39274. SourceMapGenerator$2.fromSourceMap =
  39275. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  39276. var sourceRoot = aSourceMapConsumer.sourceRoot;
  39277. var generator = new SourceMapGenerator$2({
  39278. file: aSourceMapConsumer.file,
  39279. sourceRoot: sourceRoot
  39280. });
  39281. aSourceMapConsumer.eachMapping(function (mapping) {
  39282. var newMapping = {
  39283. generated: {
  39284. line: mapping.generatedLine,
  39285. column: mapping.generatedColumn
  39286. }
  39287. };
  39288. if (mapping.source != null) {
  39289. newMapping.source = mapping.source;
  39290. if (sourceRoot != null) {
  39291. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  39292. }
  39293. newMapping.original = {
  39294. line: mapping.originalLine,
  39295. column: mapping.originalColumn
  39296. };
  39297. if (mapping.name != null) {
  39298. newMapping.name = mapping.name;
  39299. }
  39300. }
  39301. generator.addMapping(newMapping);
  39302. });
  39303. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39304. var sourceRelative = sourceFile;
  39305. if (sourceRoot !== null) {
  39306. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  39307. }
  39308. if (!generator._sources.has(sourceRelative)) {
  39309. generator._sources.add(sourceRelative);
  39310. }
  39311. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39312. if (content != null) {
  39313. generator.setSourceContent(sourceFile, content);
  39314. }
  39315. });
  39316. return generator;
  39317. };
  39318. /**
  39319. * Add a single mapping from original source line and column to the generated
  39320. * source's line and column for this source map being created. The mapping
  39321. * object should have the following properties:
  39322. *
  39323. * - generated: An object with the generated line and column positions.
  39324. * - original: An object with the original line and column positions.
  39325. * - source: The original source file (relative to the sourceRoot).
  39326. * - name: An optional original token name for this mapping.
  39327. */
  39328. SourceMapGenerator$2.prototype.addMapping =
  39329. function SourceMapGenerator_addMapping(aArgs) {
  39330. var generated = util$2.getArg(aArgs, 'generated');
  39331. var original = util$2.getArg(aArgs, 'original', null);
  39332. var source = util$2.getArg(aArgs, 'source', null);
  39333. var name = util$2.getArg(aArgs, 'name', null);
  39334. if (!this._skipValidation) {
  39335. this._validateMapping(generated, original, source, name);
  39336. }
  39337. if (source != null) {
  39338. source = String(source);
  39339. if (!this._sources.has(source)) {
  39340. this._sources.add(source);
  39341. }
  39342. }
  39343. if (name != null) {
  39344. name = String(name);
  39345. if (!this._names.has(name)) {
  39346. this._names.add(name);
  39347. }
  39348. }
  39349. this._mappings.add({
  39350. generatedLine: generated.line,
  39351. generatedColumn: generated.column,
  39352. originalLine: original != null && original.line,
  39353. originalColumn: original != null && original.column,
  39354. source: source,
  39355. name: name
  39356. });
  39357. };
  39358. /**
  39359. * Set the source content for a source file.
  39360. */
  39361. SourceMapGenerator$2.prototype.setSourceContent =
  39362. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  39363. var source = aSourceFile;
  39364. if (this._sourceRoot != null) {
  39365. source = util$2.relative(this._sourceRoot, source);
  39366. }
  39367. if (aSourceContent != null) {
  39368. // Add the source content to the _sourcesContents map.
  39369. // Create a new _sourcesContents map if the property is null.
  39370. if (!this._sourcesContents) {
  39371. this._sourcesContents = Object.create(null);
  39372. }
  39373. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  39374. } else if (this._sourcesContents) {
  39375. // Remove the source file from the _sourcesContents map.
  39376. // If the _sourcesContents map is empty, set the property to null.
  39377. delete this._sourcesContents[util$2.toSetString(source)];
  39378. if (Object.keys(this._sourcesContents).length === 0) {
  39379. this._sourcesContents = null;
  39380. }
  39381. }
  39382. };
  39383. /**
  39384. * Applies the mappings of a sub-source-map for a specific source file to the
  39385. * source map being generated. Each mapping to the supplied source file is
  39386. * rewritten using the supplied source map. Note: The resolution for the
  39387. * resulting mappings is the minimium of this map and the supplied map.
  39388. *
  39389. * @param aSourceMapConsumer The source map to be applied.
  39390. * @param aSourceFile Optional. The filename of the source file.
  39391. * If omitted, SourceMapConsumer's file property will be used.
  39392. * @param aSourceMapPath Optional. The dirname of the path to the source map
  39393. * to be applied. If relative, it is relative to the SourceMapConsumer.
  39394. * This parameter is needed when the two source maps aren't in the same
  39395. * directory, and the source map to be applied contains relative source
  39396. * paths. If so, those relative source paths need to be rewritten
  39397. * relative to the SourceMapGenerator.
  39398. */
  39399. SourceMapGenerator$2.prototype.applySourceMap =
  39400. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  39401. var sourceFile = aSourceFile;
  39402. // If aSourceFile is omitted, we will use the file property of the SourceMap
  39403. if (aSourceFile == null) {
  39404. if (aSourceMapConsumer.file == null) {
  39405. throw new Error(
  39406. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  39407. 'or the source map\'s "file" property. Both were omitted.'
  39408. );
  39409. }
  39410. sourceFile = aSourceMapConsumer.file;
  39411. }
  39412. var sourceRoot = this._sourceRoot;
  39413. // Make "sourceFile" relative if an absolute Url is passed.
  39414. if (sourceRoot != null) {
  39415. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39416. }
  39417. // Applying the SourceMap can add and remove items from the sources and
  39418. // the names array.
  39419. var newSources = new ArraySet$1();
  39420. var newNames = new ArraySet$1();
  39421. // Find mappings for the "sourceFile"
  39422. this._mappings.unsortedForEach(function (mapping) {
  39423. if (mapping.source === sourceFile && mapping.originalLine != null) {
  39424. // Check if it can be mapped by the source map, then update the mapping.
  39425. var original = aSourceMapConsumer.originalPositionFor({
  39426. line: mapping.originalLine,
  39427. column: mapping.originalColumn
  39428. });
  39429. if (original.source != null) {
  39430. // Copy mapping
  39431. mapping.source = original.source;
  39432. if (aSourceMapPath != null) {
  39433. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  39434. }
  39435. if (sourceRoot != null) {
  39436. mapping.source = util$2.relative(sourceRoot, mapping.source);
  39437. }
  39438. mapping.originalLine = original.line;
  39439. mapping.originalColumn = original.column;
  39440. if (original.name != null) {
  39441. mapping.name = original.name;
  39442. }
  39443. }
  39444. }
  39445. var source = mapping.source;
  39446. if (source != null && !newSources.has(source)) {
  39447. newSources.add(source);
  39448. }
  39449. var name = mapping.name;
  39450. if (name != null && !newNames.has(name)) {
  39451. newNames.add(name);
  39452. }
  39453. }, this);
  39454. this._sources = newSources;
  39455. this._names = newNames;
  39456. // Copy sourcesContents of applied map.
  39457. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39458. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39459. if (content != null) {
  39460. if (aSourceMapPath != null) {
  39461. sourceFile = util$2.join(aSourceMapPath, sourceFile);
  39462. }
  39463. if (sourceRoot != null) {
  39464. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39465. }
  39466. this.setSourceContent(sourceFile, content);
  39467. }
  39468. }, this);
  39469. };
  39470. /**
  39471. * A mapping can have one of the three levels of data:
  39472. *
  39473. * 1. Just the generated position.
  39474. * 2. The Generated position, original position, and original source.
  39475. * 3. Generated and original position, original source, as well as a name
  39476. * token.
  39477. *
  39478. * To maintain consistency, we validate that any new mapping being added falls
  39479. * in to one of these categories.
  39480. */
  39481. SourceMapGenerator$2.prototype._validateMapping =
  39482. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  39483. aName) {
  39484. // When aOriginal is truthy but has empty values for .line and .column,
  39485. // it is most likely a programmer error. In this case we throw a very
  39486. // specific error message to try to guide them the right way.
  39487. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  39488. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  39489. throw new Error(
  39490. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  39491. 'the original mapping entirely and only map the generated position. If so, pass ' +
  39492. 'null for the original mapping instead of an object with empty or null values.'
  39493. );
  39494. }
  39495. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39496. && aGenerated.line > 0 && aGenerated.column >= 0
  39497. && !aOriginal && !aSource && !aName) {
  39498. // Case 1.
  39499. return;
  39500. }
  39501. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39502. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  39503. && aGenerated.line > 0 && aGenerated.column >= 0
  39504. && aOriginal.line > 0 && aOriginal.column >= 0
  39505. && aSource) {
  39506. // Cases 2 and 3.
  39507. return;
  39508. }
  39509. else {
  39510. throw new Error('Invalid mapping: ' + JSON.stringify({
  39511. generated: aGenerated,
  39512. source: aSource,
  39513. original: aOriginal,
  39514. name: aName
  39515. }));
  39516. }
  39517. };
  39518. /**
  39519. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  39520. * specified by the source map format.
  39521. */
  39522. SourceMapGenerator$2.prototype._serializeMappings =
  39523. function SourceMapGenerator_serializeMappings() {
  39524. var previousGeneratedColumn = 0;
  39525. var previousGeneratedLine = 1;
  39526. var previousOriginalColumn = 0;
  39527. var previousOriginalLine = 0;
  39528. var previousName = 0;
  39529. var previousSource = 0;
  39530. var result = '';
  39531. var next;
  39532. var mapping;
  39533. var nameIdx;
  39534. var sourceIdx;
  39535. var mappings = this._mappings.toArray();
  39536. for (var i = 0, len = mappings.length; i < len; i++) {
  39537. mapping = mappings[i];
  39538. next = '';
  39539. if (mapping.generatedLine !== previousGeneratedLine) {
  39540. previousGeneratedColumn = 0;
  39541. while (mapping.generatedLine !== previousGeneratedLine) {
  39542. next += ';';
  39543. previousGeneratedLine++;
  39544. }
  39545. }
  39546. else {
  39547. if (i > 0) {
  39548. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  39549. continue;
  39550. }
  39551. next += ',';
  39552. }
  39553. }
  39554. next += base64VLQ$1.encode(mapping.generatedColumn
  39555. - previousGeneratedColumn);
  39556. previousGeneratedColumn = mapping.generatedColumn;
  39557. if (mapping.source != null) {
  39558. sourceIdx = this._sources.indexOf(mapping.source);
  39559. next += base64VLQ$1.encode(sourceIdx - previousSource);
  39560. previousSource = sourceIdx;
  39561. // lines are stored 0-based in SourceMap spec version 3
  39562. next += base64VLQ$1.encode(mapping.originalLine - 1
  39563. - previousOriginalLine);
  39564. previousOriginalLine = mapping.originalLine - 1;
  39565. next += base64VLQ$1.encode(mapping.originalColumn
  39566. - previousOriginalColumn);
  39567. previousOriginalColumn = mapping.originalColumn;
  39568. if (mapping.name != null) {
  39569. nameIdx = this._names.indexOf(mapping.name);
  39570. next += base64VLQ$1.encode(nameIdx - previousName);
  39571. previousName = nameIdx;
  39572. }
  39573. }
  39574. result += next;
  39575. }
  39576. return result;
  39577. };
  39578. SourceMapGenerator$2.prototype._generateSourcesContent =
  39579. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  39580. return aSources.map(function (source) {
  39581. if (!this._sourcesContents) {
  39582. return null;
  39583. }
  39584. if (aSourceRoot != null) {
  39585. source = util$2.relative(aSourceRoot, source);
  39586. }
  39587. var key = util$2.toSetString(source);
  39588. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  39589. ? this._sourcesContents[key]
  39590. : null;
  39591. }, this);
  39592. };
  39593. /**
  39594. * Externalize the source map.
  39595. */
  39596. SourceMapGenerator$2.prototype.toJSON =
  39597. function SourceMapGenerator_toJSON() {
  39598. var map = {
  39599. version: this._version,
  39600. sources: this._sources.toArray(),
  39601. names: this._names.toArray(),
  39602. mappings: this._serializeMappings()
  39603. };
  39604. if (this._file != null) {
  39605. map.file = this._file;
  39606. }
  39607. if (this._sourceRoot != null) {
  39608. map.sourceRoot = this._sourceRoot;
  39609. }
  39610. if (this._sourcesContents) {
  39611. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  39612. }
  39613. return map;
  39614. };
  39615. /**
  39616. * Render the source map being generated to a string.
  39617. */
  39618. SourceMapGenerator$2.prototype.toString =
  39619. function SourceMapGenerator_toString() {
  39620. return JSON.stringify(this.toJSON());
  39621. };
  39622. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$2;
  39623. var sourceMapConsumer = {};
  39624. var binarySearch$1 = {};
  39625. /* -*- Mode: js; js-indent-level: 2; -*- */
  39626. (function (exports) {
  39627. /*
  39628. * Copyright 2011 Mozilla Foundation and contributors
  39629. * Licensed under the New BSD license. See LICENSE or:
  39630. * http://opensource.org/licenses/BSD-3-Clause
  39631. */
  39632. exports.GREATEST_LOWER_BOUND = 1;
  39633. exports.LEAST_UPPER_BOUND = 2;
  39634. /**
  39635. * Recursive implementation of binary search.
  39636. *
  39637. * @param aLow Indices here and lower do not contain the needle.
  39638. * @param aHigh Indices here and higher do not contain the needle.
  39639. * @param aNeedle The element being searched for.
  39640. * @param aHaystack The non-empty array being searched.
  39641. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  39642. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39643. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39644. * closest element that is smaller than or greater than the one we are
  39645. * searching for, respectively, if the exact element cannot be found.
  39646. */
  39647. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  39648. // This function terminates when one of the following is true:
  39649. //
  39650. // 1. We find the exact element we are looking for.
  39651. //
  39652. // 2. We did not find the exact element, but we can return the index of
  39653. // the next-closest element.
  39654. //
  39655. // 3. We did not find the exact element, and there is no next-closest
  39656. // element than the one we are searching for, so we return -1.
  39657. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  39658. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  39659. if (cmp === 0) {
  39660. // Found the element we are looking for.
  39661. return mid;
  39662. }
  39663. else if (cmp > 0) {
  39664. // Our needle is greater than aHaystack[mid].
  39665. if (aHigh - mid > 1) {
  39666. // The element is in the upper half.
  39667. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  39668. }
  39669. // The exact needle element was not found in this haystack. Determine if
  39670. // we are in termination case (3) or (2) and return the appropriate thing.
  39671. if (aBias == exports.LEAST_UPPER_BOUND) {
  39672. return aHigh < aHaystack.length ? aHigh : -1;
  39673. } else {
  39674. return mid;
  39675. }
  39676. }
  39677. else {
  39678. // Our needle is less than aHaystack[mid].
  39679. if (mid - aLow > 1) {
  39680. // The element is in the lower half.
  39681. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  39682. }
  39683. // we are in termination case (3) or (2) and return the appropriate thing.
  39684. if (aBias == exports.LEAST_UPPER_BOUND) {
  39685. return mid;
  39686. } else {
  39687. return aLow < 0 ? -1 : aLow;
  39688. }
  39689. }
  39690. }
  39691. /**
  39692. * This is an implementation of binary search which will always try and return
  39693. * the index of the closest element if there is no exact hit. This is because
  39694. * mappings between original and generated line/col pairs are single points,
  39695. * and there is an implicit region between each of them, so a miss just means
  39696. * that you aren't on the very start of a region.
  39697. *
  39698. * @param aNeedle The element you are looking for.
  39699. * @param aHaystack The array that is being searched.
  39700. * @param aCompare A function which takes the needle and an element in the
  39701. * array and returns -1, 0, or 1 depending on whether the needle is less
  39702. * than, equal to, or greater than the element, respectively.
  39703. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39704. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39705. * closest element that is smaller than or greater than the one we are
  39706. * searching for, respectively, if the exact element cannot be found.
  39707. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  39708. */
  39709. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  39710. if (aHaystack.length === 0) {
  39711. return -1;
  39712. }
  39713. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  39714. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  39715. if (index < 0) {
  39716. return -1;
  39717. }
  39718. // We have found either the exact element, or the next-closest element than
  39719. // the one we are searching for. However, there may be more than one such
  39720. // element. Make sure we always return the smallest of these.
  39721. while (index - 1 >= 0) {
  39722. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  39723. break;
  39724. }
  39725. --index;
  39726. }
  39727. return index;
  39728. };
  39729. } (binarySearch$1));
  39730. var quickSort$1 = {};
  39731. /* -*- Mode: js; js-indent-level: 2; -*- */
  39732. /*
  39733. * Copyright 2011 Mozilla Foundation and contributors
  39734. * Licensed under the New BSD license. See LICENSE or:
  39735. * http://opensource.org/licenses/BSD-3-Clause
  39736. */
  39737. // It turns out that some (most?) JavaScript engines don't self-host
  39738. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  39739. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  39740. // custom comparator function, calling back and forth between the VM's C++ and
  39741. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  39742. // worse generated code for the comparator function than would be optimal. In
  39743. // fact, when sorting with a comparator, these costs outweigh the benefits of
  39744. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  39745. // a ~3500ms mean speed-up in `bench/bench.html`.
  39746. /**
  39747. * Swap the elements indexed by `x` and `y` in the array `ary`.
  39748. *
  39749. * @param {Array} ary
  39750. * The array.
  39751. * @param {Number} x
  39752. * The index of the first item.
  39753. * @param {Number} y
  39754. * The index of the second item.
  39755. */
  39756. function swap(ary, x, y) {
  39757. var temp = ary[x];
  39758. ary[x] = ary[y];
  39759. ary[y] = temp;
  39760. }
  39761. /**
  39762. * Returns a random integer within the range `low .. high` inclusive.
  39763. *
  39764. * @param {Number} low
  39765. * The lower bound on the range.
  39766. * @param {Number} high
  39767. * The upper bound on the range.
  39768. */
  39769. function randomIntInRange(low, high) {
  39770. return Math.round(low + (Math.random() * (high - low)));
  39771. }
  39772. /**
  39773. * The Quick Sort algorithm.
  39774. *
  39775. * @param {Array} ary
  39776. * An array to sort.
  39777. * @param {function} comparator
  39778. * Function to use to compare two items.
  39779. * @param {Number} p
  39780. * Start index of the array
  39781. * @param {Number} r
  39782. * End index of the array
  39783. */
  39784. function doQuickSort(ary, comparator, p, r) {
  39785. // If our lower bound is less than our upper bound, we (1) partition the
  39786. // array into two pieces and (2) recurse on each half. If it is not, this is
  39787. // the empty array and our base case.
  39788. if (p < r) {
  39789. // (1) Partitioning.
  39790. //
  39791. // The partitioning chooses a pivot between `p` and `r` and moves all
  39792. // elements that are less than or equal to the pivot to the before it, and
  39793. // all the elements that are greater than it after it. The effect is that
  39794. // once partition is done, the pivot is in the exact place it will be when
  39795. // the array is put in sorted order, and it will not need to be moved
  39796. // again. This runs in O(n) time.
  39797. // Always choose a random pivot so that an input array which is reverse
  39798. // sorted does not cause O(n^2) running time.
  39799. var pivotIndex = randomIntInRange(p, r);
  39800. var i = p - 1;
  39801. swap(ary, pivotIndex, r);
  39802. var pivot = ary[r];
  39803. // Immediately after `j` is incremented in this loop, the following hold
  39804. // true:
  39805. //
  39806. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  39807. //
  39808. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  39809. for (var j = p; j < r; j++) {
  39810. if (comparator(ary[j], pivot) <= 0) {
  39811. i += 1;
  39812. swap(ary, i, j);
  39813. }
  39814. }
  39815. swap(ary, i + 1, j);
  39816. var q = i + 1;
  39817. // (2) Recurse on each half.
  39818. doQuickSort(ary, comparator, p, q - 1);
  39819. doQuickSort(ary, comparator, q + 1, r);
  39820. }
  39821. }
  39822. /**
  39823. * Sort the given array in-place with the given comparator function.
  39824. *
  39825. * @param {Array} ary
  39826. * An array to sort.
  39827. * @param {function} comparator
  39828. * Function to use to compare two items.
  39829. */
  39830. quickSort$1.quickSort = function (ary, comparator) {
  39831. doQuickSort(ary, comparator, 0, ary.length - 1);
  39832. };
  39833. /* -*- Mode: js; js-indent-level: 2; -*- */
  39834. /*
  39835. * Copyright 2011 Mozilla Foundation and contributors
  39836. * Licensed under the New BSD license. See LICENSE or:
  39837. * http://opensource.org/licenses/BSD-3-Clause
  39838. */
  39839. var util$1 = util$5;
  39840. var binarySearch = binarySearch$1;
  39841. var ArraySet = arraySet.ArraySet;
  39842. var base64VLQ = base64Vlq;
  39843. var quickSort = quickSort$1.quickSort;
  39844. function SourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  39845. var sourceMap = aSourceMap;
  39846. if (typeof aSourceMap === 'string') {
  39847. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  39848. }
  39849. return sourceMap.sections != null
  39850. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  39851. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  39852. }
  39853. SourceMapConsumer$1.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  39854. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  39855. };
  39856. /**
  39857. * The version of the source mapping spec that we are consuming.
  39858. */
  39859. SourceMapConsumer$1.prototype._version = 3;
  39860. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  39861. // parsed mapping coordinates from the source map's "mappings" attribute. They
  39862. // are lazily instantiated, accessed via the `_generatedMappings` and
  39863. // `_originalMappings` getters respectively, and we only parse the mappings
  39864. // and create these arrays once queried for a source location. We jump through
  39865. // these hoops because there can be many thousands of mappings, and parsing
  39866. // them is expensive, so we only want to do it if we must.
  39867. //
  39868. // Each object in the arrays is of the form:
  39869. //
  39870. // {
  39871. // generatedLine: The line number in the generated code,
  39872. // generatedColumn: The column number in the generated code,
  39873. // source: The path to the original source file that generated this
  39874. // chunk of code,
  39875. // originalLine: The line number in the original source that
  39876. // corresponds to this chunk of generated code,
  39877. // originalColumn: The column number in the original source that
  39878. // corresponds to this chunk of generated code,
  39879. // name: The name of the original symbol which generated this chunk of
  39880. // code.
  39881. // }
  39882. //
  39883. // All properties except for `generatedLine` and `generatedColumn` can be
  39884. // `null`.
  39885. //
  39886. // `_generatedMappings` is ordered by the generated positions.
  39887. //
  39888. // `_originalMappings` is ordered by the original positions.
  39889. SourceMapConsumer$1.prototype.__generatedMappings = null;
  39890. Object.defineProperty(SourceMapConsumer$1.prototype, '_generatedMappings', {
  39891. configurable: true,
  39892. enumerable: true,
  39893. get: function () {
  39894. if (!this.__generatedMappings) {
  39895. this._parseMappings(this._mappings, this.sourceRoot);
  39896. }
  39897. return this.__generatedMappings;
  39898. }
  39899. });
  39900. SourceMapConsumer$1.prototype.__originalMappings = null;
  39901. Object.defineProperty(SourceMapConsumer$1.prototype, '_originalMappings', {
  39902. configurable: true,
  39903. enumerable: true,
  39904. get: function () {
  39905. if (!this.__originalMappings) {
  39906. this._parseMappings(this._mappings, this.sourceRoot);
  39907. }
  39908. return this.__originalMappings;
  39909. }
  39910. });
  39911. SourceMapConsumer$1.prototype._charIsMappingSeparator =
  39912. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  39913. var c = aStr.charAt(index);
  39914. return c === ";" || c === ",";
  39915. };
  39916. /**
  39917. * Parse the mappings in a string in to a data structure which we can easily
  39918. * query (the ordered arrays in the `this.__generatedMappings` and
  39919. * `this.__originalMappings` properties).
  39920. */
  39921. SourceMapConsumer$1.prototype._parseMappings =
  39922. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  39923. throw new Error("Subclasses must implement _parseMappings");
  39924. };
  39925. SourceMapConsumer$1.GENERATED_ORDER = 1;
  39926. SourceMapConsumer$1.ORIGINAL_ORDER = 2;
  39927. SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
  39928. SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
  39929. /**
  39930. * Iterate over each mapping between an original source/line/column and a
  39931. * generated line/column in this source map.
  39932. *
  39933. * @param Function aCallback
  39934. * The function that is called with each mapping.
  39935. * @param Object aContext
  39936. * Optional. If specified, this object will be the value of `this` every
  39937. * time that `aCallback` is called.
  39938. * @param aOrder
  39939. * Either `SourceMapConsumer.GENERATED_ORDER` or
  39940. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  39941. * iterate over the mappings sorted by the generated file's line/column
  39942. * order or the original's source/line/column order, respectively. Defaults to
  39943. * `SourceMapConsumer.GENERATED_ORDER`.
  39944. */
  39945. SourceMapConsumer$1.prototype.eachMapping =
  39946. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  39947. var context = aContext || null;
  39948. var order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
  39949. var mappings;
  39950. switch (order) {
  39951. case SourceMapConsumer$1.GENERATED_ORDER:
  39952. mappings = this._generatedMappings;
  39953. break;
  39954. case SourceMapConsumer$1.ORIGINAL_ORDER:
  39955. mappings = this._originalMappings;
  39956. break;
  39957. default:
  39958. throw new Error("Unknown order of iteration.");
  39959. }
  39960. var sourceRoot = this.sourceRoot;
  39961. mappings.map(function (mapping) {
  39962. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  39963. source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  39964. return {
  39965. source: source,
  39966. generatedLine: mapping.generatedLine,
  39967. generatedColumn: mapping.generatedColumn,
  39968. originalLine: mapping.originalLine,
  39969. originalColumn: mapping.originalColumn,
  39970. name: mapping.name === null ? null : this._names.at(mapping.name)
  39971. };
  39972. }, this).forEach(aCallback, context);
  39973. };
  39974. /**
  39975. * Returns all generated line and column information for the original source,
  39976. * line, and column provided. If no column is provided, returns all mappings
  39977. * corresponding to a either the line we are searching for or the next
  39978. * closest line that has any mappings. Otherwise, returns all mappings
  39979. * corresponding to the given line and either the column we are searching for
  39980. * or the next closest column that has any offsets.
  39981. *
  39982. * The only argument is an object with the following properties:
  39983. *
  39984. * - source: The filename of the original source.
  39985. * - line: The line number in the original source. The line number is 1-based.
  39986. * - column: Optional. the column number in the original source.
  39987. * The column number is 0-based.
  39988. *
  39989. * and an array of objects is returned, each with the following properties:
  39990. *
  39991. * - line: The line number in the generated source, or null. The
  39992. * line number is 1-based.
  39993. * - column: The column number in the generated source, or null.
  39994. * The column number is 0-based.
  39995. */
  39996. SourceMapConsumer$1.prototype.allGeneratedPositionsFor =
  39997. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  39998. var line = util$1.getArg(aArgs, 'line');
  39999. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  40000. // returns the index of the closest mapping less than the needle. By
  40001. // setting needle.originalColumn to 0, we thus find the last mapping for
  40002. // the given line, provided such a mapping exists.
  40003. var needle = {
  40004. source: util$1.getArg(aArgs, 'source'),
  40005. originalLine: line,
  40006. originalColumn: util$1.getArg(aArgs, 'column', 0)
  40007. };
  40008. needle.source = this._findSourceIndex(needle.source);
  40009. if (needle.source < 0) {
  40010. return [];
  40011. }
  40012. var mappings = [];
  40013. var index = this._findMapping(needle,
  40014. this._originalMappings,
  40015. "originalLine",
  40016. "originalColumn",
  40017. util$1.compareByOriginalPositions,
  40018. binarySearch.LEAST_UPPER_BOUND);
  40019. if (index >= 0) {
  40020. var mapping = this._originalMappings[index];
  40021. if (aArgs.column === undefined) {
  40022. var originalLine = mapping.originalLine;
  40023. // Iterate until either we run out of mappings, or we run into
  40024. // a mapping for a different line than the one we found. Since
  40025. // mappings are sorted, this is guaranteed to find all mappings for
  40026. // the line we found.
  40027. while (mapping && mapping.originalLine === originalLine) {
  40028. mappings.push({
  40029. line: util$1.getArg(mapping, 'generatedLine', null),
  40030. column: util$1.getArg(mapping, 'generatedColumn', null),
  40031. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40032. });
  40033. mapping = this._originalMappings[++index];
  40034. }
  40035. } else {
  40036. var originalColumn = mapping.originalColumn;
  40037. // Iterate until either we run out of mappings, or we run into
  40038. // a mapping for a different line than the one we were searching for.
  40039. // Since mappings are sorted, this is guaranteed to find all mappings for
  40040. // the line we are searching for.
  40041. while (mapping &&
  40042. mapping.originalLine === line &&
  40043. mapping.originalColumn == originalColumn) {
  40044. mappings.push({
  40045. line: util$1.getArg(mapping, 'generatedLine', null),
  40046. column: util$1.getArg(mapping, 'generatedColumn', null),
  40047. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40048. });
  40049. mapping = this._originalMappings[++index];
  40050. }
  40051. }
  40052. }
  40053. return mappings;
  40054. };
  40055. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
  40056. /**
  40057. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  40058. * query for information about the original file positions by giving it a file
  40059. * position in the generated source.
  40060. *
  40061. * The first parameter is the raw source map (either as a JSON string, or
  40062. * already parsed to an object). According to the spec, source maps have the
  40063. * following attributes:
  40064. *
  40065. * - version: Which version of the source map spec this map is following.
  40066. * - sources: An array of URLs to the original source files.
  40067. * - names: An array of identifiers which can be referrenced by individual mappings.
  40068. * - sourceRoot: Optional. The URL root from which all sources are relative.
  40069. * - sourcesContent: Optional. An array of contents of the original source files.
  40070. * - mappings: A string of base64 VLQs which contain the actual mappings.
  40071. * - file: Optional. The generated file this source map is associated with.
  40072. *
  40073. * Here is an example source map, taken from the source map spec[0]:
  40074. *
  40075. * {
  40076. * version : 3,
  40077. * file: "out.js",
  40078. * sourceRoot : "",
  40079. * sources: ["foo.js", "bar.js"],
  40080. * names: ["src", "maps", "are", "fun"],
  40081. * mappings: "AA,AB;;ABCDE;"
  40082. * }
  40083. *
  40084. * The second parameter, if given, is a string whose value is the URL
  40085. * at which the source map was found. This URL is used to compute the
  40086. * sources array.
  40087. *
  40088. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  40089. */
  40090. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40091. var sourceMap = aSourceMap;
  40092. if (typeof aSourceMap === 'string') {
  40093. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40094. }
  40095. var version = util$1.getArg(sourceMap, 'version');
  40096. var sources = util$1.getArg(sourceMap, 'sources');
  40097. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  40098. // requires the array) to play nice here.
  40099. var names = util$1.getArg(sourceMap, 'names', []);
  40100. var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
  40101. var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
  40102. var mappings = util$1.getArg(sourceMap, 'mappings');
  40103. var file = util$1.getArg(sourceMap, 'file', null);
  40104. // Once again, Sass deviates from the spec and supplies the version as a
  40105. // string rather than a number, so we use loose equality checking here.
  40106. if (version != this._version) {
  40107. throw new Error('Unsupported version: ' + version);
  40108. }
  40109. if (sourceRoot) {
  40110. sourceRoot = util$1.normalize(sourceRoot);
  40111. }
  40112. sources = sources
  40113. .map(String)
  40114. // Some source maps produce relative source paths like "./foo.js" instead of
  40115. // "foo.js". Normalize these first so that future comparisons will succeed.
  40116. // See bugzil.la/1090768.
  40117. .map(util$1.normalize)
  40118. // Always ensure that absolute sources are internally stored relative to
  40119. // the source root, if the source root is absolute. Not doing this would
  40120. // be particularly problematic when the source root is a prefix of the
  40121. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  40122. .map(function (source) {
  40123. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  40124. ? util$1.relative(sourceRoot, source)
  40125. : source;
  40126. });
  40127. // Pass `true` below to allow duplicate names and sources. While source maps
  40128. // are intended to be compressed and deduplicated, the TypeScript compiler
  40129. // sometimes generates source maps with duplicates in them. See Github issue
  40130. // #72 and bugzil.la/889492.
  40131. this._names = ArraySet.fromArray(names.map(String), true);
  40132. this._sources = ArraySet.fromArray(sources, true);
  40133. this._absoluteSources = this._sources.toArray().map(function (s) {
  40134. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  40135. });
  40136. this.sourceRoot = sourceRoot;
  40137. this.sourcesContent = sourcesContent;
  40138. this._mappings = mappings;
  40139. this._sourceMapURL = aSourceMapURL;
  40140. this.file = file;
  40141. }
  40142. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40143. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
  40144. /**
  40145. * Utility function to find the index of a source. Returns -1 if not
  40146. * found.
  40147. */
  40148. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  40149. var relativeSource = aSource;
  40150. if (this.sourceRoot != null) {
  40151. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40152. }
  40153. if (this._sources.has(relativeSource)) {
  40154. return this._sources.indexOf(relativeSource);
  40155. }
  40156. // Maybe aSource is an absolute URL as returned by |sources|. In
  40157. // this case we can't simply undo the transform.
  40158. var i;
  40159. for (i = 0; i < this._absoluteSources.length; ++i) {
  40160. if (this._absoluteSources[i] == aSource) {
  40161. return i;
  40162. }
  40163. }
  40164. return -1;
  40165. };
  40166. /**
  40167. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  40168. *
  40169. * @param SourceMapGenerator aSourceMap
  40170. * The source map that will be consumed.
  40171. * @param String aSourceMapURL
  40172. * The URL at which the source map can be found (optional)
  40173. * @returns BasicSourceMapConsumer
  40174. */
  40175. BasicSourceMapConsumer.fromSourceMap =
  40176. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  40177. var smc = Object.create(BasicSourceMapConsumer.prototype);
  40178. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  40179. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  40180. smc.sourceRoot = aSourceMap._sourceRoot;
  40181. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  40182. smc.sourceRoot);
  40183. smc.file = aSourceMap._file;
  40184. smc._sourceMapURL = aSourceMapURL;
  40185. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  40186. return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  40187. });
  40188. // Because we are modifying the entries (by converting string sources and
  40189. // names to indices into the sources and names ArraySets), we have to make
  40190. // a copy of the entry or else bad things happen. Shared mutable state
  40191. // strikes again! See github issue #191.
  40192. var generatedMappings = aSourceMap._mappings.toArray().slice();
  40193. var destGeneratedMappings = smc.__generatedMappings = [];
  40194. var destOriginalMappings = smc.__originalMappings = [];
  40195. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  40196. var srcMapping = generatedMappings[i];
  40197. var destMapping = new Mapping;
  40198. destMapping.generatedLine = srcMapping.generatedLine;
  40199. destMapping.generatedColumn = srcMapping.generatedColumn;
  40200. if (srcMapping.source) {
  40201. destMapping.source = sources.indexOf(srcMapping.source);
  40202. destMapping.originalLine = srcMapping.originalLine;
  40203. destMapping.originalColumn = srcMapping.originalColumn;
  40204. if (srcMapping.name) {
  40205. destMapping.name = names.indexOf(srcMapping.name);
  40206. }
  40207. destOriginalMappings.push(destMapping);
  40208. }
  40209. destGeneratedMappings.push(destMapping);
  40210. }
  40211. quickSort(smc.__originalMappings, util$1.compareByOriginalPositions);
  40212. return smc;
  40213. };
  40214. /**
  40215. * The version of the source mapping spec that we are consuming.
  40216. */
  40217. BasicSourceMapConsumer.prototype._version = 3;
  40218. /**
  40219. * The list of original sources.
  40220. */
  40221. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  40222. get: function () {
  40223. return this._absoluteSources.slice();
  40224. }
  40225. });
  40226. /**
  40227. * Provide the JIT with a nice shape / hidden class.
  40228. */
  40229. function Mapping() {
  40230. this.generatedLine = 0;
  40231. this.generatedColumn = 0;
  40232. this.source = null;
  40233. this.originalLine = null;
  40234. this.originalColumn = null;
  40235. this.name = null;
  40236. }
  40237. /**
  40238. * Parse the mappings in a string in to a data structure which we can easily
  40239. * query (the ordered arrays in the `this.__generatedMappings` and
  40240. * `this.__originalMappings` properties).
  40241. */
  40242. BasicSourceMapConsumer.prototype._parseMappings =
  40243. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40244. var generatedLine = 1;
  40245. var previousGeneratedColumn = 0;
  40246. var previousOriginalLine = 0;
  40247. var previousOriginalColumn = 0;
  40248. var previousSource = 0;
  40249. var previousName = 0;
  40250. var length = aStr.length;
  40251. var index = 0;
  40252. var cachedSegments = {};
  40253. var temp = {};
  40254. var originalMappings = [];
  40255. var generatedMappings = [];
  40256. var mapping, str, segment, end, value;
  40257. while (index < length) {
  40258. if (aStr.charAt(index) === ';') {
  40259. generatedLine++;
  40260. index++;
  40261. previousGeneratedColumn = 0;
  40262. }
  40263. else if (aStr.charAt(index) === ',') {
  40264. index++;
  40265. }
  40266. else {
  40267. mapping = new Mapping();
  40268. mapping.generatedLine = generatedLine;
  40269. // Because each offset is encoded relative to the previous one,
  40270. // many segments often have the same encoding. We can exploit this
  40271. // fact by caching the parsed variable length fields of each segment,
  40272. // allowing us to avoid a second parse if we encounter the same
  40273. // segment again.
  40274. for (end = index; end < length; end++) {
  40275. if (this._charIsMappingSeparator(aStr, end)) {
  40276. break;
  40277. }
  40278. }
  40279. str = aStr.slice(index, end);
  40280. segment = cachedSegments[str];
  40281. if (segment) {
  40282. index += str.length;
  40283. } else {
  40284. segment = [];
  40285. while (index < end) {
  40286. base64VLQ.decode(aStr, index, temp);
  40287. value = temp.value;
  40288. index = temp.rest;
  40289. segment.push(value);
  40290. }
  40291. if (segment.length === 2) {
  40292. throw new Error('Found a source, but no line and column');
  40293. }
  40294. if (segment.length === 3) {
  40295. throw new Error('Found a source and line, but no column');
  40296. }
  40297. cachedSegments[str] = segment;
  40298. }
  40299. // Generated column.
  40300. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  40301. previousGeneratedColumn = mapping.generatedColumn;
  40302. if (segment.length > 1) {
  40303. // Original source.
  40304. mapping.source = previousSource + segment[1];
  40305. previousSource += segment[1];
  40306. // Original line.
  40307. mapping.originalLine = previousOriginalLine + segment[2];
  40308. previousOriginalLine = mapping.originalLine;
  40309. // Lines are stored 0-based
  40310. mapping.originalLine += 1;
  40311. // Original column.
  40312. mapping.originalColumn = previousOriginalColumn + segment[3];
  40313. previousOriginalColumn = mapping.originalColumn;
  40314. if (segment.length > 4) {
  40315. // Original name.
  40316. mapping.name = previousName + segment[4];
  40317. previousName += segment[4];
  40318. }
  40319. }
  40320. generatedMappings.push(mapping);
  40321. if (typeof mapping.originalLine === 'number') {
  40322. originalMappings.push(mapping);
  40323. }
  40324. }
  40325. }
  40326. quickSort(generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40327. this.__generatedMappings = generatedMappings;
  40328. quickSort(originalMappings, util$1.compareByOriginalPositions);
  40329. this.__originalMappings = originalMappings;
  40330. };
  40331. /**
  40332. * Find the mapping that best matches the hypothetical "needle" mapping that
  40333. * we are searching for in the given "haystack" of mappings.
  40334. */
  40335. BasicSourceMapConsumer.prototype._findMapping =
  40336. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  40337. aColumnName, aComparator, aBias) {
  40338. // To return the position we are searching for, we must first find the
  40339. // mapping for the given position and then return the opposite position it
  40340. // points to. Because the mappings are sorted, we can use binary search to
  40341. // find the best mapping.
  40342. if (aNeedle[aLineName] <= 0) {
  40343. throw new TypeError('Line must be greater than or equal to 1, got '
  40344. + aNeedle[aLineName]);
  40345. }
  40346. if (aNeedle[aColumnName] < 0) {
  40347. throw new TypeError('Column must be greater than or equal to 0, got '
  40348. + aNeedle[aColumnName]);
  40349. }
  40350. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  40351. };
  40352. /**
  40353. * Compute the last column for each generated mapping. The last column is
  40354. * inclusive.
  40355. */
  40356. BasicSourceMapConsumer.prototype.computeColumnSpans =
  40357. function SourceMapConsumer_computeColumnSpans() {
  40358. for (var index = 0; index < this._generatedMappings.length; ++index) {
  40359. var mapping = this._generatedMappings[index];
  40360. // Mappings do not contain a field for the last generated columnt. We
  40361. // can come up with an optimistic estimate, however, by assuming that
  40362. // mappings are contiguous (i.e. given two consecutive mappings, the
  40363. // first mapping ends where the second one starts).
  40364. if (index + 1 < this._generatedMappings.length) {
  40365. var nextMapping = this._generatedMappings[index + 1];
  40366. if (mapping.generatedLine === nextMapping.generatedLine) {
  40367. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  40368. continue;
  40369. }
  40370. }
  40371. // The last mapping for each line spans the entire line.
  40372. mapping.lastGeneratedColumn = Infinity;
  40373. }
  40374. };
  40375. /**
  40376. * Returns the original source, line, and column information for the generated
  40377. * source's line and column positions provided. The only argument is an object
  40378. * with the following properties:
  40379. *
  40380. * - line: The line number in the generated source. The line number
  40381. * is 1-based.
  40382. * - column: The column number in the generated source. The column
  40383. * number is 0-based.
  40384. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40385. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40386. * closest element that is smaller than or greater than the one we are
  40387. * searching for, respectively, if the exact element cannot be found.
  40388. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40389. *
  40390. * and an object is returned with the following properties:
  40391. *
  40392. * - source: The original source file, or null.
  40393. * - line: The line number in the original source, or null. The
  40394. * line number is 1-based.
  40395. * - column: The column number in the original source, or null. The
  40396. * column number is 0-based.
  40397. * - name: The original identifier, or null.
  40398. */
  40399. BasicSourceMapConsumer.prototype.originalPositionFor =
  40400. function SourceMapConsumer_originalPositionFor(aArgs) {
  40401. var needle = {
  40402. generatedLine: util$1.getArg(aArgs, 'line'),
  40403. generatedColumn: util$1.getArg(aArgs, 'column')
  40404. };
  40405. var index = this._findMapping(
  40406. needle,
  40407. this._generatedMappings,
  40408. "generatedLine",
  40409. "generatedColumn",
  40410. util$1.compareByGeneratedPositionsDeflated,
  40411. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40412. );
  40413. if (index >= 0) {
  40414. var mapping = this._generatedMappings[index];
  40415. if (mapping.generatedLine === needle.generatedLine) {
  40416. var source = util$1.getArg(mapping, 'source', null);
  40417. if (source !== null) {
  40418. source = this._sources.at(source);
  40419. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  40420. }
  40421. var name = util$1.getArg(mapping, 'name', null);
  40422. if (name !== null) {
  40423. name = this._names.at(name);
  40424. }
  40425. return {
  40426. source: source,
  40427. line: util$1.getArg(mapping, 'originalLine', null),
  40428. column: util$1.getArg(mapping, 'originalColumn', null),
  40429. name: name
  40430. };
  40431. }
  40432. }
  40433. return {
  40434. source: null,
  40435. line: null,
  40436. column: null,
  40437. name: null
  40438. };
  40439. };
  40440. /**
  40441. * Return true if we have the source content for every source in the source
  40442. * map, false otherwise.
  40443. */
  40444. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  40445. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  40446. if (!this.sourcesContent) {
  40447. return false;
  40448. }
  40449. return this.sourcesContent.length >= this._sources.size() &&
  40450. !this.sourcesContent.some(function (sc) { return sc == null; });
  40451. };
  40452. /**
  40453. * Returns the original source content. The only argument is the url of the
  40454. * original source file. Returns null if no original source content is
  40455. * available.
  40456. */
  40457. BasicSourceMapConsumer.prototype.sourceContentFor =
  40458. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40459. if (!this.sourcesContent) {
  40460. return null;
  40461. }
  40462. var index = this._findSourceIndex(aSource);
  40463. if (index >= 0) {
  40464. return this.sourcesContent[index];
  40465. }
  40466. var relativeSource = aSource;
  40467. if (this.sourceRoot != null) {
  40468. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40469. }
  40470. var url;
  40471. if (this.sourceRoot != null
  40472. && (url = util$1.urlParse(this.sourceRoot))) {
  40473. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  40474. // many users. We can help them out when they expect file:// URIs to
  40475. // behave like it would if they were running a local HTTP server. See
  40476. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  40477. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  40478. if (url.scheme == "file"
  40479. && this._sources.has(fileUriAbsPath)) {
  40480. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  40481. }
  40482. if ((!url.path || url.path == "/")
  40483. && this._sources.has("/" + relativeSource)) {
  40484. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  40485. }
  40486. }
  40487. // This function is used recursively from
  40488. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  40489. // don't want to throw if we can't find the source - we just want to
  40490. // return null, so we provide a flag to exit gracefully.
  40491. if (nullOnMissing) {
  40492. return null;
  40493. }
  40494. else {
  40495. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  40496. }
  40497. };
  40498. /**
  40499. * Returns the generated line and column information for the original source,
  40500. * line, and column positions provided. The only argument is an object with
  40501. * the following properties:
  40502. *
  40503. * - source: The filename of the original source.
  40504. * - line: The line number in the original source. The line number
  40505. * is 1-based.
  40506. * - column: The column number in the original source. The column
  40507. * number is 0-based.
  40508. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40509. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40510. * closest element that is smaller than or greater than the one we are
  40511. * searching for, respectively, if the exact element cannot be found.
  40512. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40513. *
  40514. * and an object is returned with the following properties:
  40515. *
  40516. * - line: The line number in the generated source, or null. The
  40517. * line number is 1-based.
  40518. * - column: The column number in the generated source, or null.
  40519. * The column number is 0-based.
  40520. */
  40521. BasicSourceMapConsumer.prototype.generatedPositionFor =
  40522. function SourceMapConsumer_generatedPositionFor(aArgs) {
  40523. var source = util$1.getArg(aArgs, 'source');
  40524. source = this._findSourceIndex(source);
  40525. if (source < 0) {
  40526. return {
  40527. line: null,
  40528. column: null,
  40529. lastColumn: null
  40530. };
  40531. }
  40532. var needle = {
  40533. source: source,
  40534. originalLine: util$1.getArg(aArgs, 'line'),
  40535. originalColumn: util$1.getArg(aArgs, 'column')
  40536. };
  40537. var index = this._findMapping(
  40538. needle,
  40539. this._originalMappings,
  40540. "originalLine",
  40541. "originalColumn",
  40542. util$1.compareByOriginalPositions,
  40543. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40544. );
  40545. if (index >= 0) {
  40546. var mapping = this._originalMappings[index];
  40547. if (mapping.source === needle.source) {
  40548. return {
  40549. line: util$1.getArg(mapping, 'generatedLine', null),
  40550. column: util$1.getArg(mapping, 'generatedColumn', null),
  40551. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40552. };
  40553. }
  40554. }
  40555. return {
  40556. line: null,
  40557. column: null,
  40558. lastColumn: null
  40559. };
  40560. };
  40561. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  40562. /**
  40563. * An IndexedSourceMapConsumer instance represents a parsed source map which
  40564. * we can query for information. It differs from BasicSourceMapConsumer in
  40565. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  40566. * input.
  40567. *
  40568. * The first parameter is a raw source map (either as a JSON string, or already
  40569. * parsed to an object). According to the spec for indexed source maps, they
  40570. * have the following attributes:
  40571. *
  40572. * - version: Which version of the source map spec this map is following.
  40573. * - file: Optional. The generated file this source map is associated with.
  40574. * - sections: A list of section definitions.
  40575. *
  40576. * Each value under the "sections" field has two fields:
  40577. * - offset: The offset into the original specified at which this section
  40578. * begins to apply, defined as an object with a "line" and "column"
  40579. * field.
  40580. * - map: A source map definition. This source map could also be indexed,
  40581. * but doesn't have to be.
  40582. *
  40583. * Instead of the "map" field, it's also possible to have a "url" field
  40584. * specifying a URL to retrieve a source map from, but that's currently
  40585. * unsupported.
  40586. *
  40587. * Here's an example source map, taken from the source map spec[0], but
  40588. * modified to omit a section which uses the "url" field.
  40589. *
  40590. * {
  40591. * version : 3,
  40592. * file: "app.js",
  40593. * sections: [{
  40594. * offset: {line:100, column:10},
  40595. * map: {
  40596. * version : 3,
  40597. * file: "section.js",
  40598. * sources: ["foo.js", "bar.js"],
  40599. * names: ["src", "maps", "are", "fun"],
  40600. * mappings: "AAAA,E;;ABCDE;"
  40601. * }
  40602. * }],
  40603. * }
  40604. *
  40605. * The second parameter, if given, is a string whose value is the URL
  40606. * at which the source map was found. This URL is used to compute the
  40607. * sources array.
  40608. *
  40609. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  40610. */
  40611. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40612. var sourceMap = aSourceMap;
  40613. if (typeof aSourceMap === 'string') {
  40614. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40615. }
  40616. var version = util$1.getArg(sourceMap, 'version');
  40617. var sections = util$1.getArg(sourceMap, 'sections');
  40618. if (version != this._version) {
  40619. throw new Error('Unsupported version: ' + version);
  40620. }
  40621. this._sources = new ArraySet();
  40622. this._names = new ArraySet();
  40623. var lastOffset = {
  40624. line: -1,
  40625. column: 0
  40626. };
  40627. this._sections = sections.map(function (s) {
  40628. if (s.url) {
  40629. // The url field will require support for asynchronicity.
  40630. // See https://github.com/mozilla/source-map/issues/16
  40631. throw new Error('Support for url field in sections not implemented.');
  40632. }
  40633. var offset = util$1.getArg(s, 'offset');
  40634. var offsetLine = util$1.getArg(offset, 'line');
  40635. var offsetColumn = util$1.getArg(offset, 'column');
  40636. if (offsetLine < lastOffset.line ||
  40637. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  40638. throw new Error('Section offsets must be ordered and non-overlapping.');
  40639. }
  40640. lastOffset = offset;
  40641. return {
  40642. generatedOffset: {
  40643. // The offset fields are 0-based, but we use 1-based indices when
  40644. // encoding/decoding from VLQ.
  40645. generatedLine: offsetLine + 1,
  40646. generatedColumn: offsetColumn + 1
  40647. },
  40648. consumer: new SourceMapConsumer$1(util$1.getArg(s, 'map'), aSourceMapURL)
  40649. }
  40650. });
  40651. }
  40652. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40653. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer$1;
  40654. /**
  40655. * The version of the source mapping spec that we are consuming.
  40656. */
  40657. IndexedSourceMapConsumer.prototype._version = 3;
  40658. /**
  40659. * The list of original sources.
  40660. */
  40661. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  40662. get: function () {
  40663. var sources = [];
  40664. for (var i = 0; i < this._sections.length; i++) {
  40665. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  40666. sources.push(this._sections[i].consumer.sources[j]);
  40667. }
  40668. }
  40669. return sources;
  40670. }
  40671. });
  40672. /**
  40673. * Returns the original source, line, and column information for the generated
  40674. * source's line and column positions provided. The only argument is an object
  40675. * with the following properties:
  40676. *
  40677. * - line: The line number in the generated source. The line number
  40678. * is 1-based.
  40679. * - column: The column number in the generated source. The column
  40680. * number is 0-based.
  40681. *
  40682. * and an object is returned with the following properties:
  40683. *
  40684. * - source: The original source file, or null.
  40685. * - line: The line number in the original source, or null. The
  40686. * line number is 1-based.
  40687. * - column: The column number in the original source, or null. The
  40688. * column number is 0-based.
  40689. * - name: The original identifier, or null.
  40690. */
  40691. IndexedSourceMapConsumer.prototype.originalPositionFor =
  40692. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  40693. var needle = {
  40694. generatedLine: util$1.getArg(aArgs, 'line'),
  40695. generatedColumn: util$1.getArg(aArgs, 'column')
  40696. };
  40697. // Find the section containing the generated position we're trying to map
  40698. // to an original position.
  40699. var sectionIndex = binarySearch.search(needle, this._sections,
  40700. function(needle, section) {
  40701. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  40702. if (cmp) {
  40703. return cmp;
  40704. }
  40705. return (needle.generatedColumn -
  40706. section.generatedOffset.generatedColumn);
  40707. });
  40708. var section = this._sections[sectionIndex];
  40709. if (!section) {
  40710. return {
  40711. source: null,
  40712. line: null,
  40713. column: null,
  40714. name: null
  40715. };
  40716. }
  40717. return section.consumer.originalPositionFor({
  40718. line: needle.generatedLine -
  40719. (section.generatedOffset.generatedLine - 1),
  40720. column: needle.generatedColumn -
  40721. (section.generatedOffset.generatedLine === needle.generatedLine
  40722. ? section.generatedOffset.generatedColumn - 1
  40723. : 0),
  40724. bias: aArgs.bias
  40725. });
  40726. };
  40727. /**
  40728. * Return true if we have the source content for every source in the source
  40729. * map, false otherwise.
  40730. */
  40731. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  40732. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  40733. return this._sections.every(function (s) {
  40734. return s.consumer.hasContentsOfAllSources();
  40735. });
  40736. };
  40737. /**
  40738. * Returns the original source content. The only argument is the url of the
  40739. * original source file. Returns null if no original source content is
  40740. * available.
  40741. */
  40742. IndexedSourceMapConsumer.prototype.sourceContentFor =
  40743. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40744. for (var i = 0; i < this._sections.length; i++) {
  40745. var section = this._sections[i];
  40746. var content = section.consumer.sourceContentFor(aSource, true);
  40747. if (content) {
  40748. return content;
  40749. }
  40750. }
  40751. if (nullOnMissing) {
  40752. return null;
  40753. }
  40754. else {
  40755. throw new Error('"' + aSource + '" is not in the SourceMap.');
  40756. }
  40757. };
  40758. /**
  40759. * Returns the generated line and column information for the original source,
  40760. * line, and column positions provided. The only argument is an object with
  40761. * the following properties:
  40762. *
  40763. * - source: The filename of the original source.
  40764. * - line: The line number in the original source. The line number
  40765. * is 1-based.
  40766. * - column: The column number in the original source. The column
  40767. * number is 0-based.
  40768. *
  40769. * and an object is returned with the following properties:
  40770. *
  40771. * - line: The line number in the generated source, or null. The
  40772. * line number is 1-based.
  40773. * - column: The column number in the generated source, or null.
  40774. * The column number is 0-based.
  40775. */
  40776. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  40777. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  40778. for (var i = 0; i < this._sections.length; i++) {
  40779. var section = this._sections[i];
  40780. // Only consider this section if the requested source is in the list of
  40781. // sources of the consumer.
  40782. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
  40783. continue;
  40784. }
  40785. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  40786. if (generatedPosition) {
  40787. var ret = {
  40788. line: generatedPosition.line +
  40789. (section.generatedOffset.generatedLine - 1),
  40790. column: generatedPosition.column +
  40791. (section.generatedOffset.generatedLine === generatedPosition.line
  40792. ? section.generatedOffset.generatedColumn - 1
  40793. : 0)
  40794. };
  40795. return ret;
  40796. }
  40797. }
  40798. return {
  40799. line: null,
  40800. column: null
  40801. };
  40802. };
  40803. /**
  40804. * Parse the mappings in a string in to a data structure which we can easily
  40805. * query (the ordered arrays in the `this.__generatedMappings` and
  40806. * `this.__originalMappings` properties).
  40807. */
  40808. IndexedSourceMapConsumer.prototype._parseMappings =
  40809. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40810. this.__generatedMappings = [];
  40811. this.__originalMappings = [];
  40812. for (var i = 0; i < this._sections.length; i++) {
  40813. var section = this._sections[i];
  40814. var sectionMappings = section.consumer._generatedMappings;
  40815. for (var j = 0; j < sectionMappings.length; j++) {
  40816. var mapping = sectionMappings[j];
  40817. var source = section.consumer._sources.at(mapping.source);
  40818. source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  40819. this._sources.add(source);
  40820. source = this._sources.indexOf(source);
  40821. var name = null;
  40822. if (mapping.name) {
  40823. name = section.consumer._names.at(mapping.name);
  40824. this._names.add(name);
  40825. name = this._names.indexOf(name);
  40826. }
  40827. // The mappings coming from the consumer for the section have
  40828. // generated positions relative to the start of the section, so we
  40829. // need to offset them to be relative to the start of the concatenated
  40830. // generated file.
  40831. var adjustedMapping = {
  40832. source: source,
  40833. generatedLine: mapping.generatedLine +
  40834. (section.generatedOffset.generatedLine - 1),
  40835. generatedColumn: mapping.generatedColumn +
  40836. (section.generatedOffset.generatedLine === mapping.generatedLine
  40837. ? section.generatedOffset.generatedColumn - 1
  40838. : 0),
  40839. originalLine: mapping.originalLine,
  40840. originalColumn: mapping.originalColumn,
  40841. name: name
  40842. };
  40843. this.__generatedMappings.push(adjustedMapping);
  40844. if (typeof adjustedMapping.originalLine === 'number') {
  40845. this.__originalMappings.push(adjustedMapping);
  40846. }
  40847. }
  40848. }
  40849. quickSort(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40850. quickSort(this.__originalMappings, util$1.compareByOriginalPositions);
  40851. };
  40852. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  40853. var sourceNode = {};
  40854. /* -*- Mode: js; js-indent-level: 2; -*- */
  40855. /*
  40856. * Copyright 2011 Mozilla Foundation and contributors
  40857. * Licensed under the New BSD license. See LICENSE or:
  40858. * http://opensource.org/licenses/BSD-3-Clause
  40859. */
  40860. var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator;
  40861. var util = util$5;
  40862. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  40863. // operating systems these days (capturing the result).
  40864. var REGEX_NEWLINE = /(\r?\n)/;
  40865. // Newline character code for charCodeAt() comparisons
  40866. var NEWLINE_CODE = 10;
  40867. // Private symbol for identifying `SourceNode`s when multiple versions of
  40868. // the source-map library are loaded. This MUST NOT CHANGE across
  40869. // versions!
  40870. var isSourceNode = "$$$isSourceNode$$$";
  40871. /**
  40872. * SourceNodes provide a way to abstract over interpolating/concatenating
  40873. * snippets of generated JavaScript source code while maintaining the line and
  40874. * column information associated with the original source code.
  40875. *
  40876. * @param aLine The original line number.
  40877. * @param aColumn The original column number.
  40878. * @param aSource The original source's filename.
  40879. * @param aChunks Optional. An array of strings which are snippets of
  40880. * generated JS, or other SourceNodes.
  40881. * @param aName The original identifier.
  40882. */
  40883. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  40884. this.children = [];
  40885. this.sourceContents = {};
  40886. this.line = aLine == null ? null : aLine;
  40887. this.column = aColumn == null ? null : aColumn;
  40888. this.source = aSource == null ? null : aSource;
  40889. this.name = aName == null ? null : aName;
  40890. this[isSourceNode] = true;
  40891. if (aChunks != null) this.add(aChunks);
  40892. }
  40893. /**
  40894. * Creates a SourceNode from generated code and a SourceMapConsumer.
  40895. *
  40896. * @param aGeneratedCode The generated code
  40897. * @param aSourceMapConsumer The SourceMap for the generated code
  40898. * @param aRelativePath Optional. The path that relative sources in the
  40899. * SourceMapConsumer should be relative to.
  40900. */
  40901. SourceNode.fromStringWithSourceMap =
  40902. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  40903. // The SourceNode we want to fill with the generated code
  40904. // and the SourceMap
  40905. var node = new SourceNode();
  40906. // All even indices of this array are one line of the generated code,
  40907. // while all odd indices are the newlines between two adjacent lines
  40908. // (since `REGEX_NEWLINE` captures its match).
  40909. // Processed fragments are accessed by calling `shiftNextLine`.
  40910. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  40911. var remainingLinesIndex = 0;
  40912. var shiftNextLine = function() {
  40913. var lineContents = getNextLine();
  40914. // The last line of a file might not have a newline.
  40915. var newLine = getNextLine() || "";
  40916. return lineContents + newLine;
  40917. function getNextLine() {
  40918. return remainingLinesIndex < remainingLines.length ?
  40919. remainingLines[remainingLinesIndex++] : undefined;
  40920. }
  40921. };
  40922. // We need to remember the position of "remainingLines"
  40923. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  40924. // The generate SourceNodes we need a code range.
  40925. // To extract it current and last mapping is used.
  40926. // Here we store the last mapping.
  40927. var lastMapping = null;
  40928. aSourceMapConsumer.eachMapping(function (mapping) {
  40929. if (lastMapping !== null) {
  40930. // We add the code from "lastMapping" to "mapping":
  40931. // First check if there is a new line in between.
  40932. if (lastGeneratedLine < mapping.generatedLine) {
  40933. // Associate first line with "lastMapping"
  40934. addMappingWithCode(lastMapping, shiftNextLine());
  40935. lastGeneratedLine++;
  40936. lastGeneratedColumn = 0;
  40937. // The remaining code is added without mapping
  40938. } else {
  40939. // There is no new line in between.
  40940. // Associate the code between "lastGeneratedColumn" and
  40941. // "mapping.generatedColumn" with "lastMapping"
  40942. var nextLine = remainingLines[remainingLinesIndex] || '';
  40943. var code = nextLine.substr(0, mapping.generatedColumn -
  40944. lastGeneratedColumn);
  40945. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  40946. lastGeneratedColumn);
  40947. lastGeneratedColumn = mapping.generatedColumn;
  40948. addMappingWithCode(lastMapping, code);
  40949. // No more remaining code, continue
  40950. lastMapping = mapping;
  40951. return;
  40952. }
  40953. }
  40954. // We add the generated code until the first mapping
  40955. // to the SourceNode without any mapping.
  40956. // Each line is added as separate string.
  40957. while (lastGeneratedLine < mapping.generatedLine) {
  40958. node.add(shiftNextLine());
  40959. lastGeneratedLine++;
  40960. }
  40961. if (lastGeneratedColumn < mapping.generatedColumn) {
  40962. var nextLine = remainingLines[remainingLinesIndex] || '';
  40963. node.add(nextLine.substr(0, mapping.generatedColumn));
  40964. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  40965. lastGeneratedColumn = mapping.generatedColumn;
  40966. }
  40967. lastMapping = mapping;
  40968. }, this);
  40969. // We have processed all mappings.
  40970. if (remainingLinesIndex < remainingLines.length) {
  40971. if (lastMapping) {
  40972. // Associate the remaining code in the current line with "lastMapping"
  40973. addMappingWithCode(lastMapping, shiftNextLine());
  40974. }
  40975. // and add the remaining lines without any mapping
  40976. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  40977. }
  40978. // Copy sourcesContent into SourceNode
  40979. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  40980. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  40981. if (content != null) {
  40982. if (aRelativePath != null) {
  40983. sourceFile = util.join(aRelativePath, sourceFile);
  40984. }
  40985. node.setSourceContent(sourceFile, content);
  40986. }
  40987. });
  40988. return node;
  40989. function addMappingWithCode(mapping, code) {
  40990. if (mapping === null || mapping.source === undefined) {
  40991. node.add(code);
  40992. } else {
  40993. var source = aRelativePath
  40994. ? util.join(aRelativePath, mapping.source)
  40995. : mapping.source;
  40996. node.add(new SourceNode(mapping.originalLine,
  40997. mapping.originalColumn,
  40998. source,
  40999. code,
  41000. mapping.name));
  41001. }
  41002. }
  41003. };
  41004. /**
  41005. * Add a chunk of generated JS to this source node.
  41006. *
  41007. * @param aChunk A string snippet of generated JS code, another instance of
  41008. * SourceNode, or an array where each member is one of those things.
  41009. */
  41010. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  41011. if (Array.isArray(aChunk)) {
  41012. aChunk.forEach(function (chunk) {
  41013. this.add(chunk);
  41014. }, this);
  41015. }
  41016. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41017. if (aChunk) {
  41018. this.children.push(aChunk);
  41019. }
  41020. }
  41021. else {
  41022. throw new TypeError(
  41023. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41024. );
  41025. }
  41026. return this;
  41027. };
  41028. /**
  41029. * Add a chunk of generated JS to the beginning of this source node.
  41030. *
  41031. * @param aChunk A string snippet of generated JS code, another instance of
  41032. * SourceNode, or an array where each member is one of those things.
  41033. */
  41034. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  41035. if (Array.isArray(aChunk)) {
  41036. for (var i = aChunk.length-1; i >= 0; i--) {
  41037. this.prepend(aChunk[i]);
  41038. }
  41039. }
  41040. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41041. this.children.unshift(aChunk);
  41042. }
  41043. else {
  41044. throw new TypeError(
  41045. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41046. );
  41047. }
  41048. return this;
  41049. };
  41050. /**
  41051. * Walk over the tree of JS snippets in this node and its children. The
  41052. * walking function is called once for each snippet of JS and is passed that
  41053. * snippet and the its original associated source's line/column location.
  41054. *
  41055. * @param aFn The traversal function.
  41056. */
  41057. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  41058. var chunk;
  41059. for (var i = 0, len = this.children.length; i < len; i++) {
  41060. chunk = this.children[i];
  41061. if (chunk[isSourceNode]) {
  41062. chunk.walk(aFn);
  41063. }
  41064. else {
  41065. if (chunk !== '') {
  41066. aFn(chunk, { source: this.source,
  41067. line: this.line,
  41068. column: this.column,
  41069. name: this.name });
  41070. }
  41071. }
  41072. }
  41073. };
  41074. /**
  41075. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  41076. * each of `this.children`.
  41077. *
  41078. * @param aSep The separator.
  41079. */
  41080. SourceNode.prototype.join = function SourceNode_join(aSep) {
  41081. var newChildren;
  41082. var i;
  41083. var len = this.children.length;
  41084. if (len > 0) {
  41085. newChildren = [];
  41086. for (i = 0; i < len-1; i++) {
  41087. newChildren.push(this.children[i]);
  41088. newChildren.push(aSep);
  41089. }
  41090. newChildren.push(this.children[i]);
  41091. this.children = newChildren;
  41092. }
  41093. return this;
  41094. };
  41095. /**
  41096. * Call String.prototype.replace on the very right-most source snippet. Useful
  41097. * for trimming whitespace from the end of a source node, etc.
  41098. *
  41099. * @param aPattern The pattern to replace.
  41100. * @param aReplacement The thing to replace the pattern with.
  41101. */
  41102. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  41103. var lastChild = this.children[this.children.length - 1];
  41104. if (lastChild[isSourceNode]) {
  41105. lastChild.replaceRight(aPattern, aReplacement);
  41106. }
  41107. else if (typeof lastChild === 'string') {
  41108. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  41109. }
  41110. else {
  41111. this.children.push(''.replace(aPattern, aReplacement));
  41112. }
  41113. return this;
  41114. };
  41115. /**
  41116. * Set the source content for a source file. This will be added to the SourceMapGenerator
  41117. * in the sourcesContent field.
  41118. *
  41119. * @param aSourceFile The filename of the source file
  41120. * @param aSourceContent The content of the source file
  41121. */
  41122. SourceNode.prototype.setSourceContent =
  41123. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  41124. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  41125. };
  41126. /**
  41127. * Walk over the tree of SourceNodes. The walking function is called for each
  41128. * source file content and is passed the filename and source content.
  41129. *
  41130. * @param aFn The traversal function.
  41131. */
  41132. SourceNode.prototype.walkSourceContents =
  41133. function SourceNode_walkSourceContents(aFn) {
  41134. for (var i = 0, len = this.children.length; i < len; i++) {
  41135. if (this.children[i][isSourceNode]) {
  41136. this.children[i].walkSourceContents(aFn);
  41137. }
  41138. }
  41139. var sources = Object.keys(this.sourceContents);
  41140. for (var i = 0, len = sources.length; i < len; i++) {
  41141. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  41142. }
  41143. };
  41144. /**
  41145. * Return the string representation of this source node. Walks over the tree
  41146. * and concatenates all the various snippets together to one string.
  41147. */
  41148. SourceNode.prototype.toString = function SourceNode_toString() {
  41149. var str = "";
  41150. this.walk(function (chunk) {
  41151. str += chunk;
  41152. });
  41153. return str;
  41154. };
  41155. /**
  41156. * Returns the string representation of this source node along with a source
  41157. * map.
  41158. */
  41159. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  41160. var generated = {
  41161. code: "",
  41162. line: 1,
  41163. column: 0
  41164. };
  41165. var map = new SourceMapGenerator$1(aArgs);
  41166. var sourceMappingActive = false;
  41167. var lastOriginalSource = null;
  41168. var lastOriginalLine = null;
  41169. var lastOriginalColumn = null;
  41170. var lastOriginalName = null;
  41171. this.walk(function (chunk, original) {
  41172. generated.code += chunk;
  41173. if (original.source !== null
  41174. && original.line !== null
  41175. && original.column !== null) {
  41176. if(lastOriginalSource !== original.source
  41177. || lastOriginalLine !== original.line
  41178. || lastOriginalColumn !== original.column
  41179. || lastOriginalName !== original.name) {
  41180. map.addMapping({
  41181. source: original.source,
  41182. original: {
  41183. line: original.line,
  41184. column: original.column
  41185. },
  41186. generated: {
  41187. line: generated.line,
  41188. column: generated.column
  41189. },
  41190. name: original.name
  41191. });
  41192. }
  41193. lastOriginalSource = original.source;
  41194. lastOriginalLine = original.line;
  41195. lastOriginalColumn = original.column;
  41196. lastOriginalName = original.name;
  41197. sourceMappingActive = true;
  41198. } else if (sourceMappingActive) {
  41199. map.addMapping({
  41200. generated: {
  41201. line: generated.line,
  41202. column: generated.column
  41203. }
  41204. });
  41205. lastOriginalSource = null;
  41206. sourceMappingActive = false;
  41207. }
  41208. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  41209. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  41210. generated.line++;
  41211. generated.column = 0;
  41212. // Mappings end at eol
  41213. if (idx + 1 === length) {
  41214. lastOriginalSource = null;
  41215. sourceMappingActive = false;
  41216. } else if (sourceMappingActive) {
  41217. map.addMapping({
  41218. source: original.source,
  41219. original: {
  41220. line: original.line,
  41221. column: original.column
  41222. },
  41223. generated: {
  41224. line: generated.line,
  41225. column: generated.column
  41226. },
  41227. name: original.name
  41228. });
  41229. }
  41230. } else {
  41231. generated.column++;
  41232. }
  41233. }
  41234. });
  41235. this.walkSourceContents(function (sourceFile, sourceContent) {
  41236. map.setSourceContent(sourceFile, sourceContent);
  41237. });
  41238. return { code: generated.code, map: map };
  41239. };
  41240. sourceNode.SourceNode = SourceNode;
  41241. /*
  41242. * Copyright 2009-2011 Mozilla Foundation and contributors
  41243. * Licensed under the New BSD license. See LICENSE.txt or:
  41244. * http://opensource.org/licenses/BSD-3-Clause
  41245. */
  41246. sourceMap$1.SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  41247. sourceMap$1.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  41248. sourceMap$1.SourceNode = sourceNode.SourceNode;
  41249. var sourceMap = sourceMap$1;
  41250. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  41251. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  41252. var mergeSourceMap = merge;
  41253. /**
  41254. * Merge old source map and new source map and return merged.
  41255. * If old or new source map value is falsy, return another one as it is.
  41256. *
  41257. * @param {object|string} [oldMap] old source map object
  41258. * @param {object|string} [newmap] new source map object
  41259. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  41260. */
  41261. function merge(oldMap, newMap) {
  41262. if (!oldMap) return newMap
  41263. if (!newMap) return oldMap
  41264. var oldMapConsumer = new SourceMapConsumer(oldMap);
  41265. var newMapConsumer = new SourceMapConsumer(newMap);
  41266. var mergedMapGenerator = new SourceMapGenerator();
  41267. // iterate on new map and overwrite original position of new map with one of old map
  41268. newMapConsumer.eachMapping(function(m) {
  41269. // pass when `originalLine` is null.
  41270. // It occurs in case that the node does not have origin in original code.
  41271. if (m.originalLine == null) return
  41272. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  41273. line: m.originalLine,
  41274. column: m.originalColumn
  41275. });
  41276. if (origPosInOldMap.source == null) return
  41277. mergedMapGenerator.addMapping({
  41278. original: {
  41279. line: origPosInOldMap.line,
  41280. column: origPosInOldMap.column
  41281. },
  41282. generated: {
  41283. line: m.generatedLine,
  41284. column: m.generatedColumn
  41285. },
  41286. source: origPosInOldMap.source,
  41287. name: origPosInOldMap.name
  41288. });
  41289. });
  41290. var consumers = [oldMapConsumer, newMapConsumer];
  41291. consumers.forEach(function(consumer) {
  41292. consumer.sources.forEach(function(sourceFile) {
  41293. mergedMapGenerator._sources.add(sourceFile);
  41294. var sourceContent = consumer.sourceContentFor(sourceFile);
  41295. if (sourceContent != null) {
  41296. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  41297. }
  41298. });
  41299. });
  41300. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  41301. mergedMapGenerator._file = oldMap.file;
  41302. return JSON.parse(mergedMapGenerator.toString())
  41303. }
  41304. var merge$1 = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMap);
  41305. var __defProp$5 = Object.defineProperty;
  41306. var __defProps$4 = Object.defineProperties;
  41307. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  41308. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  41309. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  41310. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  41311. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41312. var __spreadValues$5 = (a, b) => {
  41313. for (var prop in b || (b = {}))
  41314. if (__hasOwnProp$5.call(b, prop))
  41315. __defNormalProp$5(a, prop, b[prop]);
  41316. if (__getOwnPropSymbols$5)
  41317. for (var prop of __getOwnPropSymbols$5(b)) {
  41318. if (__propIsEnum$5.call(b, prop))
  41319. __defNormalProp$5(a, prop, b[prop]);
  41320. }
  41321. return a;
  41322. };
  41323. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  41324. const scss = (source, map, options, load = require) => {
  41325. const nodeSass = load("sass");
  41326. const finalOptions = __spreadProps$4(__spreadValues$5({}, options), {
  41327. data: getSource(source, options.filename, options.additionalData),
  41328. file: options.filename,
  41329. outFile: options.filename,
  41330. sourceMap: !!map
  41331. });
  41332. try {
  41333. const result = nodeSass.renderSync(finalOptions);
  41334. const dependencies = result.stats.includedFiles;
  41335. if (map) {
  41336. return {
  41337. code: result.css.toString(),
  41338. map: merge$1(map, JSON.parse(result.map.toString())),
  41339. errors: [],
  41340. dependencies
  41341. };
  41342. }
  41343. return { code: result.css.toString(), errors: [], dependencies };
  41344. } catch (e) {
  41345. return { code: "", errors: [e], dependencies: [] };
  41346. }
  41347. };
  41348. const sass = (source, map, options, load) => scss(
  41349. source,
  41350. map,
  41351. __spreadProps$4(__spreadValues$5({}, options), {
  41352. indentedSyntax: true
  41353. }),
  41354. load
  41355. );
  41356. const less = (source, map, options, load = require) => {
  41357. const nodeLess = load("less");
  41358. let result;
  41359. let error = null;
  41360. nodeLess.render(
  41361. getSource(source, options.filename, options.additionalData),
  41362. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  41363. (err, output) => {
  41364. error = err;
  41365. result = output;
  41366. }
  41367. );
  41368. if (error)
  41369. return { code: "", errors: [error], dependencies: [] };
  41370. const dependencies = result.imports;
  41371. if (map) {
  41372. return {
  41373. code: result.css.toString(),
  41374. map: merge$1(map, result.map),
  41375. errors: [],
  41376. dependencies
  41377. };
  41378. }
  41379. return {
  41380. code: result.css.toString(),
  41381. errors: [],
  41382. dependencies
  41383. };
  41384. };
  41385. const styl = (source, map, options, load = require) => {
  41386. const nodeStylus = load("stylus");
  41387. try {
  41388. const ref = nodeStylus(source, options);
  41389. if (map)
  41390. ref.set("sourcemap", { inline: false, comment: false });
  41391. const result = ref.render();
  41392. const dependencies = ref.deps();
  41393. if (map) {
  41394. return {
  41395. code: result,
  41396. map: merge$1(map, ref.sourcemap),
  41397. errors: [],
  41398. dependencies
  41399. };
  41400. }
  41401. return { code: result, errors: [], dependencies };
  41402. } catch (e) {
  41403. return { code: "", errors: [e], dependencies: [] };
  41404. }
  41405. };
  41406. function getSource(source, filename, additionalData) {
  41407. if (!additionalData)
  41408. return source;
  41409. if (isFunction$1(additionalData)) {
  41410. return additionalData(source, filename);
  41411. }
  41412. return additionalData + source;
  41413. }
  41414. const processors = {
  41415. less,
  41416. sass,
  41417. scss,
  41418. styl,
  41419. stylus: styl
  41420. };
  41421. var __defProp$4 = Object.defineProperty;
  41422. var __defProps$3 = Object.defineProperties;
  41423. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  41424. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  41425. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  41426. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  41427. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41428. var __spreadValues$4 = (a, b) => {
  41429. for (var prop in b || (b = {}))
  41430. if (__hasOwnProp$4.call(b, prop))
  41431. __defNormalProp$4(a, prop, b[prop]);
  41432. if (__getOwnPropSymbols$4)
  41433. for (var prop of __getOwnPropSymbols$4(b)) {
  41434. if (__propIsEnum$4.call(b, prop))
  41435. __defNormalProp$4(a, prop, b[prop]);
  41436. }
  41437. return a;
  41438. };
  41439. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  41440. function compileStyle(options) {
  41441. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41442. isAsync: false
  41443. }));
  41444. }
  41445. function compileStyleAsync(options) {
  41446. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41447. isAsync: true
  41448. }));
  41449. }
  41450. function doCompileStyle(options) {
  41451. const {
  41452. filename,
  41453. id,
  41454. scoped = false,
  41455. trim = true,
  41456. isProd = false,
  41457. modules = false,
  41458. modulesOptions = {},
  41459. preprocessLang,
  41460. postcssOptions,
  41461. postcssPlugins
  41462. } = options;
  41463. const preprocessor = preprocessLang && processors[preprocessLang];
  41464. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  41465. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  41466. const source = preProcessedSource ? preProcessedSource.code : options.source;
  41467. const shortId = id.replace(/^data-v-/, "");
  41468. const longId = `data-v-${shortId}`;
  41469. const plugins = (postcssPlugins || []).slice();
  41470. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  41471. if (trim) {
  41472. plugins.push(trimPlugin());
  41473. }
  41474. if (scoped) {
  41475. plugins.push(scopedPlugin(longId));
  41476. }
  41477. let cssModules;
  41478. if (modules) {
  41479. {
  41480. throw new Error(
  41481. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  41482. );
  41483. }
  41484. }
  41485. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  41486. to: filename,
  41487. from: filename
  41488. });
  41489. if (map) {
  41490. postCSSOptions.map = {
  41491. inline: false,
  41492. annotation: false,
  41493. prev: map
  41494. };
  41495. }
  41496. let result;
  41497. let code;
  41498. let outMap;
  41499. const dependencies = new Set(
  41500. preProcessedSource ? preProcessedSource.dependencies : []
  41501. );
  41502. dependencies.delete(filename);
  41503. const errors = [];
  41504. if (preProcessedSource && preProcessedSource.errors.length) {
  41505. errors.push(...preProcessedSource.errors);
  41506. }
  41507. const recordPlainCssDependencies = (messages) => {
  41508. messages.forEach((msg) => {
  41509. if (msg.type === "dependency") {
  41510. dependencies.add(msg.file);
  41511. }
  41512. });
  41513. return dependencies;
  41514. };
  41515. try {
  41516. result = postcss$1(plugins).process(source, postCSSOptions);
  41517. if (options.isAsync) {
  41518. return result.then((result2) => ({
  41519. code: result2.css || "",
  41520. map: result2.map && result2.map.toJSON(),
  41521. errors,
  41522. modules: cssModules,
  41523. rawResult: result2,
  41524. dependencies: recordPlainCssDependencies(result2.messages)
  41525. })).catch((error) => ({
  41526. code: "",
  41527. map: void 0,
  41528. errors: [...errors, error],
  41529. rawResult: void 0,
  41530. dependencies
  41531. }));
  41532. }
  41533. recordPlainCssDependencies(result.messages);
  41534. code = result.css;
  41535. outMap = result.map;
  41536. } catch (e) {
  41537. errors.push(e);
  41538. }
  41539. return {
  41540. code: code || ``,
  41541. map: outMap && outMap.toJSON(),
  41542. errors,
  41543. rawResult: result,
  41544. dependencies
  41545. };
  41546. }
  41547. function preprocess(options, preprocessor) {
  41548. if (!options.preprocessCustomRequire) {
  41549. throw new Error(
  41550. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  41551. );
  41552. }
  41553. return preprocessor(
  41554. options.source,
  41555. options.inMap || options.map,
  41556. __spreadValues$4({
  41557. filename: options.filename
  41558. }, options.preprocessOptions),
  41559. options.preprocessCustomRequire
  41560. );
  41561. }
  41562. function analyzeScriptBindings(ast) {
  41563. for (const node of ast) {
  41564. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  41565. return analyzeBindingsFromOptions(node.declaration);
  41566. }
  41567. }
  41568. return {};
  41569. }
  41570. function analyzeBindingsFromOptions(node) {
  41571. const bindings = {};
  41572. Object.defineProperty(bindings, "__isScriptSetup", {
  41573. enumerable: false,
  41574. value: false
  41575. });
  41576. for (const property of node.properties) {
  41577. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  41578. if (property.key.name === "props") {
  41579. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41580. bindings[key] = "props";
  41581. }
  41582. } else if (property.key.name === "inject") {
  41583. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41584. bindings[key] = "options";
  41585. }
  41586. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  41587. for (const key of getObjectExpressionKeys(property.value)) {
  41588. bindings[key] = "options";
  41589. }
  41590. }
  41591. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  41592. for (const bodyItem of property.body.body) {
  41593. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  41594. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  41595. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  41596. }
  41597. }
  41598. }
  41599. }
  41600. }
  41601. return bindings;
  41602. }
  41603. function getObjectExpressionKeys(node) {
  41604. const keys = [];
  41605. for (const prop of node.properties) {
  41606. if (prop.type === "SpreadElement")
  41607. continue;
  41608. const key = resolveObjectKey(prop.key, prop.computed);
  41609. if (key)
  41610. keys.push(String(key));
  41611. }
  41612. return keys;
  41613. }
  41614. function getArrayExpressionKeys(node) {
  41615. const keys = [];
  41616. for (const element of node.elements) {
  41617. if (element && element.type === "StringLiteral") {
  41618. keys.push(element.value);
  41619. }
  41620. }
  41621. return keys;
  41622. }
  41623. function getObjectOrArrayExpressionKeys(value) {
  41624. if (value.type === "ArrayExpression") {
  41625. return getArrayExpressionKeys(value);
  41626. }
  41627. if (value.type === "ObjectExpression") {
  41628. return getObjectExpressionKeys(value);
  41629. }
  41630. return [];
  41631. }
  41632. const comma = ','.charCodeAt(0);
  41633. const semicolon = ';'.charCodeAt(0);
  41634. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  41635. const intToChar = new Uint8Array(64); // 64 possible chars.
  41636. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  41637. for (let i = 0; i < chars.length; i++) {
  41638. const c = chars.charCodeAt(i);
  41639. intToChar[i] = c;
  41640. charToInt[c] = i;
  41641. }
  41642. // Provide a fallback for older environments.
  41643. const td = typeof TextDecoder !== 'undefined'
  41644. ? /* #__PURE__ */ new TextDecoder()
  41645. : typeof Buffer !== 'undefined'
  41646. ? {
  41647. decode(buf) {
  41648. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  41649. return out.toString();
  41650. },
  41651. }
  41652. : {
  41653. decode(buf) {
  41654. let out = '';
  41655. for (let i = 0; i < buf.length; i++) {
  41656. out += String.fromCharCode(buf[i]);
  41657. }
  41658. return out;
  41659. },
  41660. };
  41661. function encode(decoded) {
  41662. const state = new Int32Array(5);
  41663. const bufLength = 1024 * 16;
  41664. const subLength = bufLength - 36;
  41665. const buf = new Uint8Array(bufLength);
  41666. const sub = buf.subarray(0, subLength);
  41667. let pos = 0;
  41668. let out = '';
  41669. for (let i = 0; i < decoded.length; i++) {
  41670. const line = decoded[i];
  41671. if (i > 0) {
  41672. if (pos === bufLength) {
  41673. out += td.decode(buf);
  41674. pos = 0;
  41675. }
  41676. buf[pos++] = semicolon;
  41677. }
  41678. if (line.length === 0)
  41679. continue;
  41680. state[0] = 0;
  41681. for (let j = 0; j < line.length; j++) {
  41682. const segment = line[j];
  41683. // We can push up to 5 ints, each int can take at most 7 chars, and we
  41684. // may push a comma.
  41685. if (pos > subLength) {
  41686. out += td.decode(sub);
  41687. buf.copyWithin(0, subLength, pos);
  41688. pos -= subLength;
  41689. }
  41690. if (j > 0)
  41691. buf[pos++] = comma;
  41692. pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
  41693. if (segment.length === 1)
  41694. continue;
  41695. pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
  41696. pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
  41697. pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
  41698. if (segment.length === 4)
  41699. continue;
  41700. pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
  41701. }
  41702. }
  41703. return out + td.decode(buf.subarray(0, pos));
  41704. }
  41705. function encodeInteger(buf, pos, state, segment, j) {
  41706. const next = segment[j];
  41707. let num = next - state[j];
  41708. state[j] = next;
  41709. num = num < 0 ? (-num << 1) | 1 : num << 1;
  41710. do {
  41711. let clamped = num & 0b011111;
  41712. num >>>= 5;
  41713. if (num > 0)
  41714. clamped |= 0b100000;
  41715. buf[pos++] = intToChar[clamped];
  41716. } while (num > 0);
  41717. return pos;
  41718. }
  41719. class BitSet {
  41720. constructor(arg) {
  41721. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  41722. }
  41723. add(n) {
  41724. this.bits[n >> 5] |= 1 << (n & 31);
  41725. }
  41726. has(n) {
  41727. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  41728. }
  41729. }
  41730. class Chunk {
  41731. constructor(start, end, content) {
  41732. this.start = start;
  41733. this.end = end;
  41734. this.original = content;
  41735. this.intro = '';
  41736. this.outro = '';
  41737. this.content = content;
  41738. this.storeName = false;
  41739. this.edited = false;
  41740. {
  41741. this.previous = null;
  41742. this.next = null;
  41743. }
  41744. }
  41745. appendLeft(content) {
  41746. this.outro += content;
  41747. }
  41748. appendRight(content) {
  41749. this.intro = this.intro + content;
  41750. }
  41751. clone() {
  41752. const chunk = new Chunk(this.start, this.end, this.original);
  41753. chunk.intro = this.intro;
  41754. chunk.outro = this.outro;
  41755. chunk.content = this.content;
  41756. chunk.storeName = this.storeName;
  41757. chunk.edited = this.edited;
  41758. return chunk;
  41759. }
  41760. contains(index) {
  41761. return this.start < index && index < this.end;
  41762. }
  41763. eachNext(fn) {
  41764. let chunk = this;
  41765. while (chunk) {
  41766. fn(chunk);
  41767. chunk = chunk.next;
  41768. }
  41769. }
  41770. eachPrevious(fn) {
  41771. let chunk = this;
  41772. while (chunk) {
  41773. fn(chunk);
  41774. chunk = chunk.previous;
  41775. }
  41776. }
  41777. edit(content, storeName, contentOnly) {
  41778. this.content = content;
  41779. if (!contentOnly) {
  41780. this.intro = '';
  41781. this.outro = '';
  41782. }
  41783. this.storeName = storeName;
  41784. this.edited = true;
  41785. return this;
  41786. }
  41787. prependLeft(content) {
  41788. this.outro = content + this.outro;
  41789. }
  41790. prependRight(content) {
  41791. this.intro = content + this.intro;
  41792. }
  41793. reset() {
  41794. this.intro = '';
  41795. this.outro = '';
  41796. if (this.edited) {
  41797. this.content = this.original;
  41798. this.storeName = false;
  41799. this.edited = false;
  41800. }
  41801. }
  41802. split(index) {
  41803. const sliceIndex = index - this.start;
  41804. const originalBefore = this.original.slice(0, sliceIndex);
  41805. const originalAfter = this.original.slice(sliceIndex);
  41806. this.original = originalBefore;
  41807. const newChunk = new Chunk(index, this.end, originalAfter);
  41808. newChunk.outro = this.outro;
  41809. this.outro = '';
  41810. this.end = index;
  41811. if (this.edited) {
  41812. // after split we should save the edit content record into the correct chunk
  41813. // to make sure sourcemap correct
  41814. // For example:
  41815. // ' test'.trim()
  41816. // split -> ' ' + 'test'
  41817. // ✔️ edit -> '' + 'test'
  41818. // ✖️ edit -> 'test' + ''
  41819. // TODO is this block necessary?...
  41820. newChunk.edit('', false);
  41821. this.content = '';
  41822. } else {
  41823. this.content = originalBefore;
  41824. }
  41825. newChunk.next = this.next;
  41826. if (newChunk.next) newChunk.next.previous = newChunk;
  41827. newChunk.previous = this;
  41828. this.next = newChunk;
  41829. return newChunk;
  41830. }
  41831. toString() {
  41832. return this.intro + this.content + this.outro;
  41833. }
  41834. trimEnd(rx) {
  41835. this.outro = this.outro.replace(rx, '');
  41836. if (this.outro.length) return true;
  41837. const trimmed = this.content.replace(rx, '');
  41838. if (trimmed.length) {
  41839. if (trimmed !== this.content) {
  41840. this.split(this.start + trimmed.length).edit('', undefined, true);
  41841. if (this.edited) {
  41842. // save the change, if it has been edited
  41843. this.edit(trimmed, this.storeName, true);
  41844. }
  41845. }
  41846. return true;
  41847. } else {
  41848. this.edit('', undefined, true);
  41849. this.intro = this.intro.replace(rx, '');
  41850. if (this.intro.length) return true;
  41851. }
  41852. }
  41853. trimStart(rx) {
  41854. this.intro = this.intro.replace(rx, '');
  41855. if (this.intro.length) return true;
  41856. const trimmed = this.content.replace(rx, '');
  41857. if (trimmed.length) {
  41858. if (trimmed !== this.content) {
  41859. const newChunk = this.split(this.end - trimmed.length);
  41860. if (this.edited) {
  41861. // save the change, if it has been edited
  41862. newChunk.edit(trimmed, this.storeName, true);
  41863. }
  41864. this.edit('', undefined, true);
  41865. }
  41866. return true;
  41867. } else {
  41868. this.edit('', undefined, true);
  41869. this.outro = this.outro.replace(rx, '');
  41870. if (this.outro.length) return true;
  41871. }
  41872. }
  41873. }
  41874. function getBtoa() {
  41875. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  41876. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  41877. } else if (typeof Buffer === 'function') {
  41878. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  41879. } else {
  41880. return () => {
  41881. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  41882. };
  41883. }
  41884. }
  41885. const btoa = /*#__PURE__*/ getBtoa();
  41886. class SourceMap {
  41887. constructor(properties) {
  41888. this.version = 3;
  41889. this.file = properties.file;
  41890. this.sources = properties.sources;
  41891. this.sourcesContent = properties.sourcesContent;
  41892. this.names = properties.names;
  41893. this.mappings = encode(properties.mappings);
  41894. if (typeof properties.x_google_ignoreList !== 'undefined') {
  41895. this.x_google_ignoreList = properties.x_google_ignoreList;
  41896. }
  41897. }
  41898. toString() {
  41899. return JSON.stringify(this);
  41900. }
  41901. toUrl() {
  41902. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  41903. }
  41904. }
  41905. function guessIndent(code) {
  41906. const lines = code.split('\n');
  41907. const tabbed = lines.filter((line) => /^\t+/.test(line));
  41908. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  41909. if (tabbed.length === 0 && spaced.length === 0) {
  41910. return null;
  41911. }
  41912. // More lines tabbed than spaced? Assume tabs, and
  41913. // default to tabs in the case of a tie (or nothing
  41914. // to go on)
  41915. if (tabbed.length >= spaced.length) {
  41916. return '\t';
  41917. }
  41918. // Otherwise, we need to guess the multiple
  41919. const min = spaced.reduce((previous, current) => {
  41920. const numSpaces = /^ +/.exec(current)[0].length;
  41921. return Math.min(numSpaces, previous);
  41922. }, Infinity);
  41923. return new Array(min + 1).join(' ');
  41924. }
  41925. function getRelativePath(from, to) {
  41926. const fromParts = from.split(/[/\\]/);
  41927. const toParts = to.split(/[/\\]/);
  41928. fromParts.pop(); // get dirname
  41929. while (fromParts[0] === toParts[0]) {
  41930. fromParts.shift();
  41931. toParts.shift();
  41932. }
  41933. if (fromParts.length) {
  41934. let i = fromParts.length;
  41935. while (i--) fromParts[i] = '..';
  41936. }
  41937. return fromParts.concat(toParts).join('/');
  41938. }
  41939. const toString = Object.prototype.toString;
  41940. function isObject(thing) {
  41941. return toString.call(thing) === '[object Object]';
  41942. }
  41943. function getLocator(source) {
  41944. const originalLines = source.split('\n');
  41945. const lineOffsets = [];
  41946. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  41947. lineOffsets.push(pos);
  41948. pos += originalLines[i].length + 1;
  41949. }
  41950. return function locate(index) {
  41951. let i = 0;
  41952. let j = lineOffsets.length;
  41953. while (i < j) {
  41954. const m = (i + j) >> 1;
  41955. if (index < lineOffsets[m]) {
  41956. j = m;
  41957. } else {
  41958. i = m + 1;
  41959. }
  41960. }
  41961. const line = i - 1;
  41962. const column = index - lineOffsets[line];
  41963. return { line, column };
  41964. };
  41965. }
  41966. const wordRegex = /\w/;
  41967. class Mappings {
  41968. constructor(hires) {
  41969. this.hires = hires;
  41970. this.generatedCodeLine = 0;
  41971. this.generatedCodeColumn = 0;
  41972. this.raw = [];
  41973. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  41974. this.pending = null;
  41975. }
  41976. addEdit(sourceIndex, content, loc, nameIndex) {
  41977. if (content.length) {
  41978. let contentLineEnd = content.indexOf('\n', 0);
  41979. let previousContentLineEnd = -1;
  41980. while (contentLineEnd >= 0) {
  41981. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  41982. if (nameIndex >= 0) {
  41983. segment.push(nameIndex);
  41984. }
  41985. this.rawSegments.push(segment);
  41986. this.generatedCodeLine += 1;
  41987. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  41988. this.generatedCodeColumn = 0;
  41989. previousContentLineEnd = contentLineEnd;
  41990. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  41991. }
  41992. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  41993. if (nameIndex >= 0) {
  41994. segment.push(nameIndex);
  41995. }
  41996. this.rawSegments.push(segment);
  41997. this.advance(content.slice(previousContentLineEnd + 1));
  41998. } else if (this.pending) {
  41999. this.rawSegments.push(this.pending);
  42000. this.advance(content);
  42001. }
  42002. this.pending = null;
  42003. }
  42004. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  42005. let originalCharIndex = chunk.start;
  42006. let first = true;
  42007. // when iterating each char, check if it's in a word boundary
  42008. let charInHiresBoundary = false;
  42009. while (originalCharIndex < chunk.end) {
  42010. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  42011. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42012. if (this.hires === 'boundary') {
  42013. // in hires "boundary", group segments per word boundary than per char
  42014. if (wordRegex.test(original[originalCharIndex])) {
  42015. // for first char in the boundary found, start the boundary by pushing a segment
  42016. if (!charInHiresBoundary) {
  42017. this.rawSegments.push(segment);
  42018. charInHiresBoundary = true;
  42019. }
  42020. } else {
  42021. // for non-word char, end the boundary by pushing a segment
  42022. this.rawSegments.push(segment);
  42023. charInHiresBoundary = false;
  42024. }
  42025. } else {
  42026. this.rawSegments.push(segment);
  42027. }
  42028. }
  42029. if (original[originalCharIndex] === '\n') {
  42030. loc.line += 1;
  42031. loc.column = 0;
  42032. this.generatedCodeLine += 1;
  42033. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42034. this.generatedCodeColumn = 0;
  42035. first = true;
  42036. } else {
  42037. loc.column += 1;
  42038. this.generatedCodeColumn += 1;
  42039. first = false;
  42040. }
  42041. originalCharIndex += 1;
  42042. }
  42043. this.pending = null;
  42044. }
  42045. advance(str) {
  42046. if (!str) return;
  42047. const lines = str.split('\n');
  42048. if (lines.length > 1) {
  42049. for (let i = 0; i < lines.length - 1; i++) {
  42050. this.generatedCodeLine++;
  42051. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42052. }
  42053. this.generatedCodeColumn = 0;
  42054. }
  42055. this.generatedCodeColumn += lines[lines.length - 1].length;
  42056. }
  42057. }
  42058. const n = '\n';
  42059. const warned = {
  42060. insertLeft: false,
  42061. insertRight: false,
  42062. storeName: false,
  42063. };
  42064. class MagicString {
  42065. constructor(string, options = {}) {
  42066. const chunk = new Chunk(0, string.length, string);
  42067. Object.defineProperties(this, {
  42068. original: { writable: true, value: string },
  42069. outro: { writable: true, value: '' },
  42070. intro: { writable: true, value: '' },
  42071. firstChunk: { writable: true, value: chunk },
  42072. lastChunk: { writable: true, value: chunk },
  42073. lastSearchedChunk: { writable: true, value: chunk },
  42074. byStart: { writable: true, value: {} },
  42075. byEnd: { writable: true, value: {} },
  42076. filename: { writable: true, value: options.filename },
  42077. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  42078. sourcemapLocations: { writable: true, value: new BitSet() },
  42079. storedNames: { writable: true, value: {} },
  42080. indentStr: { writable: true, value: undefined },
  42081. ignoreList: { writable: true, value: options.ignoreList },
  42082. });
  42083. this.byStart[0] = chunk;
  42084. this.byEnd[string.length] = chunk;
  42085. }
  42086. addSourcemapLocation(char) {
  42087. this.sourcemapLocations.add(char);
  42088. }
  42089. append(content) {
  42090. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42091. this.outro += content;
  42092. return this;
  42093. }
  42094. appendLeft(index, content) {
  42095. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42096. this._split(index);
  42097. const chunk = this.byEnd[index];
  42098. if (chunk) {
  42099. chunk.appendLeft(content);
  42100. } else {
  42101. this.intro += content;
  42102. }
  42103. return this;
  42104. }
  42105. appendRight(index, content) {
  42106. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42107. this._split(index);
  42108. const chunk = this.byStart[index];
  42109. if (chunk) {
  42110. chunk.appendRight(content);
  42111. } else {
  42112. this.outro += content;
  42113. }
  42114. return this;
  42115. }
  42116. clone() {
  42117. const cloned = new MagicString(this.original, { filename: this.filename });
  42118. let originalChunk = this.firstChunk;
  42119. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  42120. while (originalChunk) {
  42121. cloned.byStart[clonedChunk.start] = clonedChunk;
  42122. cloned.byEnd[clonedChunk.end] = clonedChunk;
  42123. const nextOriginalChunk = originalChunk.next;
  42124. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  42125. if (nextClonedChunk) {
  42126. clonedChunk.next = nextClonedChunk;
  42127. nextClonedChunk.previous = clonedChunk;
  42128. clonedChunk = nextClonedChunk;
  42129. }
  42130. originalChunk = nextOriginalChunk;
  42131. }
  42132. cloned.lastChunk = clonedChunk;
  42133. if (this.indentExclusionRanges) {
  42134. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  42135. }
  42136. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  42137. cloned.intro = this.intro;
  42138. cloned.outro = this.outro;
  42139. return cloned;
  42140. }
  42141. generateDecodedMap(options) {
  42142. options = options || {};
  42143. const sourceIndex = 0;
  42144. const names = Object.keys(this.storedNames);
  42145. const mappings = new Mappings(options.hires);
  42146. const locate = getLocator(this.original);
  42147. if (this.intro) {
  42148. mappings.advance(this.intro);
  42149. }
  42150. this.firstChunk.eachNext((chunk) => {
  42151. const loc = locate(chunk.start);
  42152. if (chunk.intro.length) mappings.advance(chunk.intro);
  42153. if (chunk.edited) {
  42154. mappings.addEdit(
  42155. sourceIndex,
  42156. chunk.content,
  42157. loc,
  42158. chunk.storeName ? names.indexOf(chunk.original) : -1,
  42159. );
  42160. } else {
  42161. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  42162. }
  42163. if (chunk.outro.length) mappings.advance(chunk.outro);
  42164. });
  42165. return {
  42166. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  42167. sources: [
  42168. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  42169. ],
  42170. sourcesContent: options.includeContent ? [this.original] : undefined,
  42171. names,
  42172. mappings: mappings.raw,
  42173. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  42174. };
  42175. }
  42176. generateMap(options) {
  42177. return new SourceMap(this.generateDecodedMap(options));
  42178. }
  42179. _ensureindentStr() {
  42180. if (this.indentStr === undefined) {
  42181. this.indentStr = guessIndent(this.original);
  42182. }
  42183. }
  42184. _getRawIndentString() {
  42185. this._ensureindentStr();
  42186. return this.indentStr;
  42187. }
  42188. getIndentString() {
  42189. this._ensureindentStr();
  42190. return this.indentStr === null ? '\t' : this.indentStr;
  42191. }
  42192. indent(indentStr, options) {
  42193. const pattern = /^[^\r\n]/gm;
  42194. if (isObject(indentStr)) {
  42195. options = indentStr;
  42196. indentStr = undefined;
  42197. }
  42198. if (indentStr === undefined) {
  42199. this._ensureindentStr();
  42200. indentStr = this.indentStr || '\t';
  42201. }
  42202. if (indentStr === '') return this; // noop
  42203. options = options || {};
  42204. // Process exclusion ranges
  42205. const isExcluded = {};
  42206. if (options.exclude) {
  42207. const exclusions =
  42208. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  42209. exclusions.forEach((exclusion) => {
  42210. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  42211. isExcluded[i] = true;
  42212. }
  42213. });
  42214. }
  42215. let shouldIndentNextCharacter = options.indentStart !== false;
  42216. const replacer = (match) => {
  42217. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  42218. shouldIndentNextCharacter = true;
  42219. return match;
  42220. };
  42221. this.intro = this.intro.replace(pattern, replacer);
  42222. let charIndex = 0;
  42223. let chunk = this.firstChunk;
  42224. while (chunk) {
  42225. const end = chunk.end;
  42226. if (chunk.edited) {
  42227. if (!isExcluded[charIndex]) {
  42228. chunk.content = chunk.content.replace(pattern, replacer);
  42229. if (chunk.content.length) {
  42230. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  42231. }
  42232. }
  42233. } else {
  42234. charIndex = chunk.start;
  42235. while (charIndex < end) {
  42236. if (!isExcluded[charIndex]) {
  42237. const char = this.original[charIndex];
  42238. if (char === '\n') {
  42239. shouldIndentNextCharacter = true;
  42240. } else if (char !== '\r' && shouldIndentNextCharacter) {
  42241. shouldIndentNextCharacter = false;
  42242. if (charIndex === chunk.start) {
  42243. chunk.prependRight(indentStr);
  42244. } else {
  42245. this._splitChunk(chunk, charIndex);
  42246. chunk = chunk.next;
  42247. chunk.prependRight(indentStr);
  42248. }
  42249. }
  42250. }
  42251. charIndex += 1;
  42252. }
  42253. }
  42254. charIndex = chunk.end;
  42255. chunk = chunk.next;
  42256. }
  42257. this.outro = this.outro.replace(pattern, replacer);
  42258. return this;
  42259. }
  42260. insert() {
  42261. throw new Error(
  42262. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  42263. );
  42264. }
  42265. insertLeft(index, content) {
  42266. if (!warned.insertLeft) {
  42267. console.warn(
  42268. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  42269. ); // eslint-disable-line no-console
  42270. warned.insertLeft = true;
  42271. }
  42272. return this.appendLeft(index, content);
  42273. }
  42274. insertRight(index, content) {
  42275. if (!warned.insertRight) {
  42276. console.warn(
  42277. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  42278. ); // eslint-disable-line no-console
  42279. warned.insertRight = true;
  42280. }
  42281. return this.prependRight(index, content);
  42282. }
  42283. move(start, end, index) {
  42284. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  42285. this._split(start);
  42286. this._split(end);
  42287. this._split(index);
  42288. const first = this.byStart[start];
  42289. const last = this.byEnd[end];
  42290. const oldLeft = first.previous;
  42291. const oldRight = last.next;
  42292. const newRight = this.byStart[index];
  42293. if (!newRight && last === this.lastChunk) return this;
  42294. const newLeft = newRight ? newRight.previous : this.lastChunk;
  42295. if (oldLeft) oldLeft.next = oldRight;
  42296. if (oldRight) oldRight.previous = oldLeft;
  42297. if (newLeft) newLeft.next = first;
  42298. if (newRight) newRight.previous = last;
  42299. if (!first.previous) this.firstChunk = last.next;
  42300. if (!last.next) {
  42301. this.lastChunk = first.previous;
  42302. this.lastChunk.next = null;
  42303. }
  42304. first.previous = newLeft;
  42305. last.next = newRight || null;
  42306. if (!newLeft) this.firstChunk = first;
  42307. if (!newRight) this.lastChunk = last;
  42308. return this;
  42309. }
  42310. overwrite(start, end, content, options) {
  42311. options = options || {};
  42312. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  42313. }
  42314. update(start, end, content, options) {
  42315. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  42316. while (start < 0) start += this.original.length;
  42317. while (end < 0) end += this.original.length;
  42318. if (end > this.original.length) throw new Error('end is out of bounds');
  42319. if (start === end)
  42320. throw new Error(
  42321. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  42322. );
  42323. this._split(start);
  42324. this._split(end);
  42325. if (options === true) {
  42326. if (!warned.storeName) {
  42327. console.warn(
  42328. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  42329. ); // eslint-disable-line no-console
  42330. warned.storeName = true;
  42331. }
  42332. options = { storeName: true };
  42333. }
  42334. const storeName = options !== undefined ? options.storeName : false;
  42335. const overwrite = options !== undefined ? options.overwrite : false;
  42336. if (storeName) {
  42337. const original = this.original.slice(start, end);
  42338. Object.defineProperty(this.storedNames, original, {
  42339. writable: true,
  42340. value: true,
  42341. enumerable: true,
  42342. });
  42343. }
  42344. const first = this.byStart[start];
  42345. const last = this.byEnd[end];
  42346. if (first) {
  42347. let chunk = first;
  42348. while (chunk !== last) {
  42349. if (chunk.next !== this.byStart[chunk.end]) {
  42350. throw new Error('Cannot overwrite across a split point');
  42351. }
  42352. chunk = chunk.next;
  42353. chunk.edit('', false);
  42354. }
  42355. first.edit(content, storeName, !overwrite);
  42356. } else {
  42357. // must be inserting at the end
  42358. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  42359. // TODO last chunk in the array may not be the last chunk, if it's moved...
  42360. last.next = newChunk;
  42361. newChunk.previous = last;
  42362. }
  42363. return this;
  42364. }
  42365. prepend(content) {
  42366. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42367. this.intro = content + this.intro;
  42368. return this;
  42369. }
  42370. prependLeft(index, content) {
  42371. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42372. this._split(index);
  42373. const chunk = this.byEnd[index];
  42374. if (chunk) {
  42375. chunk.prependLeft(content);
  42376. } else {
  42377. this.intro = content + this.intro;
  42378. }
  42379. return this;
  42380. }
  42381. prependRight(index, content) {
  42382. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42383. this._split(index);
  42384. const chunk = this.byStart[index];
  42385. if (chunk) {
  42386. chunk.prependRight(content);
  42387. } else {
  42388. this.outro = content + this.outro;
  42389. }
  42390. return this;
  42391. }
  42392. remove(start, end) {
  42393. while (start < 0) start += this.original.length;
  42394. while (end < 0) end += this.original.length;
  42395. if (start === end) return this;
  42396. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42397. if (start > end) throw new Error('end must be greater than start');
  42398. this._split(start);
  42399. this._split(end);
  42400. let chunk = this.byStart[start];
  42401. while (chunk) {
  42402. chunk.intro = '';
  42403. chunk.outro = '';
  42404. chunk.edit('');
  42405. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42406. }
  42407. return this;
  42408. }
  42409. reset(start, end) {
  42410. while (start < 0) start += this.original.length;
  42411. while (end < 0) end += this.original.length;
  42412. if (start === end) return this;
  42413. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42414. if (start > end) throw new Error('end must be greater than start');
  42415. this._split(start);
  42416. this._split(end);
  42417. let chunk = this.byStart[start];
  42418. while (chunk) {
  42419. chunk.reset();
  42420. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42421. }
  42422. return this;
  42423. }
  42424. lastChar() {
  42425. if (this.outro.length) return this.outro[this.outro.length - 1];
  42426. let chunk = this.lastChunk;
  42427. do {
  42428. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  42429. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  42430. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  42431. } while ((chunk = chunk.previous));
  42432. if (this.intro.length) return this.intro[this.intro.length - 1];
  42433. return '';
  42434. }
  42435. lastLine() {
  42436. let lineIndex = this.outro.lastIndexOf(n);
  42437. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  42438. let lineStr = this.outro;
  42439. let chunk = this.lastChunk;
  42440. do {
  42441. if (chunk.outro.length > 0) {
  42442. lineIndex = chunk.outro.lastIndexOf(n);
  42443. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  42444. lineStr = chunk.outro + lineStr;
  42445. }
  42446. if (chunk.content.length > 0) {
  42447. lineIndex = chunk.content.lastIndexOf(n);
  42448. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  42449. lineStr = chunk.content + lineStr;
  42450. }
  42451. if (chunk.intro.length > 0) {
  42452. lineIndex = chunk.intro.lastIndexOf(n);
  42453. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  42454. lineStr = chunk.intro + lineStr;
  42455. }
  42456. } while ((chunk = chunk.previous));
  42457. lineIndex = this.intro.lastIndexOf(n);
  42458. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  42459. return this.intro + lineStr;
  42460. }
  42461. slice(start = 0, end = this.original.length) {
  42462. while (start < 0) start += this.original.length;
  42463. while (end < 0) end += this.original.length;
  42464. let result = '';
  42465. // find start chunk
  42466. let chunk = this.firstChunk;
  42467. while (chunk && (chunk.start > start || chunk.end <= start)) {
  42468. // found end chunk before start
  42469. if (chunk.start < end && chunk.end >= end) {
  42470. return result;
  42471. }
  42472. chunk = chunk.next;
  42473. }
  42474. if (chunk && chunk.edited && chunk.start !== start)
  42475. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  42476. const startChunk = chunk;
  42477. while (chunk) {
  42478. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  42479. result += chunk.intro;
  42480. }
  42481. const containsEnd = chunk.start < end && chunk.end >= end;
  42482. if (containsEnd && chunk.edited && chunk.end !== end)
  42483. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  42484. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  42485. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  42486. result += chunk.content.slice(sliceStart, sliceEnd);
  42487. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  42488. result += chunk.outro;
  42489. }
  42490. if (containsEnd) {
  42491. break;
  42492. }
  42493. chunk = chunk.next;
  42494. }
  42495. return result;
  42496. }
  42497. // TODO deprecate this? not really very useful
  42498. snip(start, end) {
  42499. const clone = this.clone();
  42500. clone.remove(0, start);
  42501. clone.remove(end, clone.original.length);
  42502. return clone;
  42503. }
  42504. _split(index) {
  42505. if (this.byStart[index] || this.byEnd[index]) return;
  42506. let chunk = this.lastSearchedChunk;
  42507. const searchForward = index > chunk.end;
  42508. while (chunk) {
  42509. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  42510. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  42511. }
  42512. }
  42513. _splitChunk(chunk, index) {
  42514. if (chunk.edited && chunk.content.length) {
  42515. // zero-length edited chunks are a special case (overlapping replacements)
  42516. const loc = getLocator(this.original)(index);
  42517. throw new Error(
  42518. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  42519. );
  42520. }
  42521. const newChunk = chunk.split(index);
  42522. this.byEnd[index] = chunk;
  42523. this.byStart[index] = newChunk;
  42524. this.byEnd[newChunk.end] = newChunk;
  42525. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  42526. this.lastSearchedChunk = chunk;
  42527. return true;
  42528. }
  42529. toString() {
  42530. let str = this.intro;
  42531. let chunk = this.firstChunk;
  42532. while (chunk) {
  42533. str += chunk.toString();
  42534. chunk = chunk.next;
  42535. }
  42536. return str + this.outro;
  42537. }
  42538. isEmpty() {
  42539. let chunk = this.firstChunk;
  42540. do {
  42541. if (
  42542. (chunk.intro.length && chunk.intro.trim()) ||
  42543. (chunk.content.length && chunk.content.trim()) ||
  42544. (chunk.outro.length && chunk.outro.trim())
  42545. )
  42546. return false;
  42547. } while ((chunk = chunk.next));
  42548. return true;
  42549. }
  42550. length() {
  42551. let chunk = this.firstChunk;
  42552. let length = 0;
  42553. do {
  42554. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  42555. } while ((chunk = chunk.next));
  42556. return length;
  42557. }
  42558. trimLines() {
  42559. return this.trim('[\\r\\n]');
  42560. }
  42561. trim(charType) {
  42562. return this.trimStart(charType).trimEnd(charType);
  42563. }
  42564. trimEndAborted(charType) {
  42565. const rx = new RegExp((charType || '\\s') + '+$');
  42566. this.outro = this.outro.replace(rx, '');
  42567. if (this.outro.length) return true;
  42568. let chunk = this.lastChunk;
  42569. do {
  42570. const end = chunk.end;
  42571. const aborted = chunk.trimEnd(rx);
  42572. // if chunk was trimmed, we have a new lastChunk
  42573. if (chunk.end !== end) {
  42574. if (this.lastChunk === chunk) {
  42575. this.lastChunk = chunk.next;
  42576. }
  42577. this.byEnd[chunk.end] = chunk;
  42578. this.byStart[chunk.next.start] = chunk.next;
  42579. this.byEnd[chunk.next.end] = chunk.next;
  42580. }
  42581. if (aborted) return true;
  42582. chunk = chunk.previous;
  42583. } while (chunk);
  42584. return false;
  42585. }
  42586. trimEnd(charType) {
  42587. this.trimEndAborted(charType);
  42588. return this;
  42589. }
  42590. trimStartAborted(charType) {
  42591. const rx = new RegExp('^' + (charType || '\\s') + '+');
  42592. this.intro = this.intro.replace(rx, '');
  42593. if (this.intro.length) return true;
  42594. let chunk = this.firstChunk;
  42595. do {
  42596. const end = chunk.end;
  42597. const aborted = chunk.trimStart(rx);
  42598. if (chunk.end !== end) {
  42599. // special case...
  42600. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  42601. this.byEnd[chunk.end] = chunk;
  42602. this.byStart[chunk.next.start] = chunk.next;
  42603. this.byEnd[chunk.next.end] = chunk.next;
  42604. }
  42605. if (aborted) return true;
  42606. chunk = chunk.next;
  42607. } while (chunk);
  42608. return false;
  42609. }
  42610. trimStart(charType) {
  42611. this.trimStartAborted(charType);
  42612. return this;
  42613. }
  42614. hasChanged() {
  42615. return this.original !== this.toString();
  42616. }
  42617. _replaceRegexp(searchValue, replacement) {
  42618. function getReplacement(match, str) {
  42619. if (typeof replacement === 'string') {
  42620. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  42621. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  42622. if (i === '$') return '$';
  42623. if (i === '&') return match[0];
  42624. const num = +i;
  42625. if (num < match.length) return match[+i];
  42626. return `$${i}`;
  42627. });
  42628. } else {
  42629. return replacement(...match, match.index, str, match.groups);
  42630. }
  42631. }
  42632. function matchAll(re, str) {
  42633. let match;
  42634. const matches = [];
  42635. while ((match = re.exec(str))) {
  42636. matches.push(match);
  42637. }
  42638. return matches;
  42639. }
  42640. if (searchValue.global) {
  42641. const matches = matchAll(searchValue, this.original);
  42642. matches.forEach((match) => {
  42643. if (match.index != null)
  42644. this.overwrite(
  42645. match.index,
  42646. match.index + match[0].length,
  42647. getReplacement(match, this.original),
  42648. );
  42649. });
  42650. } else {
  42651. const match = this.original.match(searchValue);
  42652. if (match && match.index != null)
  42653. this.overwrite(
  42654. match.index,
  42655. match.index + match[0].length,
  42656. getReplacement(match, this.original),
  42657. );
  42658. }
  42659. return this;
  42660. }
  42661. _replaceString(string, replacement) {
  42662. const { original } = this;
  42663. const index = original.indexOf(string);
  42664. if (index !== -1) {
  42665. this.overwrite(index, index + string.length, replacement);
  42666. }
  42667. return this;
  42668. }
  42669. replace(searchValue, replacement) {
  42670. if (typeof searchValue === 'string') {
  42671. return this._replaceString(searchValue, replacement);
  42672. }
  42673. return this._replaceRegexp(searchValue, replacement);
  42674. }
  42675. _replaceAllString(string, replacement) {
  42676. const { original } = this;
  42677. const stringLength = string.length;
  42678. for (
  42679. let index = original.indexOf(string);
  42680. index !== -1;
  42681. index = original.indexOf(string, index + stringLength)
  42682. ) {
  42683. this.overwrite(index, index + stringLength, replacement);
  42684. }
  42685. return this;
  42686. }
  42687. replaceAll(searchValue, replacement) {
  42688. if (typeof searchValue === 'string') {
  42689. return this._replaceAllString(searchValue, replacement);
  42690. }
  42691. if (!searchValue.global) {
  42692. throw new TypeError(
  42693. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  42694. );
  42695. }
  42696. return this._replaceRegexp(searchValue, replacement);
  42697. }
  42698. }
  42699. var _a, _b;
  42700. class ScriptCompileContext {
  42701. constructor(descriptor, options) {
  42702. this.descriptor = descriptor;
  42703. this.options = options;
  42704. this.isCE = false;
  42705. this.source = this.descriptor.source;
  42706. this.filename = this.descriptor.filename;
  42707. this.s = new MagicString(this.source);
  42708. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  42709. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  42710. this.userImports = /* @__PURE__ */ Object.create(null);
  42711. // macros presence check
  42712. this.hasDefinePropsCall = false;
  42713. this.hasDefineEmitCall = false;
  42714. this.hasDefineExposeCall = false;
  42715. this.hasDefaultExportName = false;
  42716. this.hasDefaultExportRender = false;
  42717. this.hasDefineOptionsCall = false;
  42718. this.hasDefineSlotsCall = false;
  42719. this.hasDefineModelCall = false;
  42720. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  42721. // defineModel
  42722. this.modelDecls = /* @__PURE__ */ Object.create(null);
  42723. // codegen
  42724. this.bindingMetadata = {};
  42725. this.helperImports = /* @__PURE__ */ new Set();
  42726. const { script, scriptSetup } = descriptor;
  42727. const scriptLang = script && script.lang;
  42728. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  42729. this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
  42730. this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
  42731. const customElement = options.customElement;
  42732. const filename = this.descriptor.filename;
  42733. if (customElement) {
  42734. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  42735. }
  42736. const plugins = resolveParserPlugins(
  42737. scriptLang || scriptSetupLang,
  42738. options.babelParserPlugins
  42739. );
  42740. function parse(input, offset) {
  42741. try {
  42742. return parse_1$1(input, {
  42743. plugins,
  42744. sourceType: "module"
  42745. }).program;
  42746. } catch (e) {
  42747. e.message = `[vue/compiler-sfc] ${e.message}
  42748. ${descriptor.filename}
  42749. ${generateCodeFrame(
  42750. descriptor.source,
  42751. e.pos + offset,
  42752. e.pos + offset + 1
  42753. )}`;
  42754. throw e;
  42755. }
  42756. }
  42757. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  42758. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  42759. }
  42760. helper(key) {
  42761. this.helperImports.add(key);
  42762. return `_${key}`;
  42763. }
  42764. getString(node, scriptSetup = true) {
  42765. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  42766. return block.content.slice(node.start, node.end);
  42767. }
  42768. error(msg, node, scope) {
  42769. const offset = scope ? scope.offset : this.startOffset;
  42770. throw new Error(
  42771. `[@vue/compiler-sfc] ${msg}
  42772. ${(scope || this.descriptor).filename}
  42773. ${generateCodeFrame(
  42774. (scope || this.descriptor).source,
  42775. node.start + offset,
  42776. node.end + offset
  42777. )}`
  42778. );
  42779. }
  42780. }
  42781. function resolveParserPlugins(lang, userPlugins, dts = false) {
  42782. const plugins = [];
  42783. if (!userPlugins || !userPlugins.some(
  42784. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  42785. )) {
  42786. plugins.push("importAttributes");
  42787. }
  42788. if (lang === "jsx" || lang === "tsx") {
  42789. plugins.push("jsx");
  42790. } else if (userPlugins) {
  42791. userPlugins = userPlugins.filter((p) => p !== "jsx");
  42792. }
  42793. if (lang === "ts" || lang === "tsx") {
  42794. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  42795. if (!userPlugins || !userPlugins.includes("decorators")) {
  42796. plugins.push("decorators-legacy");
  42797. }
  42798. }
  42799. if (userPlugins) {
  42800. plugins.push(...userPlugins);
  42801. }
  42802. return plugins;
  42803. }
  42804. function rewriteDefault(input, as, parserPlugins) {
  42805. const ast = parse_1$1(input, {
  42806. sourceType: "module",
  42807. plugins: resolveParserPlugins("js", parserPlugins)
  42808. }).program.body;
  42809. const s = new MagicString(input);
  42810. rewriteDefaultAST(ast, s, as);
  42811. return s.toString();
  42812. }
  42813. function rewriteDefaultAST(ast, s, as) {
  42814. if (!hasDefaultExport(ast)) {
  42815. s.append(`
  42816. const ${as} = {}`);
  42817. return;
  42818. }
  42819. ast.forEach((node) => {
  42820. if (node.type === "ExportDefaultDeclaration") {
  42821. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  42822. let start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  42823. s.overwrite(start, node.declaration.id.start, ` class `);
  42824. s.append(`
  42825. const ${as} = ${node.declaration.id.name}`);
  42826. } else {
  42827. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  42828. }
  42829. } else if (node.type === "ExportNamedDeclaration") {
  42830. for (const specifier of node.specifiers) {
  42831. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  42832. if (node.source) {
  42833. if (specifier.local.name === "default") {
  42834. s.prepend(
  42835. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  42836. `
  42837. );
  42838. const end2 = specifierEnd(s, specifier.local.end, node.end);
  42839. s.remove(specifier.start, end2);
  42840. s.append(`
  42841. const ${as} = __VUE_DEFAULT__`);
  42842. continue;
  42843. } else {
  42844. s.prepend(
  42845. `import { ${s.slice(
  42846. specifier.local.start,
  42847. specifier.local.end
  42848. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  42849. `
  42850. );
  42851. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  42852. s.remove(specifier.start, end2);
  42853. s.append(`
  42854. const ${as} = __VUE_DEFAULT__`);
  42855. continue;
  42856. }
  42857. }
  42858. const end = specifierEnd(s, specifier.end, node.end);
  42859. s.remove(specifier.start, end);
  42860. s.append(`
  42861. const ${as} = ${specifier.local.name}`);
  42862. }
  42863. }
  42864. }
  42865. });
  42866. }
  42867. function hasDefaultExport(ast) {
  42868. for (const stmt of ast) {
  42869. if (stmt.type === "ExportDefaultDeclaration") {
  42870. return true;
  42871. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  42872. (spec) => spec.exported.name === "default"
  42873. )) {
  42874. return true;
  42875. }
  42876. }
  42877. return false;
  42878. }
  42879. function specifierEnd(s, end, nodeEnd) {
  42880. let hasCommas = false;
  42881. let oldEnd = end;
  42882. while (end < nodeEnd) {
  42883. if (/\s/.test(s.slice(end, end + 1))) {
  42884. end++;
  42885. } else if (s.slice(end, end + 1) === ",") {
  42886. end++;
  42887. hasCommas = true;
  42888. break;
  42889. } else if (s.slice(end, end + 1) === "}") {
  42890. break;
  42891. }
  42892. }
  42893. return hasCommas ? end : oldEnd;
  42894. }
  42895. var __defProp$3 = Object.defineProperty;
  42896. var __defProps$2 = Object.defineProperties;
  42897. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  42898. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  42899. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  42900. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  42901. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  42902. var __spreadValues$3 = (a, b) => {
  42903. for (var prop in b || (b = {}))
  42904. if (__hasOwnProp$3.call(b, prop))
  42905. __defNormalProp$3(a, prop, b[prop]);
  42906. if (__getOwnPropSymbols$3)
  42907. for (var prop of __getOwnPropSymbols$3(b)) {
  42908. if (__propIsEnum$3.call(b, prop))
  42909. __defNormalProp$3(a, prop, b[prop]);
  42910. }
  42911. return a;
  42912. };
  42913. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  42914. const normalScriptDefaultVar = `__default__`;
  42915. function processNormalScript(ctx, scopeId) {
  42916. var _a;
  42917. const script = ctx.descriptor.script;
  42918. if (script.lang && !ctx.isJS && !ctx.isTS) {
  42919. return script;
  42920. }
  42921. try {
  42922. let content = script.content;
  42923. let map = script.map;
  42924. const scriptAst = ctx.scriptAst;
  42925. const bindings = analyzeScriptBindings(scriptAst.body);
  42926. const { cssVars } = ctx.descriptor;
  42927. const { genDefaultAs, isProd } = ctx.options;
  42928. if (cssVars.length || genDefaultAs) {
  42929. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  42930. const s = new MagicString(content);
  42931. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  42932. content = s.toString();
  42933. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  42934. content += genNormalScriptCssVarsCode(
  42935. cssVars,
  42936. bindings,
  42937. scopeId,
  42938. !!isProd,
  42939. defaultVar
  42940. );
  42941. }
  42942. if (!genDefaultAs) {
  42943. content += `
  42944. export default ${defaultVar}`;
  42945. }
  42946. }
  42947. return __spreadProps$2(__spreadValues$3({}, script), {
  42948. content,
  42949. map,
  42950. bindings,
  42951. scriptAst: scriptAst.body
  42952. });
  42953. } catch (e) {
  42954. return script;
  42955. }
  42956. }
  42957. var __defProp$2 = Object.defineProperty;
  42958. var __defProps$1 = Object.defineProperties;
  42959. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  42960. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  42961. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  42962. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  42963. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  42964. var __spreadValues$2 = (a, b) => {
  42965. for (var prop in b || (b = {}))
  42966. if (__hasOwnProp$2.call(b, prop))
  42967. __defNormalProp$2(a, prop, b[prop]);
  42968. if (__getOwnPropSymbols$2)
  42969. for (var prop of __getOwnPropSymbols$2(b)) {
  42970. if (__propIsEnum$2.call(b, prop))
  42971. __defNormalProp$2(a, prop, b[prop]);
  42972. }
  42973. return a;
  42974. };
  42975. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  42976. class TypeScope {
  42977. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  42978. this.filename = filename;
  42979. this.source = source;
  42980. this.offset = offset;
  42981. this.imports = imports;
  42982. this.types = types;
  42983. this.declares = declares;
  42984. this.isGenericScope = false;
  42985. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  42986. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  42987. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  42988. }
  42989. }
  42990. function resolveTypeElements(ctx, node, scope, typeParameters) {
  42991. const canCache = !typeParameters;
  42992. if (canCache && node._resolvedElements) {
  42993. return node._resolvedElements;
  42994. }
  42995. const resolved = innerResolveTypeElements(
  42996. ctx,
  42997. node,
  42998. node._ownerScope || scope || ctxToScope(ctx),
  42999. typeParameters
  43000. );
  43001. return canCache ? node._resolvedElements = resolved : resolved;
  43002. }
  43003. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  43004. var _a, _b;
  43005. switch (node.type) {
  43006. case "TSTypeLiteral":
  43007. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  43008. case "TSInterfaceDeclaration":
  43009. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  43010. case "TSTypeAliasDeclaration":
  43011. case "TSParenthesizedType":
  43012. return resolveTypeElements(
  43013. ctx,
  43014. node.typeAnnotation,
  43015. scope,
  43016. typeParameters
  43017. );
  43018. case "TSFunctionType": {
  43019. return { props: {}, calls: [node] };
  43020. }
  43021. case "TSUnionType":
  43022. case "TSIntersectionType":
  43023. return mergeElements(
  43024. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  43025. node.type
  43026. );
  43027. case "TSMappedType":
  43028. return resolveMappedType(ctx, node, scope);
  43029. case "TSIndexedAccessType": {
  43030. const types = resolveIndexType(ctx, node, scope);
  43031. return mergeElements(
  43032. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  43033. "TSUnionType"
  43034. );
  43035. }
  43036. case "TSExpressionWithTypeArguments":
  43037. case "TSTypeReference": {
  43038. const typeName = getReferenceName(node);
  43039. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  43040. return resolveExtractPropTypes(
  43041. resolveTypeElements(
  43042. ctx,
  43043. node.typeParameters.params[0],
  43044. scope,
  43045. typeParameters
  43046. ),
  43047. scope
  43048. );
  43049. }
  43050. const resolved = resolveTypeReference(ctx, node, scope);
  43051. if (resolved) {
  43052. let typeParams;
  43053. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  43054. typeParams = /* @__PURE__ */ Object.create(null);
  43055. resolved.typeParameters.params.forEach((p, i) => {
  43056. let param = typeParameters && typeParameters[p.name];
  43057. if (!param)
  43058. param = node.typeParameters.params[i];
  43059. typeParams[p.name] = param;
  43060. });
  43061. }
  43062. return resolveTypeElements(
  43063. ctx,
  43064. resolved,
  43065. resolved._ownerScope,
  43066. typeParams
  43067. );
  43068. } else {
  43069. if (typeof typeName === "string") {
  43070. if (typeParameters && typeParameters[typeName]) {
  43071. return resolveTypeElements(
  43072. ctx,
  43073. typeParameters[typeName],
  43074. scope,
  43075. typeParameters
  43076. );
  43077. }
  43078. if (
  43079. // @ts-expect-error
  43080. SupportedBuiltinsSet.has(typeName)
  43081. ) {
  43082. return resolveBuiltin(
  43083. ctx,
  43084. node,
  43085. typeName,
  43086. scope,
  43087. typeParameters
  43088. );
  43089. } else if (typeName === "ReturnType" && node.typeParameters) {
  43090. const ret = resolveReturnType(
  43091. ctx,
  43092. node.typeParameters.params[0],
  43093. scope
  43094. );
  43095. if (ret) {
  43096. return resolveTypeElements(ctx, ret, scope);
  43097. }
  43098. }
  43099. }
  43100. return ctx.error(
  43101. `Unresolvable type reference or unsupported built-in utility type`,
  43102. node,
  43103. scope
  43104. );
  43105. }
  43106. }
  43107. case "TSImportType": {
  43108. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  43109. return resolveExtractPropTypes(
  43110. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  43111. scope
  43112. );
  43113. }
  43114. const sourceScope = importSourceToScope(
  43115. ctx,
  43116. node.argument,
  43117. scope,
  43118. node.argument.value
  43119. );
  43120. const resolved = resolveTypeReference(ctx, node, sourceScope);
  43121. if (resolved) {
  43122. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43123. }
  43124. break;
  43125. }
  43126. case "TSTypeQuery":
  43127. {
  43128. const resolved = resolveTypeReference(ctx, node, scope);
  43129. if (resolved) {
  43130. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43131. }
  43132. }
  43133. break;
  43134. }
  43135. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  43136. }
  43137. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  43138. const res = { props: {} };
  43139. for (const e of elements) {
  43140. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  43141. if (typeParameters) {
  43142. scope = createChildScope(scope);
  43143. scope.isGenericScope = true;
  43144. Object.assign(scope.types, typeParameters);
  43145. }
  43146. e._ownerScope = scope;
  43147. const name = getId(e.key);
  43148. if (name && !e.computed) {
  43149. res.props[name] = e;
  43150. } else if (e.key.type === "TemplateLiteral") {
  43151. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  43152. res.props[key] = e;
  43153. }
  43154. } else {
  43155. ctx.error(
  43156. `Unsupported computed key in type referenced by a macro`,
  43157. e.key,
  43158. scope
  43159. );
  43160. }
  43161. } else if (e.type === "TSCallSignatureDeclaration") {
  43162. (res.calls || (res.calls = [])).push(e);
  43163. }
  43164. }
  43165. return res;
  43166. }
  43167. function mergeElements(maps, type) {
  43168. if (maps.length === 1)
  43169. return maps[0];
  43170. const res = { props: {} };
  43171. const { props: baseProps } = res;
  43172. for (const { props, calls } of maps) {
  43173. for (const key in props) {
  43174. if (!hasOwn(baseProps, key)) {
  43175. baseProps[key] = props[key];
  43176. } else {
  43177. baseProps[key] = createProperty(
  43178. baseProps[key].key,
  43179. {
  43180. type,
  43181. // @ts-expect-error
  43182. types: [baseProps[key], props[key]]
  43183. },
  43184. baseProps[key]._ownerScope,
  43185. baseProps[key].optional || props[key].optional
  43186. );
  43187. }
  43188. }
  43189. if (calls) {
  43190. (res.calls || (res.calls = [])).push(...calls);
  43191. }
  43192. }
  43193. return res;
  43194. }
  43195. function createProperty(key, typeAnnotation, scope, optional) {
  43196. return {
  43197. type: "TSPropertySignature",
  43198. key,
  43199. kind: "get",
  43200. optional,
  43201. typeAnnotation: {
  43202. type: "TSTypeAnnotation",
  43203. typeAnnotation
  43204. },
  43205. _ownerScope: scope
  43206. };
  43207. }
  43208. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  43209. const base = typeElementsToMap(
  43210. ctx,
  43211. node.body.body,
  43212. node._ownerScope,
  43213. typeParameters
  43214. );
  43215. if (node.extends) {
  43216. for (const ext of node.extends) {
  43217. if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  43218. continue;
  43219. }
  43220. try {
  43221. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  43222. for (const key in props) {
  43223. if (!hasOwn(base.props, key)) {
  43224. base.props[key] = props[key];
  43225. }
  43226. }
  43227. if (calls) {
  43228. ;
  43229. (base.calls || (base.calls = [])).push(...calls);
  43230. }
  43231. } catch (e) {
  43232. ctx.error(
  43233. `Failed to resolve extends base type.
  43234. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  43235. interface Props extends /* @vue-ignore */ Base {}
  43236. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  43237. ext
  43238. );
  43239. }
  43240. }
  43241. }
  43242. return base;
  43243. }
  43244. function resolveMappedType(ctx, node, scope) {
  43245. const res = { props: {} };
  43246. const keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  43247. for (const key of keys) {
  43248. res.props[key] = createProperty(
  43249. {
  43250. type: "Identifier",
  43251. name: key
  43252. },
  43253. node.typeAnnotation,
  43254. scope,
  43255. !!node.optional
  43256. );
  43257. }
  43258. return res;
  43259. }
  43260. function resolveIndexType(ctx, node, scope) {
  43261. var _a, _b;
  43262. if (node.indexType.type === "TSNumberKeyword") {
  43263. return resolveArrayElementType(ctx, node.objectType, scope);
  43264. }
  43265. const { indexType, objectType } = node;
  43266. const types = [];
  43267. let keys;
  43268. let resolved;
  43269. if (indexType.type === "TSStringKeyword") {
  43270. resolved = resolveTypeElements(ctx, objectType, scope);
  43271. keys = Object.keys(resolved.props);
  43272. } else {
  43273. keys = resolveStringType(ctx, indexType, scope);
  43274. resolved = resolveTypeElements(ctx, objectType, scope);
  43275. }
  43276. for (const key of keys) {
  43277. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  43278. if (targetType) {
  43279. targetType._ownerScope = resolved.props[key]._ownerScope;
  43280. types.push(targetType);
  43281. }
  43282. }
  43283. return types;
  43284. }
  43285. function resolveArrayElementType(ctx, node, scope) {
  43286. if (node.type === "TSArrayType") {
  43287. return [node.elementType];
  43288. }
  43289. if (node.type === "TSTupleType") {
  43290. return node.elementTypes.map(
  43291. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  43292. );
  43293. }
  43294. if (node.type === "TSTypeReference") {
  43295. if (getReferenceName(node) === "Array" && node.typeParameters) {
  43296. return node.typeParameters.params;
  43297. } else {
  43298. const resolved = resolveTypeReference(ctx, node, scope);
  43299. if (resolved) {
  43300. return resolveArrayElementType(ctx, resolved, scope);
  43301. }
  43302. }
  43303. }
  43304. return ctx.error(
  43305. "Failed to resolve element type from target type",
  43306. node,
  43307. scope
  43308. );
  43309. }
  43310. function resolveStringType(ctx, node, scope) {
  43311. switch (node.type) {
  43312. case "StringLiteral":
  43313. return [node.value];
  43314. case "TSLiteralType":
  43315. return resolveStringType(ctx, node.literal, scope);
  43316. case "TSUnionType":
  43317. return node.types.map((t) => resolveStringType(ctx, t, scope)).flat();
  43318. case "TemplateLiteral": {
  43319. return resolveTemplateKeys(ctx, node, scope);
  43320. }
  43321. case "TSTypeReference": {
  43322. const resolved = resolveTypeReference(ctx, node, scope);
  43323. if (resolved) {
  43324. return resolveStringType(ctx, resolved, scope);
  43325. }
  43326. if (node.typeName.type === "Identifier") {
  43327. const getParam = (index = 0) => resolveStringType(ctx, node.typeParameters.params[index], scope);
  43328. switch (node.typeName.name) {
  43329. case "Extract":
  43330. return getParam(1);
  43331. case "Exclude": {
  43332. const excluded = getParam(1);
  43333. return getParam().filter((s) => !excluded.includes(s));
  43334. }
  43335. case "Uppercase":
  43336. return getParam().map((s) => s.toUpperCase());
  43337. case "Lowercase":
  43338. return getParam().map((s) => s.toLowerCase());
  43339. case "Capitalize":
  43340. return getParam().map(capitalize$1);
  43341. case "Uncapitalize":
  43342. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  43343. default:
  43344. ctx.error(
  43345. "Unsupported type when resolving index type",
  43346. node.typeName,
  43347. scope
  43348. );
  43349. }
  43350. }
  43351. }
  43352. }
  43353. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  43354. }
  43355. function resolveTemplateKeys(ctx, node, scope) {
  43356. if (!node.expressions.length) {
  43357. return [node.quasis[0].value.raw];
  43358. }
  43359. const res = [];
  43360. const e = node.expressions[0];
  43361. const q = node.quasis[0];
  43362. const leading = q ? q.value.raw : ``;
  43363. const resolved = resolveStringType(ctx, e, scope);
  43364. const restResolved = resolveTemplateKeys(
  43365. ctx,
  43366. __spreadProps$1(__spreadValues$2({}, node), {
  43367. expressions: node.expressions.slice(1),
  43368. quasis: q ? node.quasis.slice(1) : node.quasis
  43369. }),
  43370. scope
  43371. );
  43372. for (const r of resolved) {
  43373. for (const rr of restResolved) {
  43374. res.push(leading + r + rr);
  43375. }
  43376. }
  43377. return res;
  43378. }
  43379. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  43380. "Partial",
  43381. "Required",
  43382. "Readonly",
  43383. "Pick",
  43384. "Omit"
  43385. ]);
  43386. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  43387. const t = resolveTypeElements(
  43388. ctx,
  43389. node.typeParameters.params[0],
  43390. scope,
  43391. typeParameters
  43392. );
  43393. switch (name) {
  43394. case "Partial": {
  43395. const res2 = { props: {}, calls: t.calls };
  43396. Object.keys(t.props).forEach((key) => {
  43397. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  43398. });
  43399. return res2;
  43400. }
  43401. case "Required": {
  43402. const res2 = { props: {}, calls: t.calls };
  43403. Object.keys(t.props).forEach((key) => {
  43404. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  43405. });
  43406. return res2;
  43407. }
  43408. case "Readonly":
  43409. return t;
  43410. case "Pick": {
  43411. const picked = resolveStringType(
  43412. ctx,
  43413. node.typeParameters.params[1],
  43414. scope
  43415. );
  43416. const res2 = { props: {}, calls: t.calls };
  43417. for (const key of picked) {
  43418. res2.props[key] = t.props[key];
  43419. }
  43420. return res2;
  43421. }
  43422. case "Omit":
  43423. const omitted = resolveStringType(
  43424. ctx,
  43425. node.typeParameters.params[1],
  43426. scope
  43427. );
  43428. const res = { props: {}, calls: t.calls };
  43429. for (const key in t.props) {
  43430. if (!omitted.includes(key)) {
  43431. res.props[key] = t.props[key];
  43432. }
  43433. }
  43434. return res;
  43435. }
  43436. }
  43437. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  43438. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  43439. if (canCache && node._resolvedReference) {
  43440. return node._resolvedReference;
  43441. }
  43442. const resolved = innerResolveTypeReference(
  43443. ctx,
  43444. scope || ctxToScope(ctx),
  43445. name || getReferenceName(node),
  43446. node,
  43447. onlyExported
  43448. );
  43449. return canCache ? node._resolvedReference = resolved : resolved;
  43450. }
  43451. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  43452. if (typeof name === "string") {
  43453. if (scope.imports[name]) {
  43454. return resolveTypeFromImport(ctx, node, name, scope);
  43455. } else {
  43456. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  43457. if (lookupSource[name]) {
  43458. return lookupSource[name];
  43459. } else {
  43460. const globalScopes = resolveGlobalScope(ctx);
  43461. if (globalScopes) {
  43462. for (const s of globalScopes) {
  43463. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  43464. if (src[name]) {
  43465. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  43466. return src[name];
  43467. }
  43468. }
  43469. }
  43470. }
  43471. }
  43472. } else {
  43473. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  43474. if (ns) {
  43475. if (ns.type !== "TSModuleDeclaration") {
  43476. ns = ns._ns;
  43477. }
  43478. if (ns) {
  43479. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  43480. return innerResolveTypeReference(
  43481. ctx,
  43482. childScope,
  43483. name.length > 2 ? name.slice(1) : name[name.length - 1],
  43484. node,
  43485. !ns.declare
  43486. );
  43487. }
  43488. }
  43489. }
  43490. }
  43491. function getReferenceName(node) {
  43492. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  43493. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  43494. return ref.name;
  43495. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  43496. return qualifiedNameToPath(ref);
  43497. } else {
  43498. return "default";
  43499. }
  43500. }
  43501. function qualifiedNameToPath(node) {
  43502. if (node.type === "Identifier") {
  43503. return [node.name];
  43504. } else {
  43505. return [...qualifiedNameToPath(node.left), node.right.name];
  43506. }
  43507. }
  43508. function resolveGlobalScope(ctx) {
  43509. if (ctx.options.globalTypeFiles) {
  43510. const fs = resolveFS(ctx);
  43511. if (!fs) {
  43512. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  43513. }
  43514. return ctx.options.globalTypeFiles.map(
  43515. (file) => fileToScope(ctx, normalizePath(file), true)
  43516. );
  43517. }
  43518. }
  43519. let ts;
  43520. let loadTS;
  43521. function registerTS(_loadTS) {
  43522. loadTS = () => {
  43523. try {
  43524. return _loadTS();
  43525. } catch (err) {
  43526. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  43527. throw new Error(
  43528. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  43529. );
  43530. } else {
  43531. throw new Error(
  43532. "Failed to load TypeScript for resolving imported types."
  43533. );
  43534. }
  43535. }
  43536. };
  43537. }
  43538. function resolveFS(ctx) {
  43539. if (ctx.fs) {
  43540. return ctx.fs;
  43541. }
  43542. if (!ts && loadTS) {
  43543. ts = loadTS();
  43544. }
  43545. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  43546. if (!fs) {
  43547. return;
  43548. }
  43549. return ctx.fs = {
  43550. fileExists(file) {
  43551. if (file.endsWith(".vue.ts")) {
  43552. file = file.replace(/\.ts$/, "");
  43553. }
  43554. return fs.fileExists(file);
  43555. },
  43556. readFile(file) {
  43557. if (file.endsWith(".vue.ts")) {
  43558. file = file.replace(/\.ts$/, "");
  43559. }
  43560. return fs.readFile(file);
  43561. },
  43562. realpath: fs.realpath
  43563. };
  43564. }
  43565. function resolveTypeFromImport(ctx, node, name, scope) {
  43566. const { source, imported } = scope.imports[name];
  43567. const sourceScope = importSourceToScope(ctx, node, scope, source);
  43568. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  43569. }
  43570. function importSourceToScope(ctx, node, scope, source) {
  43571. let fs;
  43572. try {
  43573. fs = resolveFS(ctx);
  43574. } catch (err) {
  43575. return ctx.error(err.message, node, scope);
  43576. }
  43577. if (!fs) {
  43578. return ctx.error(
  43579. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  43580. node,
  43581. scope
  43582. );
  43583. }
  43584. let resolved = scope.resolvedImportSources[source];
  43585. if (!resolved) {
  43586. if (source.startsWith("..")) {
  43587. const osSpecificJoinFn = joinPaths;
  43588. const filename = osSpecificJoinFn(dirname$2(scope.filename), source);
  43589. resolved = resolveExt(filename, fs);
  43590. } else if (source.startsWith(".")) {
  43591. const filename = joinPaths(dirname$2(scope.filename), source);
  43592. resolved = resolveExt(filename, fs);
  43593. } else {
  43594. {
  43595. return ctx.error(
  43596. `Type import from non-relative sources is not supported in the browser build.`,
  43597. node,
  43598. scope
  43599. );
  43600. }
  43601. }
  43602. if (resolved) {
  43603. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  43604. }
  43605. }
  43606. if (resolved) {
  43607. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  43608. return fileToScope(ctx, resolved);
  43609. } else {
  43610. return ctx.error(
  43611. `Failed to resolve import source ${JSON.stringify(source)}.`,
  43612. node,
  43613. scope
  43614. );
  43615. }
  43616. }
  43617. function resolveExt(filename, fs) {
  43618. filename = filename.replace(/\.js$/, "");
  43619. const tryResolve = (filename2) => {
  43620. if (fs.fileExists(filename2))
  43621. return filename2;
  43622. };
  43623. return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.d.ts`));
  43624. }
  43625. const tsConfigCache = createCache();
  43626. const tsConfigRefMap = /* @__PURE__ */ new Map();
  43627. const fileToScopeCache = createCache();
  43628. function invalidateTypeCache(filename) {
  43629. filename = normalizePath(filename);
  43630. fileToScopeCache.delete(filename);
  43631. tsConfigCache.delete(filename);
  43632. const affectedConfig = tsConfigRefMap.get(filename);
  43633. if (affectedConfig)
  43634. tsConfigCache.delete(affectedConfig);
  43635. }
  43636. function fileToScope(ctx, filename, asGlobal = false) {
  43637. const cached = fileToScopeCache.get(filename);
  43638. if (cached) {
  43639. return cached;
  43640. }
  43641. const fs = resolveFS(ctx);
  43642. const source = fs.readFile(filename) || "";
  43643. const body = parseFile(filename, source, ctx.options.babelParserPlugins);
  43644. const scope = new TypeScope(filename, source, 0, recordImports(body));
  43645. recordTypes(ctx, body, scope, asGlobal);
  43646. fileToScopeCache.set(filename, scope);
  43647. return scope;
  43648. }
  43649. function parseFile(filename, content, parserPlugins) {
  43650. const ext = extname(filename);
  43651. if (ext === ".ts" || ext === ".tsx") {
  43652. return parse_1$1(content, {
  43653. plugins: resolveParserPlugins(
  43654. ext.slice(1),
  43655. parserPlugins,
  43656. filename.endsWith(".d.ts")
  43657. ),
  43658. sourceType: "module"
  43659. }).program.body;
  43660. } else if (ext === ".vue") {
  43661. const {
  43662. descriptor: { script, scriptSetup }
  43663. } = parse$7(content);
  43664. if (!script && !scriptSetup) {
  43665. return [];
  43666. }
  43667. const scriptOffset = script ? script.loc.start.offset : Infinity;
  43668. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  43669. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  43670. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  43671. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  43672. if (secondBlock) {
  43673. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  43674. }
  43675. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  43676. return parse_1$1(scriptContent, {
  43677. plugins: resolveParserPlugins(lang, parserPlugins),
  43678. sourceType: "module"
  43679. }).program.body;
  43680. }
  43681. return [];
  43682. }
  43683. function ctxToScope(ctx) {
  43684. if (ctx.scope) {
  43685. return ctx.scope;
  43686. }
  43687. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  43688. const scope = new TypeScope(
  43689. ctx.filename,
  43690. ctx.source,
  43691. "startOffset" in ctx ? ctx.startOffset : 0,
  43692. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  43693. );
  43694. recordTypes(ctx, body, scope);
  43695. return ctx.scope = scope;
  43696. }
  43697. function moduleDeclToScope(ctx, node, parentScope) {
  43698. if (node._resolvedChildScope) {
  43699. return node._resolvedChildScope;
  43700. }
  43701. const scope = createChildScope(parentScope);
  43702. if (node.body.type === "TSModuleDeclaration") {
  43703. const decl = node.body;
  43704. decl._ownerScope = scope;
  43705. const id = getId(decl.id);
  43706. scope.types[id] = scope.exportedTypes[id] = decl;
  43707. } else {
  43708. recordTypes(ctx, node.body.body, scope);
  43709. }
  43710. return node._resolvedChildScope = scope;
  43711. }
  43712. function createChildScope(parentScope) {
  43713. return new TypeScope(
  43714. parentScope.filename,
  43715. parentScope.source,
  43716. parentScope.offset,
  43717. Object.create(parentScope.imports),
  43718. Object.create(parentScope.types),
  43719. Object.create(parentScope.declares)
  43720. );
  43721. }
  43722. const importExportRE = /^Import|^Export/;
  43723. function recordTypes(ctx, body, scope, asGlobal = false) {
  43724. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  43725. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  43726. for (const stmt of body) {
  43727. if (asGlobal) {
  43728. if (isAmbient) {
  43729. if (stmt.declare) {
  43730. recordType(stmt, types, declares);
  43731. }
  43732. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  43733. for (const s of stmt.body.body) {
  43734. recordType(s, types, declares);
  43735. }
  43736. }
  43737. } else {
  43738. recordType(stmt, types, declares);
  43739. }
  43740. }
  43741. if (!asGlobal) {
  43742. for (const stmt of body) {
  43743. if (stmt.type === "ExportNamedDeclaration") {
  43744. if (stmt.declaration) {
  43745. recordType(stmt.declaration, types, declares);
  43746. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  43747. } else {
  43748. for (const spec of stmt.specifiers) {
  43749. if (spec.type === "ExportSpecifier") {
  43750. const local = spec.local.name;
  43751. const exported = getId(spec.exported);
  43752. if (stmt.source) {
  43753. imports[exported] = {
  43754. source: stmt.source.value,
  43755. imported: local
  43756. };
  43757. exportedTypes[exported] = {
  43758. type: "TSTypeReference",
  43759. typeName: {
  43760. type: "Identifier",
  43761. name: local
  43762. },
  43763. _ownerScope: scope
  43764. };
  43765. } else if (types[local]) {
  43766. exportedTypes[exported] = types[local];
  43767. }
  43768. }
  43769. }
  43770. }
  43771. } else if (stmt.type === "ExportAllDeclaration") {
  43772. const sourceScope = importSourceToScope(
  43773. ctx,
  43774. stmt.source,
  43775. scope,
  43776. stmt.source.value
  43777. );
  43778. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  43779. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  43780. if (stmt.declaration.type !== "Identifier") {
  43781. recordType(stmt.declaration, types, declares, "default");
  43782. recordType(
  43783. stmt.declaration,
  43784. exportedTypes,
  43785. exportedDeclares,
  43786. "default"
  43787. );
  43788. } else if (types[stmt.declaration.name]) {
  43789. exportedTypes["default"] = types[stmt.declaration.name];
  43790. }
  43791. }
  43792. }
  43793. }
  43794. for (const key of Object.keys(types)) {
  43795. const node = types[key];
  43796. node._ownerScope = scope;
  43797. if (node._ns)
  43798. node._ns._ownerScope = scope;
  43799. }
  43800. for (const key of Object.keys(declares)) {
  43801. declares[key]._ownerScope = scope;
  43802. }
  43803. }
  43804. function recordType(node, types, declares, overwriteId) {
  43805. switch (node.type) {
  43806. case "TSInterfaceDeclaration":
  43807. case "TSEnumDeclaration":
  43808. case "TSModuleDeclaration": {
  43809. const id = overwriteId || getId(node.id);
  43810. let existing = types[id];
  43811. if (existing) {
  43812. if (node.type === "TSModuleDeclaration") {
  43813. if (existing.type === "TSModuleDeclaration") {
  43814. mergeNamespaces(existing, node);
  43815. } else {
  43816. attachNamespace(existing, node);
  43817. }
  43818. break;
  43819. }
  43820. if (existing.type === "TSModuleDeclaration") {
  43821. types[id] = node;
  43822. attachNamespace(node, existing);
  43823. break;
  43824. }
  43825. if (existing.type !== node.type) {
  43826. break;
  43827. }
  43828. if (node.type === "TSInterfaceDeclaration") {
  43829. existing.body.body.push(...node.body.body);
  43830. } else {
  43831. existing.members.push(...node.members);
  43832. }
  43833. } else {
  43834. types[id] = node;
  43835. }
  43836. break;
  43837. }
  43838. case "ClassDeclaration":
  43839. if (overwriteId || node.id)
  43840. types[overwriteId || getId(node.id)] = node;
  43841. break;
  43842. case "TSTypeAliasDeclaration":
  43843. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  43844. break;
  43845. case "TSDeclareFunction":
  43846. if (node.id)
  43847. declares[node.id.name] = node;
  43848. break;
  43849. case "VariableDeclaration": {
  43850. if (node.declare) {
  43851. for (const decl of node.declarations) {
  43852. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  43853. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  43854. }
  43855. }
  43856. }
  43857. break;
  43858. }
  43859. }
  43860. }
  43861. function mergeNamespaces(to, from) {
  43862. const toBody = to.body;
  43863. const fromBody = from.body;
  43864. if (toBody.type === "TSModuleDeclaration") {
  43865. if (fromBody.type === "TSModuleDeclaration") {
  43866. mergeNamespaces(toBody, fromBody);
  43867. } else {
  43868. fromBody.body.push({
  43869. type: "ExportNamedDeclaration",
  43870. declaration: toBody,
  43871. exportKind: "type",
  43872. specifiers: []
  43873. });
  43874. }
  43875. } else if (fromBody.type === "TSModuleDeclaration") {
  43876. toBody.body.push({
  43877. type: "ExportNamedDeclaration",
  43878. declaration: fromBody,
  43879. exportKind: "type",
  43880. specifiers: []
  43881. });
  43882. } else {
  43883. toBody.body.push(...fromBody.body);
  43884. }
  43885. }
  43886. function attachNamespace(to, ns) {
  43887. if (!to._ns) {
  43888. to._ns = ns;
  43889. } else {
  43890. mergeNamespaces(to._ns, ns);
  43891. }
  43892. }
  43893. function recordImports(body) {
  43894. const imports = /* @__PURE__ */ Object.create(null);
  43895. for (const s of body) {
  43896. recordImport(s, imports);
  43897. }
  43898. return imports;
  43899. }
  43900. function recordImport(node, imports) {
  43901. if (node.type !== "ImportDeclaration") {
  43902. return;
  43903. }
  43904. for (const s of node.specifiers) {
  43905. imports[s.local.name] = {
  43906. imported: getImportedName(s),
  43907. source: node.source.value
  43908. };
  43909. }
  43910. }
  43911. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)) {
  43912. try {
  43913. switch (node.type) {
  43914. case "TSStringKeyword":
  43915. return ["String"];
  43916. case "TSNumberKeyword":
  43917. return ["Number"];
  43918. case "TSBooleanKeyword":
  43919. return ["Boolean"];
  43920. case "TSObjectKeyword":
  43921. return ["Object"];
  43922. case "TSNullKeyword":
  43923. return ["null"];
  43924. case "TSTypeLiteral":
  43925. case "TSInterfaceDeclaration": {
  43926. const types = /* @__PURE__ */ new Set();
  43927. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  43928. for (const m of members) {
  43929. if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  43930. types.add("Function");
  43931. } else {
  43932. types.add("Object");
  43933. }
  43934. }
  43935. return types.size ? Array.from(types) : ["Object"];
  43936. }
  43937. case "TSPropertySignature":
  43938. if (node.typeAnnotation) {
  43939. return inferRuntimeType(
  43940. ctx,
  43941. node.typeAnnotation.typeAnnotation,
  43942. scope
  43943. );
  43944. }
  43945. break;
  43946. case "TSMethodSignature":
  43947. case "TSFunctionType":
  43948. return ["Function"];
  43949. case "TSArrayType":
  43950. case "TSTupleType":
  43951. return ["Array"];
  43952. case "TSLiteralType":
  43953. switch (node.literal.type) {
  43954. case "StringLiteral":
  43955. return ["String"];
  43956. case "BooleanLiteral":
  43957. return ["Boolean"];
  43958. case "NumericLiteral":
  43959. case "BigIntLiteral":
  43960. return ["Number"];
  43961. default:
  43962. return [UNKNOWN_TYPE];
  43963. }
  43964. case "TSTypeReference": {
  43965. const resolved = resolveTypeReference(ctx, node, scope);
  43966. if (resolved) {
  43967. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  43968. }
  43969. if (node.typeName.type === "Identifier") {
  43970. switch (node.typeName.name) {
  43971. case "Array":
  43972. case "Function":
  43973. case "Object":
  43974. case "Set":
  43975. case "Map":
  43976. case "WeakSet":
  43977. case "WeakMap":
  43978. case "Date":
  43979. case "Promise":
  43980. case "Error":
  43981. return [node.typeName.name];
  43982. case "Partial":
  43983. case "Required":
  43984. case "Readonly":
  43985. case "Record":
  43986. case "Pick":
  43987. case "Omit":
  43988. case "InstanceType":
  43989. return ["Object"];
  43990. case "Uppercase":
  43991. case "Lowercase":
  43992. case "Capitalize":
  43993. case "Uncapitalize":
  43994. return ["String"];
  43995. case "Parameters":
  43996. case "ConstructorParameters":
  43997. return ["Array"];
  43998. case "NonNullable":
  43999. if (node.typeParameters && node.typeParameters.params[0]) {
  44000. return inferRuntimeType(
  44001. ctx,
  44002. node.typeParameters.params[0],
  44003. scope
  44004. ).filter((t) => t !== "null");
  44005. }
  44006. break;
  44007. case "Extract":
  44008. if (node.typeParameters && node.typeParameters.params[1]) {
  44009. return inferRuntimeType(
  44010. ctx,
  44011. node.typeParameters.params[1],
  44012. scope
  44013. );
  44014. }
  44015. break;
  44016. case "Exclude":
  44017. case "OmitThisParameter":
  44018. if (node.typeParameters && node.typeParameters.params[0]) {
  44019. return inferRuntimeType(
  44020. ctx,
  44021. node.typeParameters.params[0],
  44022. scope
  44023. );
  44024. }
  44025. break;
  44026. }
  44027. }
  44028. break;
  44029. }
  44030. case "TSParenthesizedType":
  44031. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  44032. case "TSUnionType":
  44033. return flattenTypes(ctx, node.types, scope);
  44034. case "TSIntersectionType": {
  44035. return flattenTypes(ctx, node.types, scope).filter(
  44036. (t) => t !== UNKNOWN_TYPE
  44037. );
  44038. }
  44039. case "TSEnumDeclaration":
  44040. return inferEnumType(node);
  44041. case "TSSymbolKeyword":
  44042. return ["Symbol"];
  44043. case "TSIndexedAccessType": {
  44044. const types = resolveIndexType(ctx, node, scope);
  44045. return flattenTypes(ctx, types, scope);
  44046. }
  44047. case "ClassDeclaration":
  44048. return ["Object"];
  44049. case "TSImportType": {
  44050. const sourceScope = importSourceToScope(
  44051. ctx,
  44052. node.argument,
  44053. scope,
  44054. node.argument.value
  44055. );
  44056. const resolved = resolveTypeReference(ctx, node, sourceScope);
  44057. if (resolved) {
  44058. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  44059. }
  44060. break;
  44061. }
  44062. case "TSTypeQuery": {
  44063. const id = node.exprName;
  44064. if (id.type === "Identifier") {
  44065. const matched = scope.declares[id.name];
  44066. if (matched) {
  44067. return inferRuntimeType(ctx, matched, matched._ownerScope);
  44068. }
  44069. }
  44070. break;
  44071. }
  44072. }
  44073. } catch (e) {
  44074. }
  44075. return [UNKNOWN_TYPE];
  44076. }
  44077. function flattenTypes(ctx, types, scope) {
  44078. if (types.length === 1) {
  44079. return inferRuntimeType(ctx, types[0], scope);
  44080. }
  44081. return [
  44082. ...new Set(
  44083. [].concat(
  44084. ...types.map((t) => inferRuntimeType(ctx, t, scope))
  44085. )
  44086. )
  44087. ];
  44088. }
  44089. function inferEnumType(node) {
  44090. const types = /* @__PURE__ */ new Set();
  44091. for (const m of node.members) {
  44092. if (m.initializer) {
  44093. switch (m.initializer.type) {
  44094. case "StringLiteral":
  44095. types.add("String");
  44096. break;
  44097. case "NumericLiteral":
  44098. types.add("Number");
  44099. break;
  44100. }
  44101. }
  44102. }
  44103. return types.size ? [...types] : ["Number"];
  44104. }
  44105. function resolveExtractPropTypes({ props }, scope) {
  44106. const res = { props: {} };
  44107. for (const key in props) {
  44108. const raw = props[key];
  44109. res.props[key] = reverseInferType(
  44110. raw.key,
  44111. raw.typeAnnotation.typeAnnotation,
  44112. scope
  44113. );
  44114. }
  44115. return res;
  44116. }
  44117. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  44118. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  44119. const typeType = findStaticPropertyType(node, "type");
  44120. if (typeType) {
  44121. const requiredType = findStaticPropertyType(node, "required");
  44122. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  44123. return reverseInferType(key, typeType, scope, optional2, false);
  44124. }
  44125. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  44126. if (node.typeName.name.endsWith("Constructor")) {
  44127. return createProperty(
  44128. key,
  44129. ctorToType(node.typeName.name),
  44130. scope,
  44131. optional
  44132. );
  44133. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  44134. return createProperty(key, node.typeParameters.params[0], scope, optional);
  44135. }
  44136. }
  44137. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  44138. for (const t of node.typeParameters.params) {
  44139. const inferred = reverseInferType(key, t, scope, optional);
  44140. if (inferred)
  44141. return inferred;
  44142. }
  44143. }
  44144. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  44145. }
  44146. function ctorToType(ctorType) {
  44147. const ctor = ctorType.slice(0, -11);
  44148. switch (ctor) {
  44149. case "String":
  44150. case "Number":
  44151. case "Boolean":
  44152. return { type: `TS${ctor}Keyword` };
  44153. case "Array":
  44154. case "Function":
  44155. case "Object":
  44156. case "Set":
  44157. case "Map":
  44158. case "WeakSet":
  44159. case "WeakMap":
  44160. case "Date":
  44161. case "Promise":
  44162. return {
  44163. type: "TSTypeReference",
  44164. typeName: { type: "Identifier", name: ctor }
  44165. };
  44166. }
  44167. return { type: `TSNullKeyword` };
  44168. }
  44169. function findStaticPropertyType(node, key) {
  44170. const prop = node.members.find(
  44171. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  44172. );
  44173. return prop && prop.typeAnnotation.typeAnnotation;
  44174. }
  44175. function resolveReturnType(ctx, arg, scope) {
  44176. var _a;
  44177. let resolved = arg;
  44178. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  44179. resolved = resolveTypeReference(ctx, arg, scope);
  44180. }
  44181. if (!resolved)
  44182. return;
  44183. if (resolved.type === "TSFunctionType") {
  44184. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  44185. }
  44186. if (resolved.type === "TSDeclareFunction") {
  44187. return resolved.returnType;
  44188. }
  44189. }
  44190. function resolveUnionType(ctx, node, scope) {
  44191. if (node.type === "TSTypeReference") {
  44192. const resolved = resolveTypeReference(ctx, node, scope);
  44193. if (resolved)
  44194. node = resolved;
  44195. }
  44196. let types;
  44197. if (node.type === "TSUnionType") {
  44198. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  44199. } else {
  44200. types = [node];
  44201. }
  44202. return types;
  44203. }
  44204. const DEFINE_MODEL = "defineModel";
  44205. function processDefineModel(ctx, node, declId) {
  44206. if (!isCallOf(node, DEFINE_MODEL)) {
  44207. return false;
  44208. }
  44209. ctx.hasDefineModelCall = true;
  44210. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  44211. let modelName;
  44212. let options;
  44213. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  44214. const hasName = arg0 && arg0.type === "StringLiteral";
  44215. if (hasName) {
  44216. modelName = arg0.value;
  44217. options = node.arguments[1];
  44218. } else {
  44219. modelName = "modelValue";
  44220. options = arg0;
  44221. }
  44222. if (ctx.modelDecls[modelName]) {
  44223. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  44224. }
  44225. let optionsString = options && ctx.getString(options);
  44226. let optionsRemoved = !options;
  44227. const runtimeOptionNodes = [];
  44228. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  44229. let removed = 0;
  44230. for (let i = options.properties.length - 1; i >= 0; i--) {
  44231. const p = options.properties[i];
  44232. const next = options.properties[i + 1];
  44233. const start = p.start;
  44234. const end = next ? next.start : options.end - 1;
  44235. 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"))) {
  44236. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  44237. } else {
  44238. removed++;
  44239. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  44240. runtimeOptionNodes.push(p);
  44241. }
  44242. }
  44243. if (removed === options.properties.length) {
  44244. optionsRemoved = true;
  44245. ctx.s.remove(
  44246. ctx.startOffset + (hasName ? arg0.end : options.start),
  44247. ctx.startOffset + options.end
  44248. );
  44249. }
  44250. }
  44251. ctx.modelDecls[modelName] = {
  44252. type,
  44253. options: optionsString,
  44254. runtimeOptionNodes,
  44255. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  44256. };
  44257. ctx.bindingMetadata[modelName] = "props";
  44258. ctx.s.overwrite(
  44259. ctx.startOffset + node.callee.start,
  44260. ctx.startOffset + node.callee.end,
  44261. ctx.helper("useModel")
  44262. );
  44263. ctx.s.appendLeft(
  44264. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  44265. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  44266. );
  44267. return true;
  44268. }
  44269. function genModelProps(ctx) {
  44270. if (!ctx.hasDefineModelCall)
  44271. return;
  44272. const isProd = !!ctx.options.isProd;
  44273. let modelPropsDecl = "";
  44274. for (const [name, { type, options }] of Object.entries(ctx.modelDecls)) {
  44275. let skipCheck = false;
  44276. let runtimeTypes = type && inferRuntimeType(ctx, type);
  44277. if (runtimeTypes) {
  44278. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  44279. runtimeTypes = runtimeTypes.filter((el) => {
  44280. if (el === UNKNOWN_TYPE)
  44281. return false;
  44282. return isProd ? el === "Boolean" || el === "Function" && options : true;
  44283. });
  44284. skipCheck = !isProd && hasUnknownType && runtimeTypes.length > 0;
  44285. }
  44286. let runtimeType = runtimeTypes && runtimeTypes.length > 0 && toRuntimeTypeString(runtimeTypes) || void 0;
  44287. const codegenOptions = concatStrings([
  44288. runtimeType && `type: ${runtimeType}`,
  44289. skipCheck && "skipCheck: true"
  44290. ]);
  44291. let decl;
  44292. if (runtimeType && options) {
  44293. decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
  44294. } else {
  44295. decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
  44296. }
  44297. modelPropsDecl += `
  44298. ${JSON.stringify(name)}: ${decl},`;
  44299. const modifierPropName = JSON.stringify(
  44300. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  44301. );
  44302. modelPropsDecl += `
  44303. ${modifierPropName}: {},`;
  44304. }
  44305. return `{${modelPropsDecl}
  44306. }`;
  44307. }
  44308. const DEFINE_PROPS = "defineProps";
  44309. const WITH_DEFAULTS = "withDefaults";
  44310. function processDefineProps(ctx, node, declId) {
  44311. if (!isCallOf(node, DEFINE_PROPS)) {
  44312. return processWithDefaults(ctx, node, declId);
  44313. }
  44314. if (ctx.hasDefinePropsCall) {
  44315. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  44316. }
  44317. ctx.hasDefinePropsCall = true;
  44318. ctx.propsRuntimeDecl = node.arguments[0];
  44319. if (ctx.propsRuntimeDecl) {
  44320. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  44321. if (!(key in ctx.bindingMetadata)) {
  44322. ctx.bindingMetadata[key] = "props";
  44323. }
  44324. }
  44325. }
  44326. if (node.typeParameters) {
  44327. if (ctx.propsRuntimeDecl) {
  44328. ctx.error(
  44329. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  44330. node
  44331. );
  44332. }
  44333. ctx.propsTypeDecl = node.typeParameters.params[0];
  44334. }
  44335. if (declId && declId.type === "ObjectPattern") {
  44336. processPropsDestructure(ctx, declId);
  44337. }
  44338. ctx.propsCall = node;
  44339. ctx.propsDecl = declId;
  44340. return true;
  44341. }
  44342. function processWithDefaults(ctx, node, declId) {
  44343. if (!isCallOf(node, WITH_DEFAULTS)) {
  44344. return false;
  44345. }
  44346. if (!processDefineProps(ctx, node.arguments[0], declId)) {
  44347. ctx.error(
  44348. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  44349. node.arguments[0] || node
  44350. );
  44351. }
  44352. if (ctx.propsRuntimeDecl) {
  44353. ctx.error(
  44354. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  44355. node
  44356. );
  44357. }
  44358. if (ctx.propsDestructureDecl) {
  44359. ctx.error(
  44360. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  44361. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
  44362. node.callee
  44363. );
  44364. }
  44365. ctx.propsRuntimeDefaults = node.arguments[1];
  44366. if (!ctx.propsRuntimeDefaults) {
  44367. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  44368. }
  44369. ctx.propsCall = node;
  44370. return true;
  44371. }
  44372. function genRuntimeProps(ctx) {
  44373. let propsDecls;
  44374. if (ctx.propsRuntimeDecl) {
  44375. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  44376. if (ctx.propsDestructureDecl) {
  44377. const defaults = [];
  44378. for (const key in ctx.propsDestructuredBindings) {
  44379. const d = genDestructuredDefaultValue(ctx, key);
  44380. const finalKey = getEscapedPropName(key);
  44381. if (d)
  44382. defaults.push(
  44383. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  44384. );
  44385. }
  44386. if (defaults.length) {
  44387. propsDecls = `/*#__PURE__*/${ctx.helper(
  44388. `mergeDefaults`
  44389. )}(${propsDecls}, {
  44390. ${defaults.join(",\n ")}
  44391. })`;
  44392. }
  44393. }
  44394. } else if (ctx.propsTypeDecl) {
  44395. propsDecls = extractRuntimeProps(ctx);
  44396. }
  44397. const modelsDecls = genModelProps(ctx);
  44398. if (propsDecls && modelsDecls) {
  44399. return `/*#__PURE__*/${ctx.helper(
  44400. "mergeModels"
  44401. )}(${propsDecls}, ${modelsDecls})`;
  44402. } else {
  44403. return modelsDecls || propsDecls;
  44404. }
  44405. }
  44406. function extractRuntimeProps(ctx) {
  44407. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  44408. if (!props.length) {
  44409. return;
  44410. }
  44411. const propStrings = [];
  44412. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  44413. for (const prop of props) {
  44414. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  44415. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  44416. ctx.bindingMetadata[prop.key] = "props";
  44417. }
  44418. }
  44419. let propsDecls = `{
  44420. ${propStrings.join(",\n ")}
  44421. }`;
  44422. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  44423. propsDecls = `/*#__PURE__*/${ctx.helper(
  44424. "mergeDefaults"
  44425. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  44426. }
  44427. return propsDecls;
  44428. }
  44429. function resolveRuntimePropsFromType(ctx, node) {
  44430. const props = [];
  44431. const elements = resolveTypeElements(ctx, node);
  44432. for (const key in elements.props) {
  44433. const e = elements.props[key];
  44434. let type = inferRuntimeType(ctx, e);
  44435. let skipCheck = false;
  44436. if (type.includes(UNKNOWN_TYPE)) {
  44437. if (type.includes("Boolean") || type.includes("Function")) {
  44438. type = type.filter((t) => t !== UNKNOWN_TYPE);
  44439. skipCheck = true;
  44440. } else {
  44441. type = ["null"];
  44442. }
  44443. }
  44444. props.push({
  44445. key,
  44446. required: !e.optional,
  44447. type: type || [`null`],
  44448. skipCheck
  44449. });
  44450. }
  44451. return props;
  44452. }
  44453. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  44454. let defaultString;
  44455. const destructured = genDestructuredDefaultValue(ctx, key, type);
  44456. if (destructured) {
  44457. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  44458. } else if (hasStaticDefaults) {
  44459. const prop = ctx.propsRuntimeDefaults.properties.find(
  44460. (node) => {
  44461. if (node.type === "SpreadElement")
  44462. return false;
  44463. return resolveObjectKey(node.key, node.computed) === key;
  44464. }
  44465. );
  44466. if (prop) {
  44467. if (prop.type === "ObjectProperty") {
  44468. defaultString = `default: ${ctx.getString(prop.value)}`;
  44469. } else {
  44470. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  44471. }
  44472. }
  44473. }
  44474. const finalKey = getEscapedPropName(key);
  44475. if (!ctx.options.isProd) {
  44476. return `${finalKey}: { ${concatStrings([
  44477. `type: ${toRuntimeTypeString(type)}`,
  44478. `required: ${required}`,
  44479. skipCheck && "skipCheck: true",
  44480. defaultString
  44481. ])} }`;
  44482. } else if (type.some(
  44483. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  44484. )) {
  44485. return `${finalKey}: { ${concatStrings([
  44486. `type: ${toRuntimeTypeString(type)}`,
  44487. defaultString
  44488. ])} }`;
  44489. } else {
  44490. if (ctx.isCE) {
  44491. if (defaultString) {
  44492. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  44493. type
  44494. )} }`}`;
  44495. } else {
  44496. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  44497. }
  44498. }
  44499. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  44500. }
  44501. }
  44502. function hasStaticWithDefaults(ctx) {
  44503. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  44504. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  44505. ));
  44506. }
  44507. function genDestructuredDefaultValue(ctx, key, inferredType) {
  44508. const destructured = ctx.propsDestructuredBindings[key];
  44509. const defaultVal = destructured && destructured.default;
  44510. if (defaultVal) {
  44511. const value = ctx.getString(defaultVal);
  44512. const unwrapped = unwrapTSNode(defaultVal);
  44513. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  44514. const valueType = inferValueType(unwrapped);
  44515. if (valueType && !inferredType.includes(valueType)) {
  44516. ctx.error(
  44517. `Default value of prop "${key}" does not match declared type.`,
  44518. unwrapped
  44519. );
  44520. }
  44521. }
  44522. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  44523. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  44524. return {
  44525. valueString: needFactoryWrap ? `() => (${value})` : value,
  44526. needSkipFactory
  44527. };
  44528. }
  44529. }
  44530. function inferValueType(node) {
  44531. switch (node.type) {
  44532. case "StringLiteral":
  44533. return "String";
  44534. case "NumericLiteral":
  44535. return "Number";
  44536. case "BooleanLiteral":
  44537. return "Boolean";
  44538. case "ObjectExpression":
  44539. return "Object";
  44540. case "ArrayExpression":
  44541. return "Array";
  44542. case "FunctionExpression":
  44543. case "ArrowFunctionExpression":
  44544. return "Function";
  44545. }
  44546. }
  44547. function processPropsDestructure(ctx, declId) {
  44548. if (!ctx.options.propsDestructure) {
  44549. return;
  44550. }
  44551. warnOnce$3(
  44552. `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.
  44553. To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
  44554. );
  44555. ctx.propsDestructureDecl = declId;
  44556. const registerBinding = (key, local, defaultValue) => {
  44557. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  44558. if (local !== key) {
  44559. ctx.bindingMetadata[local] = "props-aliased";
  44560. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  44561. }
  44562. };
  44563. for (const prop of declId.properties) {
  44564. if (prop.type === "ObjectProperty") {
  44565. const propKey = resolveObjectKey(prop.key, prop.computed);
  44566. if (!propKey) {
  44567. ctx.error(
  44568. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  44569. prop.key
  44570. );
  44571. }
  44572. if (prop.value.type === "AssignmentPattern") {
  44573. const { left, right } = prop.value;
  44574. if (left.type !== "Identifier") {
  44575. ctx.error(
  44576. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44577. left
  44578. );
  44579. }
  44580. registerBinding(propKey, left.name, right);
  44581. } else if (prop.value.type === "Identifier") {
  44582. registerBinding(propKey, prop.value.name);
  44583. } else {
  44584. ctx.error(
  44585. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44586. prop.value
  44587. );
  44588. }
  44589. } else {
  44590. ctx.propsDestructureRestId = prop.argument.name;
  44591. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  44592. }
  44593. }
  44594. }
  44595. function transformDestructuredProps(ctx, vueImportAliases) {
  44596. if (!ctx.options.propsDestructure) {
  44597. return;
  44598. }
  44599. const rootScope = {};
  44600. const scopeStack = [rootScope];
  44601. let currentScope = rootScope;
  44602. const excludedIds = /* @__PURE__ */ new WeakSet();
  44603. const parentStack = [];
  44604. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  44605. for (const key in ctx.propsDestructuredBindings) {
  44606. const { local } = ctx.propsDestructuredBindings[key];
  44607. rootScope[local] = true;
  44608. propsLocalToPublicMap[local] = key;
  44609. }
  44610. function pushScope() {
  44611. scopeStack.push(currentScope = Object.create(currentScope));
  44612. }
  44613. function popScope() {
  44614. scopeStack.pop();
  44615. currentScope = scopeStack[scopeStack.length - 1] || null;
  44616. }
  44617. function registerLocalBinding(id) {
  44618. excludedIds.add(id);
  44619. if (currentScope) {
  44620. currentScope[id.name] = false;
  44621. } else {
  44622. ctx.error(
  44623. "registerBinding called without active scope, something is wrong.",
  44624. id
  44625. );
  44626. }
  44627. }
  44628. function walkScope(node, isRoot = false) {
  44629. for (const stmt of node.body) {
  44630. if (stmt.type === "VariableDeclaration") {
  44631. walkVariableDeclaration(stmt, isRoot);
  44632. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  44633. if (stmt.declare || !stmt.id)
  44634. continue;
  44635. registerLocalBinding(stmt.id);
  44636. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  44637. walkVariableDeclaration(stmt.left);
  44638. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  44639. walkVariableDeclaration(stmt.declaration, isRoot);
  44640. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  44641. walkVariableDeclaration(stmt.body, isRoot);
  44642. }
  44643. }
  44644. }
  44645. function walkVariableDeclaration(stmt, isRoot = false) {
  44646. if (stmt.declare) {
  44647. return;
  44648. }
  44649. for (const decl of stmt.declarations) {
  44650. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  44651. for (const id of extractIdentifiers$1(decl.id)) {
  44652. if (isDefineProps) {
  44653. excludedIds.add(id);
  44654. } else {
  44655. registerLocalBinding(id);
  44656. }
  44657. }
  44658. }
  44659. }
  44660. function rewriteId(id, parent, parentStack2) {
  44661. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  44662. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  44663. }
  44664. if (isStaticProperty(parent) && parent.shorthand) {
  44665. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  44666. ctx.s.appendLeft(
  44667. id.end + ctx.startOffset,
  44668. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  44669. );
  44670. }
  44671. } else {
  44672. ctx.s.overwrite(
  44673. id.start + ctx.startOffset,
  44674. id.end + ctx.startOffset,
  44675. genPropsAccessExp(propsLocalToPublicMap[id.name])
  44676. );
  44677. }
  44678. }
  44679. function checkUsage(node, method, alias = method) {
  44680. if (isCallOf(node, alias)) {
  44681. const arg = unwrapTSNode(node.arguments[0]);
  44682. if (arg.type === "Identifier" && currentScope[arg.name]) {
  44683. ctx.error(
  44684. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  44685. arg
  44686. );
  44687. }
  44688. }
  44689. }
  44690. const ast = ctx.scriptSetupAst;
  44691. walkScope(ast, true);
  44692. walk$2(ast, {
  44693. enter(node, parent) {
  44694. parent && parentStack.push(parent);
  44695. if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
  44696. return this.skip();
  44697. }
  44698. checkUsage(node, "watch", vueImportAliases.watch);
  44699. checkUsage(node, "toRef", vueImportAliases.toRef);
  44700. if (isFunctionType(node)) {
  44701. pushScope();
  44702. walkFunctionParams(node, registerLocalBinding);
  44703. if (node.body.type === "BlockStatement") {
  44704. walkScope(node.body);
  44705. }
  44706. return;
  44707. }
  44708. if (node.type === "CatchClause") {
  44709. pushScope();
  44710. if (node.param && node.param.type === "Identifier") {
  44711. registerLocalBinding(node.param);
  44712. }
  44713. walkScope(node.body);
  44714. return;
  44715. }
  44716. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  44717. pushScope();
  44718. walkScope(node);
  44719. return;
  44720. }
  44721. if (node.type === "Identifier") {
  44722. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  44723. if (currentScope[node.name]) {
  44724. rewriteId(node, parent, parentStack);
  44725. }
  44726. }
  44727. }
  44728. },
  44729. leave(node, parent) {
  44730. parent && parentStack.pop();
  44731. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node)) {
  44732. popScope();
  44733. }
  44734. }
  44735. });
  44736. }
  44737. const DEFINE_EMITS = "defineEmits";
  44738. function processDefineEmits(ctx, node, declId) {
  44739. if (!isCallOf(node, DEFINE_EMITS)) {
  44740. return false;
  44741. }
  44742. if (ctx.hasDefineEmitCall) {
  44743. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  44744. }
  44745. ctx.hasDefineEmitCall = true;
  44746. ctx.emitsRuntimeDecl = node.arguments[0];
  44747. if (node.typeParameters) {
  44748. if (ctx.emitsRuntimeDecl) {
  44749. ctx.error(
  44750. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  44751. node
  44752. );
  44753. }
  44754. ctx.emitsTypeDecl = node.typeParameters.params[0];
  44755. }
  44756. ctx.emitDecl = declId;
  44757. return true;
  44758. }
  44759. function genRuntimeEmits(ctx) {
  44760. let emitsDecl = "";
  44761. if (ctx.emitsRuntimeDecl) {
  44762. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  44763. } else if (ctx.emitsTypeDecl) {
  44764. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  44765. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  44766. }
  44767. if (ctx.hasDefineModelCall) {
  44768. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  44769. emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
  44770. "mergeModels"
  44771. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  44772. }
  44773. return emitsDecl;
  44774. }
  44775. function extractRuntimeEmits(ctx) {
  44776. const emits = /* @__PURE__ */ new Set();
  44777. const node = ctx.emitsTypeDecl;
  44778. if (node.type === "TSFunctionType") {
  44779. extractEventNames(ctx, node.parameters[0], emits);
  44780. return emits;
  44781. }
  44782. const { props, calls } = resolveTypeElements(ctx, node);
  44783. let hasProperty = false;
  44784. for (const key in props) {
  44785. emits.add(key);
  44786. hasProperty = true;
  44787. }
  44788. if (calls) {
  44789. if (hasProperty) {
  44790. ctx.error(
  44791. `defineEmits() type cannot mixed call signature and property syntax.`,
  44792. node
  44793. );
  44794. }
  44795. for (const call of calls) {
  44796. extractEventNames(ctx, call.parameters[0], emits);
  44797. }
  44798. }
  44799. return emits;
  44800. }
  44801. function extractEventNames(ctx, eventName, emits) {
  44802. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  44803. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  44804. for (const type of types) {
  44805. if (type.type === "TSLiteralType") {
  44806. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  44807. emits.add(String(type.literal.value));
  44808. }
  44809. }
  44810. }
  44811. }
  44812. }
  44813. const DEFINE_EXPOSE = "defineExpose";
  44814. function processDefineExpose(ctx, node) {
  44815. if (isCallOf(node, DEFINE_EXPOSE)) {
  44816. if (ctx.hasDefineExposeCall) {
  44817. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  44818. }
  44819. ctx.hasDefineExposeCall = true;
  44820. return true;
  44821. }
  44822. return false;
  44823. }
  44824. const DEFINE_SLOTS = "defineSlots";
  44825. function processDefineSlots(ctx, node, declId) {
  44826. if (!isCallOf(node, DEFINE_SLOTS)) {
  44827. return false;
  44828. }
  44829. if (ctx.hasDefineSlotsCall) {
  44830. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  44831. }
  44832. ctx.hasDefineSlotsCall = true;
  44833. if (node.arguments.length > 0) {
  44834. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  44835. }
  44836. if (declId) {
  44837. ctx.s.overwrite(
  44838. ctx.startOffset + node.start,
  44839. ctx.startOffset + node.end,
  44840. `${ctx.helper("useSlots")}()`
  44841. );
  44842. }
  44843. return true;
  44844. }
  44845. const DEFINE_OPTIONS = "defineOptions";
  44846. function processDefineOptions(ctx, node) {
  44847. if (!isCallOf(node, DEFINE_OPTIONS)) {
  44848. return false;
  44849. }
  44850. if (ctx.hasDefineOptionsCall) {
  44851. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  44852. }
  44853. if (node.typeParameters) {
  44854. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  44855. }
  44856. if (!node.arguments[0])
  44857. return true;
  44858. ctx.hasDefineOptionsCall = true;
  44859. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  44860. let propsOption = void 0;
  44861. let emitsOption = void 0;
  44862. let exposeOption = void 0;
  44863. let slotsOption = void 0;
  44864. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  44865. for (const prop of ctx.optionsRuntimeDecl.properties) {
  44866. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  44867. if (prop.key.name === "props")
  44868. propsOption = prop;
  44869. if (prop.key.name === "emits")
  44870. emitsOption = prop;
  44871. if (prop.key.name === "expose")
  44872. exposeOption = prop;
  44873. if (prop.key.name === "slots")
  44874. slotsOption = prop;
  44875. }
  44876. }
  44877. }
  44878. if (propsOption) {
  44879. ctx.error(
  44880. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  44881. propsOption
  44882. );
  44883. }
  44884. if (emitsOption) {
  44885. ctx.error(
  44886. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  44887. emitsOption
  44888. );
  44889. }
  44890. if (exposeOption) {
  44891. ctx.error(
  44892. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  44893. exposeOption
  44894. );
  44895. }
  44896. if (slotsOption) {
  44897. ctx.error(
  44898. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  44899. slotsOption
  44900. );
  44901. }
  44902. return true;
  44903. }
  44904. function processAwait(ctx, node, needSemi, isStatement) {
  44905. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  44906. const startOffset = ctx.startOffset;
  44907. const argumentStr = ctx.descriptor.source.slice(
  44908. argumentStart + startOffset,
  44909. node.argument.end + startOffset
  44910. );
  44911. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  44912. ctx.s.overwrite(
  44913. node.start + startOffset,
  44914. argumentStart + startOffset,
  44915. `${needSemi ? `;` : ``}(
  44916. ([__temp,__restore] = ${ctx.helper(
  44917. `withAsyncContext`
  44918. )}(${containsNestedAwait ? `async ` : ``}() => `
  44919. );
  44920. ctx.s.appendLeft(
  44921. node.end + startOffset,
  44922. `)),
  44923. ${isStatement ? `` : `__temp = `}await __temp,
  44924. __restore()${isStatement ? `` : `,
  44925. __temp`}
  44926. )`
  44927. );
  44928. }
  44929. var __defProp$1 = Object.defineProperty;
  44930. var __defProps = Object.defineProperties;
  44931. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  44932. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  44933. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  44934. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  44935. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  44936. var __spreadValues$1 = (a, b) => {
  44937. for (var prop in b || (b = {}))
  44938. if (__hasOwnProp$1.call(b, prop))
  44939. __defNormalProp$1(a, prop, b[prop]);
  44940. if (__getOwnPropSymbols$1)
  44941. for (var prop of __getOwnPropSymbols$1(b)) {
  44942. if (__propIsEnum$1.call(b, prop))
  44943. __defNormalProp$1(a, prop, b[prop]);
  44944. }
  44945. return a;
  44946. };
  44947. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  44948. function compileScript(sfc, options) {
  44949. var _a;
  44950. if (!options.id) {
  44951. warnOnce$3(
  44952. `compileScript now requires passing the \`id\` option.
  44953. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  44954. );
  44955. }
  44956. const ctx = new ScriptCompileContext(sfc, options);
  44957. const { script, scriptSetup, source, filename } = sfc;
  44958. const hoistStatic = options.hoistStatic !== false && !script;
  44959. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  44960. const scriptLang = script && script.lang;
  44961. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  44962. if (!scriptSetup) {
  44963. if (!script) {
  44964. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  44965. }
  44966. return processNormalScript(ctx, scopeId);
  44967. }
  44968. if (script && scriptLang !== scriptSetupLang) {
  44969. throw new Error(
  44970. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  44971. );
  44972. }
  44973. if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
  44974. return scriptSetup;
  44975. }
  44976. const scriptBindings = /* @__PURE__ */ Object.create(null);
  44977. const setupBindings = /* @__PURE__ */ Object.create(null);
  44978. let defaultExport;
  44979. let hasAwait = false;
  44980. let hasInlinedSsrRenderFn = false;
  44981. const startOffset = ctx.startOffset;
  44982. const endOffset = ctx.endOffset;
  44983. const scriptStartOffset = script && script.loc.start.offset;
  44984. const scriptEndOffset = script && script.loc.end.offset;
  44985. function hoistNode(node) {
  44986. const start = node.start + startOffset;
  44987. let end = node.end + startOffset;
  44988. if (node.trailingComments && node.trailingComments.length > 0) {
  44989. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  44990. end = lastCommentNode.end + startOffset;
  44991. }
  44992. while (end <= source.length) {
  44993. if (!/\s/.test(source.charAt(end))) {
  44994. break;
  44995. }
  44996. end++;
  44997. }
  44998. ctx.s.move(start, end, 0);
  44999. }
  45000. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  45001. let isUsedInTemplate = needTemplateUsageCheck;
  45002. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  45003. isUsedInTemplate = isImportUsed(local, sfc);
  45004. }
  45005. ctx.userImports[local] = {
  45006. isType,
  45007. imported,
  45008. local,
  45009. source: source2,
  45010. isFromSetup,
  45011. isUsedInTemplate
  45012. };
  45013. }
  45014. function checkInvalidScopeReference(node, method) {
  45015. if (!node)
  45016. return;
  45017. walkIdentifiers(node, (id) => {
  45018. const binding = setupBindings[id.name];
  45019. if (binding && binding !== "literal-const") {
  45020. ctx.error(
  45021. `\`${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.`,
  45022. id
  45023. );
  45024. }
  45025. });
  45026. }
  45027. const scriptAst = ctx.scriptAst;
  45028. const scriptSetupAst = ctx.scriptSetupAst;
  45029. if (scriptAst) {
  45030. for (const node of scriptAst.body) {
  45031. if (node.type === "ImportDeclaration") {
  45032. for (const specifier of node.specifiers) {
  45033. const imported = getImportedName(specifier);
  45034. registerUserImport(
  45035. node.source.value,
  45036. specifier.local.name,
  45037. imported,
  45038. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45039. false,
  45040. !options.inlineTemplate
  45041. );
  45042. }
  45043. }
  45044. }
  45045. }
  45046. for (const node of scriptSetupAst.body) {
  45047. if (node.type === "ImportDeclaration") {
  45048. hoistNode(node);
  45049. let removed = 0;
  45050. const removeSpecifier = (i) => {
  45051. const removeLeft = i > removed;
  45052. removed++;
  45053. const current = node.specifiers[i];
  45054. const next = node.specifiers[i + 1];
  45055. ctx.s.remove(
  45056. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  45057. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  45058. );
  45059. };
  45060. for (let i = 0; i < node.specifiers.length; i++) {
  45061. const specifier = node.specifiers[i];
  45062. const local = specifier.local.name;
  45063. const imported = getImportedName(specifier);
  45064. const source2 = node.source.value;
  45065. const existing = ctx.userImports[local];
  45066. if (source2 === "vue" && (imported === DEFINE_PROPS || imported === DEFINE_EMITS || imported === DEFINE_EXPOSE)) {
  45067. warnOnce$3(
  45068. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  45069. );
  45070. removeSpecifier(i);
  45071. } else if (existing) {
  45072. if (existing.source === source2 && existing.imported === imported) {
  45073. removeSpecifier(i);
  45074. } else {
  45075. ctx.error(
  45076. `different imports aliased to same local name.`,
  45077. specifier
  45078. );
  45079. }
  45080. } else {
  45081. registerUserImport(
  45082. source2,
  45083. local,
  45084. imported,
  45085. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45086. true,
  45087. !options.inlineTemplate
  45088. );
  45089. }
  45090. }
  45091. if (node.specifiers.length && removed === node.specifiers.length) {
  45092. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45093. }
  45094. }
  45095. }
  45096. const vueImportAliases = {};
  45097. for (const key in ctx.userImports) {
  45098. const { source: source2, imported, local } = ctx.userImports[key];
  45099. if (source2 === "vue")
  45100. vueImportAliases[imported] = local;
  45101. }
  45102. if (script && scriptAst) {
  45103. for (const node of scriptAst.body) {
  45104. if (node.type === "ExportDefaultDeclaration") {
  45105. defaultExport = node;
  45106. let optionProperties;
  45107. if (defaultExport.declaration.type === "ObjectExpression") {
  45108. optionProperties = defaultExport.declaration.properties;
  45109. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  45110. optionProperties = defaultExport.declaration.arguments[0].properties;
  45111. }
  45112. if (optionProperties) {
  45113. for (const p of optionProperties) {
  45114. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  45115. ctx.hasDefaultExportName = true;
  45116. }
  45117. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  45118. ctx.hasDefaultExportRender = true;
  45119. }
  45120. }
  45121. }
  45122. const start = node.start + scriptStartOffset;
  45123. const end = node.declaration.start + scriptStartOffset;
  45124. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  45125. } else if (node.type === "ExportNamedDeclaration") {
  45126. const defaultSpecifier = node.specifiers.find(
  45127. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  45128. );
  45129. if (defaultSpecifier) {
  45130. defaultExport = node;
  45131. if (node.specifiers.length > 1) {
  45132. ctx.s.remove(
  45133. defaultSpecifier.start + scriptStartOffset,
  45134. defaultSpecifier.end + scriptStartOffset
  45135. );
  45136. } else {
  45137. ctx.s.remove(
  45138. node.start + scriptStartOffset,
  45139. node.end + scriptStartOffset
  45140. );
  45141. }
  45142. if (node.source) {
  45143. ctx.s.prepend(
  45144. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  45145. `
  45146. );
  45147. } else {
  45148. ctx.s.appendLeft(
  45149. scriptEndOffset,
  45150. `
  45151. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  45152. `
  45153. );
  45154. }
  45155. }
  45156. if (node.declaration) {
  45157. walkDeclaration(
  45158. "script",
  45159. node.declaration,
  45160. scriptBindings,
  45161. vueImportAliases,
  45162. hoistStatic
  45163. );
  45164. }
  45165. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45166. walkDeclaration(
  45167. "script",
  45168. node,
  45169. scriptBindings,
  45170. vueImportAliases,
  45171. hoistStatic
  45172. );
  45173. }
  45174. }
  45175. if (scriptStartOffset > startOffset) {
  45176. if (!/\n$/.test(script.content.trim())) {
  45177. ctx.s.appendLeft(scriptEndOffset, `
  45178. `);
  45179. }
  45180. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  45181. }
  45182. }
  45183. for (const node of scriptSetupAst.body) {
  45184. if (node.type === "ExpressionStatement") {
  45185. const expr = unwrapTSNode(node.expression);
  45186. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  45187. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45188. } else if (processDefineExpose(ctx, expr)) {
  45189. const callee = expr.callee;
  45190. ctx.s.overwrite(
  45191. callee.start + startOffset,
  45192. callee.end + startOffset,
  45193. "__expose"
  45194. );
  45195. } else {
  45196. processDefineModel(ctx, expr);
  45197. }
  45198. }
  45199. if (node.type === "VariableDeclaration" && !node.declare) {
  45200. const total = node.declarations.length;
  45201. let left = total;
  45202. let lastNonRemoved;
  45203. for (let i = 0; i < total; i++) {
  45204. const decl = node.declarations[i];
  45205. const init = decl.init && unwrapTSNode(decl.init);
  45206. if (init) {
  45207. if (processDefineOptions(ctx, init)) {
  45208. ctx.error(
  45209. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  45210. node
  45211. );
  45212. }
  45213. const isDefineProps = processDefineProps(ctx, init, decl.id);
  45214. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  45215. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  45216. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  45217. if (left === 1) {
  45218. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45219. } else {
  45220. let start = decl.start + startOffset;
  45221. let end = decl.end + startOffset;
  45222. if (i === total - 1) {
  45223. start = node.declarations[lastNonRemoved].end + startOffset;
  45224. } else {
  45225. end = node.declarations[i + 1].start + startOffset;
  45226. }
  45227. ctx.s.remove(start, end);
  45228. left--;
  45229. }
  45230. } else if (isDefineEmits) {
  45231. ctx.s.overwrite(
  45232. startOffset + init.start,
  45233. startOffset + init.end,
  45234. "__emit"
  45235. );
  45236. } else {
  45237. lastNonRemoved = i;
  45238. }
  45239. }
  45240. }
  45241. }
  45242. let isAllLiteral = false;
  45243. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45244. isAllLiteral = walkDeclaration(
  45245. "scriptSetup",
  45246. node,
  45247. setupBindings,
  45248. vueImportAliases,
  45249. hoistStatic
  45250. );
  45251. }
  45252. if (hoistStatic && isAllLiteral) {
  45253. hoistNode(node);
  45254. }
  45255. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  45256. const scope = [scriptSetupAst.body];
  45257. walk$2(node, {
  45258. enter(child, parent) {
  45259. if (isFunctionType(child)) {
  45260. this.skip();
  45261. }
  45262. if (child.type === "BlockStatement") {
  45263. scope.push(child.body);
  45264. }
  45265. if (child.type === "AwaitExpression") {
  45266. hasAwait = true;
  45267. const currentScope = scope[scope.length - 1];
  45268. const needsSemi = currentScope.some((n, i) => {
  45269. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  45270. });
  45271. processAwait(
  45272. ctx,
  45273. child,
  45274. needsSemi,
  45275. parent.type === "ExpressionStatement"
  45276. );
  45277. }
  45278. },
  45279. exit(node2) {
  45280. if (node2.type === "BlockStatement")
  45281. scope.pop();
  45282. }
  45283. });
  45284. }
  45285. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  45286. ctx.error(
  45287. `<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.`,
  45288. node
  45289. );
  45290. }
  45291. if (ctx.isTS) {
  45292. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  45293. if (node.type !== "TSEnumDeclaration") {
  45294. hoistNode(node);
  45295. }
  45296. }
  45297. }
  45298. }
  45299. if (ctx.propsDestructureDecl) {
  45300. transformDestructuredProps(ctx, vueImportAliases);
  45301. }
  45302. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  45303. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  45304. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  45305. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  45306. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  45307. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  45308. for (const node of runtimeOptionNodes) {
  45309. checkInvalidScopeReference(node, DEFINE_MODEL);
  45310. }
  45311. }
  45312. if (script) {
  45313. if (startOffset < scriptStartOffset) {
  45314. ctx.s.remove(0, startOffset);
  45315. ctx.s.remove(endOffset, scriptStartOffset);
  45316. ctx.s.remove(scriptEndOffset, source.length);
  45317. } else {
  45318. ctx.s.remove(0, scriptStartOffset);
  45319. ctx.s.remove(scriptEndOffset, startOffset);
  45320. ctx.s.remove(endOffset, source.length);
  45321. }
  45322. } else {
  45323. ctx.s.remove(0, startOffset);
  45324. ctx.s.remove(endOffset, source.length);
  45325. }
  45326. if (scriptAst) {
  45327. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  45328. }
  45329. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  45330. ctx.userImports
  45331. )) {
  45332. if (isType)
  45333. continue;
  45334. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  45335. }
  45336. for (const key in scriptBindings) {
  45337. ctx.bindingMetadata[key] = scriptBindings[key];
  45338. }
  45339. for (const key in setupBindings) {
  45340. ctx.bindingMetadata[key] = setupBindings[key];
  45341. }
  45342. if (sfc.cssVars.length && // no need to do this when targeting SSR
  45343. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  45344. ctx.helperImports.add(CSS_VARS_HELPER);
  45345. ctx.helperImports.add("unref");
  45346. ctx.s.prependLeft(
  45347. startOffset,
  45348. `
  45349. ${genCssVarsCode(
  45350. sfc.cssVars,
  45351. ctx.bindingMetadata,
  45352. scopeId,
  45353. !!options.isProd
  45354. )}
  45355. `
  45356. );
  45357. }
  45358. let args = `__props`;
  45359. if (ctx.propsTypeDecl) {
  45360. args += `: any`;
  45361. }
  45362. if (ctx.propsDecl) {
  45363. if (ctx.propsDestructureRestId) {
  45364. ctx.s.overwrite(
  45365. startOffset + ctx.propsCall.start,
  45366. startOffset + ctx.propsCall.end,
  45367. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  45368. Object.keys(ctx.propsDestructuredBindings)
  45369. )})`
  45370. );
  45371. ctx.s.overwrite(
  45372. startOffset + ctx.propsDestructureDecl.start,
  45373. startOffset + ctx.propsDestructureDecl.end,
  45374. ctx.propsDestructureRestId
  45375. );
  45376. } else if (!ctx.propsDestructureDecl) {
  45377. ctx.s.overwrite(
  45378. startOffset + ctx.propsCall.start,
  45379. startOffset + ctx.propsCall.end,
  45380. "__props"
  45381. );
  45382. }
  45383. }
  45384. if (hasAwait) {
  45385. const any = ctx.isTS ? `: any` : ``;
  45386. ctx.s.prependLeft(startOffset, `
  45387. let __temp${any}, __restore${any}
  45388. `);
  45389. }
  45390. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  45391. if (ctx.emitDecl) {
  45392. destructureElements.push(`emit: __emit`);
  45393. }
  45394. if (destructureElements.length) {
  45395. args += `, { ${destructureElements.join(", ")} }`;
  45396. }
  45397. let returned;
  45398. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  45399. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  45400. for (const key in ctx.userImports) {
  45401. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  45402. allBindings[key] = true;
  45403. }
  45404. }
  45405. returned = `{ `;
  45406. for (const key in allBindings) {
  45407. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  45408. returned += `get ${key}() { return ${key} }, `;
  45409. } else if (ctx.bindingMetadata[key] === "setup-let") {
  45410. const setArg = key === "v" ? `_v` : `v`;
  45411. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  45412. } else {
  45413. returned += `${key}, `;
  45414. }
  45415. }
  45416. returned = returned.replace(/, $/, "") + ` }`;
  45417. } else {
  45418. if (sfc.template && !sfc.template.src) {
  45419. if (options.templateOptions && options.templateOptions.ssr) {
  45420. hasInlinedSsrRenderFn = true;
  45421. }
  45422. const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
  45423. filename,
  45424. ast: sfc.template.ast,
  45425. source: sfc.template.content,
  45426. inMap: sfc.template.map
  45427. }, options.templateOptions), {
  45428. id: scopeId,
  45429. scoped: sfc.styles.some((s) => s.scoped),
  45430. isProd: options.isProd,
  45431. ssrCssVars: sfc.cssVars,
  45432. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  45433. inline: true,
  45434. isTS: ctx.isTS,
  45435. bindingMetadata: ctx.bindingMetadata
  45436. })
  45437. }));
  45438. if (tips.length) {
  45439. tips.forEach(warnOnce$3);
  45440. }
  45441. const err = errors[0];
  45442. if (typeof err === "string") {
  45443. throw new Error(err);
  45444. } else if (err) {
  45445. if (err.loc) {
  45446. err.message += `
  45447. ` + sfc.filename + "\n" + generateCodeFrame(
  45448. source,
  45449. err.loc.start.offset,
  45450. err.loc.end.offset
  45451. ) + `
  45452. `;
  45453. }
  45454. throw err;
  45455. }
  45456. if (preamble) {
  45457. ctx.s.prepend(preamble);
  45458. }
  45459. if (ast && ast.helpers.has(UNREF)) {
  45460. ctx.helperImports.delete("unref");
  45461. }
  45462. returned = code;
  45463. } else {
  45464. returned = `() => {}`;
  45465. }
  45466. }
  45467. if (!options.inlineTemplate && true) {
  45468. ctx.s.appendRight(
  45469. endOffset,
  45470. `
  45471. const __returned__ = ${returned}
  45472. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  45473. return __returned__
  45474. }
  45475. `
  45476. );
  45477. } else {
  45478. ctx.s.appendRight(endOffset, `
  45479. return ${returned}
  45480. }
  45481. `);
  45482. }
  45483. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  45484. let runtimeOptions = ``;
  45485. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  45486. const match = filename.match(/([^/\\]+)\.\w+$/);
  45487. if (match) {
  45488. runtimeOptions += `
  45489. __name: '${match[1]}',`;
  45490. }
  45491. }
  45492. if (hasInlinedSsrRenderFn) {
  45493. runtimeOptions += `
  45494. __ssrInlineRender: true,`;
  45495. }
  45496. const propsDecl = genRuntimeProps(ctx);
  45497. if (propsDecl)
  45498. runtimeOptions += `
  45499. props: ${propsDecl},`;
  45500. const emitsDecl = genRuntimeEmits(ctx);
  45501. if (emitsDecl)
  45502. runtimeOptions += `
  45503. emits: ${emitsDecl},`;
  45504. let definedOptions = "";
  45505. if (ctx.optionsRuntimeDecl) {
  45506. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  45507. }
  45508. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  45509. `;
  45510. if (ctx.isTS) {
  45511. const def = (defaultExport ? `
  45512. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  45513. ...${definedOptions},` : "");
  45514. ctx.s.prependLeft(
  45515. startOffset,
  45516. `
  45517. ${genDefaultAs} /*#__PURE__*/${ctx.helper(
  45518. `defineComponent`
  45519. )}({${def}${runtimeOptions}
  45520. ${hasAwait ? `async ` : ``}setup(${args}) {
  45521. ${exposeCall}`
  45522. );
  45523. ctx.s.appendRight(endOffset, `})`);
  45524. } else {
  45525. if (defaultExport || definedOptions) {
  45526. ctx.s.prependLeft(
  45527. startOffset,
  45528. `
  45529. ${genDefaultAs} /*#__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  45530. ${hasAwait ? `async ` : ``}setup(${args}) {
  45531. ${exposeCall}`
  45532. );
  45533. ctx.s.appendRight(endOffset, `})`);
  45534. } else {
  45535. ctx.s.prependLeft(
  45536. startOffset,
  45537. `
  45538. ${genDefaultAs} {${runtimeOptions}
  45539. ${hasAwait ? `async ` : ``}setup(${args}) {
  45540. ${exposeCall}`
  45541. );
  45542. ctx.s.appendRight(endOffset, `}`);
  45543. }
  45544. }
  45545. if (ctx.helperImports.size > 0) {
  45546. ctx.s.prepend(
  45547. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from 'vue'
  45548. `
  45549. );
  45550. }
  45551. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  45552. bindings: ctx.bindingMetadata,
  45553. imports: ctx.userImports,
  45554. content: ctx.s.toString(),
  45555. map: options.sourceMap !== false ? ctx.s.generateMap({
  45556. source: filename,
  45557. hires: true,
  45558. includeContent: true
  45559. }) : void 0,
  45560. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  45561. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  45562. deps: ctx.deps ? [...ctx.deps] : void 0
  45563. });
  45564. }
  45565. function registerBinding(bindings, node, type) {
  45566. bindings[node.name] = type;
  45567. }
  45568. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
  45569. let isAllLiteral = false;
  45570. if (node.type === "VariableDeclaration") {
  45571. const isConst = node.kind === "const";
  45572. isAllLiteral = isConst && node.declarations.every(
  45573. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  45574. );
  45575. for (const { id, init: _init } of node.declarations) {
  45576. const init = _init && unwrapTSNode(_init);
  45577. const isDefineCall = !!(isConst && isCallOf(
  45578. init,
  45579. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
  45580. ));
  45581. if (id.type === "Identifier") {
  45582. let bindingType;
  45583. const userReactiveBinding = userImportAliases["reactive"];
  45584. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  45585. bindingType = "literal-const";
  45586. } else if (isCallOf(init, userReactiveBinding)) {
  45587. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  45588. } else if (
  45589. // if a declaration is a const literal, we can mark it so that
  45590. // the generated render fn code doesn't need to unref() it
  45591. isDefineCall || isConst && canNeverBeRef(init, userReactiveBinding)
  45592. ) {
  45593. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  45594. } else if (isConst) {
  45595. if (isCallOf(
  45596. init,
  45597. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === DEFINE_MODEL
  45598. )) {
  45599. bindingType = "setup-ref";
  45600. } else {
  45601. bindingType = "setup-maybe-ref";
  45602. }
  45603. } else {
  45604. bindingType = "setup-let";
  45605. }
  45606. registerBinding(bindings, id, bindingType);
  45607. } else {
  45608. if (isCallOf(init, DEFINE_PROPS)) {
  45609. continue;
  45610. }
  45611. if (id.type === "ObjectPattern") {
  45612. walkObjectPattern(id, bindings, isConst, isDefineCall);
  45613. } else if (id.type === "ArrayPattern") {
  45614. walkArrayPattern(id, bindings, isConst, isDefineCall);
  45615. }
  45616. }
  45617. }
  45618. } else if (node.type === "TSEnumDeclaration") {
  45619. isAllLiteral = node.members.every(
  45620. (member) => !member.initializer || isStaticNode(member.initializer)
  45621. );
  45622. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  45623. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  45624. bindings[node.id.name] = "setup-const";
  45625. }
  45626. return isAllLiteral;
  45627. }
  45628. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  45629. for (const p of node.properties) {
  45630. if (p.type === "ObjectProperty") {
  45631. if (p.key.type === "Identifier" && p.key === p.value) {
  45632. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45633. registerBinding(bindings, p.key, type);
  45634. } else {
  45635. walkPattern(p.value, bindings, isConst, isDefineCall);
  45636. }
  45637. } else {
  45638. const type = isConst ? "setup-const" : "setup-let";
  45639. registerBinding(bindings, p.argument, type);
  45640. }
  45641. }
  45642. }
  45643. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  45644. for (const e of node.elements) {
  45645. e && walkPattern(e, bindings, isConst, isDefineCall);
  45646. }
  45647. }
  45648. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  45649. if (node.type === "Identifier") {
  45650. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45651. registerBinding(bindings, node, type);
  45652. } else if (node.type === "RestElement") {
  45653. const type = isConst ? "setup-const" : "setup-let";
  45654. registerBinding(bindings, node.argument, type);
  45655. } else if (node.type === "ObjectPattern") {
  45656. walkObjectPattern(node, bindings, isConst);
  45657. } else if (node.type === "ArrayPattern") {
  45658. walkArrayPattern(node, bindings, isConst);
  45659. } else if (node.type === "AssignmentPattern") {
  45660. if (node.left.type === "Identifier") {
  45661. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45662. registerBinding(bindings, node.left, type);
  45663. } else {
  45664. walkPattern(node.left, bindings, isConst);
  45665. }
  45666. }
  45667. }
  45668. function canNeverBeRef(node, userReactiveImport) {
  45669. if (isCallOf(node, userReactiveImport)) {
  45670. return true;
  45671. }
  45672. switch (node.type) {
  45673. case "UnaryExpression":
  45674. case "BinaryExpression":
  45675. case "ArrayExpression":
  45676. case "ObjectExpression":
  45677. case "FunctionExpression":
  45678. case "ArrowFunctionExpression":
  45679. case "UpdateExpression":
  45680. case "ClassExpression":
  45681. case "TaggedTemplateExpression":
  45682. return true;
  45683. case "SequenceExpression":
  45684. return canNeverBeRef(
  45685. node.expressions[node.expressions.length - 1],
  45686. userReactiveImport
  45687. );
  45688. default:
  45689. if (isLiteralNode(node)) {
  45690. return true;
  45691. }
  45692. return false;
  45693. }
  45694. }
  45695. function isStaticNode(node) {
  45696. node = unwrapTSNode(node);
  45697. switch (node.type) {
  45698. case "UnaryExpression":
  45699. return isStaticNode(node.argument);
  45700. case "LogicalExpression":
  45701. case "BinaryExpression":
  45702. return isStaticNode(node.left) && isStaticNode(node.right);
  45703. case "ConditionalExpression": {
  45704. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  45705. }
  45706. case "SequenceExpression":
  45707. case "TemplateLiteral":
  45708. return node.expressions.every((expr) => isStaticNode(expr));
  45709. case "ParenthesizedExpression":
  45710. return isStaticNode(node.expression);
  45711. case "StringLiteral":
  45712. case "NumericLiteral":
  45713. case "BooleanLiteral":
  45714. case "NullLiteral":
  45715. case "BigIntLiteral":
  45716. return true;
  45717. }
  45718. return false;
  45719. }
  45720. var __defProp = Object.defineProperty;
  45721. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  45722. var __hasOwnProp = Object.prototype.hasOwnProperty;
  45723. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  45724. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45725. var __spreadValues = (a, b) => {
  45726. for (var prop in b || (b = {}))
  45727. if (__hasOwnProp.call(b, prop))
  45728. __defNormalProp(a, prop, b[prop]);
  45729. if (__getOwnPropSymbols)
  45730. for (var prop of __getOwnPropSymbols(b)) {
  45731. if (__propIsEnum.call(b, prop))
  45732. __defNormalProp(a, prop, b[prop]);
  45733. }
  45734. return a;
  45735. };
  45736. const version = "3.4.21";
  45737. const parseCache = parseCache$1;
  45738. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  45739. const walk = walk$2;
  45740. const shouldTransformRef = () => false;
  45741. 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 };