compiler-sfc.esm-browser.js 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043
  1. /**
  2. * @vue/compiler-sfc v3.5.13
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. /*! #__NO_SIDE_EFFECTS__ */
  7. // @__NO_SIDE_EFFECTS__
  8. function makeMap(str) {
  9. const map = /* @__PURE__ */ Object.create(null);
  10. for (const key of str.split(",")) map[key] = 1;
  11. return (val) => val in map;
  12. }
  13. const EMPTY_OBJ = Object.freeze({}) ;
  14. const NOOP = () => {
  15. };
  16. const NO = () => false;
  17. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  18. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  19. const extend = Object.assign;
  20. const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
  21. const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
  22. const isArray$3 = Array.isArray;
  23. const isMap = (val) => toTypeString(val) === "[object Map]";
  24. const isSet = (val) => toTypeString(val) === "[object Set]";
  25. const isFunction$1 = (val) => typeof val === "function";
  26. const isString$1 = (val) => typeof val === "string";
  27. const isSymbol$1 = (val) => typeof val === "symbol";
  28. const isObject$2 = (val) => val !== null && typeof val === "object";
  29. const objectToString$1 = Object.prototype.toString;
  30. const toTypeString = (value) => objectToString$1.call(value);
  31. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  32. const isReservedProp = /* @__PURE__ */ makeMap(
  33. // the leading comma is intentional so empty string "" is also included
  34. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  35. );
  36. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  37. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  38. );
  39. const cacheStringFunction = (fn) => {
  40. const cache = /* @__PURE__ */ Object.create(null);
  41. return (str) => {
  42. const hit = cache[str];
  43. return hit || (cache[str] = fn(str));
  44. };
  45. };
  46. const camelizeRE = /-(\w)/g;
  47. const camelize = cacheStringFunction(
  48. (str) => {
  49. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  50. }
  51. );
  52. const hyphenateRE = /\B([A-Z])/g;
  53. const hyphenate = cacheStringFunction(
  54. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  55. );
  56. const capitalize = cacheStringFunction((str) => {
  57. return str.charAt(0).toUpperCase() + str.slice(1);
  58. });
  59. const toHandlerKey = cacheStringFunction(
  60. (str) => {
  61. const s = str ? `on${capitalize(str)}` : ``;
  62. return s;
  63. }
  64. );
  65. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  66. function genPropsAccessExp(name) {
  67. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  68. }
  69. function genCacheKey(source, options) {
  70. return source + JSON.stringify(
  71. options,
  72. (_, val) => typeof val === "function" ? val.toString() : val
  73. );
  74. }
  75. const PatchFlagNames = {
  76. [1]: `TEXT`,
  77. [2]: `CLASS`,
  78. [4]: `STYLE`,
  79. [8]: `PROPS`,
  80. [16]: `FULL_PROPS`,
  81. [32]: `NEED_HYDRATION`,
  82. [64]: `STABLE_FRAGMENT`,
  83. [128]: `KEYED_FRAGMENT`,
  84. [256]: `UNKEYED_FRAGMENT`,
  85. [512]: `NEED_PATCH`,
  86. [1024]: `DYNAMIC_SLOTS`,
  87. [2048]: `DEV_ROOT_FRAGMENT`,
  88. [-1]: `HOISTED`,
  89. [-2]: `BAIL`
  90. };
  91. const slotFlagsText = {
  92. [1]: "STABLE",
  93. [2]: "DYNAMIC",
  94. [3]: "FORWARDED"
  95. };
  96. 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,Symbol";
  97. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  98. const range = 2;
  99. function generateCodeFrame(source, start = 0, end = source.length) {
  100. start = Math.max(0, Math.min(start, source.length));
  101. end = Math.max(0, Math.min(end, source.length));
  102. if (start > end) return "";
  103. let lines = source.split(/(\r?\n)/);
  104. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  105. lines = lines.filter((_, idx) => idx % 2 === 0);
  106. let count = 0;
  107. const res = [];
  108. for (let i = 0; i < lines.length; i++) {
  109. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  110. if (count >= start) {
  111. for (let j = i - range; j <= i + range || end > count; j++) {
  112. if (j < 0 || j >= lines.length) continue;
  113. const line = j + 1;
  114. res.push(
  115. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  116. );
  117. const lineLength = lines[j].length;
  118. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  119. if (j === i) {
  120. const pad = start - (count - (lineLength + newLineSeqLength));
  121. const length = Math.max(
  122. 1,
  123. end > count ? lineLength - pad : end - start
  124. );
  125. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  126. } else if (j > i) {
  127. if (end > count) {
  128. const length = Math.max(Math.min(end - count, lineLength), 1);
  129. res.push(` | ` + "^".repeat(length));
  130. }
  131. count += lineLength + newLineSeqLength;
  132. }
  133. }
  134. break;
  135. }
  136. }
  137. return res.join("\n");
  138. }
  139. function normalizeStyle(value) {
  140. if (isArray$3(value)) {
  141. const res = {};
  142. for (let i = 0; i < value.length; i++) {
  143. const item = value[i];
  144. const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
  145. if (normalized) {
  146. for (const key in normalized) {
  147. res[key] = normalized[key];
  148. }
  149. }
  150. }
  151. return res;
  152. } else if (isString$1(value) || isObject$2(value)) {
  153. return value;
  154. }
  155. }
  156. const listDelimiterRE = /;(?![^(]*\))/g;
  157. const propertyDelimiterRE = /:([^]+)/;
  158. const styleCommentRE = /\/\*[^]*?\*\//g;
  159. function parseStringStyle(cssText) {
  160. const ret = {};
  161. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  162. if (item) {
  163. const tmp = item.split(propertyDelimiterRE);
  164. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  165. }
  166. });
  167. return ret;
  168. }
  169. function stringifyStyle(styles) {
  170. if (!styles) return "";
  171. if (isString$1(styles)) return styles;
  172. let ret = "";
  173. for (const key in styles) {
  174. const value = styles[key];
  175. if (isString$1(value) || typeof value === "number") {
  176. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  177. ret += `${normalizedKey}:${value};`;
  178. }
  179. }
  180. return ret;
  181. }
  182. function normalizeClass(value) {
  183. let res = "";
  184. if (isString$1(value)) {
  185. res = value;
  186. } else if (isArray$3(value)) {
  187. for (let i = 0; i < value.length; i++) {
  188. const normalized = normalizeClass(value[i]);
  189. if (normalized) {
  190. res += normalized + " ";
  191. }
  192. }
  193. } else if (isObject$2(value)) {
  194. for (const name in value) {
  195. if (value[name]) {
  196. res += name + " ";
  197. }
  198. }
  199. }
  200. return res.trim();
  201. }
  202. 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";
  203. 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";
  204. 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";
  205. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  206. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  207. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  208. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  209. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  210. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  211. const isBooleanAttr = /* @__PURE__ */ makeMap(
  212. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  213. );
  214. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  215. const attrValidationCache = {};
  216. function isSSRSafeAttrName(name) {
  217. if (attrValidationCache.hasOwnProperty(name)) {
  218. return attrValidationCache[name];
  219. }
  220. const isUnsafe = unsafeAttrCharRE.test(name);
  221. if (isUnsafe) {
  222. console.error(`unsafe attribute name: ${name}`);
  223. }
  224. return attrValidationCache[name] = !isUnsafe;
  225. }
  226. const propsToAttrMap = {
  227. acceptCharset: "accept-charset",
  228. className: "class",
  229. htmlFor: "for",
  230. httpEquiv: "http-equiv"
  231. };
  232. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  233. `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`
  234. );
  235. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  236. `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`
  237. );
  238. const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
  239. `accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`
  240. );
  241. const escapeRE = /["'&<>]/;
  242. function escapeHtml(string) {
  243. const str = "" + string;
  244. const match = escapeRE.exec(str);
  245. if (!match) {
  246. return str;
  247. }
  248. let html = "";
  249. let escaped;
  250. let index;
  251. let lastIndex = 0;
  252. for (index = match.index; index < str.length; index++) {
  253. switch (str.charCodeAt(index)) {
  254. case 34:
  255. escaped = "&quot;";
  256. break;
  257. case 38:
  258. escaped = "&amp;";
  259. break;
  260. case 39:
  261. escaped = "&#39;";
  262. break;
  263. case 60:
  264. escaped = "&lt;";
  265. break;
  266. case 62:
  267. escaped = "&gt;";
  268. break;
  269. default:
  270. continue;
  271. }
  272. if (lastIndex !== index) {
  273. html += str.slice(lastIndex, index);
  274. }
  275. lastIndex = index + 1;
  276. html += escaped;
  277. }
  278. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  279. }
  280. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  281. function getEscapedCssVarName(key, doubleEscape) {
  282. return key.replace(
  283. cssVarNameEscapeSymbolsRE,
  284. (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
  285. );
  286. }
  287. const isRef = (val) => {
  288. return !!(val && val["__v_isRef"] === true);
  289. };
  290. const toDisplayString = (val) => {
  291. return isString$1(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$1(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
  292. };
  293. const replacer = (_key, val) => {
  294. if (isRef(val)) {
  295. return replacer(_key, val.value);
  296. } else if (isMap(val)) {
  297. return {
  298. [`Map(${val.size})`]: [...val.entries()].reduce(
  299. (entries, [key, val2], i) => {
  300. entries[stringifySymbol(key, i) + " =>"] = val2;
  301. return entries;
  302. },
  303. {}
  304. )
  305. };
  306. } else if (isSet(val)) {
  307. return {
  308. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  309. };
  310. } else if (isSymbol$1(val)) {
  311. return stringifySymbol(val);
  312. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  313. return String(val);
  314. }
  315. return val;
  316. };
  317. const stringifySymbol = (v, i = "") => {
  318. var _a;
  319. return (
  320. // Symbol.description in es2019+ so we need to cast here to pass
  321. // the lib: es2016 check
  322. isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  323. );
  324. };
  325. const FRAGMENT = Symbol(`Fragment` );
  326. const TELEPORT = Symbol(`Teleport` );
  327. const SUSPENSE = Symbol(`Suspense` );
  328. const KEEP_ALIVE = Symbol(`KeepAlive` );
  329. const BASE_TRANSITION = Symbol(
  330. `BaseTransition`
  331. );
  332. const OPEN_BLOCK = Symbol(`openBlock` );
  333. const CREATE_BLOCK = Symbol(`createBlock` );
  334. const CREATE_ELEMENT_BLOCK = Symbol(
  335. `createElementBlock`
  336. );
  337. const CREATE_VNODE = Symbol(`createVNode` );
  338. const CREATE_ELEMENT_VNODE = Symbol(
  339. `createElementVNode`
  340. );
  341. const CREATE_COMMENT = Symbol(
  342. `createCommentVNode`
  343. );
  344. const CREATE_TEXT = Symbol(
  345. `createTextVNode`
  346. );
  347. const CREATE_STATIC = Symbol(
  348. `createStaticVNode`
  349. );
  350. const RESOLVE_COMPONENT = Symbol(
  351. `resolveComponent`
  352. );
  353. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  354. `resolveDynamicComponent`
  355. );
  356. const RESOLVE_DIRECTIVE = Symbol(
  357. `resolveDirective`
  358. );
  359. const RESOLVE_FILTER = Symbol(
  360. `resolveFilter`
  361. );
  362. const WITH_DIRECTIVES = Symbol(
  363. `withDirectives`
  364. );
  365. const RENDER_LIST = Symbol(`renderList` );
  366. const RENDER_SLOT = Symbol(`renderSlot` );
  367. const CREATE_SLOTS = Symbol(`createSlots` );
  368. const TO_DISPLAY_STRING = Symbol(
  369. `toDisplayString`
  370. );
  371. const MERGE_PROPS = Symbol(`mergeProps` );
  372. const NORMALIZE_CLASS = Symbol(
  373. `normalizeClass`
  374. );
  375. const NORMALIZE_STYLE = Symbol(
  376. `normalizeStyle`
  377. );
  378. const NORMALIZE_PROPS = Symbol(
  379. `normalizeProps`
  380. );
  381. const GUARD_REACTIVE_PROPS = Symbol(
  382. `guardReactiveProps`
  383. );
  384. const TO_HANDLERS = Symbol(`toHandlers` );
  385. const CAMELIZE = Symbol(`camelize` );
  386. const CAPITALIZE = Symbol(`capitalize` );
  387. const TO_HANDLER_KEY = Symbol(
  388. `toHandlerKey`
  389. );
  390. const SET_BLOCK_TRACKING = Symbol(
  391. `setBlockTracking`
  392. );
  393. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  394. const POP_SCOPE_ID = Symbol(`popScopeId` );
  395. const WITH_CTX = Symbol(`withCtx` );
  396. const UNREF = Symbol(`unref` );
  397. const IS_REF = Symbol(`isRef` );
  398. const WITH_MEMO = Symbol(`withMemo` );
  399. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  400. const helperNameMap = {
  401. [FRAGMENT]: `Fragment`,
  402. [TELEPORT]: `Teleport`,
  403. [SUSPENSE]: `Suspense`,
  404. [KEEP_ALIVE]: `KeepAlive`,
  405. [BASE_TRANSITION]: `BaseTransition`,
  406. [OPEN_BLOCK]: `openBlock`,
  407. [CREATE_BLOCK]: `createBlock`,
  408. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  409. [CREATE_VNODE]: `createVNode`,
  410. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  411. [CREATE_COMMENT]: `createCommentVNode`,
  412. [CREATE_TEXT]: `createTextVNode`,
  413. [CREATE_STATIC]: `createStaticVNode`,
  414. [RESOLVE_COMPONENT]: `resolveComponent`,
  415. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  416. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  417. [RESOLVE_FILTER]: `resolveFilter`,
  418. [WITH_DIRECTIVES]: `withDirectives`,
  419. [RENDER_LIST]: `renderList`,
  420. [RENDER_SLOT]: `renderSlot`,
  421. [CREATE_SLOTS]: `createSlots`,
  422. [TO_DISPLAY_STRING]: `toDisplayString`,
  423. [MERGE_PROPS]: `mergeProps`,
  424. [NORMALIZE_CLASS]: `normalizeClass`,
  425. [NORMALIZE_STYLE]: `normalizeStyle`,
  426. [NORMALIZE_PROPS]: `normalizeProps`,
  427. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  428. [TO_HANDLERS]: `toHandlers`,
  429. [CAMELIZE]: `camelize`,
  430. [CAPITALIZE]: `capitalize`,
  431. [TO_HANDLER_KEY]: `toHandlerKey`,
  432. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  433. [PUSH_SCOPE_ID]: `pushScopeId`,
  434. [POP_SCOPE_ID]: `popScopeId`,
  435. [WITH_CTX]: `withCtx`,
  436. [UNREF]: `unref`,
  437. [IS_REF]: `isRef`,
  438. [WITH_MEMO]: `withMemo`,
  439. [IS_MEMO_SAME]: `isMemoSame`
  440. };
  441. function registerRuntimeHelpers(helpers) {
  442. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  443. helperNameMap[s] = helpers[s];
  444. });
  445. }
  446. const Namespaces = {
  447. "HTML": 0,
  448. "0": "HTML",
  449. "SVG": 1,
  450. "1": "SVG",
  451. "MATH_ML": 2,
  452. "2": "MATH_ML"
  453. };
  454. const NodeTypes = {
  455. "ROOT": 0,
  456. "0": "ROOT",
  457. "ELEMENT": 1,
  458. "1": "ELEMENT",
  459. "TEXT": 2,
  460. "2": "TEXT",
  461. "COMMENT": 3,
  462. "3": "COMMENT",
  463. "SIMPLE_EXPRESSION": 4,
  464. "4": "SIMPLE_EXPRESSION",
  465. "INTERPOLATION": 5,
  466. "5": "INTERPOLATION",
  467. "ATTRIBUTE": 6,
  468. "6": "ATTRIBUTE",
  469. "DIRECTIVE": 7,
  470. "7": "DIRECTIVE",
  471. "COMPOUND_EXPRESSION": 8,
  472. "8": "COMPOUND_EXPRESSION",
  473. "IF": 9,
  474. "9": "IF",
  475. "IF_BRANCH": 10,
  476. "10": "IF_BRANCH",
  477. "FOR": 11,
  478. "11": "FOR",
  479. "TEXT_CALL": 12,
  480. "12": "TEXT_CALL",
  481. "VNODE_CALL": 13,
  482. "13": "VNODE_CALL",
  483. "JS_CALL_EXPRESSION": 14,
  484. "14": "JS_CALL_EXPRESSION",
  485. "JS_OBJECT_EXPRESSION": 15,
  486. "15": "JS_OBJECT_EXPRESSION",
  487. "JS_PROPERTY": 16,
  488. "16": "JS_PROPERTY",
  489. "JS_ARRAY_EXPRESSION": 17,
  490. "17": "JS_ARRAY_EXPRESSION",
  491. "JS_FUNCTION_EXPRESSION": 18,
  492. "18": "JS_FUNCTION_EXPRESSION",
  493. "JS_CONDITIONAL_EXPRESSION": 19,
  494. "19": "JS_CONDITIONAL_EXPRESSION",
  495. "JS_CACHE_EXPRESSION": 20,
  496. "20": "JS_CACHE_EXPRESSION",
  497. "JS_BLOCK_STATEMENT": 21,
  498. "21": "JS_BLOCK_STATEMENT",
  499. "JS_TEMPLATE_LITERAL": 22,
  500. "22": "JS_TEMPLATE_LITERAL",
  501. "JS_IF_STATEMENT": 23,
  502. "23": "JS_IF_STATEMENT",
  503. "JS_ASSIGNMENT_EXPRESSION": 24,
  504. "24": "JS_ASSIGNMENT_EXPRESSION",
  505. "JS_SEQUENCE_EXPRESSION": 25,
  506. "25": "JS_SEQUENCE_EXPRESSION",
  507. "JS_RETURN_STATEMENT": 26,
  508. "26": "JS_RETURN_STATEMENT"
  509. };
  510. const ElementTypes = {
  511. "ELEMENT": 0,
  512. "0": "ELEMENT",
  513. "COMPONENT": 1,
  514. "1": "COMPONENT",
  515. "SLOT": 2,
  516. "2": "SLOT",
  517. "TEMPLATE": 3,
  518. "3": "TEMPLATE"
  519. };
  520. const ConstantTypes = {
  521. "NOT_CONSTANT": 0,
  522. "0": "NOT_CONSTANT",
  523. "CAN_SKIP_PATCH": 1,
  524. "1": "CAN_SKIP_PATCH",
  525. "CAN_CACHE": 2,
  526. "2": "CAN_CACHE",
  527. "CAN_STRINGIFY": 3,
  528. "3": "CAN_STRINGIFY"
  529. };
  530. const locStub = {
  531. start: { line: 1, column: 1, offset: 0 },
  532. end: { line: 1, column: 1, offset: 0 },
  533. source: ""
  534. };
  535. function createRoot(children, source = "") {
  536. return {
  537. type: 0,
  538. source,
  539. children,
  540. helpers: /* @__PURE__ */ new Set(),
  541. components: [],
  542. directives: [],
  543. hoists: [],
  544. imports: [],
  545. cached: [],
  546. temps: 0,
  547. codegenNode: void 0,
  548. loc: locStub
  549. };
  550. }
  551. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  552. if (context) {
  553. if (isBlock) {
  554. context.helper(OPEN_BLOCK);
  555. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  556. } else {
  557. context.helper(getVNodeHelper(context.inSSR, isComponent));
  558. }
  559. if (directives) {
  560. context.helper(WITH_DIRECTIVES);
  561. }
  562. }
  563. return {
  564. type: 13,
  565. tag,
  566. props,
  567. children,
  568. patchFlag,
  569. dynamicProps,
  570. directives,
  571. isBlock,
  572. disableTracking,
  573. isComponent,
  574. loc
  575. };
  576. }
  577. function createArrayExpression(elements, loc = locStub) {
  578. return {
  579. type: 17,
  580. loc,
  581. elements
  582. };
  583. }
  584. function createObjectExpression(properties, loc = locStub) {
  585. return {
  586. type: 15,
  587. loc,
  588. properties
  589. };
  590. }
  591. function createObjectProperty(key, value) {
  592. return {
  593. type: 16,
  594. loc: locStub,
  595. key: isString$1(key) ? createSimpleExpression(key, true) : key,
  596. value
  597. };
  598. }
  599. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  600. return {
  601. type: 4,
  602. loc,
  603. content,
  604. isStatic,
  605. constType: isStatic ? 3 : constType
  606. };
  607. }
  608. function createInterpolation(content, loc) {
  609. return {
  610. type: 5,
  611. loc,
  612. content: isString$1(content) ? createSimpleExpression(content, false, loc) : content
  613. };
  614. }
  615. function createCompoundExpression(children, loc = locStub) {
  616. return {
  617. type: 8,
  618. loc,
  619. children
  620. };
  621. }
  622. function createCallExpression(callee, args = [], loc = locStub) {
  623. return {
  624. type: 14,
  625. loc,
  626. callee,
  627. arguments: args
  628. };
  629. }
  630. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  631. return {
  632. type: 18,
  633. params,
  634. returns,
  635. newline,
  636. isSlot,
  637. loc
  638. };
  639. }
  640. function createConditionalExpression(test, consequent, alternate, newline = true) {
  641. return {
  642. type: 19,
  643. test,
  644. consequent,
  645. alternate,
  646. newline,
  647. loc: locStub
  648. };
  649. }
  650. function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
  651. return {
  652. type: 20,
  653. index,
  654. value,
  655. needPauseTracking,
  656. inVOnce,
  657. needArraySpread: false,
  658. loc: locStub
  659. };
  660. }
  661. function createBlockStatement(body) {
  662. return {
  663. type: 21,
  664. body,
  665. loc: locStub
  666. };
  667. }
  668. function createTemplateLiteral(elements) {
  669. return {
  670. type: 22,
  671. elements,
  672. loc: locStub
  673. };
  674. }
  675. function createIfStatement(test, consequent, alternate) {
  676. return {
  677. type: 23,
  678. test,
  679. consequent,
  680. alternate,
  681. loc: locStub
  682. };
  683. }
  684. function createAssignmentExpression(left, right) {
  685. return {
  686. type: 24,
  687. left,
  688. right,
  689. loc: locStub
  690. };
  691. }
  692. function createSequenceExpression(expressions) {
  693. return {
  694. type: 25,
  695. expressions,
  696. loc: locStub
  697. };
  698. }
  699. function createReturnStatement(returns) {
  700. return {
  701. type: 26,
  702. returns,
  703. loc: locStub
  704. };
  705. }
  706. function getVNodeHelper(ssr, isComponent) {
  707. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  708. }
  709. function getVNodeBlockHelper(ssr, isComponent) {
  710. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  711. }
  712. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  713. if (!node.isBlock) {
  714. node.isBlock = true;
  715. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  716. helper(OPEN_BLOCK);
  717. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  718. }
  719. }
  720. // Generated using scripts/write-decode-map.ts
  721. var htmlDecodeTree = new Uint16Array(
  722. // prettier-ignore
  723. "\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"
  724. .split("")
  725. .map((c) => c.charCodeAt(0)));
  726. // Generated using scripts/write-decode-map.ts
  727. var xmlDecodeTree = new Uint16Array(
  728. // prettier-ignore
  729. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  730. .split("")
  731. .map((c) => c.charCodeAt(0)));
  732. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  733. var _a$1;
  734. const decodeMap = new Map([
  735. [0, 65533],
  736. // C1 Unicode control character reference replacements
  737. [128, 8364],
  738. [130, 8218],
  739. [131, 402],
  740. [132, 8222],
  741. [133, 8230],
  742. [134, 8224],
  743. [135, 8225],
  744. [136, 710],
  745. [137, 8240],
  746. [138, 352],
  747. [139, 8249],
  748. [140, 338],
  749. [142, 381],
  750. [145, 8216],
  751. [146, 8217],
  752. [147, 8220],
  753. [148, 8221],
  754. [149, 8226],
  755. [150, 8211],
  756. [151, 8212],
  757. [152, 732],
  758. [153, 8482],
  759. [154, 353],
  760. [155, 8250],
  761. [156, 339],
  762. [158, 382],
  763. [159, 376],
  764. ]);
  765. /**
  766. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  767. */
  768. const fromCodePoint =
  769. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  770. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  771. let output = "";
  772. if (codePoint > 0xffff) {
  773. codePoint -= 0x10000;
  774. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  775. codePoint = 0xdc00 | (codePoint & 0x3ff);
  776. }
  777. output += String.fromCharCode(codePoint);
  778. return output;
  779. };
  780. /**
  781. * Replace the given code point with a replacement character if it is a
  782. * surrogate or is outside the valid range. Otherwise return the code
  783. * point unchanged.
  784. */
  785. function replaceCodePoint(codePoint) {
  786. var _a;
  787. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  788. return 0xfffd;
  789. }
  790. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  791. }
  792. var CharCodes;
  793. (function (CharCodes) {
  794. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  795. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  796. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  797. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  798. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  799. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  800. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  801. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  802. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  803. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  804. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  805. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  806. })(CharCodes || (CharCodes = {}));
  807. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  808. const TO_LOWER_BIT = 0b100000;
  809. var BinTrieFlags;
  810. (function (BinTrieFlags) {
  811. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  812. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  813. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  814. })(BinTrieFlags || (BinTrieFlags = {}));
  815. function isNumber$1(code) {
  816. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  817. }
  818. function isHexadecimalCharacter(code) {
  819. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  820. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  821. }
  822. function isAsciiAlphaNumeric(code) {
  823. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  824. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  825. isNumber$1(code));
  826. }
  827. /**
  828. * Checks if the given character is a valid end character for an entity in an attribute.
  829. *
  830. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  831. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  832. */
  833. function isEntityInAttributeInvalidEnd(code) {
  834. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  835. }
  836. var EntityDecoderState;
  837. (function (EntityDecoderState) {
  838. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  839. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  840. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  841. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  842. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  843. })(EntityDecoderState || (EntityDecoderState = {}));
  844. var DecodingMode;
  845. (function (DecodingMode) {
  846. /** Entities in text nodes that can end with any character. */
  847. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  848. /** Only allow entities terminated with a semicolon. */
  849. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  850. /** Entities in attributes have limitations on ending characters. */
  851. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  852. })(DecodingMode || (DecodingMode = {}));
  853. /**
  854. * Token decoder with support of writing partial entities.
  855. */
  856. class EntityDecoder {
  857. constructor(
  858. /** The tree used to decode entities. */
  859. decodeTree,
  860. /**
  861. * The function that is called when a codepoint is decoded.
  862. *
  863. * For multi-byte named entities, this will be called multiple times,
  864. * with the second codepoint, and the same `consumed` value.
  865. *
  866. * @param codepoint The decoded codepoint.
  867. * @param consumed The number of bytes consumed by the decoder.
  868. */
  869. emitCodePoint,
  870. /** An object that is used to produce errors. */
  871. errors) {
  872. this.decodeTree = decodeTree;
  873. this.emitCodePoint = emitCodePoint;
  874. this.errors = errors;
  875. /** The current state of the decoder. */
  876. this.state = EntityDecoderState.EntityStart;
  877. /** Characters that were consumed while parsing an entity. */
  878. this.consumed = 1;
  879. /**
  880. * The result of the entity.
  881. *
  882. * Either the result index of a numeric entity, or the codepoint of a
  883. * numeric entity.
  884. */
  885. this.result = 0;
  886. /** The current index in the decode tree. */
  887. this.treeIndex = 0;
  888. /** The number of characters that were consumed in excess. */
  889. this.excess = 1;
  890. /** The mode in which the decoder is operating. */
  891. this.decodeMode = DecodingMode.Strict;
  892. }
  893. /** Resets the instance to make it reusable. */
  894. startEntity(decodeMode) {
  895. this.decodeMode = decodeMode;
  896. this.state = EntityDecoderState.EntityStart;
  897. this.result = 0;
  898. this.treeIndex = 0;
  899. this.excess = 1;
  900. this.consumed = 1;
  901. }
  902. /**
  903. * Write an entity to the decoder. This can be called multiple times with partial entities.
  904. * If the entity is incomplete, the decoder will return -1.
  905. *
  906. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  907. * entity is incomplete, and resume when the next string is written.
  908. *
  909. * @param string The string containing the entity (or a continuation of the entity).
  910. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  911. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  912. */
  913. write(str, offset) {
  914. switch (this.state) {
  915. case EntityDecoderState.EntityStart: {
  916. if (str.charCodeAt(offset) === CharCodes.NUM) {
  917. this.state = EntityDecoderState.NumericStart;
  918. this.consumed += 1;
  919. return this.stateNumericStart(str, offset + 1);
  920. }
  921. this.state = EntityDecoderState.NamedEntity;
  922. return this.stateNamedEntity(str, offset);
  923. }
  924. case EntityDecoderState.NumericStart: {
  925. return this.stateNumericStart(str, offset);
  926. }
  927. case EntityDecoderState.NumericDecimal: {
  928. return this.stateNumericDecimal(str, offset);
  929. }
  930. case EntityDecoderState.NumericHex: {
  931. return this.stateNumericHex(str, offset);
  932. }
  933. case EntityDecoderState.NamedEntity: {
  934. return this.stateNamedEntity(str, offset);
  935. }
  936. }
  937. }
  938. /**
  939. * Switches between the numeric decimal and hexadecimal states.
  940. *
  941. * Equivalent to the `Numeric character reference state` in the HTML spec.
  942. *
  943. * @param str The string containing the entity (or a continuation of the entity).
  944. * @param offset The current offset.
  945. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  946. */
  947. stateNumericStart(str, offset) {
  948. if (offset >= str.length) {
  949. return -1;
  950. }
  951. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  952. this.state = EntityDecoderState.NumericHex;
  953. this.consumed += 1;
  954. return this.stateNumericHex(str, offset + 1);
  955. }
  956. this.state = EntityDecoderState.NumericDecimal;
  957. return this.stateNumericDecimal(str, offset);
  958. }
  959. addToNumericResult(str, start, end, base) {
  960. if (start !== end) {
  961. const digitCount = end - start;
  962. this.result =
  963. this.result * Math.pow(base, digitCount) +
  964. parseInt(str.substr(start, digitCount), base);
  965. this.consumed += digitCount;
  966. }
  967. }
  968. /**
  969. * Parses a hexadecimal numeric entity.
  970. *
  971. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  972. *
  973. * @param str The string containing the entity (or a continuation of the entity).
  974. * @param offset The current offset.
  975. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  976. */
  977. stateNumericHex(str, offset) {
  978. const startIdx = offset;
  979. while (offset < str.length) {
  980. const char = str.charCodeAt(offset);
  981. if (isNumber$1(char) || isHexadecimalCharacter(char)) {
  982. offset += 1;
  983. }
  984. else {
  985. this.addToNumericResult(str, startIdx, offset, 16);
  986. return this.emitNumericEntity(char, 3);
  987. }
  988. }
  989. this.addToNumericResult(str, startIdx, offset, 16);
  990. return -1;
  991. }
  992. /**
  993. * Parses a decimal numeric entity.
  994. *
  995. * Equivalent to the `Decimal character reference state` in the HTML spec.
  996. *
  997. * @param str The string containing the entity (or a continuation of the entity).
  998. * @param offset The current offset.
  999. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1000. */
  1001. stateNumericDecimal(str, offset) {
  1002. const startIdx = offset;
  1003. while (offset < str.length) {
  1004. const char = str.charCodeAt(offset);
  1005. if (isNumber$1(char)) {
  1006. offset += 1;
  1007. }
  1008. else {
  1009. this.addToNumericResult(str, startIdx, offset, 10);
  1010. return this.emitNumericEntity(char, 2);
  1011. }
  1012. }
  1013. this.addToNumericResult(str, startIdx, offset, 10);
  1014. return -1;
  1015. }
  1016. /**
  1017. * Validate and emit a numeric entity.
  1018. *
  1019. * Implements the logic from the `Hexademical character reference start
  1020. * state` and `Numeric character reference end state` in the HTML spec.
  1021. *
  1022. * @param lastCp The last code point of the entity. Used to see if the
  1023. * entity was terminated with a semicolon.
  1024. * @param expectedLength The minimum number of characters that should be
  1025. * consumed. Used to validate that at least one digit
  1026. * was consumed.
  1027. * @returns The number of characters that were consumed.
  1028. */
  1029. emitNumericEntity(lastCp, expectedLength) {
  1030. var _a;
  1031. // Ensure we consumed at least one digit.
  1032. if (this.consumed <= expectedLength) {
  1033. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1034. return 0;
  1035. }
  1036. // Figure out if this is a legit end of the entity
  1037. if (lastCp === CharCodes.SEMI) {
  1038. this.consumed += 1;
  1039. }
  1040. else if (this.decodeMode === DecodingMode.Strict) {
  1041. return 0;
  1042. }
  1043. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  1044. if (this.errors) {
  1045. if (lastCp !== CharCodes.SEMI) {
  1046. this.errors.missingSemicolonAfterCharacterReference();
  1047. }
  1048. this.errors.validateNumericCharacterReference(this.result);
  1049. }
  1050. return this.consumed;
  1051. }
  1052. /**
  1053. * Parses a named entity.
  1054. *
  1055. * Equivalent to the `Named character reference state` in the HTML spec.
  1056. *
  1057. * @param str The string containing the entity (or a continuation of the entity).
  1058. * @param offset The current offset.
  1059. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1060. */
  1061. stateNamedEntity(str, offset) {
  1062. const { decodeTree } = this;
  1063. let current = decodeTree[this.treeIndex];
  1064. // The mask is the number of bytes of the value, including the current byte.
  1065. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1066. for (; offset < str.length; offset++, this.excess++) {
  1067. const char = str.charCodeAt(offset);
  1068. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1069. if (this.treeIndex < 0) {
  1070. return this.result === 0 ||
  1071. // If we are parsing an attribute
  1072. (this.decodeMode === DecodingMode.Attribute &&
  1073. // We shouldn't have consumed any characters after the entity,
  1074. (valueLength === 0 ||
  1075. // And there should be no invalid characters.
  1076. isEntityInAttributeInvalidEnd(char)))
  1077. ? 0
  1078. : this.emitNotTerminatedNamedEntity();
  1079. }
  1080. current = decodeTree[this.treeIndex];
  1081. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1082. // If the branch is a value, store it and continue
  1083. if (valueLength !== 0) {
  1084. // If the entity is terminated by a semicolon, we are done.
  1085. if (char === CharCodes.SEMI) {
  1086. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1087. }
  1088. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1089. if (this.decodeMode !== DecodingMode.Strict) {
  1090. this.result = this.treeIndex;
  1091. this.consumed += this.excess;
  1092. this.excess = 0;
  1093. }
  1094. }
  1095. }
  1096. return -1;
  1097. }
  1098. /**
  1099. * Emit a named entity that was not terminated with a semicolon.
  1100. *
  1101. * @returns The number of characters consumed.
  1102. */
  1103. emitNotTerminatedNamedEntity() {
  1104. var _a;
  1105. const { result, decodeTree } = this;
  1106. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1107. this.emitNamedEntityData(result, valueLength, this.consumed);
  1108. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1109. return this.consumed;
  1110. }
  1111. /**
  1112. * Emit a named entity.
  1113. *
  1114. * @param result The index of the entity in the decode tree.
  1115. * @param valueLength The number of bytes in the entity.
  1116. * @param consumed The number of characters consumed.
  1117. *
  1118. * @returns The number of characters consumed.
  1119. */
  1120. emitNamedEntityData(result, valueLength, consumed) {
  1121. const { decodeTree } = this;
  1122. this.emitCodePoint(valueLength === 1
  1123. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1124. : decodeTree[result + 1], consumed);
  1125. if (valueLength === 3) {
  1126. // For multi-byte values, we need to emit the second byte.
  1127. this.emitCodePoint(decodeTree[result + 2], consumed);
  1128. }
  1129. return consumed;
  1130. }
  1131. /**
  1132. * Signal to the parser that the end of the input was reached.
  1133. *
  1134. * Remaining data will be emitted and relevant errors will be produced.
  1135. *
  1136. * @returns The number of characters consumed.
  1137. */
  1138. end() {
  1139. var _a;
  1140. switch (this.state) {
  1141. case EntityDecoderState.NamedEntity: {
  1142. // Emit a named entity if we have one.
  1143. return this.result !== 0 &&
  1144. (this.decodeMode !== DecodingMode.Attribute ||
  1145. this.result === this.treeIndex)
  1146. ? this.emitNotTerminatedNamedEntity()
  1147. : 0;
  1148. }
  1149. // Otherwise, emit a numeric entity if we have one.
  1150. case EntityDecoderState.NumericDecimal: {
  1151. return this.emitNumericEntity(0, 2);
  1152. }
  1153. case EntityDecoderState.NumericHex: {
  1154. return this.emitNumericEntity(0, 3);
  1155. }
  1156. case EntityDecoderState.NumericStart: {
  1157. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1158. return 0;
  1159. }
  1160. case EntityDecoderState.EntityStart: {
  1161. // Return 0 if we have no entity.
  1162. return 0;
  1163. }
  1164. }
  1165. }
  1166. }
  1167. /**
  1168. * Creates a function that decodes entities in a string.
  1169. *
  1170. * @param decodeTree The decode tree.
  1171. * @returns A function that decodes entities in a string.
  1172. */
  1173. function getDecoder(decodeTree) {
  1174. let ret = "";
  1175. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1176. return function decodeWithTrie(str, decodeMode) {
  1177. let lastIndex = 0;
  1178. let offset = 0;
  1179. while ((offset = str.indexOf("&", offset)) >= 0) {
  1180. ret += str.slice(lastIndex, offset);
  1181. decoder.startEntity(decodeMode);
  1182. const len = decoder.write(str,
  1183. // Skip the "&"
  1184. offset + 1);
  1185. if (len < 0) {
  1186. lastIndex = offset + decoder.end();
  1187. break;
  1188. }
  1189. lastIndex = offset + len;
  1190. // If `len` is 0, skip the current `&` and continue.
  1191. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1192. }
  1193. const result = ret + str.slice(lastIndex);
  1194. // Make sure we don't keep a reference to the final string.
  1195. ret = "";
  1196. return result;
  1197. };
  1198. }
  1199. /**
  1200. * Determines the branch of the current node that is taken given the current
  1201. * character. This function is used to traverse the trie.
  1202. *
  1203. * @param decodeTree The trie.
  1204. * @param current The current node.
  1205. * @param nodeIdx The index right after the current node and its value.
  1206. * @param char The current character.
  1207. * @returns The index of the next node, or -1 if no branch is taken.
  1208. */
  1209. function determineBranch(decodeTree, current, nodeIdx, char) {
  1210. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1211. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1212. // Case 1: Single branch encoded in jump offset
  1213. if (branchCount === 0) {
  1214. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1215. }
  1216. // Case 2: Multiple branches encoded in jump table
  1217. if (jumpOffset) {
  1218. const value = char - jumpOffset;
  1219. return value < 0 || value >= branchCount
  1220. ? -1
  1221. : decodeTree[nodeIdx + value] - 1;
  1222. }
  1223. // Case 3: Multiple branches encoded in dictionary
  1224. // Binary search for the character.
  1225. let lo = nodeIdx;
  1226. let hi = lo + branchCount - 1;
  1227. while (lo <= hi) {
  1228. const mid = (lo + hi) >>> 1;
  1229. const midVal = decodeTree[mid];
  1230. if (midVal < char) {
  1231. lo = mid + 1;
  1232. }
  1233. else if (midVal > char) {
  1234. hi = mid - 1;
  1235. }
  1236. else {
  1237. return decodeTree[mid + branchCount];
  1238. }
  1239. }
  1240. return -1;
  1241. }
  1242. const htmlDecoder = getDecoder(htmlDecodeTree);
  1243. getDecoder(xmlDecodeTree);
  1244. /**
  1245. * Decodes an HTML string.
  1246. *
  1247. * @param str The string to decode.
  1248. * @param mode The decoding mode.
  1249. * @returns The decoded string.
  1250. */
  1251. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1252. return htmlDecoder(str, mode);
  1253. }
  1254. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1255. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1256. function isTagStartChar(c) {
  1257. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1258. }
  1259. function isWhitespace(c) {
  1260. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1261. }
  1262. function isEndOfTagSection(c) {
  1263. return c === 47 || c === 62 || isWhitespace(c);
  1264. }
  1265. function toCharCodes(str) {
  1266. const ret = new Uint8Array(str.length);
  1267. for (let i = 0; i < str.length; i++) {
  1268. ret[i] = str.charCodeAt(i);
  1269. }
  1270. return ret;
  1271. }
  1272. const Sequences = {
  1273. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1274. // CDATA[
  1275. CdataEnd: new Uint8Array([93, 93, 62]),
  1276. // ]]>
  1277. CommentEnd: new Uint8Array([45, 45, 62]),
  1278. // `-->`
  1279. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1280. // `<\/script`
  1281. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1282. // `</style`
  1283. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1284. // `</title`
  1285. TextareaEnd: new Uint8Array([
  1286. 60,
  1287. 47,
  1288. 116,
  1289. 101,
  1290. 120,
  1291. 116,
  1292. 97,
  1293. 114,
  1294. 101,
  1295. 97
  1296. ])
  1297. // `</textarea
  1298. };
  1299. class Tokenizer {
  1300. constructor(stack, cbs) {
  1301. this.stack = stack;
  1302. this.cbs = cbs;
  1303. /** The current state the tokenizer is in. */
  1304. this.state = 1;
  1305. /** The read buffer. */
  1306. this.buffer = "";
  1307. /** The beginning of the section that is currently being read. */
  1308. this.sectionStart = 0;
  1309. /** The index within the buffer that we are currently looking at. */
  1310. this.index = 0;
  1311. /** The start of the last entity. */
  1312. this.entityStart = 0;
  1313. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1314. this.baseState = 1;
  1315. /** For special parsing behavior inside of script and style tags. */
  1316. this.inRCDATA = false;
  1317. /** For disabling RCDATA tags handling */
  1318. this.inXML = false;
  1319. /** For disabling interpolation parsing in v-pre */
  1320. this.inVPre = false;
  1321. /** Record newline positions for fast line / column calculation */
  1322. this.newlines = [];
  1323. this.mode = 0;
  1324. this.delimiterOpen = defaultDelimitersOpen;
  1325. this.delimiterClose = defaultDelimitersClose;
  1326. this.delimiterIndex = -1;
  1327. this.currentSequence = void 0;
  1328. this.sequenceIndex = 0;
  1329. {
  1330. this.entityDecoder = new EntityDecoder(
  1331. htmlDecodeTree,
  1332. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1333. );
  1334. }
  1335. }
  1336. get inSFCRoot() {
  1337. return this.mode === 2 && this.stack.length === 0;
  1338. }
  1339. reset() {
  1340. this.state = 1;
  1341. this.mode = 0;
  1342. this.buffer = "";
  1343. this.sectionStart = 0;
  1344. this.index = 0;
  1345. this.baseState = 1;
  1346. this.inRCDATA = false;
  1347. this.currentSequence = void 0;
  1348. this.newlines.length = 0;
  1349. this.delimiterOpen = defaultDelimitersOpen;
  1350. this.delimiterClose = defaultDelimitersClose;
  1351. }
  1352. /**
  1353. * Generate Position object with line / column information using recorded
  1354. * newline positions. We know the index is always going to be an already
  1355. * processed index, so all the newlines up to this index should have been
  1356. * recorded.
  1357. */
  1358. getPos(index) {
  1359. let line = 1;
  1360. let column = index + 1;
  1361. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1362. const newlineIndex = this.newlines[i];
  1363. if (index > newlineIndex) {
  1364. line = i + 2;
  1365. column = index - newlineIndex;
  1366. break;
  1367. }
  1368. }
  1369. return {
  1370. column,
  1371. line,
  1372. offset: index
  1373. };
  1374. }
  1375. peek() {
  1376. return this.buffer.charCodeAt(this.index + 1);
  1377. }
  1378. stateText(c) {
  1379. if (c === 60) {
  1380. if (this.index > this.sectionStart) {
  1381. this.cbs.ontext(this.sectionStart, this.index);
  1382. }
  1383. this.state = 5;
  1384. this.sectionStart = this.index;
  1385. } else if (c === 38) {
  1386. this.startEntity();
  1387. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1388. this.state = 2;
  1389. this.delimiterIndex = 0;
  1390. this.stateInterpolationOpen(c);
  1391. }
  1392. }
  1393. stateInterpolationOpen(c) {
  1394. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1395. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1396. const start = this.index + 1 - this.delimiterOpen.length;
  1397. if (start > this.sectionStart) {
  1398. this.cbs.ontext(this.sectionStart, start);
  1399. }
  1400. this.state = 3;
  1401. this.sectionStart = start;
  1402. } else {
  1403. this.delimiterIndex++;
  1404. }
  1405. } else if (this.inRCDATA) {
  1406. this.state = 32;
  1407. this.stateInRCDATA(c);
  1408. } else {
  1409. this.state = 1;
  1410. this.stateText(c);
  1411. }
  1412. }
  1413. stateInterpolation(c) {
  1414. if (c === this.delimiterClose[0]) {
  1415. this.state = 4;
  1416. this.delimiterIndex = 0;
  1417. this.stateInterpolationClose(c);
  1418. }
  1419. }
  1420. stateInterpolationClose(c) {
  1421. if (c === this.delimiterClose[this.delimiterIndex]) {
  1422. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1423. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1424. if (this.inRCDATA) {
  1425. this.state = 32;
  1426. } else {
  1427. this.state = 1;
  1428. }
  1429. this.sectionStart = this.index + 1;
  1430. } else {
  1431. this.delimiterIndex++;
  1432. }
  1433. } else {
  1434. this.state = 3;
  1435. this.stateInterpolation(c);
  1436. }
  1437. }
  1438. stateSpecialStartSequence(c) {
  1439. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1440. const isMatch = isEnd ? (
  1441. // If we are at the end of the sequence, make sure the tag name has ended
  1442. isEndOfTagSection(c)
  1443. ) : (
  1444. // Otherwise, do a case-insensitive comparison
  1445. (c | 32) === this.currentSequence[this.sequenceIndex]
  1446. );
  1447. if (!isMatch) {
  1448. this.inRCDATA = false;
  1449. } else if (!isEnd) {
  1450. this.sequenceIndex++;
  1451. return;
  1452. }
  1453. this.sequenceIndex = 0;
  1454. this.state = 6;
  1455. this.stateInTagName(c);
  1456. }
  1457. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1458. stateInRCDATA(c) {
  1459. if (this.sequenceIndex === this.currentSequence.length) {
  1460. if (c === 62 || isWhitespace(c)) {
  1461. const endOfText = this.index - this.currentSequence.length;
  1462. if (this.sectionStart < endOfText) {
  1463. const actualIndex = this.index;
  1464. this.index = endOfText;
  1465. this.cbs.ontext(this.sectionStart, endOfText);
  1466. this.index = actualIndex;
  1467. }
  1468. this.sectionStart = endOfText + 2;
  1469. this.stateInClosingTagName(c);
  1470. this.inRCDATA = false;
  1471. return;
  1472. }
  1473. this.sequenceIndex = 0;
  1474. }
  1475. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1476. this.sequenceIndex += 1;
  1477. } else if (this.sequenceIndex === 0) {
  1478. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1479. if (c === 38) {
  1480. this.startEntity();
  1481. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1482. this.state = 2;
  1483. this.delimiterIndex = 0;
  1484. this.stateInterpolationOpen(c);
  1485. }
  1486. } else if (this.fastForwardTo(60)) {
  1487. this.sequenceIndex = 1;
  1488. }
  1489. } else {
  1490. this.sequenceIndex = Number(c === 60);
  1491. }
  1492. }
  1493. stateCDATASequence(c) {
  1494. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1495. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1496. this.state = 28;
  1497. this.currentSequence = Sequences.CdataEnd;
  1498. this.sequenceIndex = 0;
  1499. this.sectionStart = this.index + 1;
  1500. }
  1501. } else {
  1502. this.sequenceIndex = 0;
  1503. this.state = 23;
  1504. this.stateInDeclaration(c);
  1505. }
  1506. }
  1507. /**
  1508. * When we wait for one specific character, we can speed things up
  1509. * by skipping through the buffer until we find it.
  1510. *
  1511. * @returns Whether the character was found.
  1512. */
  1513. fastForwardTo(c) {
  1514. while (++this.index < this.buffer.length) {
  1515. const cc = this.buffer.charCodeAt(this.index);
  1516. if (cc === 10) {
  1517. this.newlines.push(this.index);
  1518. }
  1519. if (cc === c) {
  1520. return true;
  1521. }
  1522. }
  1523. this.index = this.buffer.length - 1;
  1524. return false;
  1525. }
  1526. /**
  1527. * Comments and CDATA end with `-->` and `]]>`.
  1528. *
  1529. * Their common qualities are:
  1530. * - Their end sequences have a distinct character they start with.
  1531. * - That character is then repeated, so we have to check multiple repeats.
  1532. * - All characters but the start character of the sequence can be skipped.
  1533. */
  1534. stateInCommentLike(c) {
  1535. if (c === this.currentSequence[this.sequenceIndex]) {
  1536. if (++this.sequenceIndex === this.currentSequence.length) {
  1537. if (this.currentSequence === Sequences.CdataEnd) {
  1538. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1539. } else {
  1540. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1541. }
  1542. this.sequenceIndex = 0;
  1543. this.sectionStart = this.index + 1;
  1544. this.state = 1;
  1545. }
  1546. } else if (this.sequenceIndex === 0) {
  1547. if (this.fastForwardTo(this.currentSequence[0])) {
  1548. this.sequenceIndex = 1;
  1549. }
  1550. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1551. this.sequenceIndex = 0;
  1552. }
  1553. }
  1554. startSpecial(sequence, offset) {
  1555. this.enterRCDATA(sequence, offset);
  1556. this.state = 31;
  1557. }
  1558. enterRCDATA(sequence, offset) {
  1559. this.inRCDATA = true;
  1560. this.currentSequence = sequence;
  1561. this.sequenceIndex = offset;
  1562. }
  1563. stateBeforeTagName(c) {
  1564. if (c === 33) {
  1565. this.state = 22;
  1566. this.sectionStart = this.index + 1;
  1567. } else if (c === 63) {
  1568. this.state = 24;
  1569. this.sectionStart = this.index + 1;
  1570. } else if (isTagStartChar(c)) {
  1571. this.sectionStart = this.index;
  1572. if (this.mode === 0) {
  1573. this.state = 6;
  1574. } else if (this.inSFCRoot) {
  1575. this.state = 34;
  1576. } else if (!this.inXML) {
  1577. if (c === 116) {
  1578. this.state = 30;
  1579. } else {
  1580. this.state = c === 115 ? 29 : 6;
  1581. }
  1582. } else {
  1583. this.state = 6;
  1584. }
  1585. } else if (c === 47) {
  1586. this.state = 8;
  1587. } else {
  1588. this.state = 1;
  1589. this.stateText(c);
  1590. }
  1591. }
  1592. stateInTagName(c) {
  1593. if (isEndOfTagSection(c)) {
  1594. this.handleTagName(c);
  1595. }
  1596. }
  1597. stateInSFCRootTagName(c) {
  1598. if (isEndOfTagSection(c)) {
  1599. const tag = this.buffer.slice(this.sectionStart, this.index);
  1600. if (tag !== "template") {
  1601. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1602. }
  1603. this.handleTagName(c);
  1604. }
  1605. }
  1606. handleTagName(c) {
  1607. this.cbs.onopentagname(this.sectionStart, this.index);
  1608. this.sectionStart = -1;
  1609. this.state = 11;
  1610. this.stateBeforeAttrName(c);
  1611. }
  1612. stateBeforeClosingTagName(c) {
  1613. if (isWhitespace(c)) ; else if (c === 62) {
  1614. {
  1615. this.cbs.onerr(14, this.index);
  1616. }
  1617. this.state = 1;
  1618. this.sectionStart = this.index + 1;
  1619. } else {
  1620. this.state = isTagStartChar(c) ? 9 : 27;
  1621. this.sectionStart = this.index;
  1622. }
  1623. }
  1624. stateInClosingTagName(c) {
  1625. if (c === 62 || isWhitespace(c)) {
  1626. this.cbs.onclosetag(this.sectionStart, this.index);
  1627. this.sectionStart = -1;
  1628. this.state = 10;
  1629. this.stateAfterClosingTagName(c);
  1630. }
  1631. }
  1632. stateAfterClosingTagName(c) {
  1633. if (c === 62) {
  1634. this.state = 1;
  1635. this.sectionStart = this.index + 1;
  1636. }
  1637. }
  1638. stateBeforeAttrName(c) {
  1639. if (c === 62) {
  1640. this.cbs.onopentagend(this.index);
  1641. if (this.inRCDATA) {
  1642. this.state = 32;
  1643. } else {
  1644. this.state = 1;
  1645. }
  1646. this.sectionStart = this.index + 1;
  1647. } else if (c === 47) {
  1648. this.state = 7;
  1649. if (this.peek() !== 62) {
  1650. this.cbs.onerr(22, this.index);
  1651. }
  1652. } else if (c === 60 && this.peek() === 47) {
  1653. this.cbs.onopentagend(this.index);
  1654. this.state = 5;
  1655. this.sectionStart = this.index;
  1656. } else if (!isWhitespace(c)) {
  1657. if (c === 61) {
  1658. this.cbs.onerr(
  1659. 19,
  1660. this.index
  1661. );
  1662. }
  1663. this.handleAttrStart(c);
  1664. }
  1665. }
  1666. handleAttrStart(c) {
  1667. if (c === 118 && this.peek() === 45) {
  1668. this.state = 13;
  1669. this.sectionStart = this.index;
  1670. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1671. this.cbs.ondirname(this.index, this.index + 1);
  1672. this.state = 14;
  1673. this.sectionStart = this.index + 1;
  1674. } else {
  1675. this.state = 12;
  1676. this.sectionStart = this.index;
  1677. }
  1678. }
  1679. stateInSelfClosingTag(c) {
  1680. if (c === 62) {
  1681. this.cbs.onselfclosingtag(this.index);
  1682. this.state = 1;
  1683. this.sectionStart = this.index + 1;
  1684. this.inRCDATA = false;
  1685. } else if (!isWhitespace(c)) {
  1686. this.state = 11;
  1687. this.stateBeforeAttrName(c);
  1688. }
  1689. }
  1690. stateInAttrName(c) {
  1691. if (c === 61 || isEndOfTagSection(c)) {
  1692. this.cbs.onattribname(this.sectionStart, this.index);
  1693. this.handleAttrNameEnd(c);
  1694. } else if (c === 34 || c === 39 || c === 60) {
  1695. this.cbs.onerr(
  1696. 17,
  1697. this.index
  1698. );
  1699. }
  1700. }
  1701. stateInDirName(c) {
  1702. if (c === 61 || isEndOfTagSection(c)) {
  1703. this.cbs.ondirname(this.sectionStart, this.index);
  1704. this.handleAttrNameEnd(c);
  1705. } else if (c === 58) {
  1706. this.cbs.ondirname(this.sectionStart, this.index);
  1707. this.state = 14;
  1708. this.sectionStart = this.index + 1;
  1709. } else if (c === 46) {
  1710. this.cbs.ondirname(this.sectionStart, this.index);
  1711. this.state = 16;
  1712. this.sectionStart = this.index + 1;
  1713. }
  1714. }
  1715. stateInDirArg(c) {
  1716. if (c === 61 || isEndOfTagSection(c)) {
  1717. this.cbs.ondirarg(this.sectionStart, this.index);
  1718. this.handleAttrNameEnd(c);
  1719. } else if (c === 91) {
  1720. this.state = 15;
  1721. } else if (c === 46) {
  1722. this.cbs.ondirarg(this.sectionStart, this.index);
  1723. this.state = 16;
  1724. this.sectionStart = this.index + 1;
  1725. }
  1726. }
  1727. stateInDynamicDirArg(c) {
  1728. if (c === 93) {
  1729. this.state = 14;
  1730. } else if (c === 61 || isEndOfTagSection(c)) {
  1731. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1732. this.handleAttrNameEnd(c);
  1733. {
  1734. this.cbs.onerr(
  1735. 27,
  1736. this.index
  1737. );
  1738. }
  1739. }
  1740. }
  1741. stateInDirModifier(c) {
  1742. if (c === 61 || isEndOfTagSection(c)) {
  1743. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1744. this.handleAttrNameEnd(c);
  1745. } else if (c === 46) {
  1746. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1747. this.sectionStart = this.index + 1;
  1748. }
  1749. }
  1750. handleAttrNameEnd(c) {
  1751. this.sectionStart = this.index;
  1752. this.state = 17;
  1753. this.cbs.onattribnameend(this.index);
  1754. this.stateAfterAttrName(c);
  1755. }
  1756. stateAfterAttrName(c) {
  1757. if (c === 61) {
  1758. this.state = 18;
  1759. } else if (c === 47 || c === 62) {
  1760. this.cbs.onattribend(0, this.sectionStart);
  1761. this.sectionStart = -1;
  1762. this.state = 11;
  1763. this.stateBeforeAttrName(c);
  1764. } else if (!isWhitespace(c)) {
  1765. this.cbs.onattribend(0, this.sectionStart);
  1766. this.handleAttrStart(c);
  1767. }
  1768. }
  1769. stateBeforeAttrValue(c) {
  1770. if (c === 34) {
  1771. this.state = 19;
  1772. this.sectionStart = this.index + 1;
  1773. } else if (c === 39) {
  1774. this.state = 20;
  1775. this.sectionStart = this.index + 1;
  1776. } else if (!isWhitespace(c)) {
  1777. this.sectionStart = this.index;
  1778. this.state = 21;
  1779. this.stateInAttrValueNoQuotes(c);
  1780. }
  1781. }
  1782. handleInAttrValue(c, quote) {
  1783. if (c === quote || false) {
  1784. this.cbs.onattribdata(this.sectionStart, this.index);
  1785. this.sectionStart = -1;
  1786. this.cbs.onattribend(
  1787. quote === 34 ? 3 : 2,
  1788. this.index + 1
  1789. );
  1790. this.state = 11;
  1791. } else if (c === 38) {
  1792. this.startEntity();
  1793. }
  1794. }
  1795. stateInAttrValueDoubleQuotes(c) {
  1796. this.handleInAttrValue(c, 34);
  1797. }
  1798. stateInAttrValueSingleQuotes(c) {
  1799. this.handleInAttrValue(c, 39);
  1800. }
  1801. stateInAttrValueNoQuotes(c) {
  1802. if (isWhitespace(c) || c === 62) {
  1803. this.cbs.onattribdata(this.sectionStart, this.index);
  1804. this.sectionStart = -1;
  1805. this.cbs.onattribend(1, this.index);
  1806. this.state = 11;
  1807. this.stateBeforeAttrName(c);
  1808. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1809. this.cbs.onerr(
  1810. 18,
  1811. this.index
  1812. );
  1813. } else if (c === 38) {
  1814. this.startEntity();
  1815. }
  1816. }
  1817. stateBeforeDeclaration(c) {
  1818. if (c === 91) {
  1819. this.state = 26;
  1820. this.sequenceIndex = 0;
  1821. } else {
  1822. this.state = c === 45 ? 25 : 23;
  1823. }
  1824. }
  1825. stateInDeclaration(c) {
  1826. if (c === 62 || this.fastForwardTo(62)) {
  1827. this.state = 1;
  1828. this.sectionStart = this.index + 1;
  1829. }
  1830. }
  1831. stateInProcessingInstruction(c) {
  1832. if (c === 62 || this.fastForwardTo(62)) {
  1833. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1834. this.state = 1;
  1835. this.sectionStart = this.index + 1;
  1836. }
  1837. }
  1838. stateBeforeComment(c) {
  1839. if (c === 45) {
  1840. this.state = 28;
  1841. this.currentSequence = Sequences.CommentEnd;
  1842. this.sequenceIndex = 2;
  1843. this.sectionStart = this.index + 1;
  1844. } else {
  1845. this.state = 23;
  1846. }
  1847. }
  1848. stateInSpecialComment(c) {
  1849. if (c === 62 || this.fastForwardTo(62)) {
  1850. this.cbs.oncomment(this.sectionStart, this.index);
  1851. this.state = 1;
  1852. this.sectionStart = this.index + 1;
  1853. }
  1854. }
  1855. stateBeforeSpecialS(c) {
  1856. if (c === Sequences.ScriptEnd[3]) {
  1857. this.startSpecial(Sequences.ScriptEnd, 4);
  1858. } else if (c === Sequences.StyleEnd[3]) {
  1859. this.startSpecial(Sequences.StyleEnd, 4);
  1860. } else {
  1861. this.state = 6;
  1862. this.stateInTagName(c);
  1863. }
  1864. }
  1865. stateBeforeSpecialT(c) {
  1866. if (c === Sequences.TitleEnd[3]) {
  1867. this.startSpecial(Sequences.TitleEnd, 4);
  1868. } else if (c === Sequences.TextareaEnd[3]) {
  1869. this.startSpecial(Sequences.TextareaEnd, 4);
  1870. } else {
  1871. this.state = 6;
  1872. this.stateInTagName(c);
  1873. }
  1874. }
  1875. startEntity() {
  1876. {
  1877. this.baseState = this.state;
  1878. this.state = 33;
  1879. this.entityStart = this.index;
  1880. this.entityDecoder.startEntity(
  1881. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1882. );
  1883. }
  1884. }
  1885. stateInEntity() {
  1886. {
  1887. const length = this.entityDecoder.write(this.buffer, this.index);
  1888. if (length >= 0) {
  1889. this.state = this.baseState;
  1890. if (length === 0) {
  1891. this.index = this.entityStart;
  1892. }
  1893. } else {
  1894. this.index = this.buffer.length - 1;
  1895. }
  1896. }
  1897. }
  1898. /**
  1899. * Iterates through the buffer, calling the function corresponding to the current state.
  1900. *
  1901. * States that are more likely to be hit are higher up, as a performance improvement.
  1902. */
  1903. parse(input) {
  1904. this.buffer = input;
  1905. while (this.index < this.buffer.length) {
  1906. const c = this.buffer.charCodeAt(this.index);
  1907. if (c === 10) {
  1908. this.newlines.push(this.index);
  1909. }
  1910. switch (this.state) {
  1911. case 1: {
  1912. this.stateText(c);
  1913. break;
  1914. }
  1915. case 2: {
  1916. this.stateInterpolationOpen(c);
  1917. break;
  1918. }
  1919. case 3: {
  1920. this.stateInterpolation(c);
  1921. break;
  1922. }
  1923. case 4: {
  1924. this.stateInterpolationClose(c);
  1925. break;
  1926. }
  1927. case 31: {
  1928. this.stateSpecialStartSequence(c);
  1929. break;
  1930. }
  1931. case 32: {
  1932. this.stateInRCDATA(c);
  1933. break;
  1934. }
  1935. case 26: {
  1936. this.stateCDATASequence(c);
  1937. break;
  1938. }
  1939. case 19: {
  1940. this.stateInAttrValueDoubleQuotes(c);
  1941. break;
  1942. }
  1943. case 12: {
  1944. this.stateInAttrName(c);
  1945. break;
  1946. }
  1947. case 13: {
  1948. this.stateInDirName(c);
  1949. break;
  1950. }
  1951. case 14: {
  1952. this.stateInDirArg(c);
  1953. break;
  1954. }
  1955. case 15: {
  1956. this.stateInDynamicDirArg(c);
  1957. break;
  1958. }
  1959. case 16: {
  1960. this.stateInDirModifier(c);
  1961. break;
  1962. }
  1963. case 28: {
  1964. this.stateInCommentLike(c);
  1965. break;
  1966. }
  1967. case 27: {
  1968. this.stateInSpecialComment(c);
  1969. break;
  1970. }
  1971. case 11: {
  1972. this.stateBeforeAttrName(c);
  1973. break;
  1974. }
  1975. case 6: {
  1976. this.stateInTagName(c);
  1977. break;
  1978. }
  1979. case 34: {
  1980. this.stateInSFCRootTagName(c);
  1981. break;
  1982. }
  1983. case 9: {
  1984. this.stateInClosingTagName(c);
  1985. break;
  1986. }
  1987. case 5: {
  1988. this.stateBeforeTagName(c);
  1989. break;
  1990. }
  1991. case 17: {
  1992. this.stateAfterAttrName(c);
  1993. break;
  1994. }
  1995. case 20: {
  1996. this.stateInAttrValueSingleQuotes(c);
  1997. break;
  1998. }
  1999. case 18: {
  2000. this.stateBeforeAttrValue(c);
  2001. break;
  2002. }
  2003. case 8: {
  2004. this.stateBeforeClosingTagName(c);
  2005. break;
  2006. }
  2007. case 10: {
  2008. this.stateAfterClosingTagName(c);
  2009. break;
  2010. }
  2011. case 29: {
  2012. this.stateBeforeSpecialS(c);
  2013. break;
  2014. }
  2015. case 30: {
  2016. this.stateBeforeSpecialT(c);
  2017. break;
  2018. }
  2019. case 21: {
  2020. this.stateInAttrValueNoQuotes(c);
  2021. break;
  2022. }
  2023. case 7: {
  2024. this.stateInSelfClosingTag(c);
  2025. break;
  2026. }
  2027. case 23: {
  2028. this.stateInDeclaration(c);
  2029. break;
  2030. }
  2031. case 22: {
  2032. this.stateBeforeDeclaration(c);
  2033. break;
  2034. }
  2035. case 25: {
  2036. this.stateBeforeComment(c);
  2037. break;
  2038. }
  2039. case 24: {
  2040. this.stateInProcessingInstruction(c);
  2041. break;
  2042. }
  2043. case 33: {
  2044. this.stateInEntity();
  2045. break;
  2046. }
  2047. }
  2048. this.index++;
  2049. }
  2050. this.cleanup();
  2051. this.finish();
  2052. }
  2053. /**
  2054. * Remove data that has already been consumed from the buffer.
  2055. */
  2056. cleanup() {
  2057. if (this.sectionStart !== this.index) {
  2058. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  2059. this.cbs.ontext(this.sectionStart, this.index);
  2060. this.sectionStart = this.index;
  2061. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  2062. this.cbs.onattribdata(this.sectionStart, this.index);
  2063. this.sectionStart = this.index;
  2064. }
  2065. }
  2066. }
  2067. finish() {
  2068. if (this.state === 33) {
  2069. this.entityDecoder.end();
  2070. this.state = this.baseState;
  2071. }
  2072. this.handleTrailingData();
  2073. this.cbs.onend();
  2074. }
  2075. /** Handle any trailing data. */
  2076. handleTrailingData() {
  2077. const endIndex = this.buffer.length;
  2078. if (this.sectionStart >= endIndex) {
  2079. return;
  2080. }
  2081. if (this.state === 28) {
  2082. if (this.currentSequence === Sequences.CdataEnd) {
  2083. this.cbs.oncdata(this.sectionStart, endIndex);
  2084. } else {
  2085. this.cbs.oncomment(this.sectionStart, endIndex);
  2086. }
  2087. } 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 {
  2088. this.cbs.ontext(this.sectionStart, endIndex);
  2089. }
  2090. }
  2091. emitCodePoint(cp, consumed) {
  2092. {
  2093. if (this.baseState !== 1 && this.baseState !== 32) {
  2094. if (this.sectionStart < this.entityStart) {
  2095. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2096. }
  2097. this.sectionStart = this.entityStart + consumed;
  2098. this.index = this.sectionStart - 1;
  2099. this.cbs.onattribentity(
  2100. fromCodePoint(cp),
  2101. this.entityStart,
  2102. this.sectionStart
  2103. );
  2104. } else {
  2105. if (this.sectionStart < this.entityStart) {
  2106. this.cbs.ontext(this.sectionStart, this.entityStart);
  2107. }
  2108. this.sectionStart = this.entityStart + consumed;
  2109. this.index = this.sectionStart - 1;
  2110. this.cbs.ontextentity(
  2111. fromCodePoint(cp),
  2112. this.entityStart,
  2113. this.sectionStart
  2114. );
  2115. }
  2116. }
  2117. }
  2118. }
  2119. const CompilerDeprecationTypes = {
  2120. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2121. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2122. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2123. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2124. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2125. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2126. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2127. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2128. };
  2129. const deprecationData = {
  2130. ["COMPILER_IS_ON_ELEMENT"]: {
  2131. 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:".`,
  2132. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2133. },
  2134. ["COMPILER_V_BIND_SYNC"]: {
  2135. 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}\`.`,
  2136. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2137. },
  2138. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2139. 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.`,
  2140. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2141. },
  2142. ["COMPILER_V_ON_NATIVE"]: {
  2143. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2144. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2145. },
  2146. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2147. 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.`,
  2148. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2149. },
  2150. ["COMPILER_NATIVE_TEMPLATE"]: {
  2151. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2152. },
  2153. ["COMPILER_INLINE_TEMPLATE"]: {
  2154. message: `"inline-template" has been removed in Vue 3.`,
  2155. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2156. },
  2157. ["COMPILER_FILTERS"]: {
  2158. 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.`,
  2159. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2160. }
  2161. };
  2162. function getCompatValue(key, { compatConfig }) {
  2163. const value = compatConfig && compatConfig[key];
  2164. if (key === "MODE") {
  2165. return value || 3;
  2166. } else {
  2167. return value;
  2168. }
  2169. }
  2170. function isCompatEnabled(key, context) {
  2171. const mode = getCompatValue("MODE", context);
  2172. const value = getCompatValue(key, context);
  2173. return mode === 3 ? value === true : value !== false;
  2174. }
  2175. function checkCompatEnabled(key, context, loc, ...args) {
  2176. const enabled = isCompatEnabled(key, context);
  2177. if (enabled) {
  2178. warnDeprecation(key, context, loc, ...args);
  2179. }
  2180. return enabled;
  2181. }
  2182. function warnDeprecation(key, context, loc, ...args) {
  2183. const val = getCompatValue(key, context);
  2184. if (val === "suppress-warning") {
  2185. return;
  2186. }
  2187. const { message, link } = deprecationData[key];
  2188. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2189. Details: ${link}` : ``}`;
  2190. const err = new SyntaxError(msg);
  2191. err.code = key;
  2192. if (loc) err.loc = loc;
  2193. context.onWarn(err);
  2194. }
  2195. function defaultOnError(error) {
  2196. throw error;
  2197. }
  2198. function defaultOnWarn(msg) {
  2199. console.warn(`[Vue warn] ${msg.message}`);
  2200. }
  2201. function createCompilerError(code, loc, messages, additionalMessage) {
  2202. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2203. const error = new SyntaxError(String(msg));
  2204. error.code = code;
  2205. error.loc = loc;
  2206. return error;
  2207. }
  2208. const ErrorCodes = {
  2209. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2210. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2211. "CDATA_IN_HTML_CONTENT": 1,
  2212. "1": "CDATA_IN_HTML_CONTENT",
  2213. "DUPLICATE_ATTRIBUTE": 2,
  2214. "2": "DUPLICATE_ATTRIBUTE",
  2215. "END_TAG_WITH_ATTRIBUTES": 3,
  2216. "3": "END_TAG_WITH_ATTRIBUTES",
  2217. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2218. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2219. "EOF_BEFORE_TAG_NAME": 5,
  2220. "5": "EOF_BEFORE_TAG_NAME",
  2221. "EOF_IN_CDATA": 6,
  2222. "6": "EOF_IN_CDATA",
  2223. "EOF_IN_COMMENT": 7,
  2224. "7": "EOF_IN_COMMENT",
  2225. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2226. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2227. "EOF_IN_TAG": 9,
  2228. "9": "EOF_IN_TAG",
  2229. "INCORRECTLY_CLOSED_COMMENT": 10,
  2230. "10": "INCORRECTLY_CLOSED_COMMENT",
  2231. "INCORRECTLY_OPENED_COMMENT": 11,
  2232. "11": "INCORRECTLY_OPENED_COMMENT",
  2233. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2234. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2235. "MISSING_ATTRIBUTE_VALUE": 13,
  2236. "13": "MISSING_ATTRIBUTE_VALUE",
  2237. "MISSING_END_TAG_NAME": 14,
  2238. "14": "MISSING_END_TAG_NAME",
  2239. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2240. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2241. "NESTED_COMMENT": 16,
  2242. "16": "NESTED_COMMENT",
  2243. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2244. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2245. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2246. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2247. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2248. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2249. "UNEXPECTED_NULL_CHARACTER": 20,
  2250. "20": "UNEXPECTED_NULL_CHARACTER",
  2251. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2252. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2253. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2254. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2255. "X_INVALID_END_TAG": 23,
  2256. "23": "X_INVALID_END_TAG",
  2257. "X_MISSING_END_TAG": 24,
  2258. "24": "X_MISSING_END_TAG",
  2259. "X_MISSING_INTERPOLATION_END": 25,
  2260. "25": "X_MISSING_INTERPOLATION_END",
  2261. "X_MISSING_DIRECTIVE_NAME": 26,
  2262. "26": "X_MISSING_DIRECTIVE_NAME",
  2263. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2264. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2265. "X_V_IF_NO_EXPRESSION": 28,
  2266. "28": "X_V_IF_NO_EXPRESSION",
  2267. "X_V_IF_SAME_KEY": 29,
  2268. "29": "X_V_IF_SAME_KEY",
  2269. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2270. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2271. "X_V_FOR_NO_EXPRESSION": 31,
  2272. "31": "X_V_FOR_NO_EXPRESSION",
  2273. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2274. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2275. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2276. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2277. "X_V_BIND_NO_EXPRESSION": 34,
  2278. "34": "X_V_BIND_NO_EXPRESSION",
  2279. "X_V_ON_NO_EXPRESSION": 35,
  2280. "35": "X_V_ON_NO_EXPRESSION",
  2281. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2282. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2283. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2284. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2285. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2286. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2287. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2288. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2289. "X_V_SLOT_MISPLACED": 40,
  2290. "40": "X_V_SLOT_MISPLACED",
  2291. "X_V_MODEL_NO_EXPRESSION": 41,
  2292. "41": "X_V_MODEL_NO_EXPRESSION",
  2293. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2294. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2295. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2296. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2297. "X_V_MODEL_ON_PROPS": 44,
  2298. "44": "X_V_MODEL_ON_PROPS",
  2299. "X_INVALID_EXPRESSION": 45,
  2300. "45": "X_INVALID_EXPRESSION",
  2301. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2302. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2303. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2304. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2305. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2306. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2307. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2308. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2309. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2310. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2311. "X_VNODE_HOOKS": 51,
  2312. "51": "X_VNODE_HOOKS",
  2313. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2314. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2315. "__EXTEND_POINT__": 53,
  2316. "53": "__EXTEND_POINT__"
  2317. };
  2318. const errorMessages$1 = {
  2319. // parse errors
  2320. [0]: "Illegal comment.",
  2321. [1]: "CDATA section is allowed only in XML context.",
  2322. [2]: "Duplicate attribute.",
  2323. [3]: "End tag cannot have attributes.",
  2324. [4]: "Illegal '/' in tags.",
  2325. [5]: "Unexpected EOF in tag.",
  2326. [6]: "Unexpected EOF in CDATA section.",
  2327. [7]: "Unexpected EOF in comment.",
  2328. [8]: "Unexpected EOF in script.",
  2329. [9]: "Unexpected EOF in tag.",
  2330. [10]: "Incorrectly closed comment.",
  2331. [11]: "Incorrectly opened comment.",
  2332. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2333. [13]: "Attribute value was expected.",
  2334. [14]: "End tag name was expected.",
  2335. [15]: "Whitespace was expected.",
  2336. [16]: "Unexpected '<!--' in comment.",
  2337. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2338. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2339. [19]: "Attribute name cannot start with '='.",
  2340. [21]: "'<?' is allowed only in XML context.",
  2341. [20]: `Unexpected null character.`,
  2342. [22]: "Illegal '/' in tags.",
  2343. // Vue-specific parse errors
  2344. [23]: "Invalid end tag.",
  2345. [24]: "Element is missing end tag.",
  2346. [25]: "Interpolation end sign was not found.",
  2347. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2348. [26]: "Legal directive name was expected.",
  2349. // transform errors
  2350. [28]: `v-if/v-else-if is missing expression.`,
  2351. [29]: `v-if/else branches must use unique keys.`,
  2352. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2353. [31]: `v-for is missing expression.`,
  2354. [32]: `v-for has invalid expression.`,
  2355. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2356. [34]: `v-bind is missing expression.`,
  2357. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2358. [35]: `v-on is missing expression.`,
  2359. [36]: `Unexpected custom directive on <slot> outlet.`,
  2360. [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.`,
  2361. [38]: `Duplicate slot names found. `,
  2362. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2363. [40]: `v-slot can only be used on components or <template> tags.`,
  2364. [41]: `v-model is missing expression.`,
  2365. [42]: `v-model value must be a valid JavaScript member expression.`,
  2366. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2367. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2368. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2369. [45]: `Error parsing JavaScript expression: `,
  2370. [46]: `<KeepAlive> expects exactly one child component.`,
  2371. [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.`,
  2372. // generic errors
  2373. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2374. [48]: `ES module mode is not supported in this build of compiler.`,
  2375. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2376. [50]: `"scopeId" option is only supported in module mode.`,
  2377. // just to fulfill types
  2378. [53]: ``
  2379. };
  2380. function getDefaultExportFromCjs (x) {
  2381. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2382. }
  2383. function getAugmentedNamespace(n) {
  2384. if (n.__esModule) return n;
  2385. var f = n.default;
  2386. if (typeof f == "function") {
  2387. var a = function a () {
  2388. if (this instanceof a) {
  2389. return Reflect.construct(f, arguments, this.constructor);
  2390. }
  2391. return f.apply(this, arguments);
  2392. };
  2393. a.prototype = f.prototype;
  2394. } else a = {};
  2395. Object.defineProperty(a, '__esModule', {value: true});
  2396. Object.keys(n).forEach(function (k) {
  2397. var d = Object.getOwnPropertyDescriptor(n, k);
  2398. Object.defineProperty(a, k, d.get ? d : {
  2399. enumerable: true,
  2400. get: function () {
  2401. return n[k];
  2402. }
  2403. });
  2404. });
  2405. return a;
  2406. }
  2407. var lib = {};
  2408. var hasRequiredLib;
  2409. function requireLib () {
  2410. if (hasRequiredLib) return lib;
  2411. hasRequiredLib = 1;
  2412. Object.defineProperty(lib, '__esModule', {
  2413. value: true
  2414. });
  2415. function _objectWithoutPropertiesLoose(r, e) {
  2416. if (null == r) return {};
  2417. var t = {};
  2418. for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
  2419. if (e.includes(n)) continue;
  2420. t[n] = r[n];
  2421. }
  2422. return t;
  2423. }
  2424. class Position {
  2425. constructor(line, col, index) {
  2426. this.line = void 0;
  2427. this.column = void 0;
  2428. this.index = void 0;
  2429. this.line = line;
  2430. this.column = col;
  2431. this.index = index;
  2432. }
  2433. }
  2434. class SourceLocation {
  2435. constructor(start, end) {
  2436. this.start = void 0;
  2437. this.end = void 0;
  2438. this.filename = void 0;
  2439. this.identifierName = void 0;
  2440. this.start = start;
  2441. this.end = end;
  2442. }
  2443. }
  2444. function createPositionWithColumnOffset(position, columnOffset) {
  2445. const {
  2446. line,
  2447. column,
  2448. index
  2449. } = position;
  2450. return new Position(line, column + columnOffset, index + columnOffset);
  2451. }
  2452. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2453. var ModuleErrors = {
  2454. ImportMetaOutsideModule: {
  2455. message: `import.meta may appear only with 'sourceType: "module"'`,
  2456. code
  2457. },
  2458. ImportOutsideModule: {
  2459. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2460. code
  2461. }
  2462. };
  2463. const NodeDescriptions = {
  2464. ArrayPattern: "array destructuring pattern",
  2465. AssignmentExpression: "assignment expression",
  2466. AssignmentPattern: "assignment expression",
  2467. ArrowFunctionExpression: "arrow function expression",
  2468. ConditionalExpression: "conditional expression",
  2469. CatchClause: "catch clause",
  2470. ForOfStatement: "for-of statement",
  2471. ForInStatement: "for-in statement",
  2472. ForStatement: "for-loop",
  2473. FormalParameters: "function parameter list",
  2474. Identifier: "identifier",
  2475. ImportSpecifier: "import specifier",
  2476. ImportDefaultSpecifier: "import default specifier",
  2477. ImportNamespaceSpecifier: "import namespace specifier",
  2478. ObjectPattern: "object destructuring pattern",
  2479. ParenthesizedExpression: "parenthesized expression",
  2480. RestElement: "rest element",
  2481. UpdateExpression: {
  2482. true: "prefix operation",
  2483. false: "postfix operation"
  2484. },
  2485. VariableDeclarator: "variable declaration",
  2486. YieldExpression: "yield expression"
  2487. };
  2488. const toNodeDescription = node => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
  2489. var StandardErrors = {
  2490. AccessorIsGenerator: ({
  2491. kind
  2492. }) => `A ${kind}ter cannot be a generator.`,
  2493. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2494. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2495. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2496. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2497. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2498. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2499. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2500. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  2501. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2502. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2503. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2504. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2505. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2506. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2507. ConstructorIsAsync: "Constructor can't be an async function.",
  2508. ConstructorIsGenerator: "Constructor can't be a generator.",
  2509. DeclarationMissingInitializer: ({
  2510. kind
  2511. }) => `Missing initializer in ${kind} declaration.`,
  2512. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2513. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2514. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2515. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2516. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2517. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2518. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2519. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2520. DeletePrivateField: "Deleting a private field is not allowed.",
  2521. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2522. DuplicateConstructor: "Duplicate constructor in the same class.",
  2523. DuplicateDefaultExport: "Only one default export allowed per module.",
  2524. DuplicateExport: ({
  2525. exportName
  2526. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2527. DuplicateProto: "Redefinition of __proto__ property.",
  2528. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2529. DynamicImportPhaseRequiresImportExpressions: ({
  2530. phase
  2531. }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
  2532. ElementAfterRest: "Rest element must be last element.",
  2533. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2534. ExportBindingIsString: ({
  2535. localName,
  2536. exportName
  2537. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2538. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2539. ForInOfLoopInitializer: ({
  2540. type
  2541. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2542. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2543. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2544. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2545. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2546. IllegalBreakContinue: ({
  2547. type
  2548. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2549. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2550. IllegalReturn: "'return' outside of function.",
  2551. 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.",
  2552. ImportBindingIsString: ({
  2553. importName
  2554. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2555. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  2556. ImportCallArity: ({
  2557. maxArgumentCount
  2558. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  2559. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2560. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2561. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2562. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2563. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2564. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2565. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2566. InvalidCodePoint: "Code point out of bounds.",
  2567. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2568. InvalidDecimal: "Invalid decimal.",
  2569. InvalidDigit: ({
  2570. radix
  2571. }) => `Expected number in radix ${radix}.`,
  2572. InvalidEscapeSequence: "Bad character escape sequence.",
  2573. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2574. InvalidEscapedReservedWord: ({
  2575. reservedWord
  2576. }) => `Escape sequence in keyword ${reservedWord}.`,
  2577. InvalidIdentifier: ({
  2578. identifierName
  2579. }) => `Invalid identifier ${identifierName}.`,
  2580. InvalidLhs: ({
  2581. ancestor
  2582. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2583. InvalidLhsBinding: ({
  2584. ancestor
  2585. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2586. InvalidLhsOptionalChaining: ({
  2587. ancestor
  2588. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2589. InvalidNumber: "Invalid number.",
  2590. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2591. InvalidOrUnexpectedToken: ({
  2592. unexpected
  2593. }) => `Unexpected character '${unexpected}'.`,
  2594. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2595. InvalidPrivateFieldResolution: ({
  2596. identifierName
  2597. }) => `Private name #${identifierName} is not defined.`,
  2598. InvalidPropertyBindingPattern: "Binding member expression.",
  2599. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2600. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2601. LabelRedeclaration: ({
  2602. labelName
  2603. }) => `Label '${labelName}' is already declared.`,
  2604. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2605. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2606. MalformedRegExpFlags: "Invalid regular expression flag.",
  2607. MissingClassName: "A class name is required.",
  2608. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2609. MissingSemicolon: "Missing semicolon.",
  2610. MissingPlugin: ({
  2611. missingPlugin
  2612. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2613. MissingOneOfPlugins: ({
  2614. missingPlugin
  2615. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2616. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2617. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2618. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2619. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2620. ModuleAttributesWithDuplicateKeys: ({
  2621. key
  2622. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2623. ModuleExportNameHasLoneSurrogate: ({
  2624. surrogateCharCode
  2625. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2626. ModuleExportUndefined: ({
  2627. localName
  2628. }) => `Export '${localName}' is not defined.`,
  2629. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2630. NewlineAfterThrow: "Illegal newline after throw.",
  2631. NoCatchOrFinally: "Missing catch or finally clause.",
  2632. NumberIdentifier: "Identifier directly after number.",
  2633. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2634. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2635. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2636. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2637. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2638. ParamDupe: "Argument name clash.",
  2639. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2640. PatternHasMethod: "Object pattern can't contain methods.",
  2641. PrivateInExpectedIn: ({
  2642. identifierName
  2643. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2644. PrivateNameRedeclaration: ({
  2645. identifierName
  2646. }) => `Duplicate private name #${identifierName}.`,
  2647. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2648. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2649. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2650. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2651. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2652. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2653. 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.",
  2654. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2655. StaticPrototype: "Classes may not have static property named prototype.",
  2656. 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?",
  2657. SuperPrivateField: "Private fields can't be accessed on super.",
  2658. TrailingDecorator: "Decorators must be attached to a class element.",
  2659. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2660. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2661. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2662. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2663. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2664. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2665. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2666. UnexpectedKeyword: ({
  2667. keyword
  2668. }) => `Unexpected keyword '${keyword}'.`,
  2669. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2670. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2671. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2672. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2673. UnexpectedPrivateField: "Unexpected private name.",
  2674. UnexpectedReservedWord: ({
  2675. reservedWord
  2676. }) => `Unexpected reserved word '${reservedWord}'.`,
  2677. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2678. UnexpectedToken: ({
  2679. expected,
  2680. unexpected
  2681. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2682. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2683. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  2684. UnsupportedBind: "Binding should be performed on object property.",
  2685. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2686. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2687. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2688. UnsupportedMetaProperty: ({
  2689. target,
  2690. onlyValidPropertyName
  2691. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2692. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2693. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2694. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2695. UnterminatedComment: "Unterminated comment.",
  2696. UnterminatedRegExp: "Unterminated regular expression.",
  2697. UnterminatedString: "Unterminated string constant.",
  2698. UnterminatedTemplate: "Unterminated template.",
  2699. UsingDeclarationExport: "Using declaration cannot be exported.",
  2700. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2701. VarRedeclaration: ({
  2702. identifierName
  2703. }) => `Identifier '${identifierName}' has already been declared.`,
  2704. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2705. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2706. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2707. };
  2708. var StrictModeErrors = {
  2709. StrictDelete: "Deleting local variable in strict mode.",
  2710. StrictEvalArguments: ({
  2711. referenceName
  2712. }) => `Assigning to '${referenceName}' in strict mode.`,
  2713. StrictEvalArgumentsBinding: ({
  2714. bindingName
  2715. }) => `Binding '${bindingName}' in strict mode.`,
  2716. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2717. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2718. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2719. StrictWith: "'with' in strict mode."
  2720. };
  2721. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2722. var PipelineOperatorErrors = {
  2723. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2724. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2725. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2726. PipeTopicUnconfiguredToken: ({
  2727. token
  2728. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2729. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2730. PipeUnparenthesizedBody: ({
  2731. type
  2732. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2733. type
  2734. })}; please wrap it in parentheses.`,
  2735. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2736. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2737. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2738. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2739. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2740. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2741. };
  2742. const _excluded = ["message"];
  2743. function defineHidden(obj, key, value) {
  2744. Object.defineProperty(obj, key, {
  2745. enumerable: false,
  2746. configurable: true,
  2747. value
  2748. });
  2749. }
  2750. function toParseErrorConstructor({
  2751. toMessage,
  2752. code,
  2753. reasonCode,
  2754. syntaxPlugin
  2755. }) {
  2756. const hasMissingPlugin = reasonCode === "MissingPlugin" || reasonCode === "MissingOneOfPlugins";
  2757. return function constructor(loc, details) {
  2758. const error = new SyntaxError();
  2759. error.code = code;
  2760. error.reasonCode = reasonCode;
  2761. error.loc = loc;
  2762. error.pos = loc.index;
  2763. error.syntaxPlugin = syntaxPlugin;
  2764. if (hasMissingPlugin) {
  2765. error.missingPlugin = details.missingPlugin;
  2766. }
  2767. defineHidden(error, "clone", function clone(overrides = {}) {
  2768. var _overrides$loc;
  2769. const {
  2770. line,
  2771. column,
  2772. index
  2773. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2774. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2775. });
  2776. defineHidden(error, "details", details);
  2777. Object.defineProperty(error, "message", {
  2778. configurable: true,
  2779. get() {
  2780. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2781. this.message = message;
  2782. return message;
  2783. },
  2784. set(value) {
  2785. Object.defineProperty(this, "message", {
  2786. value,
  2787. writable: true
  2788. });
  2789. }
  2790. });
  2791. return error;
  2792. };
  2793. }
  2794. function ParseErrorEnum(argument, syntaxPlugin) {
  2795. if (Array.isArray(argument)) {
  2796. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2797. }
  2798. const ParseErrorConstructors = {};
  2799. for (const reasonCode of Object.keys(argument)) {
  2800. const template = argument[reasonCode];
  2801. const _ref = typeof template === "string" ? {
  2802. message: () => template
  2803. } : typeof template === "function" ? {
  2804. message: template
  2805. } : template,
  2806. {
  2807. message
  2808. } = _ref,
  2809. rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  2810. const toMessage = typeof message === "string" ? () => message : message;
  2811. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2812. code: "BABEL_PARSER_SYNTAX_ERROR",
  2813. reasonCode,
  2814. toMessage
  2815. }, syntaxPlugin ? {
  2816. syntaxPlugin
  2817. } : {}, rest));
  2818. }
  2819. return ParseErrorConstructors;
  2820. }
  2821. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2822. const {
  2823. defineProperty
  2824. } = Object;
  2825. const toUnenumerable = (object, key) => {
  2826. if (object) {
  2827. defineProperty(object, key, {
  2828. enumerable: false,
  2829. value: object[key]
  2830. });
  2831. }
  2832. };
  2833. function toESTreeLocation(node) {
  2834. toUnenumerable(node.loc.start, "index");
  2835. toUnenumerable(node.loc.end, "index");
  2836. return node;
  2837. }
  2838. var estree = superClass => class ESTreeParserMixin extends superClass {
  2839. parse() {
  2840. const file = toESTreeLocation(super.parse());
  2841. if (this.options.tokens) {
  2842. file.tokens = file.tokens.map(toESTreeLocation);
  2843. }
  2844. return file;
  2845. }
  2846. parseRegExpLiteral({
  2847. pattern,
  2848. flags
  2849. }) {
  2850. let regex = null;
  2851. try {
  2852. regex = new RegExp(pattern, flags);
  2853. } catch (_) {}
  2854. const node = this.estreeParseLiteral(regex);
  2855. node.regex = {
  2856. pattern,
  2857. flags
  2858. };
  2859. return node;
  2860. }
  2861. parseBigIntLiteral(value) {
  2862. let bigInt;
  2863. try {
  2864. bigInt = BigInt(value);
  2865. } catch (_unused) {
  2866. bigInt = null;
  2867. }
  2868. const node = this.estreeParseLiteral(bigInt);
  2869. node.bigint = String(node.value || value);
  2870. return node;
  2871. }
  2872. parseDecimalLiteral(value) {
  2873. const decimal = null;
  2874. const node = this.estreeParseLiteral(decimal);
  2875. node.decimal = String(node.value || value);
  2876. return node;
  2877. }
  2878. estreeParseLiteral(value) {
  2879. return this.parseLiteral(value, "Literal");
  2880. }
  2881. parseStringLiteral(value) {
  2882. return this.estreeParseLiteral(value);
  2883. }
  2884. parseNumericLiteral(value) {
  2885. return this.estreeParseLiteral(value);
  2886. }
  2887. parseNullLiteral() {
  2888. return this.estreeParseLiteral(null);
  2889. }
  2890. parseBooleanLiteral(value) {
  2891. return this.estreeParseLiteral(value);
  2892. }
  2893. directiveToStmt(directive) {
  2894. const expression = directive.value;
  2895. delete directive.value;
  2896. expression.type = "Literal";
  2897. expression.raw = expression.extra.raw;
  2898. expression.value = expression.extra.expressionValue;
  2899. const stmt = directive;
  2900. stmt.type = "ExpressionStatement";
  2901. stmt.expression = expression;
  2902. stmt.directive = expression.extra.rawValue;
  2903. delete expression.extra;
  2904. return stmt;
  2905. }
  2906. initFunction(node, isAsync) {
  2907. super.initFunction(node, isAsync);
  2908. node.expression = false;
  2909. }
  2910. checkDeclaration(node) {
  2911. if (node != null && this.isObjectProperty(node)) {
  2912. this.checkDeclaration(node.value);
  2913. } else {
  2914. super.checkDeclaration(node);
  2915. }
  2916. }
  2917. getObjectOrClassMethodParams(method) {
  2918. return method.value.params;
  2919. }
  2920. isValidDirective(stmt) {
  2921. var _stmt$expression$extr;
  2922. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  2923. }
  2924. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  2925. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  2926. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  2927. node.body = directiveStatements.concat(node.body);
  2928. delete node.directives;
  2929. }
  2930. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  2931. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  2932. if (method.typeParameters) {
  2933. method.value.typeParameters = method.typeParameters;
  2934. delete method.typeParameters;
  2935. }
  2936. classBody.body.push(method);
  2937. }
  2938. parsePrivateName() {
  2939. const node = super.parsePrivateName();
  2940. {
  2941. if (!this.getPluginOption("estree", "classFeatures")) {
  2942. return node;
  2943. }
  2944. }
  2945. return this.convertPrivateNameToPrivateIdentifier(node);
  2946. }
  2947. convertPrivateNameToPrivateIdentifier(node) {
  2948. const name = super.getPrivateNameSV(node);
  2949. node = node;
  2950. delete node.id;
  2951. node.name = name;
  2952. node.type = "PrivateIdentifier";
  2953. return node;
  2954. }
  2955. isPrivateName(node) {
  2956. {
  2957. if (!this.getPluginOption("estree", "classFeatures")) {
  2958. return super.isPrivateName(node);
  2959. }
  2960. }
  2961. return node.type === "PrivateIdentifier";
  2962. }
  2963. getPrivateNameSV(node) {
  2964. {
  2965. if (!this.getPluginOption("estree", "classFeatures")) {
  2966. return super.getPrivateNameSV(node);
  2967. }
  2968. }
  2969. return node.name;
  2970. }
  2971. parseLiteral(value, type) {
  2972. const node = super.parseLiteral(value, type);
  2973. node.raw = node.extra.raw;
  2974. delete node.extra;
  2975. return node;
  2976. }
  2977. parseFunctionBody(node, allowExpression, isMethod = false) {
  2978. super.parseFunctionBody(node, allowExpression, isMethod);
  2979. node.expression = node.body.type !== "BlockStatement";
  2980. }
  2981. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  2982. let funcNode = this.startNode();
  2983. funcNode.kind = node.kind;
  2984. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  2985. funcNode.type = "FunctionExpression";
  2986. delete funcNode.kind;
  2987. node.value = funcNode;
  2988. if (type === "ClassPrivateMethod") {
  2989. node.computed = false;
  2990. }
  2991. return this.finishNode(node, "MethodDefinition");
  2992. }
  2993. nameIsConstructor(key) {
  2994. if (key.type === "Literal") return key.value === "constructor";
  2995. return super.nameIsConstructor(key);
  2996. }
  2997. parseClassProperty(...args) {
  2998. const propertyNode = super.parseClassProperty(...args);
  2999. {
  3000. if (!this.getPluginOption("estree", "classFeatures")) {
  3001. return propertyNode;
  3002. }
  3003. }
  3004. propertyNode.type = "PropertyDefinition";
  3005. return propertyNode;
  3006. }
  3007. parseClassPrivateProperty(...args) {
  3008. const propertyNode = super.parseClassPrivateProperty(...args);
  3009. {
  3010. if (!this.getPluginOption("estree", "classFeatures")) {
  3011. return propertyNode;
  3012. }
  3013. }
  3014. propertyNode.type = "PropertyDefinition";
  3015. propertyNode.computed = false;
  3016. return propertyNode;
  3017. }
  3018. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  3019. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  3020. if (node) {
  3021. node.type = "Property";
  3022. if (node.kind === "method") {
  3023. node.kind = "init";
  3024. }
  3025. node.shorthand = false;
  3026. }
  3027. return node;
  3028. }
  3029. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  3030. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  3031. if (node) {
  3032. node.kind = "init";
  3033. node.type = "Property";
  3034. }
  3035. return node;
  3036. }
  3037. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  3038. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  3039. }
  3040. isAssignable(node, isBinding) {
  3041. if (node != null && this.isObjectProperty(node)) {
  3042. return this.isAssignable(node.value, isBinding);
  3043. }
  3044. return super.isAssignable(node, isBinding);
  3045. }
  3046. toAssignable(node, isLHS = false) {
  3047. if (node != null && this.isObjectProperty(node)) {
  3048. const {
  3049. key,
  3050. value
  3051. } = node;
  3052. if (this.isPrivateName(key)) {
  3053. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  3054. }
  3055. this.toAssignable(value, isLHS);
  3056. } else {
  3057. super.toAssignable(node, isLHS);
  3058. }
  3059. }
  3060. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  3061. if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) {
  3062. this.raise(Errors.PatternHasAccessor, prop.key);
  3063. } else if (prop.type === "Property" && prop.method) {
  3064. this.raise(Errors.PatternHasMethod, prop.key);
  3065. } else {
  3066. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  3067. }
  3068. }
  3069. finishCallExpression(unfinished, optional) {
  3070. const node = super.finishCallExpression(unfinished, optional);
  3071. if (node.callee.type === "Import") {
  3072. node.type = "ImportExpression";
  3073. node.source = node.arguments[0];
  3074. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  3075. var _ref, _ref2;
  3076. node.options = (_ref = node.arguments[1]) != null ? _ref : null;
  3077. node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
  3078. }
  3079. delete node.arguments;
  3080. delete node.callee;
  3081. }
  3082. return node;
  3083. }
  3084. toReferencedArguments(node) {
  3085. if (node.type === "ImportExpression") {
  3086. return;
  3087. }
  3088. super.toReferencedArguments(node);
  3089. }
  3090. parseExport(unfinished, decorators) {
  3091. const exportStartLoc = this.state.lastTokStartLoc;
  3092. const node = super.parseExport(unfinished, decorators);
  3093. switch (node.type) {
  3094. case "ExportAllDeclaration":
  3095. node.exported = null;
  3096. break;
  3097. case "ExportNamedDeclaration":
  3098. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3099. node.type = "ExportAllDeclaration";
  3100. node.exported = node.specifiers[0].exported;
  3101. delete node.specifiers;
  3102. }
  3103. case "ExportDefaultDeclaration":
  3104. {
  3105. var _declaration$decorato;
  3106. const {
  3107. declaration
  3108. } = node;
  3109. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3110. this.resetStartLocation(node, exportStartLoc);
  3111. }
  3112. }
  3113. break;
  3114. }
  3115. return node;
  3116. }
  3117. parseSubscript(base, startLoc, noCalls, state) {
  3118. const node = super.parseSubscript(base, startLoc, noCalls, state);
  3119. if (state.optionalChainMember) {
  3120. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  3121. node.type = node.type.substring(8);
  3122. }
  3123. if (state.stop) {
  3124. const chain = this.startNodeAtNode(node);
  3125. chain.expression = node;
  3126. return this.finishNode(chain, "ChainExpression");
  3127. }
  3128. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  3129. node.optional = false;
  3130. }
  3131. return node;
  3132. }
  3133. isOptionalMemberExpression(node) {
  3134. if (node.type === "ChainExpression") {
  3135. return node.expression.type === "MemberExpression";
  3136. }
  3137. return super.isOptionalMemberExpression(node);
  3138. }
  3139. hasPropertyAsPrivateName(node) {
  3140. if (node.type === "ChainExpression") {
  3141. node = node.expression;
  3142. }
  3143. return super.hasPropertyAsPrivateName(node);
  3144. }
  3145. isObjectProperty(node) {
  3146. return node.type === "Property" && node.kind === "init" && !node.method;
  3147. }
  3148. isObjectMethod(node) {
  3149. return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set");
  3150. }
  3151. finishNodeAt(node, type, endLoc) {
  3152. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3153. }
  3154. resetStartLocation(node, startLoc) {
  3155. super.resetStartLocation(node, startLoc);
  3156. toESTreeLocation(node);
  3157. }
  3158. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3159. super.resetEndLocation(node, endLoc);
  3160. toESTreeLocation(node);
  3161. }
  3162. };
  3163. class TokContext {
  3164. constructor(token, preserveSpace) {
  3165. this.token = void 0;
  3166. this.preserveSpace = void 0;
  3167. this.token = token;
  3168. this.preserveSpace = !!preserveSpace;
  3169. }
  3170. }
  3171. const types = {
  3172. brace: new TokContext("{"),
  3173. j_oTag: new TokContext("<tag"),
  3174. j_cTag: new TokContext("</tag"),
  3175. j_expr: new TokContext("<tag>...</tag>", true)
  3176. };
  3177. {
  3178. types.template = new TokContext("`", true);
  3179. }
  3180. const beforeExpr = true;
  3181. const startsExpr = true;
  3182. const isLoop = true;
  3183. const isAssign = true;
  3184. const prefix = true;
  3185. const postfix = true;
  3186. class ExportedTokenType {
  3187. constructor(label, conf = {}) {
  3188. this.label = void 0;
  3189. this.keyword = void 0;
  3190. this.beforeExpr = void 0;
  3191. this.startsExpr = void 0;
  3192. this.rightAssociative = void 0;
  3193. this.isLoop = void 0;
  3194. this.isAssign = void 0;
  3195. this.prefix = void 0;
  3196. this.postfix = void 0;
  3197. this.binop = void 0;
  3198. this.label = label;
  3199. this.keyword = conf.keyword;
  3200. this.beforeExpr = !!conf.beforeExpr;
  3201. this.startsExpr = !!conf.startsExpr;
  3202. this.rightAssociative = !!conf.rightAssociative;
  3203. this.isLoop = !!conf.isLoop;
  3204. this.isAssign = !!conf.isAssign;
  3205. this.prefix = !!conf.prefix;
  3206. this.postfix = !!conf.postfix;
  3207. this.binop = conf.binop != null ? conf.binop : null;
  3208. {
  3209. this.updateContext = null;
  3210. }
  3211. }
  3212. }
  3213. const keywords$1 = new Map();
  3214. function createKeyword(name, options = {}) {
  3215. options.keyword = name;
  3216. const token = createToken(name, options);
  3217. keywords$1.set(name, token);
  3218. return token;
  3219. }
  3220. function createBinop(name, binop) {
  3221. return createToken(name, {
  3222. beforeExpr,
  3223. binop
  3224. });
  3225. }
  3226. let tokenTypeCounter = -1;
  3227. const tokenTypes = [];
  3228. const tokenLabels = [];
  3229. const tokenBinops = [];
  3230. const tokenBeforeExprs = [];
  3231. const tokenStartsExprs = [];
  3232. const tokenPrefixes = [];
  3233. function createToken(name, options = {}) {
  3234. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3235. ++tokenTypeCounter;
  3236. tokenLabels.push(name);
  3237. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3238. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3239. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3240. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3241. tokenTypes.push(new ExportedTokenType(name, options));
  3242. return tokenTypeCounter;
  3243. }
  3244. function createKeywordLike(name, options = {}) {
  3245. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3246. ++tokenTypeCounter;
  3247. keywords$1.set(name, tokenTypeCounter);
  3248. tokenLabels.push(name);
  3249. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3250. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3251. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3252. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3253. tokenTypes.push(new ExportedTokenType("name", options));
  3254. return tokenTypeCounter;
  3255. }
  3256. const tt = {
  3257. bracketL: createToken("[", {
  3258. beforeExpr,
  3259. startsExpr
  3260. }),
  3261. bracketHashL: createToken("#[", {
  3262. beforeExpr,
  3263. startsExpr
  3264. }),
  3265. bracketBarL: createToken("[|", {
  3266. beforeExpr,
  3267. startsExpr
  3268. }),
  3269. bracketR: createToken("]"),
  3270. bracketBarR: createToken("|]"),
  3271. braceL: createToken("{", {
  3272. beforeExpr,
  3273. startsExpr
  3274. }),
  3275. braceBarL: createToken("{|", {
  3276. beforeExpr,
  3277. startsExpr
  3278. }),
  3279. braceHashL: createToken("#{", {
  3280. beforeExpr,
  3281. startsExpr
  3282. }),
  3283. braceR: createToken("}"),
  3284. braceBarR: createToken("|}"),
  3285. parenL: createToken("(", {
  3286. beforeExpr,
  3287. startsExpr
  3288. }),
  3289. parenR: createToken(")"),
  3290. comma: createToken(",", {
  3291. beforeExpr
  3292. }),
  3293. semi: createToken(";", {
  3294. beforeExpr
  3295. }),
  3296. colon: createToken(":", {
  3297. beforeExpr
  3298. }),
  3299. doubleColon: createToken("::", {
  3300. beforeExpr
  3301. }),
  3302. dot: createToken("."),
  3303. question: createToken("?", {
  3304. beforeExpr
  3305. }),
  3306. questionDot: createToken("?."),
  3307. arrow: createToken("=>", {
  3308. beforeExpr
  3309. }),
  3310. template: createToken("template"),
  3311. ellipsis: createToken("...", {
  3312. beforeExpr
  3313. }),
  3314. backQuote: createToken("`", {
  3315. startsExpr
  3316. }),
  3317. dollarBraceL: createToken("${", {
  3318. beforeExpr,
  3319. startsExpr
  3320. }),
  3321. templateTail: createToken("...`", {
  3322. startsExpr
  3323. }),
  3324. templateNonTail: createToken("...${", {
  3325. beforeExpr,
  3326. startsExpr
  3327. }),
  3328. at: createToken("@"),
  3329. hash: createToken("#", {
  3330. startsExpr
  3331. }),
  3332. interpreterDirective: createToken("#!..."),
  3333. eq: createToken("=", {
  3334. beforeExpr,
  3335. isAssign
  3336. }),
  3337. assign: createToken("_=", {
  3338. beforeExpr,
  3339. isAssign
  3340. }),
  3341. slashAssign: createToken("_=", {
  3342. beforeExpr,
  3343. isAssign
  3344. }),
  3345. xorAssign: createToken("_=", {
  3346. beforeExpr,
  3347. isAssign
  3348. }),
  3349. moduloAssign: createToken("_=", {
  3350. beforeExpr,
  3351. isAssign
  3352. }),
  3353. incDec: createToken("++/--", {
  3354. prefix,
  3355. postfix,
  3356. startsExpr
  3357. }),
  3358. bang: createToken("!", {
  3359. beforeExpr,
  3360. prefix,
  3361. startsExpr
  3362. }),
  3363. tilde: createToken("~", {
  3364. beforeExpr,
  3365. prefix,
  3366. startsExpr
  3367. }),
  3368. doubleCaret: createToken("^^", {
  3369. startsExpr
  3370. }),
  3371. doubleAt: createToken("@@", {
  3372. startsExpr
  3373. }),
  3374. pipeline: createBinop("|>", 0),
  3375. nullishCoalescing: createBinop("??", 1),
  3376. logicalOR: createBinop("||", 1),
  3377. logicalAND: createBinop("&&", 2),
  3378. bitwiseOR: createBinop("|", 3),
  3379. bitwiseXOR: createBinop("^", 4),
  3380. bitwiseAND: createBinop("&", 5),
  3381. equality: createBinop("==/!=/===/!==", 6),
  3382. lt: createBinop("</>/<=/>=", 7),
  3383. gt: createBinop("</>/<=/>=", 7),
  3384. relational: createBinop("</>/<=/>=", 7),
  3385. bitShift: createBinop("<</>>/>>>", 8),
  3386. bitShiftL: createBinop("<</>>/>>>", 8),
  3387. bitShiftR: createBinop("<</>>/>>>", 8),
  3388. plusMin: createToken("+/-", {
  3389. beforeExpr,
  3390. binop: 9,
  3391. prefix,
  3392. startsExpr
  3393. }),
  3394. modulo: createToken("%", {
  3395. binop: 10,
  3396. startsExpr
  3397. }),
  3398. star: createToken("*", {
  3399. binop: 10
  3400. }),
  3401. slash: createBinop("/", 10),
  3402. exponent: createToken("**", {
  3403. beforeExpr,
  3404. binop: 11,
  3405. rightAssociative: true
  3406. }),
  3407. _in: createKeyword("in", {
  3408. beforeExpr,
  3409. binop: 7
  3410. }),
  3411. _instanceof: createKeyword("instanceof", {
  3412. beforeExpr,
  3413. binop: 7
  3414. }),
  3415. _break: createKeyword("break"),
  3416. _case: createKeyword("case", {
  3417. beforeExpr
  3418. }),
  3419. _catch: createKeyword("catch"),
  3420. _continue: createKeyword("continue"),
  3421. _debugger: createKeyword("debugger"),
  3422. _default: createKeyword("default", {
  3423. beforeExpr
  3424. }),
  3425. _else: createKeyword("else", {
  3426. beforeExpr
  3427. }),
  3428. _finally: createKeyword("finally"),
  3429. _function: createKeyword("function", {
  3430. startsExpr
  3431. }),
  3432. _if: createKeyword("if"),
  3433. _return: createKeyword("return", {
  3434. beforeExpr
  3435. }),
  3436. _switch: createKeyword("switch"),
  3437. _throw: createKeyword("throw", {
  3438. beforeExpr,
  3439. prefix,
  3440. startsExpr
  3441. }),
  3442. _try: createKeyword("try"),
  3443. _var: createKeyword("var"),
  3444. _const: createKeyword("const"),
  3445. _with: createKeyword("with"),
  3446. _new: createKeyword("new", {
  3447. beforeExpr,
  3448. startsExpr
  3449. }),
  3450. _this: createKeyword("this", {
  3451. startsExpr
  3452. }),
  3453. _super: createKeyword("super", {
  3454. startsExpr
  3455. }),
  3456. _class: createKeyword("class", {
  3457. startsExpr
  3458. }),
  3459. _extends: createKeyword("extends", {
  3460. beforeExpr
  3461. }),
  3462. _export: createKeyword("export"),
  3463. _import: createKeyword("import", {
  3464. startsExpr
  3465. }),
  3466. _null: createKeyword("null", {
  3467. startsExpr
  3468. }),
  3469. _true: createKeyword("true", {
  3470. startsExpr
  3471. }),
  3472. _false: createKeyword("false", {
  3473. startsExpr
  3474. }),
  3475. _typeof: createKeyword("typeof", {
  3476. beforeExpr,
  3477. prefix,
  3478. startsExpr
  3479. }),
  3480. _void: createKeyword("void", {
  3481. beforeExpr,
  3482. prefix,
  3483. startsExpr
  3484. }),
  3485. _delete: createKeyword("delete", {
  3486. beforeExpr,
  3487. prefix,
  3488. startsExpr
  3489. }),
  3490. _do: createKeyword("do", {
  3491. isLoop,
  3492. beforeExpr
  3493. }),
  3494. _for: createKeyword("for", {
  3495. isLoop
  3496. }),
  3497. _while: createKeyword("while", {
  3498. isLoop
  3499. }),
  3500. _as: createKeywordLike("as", {
  3501. startsExpr
  3502. }),
  3503. _assert: createKeywordLike("assert", {
  3504. startsExpr
  3505. }),
  3506. _async: createKeywordLike("async", {
  3507. startsExpr
  3508. }),
  3509. _await: createKeywordLike("await", {
  3510. startsExpr
  3511. }),
  3512. _defer: createKeywordLike("defer", {
  3513. startsExpr
  3514. }),
  3515. _from: createKeywordLike("from", {
  3516. startsExpr
  3517. }),
  3518. _get: createKeywordLike("get", {
  3519. startsExpr
  3520. }),
  3521. _let: createKeywordLike("let", {
  3522. startsExpr
  3523. }),
  3524. _meta: createKeywordLike("meta", {
  3525. startsExpr
  3526. }),
  3527. _of: createKeywordLike("of", {
  3528. startsExpr
  3529. }),
  3530. _sent: createKeywordLike("sent", {
  3531. startsExpr
  3532. }),
  3533. _set: createKeywordLike("set", {
  3534. startsExpr
  3535. }),
  3536. _source: createKeywordLike("source", {
  3537. startsExpr
  3538. }),
  3539. _static: createKeywordLike("static", {
  3540. startsExpr
  3541. }),
  3542. _using: createKeywordLike("using", {
  3543. startsExpr
  3544. }),
  3545. _yield: createKeywordLike("yield", {
  3546. startsExpr
  3547. }),
  3548. _asserts: createKeywordLike("asserts", {
  3549. startsExpr
  3550. }),
  3551. _checks: createKeywordLike("checks", {
  3552. startsExpr
  3553. }),
  3554. _exports: createKeywordLike("exports", {
  3555. startsExpr
  3556. }),
  3557. _global: createKeywordLike("global", {
  3558. startsExpr
  3559. }),
  3560. _implements: createKeywordLike("implements", {
  3561. startsExpr
  3562. }),
  3563. _intrinsic: createKeywordLike("intrinsic", {
  3564. startsExpr
  3565. }),
  3566. _infer: createKeywordLike("infer", {
  3567. startsExpr
  3568. }),
  3569. _is: createKeywordLike("is", {
  3570. startsExpr
  3571. }),
  3572. _mixins: createKeywordLike("mixins", {
  3573. startsExpr
  3574. }),
  3575. _proto: createKeywordLike("proto", {
  3576. startsExpr
  3577. }),
  3578. _require: createKeywordLike("require", {
  3579. startsExpr
  3580. }),
  3581. _satisfies: createKeywordLike("satisfies", {
  3582. startsExpr
  3583. }),
  3584. _keyof: createKeywordLike("keyof", {
  3585. startsExpr
  3586. }),
  3587. _readonly: createKeywordLike("readonly", {
  3588. startsExpr
  3589. }),
  3590. _unique: createKeywordLike("unique", {
  3591. startsExpr
  3592. }),
  3593. _abstract: createKeywordLike("abstract", {
  3594. startsExpr
  3595. }),
  3596. _declare: createKeywordLike("declare", {
  3597. startsExpr
  3598. }),
  3599. _enum: createKeywordLike("enum", {
  3600. startsExpr
  3601. }),
  3602. _module: createKeywordLike("module", {
  3603. startsExpr
  3604. }),
  3605. _namespace: createKeywordLike("namespace", {
  3606. startsExpr
  3607. }),
  3608. _interface: createKeywordLike("interface", {
  3609. startsExpr
  3610. }),
  3611. _type: createKeywordLike("type", {
  3612. startsExpr
  3613. }),
  3614. _opaque: createKeywordLike("opaque", {
  3615. startsExpr
  3616. }),
  3617. name: createToken("name", {
  3618. startsExpr
  3619. }),
  3620. string: createToken("string", {
  3621. startsExpr
  3622. }),
  3623. num: createToken("num", {
  3624. startsExpr
  3625. }),
  3626. bigint: createToken("bigint", {
  3627. startsExpr
  3628. }),
  3629. decimal: createToken("decimal", {
  3630. startsExpr
  3631. }),
  3632. regexp: createToken("regexp", {
  3633. startsExpr
  3634. }),
  3635. privateName: createToken("#name", {
  3636. startsExpr
  3637. }),
  3638. eof: createToken("eof"),
  3639. jsxName: createToken("jsxName"),
  3640. jsxText: createToken("jsxText", {
  3641. beforeExpr: true
  3642. }),
  3643. jsxTagStart: createToken("jsxTagStart", {
  3644. startsExpr: true
  3645. }),
  3646. jsxTagEnd: createToken("jsxTagEnd"),
  3647. placeholder: createToken("%%", {
  3648. startsExpr: true
  3649. })
  3650. };
  3651. function tokenIsIdentifier(token) {
  3652. return token >= 93 && token <= 132;
  3653. }
  3654. function tokenKeywordOrIdentifierIsKeyword(token) {
  3655. return token <= 92;
  3656. }
  3657. function tokenIsKeywordOrIdentifier(token) {
  3658. return token >= 58 && token <= 132;
  3659. }
  3660. function tokenIsLiteralPropertyName(token) {
  3661. return token >= 58 && token <= 136;
  3662. }
  3663. function tokenComesBeforeExpression(token) {
  3664. return tokenBeforeExprs[token];
  3665. }
  3666. function tokenCanStartExpression(token) {
  3667. return tokenStartsExprs[token];
  3668. }
  3669. function tokenIsAssignment(token) {
  3670. return token >= 29 && token <= 33;
  3671. }
  3672. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3673. return token >= 129 && token <= 131;
  3674. }
  3675. function tokenIsLoop(token) {
  3676. return token >= 90 && token <= 92;
  3677. }
  3678. function tokenIsKeyword(token) {
  3679. return token >= 58 && token <= 92;
  3680. }
  3681. function tokenIsOperator(token) {
  3682. return token >= 39 && token <= 59;
  3683. }
  3684. function tokenIsPostfix(token) {
  3685. return token === 34;
  3686. }
  3687. function tokenIsPrefix(token) {
  3688. return tokenPrefixes[token];
  3689. }
  3690. function tokenIsTSTypeOperator(token) {
  3691. return token >= 121 && token <= 123;
  3692. }
  3693. function tokenIsTSDeclarationStart(token) {
  3694. return token >= 124 && token <= 130;
  3695. }
  3696. function tokenLabelName(token) {
  3697. return tokenLabels[token];
  3698. }
  3699. function tokenOperatorPrecedence(token) {
  3700. return tokenBinops[token];
  3701. }
  3702. function tokenIsRightAssociative(token) {
  3703. return token === 57;
  3704. }
  3705. function tokenIsTemplate(token) {
  3706. return token >= 24 && token <= 25;
  3707. }
  3708. function getExportedToken(token) {
  3709. return tokenTypes[token];
  3710. }
  3711. {
  3712. tokenTypes[8].updateContext = context => {
  3713. context.pop();
  3714. };
  3715. tokenTypes[5].updateContext = tokenTypes[7].updateContext = tokenTypes[23].updateContext = context => {
  3716. context.push(types.brace);
  3717. };
  3718. tokenTypes[22].updateContext = context => {
  3719. if (context[context.length - 1] === types.template) {
  3720. context.pop();
  3721. } else {
  3722. context.push(types.template);
  3723. }
  3724. };
  3725. tokenTypes[142].updateContext = context => {
  3726. context.push(types.j_expr, types.j_oTag);
  3727. };
  3728. }
  3729. 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";
  3730. 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";
  3731. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3732. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3733. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3734. 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];
  3735. 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];
  3736. function isInAstralSet(code, set) {
  3737. let pos = 0x10000;
  3738. for (let i = 0, length = set.length; i < length; i += 2) {
  3739. pos += set[i];
  3740. if (pos > code) return false;
  3741. pos += set[i + 1];
  3742. if (pos >= code) return true;
  3743. }
  3744. return false;
  3745. }
  3746. function isIdentifierStart(code) {
  3747. if (code < 65) return code === 36;
  3748. if (code <= 90) return true;
  3749. if (code < 97) return code === 95;
  3750. if (code <= 122) return true;
  3751. if (code <= 0xffff) {
  3752. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3753. }
  3754. return isInAstralSet(code, astralIdentifierStartCodes);
  3755. }
  3756. function isIdentifierChar(code) {
  3757. if (code < 48) return code === 36;
  3758. if (code < 58) return true;
  3759. if (code < 65) return false;
  3760. if (code <= 90) return true;
  3761. if (code < 97) return code === 95;
  3762. if (code <= 122) return true;
  3763. if (code <= 0xffff) {
  3764. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3765. }
  3766. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3767. }
  3768. const reservedWords = {
  3769. 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"],
  3770. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3771. strictBind: ["eval", "arguments"]
  3772. };
  3773. const keywords = new Set(reservedWords.keyword);
  3774. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3775. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3776. function isReservedWord(word, inModule) {
  3777. return inModule && word === "await" || word === "enum";
  3778. }
  3779. function isStrictReservedWord(word, inModule) {
  3780. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3781. }
  3782. function isStrictBindOnlyReservedWord(word) {
  3783. return reservedWordsStrictBindSet.has(word);
  3784. }
  3785. function isStrictBindReservedWord(word, inModule) {
  3786. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3787. }
  3788. function isKeyword(word) {
  3789. return keywords.has(word);
  3790. }
  3791. function isIteratorStart(current, next, next2) {
  3792. return current === 64 && next === 64 && isIdentifierStart(next2);
  3793. }
  3794. 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"]);
  3795. function canBeReservedWord(word) {
  3796. return reservedWordLikeSet.has(word);
  3797. }
  3798. class Scope {
  3799. constructor(flags) {
  3800. this.flags = 0;
  3801. this.names = new Map();
  3802. this.firstLexicalName = "";
  3803. this.flags = flags;
  3804. }
  3805. }
  3806. class ScopeHandler {
  3807. constructor(parser, inModule) {
  3808. this.parser = void 0;
  3809. this.scopeStack = [];
  3810. this.inModule = void 0;
  3811. this.undefinedExports = new Map();
  3812. this.parser = parser;
  3813. this.inModule = inModule;
  3814. }
  3815. get inTopLevel() {
  3816. return (this.currentScope().flags & 1) > 0;
  3817. }
  3818. get inFunction() {
  3819. return (this.currentVarScopeFlags() & 2) > 0;
  3820. }
  3821. get allowSuper() {
  3822. return (this.currentThisScopeFlags() & 16) > 0;
  3823. }
  3824. get allowDirectSuper() {
  3825. return (this.currentThisScopeFlags() & 32) > 0;
  3826. }
  3827. get inClass() {
  3828. return (this.currentThisScopeFlags() & 64) > 0;
  3829. }
  3830. get inClassAndNotInNonArrowFunction() {
  3831. const flags = this.currentThisScopeFlags();
  3832. return (flags & 64) > 0 && (flags & 2) === 0;
  3833. }
  3834. get inStaticBlock() {
  3835. for (let i = this.scopeStack.length - 1;; i--) {
  3836. const {
  3837. flags
  3838. } = this.scopeStack[i];
  3839. if (flags & 128) {
  3840. return true;
  3841. }
  3842. if (flags & (387 | 64)) {
  3843. return false;
  3844. }
  3845. }
  3846. }
  3847. get inNonArrowFunction() {
  3848. return (this.currentThisScopeFlags() & 2) > 0;
  3849. }
  3850. get treatFunctionsAsVar() {
  3851. return this.treatFunctionsAsVarInScope(this.currentScope());
  3852. }
  3853. createScope(flags) {
  3854. return new Scope(flags);
  3855. }
  3856. enter(flags) {
  3857. this.scopeStack.push(this.createScope(flags));
  3858. }
  3859. exit() {
  3860. const scope = this.scopeStack.pop();
  3861. return scope.flags;
  3862. }
  3863. treatFunctionsAsVarInScope(scope) {
  3864. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  3865. }
  3866. declareName(name, bindingType, loc) {
  3867. let scope = this.currentScope();
  3868. if (bindingType & 8 || bindingType & 16) {
  3869. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3870. let type = scope.names.get(name) || 0;
  3871. if (bindingType & 16) {
  3872. type = type | 4;
  3873. } else {
  3874. if (!scope.firstLexicalName) {
  3875. scope.firstLexicalName = name;
  3876. }
  3877. type = type | 2;
  3878. }
  3879. scope.names.set(name, type);
  3880. if (bindingType & 8) {
  3881. this.maybeExportDefined(scope, name);
  3882. }
  3883. } else if (bindingType & 4) {
  3884. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  3885. scope = this.scopeStack[i];
  3886. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3887. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  3888. this.maybeExportDefined(scope, name);
  3889. if (scope.flags & 387) break;
  3890. }
  3891. }
  3892. if (this.parser.inModule && scope.flags & 1) {
  3893. this.undefinedExports.delete(name);
  3894. }
  3895. }
  3896. maybeExportDefined(scope, name) {
  3897. if (this.parser.inModule && scope.flags & 1) {
  3898. this.undefinedExports.delete(name);
  3899. }
  3900. }
  3901. checkRedeclarationInScope(scope, name, bindingType, loc) {
  3902. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  3903. this.parser.raise(Errors.VarRedeclaration, loc, {
  3904. identifierName: name
  3905. });
  3906. }
  3907. }
  3908. isRedeclaredInScope(scope, name, bindingType) {
  3909. if (!(bindingType & 1)) return false;
  3910. if (bindingType & 8) {
  3911. return scope.names.has(name);
  3912. }
  3913. const type = scope.names.get(name);
  3914. if (bindingType & 16) {
  3915. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  3916. }
  3917. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  3918. }
  3919. checkLocalExport(id) {
  3920. const {
  3921. name
  3922. } = id;
  3923. const topLevelScope = this.scopeStack[0];
  3924. if (!topLevelScope.names.has(name)) {
  3925. this.undefinedExports.set(name, id.loc.start);
  3926. }
  3927. }
  3928. currentScope() {
  3929. return this.scopeStack[this.scopeStack.length - 1];
  3930. }
  3931. currentVarScopeFlags() {
  3932. for (let i = this.scopeStack.length - 1;; i--) {
  3933. const {
  3934. flags
  3935. } = this.scopeStack[i];
  3936. if (flags & 387) {
  3937. return flags;
  3938. }
  3939. }
  3940. }
  3941. currentThisScopeFlags() {
  3942. for (let i = this.scopeStack.length - 1;; i--) {
  3943. const {
  3944. flags
  3945. } = this.scopeStack[i];
  3946. if (flags & (387 | 64) && !(flags & 4)) {
  3947. return flags;
  3948. }
  3949. }
  3950. }
  3951. }
  3952. class FlowScope extends Scope {
  3953. constructor(...args) {
  3954. super(...args);
  3955. this.declareFunctions = new Set();
  3956. }
  3957. }
  3958. class FlowScopeHandler extends ScopeHandler {
  3959. createScope(flags) {
  3960. return new FlowScope(flags);
  3961. }
  3962. declareName(name, bindingType, loc) {
  3963. const scope = this.currentScope();
  3964. if (bindingType & 2048) {
  3965. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3966. this.maybeExportDefined(scope, name);
  3967. scope.declareFunctions.add(name);
  3968. return;
  3969. }
  3970. super.declareName(name, bindingType, loc);
  3971. }
  3972. isRedeclaredInScope(scope, name, bindingType) {
  3973. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  3974. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  3975. const type = scope.names.get(name);
  3976. return (type & 4) > 0 || (type & 2) > 0;
  3977. }
  3978. return false;
  3979. }
  3980. checkLocalExport(id) {
  3981. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  3982. super.checkLocalExport(id);
  3983. }
  3984. }
  3985. }
  3986. class BaseParser {
  3987. constructor() {
  3988. this.sawUnambiguousESM = false;
  3989. this.ambiguousScriptDifferentAst = false;
  3990. }
  3991. hasPlugin(pluginConfig) {
  3992. if (typeof pluginConfig === "string") {
  3993. return this.plugins.has(pluginConfig);
  3994. } else {
  3995. const [pluginName, pluginOptions] = pluginConfig;
  3996. if (!this.hasPlugin(pluginName)) {
  3997. return false;
  3998. }
  3999. const actualOptions = this.plugins.get(pluginName);
  4000. for (const key of Object.keys(pluginOptions)) {
  4001. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  4002. return false;
  4003. }
  4004. }
  4005. return true;
  4006. }
  4007. }
  4008. getPluginOption(plugin, name) {
  4009. var _this$plugins$get;
  4010. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  4011. }
  4012. }
  4013. function setTrailingComments(node, comments) {
  4014. if (node.trailingComments === undefined) {
  4015. node.trailingComments = comments;
  4016. } else {
  4017. node.trailingComments.unshift(...comments);
  4018. }
  4019. }
  4020. function setLeadingComments(node, comments) {
  4021. if (node.leadingComments === undefined) {
  4022. node.leadingComments = comments;
  4023. } else {
  4024. node.leadingComments.unshift(...comments);
  4025. }
  4026. }
  4027. function setInnerComments(node, comments) {
  4028. if (node.innerComments === undefined) {
  4029. node.innerComments = comments;
  4030. } else {
  4031. node.innerComments.unshift(...comments);
  4032. }
  4033. }
  4034. function adjustInnerComments(node, elements, commentWS) {
  4035. let lastElement = null;
  4036. let i = elements.length;
  4037. while (lastElement === null && i > 0) {
  4038. lastElement = elements[--i];
  4039. }
  4040. if (lastElement === null || lastElement.start > commentWS.start) {
  4041. setInnerComments(node, commentWS.comments);
  4042. } else {
  4043. setTrailingComments(lastElement, commentWS.comments);
  4044. }
  4045. }
  4046. class CommentsParser extends BaseParser {
  4047. addComment(comment) {
  4048. if (this.filename) comment.loc.filename = this.filename;
  4049. const {
  4050. commentsLen
  4051. } = this.state;
  4052. if (this.comments.length !== commentsLen) {
  4053. this.comments.length = commentsLen;
  4054. }
  4055. this.comments.push(comment);
  4056. this.state.commentsLen++;
  4057. }
  4058. processComment(node) {
  4059. const {
  4060. commentStack
  4061. } = this.state;
  4062. const commentStackLength = commentStack.length;
  4063. if (commentStackLength === 0) return;
  4064. let i = commentStackLength - 1;
  4065. const lastCommentWS = commentStack[i];
  4066. if (lastCommentWS.start === node.end) {
  4067. lastCommentWS.leadingNode = node;
  4068. i--;
  4069. }
  4070. const {
  4071. start: nodeStart
  4072. } = node;
  4073. for (; i >= 0; i--) {
  4074. const commentWS = commentStack[i];
  4075. const commentEnd = commentWS.end;
  4076. if (commentEnd > nodeStart) {
  4077. commentWS.containingNode = node;
  4078. this.finalizeComment(commentWS);
  4079. commentStack.splice(i, 1);
  4080. } else {
  4081. if (commentEnd === nodeStart) {
  4082. commentWS.trailingNode = node;
  4083. }
  4084. break;
  4085. }
  4086. }
  4087. }
  4088. finalizeComment(commentWS) {
  4089. const {
  4090. comments
  4091. } = commentWS;
  4092. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  4093. if (commentWS.leadingNode !== null) {
  4094. setTrailingComments(commentWS.leadingNode, comments);
  4095. }
  4096. if (commentWS.trailingNode !== null) {
  4097. setLeadingComments(commentWS.trailingNode, comments);
  4098. }
  4099. } else {
  4100. const {
  4101. containingNode: node,
  4102. start: commentStart
  4103. } = commentWS;
  4104. if (this.input.charCodeAt(commentStart - 1) === 44) {
  4105. switch (node.type) {
  4106. case "ObjectExpression":
  4107. case "ObjectPattern":
  4108. case "RecordExpression":
  4109. adjustInnerComments(node, node.properties, commentWS);
  4110. break;
  4111. case "CallExpression":
  4112. case "OptionalCallExpression":
  4113. adjustInnerComments(node, node.arguments, commentWS);
  4114. break;
  4115. case "FunctionDeclaration":
  4116. case "FunctionExpression":
  4117. case "ArrowFunctionExpression":
  4118. case "ObjectMethod":
  4119. case "ClassMethod":
  4120. case "ClassPrivateMethod":
  4121. adjustInnerComments(node, node.params, commentWS);
  4122. break;
  4123. case "ArrayExpression":
  4124. case "ArrayPattern":
  4125. case "TupleExpression":
  4126. adjustInnerComments(node, node.elements, commentWS);
  4127. break;
  4128. case "ExportNamedDeclaration":
  4129. case "ImportDeclaration":
  4130. adjustInnerComments(node, node.specifiers, commentWS);
  4131. break;
  4132. default:
  4133. {
  4134. setInnerComments(node, comments);
  4135. }
  4136. }
  4137. } else {
  4138. setInnerComments(node, comments);
  4139. }
  4140. }
  4141. }
  4142. finalizeRemainingComments() {
  4143. const {
  4144. commentStack
  4145. } = this.state;
  4146. for (let i = commentStack.length - 1; i >= 0; i--) {
  4147. this.finalizeComment(commentStack[i]);
  4148. }
  4149. this.state.commentStack = [];
  4150. }
  4151. resetPreviousNodeTrailingComments(node) {
  4152. const {
  4153. commentStack
  4154. } = this.state;
  4155. const {
  4156. length
  4157. } = commentStack;
  4158. if (length === 0) return;
  4159. const commentWS = commentStack[length - 1];
  4160. if (commentWS.leadingNode === node) {
  4161. commentWS.leadingNode = null;
  4162. }
  4163. }
  4164. resetPreviousIdentifierLeadingComments(node) {
  4165. const {
  4166. commentStack
  4167. } = this.state;
  4168. const {
  4169. length
  4170. } = commentStack;
  4171. if (length === 0) return;
  4172. if (commentStack[length - 1].trailingNode === node) {
  4173. commentStack[length - 1].trailingNode = null;
  4174. } else if (length >= 2 && commentStack[length - 2].trailingNode === node) {
  4175. commentStack[length - 2].trailingNode = null;
  4176. }
  4177. }
  4178. takeSurroundingComments(node, start, end) {
  4179. const {
  4180. commentStack
  4181. } = this.state;
  4182. const commentStackLength = commentStack.length;
  4183. if (commentStackLength === 0) return;
  4184. let i = commentStackLength - 1;
  4185. for (; i >= 0; i--) {
  4186. const commentWS = commentStack[i];
  4187. const commentEnd = commentWS.end;
  4188. const commentStart = commentWS.start;
  4189. if (commentStart === end) {
  4190. commentWS.leadingNode = node;
  4191. } else if (commentEnd === start) {
  4192. commentWS.trailingNode = node;
  4193. } else if (commentEnd < start) {
  4194. break;
  4195. }
  4196. }
  4197. }
  4198. }
  4199. const lineBreak = /\r\n|[\r\n\u2028\u2029]/;
  4200. const lineBreakG = new RegExp(lineBreak.source, "g");
  4201. function isNewLine(code) {
  4202. switch (code) {
  4203. case 10:
  4204. case 13:
  4205. case 8232:
  4206. case 8233:
  4207. return true;
  4208. default:
  4209. return false;
  4210. }
  4211. }
  4212. function hasNewLine(input, start, end) {
  4213. for (let i = start; i < end; i++) {
  4214. if (isNewLine(input.charCodeAt(i))) {
  4215. return true;
  4216. }
  4217. }
  4218. return false;
  4219. }
  4220. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  4221. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  4222. function isWhitespace(code) {
  4223. switch (code) {
  4224. case 0x0009:
  4225. case 0x000b:
  4226. case 0x000c:
  4227. case 32:
  4228. case 160:
  4229. case 5760:
  4230. case 0x2000:
  4231. case 0x2001:
  4232. case 0x2002:
  4233. case 0x2003:
  4234. case 0x2004:
  4235. case 0x2005:
  4236. case 0x2006:
  4237. case 0x2007:
  4238. case 0x2008:
  4239. case 0x2009:
  4240. case 0x200a:
  4241. case 0x202f:
  4242. case 0x205f:
  4243. case 0x3000:
  4244. case 0xfeff:
  4245. return true;
  4246. default:
  4247. return false;
  4248. }
  4249. }
  4250. class State {
  4251. constructor() {
  4252. this.flags = 1024;
  4253. this.curLine = void 0;
  4254. this.lineStart = void 0;
  4255. this.startLoc = void 0;
  4256. this.endLoc = void 0;
  4257. this.errors = [];
  4258. this.potentialArrowAt = -1;
  4259. this.noArrowAt = [];
  4260. this.noArrowParamsConversionAt = [];
  4261. this.topicContext = {
  4262. maxNumOfResolvableTopics: 0,
  4263. maxTopicIndex: null
  4264. };
  4265. this.labels = [];
  4266. this.commentsLen = 0;
  4267. this.commentStack = [];
  4268. this.pos = 0;
  4269. this.type = 139;
  4270. this.value = null;
  4271. this.start = 0;
  4272. this.end = 0;
  4273. this.lastTokEndLoc = null;
  4274. this.lastTokStartLoc = null;
  4275. this.context = [types.brace];
  4276. this.firstInvalidTemplateEscapePos = null;
  4277. this.strictErrors = new Map();
  4278. this.tokensLength = 0;
  4279. }
  4280. get strict() {
  4281. return (this.flags & 1) > 0;
  4282. }
  4283. set strict(v) {
  4284. if (v) this.flags |= 1;else this.flags &= -2;
  4285. }
  4286. init({
  4287. strictMode,
  4288. sourceType,
  4289. startLine,
  4290. startColumn
  4291. }) {
  4292. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  4293. this.curLine = startLine;
  4294. this.lineStart = -startColumn;
  4295. this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
  4296. }
  4297. get maybeInArrowParameters() {
  4298. return (this.flags & 2) > 0;
  4299. }
  4300. set maybeInArrowParameters(v) {
  4301. if (v) this.flags |= 2;else this.flags &= -3;
  4302. }
  4303. get inType() {
  4304. return (this.flags & 4) > 0;
  4305. }
  4306. set inType(v) {
  4307. if (v) this.flags |= 4;else this.flags &= -5;
  4308. }
  4309. get noAnonFunctionType() {
  4310. return (this.flags & 8) > 0;
  4311. }
  4312. set noAnonFunctionType(v) {
  4313. if (v) this.flags |= 8;else this.flags &= -9;
  4314. }
  4315. get hasFlowComment() {
  4316. return (this.flags & 16) > 0;
  4317. }
  4318. set hasFlowComment(v) {
  4319. if (v) this.flags |= 16;else this.flags &= -17;
  4320. }
  4321. get isAmbientContext() {
  4322. return (this.flags & 32) > 0;
  4323. }
  4324. set isAmbientContext(v) {
  4325. if (v) this.flags |= 32;else this.flags &= -33;
  4326. }
  4327. get inAbstractClass() {
  4328. return (this.flags & 64) > 0;
  4329. }
  4330. set inAbstractClass(v) {
  4331. if (v) this.flags |= 64;else this.flags &= -65;
  4332. }
  4333. get inDisallowConditionalTypesContext() {
  4334. return (this.flags & 128) > 0;
  4335. }
  4336. set inDisallowConditionalTypesContext(v) {
  4337. if (v) this.flags |= 128;else this.flags &= -129;
  4338. }
  4339. get soloAwait() {
  4340. return (this.flags & 256) > 0;
  4341. }
  4342. set soloAwait(v) {
  4343. if (v) this.flags |= 256;else this.flags &= -257;
  4344. }
  4345. get inFSharpPipelineDirectBody() {
  4346. return (this.flags & 512) > 0;
  4347. }
  4348. set inFSharpPipelineDirectBody(v) {
  4349. if (v) this.flags |= 512;else this.flags &= -513;
  4350. }
  4351. get canStartJSXElement() {
  4352. return (this.flags & 1024) > 0;
  4353. }
  4354. set canStartJSXElement(v) {
  4355. if (v) this.flags |= 1024;else this.flags &= -1025;
  4356. }
  4357. get containsEsc() {
  4358. return (this.flags & 2048) > 0;
  4359. }
  4360. set containsEsc(v) {
  4361. if (v) this.flags |= 2048;else this.flags &= -2049;
  4362. }
  4363. get hasTopLevelAwait() {
  4364. return (this.flags & 4096) > 0;
  4365. }
  4366. set hasTopLevelAwait(v) {
  4367. if (v) this.flags |= 4096;else this.flags &= -4097;
  4368. }
  4369. curPosition() {
  4370. return new Position(this.curLine, this.pos - this.lineStart, this.pos);
  4371. }
  4372. clone() {
  4373. const state = new State();
  4374. state.flags = this.flags;
  4375. state.curLine = this.curLine;
  4376. state.lineStart = this.lineStart;
  4377. state.startLoc = this.startLoc;
  4378. state.endLoc = this.endLoc;
  4379. state.errors = this.errors.slice();
  4380. state.potentialArrowAt = this.potentialArrowAt;
  4381. state.noArrowAt = this.noArrowAt.slice();
  4382. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  4383. state.topicContext = this.topicContext;
  4384. state.labels = this.labels.slice();
  4385. state.commentsLen = this.commentsLen;
  4386. state.commentStack = this.commentStack.slice();
  4387. state.pos = this.pos;
  4388. state.type = this.type;
  4389. state.value = this.value;
  4390. state.start = this.start;
  4391. state.end = this.end;
  4392. state.lastTokEndLoc = this.lastTokEndLoc;
  4393. state.lastTokStartLoc = this.lastTokStartLoc;
  4394. state.context = this.context.slice();
  4395. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  4396. state.strictErrors = this.strictErrors;
  4397. state.tokensLength = this.tokensLength;
  4398. return state;
  4399. }
  4400. }
  4401. var _isDigit = function isDigit(code) {
  4402. return code >= 48 && code <= 57;
  4403. };
  4404. const forbiddenNumericSeparatorSiblings = {
  4405. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  4406. hex: new Set([46, 88, 95, 120])
  4407. };
  4408. const isAllowedNumericSeparatorSibling = {
  4409. bin: ch => ch === 48 || ch === 49,
  4410. oct: ch => ch >= 48 && ch <= 55,
  4411. dec: ch => ch >= 48 && ch <= 57,
  4412. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  4413. };
  4414. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  4415. const initialPos = pos;
  4416. const initialLineStart = lineStart;
  4417. const initialCurLine = curLine;
  4418. let out = "";
  4419. let firstInvalidLoc = null;
  4420. let chunkStart = pos;
  4421. const {
  4422. length
  4423. } = input;
  4424. for (;;) {
  4425. if (pos >= length) {
  4426. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4427. out += input.slice(chunkStart, pos);
  4428. break;
  4429. }
  4430. const ch = input.charCodeAt(pos);
  4431. if (isStringEnd(type, ch, input, pos)) {
  4432. out += input.slice(chunkStart, pos);
  4433. break;
  4434. }
  4435. if (ch === 92) {
  4436. out += input.slice(chunkStart, pos);
  4437. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  4438. if (res.ch === null && !firstInvalidLoc) {
  4439. firstInvalidLoc = {
  4440. pos,
  4441. lineStart,
  4442. curLine
  4443. };
  4444. } else {
  4445. out += res.ch;
  4446. }
  4447. ({
  4448. pos,
  4449. lineStart,
  4450. curLine
  4451. } = res);
  4452. chunkStart = pos;
  4453. } else if (ch === 8232 || ch === 8233) {
  4454. ++pos;
  4455. ++curLine;
  4456. lineStart = pos;
  4457. } else if (ch === 10 || ch === 13) {
  4458. if (type === "template") {
  4459. out += input.slice(chunkStart, pos) + "\n";
  4460. ++pos;
  4461. if (ch === 13 && input.charCodeAt(pos) === 10) {
  4462. ++pos;
  4463. }
  4464. ++curLine;
  4465. chunkStart = lineStart = pos;
  4466. } else {
  4467. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4468. }
  4469. } else {
  4470. ++pos;
  4471. }
  4472. }
  4473. return {
  4474. pos,
  4475. str: out,
  4476. firstInvalidLoc,
  4477. lineStart,
  4478. curLine,
  4479. containsInvalid: !!firstInvalidLoc
  4480. };
  4481. }
  4482. function isStringEnd(type, ch, input, pos) {
  4483. if (type === "template") {
  4484. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  4485. }
  4486. return ch === (type === "double" ? 34 : 39);
  4487. }
  4488. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  4489. const throwOnInvalid = !inTemplate;
  4490. pos++;
  4491. const res = ch => ({
  4492. pos,
  4493. ch,
  4494. lineStart,
  4495. curLine
  4496. });
  4497. const ch = input.charCodeAt(pos++);
  4498. switch (ch) {
  4499. case 110:
  4500. return res("\n");
  4501. case 114:
  4502. return res("\r");
  4503. case 120:
  4504. {
  4505. let code;
  4506. ({
  4507. code,
  4508. pos
  4509. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  4510. return res(code === null ? null : String.fromCharCode(code));
  4511. }
  4512. case 117:
  4513. {
  4514. let code;
  4515. ({
  4516. code,
  4517. pos
  4518. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  4519. return res(code === null ? null : String.fromCodePoint(code));
  4520. }
  4521. case 116:
  4522. return res("\t");
  4523. case 98:
  4524. return res("\b");
  4525. case 118:
  4526. return res("\u000b");
  4527. case 102:
  4528. return res("\f");
  4529. case 13:
  4530. if (input.charCodeAt(pos) === 10) {
  4531. ++pos;
  4532. }
  4533. case 10:
  4534. lineStart = pos;
  4535. ++curLine;
  4536. case 8232:
  4537. case 8233:
  4538. return res("");
  4539. case 56:
  4540. case 57:
  4541. if (inTemplate) {
  4542. return res(null);
  4543. } else {
  4544. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  4545. }
  4546. default:
  4547. if (ch >= 48 && ch <= 55) {
  4548. const startPos = pos - 1;
  4549. const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2));
  4550. let octalStr = match[0];
  4551. let octal = parseInt(octalStr, 8);
  4552. if (octal > 255) {
  4553. octalStr = octalStr.slice(0, -1);
  4554. octal = parseInt(octalStr, 8);
  4555. }
  4556. pos += octalStr.length - 1;
  4557. const next = input.charCodeAt(pos);
  4558. if (octalStr !== "0" || next === 56 || next === 57) {
  4559. if (inTemplate) {
  4560. return res(null);
  4561. } else {
  4562. errors.strictNumericEscape(startPos, lineStart, curLine);
  4563. }
  4564. }
  4565. return res(String.fromCharCode(octal));
  4566. }
  4567. return res(String.fromCharCode(ch));
  4568. }
  4569. }
  4570. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  4571. const initialPos = pos;
  4572. let n;
  4573. ({
  4574. n,
  4575. pos
  4576. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  4577. if (n === null) {
  4578. if (throwOnInvalid) {
  4579. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  4580. } else {
  4581. pos = initialPos - 1;
  4582. }
  4583. }
  4584. return {
  4585. code: n,
  4586. pos
  4587. };
  4588. }
  4589. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  4590. const start = pos;
  4591. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  4592. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  4593. let invalid = false;
  4594. let total = 0;
  4595. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  4596. const code = input.charCodeAt(pos);
  4597. let val;
  4598. if (code === 95 && allowNumSeparator !== "bail") {
  4599. const prev = input.charCodeAt(pos - 1);
  4600. const next = input.charCodeAt(pos + 1);
  4601. if (!allowNumSeparator) {
  4602. if (bailOnError) return {
  4603. n: null,
  4604. pos
  4605. };
  4606. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  4607. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  4608. if (bailOnError) return {
  4609. n: null,
  4610. pos
  4611. };
  4612. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  4613. }
  4614. ++pos;
  4615. continue;
  4616. }
  4617. if (code >= 97) {
  4618. val = code - 97 + 10;
  4619. } else if (code >= 65) {
  4620. val = code - 65 + 10;
  4621. } else if (_isDigit(code)) {
  4622. val = code - 48;
  4623. } else {
  4624. val = Infinity;
  4625. }
  4626. if (val >= radix) {
  4627. if (val <= 9 && bailOnError) {
  4628. return {
  4629. n: null,
  4630. pos
  4631. };
  4632. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  4633. val = 0;
  4634. } else if (forceLen) {
  4635. val = 0;
  4636. invalid = true;
  4637. } else {
  4638. break;
  4639. }
  4640. }
  4641. ++pos;
  4642. total = total * radix + val;
  4643. }
  4644. if (pos === start || len != null && pos - start !== len || invalid) {
  4645. return {
  4646. n: null,
  4647. pos
  4648. };
  4649. }
  4650. return {
  4651. n: total,
  4652. pos
  4653. };
  4654. }
  4655. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  4656. const ch = input.charCodeAt(pos);
  4657. let code;
  4658. if (ch === 123) {
  4659. ++pos;
  4660. ({
  4661. code,
  4662. pos
  4663. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  4664. ++pos;
  4665. if (code !== null && code > 0x10ffff) {
  4666. if (throwOnInvalid) {
  4667. errors.invalidCodePoint(pos, lineStart, curLine);
  4668. } else {
  4669. return {
  4670. code: null,
  4671. pos
  4672. };
  4673. }
  4674. }
  4675. } else {
  4676. ({
  4677. code,
  4678. pos
  4679. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  4680. }
  4681. return {
  4682. code,
  4683. pos
  4684. };
  4685. }
  4686. function buildPosition(pos, lineStart, curLine) {
  4687. return new Position(curLine, pos - lineStart, pos);
  4688. }
  4689. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  4690. class Token {
  4691. constructor(state) {
  4692. this.type = state.type;
  4693. this.value = state.value;
  4694. this.start = state.start;
  4695. this.end = state.end;
  4696. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  4697. }
  4698. }
  4699. class Tokenizer extends CommentsParser {
  4700. constructor(options, input) {
  4701. super();
  4702. this.isLookahead = void 0;
  4703. this.tokens = [];
  4704. this.errorHandlers_readInt = {
  4705. invalidDigit: (pos, lineStart, curLine, radix) => {
  4706. if (!this.options.errorRecovery) return false;
  4707. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  4708. radix
  4709. });
  4710. return true;
  4711. },
  4712. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  4713. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  4714. };
  4715. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  4716. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  4717. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  4718. });
  4719. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  4720. strictNumericEscape: (pos, lineStart, curLine) => {
  4721. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  4722. },
  4723. unterminated: (pos, lineStart, curLine) => {
  4724. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  4725. }
  4726. });
  4727. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  4728. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  4729. unterminated: (pos, lineStart, curLine) => {
  4730. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  4731. }
  4732. });
  4733. this.state = new State();
  4734. this.state.init(options);
  4735. this.input = input;
  4736. this.length = input.length;
  4737. this.comments = [];
  4738. this.isLookahead = false;
  4739. }
  4740. pushToken(token) {
  4741. this.tokens.length = this.state.tokensLength;
  4742. this.tokens.push(token);
  4743. ++this.state.tokensLength;
  4744. }
  4745. next() {
  4746. this.checkKeywordEscapes();
  4747. if (this.options.tokens) {
  4748. this.pushToken(new Token(this.state));
  4749. }
  4750. this.state.lastTokEndLoc = this.state.endLoc;
  4751. this.state.lastTokStartLoc = this.state.startLoc;
  4752. this.nextToken();
  4753. }
  4754. eat(type) {
  4755. if (this.match(type)) {
  4756. this.next();
  4757. return true;
  4758. } else {
  4759. return false;
  4760. }
  4761. }
  4762. match(type) {
  4763. return this.state.type === type;
  4764. }
  4765. createLookaheadState(state) {
  4766. return {
  4767. pos: state.pos,
  4768. value: null,
  4769. type: state.type,
  4770. start: state.start,
  4771. end: state.end,
  4772. context: [this.curContext()],
  4773. inType: state.inType,
  4774. startLoc: state.startLoc,
  4775. lastTokEndLoc: state.lastTokEndLoc,
  4776. curLine: state.curLine,
  4777. lineStart: state.lineStart,
  4778. curPosition: state.curPosition
  4779. };
  4780. }
  4781. lookahead() {
  4782. const old = this.state;
  4783. this.state = this.createLookaheadState(old);
  4784. this.isLookahead = true;
  4785. this.nextToken();
  4786. this.isLookahead = false;
  4787. const curr = this.state;
  4788. this.state = old;
  4789. return curr;
  4790. }
  4791. nextTokenStart() {
  4792. return this.nextTokenStartSince(this.state.pos);
  4793. }
  4794. nextTokenStartSince(pos) {
  4795. skipWhiteSpace.lastIndex = pos;
  4796. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  4797. }
  4798. lookaheadCharCode() {
  4799. return this.input.charCodeAt(this.nextTokenStart());
  4800. }
  4801. nextTokenInLineStart() {
  4802. return this.nextTokenInLineStartSince(this.state.pos);
  4803. }
  4804. nextTokenInLineStartSince(pos) {
  4805. skipWhiteSpaceInLine.lastIndex = pos;
  4806. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  4807. }
  4808. lookaheadInLineCharCode() {
  4809. return this.input.charCodeAt(this.nextTokenInLineStart());
  4810. }
  4811. codePointAtPos(pos) {
  4812. let cp = this.input.charCodeAt(pos);
  4813. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  4814. const trail = this.input.charCodeAt(pos);
  4815. if ((trail & 0xfc00) === 0xdc00) {
  4816. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  4817. }
  4818. }
  4819. return cp;
  4820. }
  4821. setStrict(strict) {
  4822. this.state.strict = strict;
  4823. if (strict) {
  4824. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  4825. this.state.strictErrors.clear();
  4826. }
  4827. }
  4828. curContext() {
  4829. return this.state.context[this.state.context.length - 1];
  4830. }
  4831. nextToken() {
  4832. this.skipSpace();
  4833. this.state.start = this.state.pos;
  4834. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  4835. if (this.state.pos >= this.length) {
  4836. this.finishToken(139);
  4837. return;
  4838. }
  4839. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  4840. }
  4841. skipBlockComment(commentEnd) {
  4842. let startLoc;
  4843. if (!this.isLookahead) startLoc = this.state.curPosition();
  4844. const start = this.state.pos;
  4845. const end = this.input.indexOf(commentEnd, start + 2);
  4846. if (end === -1) {
  4847. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  4848. }
  4849. this.state.pos = end + commentEnd.length;
  4850. lineBreakG.lastIndex = start + 2;
  4851. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  4852. ++this.state.curLine;
  4853. this.state.lineStart = lineBreakG.lastIndex;
  4854. }
  4855. if (this.isLookahead) return;
  4856. const comment = {
  4857. type: "CommentBlock",
  4858. value: this.input.slice(start + 2, end),
  4859. start,
  4860. end: end + commentEnd.length,
  4861. loc: new SourceLocation(startLoc, this.state.curPosition())
  4862. };
  4863. if (this.options.tokens) this.pushToken(comment);
  4864. return comment;
  4865. }
  4866. skipLineComment(startSkip) {
  4867. const start = this.state.pos;
  4868. let startLoc;
  4869. if (!this.isLookahead) startLoc = this.state.curPosition();
  4870. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  4871. if (this.state.pos < this.length) {
  4872. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4873. ch = this.input.charCodeAt(this.state.pos);
  4874. }
  4875. }
  4876. if (this.isLookahead) return;
  4877. const end = this.state.pos;
  4878. const value = this.input.slice(start + startSkip, end);
  4879. const comment = {
  4880. type: "CommentLine",
  4881. value,
  4882. start,
  4883. end,
  4884. loc: new SourceLocation(startLoc, this.state.curPosition())
  4885. };
  4886. if (this.options.tokens) this.pushToken(comment);
  4887. return comment;
  4888. }
  4889. skipSpace() {
  4890. const spaceStart = this.state.pos;
  4891. const comments = [];
  4892. loop: while (this.state.pos < this.length) {
  4893. const ch = this.input.charCodeAt(this.state.pos);
  4894. switch (ch) {
  4895. case 32:
  4896. case 160:
  4897. case 9:
  4898. ++this.state.pos;
  4899. break;
  4900. case 13:
  4901. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  4902. ++this.state.pos;
  4903. }
  4904. case 10:
  4905. case 8232:
  4906. case 8233:
  4907. ++this.state.pos;
  4908. ++this.state.curLine;
  4909. this.state.lineStart = this.state.pos;
  4910. break;
  4911. case 47:
  4912. switch (this.input.charCodeAt(this.state.pos + 1)) {
  4913. case 42:
  4914. {
  4915. const comment = this.skipBlockComment("*/");
  4916. if (comment !== undefined) {
  4917. this.addComment(comment);
  4918. if (this.options.attachComment) comments.push(comment);
  4919. }
  4920. break;
  4921. }
  4922. case 47:
  4923. {
  4924. const comment = this.skipLineComment(2);
  4925. if (comment !== undefined) {
  4926. this.addComment(comment);
  4927. if (this.options.attachComment) comments.push(comment);
  4928. }
  4929. break;
  4930. }
  4931. default:
  4932. break loop;
  4933. }
  4934. break;
  4935. default:
  4936. if (isWhitespace(ch)) {
  4937. ++this.state.pos;
  4938. } else if (ch === 45 && !this.inModule && this.options.annexB) {
  4939. const pos = this.state.pos;
  4940. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  4941. const comment = this.skipLineComment(3);
  4942. if (comment !== undefined) {
  4943. this.addComment(comment);
  4944. if (this.options.attachComment) comments.push(comment);
  4945. }
  4946. } else {
  4947. break loop;
  4948. }
  4949. } else if (ch === 60 && !this.inModule && this.options.annexB) {
  4950. const pos = this.state.pos;
  4951. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  4952. const comment = this.skipLineComment(4);
  4953. if (comment !== undefined) {
  4954. this.addComment(comment);
  4955. if (this.options.attachComment) comments.push(comment);
  4956. }
  4957. } else {
  4958. break loop;
  4959. }
  4960. } else {
  4961. break loop;
  4962. }
  4963. }
  4964. }
  4965. if (comments.length > 0) {
  4966. const end = this.state.pos;
  4967. const commentWhitespace = {
  4968. start: spaceStart,
  4969. end,
  4970. comments,
  4971. leadingNode: null,
  4972. trailingNode: null,
  4973. containingNode: null
  4974. };
  4975. this.state.commentStack.push(commentWhitespace);
  4976. }
  4977. }
  4978. finishToken(type, val) {
  4979. this.state.end = this.state.pos;
  4980. this.state.endLoc = this.state.curPosition();
  4981. const prevType = this.state.type;
  4982. this.state.type = type;
  4983. this.state.value = val;
  4984. if (!this.isLookahead) {
  4985. this.updateContext(prevType);
  4986. }
  4987. }
  4988. replaceToken(type) {
  4989. this.state.type = type;
  4990. this.updateContext();
  4991. }
  4992. readToken_numberSign() {
  4993. if (this.state.pos === 0 && this.readToken_interpreter()) {
  4994. return;
  4995. }
  4996. const nextPos = this.state.pos + 1;
  4997. const next = this.codePointAtPos(nextPos);
  4998. if (next >= 48 && next <= 57) {
  4999. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  5000. }
  5001. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  5002. this.expectPlugin("recordAndTuple");
  5003. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  5004. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  5005. }
  5006. this.state.pos += 2;
  5007. if (next === 123) {
  5008. this.finishToken(7);
  5009. } else {
  5010. this.finishToken(1);
  5011. }
  5012. } else if (isIdentifierStart(next)) {
  5013. ++this.state.pos;
  5014. this.finishToken(138, this.readWord1(next));
  5015. } else if (next === 92) {
  5016. ++this.state.pos;
  5017. this.finishToken(138, this.readWord1());
  5018. } else {
  5019. this.finishOp(27, 1);
  5020. }
  5021. }
  5022. readToken_dot() {
  5023. const next = this.input.charCodeAt(this.state.pos + 1);
  5024. if (next >= 48 && next <= 57) {
  5025. this.readNumber(true);
  5026. return;
  5027. }
  5028. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  5029. this.state.pos += 3;
  5030. this.finishToken(21);
  5031. } else {
  5032. ++this.state.pos;
  5033. this.finishToken(16);
  5034. }
  5035. }
  5036. readToken_slash() {
  5037. const next = this.input.charCodeAt(this.state.pos + 1);
  5038. if (next === 61) {
  5039. this.finishOp(31, 2);
  5040. } else {
  5041. this.finishOp(56, 1);
  5042. }
  5043. }
  5044. readToken_interpreter() {
  5045. if (this.state.pos !== 0 || this.length < 2) return false;
  5046. let ch = this.input.charCodeAt(this.state.pos + 1);
  5047. if (ch !== 33) return false;
  5048. const start = this.state.pos;
  5049. this.state.pos += 1;
  5050. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  5051. ch = this.input.charCodeAt(this.state.pos);
  5052. }
  5053. const value = this.input.slice(start + 2, this.state.pos);
  5054. this.finishToken(28, value);
  5055. return true;
  5056. }
  5057. readToken_mult_modulo(code) {
  5058. let type = code === 42 ? 55 : 54;
  5059. let width = 1;
  5060. let next = this.input.charCodeAt(this.state.pos + 1);
  5061. if (code === 42 && next === 42) {
  5062. width++;
  5063. next = this.input.charCodeAt(this.state.pos + 2);
  5064. type = 57;
  5065. }
  5066. if (next === 61 && !this.state.inType) {
  5067. width++;
  5068. type = code === 37 ? 33 : 30;
  5069. }
  5070. this.finishOp(type, width);
  5071. }
  5072. readToken_pipe_amp(code) {
  5073. const next = this.input.charCodeAt(this.state.pos + 1);
  5074. if (next === code) {
  5075. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  5076. this.finishOp(30, 3);
  5077. } else {
  5078. this.finishOp(code === 124 ? 41 : 42, 2);
  5079. }
  5080. return;
  5081. }
  5082. if (code === 124) {
  5083. if (next === 62) {
  5084. this.finishOp(39, 2);
  5085. return;
  5086. }
  5087. if (this.hasPlugin("recordAndTuple") && next === 125) {
  5088. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5089. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5090. }
  5091. this.state.pos += 2;
  5092. this.finishToken(9);
  5093. return;
  5094. }
  5095. if (this.hasPlugin("recordAndTuple") && next === 93) {
  5096. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5097. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5098. }
  5099. this.state.pos += 2;
  5100. this.finishToken(4);
  5101. return;
  5102. }
  5103. }
  5104. if (next === 61) {
  5105. this.finishOp(30, 2);
  5106. return;
  5107. }
  5108. this.finishOp(code === 124 ? 43 : 45, 1);
  5109. }
  5110. readToken_caret() {
  5111. const next = this.input.charCodeAt(this.state.pos + 1);
  5112. if (next === 61 && !this.state.inType) {
  5113. this.finishOp(32, 2);
  5114. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  5115. proposal: "hack",
  5116. topicToken: "^^"
  5117. }])) {
  5118. this.finishOp(37, 2);
  5119. const lookaheadCh = this.input.codePointAt(this.state.pos);
  5120. if (lookaheadCh === 94) {
  5121. this.unexpected();
  5122. }
  5123. } else {
  5124. this.finishOp(44, 1);
  5125. }
  5126. }
  5127. readToken_atSign() {
  5128. const next = this.input.charCodeAt(this.state.pos + 1);
  5129. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  5130. proposal: "hack",
  5131. topicToken: "@@"
  5132. }])) {
  5133. this.finishOp(38, 2);
  5134. } else {
  5135. this.finishOp(26, 1);
  5136. }
  5137. }
  5138. readToken_plus_min(code) {
  5139. const next = this.input.charCodeAt(this.state.pos + 1);
  5140. if (next === code) {
  5141. this.finishOp(34, 2);
  5142. return;
  5143. }
  5144. if (next === 61) {
  5145. this.finishOp(30, 2);
  5146. } else {
  5147. this.finishOp(53, 1);
  5148. }
  5149. }
  5150. readToken_lt() {
  5151. const {
  5152. pos
  5153. } = this.state;
  5154. const next = this.input.charCodeAt(pos + 1);
  5155. if (next === 60) {
  5156. if (this.input.charCodeAt(pos + 2) === 61) {
  5157. this.finishOp(30, 3);
  5158. return;
  5159. }
  5160. this.finishOp(51, 2);
  5161. return;
  5162. }
  5163. if (next === 61) {
  5164. this.finishOp(49, 2);
  5165. return;
  5166. }
  5167. this.finishOp(47, 1);
  5168. }
  5169. readToken_gt() {
  5170. const {
  5171. pos
  5172. } = this.state;
  5173. const next = this.input.charCodeAt(pos + 1);
  5174. if (next === 62) {
  5175. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  5176. if (this.input.charCodeAt(pos + size) === 61) {
  5177. this.finishOp(30, size + 1);
  5178. return;
  5179. }
  5180. this.finishOp(52, size);
  5181. return;
  5182. }
  5183. if (next === 61) {
  5184. this.finishOp(49, 2);
  5185. return;
  5186. }
  5187. this.finishOp(48, 1);
  5188. }
  5189. readToken_eq_excl(code) {
  5190. const next = this.input.charCodeAt(this.state.pos + 1);
  5191. if (next === 61) {
  5192. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  5193. return;
  5194. }
  5195. if (code === 61 && next === 62) {
  5196. this.state.pos += 2;
  5197. this.finishToken(19);
  5198. return;
  5199. }
  5200. this.finishOp(code === 61 ? 29 : 35, 1);
  5201. }
  5202. readToken_question() {
  5203. const next = this.input.charCodeAt(this.state.pos + 1);
  5204. const next2 = this.input.charCodeAt(this.state.pos + 2);
  5205. if (next === 63) {
  5206. if (next2 === 61) {
  5207. this.finishOp(30, 3);
  5208. } else {
  5209. this.finishOp(40, 2);
  5210. }
  5211. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  5212. this.state.pos += 2;
  5213. this.finishToken(18);
  5214. } else {
  5215. ++this.state.pos;
  5216. this.finishToken(17);
  5217. }
  5218. }
  5219. getTokenFromCode(code) {
  5220. switch (code) {
  5221. case 46:
  5222. this.readToken_dot();
  5223. return;
  5224. case 40:
  5225. ++this.state.pos;
  5226. this.finishToken(10);
  5227. return;
  5228. case 41:
  5229. ++this.state.pos;
  5230. this.finishToken(11);
  5231. return;
  5232. case 59:
  5233. ++this.state.pos;
  5234. this.finishToken(13);
  5235. return;
  5236. case 44:
  5237. ++this.state.pos;
  5238. this.finishToken(12);
  5239. return;
  5240. case 91:
  5241. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5242. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5243. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5244. }
  5245. this.state.pos += 2;
  5246. this.finishToken(2);
  5247. } else {
  5248. ++this.state.pos;
  5249. this.finishToken(0);
  5250. }
  5251. return;
  5252. case 93:
  5253. ++this.state.pos;
  5254. this.finishToken(3);
  5255. return;
  5256. case 123:
  5257. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5258. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5259. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5260. }
  5261. this.state.pos += 2;
  5262. this.finishToken(6);
  5263. } else {
  5264. ++this.state.pos;
  5265. this.finishToken(5);
  5266. }
  5267. return;
  5268. case 125:
  5269. ++this.state.pos;
  5270. this.finishToken(8);
  5271. return;
  5272. case 58:
  5273. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  5274. this.finishOp(15, 2);
  5275. } else {
  5276. ++this.state.pos;
  5277. this.finishToken(14);
  5278. }
  5279. return;
  5280. case 63:
  5281. this.readToken_question();
  5282. return;
  5283. case 96:
  5284. this.readTemplateToken();
  5285. return;
  5286. case 48:
  5287. {
  5288. const next = this.input.charCodeAt(this.state.pos + 1);
  5289. if (next === 120 || next === 88) {
  5290. this.readRadixNumber(16);
  5291. return;
  5292. }
  5293. if (next === 111 || next === 79) {
  5294. this.readRadixNumber(8);
  5295. return;
  5296. }
  5297. if (next === 98 || next === 66) {
  5298. this.readRadixNumber(2);
  5299. return;
  5300. }
  5301. }
  5302. case 49:
  5303. case 50:
  5304. case 51:
  5305. case 52:
  5306. case 53:
  5307. case 54:
  5308. case 55:
  5309. case 56:
  5310. case 57:
  5311. this.readNumber(false);
  5312. return;
  5313. case 34:
  5314. case 39:
  5315. this.readString(code);
  5316. return;
  5317. case 47:
  5318. this.readToken_slash();
  5319. return;
  5320. case 37:
  5321. case 42:
  5322. this.readToken_mult_modulo(code);
  5323. return;
  5324. case 124:
  5325. case 38:
  5326. this.readToken_pipe_amp(code);
  5327. return;
  5328. case 94:
  5329. this.readToken_caret();
  5330. return;
  5331. case 43:
  5332. case 45:
  5333. this.readToken_plus_min(code);
  5334. return;
  5335. case 60:
  5336. this.readToken_lt();
  5337. return;
  5338. case 62:
  5339. this.readToken_gt();
  5340. return;
  5341. case 61:
  5342. case 33:
  5343. this.readToken_eq_excl(code);
  5344. return;
  5345. case 126:
  5346. this.finishOp(36, 1);
  5347. return;
  5348. case 64:
  5349. this.readToken_atSign();
  5350. return;
  5351. case 35:
  5352. this.readToken_numberSign();
  5353. return;
  5354. case 92:
  5355. this.readWord();
  5356. return;
  5357. default:
  5358. if (isIdentifierStart(code)) {
  5359. this.readWord(code);
  5360. return;
  5361. }
  5362. }
  5363. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  5364. unexpected: String.fromCodePoint(code)
  5365. });
  5366. }
  5367. finishOp(type, size) {
  5368. const str = this.input.slice(this.state.pos, this.state.pos + size);
  5369. this.state.pos += size;
  5370. this.finishToken(type, str);
  5371. }
  5372. readRegexp() {
  5373. const startLoc = this.state.startLoc;
  5374. const start = this.state.start + 1;
  5375. let escaped, inClass;
  5376. let {
  5377. pos
  5378. } = this.state;
  5379. for (;; ++pos) {
  5380. if (pos >= this.length) {
  5381. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5382. }
  5383. const ch = this.input.charCodeAt(pos);
  5384. if (isNewLine(ch)) {
  5385. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5386. }
  5387. if (escaped) {
  5388. escaped = false;
  5389. } else {
  5390. if (ch === 91) {
  5391. inClass = true;
  5392. } else if (ch === 93 && inClass) {
  5393. inClass = false;
  5394. } else if (ch === 47 && !inClass) {
  5395. break;
  5396. }
  5397. escaped = ch === 92;
  5398. }
  5399. }
  5400. const content = this.input.slice(start, pos);
  5401. ++pos;
  5402. let mods = "";
  5403. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  5404. while (pos < this.length) {
  5405. const cp = this.codePointAtPos(pos);
  5406. const char = String.fromCharCode(cp);
  5407. if (VALID_REGEX_FLAGS.has(cp)) {
  5408. if (cp === 118) {
  5409. if (mods.includes("u")) {
  5410. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5411. }
  5412. } else if (cp === 117) {
  5413. if (mods.includes("v")) {
  5414. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5415. }
  5416. }
  5417. if (mods.includes(char)) {
  5418. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  5419. }
  5420. } else if (isIdentifierChar(cp) || cp === 92) {
  5421. this.raise(Errors.MalformedRegExpFlags, nextPos());
  5422. } else {
  5423. break;
  5424. }
  5425. ++pos;
  5426. mods += char;
  5427. }
  5428. this.state.pos = pos;
  5429. this.finishToken(137, {
  5430. pattern: content,
  5431. flags: mods
  5432. });
  5433. }
  5434. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  5435. const {
  5436. n,
  5437. pos
  5438. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  5439. this.state.pos = pos;
  5440. return n;
  5441. }
  5442. readRadixNumber(radix) {
  5443. const startLoc = this.state.curPosition();
  5444. let isBigInt = false;
  5445. this.state.pos += 2;
  5446. const val = this.readInt(radix);
  5447. if (val == null) {
  5448. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  5449. radix
  5450. });
  5451. }
  5452. const next = this.input.charCodeAt(this.state.pos);
  5453. if (next === 110) {
  5454. ++this.state.pos;
  5455. isBigInt = true;
  5456. } else if (next === 109) {
  5457. throw this.raise(Errors.InvalidDecimal, startLoc);
  5458. }
  5459. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5460. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5461. }
  5462. if (isBigInt) {
  5463. const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, "");
  5464. this.finishToken(135, str);
  5465. return;
  5466. }
  5467. this.finishToken(134, val);
  5468. }
  5469. readNumber(startsWithDot) {
  5470. const start = this.state.pos;
  5471. const startLoc = this.state.curPosition();
  5472. let isFloat = false;
  5473. let isBigInt = false;
  5474. let isDecimal = false;
  5475. let hasExponent = false;
  5476. let isOctal = false;
  5477. if (!startsWithDot && this.readInt(10) === null) {
  5478. this.raise(Errors.InvalidNumber, this.state.curPosition());
  5479. }
  5480. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5481. if (hasLeadingZero) {
  5482. const integer = this.input.slice(start, this.state.pos);
  5483. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  5484. if (!this.state.strict) {
  5485. const underscorePos = integer.indexOf("_");
  5486. if (underscorePos > 0) {
  5487. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  5488. }
  5489. }
  5490. isOctal = hasLeadingZero && !/[89]/.test(integer);
  5491. }
  5492. let next = this.input.charCodeAt(this.state.pos);
  5493. if (next === 46 && !isOctal) {
  5494. ++this.state.pos;
  5495. this.readInt(10);
  5496. isFloat = true;
  5497. next = this.input.charCodeAt(this.state.pos);
  5498. }
  5499. if ((next === 69 || next === 101) && !isOctal) {
  5500. next = this.input.charCodeAt(++this.state.pos);
  5501. if (next === 43 || next === 45) {
  5502. ++this.state.pos;
  5503. }
  5504. if (this.readInt(10) === null) {
  5505. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  5506. }
  5507. isFloat = true;
  5508. hasExponent = true;
  5509. next = this.input.charCodeAt(this.state.pos);
  5510. }
  5511. if (next === 110) {
  5512. if (isFloat || hasLeadingZero) {
  5513. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  5514. }
  5515. ++this.state.pos;
  5516. isBigInt = true;
  5517. }
  5518. if (next === 109) {
  5519. this.expectPlugin("decimal", this.state.curPosition());
  5520. if (hasExponent || hasLeadingZero) {
  5521. this.raise(Errors.InvalidDecimal, startLoc);
  5522. }
  5523. ++this.state.pos;
  5524. isDecimal = true;
  5525. }
  5526. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5527. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5528. }
  5529. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  5530. if (isBigInt) {
  5531. this.finishToken(135, str);
  5532. return;
  5533. }
  5534. if (isDecimal) {
  5535. this.finishToken(136, str);
  5536. return;
  5537. }
  5538. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  5539. this.finishToken(134, val);
  5540. }
  5541. readCodePoint(throwOnInvalid) {
  5542. const {
  5543. code,
  5544. pos
  5545. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  5546. this.state.pos = pos;
  5547. return code;
  5548. }
  5549. readString(quote) {
  5550. const {
  5551. str,
  5552. pos,
  5553. curLine,
  5554. lineStart
  5555. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  5556. this.state.pos = pos + 1;
  5557. this.state.lineStart = lineStart;
  5558. this.state.curLine = curLine;
  5559. this.finishToken(133, str);
  5560. }
  5561. readTemplateContinuation() {
  5562. if (!this.match(8)) {
  5563. this.unexpected(null, 8);
  5564. }
  5565. this.state.pos--;
  5566. this.readTemplateToken();
  5567. }
  5568. readTemplateToken() {
  5569. const opening = this.input[this.state.pos];
  5570. const {
  5571. str,
  5572. firstInvalidLoc,
  5573. pos,
  5574. curLine,
  5575. lineStart
  5576. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  5577. this.state.pos = pos + 1;
  5578. this.state.lineStart = lineStart;
  5579. this.state.curLine = curLine;
  5580. if (firstInvalidLoc) {
  5581. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
  5582. }
  5583. if (this.input.codePointAt(pos) === 96) {
  5584. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  5585. } else {
  5586. this.state.pos++;
  5587. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  5588. }
  5589. }
  5590. recordStrictModeErrors(toParseError, at) {
  5591. const index = at.index;
  5592. if (this.state.strict && !this.state.strictErrors.has(index)) {
  5593. this.raise(toParseError, at);
  5594. } else {
  5595. this.state.strictErrors.set(index, [toParseError, at]);
  5596. }
  5597. }
  5598. readWord1(firstCode) {
  5599. this.state.containsEsc = false;
  5600. let word = "";
  5601. const start = this.state.pos;
  5602. let chunkStart = this.state.pos;
  5603. if (firstCode !== undefined) {
  5604. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  5605. }
  5606. while (this.state.pos < this.length) {
  5607. const ch = this.codePointAtPos(this.state.pos);
  5608. if (isIdentifierChar(ch)) {
  5609. this.state.pos += ch <= 0xffff ? 1 : 2;
  5610. } else if (ch === 92) {
  5611. this.state.containsEsc = true;
  5612. word += this.input.slice(chunkStart, this.state.pos);
  5613. const escStart = this.state.curPosition();
  5614. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  5615. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  5616. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  5617. chunkStart = this.state.pos - 1;
  5618. continue;
  5619. }
  5620. ++this.state.pos;
  5621. const esc = this.readCodePoint(true);
  5622. if (esc !== null) {
  5623. if (!identifierCheck(esc)) {
  5624. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  5625. }
  5626. word += String.fromCodePoint(esc);
  5627. }
  5628. chunkStart = this.state.pos;
  5629. } else {
  5630. break;
  5631. }
  5632. }
  5633. return word + this.input.slice(chunkStart, this.state.pos);
  5634. }
  5635. readWord(firstCode) {
  5636. const word = this.readWord1(firstCode);
  5637. const type = keywords$1.get(word);
  5638. if (type !== undefined) {
  5639. this.finishToken(type, tokenLabelName(type));
  5640. } else {
  5641. this.finishToken(132, word);
  5642. }
  5643. }
  5644. checkKeywordEscapes() {
  5645. const {
  5646. type
  5647. } = this.state;
  5648. if (tokenIsKeyword(type) && this.state.containsEsc) {
  5649. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  5650. reservedWord: tokenLabelName(type)
  5651. });
  5652. }
  5653. }
  5654. raise(toParseError, at, details = {}) {
  5655. const loc = at instanceof Position ? at : at.loc.start;
  5656. const error = toParseError(loc, details);
  5657. if (!this.options.errorRecovery) throw error;
  5658. if (!this.isLookahead) this.state.errors.push(error);
  5659. return error;
  5660. }
  5661. raiseOverwrite(toParseError, at, details = {}) {
  5662. const loc = at instanceof Position ? at : at.loc.start;
  5663. const pos = loc.index;
  5664. const errors = this.state.errors;
  5665. for (let i = errors.length - 1; i >= 0; i--) {
  5666. const error = errors[i];
  5667. if (error.loc.index === pos) {
  5668. return errors[i] = toParseError(loc, details);
  5669. }
  5670. if (error.loc.index < pos) break;
  5671. }
  5672. return this.raise(toParseError, at, details);
  5673. }
  5674. updateContext(prevType) {}
  5675. unexpected(loc, type) {
  5676. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  5677. expected: type ? tokenLabelName(type) : null
  5678. });
  5679. }
  5680. expectPlugin(pluginName, loc) {
  5681. if (this.hasPlugin(pluginName)) {
  5682. return true;
  5683. }
  5684. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  5685. missingPlugin: [pluginName]
  5686. });
  5687. }
  5688. expectOnePlugin(pluginNames) {
  5689. if (!pluginNames.some(name => this.hasPlugin(name))) {
  5690. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  5691. missingPlugin: pluginNames
  5692. });
  5693. }
  5694. }
  5695. errorBuilder(error) {
  5696. return (pos, lineStart, curLine) => {
  5697. this.raise(error, buildPosition(pos, lineStart, curLine));
  5698. };
  5699. }
  5700. }
  5701. class ClassScope {
  5702. constructor() {
  5703. this.privateNames = new Set();
  5704. this.loneAccessors = new Map();
  5705. this.undefinedPrivateNames = new Map();
  5706. }
  5707. }
  5708. class ClassScopeHandler {
  5709. constructor(parser) {
  5710. this.parser = void 0;
  5711. this.stack = [];
  5712. this.undefinedPrivateNames = new Map();
  5713. this.parser = parser;
  5714. }
  5715. current() {
  5716. return this.stack[this.stack.length - 1];
  5717. }
  5718. enter() {
  5719. this.stack.push(new ClassScope());
  5720. }
  5721. exit() {
  5722. const oldClassScope = this.stack.pop();
  5723. const current = this.current();
  5724. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  5725. if (current) {
  5726. if (!current.undefinedPrivateNames.has(name)) {
  5727. current.undefinedPrivateNames.set(name, loc);
  5728. }
  5729. } else {
  5730. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5731. identifierName: name
  5732. });
  5733. }
  5734. }
  5735. }
  5736. declarePrivateName(name, elementType, loc) {
  5737. const {
  5738. privateNames,
  5739. loneAccessors,
  5740. undefinedPrivateNames
  5741. } = this.current();
  5742. let redefined = privateNames.has(name);
  5743. if (elementType & 3) {
  5744. const accessor = redefined && loneAccessors.get(name);
  5745. if (accessor) {
  5746. const oldStatic = accessor & 4;
  5747. const newStatic = elementType & 4;
  5748. const oldKind = accessor & 3;
  5749. const newKind = elementType & 3;
  5750. redefined = oldKind === newKind || oldStatic !== newStatic;
  5751. if (!redefined) loneAccessors.delete(name);
  5752. } else if (!redefined) {
  5753. loneAccessors.set(name, elementType);
  5754. }
  5755. }
  5756. if (redefined) {
  5757. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  5758. identifierName: name
  5759. });
  5760. }
  5761. privateNames.add(name);
  5762. undefinedPrivateNames.delete(name);
  5763. }
  5764. usePrivateName(name, loc) {
  5765. let classScope;
  5766. for (classScope of this.stack) {
  5767. if (classScope.privateNames.has(name)) return;
  5768. }
  5769. if (classScope) {
  5770. classScope.undefinedPrivateNames.set(name, loc);
  5771. } else {
  5772. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5773. identifierName: name
  5774. });
  5775. }
  5776. }
  5777. }
  5778. class ExpressionScope {
  5779. constructor(type = 0) {
  5780. this.type = type;
  5781. }
  5782. canBeArrowParameterDeclaration() {
  5783. return this.type === 2 || this.type === 1;
  5784. }
  5785. isCertainlyParameterDeclaration() {
  5786. return this.type === 3;
  5787. }
  5788. }
  5789. class ArrowHeadParsingScope extends ExpressionScope {
  5790. constructor(type) {
  5791. super(type);
  5792. this.declarationErrors = new Map();
  5793. }
  5794. recordDeclarationError(ParsingErrorClass, at) {
  5795. const index = at.index;
  5796. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  5797. }
  5798. clearDeclarationError(index) {
  5799. this.declarationErrors.delete(index);
  5800. }
  5801. iterateErrors(iterator) {
  5802. this.declarationErrors.forEach(iterator);
  5803. }
  5804. }
  5805. class ExpressionScopeHandler {
  5806. constructor(parser) {
  5807. this.parser = void 0;
  5808. this.stack = [new ExpressionScope()];
  5809. this.parser = parser;
  5810. }
  5811. enter(scope) {
  5812. this.stack.push(scope);
  5813. }
  5814. exit() {
  5815. this.stack.pop();
  5816. }
  5817. recordParameterInitializerError(toParseError, node) {
  5818. const origin = node.loc.start;
  5819. const {
  5820. stack
  5821. } = this;
  5822. let i = stack.length - 1;
  5823. let scope = stack[i];
  5824. while (!scope.isCertainlyParameterDeclaration()) {
  5825. if (scope.canBeArrowParameterDeclaration()) {
  5826. scope.recordDeclarationError(toParseError, origin);
  5827. } else {
  5828. return;
  5829. }
  5830. scope = stack[--i];
  5831. }
  5832. this.parser.raise(toParseError, origin);
  5833. }
  5834. recordArrowParameterBindingError(error, node) {
  5835. const {
  5836. stack
  5837. } = this;
  5838. const scope = stack[stack.length - 1];
  5839. const origin = node.loc.start;
  5840. if (scope.isCertainlyParameterDeclaration()) {
  5841. this.parser.raise(error, origin);
  5842. } else if (scope.canBeArrowParameterDeclaration()) {
  5843. scope.recordDeclarationError(error, origin);
  5844. } else {
  5845. return;
  5846. }
  5847. }
  5848. recordAsyncArrowParametersError(at) {
  5849. const {
  5850. stack
  5851. } = this;
  5852. let i = stack.length - 1;
  5853. let scope = stack[i];
  5854. while (scope.canBeArrowParameterDeclaration()) {
  5855. if (scope.type === 2) {
  5856. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  5857. }
  5858. scope = stack[--i];
  5859. }
  5860. }
  5861. validateAsPattern() {
  5862. const {
  5863. stack
  5864. } = this;
  5865. const currentScope = stack[stack.length - 1];
  5866. if (!currentScope.canBeArrowParameterDeclaration()) return;
  5867. currentScope.iterateErrors(([toParseError, loc]) => {
  5868. this.parser.raise(toParseError, loc);
  5869. let i = stack.length - 2;
  5870. let scope = stack[i];
  5871. while (scope.canBeArrowParameterDeclaration()) {
  5872. scope.clearDeclarationError(loc.index);
  5873. scope = stack[--i];
  5874. }
  5875. });
  5876. }
  5877. }
  5878. function newParameterDeclarationScope() {
  5879. return new ExpressionScope(3);
  5880. }
  5881. function newArrowHeadScope() {
  5882. return new ArrowHeadParsingScope(1);
  5883. }
  5884. function newAsyncArrowScope() {
  5885. return new ArrowHeadParsingScope(2);
  5886. }
  5887. function newExpressionScope() {
  5888. return new ExpressionScope();
  5889. }
  5890. class ProductionParameterHandler {
  5891. constructor() {
  5892. this.stacks = [];
  5893. }
  5894. enter(flags) {
  5895. this.stacks.push(flags);
  5896. }
  5897. exit() {
  5898. this.stacks.pop();
  5899. }
  5900. currentFlags() {
  5901. return this.stacks[this.stacks.length - 1];
  5902. }
  5903. get hasAwait() {
  5904. return (this.currentFlags() & 2) > 0;
  5905. }
  5906. get hasYield() {
  5907. return (this.currentFlags() & 1) > 0;
  5908. }
  5909. get hasReturn() {
  5910. return (this.currentFlags() & 4) > 0;
  5911. }
  5912. get hasIn() {
  5913. return (this.currentFlags() & 8) > 0;
  5914. }
  5915. }
  5916. function functionFlags(isAsync, isGenerator) {
  5917. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  5918. }
  5919. class UtilParser extends Tokenizer {
  5920. addExtra(node, key, value, enumerable = true) {
  5921. if (!node) return;
  5922. let {
  5923. extra
  5924. } = node;
  5925. if (extra == null) {
  5926. extra = {};
  5927. node.extra = extra;
  5928. }
  5929. if (enumerable) {
  5930. extra[key] = value;
  5931. } else {
  5932. Object.defineProperty(extra, key, {
  5933. enumerable,
  5934. value
  5935. });
  5936. }
  5937. }
  5938. isContextual(token) {
  5939. return this.state.type === token && !this.state.containsEsc;
  5940. }
  5941. isUnparsedContextual(nameStart, name) {
  5942. const nameEnd = nameStart + name.length;
  5943. if (this.input.slice(nameStart, nameEnd) === name) {
  5944. const nextCh = this.input.charCodeAt(nameEnd);
  5945. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  5946. }
  5947. return false;
  5948. }
  5949. isLookaheadContextual(name) {
  5950. const next = this.nextTokenStart();
  5951. return this.isUnparsedContextual(next, name);
  5952. }
  5953. eatContextual(token) {
  5954. if (this.isContextual(token)) {
  5955. this.next();
  5956. return true;
  5957. }
  5958. return false;
  5959. }
  5960. expectContextual(token, toParseError) {
  5961. if (!this.eatContextual(token)) {
  5962. if (toParseError != null) {
  5963. throw this.raise(toParseError, this.state.startLoc);
  5964. }
  5965. this.unexpected(null, token);
  5966. }
  5967. }
  5968. canInsertSemicolon() {
  5969. return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
  5970. }
  5971. hasPrecedingLineBreak() {
  5972. return hasNewLine(this.input, this.state.lastTokEndLoc.index, this.state.start);
  5973. }
  5974. hasFollowingLineBreak() {
  5975. return hasNewLine(this.input, this.state.end, this.nextTokenStart());
  5976. }
  5977. isLineTerminator() {
  5978. return this.eat(13) || this.canInsertSemicolon();
  5979. }
  5980. semicolon(allowAsi = true) {
  5981. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  5982. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  5983. }
  5984. expect(type, loc) {
  5985. if (!this.eat(type)) {
  5986. this.unexpected(loc, type);
  5987. }
  5988. }
  5989. tryParse(fn, oldState = this.state.clone()) {
  5990. const abortSignal = {
  5991. node: null
  5992. };
  5993. try {
  5994. const node = fn((node = null) => {
  5995. abortSignal.node = node;
  5996. throw abortSignal;
  5997. });
  5998. if (this.state.errors.length > oldState.errors.length) {
  5999. const failState = this.state;
  6000. this.state = oldState;
  6001. this.state.tokensLength = failState.tokensLength;
  6002. return {
  6003. node,
  6004. error: failState.errors[oldState.errors.length],
  6005. thrown: false,
  6006. aborted: false,
  6007. failState
  6008. };
  6009. }
  6010. return {
  6011. node,
  6012. error: null,
  6013. thrown: false,
  6014. aborted: false,
  6015. failState: null
  6016. };
  6017. } catch (error) {
  6018. const failState = this.state;
  6019. this.state = oldState;
  6020. if (error instanceof SyntaxError) {
  6021. return {
  6022. node: null,
  6023. error,
  6024. thrown: true,
  6025. aborted: false,
  6026. failState
  6027. };
  6028. }
  6029. if (error === abortSignal) {
  6030. return {
  6031. node: abortSignal.node,
  6032. error: null,
  6033. thrown: false,
  6034. aborted: true,
  6035. failState
  6036. };
  6037. }
  6038. throw error;
  6039. }
  6040. }
  6041. checkExpressionErrors(refExpressionErrors, andThrow) {
  6042. if (!refExpressionErrors) return false;
  6043. const {
  6044. shorthandAssignLoc,
  6045. doubleProtoLoc,
  6046. privateKeyLoc,
  6047. optionalParametersLoc
  6048. } = refExpressionErrors;
  6049. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
  6050. if (!andThrow) {
  6051. return hasErrors;
  6052. }
  6053. if (shorthandAssignLoc != null) {
  6054. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  6055. }
  6056. if (doubleProtoLoc != null) {
  6057. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  6058. }
  6059. if (privateKeyLoc != null) {
  6060. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  6061. }
  6062. if (optionalParametersLoc != null) {
  6063. this.unexpected(optionalParametersLoc);
  6064. }
  6065. }
  6066. isLiteralPropertyName() {
  6067. return tokenIsLiteralPropertyName(this.state.type);
  6068. }
  6069. isPrivateName(node) {
  6070. return node.type === "PrivateName";
  6071. }
  6072. getPrivateNameSV(node) {
  6073. return node.id.name;
  6074. }
  6075. hasPropertyAsPrivateName(node) {
  6076. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  6077. }
  6078. isObjectProperty(node) {
  6079. return node.type === "ObjectProperty";
  6080. }
  6081. isObjectMethod(node) {
  6082. return node.type === "ObjectMethod";
  6083. }
  6084. initializeScopes(inModule = this.options.sourceType === "module") {
  6085. const oldLabels = this.state.labels;
  6086. this.state.labels = [];
  6087. const oldExportedIdentifiers = this.exportedIdentifiers;
  6088. this.exportedIdentifiers = new Set();
  6089. const oldInModule = this.inModule;
  6090. this.inModule = inModule;
  6091. const oldScope = this.scope;
  6092. const ScopeHandler = this.getScopeHandler();
  6093. this.scope = new ScopeHandler(this, inModule);
  6094. const oldProdParam = this.prodParam;
  6095. this.prodParam = new ProductionParameterHandler();
  6096. const oldClassScope = this.classScope;
  6097. this.classScope = new ClassScopeHandler(this);
  6098. const oldExpressionScope = this.expressionScope;
  6099. this.expressionScope = new ExpressionScopeHandler(this);
  6100. return () => {
  6101. this.state.labels = oldLabels;
  6102. this.exportedIdentifiers = oldExportedIdentifiers;
  6103. this.inModule = oldInModule;
  6104. this.scope = oldScope;
  6105. this.prodParam = oldProdParam;
  6106. this.classScope = oldClassScope;
  6107. this.expressionScope = oldExpressionScope;
  6108. };
  6109. }
  6110. enterInitialScopes() {
  6111. let paramFlags = 0;
  6112. if (this.inModule) {
  6113. paramFlags |= 2;
  6114. }
  6115. this.scope.enter(1);
  6116. this.prodParam.enter(paramFlags);
  6117. }
  6118. checkDestructuringPrivate(refExpressionErrors) {
  6119. const {
  6120. privateKeyLoc
  6121. } = refExpressionErrors;
  6122. if (privateKeyLoc !== null) {
  6123. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  6124. }
  6125. }
  6126. }
  6127. class ExpressionErrors {
  6128. constructor() {
  6129. this.shorthandAssignLoc = null;
  6130. this.doubleProtoLoc = null;
  6131. this.privateKeyLoc = null;
  6132. this.optionalParametersLoc = null;
  6133. }
  6134. }
  6135. class Node {
  6136. constructor(parser, pos, loc) {
  6137. this.type = "";
  6138. this.start = pos;
  6139. this.end = 0;
  6140. this.loc = new SourceLocation(loc);
  6141. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  6142. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  6143. }
  6144. }
  6145. const NodePrototype = Node.prototype;
  6146. {
  6147. NodePrototype.__clone = function () {
  6148. const newNode = new Node(undefined, this.start, this.loc.start);
  6149. const keys = Object.keys(this);
  6150. for (let i = 0, length = keys.length; i < length; i++) {
  6151. const key = keys[i];
  6152. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  6153. newNode[key] = this[key];
  6154. }
  6155. }
  6156. return newNode;
  6157. };
  6158. }
  6159. function clonePlaceholder(node) {
  6160. return cloneIdentifier(node);
  6161. }
  6162. function cloneIdentifier(node) {
  6163. const {
  6164. type,
  6165. start,
  6166. end,
  6167. loc,
  6168. range,
  6169. extra,
  6170. name
  6171. } = node;
  6172. const cloned = Object.create(NodePrototype);
  6173. cloned.type = type;
  6174. cloned.start = start;
  6175. cloned.end = end;
  6176. cloned.loc = loc;
  6177. cloned.range = range;
  6178. cloned.extra = extra;
  6179. cloned.name = name;
  6180. if (type === "Placeholder") {
  6181. cloned.expectedNode = node.expectedNode;
  6182. }
  6183. return cloned;
  6184. }
  6185. function cloneStringLiteral(node) {
  6186. const {
  6187. type,
  6188. start,
  6189. end,
  6190. loc,
  6191. range,
  6192. extra
  6193. } = node;
  6194. if (type === "Placeholder") {
  6195. return clonePlaceholder(node);
  6196. }
  6197. const cloned = Object.create(NodePrototype);
  6198. cloned.type = type;
  6199. cloned.start = start;
  6200. cloned.end = end;
  6201. cloned.loc = loc;
  6202. cloned.range = range;
  6203. if (node.raw !== undefined) {
  6204. cloned.raw = node.raw;
  6205. } else {
  6206. cloned.extra = extra;
  6207. }
  6208. cloned.value = node.value;
  6209. return cloned;
  6210. }
  6211. class NodeUtils extends UtilParser {
  6212. startNode() {
  6213. const loc = this.state.startLoc;
  6214. return new Node(this, loc.index, loc);
  6215. }
  6216. startNodeAt(loc) {
  6217. return new Node(this, loc.index, loc);
  6218. }
  6219. startNodeAtNode(type) {
  6220. return this.startNodeAt(type.loc.start);
  6221. }
  6222. finishNode(node, type) {
  6223. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  6224. }
  6225. finishNodeAt(node, type, endLoc) {
  6226. node.type = type;
  6227. node.end = endLoc.index;
  6228. node.loc.end = endLoc;
  6229. if (this.options.ranges) node.range[1] = endLoc.index;
  6230. if (this.options.attachComment) this.processComment(node);
  6231. return node;
  6232. }
  6233. resetStartLocation(node, startLoc) {
  6234. node.start = startLoc.index;
  6235. node.loc.start = startLoc;
  6236. if (this.options.ranges) node.range[0] = startLoc.index;
  6237. }
  6238. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  6239. node.end = endLoc.index;
  6240. node.loc.end = endLoc;
  6241. if (this.options.ranges) node.range[1] = endLoc.index;
  6242. }
  6243. resetStartLocationFromNode(node, locationNode) {
  6244. this.resetStartLocation(node, locationNode.loc.start);
  6245. }
  6246. }
  6247. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  6248. const FlowErrors = ParseErrorEnum`flow`({
  6249. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  6250. 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.",
  6251. AssignReservedType: ({
  6252. reservedType
  6253. }) => `Cannot overwrite reserved type ${reservedType}.`,
  6254. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  6255. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  6256. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  6257. EnumBooleanMemberNotInitialized: ({
  6258. memberName,
  6259. enumName
  6260. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  6261. EnumDuplicateMemberName: ({
  6262. memberName,
  6263. enumName
  6264. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  6265. EnumInconsistentMemberValues: ({
  6266. enumName
  6267. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  6268. EnumInvalidExplicitType: ({
  6269. invalidEnumType,
  6270. enumName
  6271. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6272. EnumInvalidExplicitTypeUnknownSupplied: ({
  6273. enumName
  6274. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6275. EnumInvalidMemberInitializerPrimaryType: ({
  6276. enumName,
  6277. memberName,
  6278. explicitType
  6279. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  6280. EnumInvalidMemberInitializerSymbolType: ({
  6281. enumName,
  6282. memberName
  6283. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  6284. EnumInvalidMemberInitializerUnknownType: ({
  6285. enumName,
  6286. memberName
  6287. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  6288. EnumInvalidMemberName: ({
  6289. enumName,
  6290. memberName,
  6291. suggestion
  6292. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  6293. EnumNumberMemberNotInitialized: ({
  6294. enumName,
  6295. memberName
  6296. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  6297. EnumStringMemberInconsistentlyInitialized: ({
  6298. enumName
  6299. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  6300. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  6301. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  6302. 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.",
  6303. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  6304. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  6305. InexactVariance: "Explicit inexact syntax cannot have variance.",
  6306. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  6307. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  6308. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  6309. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  6310. PatternIsOptional: Object.assign({
  6311. message: "A binding pattern parameter cannot be optional in an implementation signature."
  6312. }, {
  6313. reasonCode: "OptionalBindingPattern"
  6314. }),
  6315. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  6316. SpreadVariance: "Spread properties cannot have variance.",
  6317. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  6318. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  6319. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  6320. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  6321. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  6322. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  6323. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  6324. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  6325. UnexpectedReservedType: ({
  6326. reservedType
  6327. }) => `Unexpected reserved type ${reservedType}.`,
  6328. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  6329. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  6330. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  6331. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  6332. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  6333. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  6334. UnsupportedDeclareExportKind: ({
  6335. unsupportedExportKind,
  6336. suggestion
  6337. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  6338. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  6339. UnterminatedFlowComment: "Unterminated flow-comment."
  6340. });
  6341. function isEsModuleType(bodyElement) {
  6342. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  6343. }
  6344. function hasTypeImportKind(node) {
  6345. return node.importKind === "type" || node.importKind === "typeof";
  6346. }
  6347. const exportSuggestions = {
  6348. const: "declare export var",
  6349. let: "declare export var",
  6350. type: "export type",
  6351. interface: "export interface"
  6352. };
  6353. function partition(list, test) {
  6354. const list1 = [];
  6355. const list2 = [];
  6356. for (let i = 0; i < list.length; i++) {
  6357. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  6358. }
  6359. return [list1, list2];
  6360. }
  6361. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  6362. var flow = superClass => class FlowParserMixin extends superClass {
  6363. constructor(...args) {
  6364. super(...args);
  6365. this.flowPragma = undefined;
  6366. }
  6367. getScopeHandler() {
  6368. return FlowScopeHandler;
  6369. }
  6370. shouldParseTypes() {
  6371. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  6372. }
  6373. shouldParseEnums() {
  6374. return !!this.getPluginOption("flow", "enums");
  6375. }
  6376. finishToken(type, val) {
  6377. if (type !== 133 && type !== 13 && type !== 28) {
  6378. if (this.flowPragma === undefined) {
  6379. this.flowPragma = null;
  6380. }
  6381. }
  6382. super.finishToken(type, val);
  6383. }
  6384. addComment(comment) {
  6385. if (this.flowPragma === undefined) {
  6386. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  6387. if (!matches) ;else if (matches[1] === "flow") {
  6388. this.flowPragma = "flow";
  6389. } else if (matches[1] === "noflow") {
  6390. this.flowPragma = "noflow";
  6391. } else {
  6392. throw new Error("Unexpected flow pragma");
  6393. }
  6394. }
  6395. super.addComment(comment);
  6396. }
  6397. flowParseTypeInitialiser(tok) {
  6398. const oldInType = this.state.inType;
  6399. this.state.inType = true;
  6400. this.expect(tok || 14);
  6401. const type = this.flowParseType();
  6402. this.state.inType = oldInType;
  6403. return type;
  6404. }
  6405. flowParsePredicate() {
  6406. const node = this.startNode();
  6407. const moduloLoc = this.state.startLoc;
  6408. this.next();
  6409. this.expectContextual(110);
  6410. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  6411. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  6412. }
  6413. if (this.eat(10)) {
  6414. node.value = super.parseExpression();
  6415. this.expect(11);
  6416. return this.finishNode(node, "DeclaredPredicate");
  6417. } else {
  6418. return this.finishNode(node, "InferredPredicate");
  6419. }
  6420. }
  6421. flowParseTypeAndPredicateInitialiser() {
  6422. const oldInType = this.state.inType;
  6423. this.state.inType = true;
  6424. this.expect(14);
  6425. let type = null;
  6426. let predicate = null;
  6427. if (this.match(54)) {
  6428. this.state.inType = oldInType;
  6429. predicate = this.flowParsePredicate();
  6430. } else {
  6431. type = this.flowParseType();
  6432. this.state.inType = oldInType;
  6433. if (this.match(54)) {
  6434. predicate = this.flowParsePredicate();
  6435. }
  6436. }
  6437. return [type, predicate];
  6438. }
  6439. flowParseDeclareClass(node) {
  6440. this.next();
  6441. this.flowParseInterfaceish(node, true);
  6442. return this.finishNode(node, "DeclareClass");
  6443. }
  6444. flowParseDeclareFunction(node) {
  6445. this.next();
  6446. const id = node.id = this.parseIdentifier();
  6447. const typeNode = this.startNode();
  6448. const typeContainer = this.startNode();
  6449. if (this.match(47)) {
  6450. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  6451. } else {
  6452. typeNode.typeParameters = null;
  6453. }
  6454. this.expect(10);
  6455. const tmp = this.flowParseFunctionTypeParams();
  6456. typeNode.params = tmp.params;
  6457. typeNode.rest = tmp.rest;
  6458. typeNode.this = tmp._this;
  6459. this.expect(11);
  6460. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6461. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  6462. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  6463. this.resetEndLocation(id);
  6464. this.semicolon();
  6465. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  6466. return this.finishNode(node, "DeclareFunction");
  6467. }
  6468. flowParseDeclare(node, insideModule) {
  6469. if (this.match(80)) {
  6470. return this.flowParseDeclareClass(node);
  6471. } else if (this.match(68)) {
  6472. return this.flowParseDeclareFunction(node);
  6473. } else if (this.match(74)) {
  6474. return this.flowParseDeclareVariable(node);
  6475. } else if (this.eatContextual(127)) {
  6476. if (this.match(16)) {
  6477. return this.flowParseDeclareModuleExports(node);
  6478. } else {
  6479. if (insideModule) {
  6480. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  6481. }
  6482. return this.flowParseDeclareModule(node);
  6483. }
  6484. } else if (this.isContextual(130)) {
  6485. return this.flowParseDeclareTypeAlias(node);
  6486. } else if (this.isContextual(131)) {
  6487. return this.flowParseDeclareOpaqueType(node);
  6488. } else if (this.isContextual(129)) {
  6489. return this.flowParseDeclareInterface(node);
  6490. } else if (this.match(82)) {
  6491. return this.flowParseDeclareExportDeclaration(node, insideModule);
  6492. } else {
  6493. this.unexpected();
  6494. }
  6495. }
  6496. flowParseDeclareVariable(node) {
  6497. this.next();
  6498. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  6499. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  6500. this.semicolon();
  6501. return this.finishNode(node, "DeclareVariable");
  6502. }
  6503. flowParseDeclareModule(node) {
  6504. this.scope.enter(0);
  6505. if (this.match(133)) {
  6506. node.id = super.parseExprAtom();
  6507. } else {
  6508. node.id = this.parseIdentifier();
  6509. }
  6510. const bodyNode = node.body = this.startNode();
  6511. const body = bodyNode.body = [];
  6512. this.expect(5);
  6513. while (!this.match(8)) {
  6514. let bodyNode = this.startNode();
  6515. if (this.match(83)) {
  6516. this.next();
  6517. if (!this.isContextual(130) && !this.match(87)) {
  6518. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  6519. }
  6520. super.parseImport(bodyNode);
  6521. } else {
  6522. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  6523. bodyNode = this.flowParseDeclare(bodyNode, true);
  6524. }
  6525. body.push(bodyNode);
  6526. }
  6527. this.scope.exit();
  6528. this.expect(8);
  6529. this.finishNode(bodyNode, "BlockStatement");
  6530. let kind = null;
  6531. let hasModuleExport = false;
  6532. body.forEach(bodyElement => {
  6533. if (isEsModuleType(bodyElement)) {
  6534. if (kind === "CommonJS") {
  6535. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6536. }
  6537. kind = "ES";
  6538. } else if (bodyElement.type === "DeclareModuleExports") {
  6539. if (hasModuleExport) {
  6540. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  6541. }
  6542. if (kind === "ES") {
  6543. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6544. }
  6545. kind = "CommonJS";
  6546. hasModuleExport = true;
  6547. }
  6548. });
  6549. node.kind = kind || "CommonJS";
  6550. return this.finishNode(node, "DeclareModule");
  6551. }
  6552. flowParseDeclareExportDeclaration(node, insideModule) {
  6553. this.expect(82);
  6554. if (this.eat(65)) {
  6555. if (this.match(68) || this.match(80)) {
  6556. node.declaration = this.flowParseDeclare(this.startNode());
  6557. } else {
  6558. node.declaration = this.flowParseType();
  6559. this.semicolon();
  6560. }
  6561. node.default = true;
  6562. return this.finishNode(node, "DeclareExportDeclaration");
  6563. } else {
  6564. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  6565. const label = this.state.value;
  6566. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  6567. unsupportedExportKind: label,
  6568. suggestion: exportSuggestions[label]
  6569. });
  6570. }
  6571. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  6572. node.declaration = this.flowParseDeclare(this.startNode());
  6573. node.default = false;
  6574. return this.finishNode(node, "DeclareExportDeclaration");
  6575. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  6576. node = this.parseExport(node, null);
  6577. if (node.type === "ExportNamedDeclaration") {
  6578. node.type = "ExportDeclaration";
  6579. node.default = false;
  6580. delete node.exportKind;
  6581. }
  6582. node.type = "Declare" + node.type;
  6583. return node;
  6584. }
  6585. }
  6586. this.unexpected();
  6587. }
  6588. flowParseDeclareModuleExports(node) {
  6589. this.next();
  6590. this.expectContextual(111);
  6591. node.typeAnnotation = this.flowParseTypeAnnotation();
  6592. this.semicolon();
  6593. return this.finishNode(node, "DeclareModuleExports");
  6594. }
  6595. flowParseDeclareTypeAlias(node) {
  6596. this.next();
  6597. const finished = this.flowParseTypeAlias(node);
  6598. finished.type = "DeclareTypeAlias";
  6599. return finished;
  6600. }
  6601. flowParseDeclareOpaqueType(node) {
  6602. this.next();
  6603. const finished = this.flowParseOpaqueType(node, true);
  6604. finished.type = "DeclareOpaqueType";
  6605. return finished;
  6606. }
  6607. flowParseDeclareInterface(node) {
  6608. this.next();
  6609. this.flowParseInterfaceish(node, false);
  6610. return this.finishNode(node, "DeclareInterface");
  6611. }
  6612. flowParseInterfaceish(node, isClass) {
  6613. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  6614. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  6615. if (this.match(47)) {
  6616. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6617. } else {
  6618. node.typeParameters = null;
  6619. }
  6620. node.extends = [];
  6621. if (this.eat(81)) {
  6622. do {
  6623. node.extends.push(this.flowParseInterfaceExtends());
  6624. } while (!isClass && this.eat(12));
  6625. }
  6626. if (isClass) {
  6627. node.implements = [];
  6628. node.mixins = [];
  6629. if (this.eatContextual(117)) {
  6630. do {
  6631. node.mixins.push(this.flowParseInterfaceExtends());
  6632. } while (this.eat(12));
  6633. }
  6634. if (this.eatContextual(113)) {
  6635. do {
  6636. node.implements.push(this.flowParseInterfaceExtends());
  6637. } while (this.eat(12));
  6638. }
  6639. }
  6640. node.body = this.flowParseObjectType({
  6641. allowStatic: isClass,
  6642. allowExact: false,
  6643. allowSpread: false,
  6644. allowProto: isClass,
  6645. allowInexact: false
  6646. });
  6647. }
  6648. flowParseInterfaceExtends() {
  6649. const node = this.startNode();
  6650. node.id = this.flowParseQualifiedTypeIdentifier();
  6651. if (this.match(47)) {
  6652. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6653. } else {
  6654. node.typeParameters = null;
  6655. }
  6656. return this.finishNode(node, "InterfaceExtends");
  6657. }
  6658. flowParseInterface(node) {
  6659. this.flowParseInterfaceish(node, false);
  6660. return this.finishNode(node, "InterfaceDeclaration");
  6661. }
  6662. checkNotUnderscore(word) {
  6663. if (word === "_") {
  6664. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  6665. }
  6666. }
  6667. checkReservedType(word, startLoc, declaration) {
  6668. if (!reservedTypes.has(word)) return;
  6669. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  6670. reservedType: word
  6671. });
  6672. }
  6673. flowParseRestrictedIdentifier(liberal, declaration) {
  6674. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  6675. return this.parseIdentifier(liberal);
  6676. }
  6677. flowParseTypeAlias(node) {
  6678. node.id = this.flowParseRestrictedIdentifier(false, true);
  6679. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6680. if (this.match(47)) {
  6681. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6682. } else {
  6683. node.typeParameters = null;
  6684. }
  6685. node.right = this.flowParseTypeInitialiser(29);
  6686. this.semicolon();
  6687. return this.finishNode(node, "TypeAlias");
  6688. }
  6689. flowParseOpaqueType(node, declare) {
  6690. this.expectContextual(130);
  6691. node.id = this.flowParseRestrictedIdentifier(true, true);
  6692. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6693. if (this.match(47)) {
  6694. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6695. } else {
  6696. node.typeParameters = null;
  6697. }
  6698. node.supertype = null;
  6699. if (this.match(14)) {
  6700. node.supertype = this.flowParseTypeInitialiser(14);
  6701. }
  6702. node.impltype = null;
  6703. if (!declare) {
  6704. node.impltype = this.flowParseTypeInitialiser(29);
  6705. }
  6706. this.semicolon();
  6707. return this.finishNode(node, "OpaqueType");
  6708. }
  6709. flowParseTypeParameter(requireDefault = false) {
  6710. const nodeStartLoc = this.state.startLoc;
  6711. const node = this.startNode();
  6712. const variance = this.flowParseVariance();
  6713. const ident = this.flowParseTypeAnnotatableIdentifier();
  6714. node.name = ident.name;
  6715. node.variance = variance;
  6716. node.bound = ident.typeAnnotation;
  6717. if (this.match(29)) {
  6718. this.eat(29);
  6719. node.default = this.flowParseType();
  6720. } else {
  6721. if (requireDefault) {
  6722. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  6723. }
  6724. }
  6725. return this.finishNode(node, "TypeParameter");
  6726. }
  6727. flowParseTypeParameterDeclaration() {
  6728. const oldInType = this.state.inType;
  6729. const node = this.startNode();
  6730. node.params = [];
  6731. this.state.inType = true;
  6732. if (this.match(47) || this.match(142)) {
  6733. this.next();
  6734. } else {
  6735. this.unexpected();
  6736. }
  6737. let defaultRequired = false;
  6738. do {
  6739. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  6740. node.params.push(typeParameter);
  6741. if (typeParameter.default) {
  6742. defaultRequired = true;
  6743. }
  6744. if (!this.match(48)) {
  6745. this.expect(12);
  6746. }
  6747. } while (!this.match(48));
  6748. this.expect(48);
  6749. this.state.inType = oldInType;
  6750. return this.finishNode(node, "TypeParameterDeclaration");
  6751. }
  6752. flowParseTypeParameterInstantiation() {
  6753. const node = this.startNode();
  6754. const oldInType = this.state.inType;
  6755. node.params = [];
  6756. this.state.inType = true;
  6757. this.expect(47);
  6758. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6759. this.state.noAnonFunctionType = false;
  6760. while (!this.match(48)) {
  6761. node.params.push(this.flowParseType());
  6762. if (!this.match(48)) {
  6763. this.expect(12);
  6764. }
  6765. }
  6766. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6767. this.expect(48);
  6768. this.state.inType = oldInType;
  6769. return this.finishNode(node, "TypeParameterInstantiation");
  6770. }
  6771. flowParseTypeParameterInstantiationCallOrNew() {
  6772. const node = this.startNode();
  6773. const oldInType = this.state.inType;
  6774. node.params = [];
  6775. this.state.inType = true;
  6776. this.expect(47);
  6777. while (!this.match(48)) {
  6778. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  6779. if (!this.match(48)) {
  6780. this.expect(12);
  6781. }
  6782. }
  6783. this.expect(48);
  6784. this.state.inType = oldInType;
  6785. return this.finishNode(node, "TypeParameterInstantiation");
  6786. }
  6787. flowParseInterfaceType() {
  6788. const node = this.startNode();
  6789. this.expectContextual(129);
  6790. node.extends = [];
  6791. if (this.eat(81)) {
  6792. do {
  6793. node.extends.push(this.flowParseInterfaceExtends());
  6794. } while (this.eat(12));
  6795. }
  6796. node.body = this.flowParseObjectType({
  6797. allowStatic: false,
  6798. allowExact: false,
  6799. allowSpread: false,
  6800. allowProto: false,
  6801. allowInexact: false
  6802. });
  6803. return this.finishNode(node, "InterfaceTypeAnnotation");
  6804. }
  6805. flowParseObjectPropertyKey() {
  6806. return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
  6807. }
  6808. flowParseObjectTypeIndexer(node, isStatic, variance) {
  6809. node.static = isStatic;
  6810. if (this.lookahead().type === 14) {
  6811. node.id = this.flowParseObjectPropertyKey();
  6812. node.key = this.flowParseTypeInitialiser();
  6813. } else {
  6814. node.id = null;
  6815. node.key = this.flowParseType();
  6816. }
  6817. this.expect(3);
  6818. node.value = this.flowParseTypeInitialiser();
  6819. node.variance = variance;
  6820. return this.finishNode(node, "ObjectTypeIndexer");
  6821. }
  6822. flowParseObjectTypeInternalSlot(node, isStatic) {
  6823. node.static = isStatic;
  6824. node.id = this.flowParseObjectPropertyKey();
  6825. this.expect(3);
  6826. this.expect(3);
  6827. if (this.match(47) || this.match(10)) {
  6828. node.method = true;
  6829. node.optional = false;
  6830. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6831. } else {
  6832. node.method = false;
  6833. if (this.eat(17)) {
  6834. node.optional = true;
  6835. }
  6836. node.value = this.flowParseTypeInitialiser();
  6837. }
  6838. return this.finishNode(node, "ObjectTypeInternalSlot");
  6839. }
  6840. flowParseObjectTypeMethodish(node) {
  6841. node.params = [];
  6842. node.rest = null;
  6843. node.typeParameters = null;
  6844. node.this = null;
  6845. if (this.match(47)) {
  6846. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6847. }
  6848. this.expect(10);
  6849. if (this.match(78)) {
  6850. node.this = this.flowParseFunctionTypeParam(true);
  6851. node.this.name = null;
  6852. if (!this.match(11)) {
  6853. this.expect(12);
  6854. }
  6855. }
  6856. while (!this.match(11) && !this.match(21)) {
  6857. node.params.push(this.flowParseFunctionTypeParam(false));
  6858. if (!this.match(11)) {
  6859. this.expect(12);
  6860. }
  6861. }
  6862. if (this.eat(21)) {
  6863. node.rest = this.flowParseFunctionTypeParam(false);
  6864. }
  6865. this.expect(11);
  6866. node.returnType = this.flowParseTypeInitialiser();
  6867. return this.finishNode(node, "FunctionTypeAnnotation");
  6868. }
  6869. flowParseObjectTypeCallProperty(node, isStatic) {
  6870. const valueNode = this.startNode();
  6871. node.static = isStatic;
  6872. node.value = this.flowParseObjectTypeMethodish(valueNode);
  6873. return this.finishNode(node, "ObjectTypeCallProperty");
  6874. }
  6875. flowParseObjectType({
  6876. allowStatic,
  6877. allowExact,
  6878. allowSpread,
  6879. allowProto,
  6880. allowInexact
  6881. }) {
  6882. const oldInType = this.state.inType;
  6883. this.state.inType = true;
  6884. const nodeStart = this.startNode();
  6885. nodeStart.callProperties = [];
  6886. nodeStart.properties = [];
  6887. nodeStart.indexers = [];
  6888. nodeStart.internalSlots = [];
  6889. let endDelim;
  6890. let exact;
  6891. let inexact = false;
  6892. if (allowExact && this.match(6)) {
  6893. this.expect(6);
  6894. endDelim = 9;
  6895. exact = true;
  6896. } else {
  6897. this.expect(5);
  6898. endDelim = 8;
  6899. exact = false;
  6900. }
  6901. nodeStart.exact = exact;
  6902. while (!this.match(endDelim)) {
  6903. let isStatic = false;
  6904. let protoStartLoc = null;
  6905. let inexactStartLoc = null;
  6906. const node = this.startNode();
  6907. if (allowProto && this.isContextual(118)) {
  6908. const lookahead = this.lookahead();
  6909. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6910. this.next();
  6911. protoStartLoc = this.state.startLoc;
  6912. allowStatic = false;
  6913. }
  6914. }
  6915. if (allowStatic && this.isContextual(106)) {
  6916. const lookahead = this.lookahead();
  6917. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6918. this.next();
  6919. isStatic = true;
  6920. }
  6921. }
  6922. const variance = this.flowParseVariance();
  6923. if (this.eat(0)) {
  6924. if (protoStartLoc != null) {
  6925. this.unexpected(protoStartLoc);
  6926. }
  6927. if (this.eat(0)) {
  6928. if (variance) {
  6929. this.unexpected(variance.loc.start);
  6930. }
  6931. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  6932. } else {
  6933. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  6934. }
  6935. } else if (this.match(10) || this.match(47)) {
  6936. if (protoStartLoc != null) {
  6937. this.unexpected(protoStartLoc);
  6938. }
  6939. if (variance) {
  6940. this.unexpected(variance.loc.start);
  6941. }
  6942. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  6943. } else {
  6944. let kind = "init";
  6945. if (this.isContextual(99) || this.isContextual(104)) {
  6946. const lookahead = this.lookahead();
  6947. if (tokenIsLiteralPropertyName(lookahead.type)) {
  6948. kind = this.state.value;
  6949. this.next();
  6950. }
  6951. }
  6952. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  6953. if (propOrInexact === null) {
  6954. inexact = true;
  6955. inexactStartLoc = this.state.lastTokStartLoc;
  6956. } else {
  6957. nodeStart.properties.push(propOrInexact);
  6958. }
  6959. }
  6960. this.flowObjectTypeSemicolon();
  6961. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  6962. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  6963. }
  6964. }
  6965. this.expect(endDelim);
  6966. if (allowSpread) {
  6967. nodeStart.inexact = inexact;
  6968. }
  6969. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  6970. this.state.inType = oldInType;
  6971. return out;
  6972. }
  6973. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  6974. if (this.eat(21)) {
  6975. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  6976. if (isInexactToken) {
  6977. if (!allowSpread) {
  6978. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  6979. } else if (!allowInexact) {
  6980. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  6981. }
  6982. if (variance) {
  6983. this.raise(FlowErrors.InexactVariance, variance);
  6984. }
  6985. return null;
  6986. }
  6987. if (!allowSpread) {
  6988. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  6989. }
  6990. if (protoStartLoc != null) {
  6991. this.unexpected(protoStartLoc);
  6992. }
  6993. if (variance) {
  6994. this.raise(FlowErrors.SpreadVariance, variance);
  6995. }
  6996. node.argument = this.flowParseType();
  6997. return this.finishNode(node, "ObjectTypeSpreadProperty");
  6998. } else {
  6999. node.key = this.flowParseObjectPropertyKey();
  7000. node.static = isStatic;
  7001. node.proto = protoStartLoc != null;
  7002. node.kind = kind;
  7003. let optional = false;
  7004. if (this.match(47) || this.match(10)) {
  7005. node.method = true;
  7006. if (protoStartLoc != null) {
  7007. this.unexpected(protoStartLoc);
  7008. }
  7009. if (variance) {
  7010. this.unexpected(variance.loc.start);
  7011. }
  7012. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  7013. if (kind === "get" || kind === "set") {
  7014. this.flowCheckGetterSetterParams(node);
  7015. }
  7016. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  7017. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  7018. }
  7019. } else {
  7020. if (kind !== "init") this.unexpected();
  7021. node.method = false;
  7022. if (this.eat(17)) {
  7023. optional = true;
  7024. }
  7025. node.value = this.flowParseTypeInitialiser();
  7026. node.variance = variance;
  7027. }
  7028. node.optional = optional;
  7029. return this.finishNode(node, "ObjectTypeProperty");
  7030. }
  7031. }
  7032. flowCheckGetterSetterParams(property) {
  7033. const paramCount = property.kind === "get" ? 0 : 1;
  7034. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  7035. if (property.value.this) {
  7036. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  7037. }
  7038. if (length !== paramCount) {
  7039. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  7040. }
  7041. if (property.kind === "set" && property.value.rest) {
  7042. this.raise(Errors.BadSetterRestParameter, property);
  7043. }
  7044. }
  7045. flowObjectTypeSemicolon() {
  7046. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  7047. this.unexpected();
  7048. }
  7049. }
  7050. flowParseQualifiedTypeIdentifier(startLoc, id) {
  7051. var _startLoc;
  7052. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  7053. let node = id || this.flowParseRestrictedIdentifier(true);
  7054. while (this.eat(16)) {
  7055. const node2 = this.startNodeAt(startLoc);
  7056. node2.qualification = node;
  7057. node2.id = this.flowParseRestrictedIdentifier(true);
  7058. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  7059. }
  7060. return node;
  7061. }
  7062. flowParseGenericType(startLoc, id) {
  7063. const node = this.startNodeAt(startLoc);
  7064. node.typeParameters = null;
  7065. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  7066. if (this.match(47)) {
  7067. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7068. }
  7069. return this.finishNode(node, "GenericTypeAnnotation");
  7070. }
  7071. flowParseTypeofType() {
  7072. const node = this.startNode();
  7073. this.expect(87);
  7074. node.argument = this.flowParsePrimaryType();
  7075. return this.finishNode(node, "TypeofTypeAnnotation");
  7076. }
  7077. flowParseTupleType() {
  7078. const node = this.startNode();
  7079. node.types = [];
  7080. this.expect(0);
  7081. while (this.state.pos < this.length && !this.match(3)) {
  7082. node.types.push(this.flowParseType());
  7083. if (this.match(3)) break;
  7084. this.expect(12);
  7085. }
  7086. this.expect(3);
  7087. return this.finishNode(node, "TupleTypeAnnotation");
  7088. }
  7089. flowParseFunctionTypeParam(first) {
  7090. let name = null;
  7091. let optional = false;
  7092. let typeAnnotation = null;
  7093. const node = this.startNode();
  7094. const lh = this.lookahead();
  7095. const isThis = this.state.type === 78;
  7096. if (lh.type === 14 || lh.type === 17) {
  7097. if (isThis && !first) {
  7098. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  7099. }
  7100. name = this.parseIdentifier(isThis);
  7101. if (this.eat(17)) {
  7102. optional = true;
  7103. if (isThis) {
  7104. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  7105. }
  7106. }
  7107. typeAnnotation = this.flowParseTypeInitialiser();
  7108. } else {
  7109. typeAnnotation = this.flowParseType();
  7110. }
  7111. node.name = name;
  7112. node.optional = optional;
  7113. node.typeAnnotation = typeAnnotation;
  7114. return this.finishNode(node, "FunctionTypeParam");
  7115. }
  7116. reinterpretTypeAsFunctionTypeParam(type) {
  7117. const node = this.startNodeAt(type.loc.start);
  7118. node.name = null;
  7119. node.optional = false;
  7120. node.typeAnnotation = type;
  7121. return this.finishNode(node, "FunctionTypeParam");
  7122. }
  7123. flowParseFunctionTypeParams(params = []) {
  7124. let rest = null;
  7125. let _this = null;
  7126. if (this.match(78)) {
  7127. _this = this.flowParseFunctionTypeParam(true);
  7128. _this.name = null;
  7129. if (!this.match(11)) {
  7130. this.expect(12);
  7131. }
  7132. }
  7133. while (!this.match(11) && !this.match(21)) {
  7134. params.push(this.flowParseFunctionTypeParam(false));
  7135. if (!this.match(11)) {
  7136. this.expect(12);
  7137. }
  7138. }
  7139. if (this.eat(21)) {
  7140. rest = this.flowParseFunctionTypeParam(false);
  7141. }
  7142. return {
  7143. params,
  7144. rest,
  7145. _this
  7146. };
  7147. }
  7148. flowIdentToTypeAnnotation(startLoc, node, id) {
  7149. switch (id.name) {
  7150. case "any":
  7151. return this.finishNode(node, "AnyTypeAnnotation");
  7152. case "bool":
  7153. case "boolean":
  7154. return this.finishNode(node, "BooleanTypeAnnotation");
  7155. case "mixed":
  7156. return this.finishNode(node, "MixedTypeAnnotation");
  7157. case "empty":
  7158. return this.finishNode(node, "EmptyTypeAnnotation");
  7159. case "number":
  7160. return this.finishNode(node, "NumberTypeAnnotation");
  7161. case "string":
  7162. return this.finishNode(node, "StringTypeAnnotation");
  7163. case "symbol":
  7164. return this.finishNode(node, "SymbolTypeAnnotation");
  7165. default:
  7166. this.checkNotUnderscore(id.name);
  7167. return this.flowParseGenericType(startLoc, id);
  7168. }
  7169. }
  7170. flowParsePrimaryType() {
  7171. const startLoc = this.state.startLoc;
  7172. const node = this.startNode();
  7173. let tmp;
  7174. let type;
  7175. let isGroupedType = false;
  7176. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7177. switch (this.state.type) {
  7178. case 5:
  7179. return this.flowParseObjectType({
  7180. allowStatic: false,
  7181. allowExact: false,
  7182. allowSpread: true,
  7183. allowProto: false,
  7184. allowInexact: true
  7185. });
  7186. case 6:
  7187. return this.flowParseObjectType({
  7188. allowStatic: false,
  7189. allowExact: true,
  7190. allowSpread: true,
  7191. allowProto: false,
  7192. allowInexact: false
  7193. });
  7194. case 0:
  7195. this.state.noAnonFunctionType = false;
  7196. type = this.flowParseTupleType();
  7197. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7198. return type;
  7199. case 47:
  7200. {
  7201. const node = this.startNode();
  7202. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7203. this.expect(10);
  7204. tmp = this.flowParseFunctionTypeParams();
  7205. node.params = tmp.params;
  7206. node.rest = tmp.rest;
  7207. node.this = tmp._this;
  7208. this.expect(11);
  7209. this.expect(19);
  7210. node.returnType = this.flowParseType();
  7211. return this.finishNode(node, "FunctionTypeAnnotation");
  7212. }
  7213. case 10:
  7214. {
  7215. const node = this.startNode();
  7216. this.next();
  7217. if (!this.match(11) && !this.match(21)) {
  7218. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  7219. const token = this.lookahead().type;
  7220. isGroupedType = token !== 17 && token !== 14;
  7221. } else {
  7222. isGroupedType = true;
  7223. }
  7224. }
  7225. if (isGroupedType) {
  7226. this.state.noAnonFunctionType = false;
  7227. type = this.flowParseType();
  7228. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7229. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  7230. this.expect(11);
  7231. return type;
  7232. } else {
  7233. this.eat(12);
  7234. }
  7235. }
  7236. if (type) {
  7237. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  7238. } else {
  7239. tmp = this.flowParseFunctionTypeParams();
  7240. }
  7241. node.params = tmp.params;
  7242. node.rest = tmp.rest;
  7243. node.this = tmp._this;
  7244. this.expect(11);
  7245. this.expect(19);
  7246. node.returnType = this.flowParseType();
  7247. node.typeParameters = null;
  7248. return this.finishNode(node, "FunctionTypeAnnotation");
  7249. }
  7250. case 133:
  7251. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  7252. case 85:
  7253. case 86:
  7254. node.value = this.match(85);
  7255. this.next();
  7256. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  7257. case 53:
  7258. if (this.state.value === "-") {
  7259. this.next();
  7260. if (this.match(134)) {
  7261. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  7262. }
  7263. if (this.match(135)) {
  7264. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  7265. }
  7266. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  7267. }
  7268. this.unexpected();
  7269. return;
  7270. case 134:
  7271. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  7272. case 135:
  7273. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  7274. case 88:
  7275. this.next();
  7276. return this.finishNode(node, "VoidTypeAnnotation");
  7277. case 84:
  7278. this.next();
  7279. return this.finishNode(node, "NullLiteralTypeAnnotation");
  7280. case 78:
  7281. this.next();
  7282. return this.finishNode(node, "ThisTypeAnnotation");
  7283. case 55:
  7284. this.next();
  7285. return this.finishNode(node, "ExistsTypeAnnotation");
  7286. case 87:
  7287. return this.flowParseTypeofType();
  7288. default:
  7289. if (tokenIsKeyword(this.state.type)) {
  7290. const label = tokenLabelName(this.state.type);
  7291. this.next();
  7292. return super.createIdentifier(node, label);
  7293. } else if (tokenIsIdentifier(this.state.type)) {
  7294. if (this.isContextual(129)) {
  7295. return this.flowParseInterfaceType();
  7296. }
  7297. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  7298. }
  7299. }
  7300. this.unexpected();
  7301. }
  7302. flowParsePostfixType() {
  7303. const startLoc = this.state.startLoc;
  7304. let type = this.flowParsePrimaryType();
  7305. let seenOptionalIndexedAccess = false;
  7306. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  7307. const node = this.startNodeAt(startLoc);
  7308. const optional = this.eat(18);
  7309. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  7310. this.expect(0);
  7311. if (!optional && this.match(3)) {
  7312. node.elementType = type;
  7313. this.next();
  7314. type = this.finishNode(node, "ArrayTypeAnnotation");
  7315. } else {
  7316. node.objectType = type;
  7317. node.indexType = this.flowParseType();
  7318. this.expect(3);
  7319. if (seenOptionalIndexedAccess) {
  7320. node.optional = optional;
  7321. type = this.finishNode(node, "OptionalIndexedAccessType");
  7322. } else {
  7323. type = this.finishNode(node, "IndexedAccessType");
  7324. }
  7325. }
  7326. }
  7327. return type;
  7328. }
  7329. flowParsePrefixType() {
  7330. const node = this.startNode();
  7331. if (this.eat(17)) {
  7332. node.typeAnnotation = this.flowParsePrefixType();
  7333. return this.finishNode(node, "NullableTypeAnnotation");
  7334. } else {
  7335. return this.flowParsePostfixType();
  7336. }
  7337. }
  7338. flowParseAnonFunctionWithoutParens() {
  7339. const param = this.flowParsePrefixType();
  7340. if (!this.state.noAnonFunctionType && this.eat(19)) {
  7341. const node = this.startNodeAt(param.loc.start);
  7342. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  7343. node.rest = null;
  7344. node.this = null;
  7345. node.returnType = this.flowParseType();
  7346. node.typeParameters = null;
  7347. return this.finishNode(node, "FunctionTypeAnnotation");
  7348. }
  7349. return param;
  7350. }
  7351. flowParseIntersectionType() {
  7352. const node = this.startNode();
  7353. this.eat(45);
  7354. const type = this.flowParseAnonFunctionWithoutParens();
  7355. node.types = [type];
  7356. while (this.eat(45)) {
  7357. node.types.push(this.flowParseAnonFunctionWithoutParens());
  7358. }
  7359. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  7360. }
  7361. flowParseUnionType() {
  7362. const node = this.startNode();
  7363. this.eat(43);
  7364. const type = this.flowParseIntersectionType();
  7365. node.types = [type];
  7366. while (this.eat(43)) {
  7367. node.types.push(this.flowParseIntersectionType());
  7368. }
  7369. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  7370. }
  7371. flowParseType() {
  7372. const oldInType = this.state.inType;
  7373. this.state.inType = true;
  7374. const type = this.flowParseUnionType();
  7375. this.state.inType = oldInType;
  7376. return type;
  7377. }
  7378. flowParseTypeOrImplicitInstantiation() {
  7379. if (this.state.type === 132 && this.state.value === "_") {
  7380. const startLoc = this.state.startLoc;
  7381. const node = this.parseIdentifier();
  7382. return this.flowParseGenericType(startLoc, node);
  7383. } else {
  7384. return this.flowParseType();
  7385. }
  7386. }
  7387. flowParseTypeAnnotation() {
  7388. const node = this.startNode();
  7389. node.typeAnnotation = this.flowParseTypeInitialiser();
  7390. return this.finishNode(node, "TypeAnnotation");
  7391. }
  7392. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  7393. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  7394. if (this.match(14)) {
  7395. ident.typeAnnotation = this.flowParseTypeAnnotation();
  7396. this.resetEndLocation(ident);
  7397. }
  7398. return ident;
  7399. }
  7400. typeCastToParameter(node) {
  7401. node.expression.typeAnnotation = node.typeAnnotation;
  7402. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  7403. return node.expression;
  7404. }
  7405. flowParseVariance() {
  7406. let variance = null;
  7407. if (this.match(53)) {
  7408. variance = this.startNode();
  7409. if (this.state.value === "+") {
  7410. variance.kind = "plus";
  7411. } else {
  7412. variance.kind = "minus";
  7413. }
  7414. this.next();
  7415. return this.finishNode(variance, "Variance");
  7416. }
  7417. return variance;
  7418. }
  7419. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  7420. if (allowExpressionBody) {
  7421. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  7422. return;
  7423. }
  7424. super.parseFunctionBody(node, false, isMethod);
  7425. }
  7426. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  7427. if (this.match(14)) {
  7428. const typeNode = this.startNode();
  7429. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  7430. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  7431. }
  7432. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  7433. }
  7434. parseStatementLike(flags) {
  7435. if (this.state.strict && this.isContextual(129)) {
  7436. const lookahead = this.lookahead();
  7437. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  7438. const node = this.startNode();
  7439. this.next();
  7440. return this.flowParseInterface(node);
  7441. }
  7442. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7443. const node = this.startNode();
  7444. this.next();
  7445. return this.flowParseEnumDeclaration(node);
  7446. }
  7447. const stmt = super.parseStatementLike(flags);
  7448. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  7449. this.flowPragma = null;
  7450. }
  7451. return stmt;
  7452. }
  7453. parseExpressionStatement(node, expr, decorators) {
  7454. if (expr.type === "Identifier") {
  7455. if (expr.name === "declare") {
  7456. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  7457. return this.flowParseDeclare(node);
  7458. }
  7459. } else if (tokenIsIdentifier(this.state.type)) {
  7460. if (expr.name === "interface") {
  7461. return this.flowParseInterface(node);
  7462. } else if (expr.name === "type") {
  7463. return this.flowParseTypeAlias(node);
  7464. } else if (expr.name === "opaque") {
  7465. return this.flowParseOpaqueType(node, false);
  7466. }
  7467. }
  7468. }
  7469. return super.parseExpressionStatement(node, expr, decorators);
  7470. }
  7471. shouldParseExportDeclaration() {
  7472. const {
  7473. type
  7474. } = this.state;
  7475. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7476. return !this.state.containsEsc;
  7477. }
  7478. return super.shouldParseExportDeclaration();
  7479. }
  7480. isExportDefaultSpecifier() {
  7481. const {
  7482. type
  7483. } = this.state;
  7484. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7485. return this.state.containsEsc;
  7486. }
  7487. return super.isExportDefaultSpecifier();
  7488. }
  7489. parseExportDefaultExpression() {
  7490. if (this.shouldParseEnums() && this.isContextual(126)) {
  7491. const node = this.startNode();
  7492. this.next();
  7493. return this.flowParseEnumDeclaration(node);
  7494. }
  7495. return super.parseExportDefaultExpression();
  7496. }
  7497. parseConditional(expr, startLoc, refExpressionErrors) {
  7498. if (!this.match(17)) return expr;
  7499. if (this.state.maybeInArrowParameters) {
  7500. const nextCh = this.lookaheadCharCode();
  7501. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  7502. this.setOptionalParametersError(refExpressionErrors);
  7503. return expr;
  7504. }
  7505. }
  7506. this.expect(17);
  7507. const state = this.state.clone();
  7508. const originalNoArrowAt = this.state.noArrowAt;
  7509. const node = this.startNodeAt(startLoc);
  7510. let {
  7511. consequent,
  7512. failed
  7513. } = this.tryParseConditionalConsequent();
  7514. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7515. if (failed || invalid.length > 0) {
  7516. const noArrowAt = [...originalNoArrowAt];
  7517. if (invalid.length > 0) {
  7518. this.state = state;
  7519. this.state.noArrowAt = noArrowAt;
  7520. for (let i = 0; i < invalid.length; i++) {
  7521. noArrowAt.push(invalid[i].start);
  7522. }
  7523. ({
  7524. consequent,
  7525. failed
  7526. } = this.tryParseConditionalConsequent());
  7527. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7528. }
  7529. if (failed && valid.length > 1) {
  7530. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  7531. }
  7532. if (failed && valid.length === 1) {
  7533. this.state = state;
  7534. noArrowAt.push(valid[0].start);
  7535. this.state.noArrowAt = noArrowAt;
  7536. ({
  7537. consequent,
  7538. failed
  7539. } = this.tryParseConditionalConsequent());
  7540. }
  7541. }
  7542. this.getArrowLikeExpressions(consequent, true);
  7543. this.state.noArrowAt = originalNoArrowAt;
  7544. this.expect(14);
  7545. node.test = expr;
  7546. node.consequent = consequent;
  7547. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  7548. return this.finishNode(node, "ConditionalExpression");
  7549. }
  7550. tryParseConditionalConsequent() {
  7551. this.state.noArrowParamsConversionAt.push(this.state.start);
  7552. const consequent = this.parseMaybeAssignAllowIn();
  7553. const failed = !this.match(14);
  7554. this.state.noArrowParamsConversionAt.pop();
  7555. return {
  7556. consequent,
  7557. failed
  7558. };
  7559. }
  7560. getArrowLikeExpressions(node, disallowInvalid) {
  7561. const stack = [node];
  7562. const arrows = [];
  7563. while (stack.length !== 0) {
  7564. const node = stack.pop();
  7565. if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
  7566. if (node.typeParameters || !node.returnType) {
  7567. this.finishArrowValidation(node);
  7568. } else {
  7569. arrows.push(node);
  7570. }
  7571. stack.push(node.body);
  7572. } else if (node.type === "ConditionalExpression") {
  7573. stack.push(node.consequent);
  7574. stack.push(node.alternate);
  7575. }
  7576. }
  7577. if (disallowInvalid) {
  7578. arrows.forEach(node => this.finishArrowValidation(node));
  7579. return [arrows, []];
  7580. }
  7581. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  7582. }
  7583. finishArrowValidation(node) {
  7584. var _node$extra;
  7585. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  7586. this.scope.enter(2 | 4);
  7587. super.checkParams(node, false, true);
  7588. this.scope.exit();
  7589. }
  7590. forwardNoArrowParamsConversionAt(node, parse) {
  7591. let result;
  7592. if (this.state.noArrowParamsConversionAt.includes(node.start)) {
  7593. this.state.noArrowParamsConversionAt.push(this.state.start);
  7594. result = parse();
  7595. this.state.noArrowParamsConversionAt.pop();
  7596. } else {
  7597. result = parse();
  7598. }
  7599. return result;
  7600. }
  7601. parseParenItem(node, startLoc) {
  7602. const newNode = super.parseParenItem(node, startLoc);
  7603. if (this.eat(17)) {
  7604. newNode.optional = true;
  7605. this.resetEndLocation(node);
  7606. }
  7607. if (this.match(14)) {
  7608. const typeCastNode = this.startNodeAt(startLoc);
  7609. typeCastNode.expression = newNode;
  7610. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  7611. return this.finishNode(typeCastNode, "TypeCastExpression");
  7612. }
  7613. return newNode;
  7614. }
  7615. assertModuleNodeAllowed(node) {
  7616. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  7617. return;
  7618. }
  7619. super.assertModuleNodeAllowed(node);
  7620. }
  7621. parseExportDeclaration(node) {
  7622. if (this.isContextual(130)) {
  7623. node.exportKind = "type";
  7624. const declarationNode = this.startNode();
  7625. this.next();
  7626. if (this.match(5)) {
  7627. node.specifiers = this.parseExportSpecifiers(true);
  7628. super.parseExportFrom(node);
  7629. return null;
  7630. } else {
  7631. return this.flowParseTypeAlias(declarationNode);
  7632. }
  7633. } else if (this.isContextual(131)) {
  7634. node.exportKind = "type";
  7635. const declarationNode = this.startNode();
  7636. this.next();
  7637. return this.flowParseOpaqueType(declarationNode, false);
  7638. } else if (this.isContextual(129)) {
  7639. node.exportKind = "type";
  7640. const declarationNode = this.startNode();
  7641. this.next();
  7642. return this.flowParseInterface(declarationNode);
  7643. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7644. node.exportKind = "value";
  7645. const declarationNode = this.startNode();
  7646. this.next();
  7647. return this.flowParseEnumDeclaration(declarationNode);
  7648. } else {
  7649. return super.parseExportDeclaration(node);
  7650. }
  7651. }
  7652. eatExportStar(node) {
  7653. if (super.eatExportStar(node)) return true;
  7654. if (this.isContextual(130) && this.lookahead().type === 55) {
  7655. node.exportKind = "type";
  7656. this.next();
  7657. this.next();
  7658. return true;
  7659. }
  7660. return false;
  7661. }
  7662. maybeParseExportNamespaceSpecifier(node) {
  7663. const {
  7664. startLoc
  7665. } = this.state;
  7666. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  7667. if (hasNamespace && node.exportKind === "type") {
  7668. this.unexpected(startLoc);
  7669. }
  7670. return hasNamespace;
  7671. }
  7672. parseClassId(node, isStatement, optionalId) {
  7673. super.parseClassId(node, isStatement, optionalId);
  7674. if (this.match(47)) {
  7675. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7676. }
  7677. }
  7678. parseClassMember(classBody, member, state) {
  7679. const {
  7680. startLoc
  7681. } = this.state;
  7682. if (this.isContextual(125)) {
  7683. if (super.parseClassMemberFromModifier(classBody, member)) {
  7684. return;
  7685. }
  7686. member.declare = true;
  7687. }
  7688. super.parseClassMember(classBody, member, state);
  7689. if (member.declare) {
  7690. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  7691. this.raise(FlowErrors.DeclareClassElement, startLoc);
  7692. } else if (member.value) {
  7693. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  7694. }
  7695. }
  7696. }
  7697. isIterator(word) {
  7698. return word === "iterator" || word === "asyncIterator";
  7699. }
  7700. readIterator() {
  7701. const word = super.readWord1();
  7702. const fullWord = "@@" + word;
  7703. if (!this.isIterator(word) || !this.state.inType) {
  7704. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  7705. identifierName: fullWord
  7706. });
  7707. }
  7708. this.finishToken(132, fullWord);
  7709. }
  7710. getTokenFromCode(code) {
  7711. const next = this.input.charCodeAt(this.state.pos + 1);
  7712. if (code === 123 && next === 124) {
  7713. this.finishOp(6, 2);
  7714. } else if (this.state.inType && (code === 62 || code === 60)) {
  7715. this.finishOp(code === 62 ? 48 : 47, 1);
  7716. } else if (this.state.inType && code === 63) {
  7717. if (next === 46) {
  7718. this.finishOp(18, 2);
  7719. } else {
  7720. this.finishOp(17, 1);
  7721. }
  7722. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  7723. this.state.pos += 2;
  7724. this.readIterator();
  7725. } else {
  7726. super.getTokenFromCode(code);
  7727. }
  7728. }
  7729. isAssignable(node, isBinding) {
  7730. if (node.type === "TypeCastExpression") {
  7731. return this.isAssignable(node.expression, isBinding);
  7732. } else {
  7733. return super.isAssignable(node, isBinding);
  7734. }
  7735. }
  7736. toAssignable(node, isLHS = false) {
  7737. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  7738. node.left = this.typeCastToParameter(node.left);
  7739. }
  7740. super.toAssignable(node, isLHS);
  7741. }
  7742. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  7743. for (let i = 0; i < exprList.length; i++) {
  7744. const expr = exprList[i];
  7745. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  7746. exprList[i] = this.typeCastToParameter(expr);
  7747. }
  7748. }
  7749. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  7750. }
  7751. toReferencedList(exprList, isParenthesizedExpr) {
  7752. for (let i = 0; i < exprList.length; i++) {
  7753. var _expr$extra;
  7754. const expr = exprList[i];
  7755. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  7756. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  7757. }
  7758. }
  7759. return exprList;
  7760. }
  7761. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  7762. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  7763. if (canBePattern && !this.state.maybeInArrowParameters) {
  7764. this.toReferencedList(node.elements);
  7765. }
  7766. return node;
  7767. }
  7768. isValidLVal(type, isParenthesized, binding) {
  7769. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  7770. }
  7771. parseClassProperty(node) {
  7772. if (this.match(14)) {
  7773. node.typeAnnotation = this.flowParseTypeAnnotation();
  7774. }
  7775. return super.parseClassProperty(node);
  7776. }
  7777. parseClassPrivateProperty(node) {
  7778. if (this.match(14)) {
  7779. node.typeAnnotation = this.flowParseTypeAnnotation();
  7780. }
  7781. return super.parseClassPrivateProperty(node);
  7782. }
  7783. isClassMethod() {
  7784. return this.match(47) || super.isClassMethod();
  7785. }
  7786. isClassProperty() {
  7787. return this.match(14) || super.isClassProperty();
  7788. }
  7789. isNonstaticConstructor(method) {
  7790. return !this.match(14) && super.isNonstaticConstructor(method);
  7791. }
  7792. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  7793. if (method.variance) {
  7794. this.unexpected(method.variance.loc.start);
  7795. }
  7796. delete method.variance;
  7797. if (this.match(47)) {
  7798. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7799. }
  7800. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  7801. if (method.params && isConstructor) {
  7802. const params = method.params;
  7803. if (params.length > 0 && this.isThisParam(params[0])) {
  7804. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7805. }
  7806. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  7807. const params = method.value.params;
  7808. if (params.length > 0 && this.isThisParam(params[0])) {
  7809. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7810. }
  7811. }
  7812. }
  7813. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  7814. if (method.variance) {
  7815. this.unexpected(method.variance.loc.start);
  7816. }
  7817. delete method.variance;
  7818. if (this.match(47)) {
  7819. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7820. }
  7821. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  7822. }
  7823. parseClassSuper(node) {
  7824. super.parseClassSuper(node);
  7825. if (node.superClass && this.match(47)) {
  7826. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  7827. }
  7828. if (this.isContextual(113)) {
  7829. this.next();
  7830. const implemented = node.implements = [];
  7831. do {
  7832. const node = this.startNode();
  7833. node.id = this.flowParseRestrictedIdentifier(true);
  7834. if (this.match(47)) {
  7835. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7836. } else {
  7837. node.typeParameters = null;
  7838. }
  7839. implemented.push(this.finishNode(node, "ClassImplements"));
  7840. } while (this.eat(12));
  7841. }
  7842. }
  7843. checkGetterSetterParams(method) {
  7844. super.checkGetterSetterParams(method);
  7845. const params = this.getObjectOrClassMethodParams(method);
  7846. if (params.length > 0) {
  7847. const param = params[0];
  7848. if (this.isThisParam(param) && method.kind === "get") {
  7849. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  7850. } else if (this.isThisParam(param)) {
  7851. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  7852. }
  7853. }
  7854. }
  7855. parsePropertyNamePrefixOperator(node) {
  7856. node.variance = this.flowParseVariance();
  7857. }
  7858. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  7859. if (prop.variance) {
  7860. this.unexpected(prop.variance.loc.start);
  7861. }
  7862. delete prop.variance;
  7863. let typeParameters;
  7864. if (this.match(47) && !isAccessor) {
  7865. typeParameters = this.flowParseTypeParameterDeclaration();
  7866. if (!this.match(10)) this.unexpected();
  7867. }
  7868. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  7869. if (typeParameters) {
  7870. (result.value || result).typeParameters = typeParameters;
  7871. }
  7872. return result;
  7873. }
  7874. parseAssignableListItemTypes(param) {
  7875. if (this.eat(17)) {
  7876. if (param.type !== "Identifier") {
  7877. this.raise(FlowErrors.PatternIsOptional, param);
  7878. }
  7879. if (this.isThisParam(param)) {
  7880. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  7881. }
  7882. param.optional = true;
  7883. }
  7884. if (this.match(14)) {
  7885. param.typeAnnotation = this.flowParseTypeAnnotation();
  7886. } else if (this.isThisParam(param)) {
  7887. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  7888. }
  7889. if (this.match(29) && this.isThisParam(param)) {
  7890. this.raise(FlowErrors.ThisParamNoDefault, param);
  7891. }
  7892. this.resetEndLocation(param);
  7893. return param;
  7894. }
  7895. parseMaybeDefault(startLoc, left) {
  7896. const node = super.parseMaybeDefault(startLoc, left);
  7897. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  7898. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  7899. }
  7900. return node;
  7901. }
  7902. checkImportReflection(node) {
  7903. super.checkImportReflection(node);
  7904. if (node.module && node.importKind !== "value") {
  7905. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  7906. }
  7907. }
  7908. parseImportSpecifierLocal(node, specifier, type) {
  7909. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  7910. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  7911. }
  7912. isPotentialImportPhase(isExport) {
  7913. if (super.isPotentialImportPhase(isExport)) return true;
  7914. if (this.isContextual(130)) {
  7915. if (!isExport) return true;
  7916. const ch = this.lookaheadCharCode();
  7917. return ch === 123 || ch === 42;
  7918. }
  7919. return !isExport && this.isContextual(87);
  7920. }
  7921. applyImportPhase(node, isExport, phase, loc) {
  7922. super.applyImportPhase(node, isExport, phase, loc);
  7923. if (isExport) {
  7924. if (!phase && this.match(65)) {
  7925. return;
  7926. }
  7927. node.exportKind = phase === "type" ? phase : "value";
  7928. } else {
  7929. if (phase === "type" && this.match(55)) this.unexpected();
  7930. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  7931. }
  7932. }
  7933. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  7934. const firstIdent = specifier.imported;
  7935. let specifierTypeKind = null;
  7936. if (firstIdent.type === "Identifier") {
  7937. if (firstIdent.name === "type") {
  7938. specifierTypeKind = "type";
  7939. } else if (firstIdent.name === "typeof") {
  7940. specifierTypeKind = "typeof";
  7941. }
  7942. }
  7943. let isBinding = false;
  7944. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  7945. const as_ident = this.parseIdentifier(true);
  7946. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  7947. specifier.imported = as_ident;
  7948. specifier.importKind = specifierTypeKind;
  7949. specifier.local = cloneIdentifier(as_ident);
  7950. } else {
  7951. specifier.imported = firstIdent;
  7952. specifier.importKind = null;
  7953. specifier.local = this.parseIdentifier();
  7954. }
  7955. } else {
  7956. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  7957. specifier.imported = this.parseIdentifier(true);
  7958. specifier.importKind = specifierTypeKind;
  7959. } else {
  7960. if (importedIsString) {
  7961. throw this.raise(Errors.ImportBindingIsString, specifier, {
  7962. importName: firstIdent.value
  7963. });
  7964. }
  7965. specifier.imported = firstIdent;
  7966. specifier.importKind = null;
  7967. }
  7968. if (this.eatContextual(93)) {
  7969. specifier.local = this.parseIdentifier();
  7970. } else {
  7971. isBinding = true;
  7972. specifier.local = cloneIdentifier(specifier.imported);
  7973. }
  7974. }
  7975. const specifierIsTypeImport = hasTypeImportKind(specifier);
  7976. if (isInTypeOnlyImport && specifierIsTypeImport) {
  7977. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  7978. }
  7979. if (isInTypeOnlyImport || specifierIsTypeImport) {
  7980. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  7981. }
  7982. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  7983. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  7984. }
  7985. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  7986. }
  7987. parseBindingAtom() {
  7988. switch (this.state.type) {
  7989. case 78:
  7990. return this.parseIdentifier(true);
  7991. default:
  7992. return super.parseBindingAtom();
  7993. }
  7994. }
  7995. parseFunctionParams(node, isConstructor) {
  7996. const kind = node.kind;
  7997. if (kind !== "get" && kind !== "set" && this.match(47)) {
  7998. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7999. }
  8000. super.parseFunctionParams(node, isConstructor);
  8001. }
  8002. parseVarId(decl, kind) {
  8003. super.parseVarId(decl, kind);
  8004. if (this.match(14)) {
  8005. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  8006. this.resetEndLocation(decl.id);
  8007. }
  8008. }
  8009. parseAsyncArrowFromCallExpression(node, call) {
  8010. if (this.match(14)) {
  8011. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8012. this.state.noAnonFunctionType = true;
  8013. node.returnType = this.flowParseTypeAnnotation();
  8014. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8015. }
  8016. return super.parseAsyncArrowFromCallExpression(node, call);
  8017. }
  8018. shouldParseAsyncArrow() {
  8019. return this.match(14) || super.shouldParseAsyncArrow();
  8020. }
  8021. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  8022. var _jsx;
  8023. let state = null;
  8024. let jsx;
  8025. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  8026. state = this.state.clone();
  8027. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  8028. if (!jsx.error) return jsx.node;
  8029. const {
  8030. context
  8031. } = this.state;
  8032. const currentContext = context[context.length - 1];
  8033. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  8034. context.pop();
  8035. }
  8036. }
  8037. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  8038. var _jsx2, _jsx3;
  8039. state = state || this.state.clone();
  8040. let typeParameters;
  8041. const arrow = this.tryParse(abort => {
  8042. var _arrowExpression$extr;
  8043. typeParameters = this.flowParseTypeParameterDeclaration();
  8044. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  8045. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8046. this.resetStartLocationFromNode(result, typeParameters);
  8047. return result;
  8048. });
  8049. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  8050. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  8051. if (expr.type !== "ArrowFunctionExpression") abort();
  8052. expr.typeParameters = typeParameters;
  8053. this.resetStartLocationFromNode(expr, typeParameters);
  8054. return arrowExpression;
  8055. }, state);
  8056. let arrowExpression = null;
  8057. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  8058. if (!arrow.error && !arrow.aborted) {
  8059. if (arrow.node.async) {
  8060. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  8061. }
  8062. return arrow.node;
  8063. }
  8064. arrowExpression = arrow.node;
  8065. }
  8066. if ((_jsx2 = jsx) != null && _jsx2.node) {
  8067. this.state = jsx.failState;
  8068. return jsx.node;
  8069. }
  8070. if (arrowExpression) {
  8071. this.state = arrow.failState;
  8072. return arrowExpression;
  8073. }
  8074. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  8075. if (arrow.thrown) throw arrow.error;
  8076. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  8077. }
  8078. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8079. }
  8080. parseArrow(node) {
  8081. if (this.match(14)) {
  8082. const result = this.tryParse(() => {
  8083. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8084. this.state.noAnonFunctionType = true;
  8085. const typeNode = this.startNode();
  8086. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  8087. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8088. if (this.canInsertSemicolon()) this.unexpected();
  8089. if (!this.match(19)) this.unexpected();
  8090. return typeNode;
  8091. });
  8092. if (result.thrown) return null;
  8093. if (result.error) this.state = result.failState;
  8094. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  8095. }
  8096. return super.parseArrow(node);
  8097. }
  8098. shouldParseArrow(params) {
  8099. return this.match(14) || super.shouldParseArrow(params);
  8100. }
  8101. setArrowFunctionParameters(node, params) {
  8102. if (this.state.noArrowParamsConversionAt.includes(node.start)) {
  8103. node.params = params;
  8104. } else {
  8105. super.setArrowFunctionParameters(node, params);
  8106. }
  8107. }
  8108. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  8109. if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(node.start)) {
  8110. return;
  8111. }
  8112. for (let i = 0; i < node.params.length; i++) {
  8113. if (this.isThisParam(node.params[i]) && i > 0) {
  8114. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  8115. }
  8116. }
  8117. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  8118. }
  8119. parseParenAndDistinguishExpression(canBeArrow) {
  8120. return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.state.start));
  8121. }
  8122. parseSubscripts(base, startLoc, noCalls) {
  8123. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
  8124. this.next();
  8125. const node = this.startNodeAt(startLoc);
  8126. node.callee = base;
  8127. node.arguments = super.parseCallExpressionArguments(11, false);
  8128. base = this.finishNode(node, "CallExpression");
  8129. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  8130. const state = this.state.clone();
  8131. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  8132. if (!arrow.error && !arrow.aborted) return arrow.node;
  8133. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  8134. if (result.node && !result.error) return result.node;
  8135. if (arrow.node) {
  8136. this.state = arrow.failState;
  8137. return arrow.node;
  8138. }
  8139. if (result.node) {
  8140. this.state = result.failState;
  8141. return result.node;
  8142. }
  8143. throw arrow.error || result.error;
  8144. }
  8145. return super.parseSubscripts(base, startLoc, noCalls);
  8146. }
  8147. parseSubscript(base, startLoc, noCalls, subscriptState) {
  8148. if (this.match(18) && this.isLookaheadToken_lt()) {
  8149. subscriptState.optionalChainMember = true;
  8150. if (noCalls) {
  8151. subscriptState.stop = true;
  8152. return base;
  8153. }
  8154. this.next();
  8155. const node = this.startNodeAt(startLoc);
  8156. node.callee = base;
  8157. node.typeArguments = this.flowParseTypeParameterInstantiation();
  8158. this.expect(10);
  8159. node.arguments = this.parseCallExpressionArguments(11, false);
  8160. node.optional = true;
  8161. return this.finishCallExpression(node, true);
  8162. } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {
  8163. const node = this.startNodeAt(startLoc);
  8164. node.callee = base;
  8165. const result = this.tryParse(() => {
  8166. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  8167. this.expect(10);
  8168. node.arguments = super.parseCallExpressionArguments(11, false);
  8169. if (subscriptState.optionalChainMember) {
  8170. node.optional = false;
  8171. }
  8172. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  8173. });
  8174. if (result.node) {
  8175. if (result.error) this.state = result.failState;
  8176. return result.node;
  8177. }
  8178. }
  8179. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  8180. }
  8181. parseNewCallee(node) {
  8182. super.parseNewCallee(node);
  8183. let targs = null;
  8184. if (this.shouldParseTypes() && this.match(47)) {
  8185. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  8186. }
  8187. node.typeArguments = targs;
  8188. }
  8189. parseAsyncArrowWithTypeParameters(startLoc) {
  8190. const node = this.startNodeAt(startLoc);
  8191. this.parseFunctionParams(node, false);
  8192. if (!this.parseArrow(node)) return;
  8193. return super.parseArrowExpression(node, undefined, true);
  8194. }
  8195. readToken_mult_modulo(code) {
  8196. const next = this.input.charCodeAt(this.state.pos + 1);
  8197. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  8198. this.state.hasFlowComment = false;
  8199. this.state.pos += 2;
  8200. this.nextToken();
  8201. return;
  8202. }
  8203. super.readToken_mult_modulo(code);
  8204. }
  8205. readToken_pipe_amp(code) {
  8206. const next = this.input.charCodeAt(this.state.pos + 1);
  8207. if (code === 124 && next === 125) {
  8208. this.finishOp(9, 2);
  8209. return;
  8210. }
  8211. super.readToken_pipe_amp(code);
  8212. }
  8213. parseTopLevel(file, program) {
  8214. const fileNode = super.parseTopLevel(file, program);
  8215. if (this.state.hasFlowComment) {
  8216. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  8217. }
  8218. return fileNode;
  8219. }
  8220. skipBlockComment() {
  8221. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  8222. if (this.state.hasFlowComment) {
  8223. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  8224. }
  8225. this.hasFlowCommentCompletion();
  8226. const commentSkip = this.skipFlowComment();
  8227. if (commentSkip) {
  8228. this.state.pos += commentSkip;
  8229. this.state.hasFlowComment = true;
  8230. }
  8231. return;
  8232. }
  8233. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  8234. }
  8235. skipFlowComment() {
  8236. const {
  8237. pos
  8238. } = this.state;
  8239. let shiftToFirstNonWhiteSpace = 2;
  8240. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  8241. shiftToFirstNonWhiteSpace++;
  8242. }
  8243. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  8244. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  8245. if (ch2 === 58 && ch3 === 58) {
  8246. return shiftToFirstNonWhiteSpace + 2;
  8247. }
  8248. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  8249. return shiftToFirstNonWhiteSpace + 12;
  8250. }
  8251. if (ch2 === 58 && ch3 !== 58) {
  8252. return shiftToFirstNonWhiteSpace;
  8253. }
  8254. return false;
  8255. }
  8256. hasFlowCommentCompletion() {
  8257. const end = this.input.indexOf("*/", this.state.pos);
  8258. if (end === -1) {
  8259. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8260. }
  8261. }
  8262. flowEnumErrorBooleanMemberNotInitialized(loc, {
  8263. enumName,
  8264. memberName
  8265. }) {
  8266. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  8267. memberName,
  8268. enumName
  8269. });
  8270. }
  8271. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  8272. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  8273. }
  8274. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  8275. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  8276. }
  8277. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  8278. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  8279. }
  8280. flowEnumMemberInit() {
  8281. const startLoc = this.state.startLoc;
  8282. const endOfInit = () => this.match(12) || this.match(8);
  8283. switch (this.state.type) {
  8284. case 134:
  8285. {
  8286. const literal = this.parseNumericLiteral(this.state.value);
  8287. if (endOfInit()) {
  8288. return {
  8289. type: "number",
  8290. loc: literal.loc.start,
  8291. value: literal
  8292. };
  8293. }
  8294. return {
  8295. type: "invalid",
  8296. loc: startLoc
  8297. };
  8298. }
  8299. case 133:
  8300. {
  8301. const literal = this.parseStringLiteral(this.state.value);
  8302. if (endOfInit()) {
  8303. return {
  8304. type: "string",
  8305. loc: literal.loc.start,
  8306. value: literal
  8307. };
  8308. }
  8309. return {
  8310. type: "invalid",
  8311. loc: startLoc
  8312. };
  8313. }
  8314. case 85:
  8315. case 86:
  8316. {
  8317. const literal = this.parseBooleanLiteral(this.match(85));
  8318. if (endOfInit()) {
  8319. return {
  8320. type: "boolean",
  8321. loc: literal.loc.start,
  8322. value: literal
  8323. };
  8324. }
  8325. return {
  8326. type: "invalid",
  8327. loc: startLoc
  8328. };
  8329. }
  8330. default:
  8331. return {
  8332. type: "invalid",
  8333. loc: startLoc
  8334. };
  8335. }
  8336. }
  8337. flowEnumMemberRaw() {
  8338. const loc = this.state.startLoc;
  8339. const id = this.parseIdentifier(true);
  8340. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  8341. type: "none",
  8342. loc
  8343. };
  8344. return {
  8345. id,
  8346. init
  8347. };
  8348. }
  8349. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  8350. const {
  8351. explicitType
  8352. } = context;
  8353. if (explicitType === null) {
  8354. return;
  8355. }
  8356. if (explicitType !== expectedType) {
  8357. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  8358. }
  8359. }
  8360. flowEnumMembers({
  8361. enumName,
  8362. explicitType
  8363. }) {
  8364. const seenNames = new Set();
  8365. const members = {
  8366. booleanMembers: [],
  8367. numberMembers: [],
  8368. stringMembers: [],
  8369. defaultedMembers: []
  8370. };
  8371. let hasUnknownMembers = false;
  8372. while (!this.match(8)) {
  8373. if (this.eat(21)) {
  8374. hasUnknownMembers = true;
  8375. break;
  8376. }
  8377. const memberNode = this.startNode();
  8378. const {
  8379. id,
  8380. init
  8381. } = this.flowEnumMemberRaw();
  8382. const memberName = id.name;
  8383. if (memberName === "") {
  8384. continue;
  8385. }
  8386. if (/^[a-z]/.test(memberName)) {
  8387. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  8388. memberName,
  8389. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  8390. enumName
  8391. });
  8392. }
  8393. if (seenNames.has(memberName)) {
  8394. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  8395. memberName,
  8396. enumName
  8397. });
  8398. }
  8399. seenNames.add(memberName);
  8400. const context = {
  8401. enumName,
  8402. explicitType,
  8403. memberName
  8404. };
  8405. memberNode.id = id;
  8406. switch (init.type) {
  8407. case "boolean":
  8408. {
  8409. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  8410. memberNode.init = init.value;
  8411. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  8412. break;
  8413. }
  8414. case "number":
  8415. {
  8416. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  8417. memberNode.init = init.value;
  8418. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  8419. break;
  8420. }
  8421. case "string":
  8422. {
  8423. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  8424. memberNode.init = init.value;
  8425. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  8426. break;
  8427. }
  8428. case "invalid":
  8429. {
  8430. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  8431. }
  8432. case "none":
  8433. {
  8434. switch (explicitType) {
  8435. case "boolean":
  8436. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  8437. break;
  8438. case "number":
  8439. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  8440. break;
  8441. default:
  8442. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  8443. }
  8444. }
  8445. }
  8446. if (!this.match(8)) {
  8447. this.expect(12);
  8448. }
  8449. }
  8450. return {
  8451. members,
  8452. hasUnknownMembers
  8453. };
  8454. }
  8455. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  8456. enumName
  8457. }) {
  8458. if (initializedMembers.length === 0) {
  8459. return defaultedMembers;
  8460. } else if (defaultedMembers.length === 0) {
  8461. return initializedMembers;
  8462. } else if (defaultedMembers.length > initializedMembers.length) {
  8463. for (const member of initializedMembers) {
  8464. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8465. enumName
  8466. });
  8467. }
  8468. return defaultedMembers;
  8469. } else {
  8470. for (const member of defaultedMembers) {
  8471. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8472. enumName
  8473. });
  8474. }
  8475. return initializedMembers;
  8476. }
  8477. }
  8478. flowEnumParseExplicitType({
  8479. enumName
  8480. }) {
  8481. if (!this.eatContextual(102)) return null;
  8482. if (!tokenIsIdentifier(this.state.type)) {
  8483. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  8484. enumName
  8485. });
  8486. }
  8487. const {
  8488. value
  8489. } = this.state;
  8490. this.next();
  8491. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  8492. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  8493. enumName,
  8494. invalidEnumType: value
  8495. });
  8496. }
  8497. return value;
  8498. }
  8499. flowEnumBody(node, id) {
  8500. const enumName = id.name;
  8501. const nameLoc = id.loc.start;
  8502. const explicitType = this.flowEnumParseExplicitType({
  8503. enumName
  8504. });
  8505. this.expect(5);
  8506. const {
  8507. members,
  8508. hasUnknownMembers
  8509. } = this.flowEnumMembers({
  8510. enumName,
  8511. explicitType
  8512. });
  8513. node.hasUnknownMembers = hasUnknownMembers;
  8514. switch (explicitType) {
  8515. case "boolean":
  8516. node.explicitType = true;
  8517. node.members = members.booleanMembers;
  8518. this.expect(8);
  8519. return this.finishNode(node, "EnumBooleanBody");
  8520. case "number":
  8521. node.explicitType = true;
  8522. node.members = members.numberMembers;
  8523. this.expect(8);
  8524. return this.finishNode(node, "EnumNumberBody");
  8525. case "string":
  8526. node.explicitType = true;
  8527. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8528. enumName
  8529. });
  8530. this.expect(8);
  8531. return this.finishNode(node, "EnumStringBody");
  8532. case "symbol":
  8533. node.members = members.defaultedMembers;
  8534. this.expect(8);
  8535. return this.finishNode(node, "EnumSymbolBody");
  8536. default:
  8537. {
  8538. const empty = () => {
  8539. node.members = [];
  8540. this.expect(8);
  8541. return this.finishNode(node, "EnumStringBody");
  8542. };
  8543. node.explicitType = false;
  8544. const boolsLen = members.booleanMembers.length;
  8545. const numsLen = members.numberMembers.length;
  8546. const strsLen = members.stringMembers.length;
  8547. const defaultedLen = members.defaultedMembers.length;
  8548. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  8549. return empty();
  8550. } else if (!boolsLen && !numsLen) {
  8551. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8552. enumName
  8553. });
  8554. this.expect(8);
  8555. return this.finishNode(node, "EnumStringBody");
  8556. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  8557. for (const member of members.defaultedMembers) {
  8558. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  8559. enumName,
  8560. memberName: member.id.name
  8561. });
  8562. }
  8563. node.members = members.booleanMembers;
  8564. this.expect(8);
  8565. return this.finishNode(node, "EnumBooleanBody");
  8566. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  8567. for (const member of members.defaultedMembers) {
  8568. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  8569. enumName,
  8570. memberName: member.id.name
  8571. });
  8572. }
  8573. node.members = members.numberMembers;
  8574. this.expect(8);
  8575. return this.finishNode(node, "EnumNumberBody");
  8576. } else {
  8577. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  8578. enumName
  8579. });
  8580. return empty();
  8581. }
  8582. }
  8583. }
  8584. }
  8585. flowParseEnumDeclaration(node) {
  8586. const id = this.parseIdentifier();
  8587. node.id = id;
  8588. node.body = this.flowEnumBody(this.startNode(), id);
  8589. return this.finishNode(node, "EnumDeclaration");
  8590. }
  8591. isLookaheadToken_lt() {
  8592. const next = this.nextTokenStart();
  8593. if (this.input.charCodeAt(next) === 60) {
  8594. const afterNext = this.input.charCodeAt(next + 1);
  8595. return afterNext !== 60 && afterNext !== 61;
  8596. }
  8597. return false;
  8598. }
  8599. maybeUnwrapTypeCastExpression(node) {
  8600. return node.type === "TypeCastExpression" ? node.expression : node;
  8601. }
  8602. };
  8603. const entities = {
  8604. __proto__: null,
  8605. quot: "\u0022",
  8606. amp: "&",
  8607. apos: "\u0027",
  8608. lt: "<",
  8609. gt: ">",
  8610. nbsp: "\u00A0",
  8611. iexcl: "\u00A1",
  8612. cent: "\u00A2",
  8613. pound: "\u00A3",
  8614. curren: "\u00A4",
  8615. yen: "\u00A5",
  8616. brvbar: "\u00A6",
  8617. sect: "\u00A7",
  8618. uml: "\u00A8",
  8619. copy: "\u00A9",
  8620. ordf: "\u00AA",
  8621. laquo: "\u00AB",
  8622. not: "\u00AC",
  8623. shy: "\u00AD",
  8624. reg: "\u00AE",
  8625. macr: "\u00AF",
  8626. deg: "\u00B0",
  8627. plusmn: "\u00B1",
  8628. sup2: "\u00B2",
  8629. sup3: "\u00B3",
  8630. acute: "\u00B4",
  8631. micro: "\u00B5",
  8632. para: "\u00B6",
  8633. middot: "\u00B7",
  8634. cedil: "\u00B8",
  8635. sup1: "\u00B9",
  8636. ordm: "\u00BA",
  8637. raquo: "\u00BB",
  8638. frac14: "\u00BC",
  8639. frac12: "\u00BD",
  8640. frac34: "\u00BE",
  8641. iquest: "\u00BF",
  8642. Agrave: "\u00C0",
  8643. Aacute: "\u00C1",
  8644. Acirc: "\u00C2",
  8645. Atilde: "\u00C3",
  8646. Auml: "\u00C4",
  8647. Aring: "\u00C5",
  8648. AElig: "\u00C6",
  8649. Ccedil: "\u00C7",
  8650. Egrave: "\u00C8",
  8651. Eacute: "\u00C9",
  8652. Ecirc: "\u00CA",
  8653. Euml: "\u00CB",
  8654. Igrave: "\u00CC",
  8655. Iacute: "\u00CD",
  8656. Icirc: "\u00CE",
  8657. Iuml: "\u00CF",
  8658. ETH: "\u00D0",
  8659. Ntilde: "\u00D1",
  8660. Ograve: "\u00D2",
  8661. Oacute: "\u00D3",
  8662. Ocirc: "\u00D4",
  8663. Otilde: "\u00D5",
  8664. Ouml: "\u00D6",
  8665. times: "\u00D7",
  8666. Oslash: "\u00D8",
  8667. Ugrave: "\u00D9",
  8668. Uacute: "\u00DA",
  8669. Ucirc: "\u00DB",
  8670. Uuml: "\u00DC",
  8671. Yacute: "\u00DD",
  8672. THORN: "\u00DE",
  8673. szlig: "\u00DF",
  8674. agrave: "\u00E0",
  8675. aacute: "\u00E1",
  8676. acirc: "\u00E2",
  8677. atilde: "\u00E3",
  8678. auml: "\u00E4",
  8679. aring: "\u00E5",
  8680. aelig: "\u00E6",
  8681. ccedil: "\u00E7",
  8682. egrave: "\u00E8",
  8683. eacute: "\u00E9",
  8684. ecirc: "\u00EA",
  8685. euml: "\u00EB",
  8686. igrave: "\u00EC",
  8687. iacute: "\u00ED",
  8688. icirc: "\u00EE",
  8689. iuml: "\u00EF",
  8690. eth: "\u00F0",
  8691. ntilde: "\u00F1",
  8692. ograve: "\u00F2",
  8693. oacute: "\u00F3",
  8694. ocirc: "\u00F4",
  8695. otilde: "\u00F5",
  8696. ouml: "\u00F6",
  8697. divide: "\u00F7",
  8698. oslash: "\u00F8",
  8699. ugrave: "\u00F9",
  8700. uacute: "\u00FA",
  8701. ucirc: "\u00FB",
  8702. uuml: "\u00FC",
  8703. yacute: "\u00FD",
  8704. thorn: "\u00FE",
  8705. yuml: "\u00FF",
  8706. OElig: "\u0152",
  8707. oelig: "\u0153",
  8708. Scaron: "\u0160",
  8709. scaron: "\u0161",
  8710. Yuml: "\u0178",
  8711. fnof: "\u0192",
  8712. circ: "\u02C6",
  8713. tilde: "\u02DC",
  8714. Alpha: "\u0391",
  8715. Beta: "\u0392",
  8716. Gamma: "\u0393",
  8717. Delta: "\u0394",
  8718. Epsilon: "\u0395",
  8719. Zeta: "\u0396",
  8720. Eta: "\u0397",
  8721. Theta: "\u0398",
  8722. Iota: "\u0399",
  8723. Kappa: "\u039A",
  8724. Lambda: "\u039B",
  8725. Mu: "\u039C",
  8726. Nu: "\u039D",
  8727. Xi: "\u039E",
  8728. Omicron: "\u039F",
  8729. Pi: "\u03A0",
  8730. Rho: "\u03A1",
  8731. Sigma: "\u03A3",
  8732. Tau: "\u03A4",
  8733. Upsilon: "\u03A5",
  8734. Phi: "\u03A6",
  8735. Chi: "\u03A7",
  8736. Psi: "\u03A8",
  8737. Omega: "\u03A9",
  8738. alpha: "\u03B1",
  8739. beta: "\u03B2",
  8740. gamma: "\u03B3",
  8741. delta: "\u03B4",
  8742. epsilon: "\u03B5",
  8743. zeta: "\u03B6",
  8744. eta: "\u03B7",
  8745. theta: "\u03B8",
  8746. iota: "\u03B9",
  8747. kappa: "\u03BA",
  8748. lambda: "\u03BB",
  8749. mu: "\u03BC",
  8750. nu: "\u03BD",
  8751. xi: "\u03BE",
  8752. omicron: "\u03BF",
  8753. pi: "\u03C0",
  8754. rho: "\u03C1",
  8755. sigmaf: "\u03C2",
  8756. sigma: "\u03C3",
  8757. tau: "\u03C4",
  8758. upsilon: "\u03C5",
  8759. phi: "\u03C6",
  8760. chi: "\u03C7",
  8761. psi: "\u03C8",
  8762. omega: "\u03C9",
  8763. thetasym: "\u03D1",
  8764. upsih: "\u03D2",
  8765. piv: "\u03D6",
  8766. ensp: "\u2002",
  8767. emsp: "\u2003",
  8768. thinsp: "\u2009",
  8769. zwnj: "\u200C",
  8770. zwj: "\u200D",
  8771. lrm: "\u200E",
  8772. rlm: "\u200F",
  8773. ndash: "\u2013",
  8774. mdash: "\u2014",
  8775. lsquo: "\u2018",
  8776. rsquo: "\u2019",
  8777. sbquo: "\u201A",
  8778. ldquo: "\u201C",
  8779. rdquo: "\u201D",
  8780. bdquo: "\u201E",
  8781. dagger: "\u2020",
  8782. Dagger: "\u2021",
  8783. bull: "\u2022",
  8784. hellip: "\u2026",
  8785. permil: "\u2030",
  8786. prime: "\u2032",
  8787. Prime: "\u2033",
  8788. lsaquo: "\u2039",
  8789. rsaquo: "\u203A",
  8790. oline: "\u203E",
  8791. frasl: "\u2044",
  8792. euro: "\u20AC",
  8793. image: "\u2111",
  8794. weierp: "\u2118",
  8795. real: "\u211C",
  8796. trade: "\u2122",
  8797. alefsym: "\u2135",
  8798. larr: "\u2190",
  8799. uarr: "\u2191",
  8800. rarr: "\u2192",
  8801. darr: "\u2193",
  8802. harr: "\u2194",
  8803. crarr: "\u21B5",
  8804. lArr: "\u21D0",
  8805. uArr: "\u21D1",
  8806. rArr: "\u21D2",
  8807. dArr: "\u21D3",
  8808. hArr: "\u21D4",
  8809. forall: "\u2200",
  8810. part: "\u2202",
  8811. exist: "\u2203",
  8812. empty: "\u2205",
  8813. nabla: "\u2207",
  8814. isin: "\u2208",
  8815. notin: "\u2209",
  8816. ni: "\u220B",
  8817. prod: "\u220F",
  8818. sum: "\u2211",
  8819. minus: "\u2212",
  8820. lowast: "\u2217",
  8821. radic: "\u221A",
  8822. prop: "\u221D",
  8823. infin: "\u221E",
  8824. ang: "\u2220",
  8825. and: "\u2227",
  8826. or: "\u2228",
  8827. cap: "\u2229",
  8828. cup: "\u222A",
  8829. int: "\u222B",
  8830. there4: "\u2234",
  8831. sim: "\u223C",
  8832. cong: "\u2245",
  8833. asymp: "\u2248",
  8834. ne: "\u2260",
  8835. equiv: "\u2261",
  8836. le: "\u2264",
  8837. ge: "\u2265",
  8838. sub: "\u2282",
  8839. sup: "\u2283",
  8840. nsub: "\u2284",
  8841. sube: "\u2286",
  8842. supe: "\u2287",
  8843. oplus: "\u2295",
  8844. otimes: "\u2297",
  8845. perp: "\u22A5",
  8846. sdot: "\u22C5",
  8847. lceil: "\u2308",
  8848. rceil: "\u2309",
  8849. lfloor: "\u230A",
  8850. rfloor: "\u230B",
  8851. lang: "\u2329",
  8852. rang: "\u232A",
  8853. loz: "\u25CA",
  8854. spades: "\u2660",
  8855. clubs: "\u2663",
  8856. hearts: "\u2665",
  8857. diams: "\u2666"
  8858. };
  8859. const JsxErrors = ParseErrorEnum`jsx`({
  8860. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  8861. MissingClosingTagElement: ({
  8862. openingTagName
  8863. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  8864. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  8865. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  8866. UnexpectedToken: ({
  8867. unexpected,
  8868. HTMLEntity
  8869. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  8870. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  8871. UnterminatedJsxContent: "Unterminated JSX contents.",
  8872. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  8873. });
  8874. function isFragment(object) {
  8875. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  8876. }
  8877. function getQualifiedJSXName(object) {
  8878. if (object.type === "JSXIdentifier") {
  8879. return object.name;
  8880. }
  8881. if (object.type === "JSXNamespacedName") {
  8882. return object.namespace.name + ":" + object.name.name;
  8883. }
  8884. if (object.type === "JSXMemberExpression") {
  8885. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  8886. }
  8887. throw new Error("Node had unexpected type: " + object.type);
  8888. }
  8889. var jsx = superClass => class JSXParserMixin extends superClass {
  8890. jsxReadToken() {
  8891. let out = "";
  8892. let chunkStart = this.state.pos;
  8893. for (;;) {
  8894. if (this.state.pos >= this.length) {
  8895. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  8896. }
  8897. const ch = this.input.charCodeAt(this.state.pos);
  8898. switch (ch) {
  8899. case 60:
  8900. case 123:
  8901. if (this.state.pos === this.state.start) {
  8902. if (ch === 60 && this.state.canStartJSXElement) {
  8903. ++this.state.pos;
  8904. this.finishToken(142);
  8905. } else {
  8906. super.getTokenFromCode(ch);
  8907. }
  8908. return;
  8909. }
  8910. out += this.input.slice(chunkStart, this.state.pos);
  8911. this.finishToken(141, out);
  8912. return;
  8913. case 38:
  8914. out += this.input.slice(chunkStart, this.state.pos);
  8915. out += this.jsxReadEntity();
  8916. chunkStart = this.state.pos;
  8917. break;
  8918. case 62:
  8919. case 125:
  8920. default:
  8921. if (isNewLine(ch)) {
  8922. out += this.input.slice(chunkStart, this.state.pos);
  8923. out += this.jsxReadNewLine(true);
  8924. chunkStart = this.state.pos;
  8925. } else {
  8926. ++this.state.pos;
  8927. }
  8928. }
  8929. }
  8930. }
  8931. jsxReadNewLine(normalizeCRLF) {
  8932. const ch = this.input.charCodeAt(this.state.pos);
  8933. let out;
  8934. ++this.state.pos;
  8935. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  8936. ++this.state.pos;
  8937. out = normalizeCRLF ? "\n" : "\r\n";
  8938. } else {
  8939. out = String.fromCharCode(ch);
  8940. }
  8941. ++this.state.curLine;
  8942. this.state.lineStart = this.state.pos;
  8943. return out;
  8944. }
  8945. jsxReadString(quote) {
  8946. let out = "";
  8947. let chunkStart = ++this.state.pos;
  8948. for (;;) {
  8949. if (this.state.pos >= this.length) {
  8950. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  8951. }
  8952. const ch = this.input.charCodeAt(this.state.pos);
  8953. if (ch === quote) break;
  8954. if (ch === 38) {
  8955. out += this.input.slice(chunkStart, this.state.pos);
  8956. out += this.jsxReadEntity();
  8957. chunkStart = this.state.pos;
  8958. } else if (isNewLine(ch)) {
  8959. out += this.input.slice(chunkStart, this.state.pos);
  8960. out += this.jsxReadNewLine(false);
  8961. chunkStart = this.state.pos;
  8962. } else {
  8963. ++this.state.pos;
  8964. }
  8965. }
  8966. out += this.input.slice(chunkStart, this.state.pos++);
  8967. this.finishToken(133, out);
  8968. }
  8969. jsxReadEntity() {
  8970. const startPos = ++this.state.pos;
  8971. if (this.codePointAtPos(this.state.pos) === 35) {
  8972. ++this.state.pos;
  8973. let radix = 10;
  8974. if (this.codePointAtPos(this.state.pos) === 120) {
  8975. radix = 16;
  8976. ++this.state.pos;
  8977. }
  8978. const codePoint = this.readInt(radix, undefined, false, "bail");
  8979. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  8980. ++this.state.pos;
  8981. return String.fromCodePoint(codePoint);
  8982. }
  8983. } else {
  8984. let count = 0;
  8985. let semi = false;
  8986. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) === 59)) {
  8987. ++this.state.pos;
  8988. }
  8989. if (semi) {
  8990. const desc = this.input.slice(startPos, this.state.pos);
  8991. const entity = entities[desc];
  8992. ++this.state.pos;
  8993. if (entity) {
  8994. return entity;
  8995. }
  8996. }
  8997. }
  8998. this.state.pos = startPos;
  8999. return "&";
  9000. }
  9001. jsxReadWord() {
  9002. let ch;
  9003. const start = this.state.pos;
  9004. do {
  9005. ch = this.input.charCodeAt(++this.state.pos);
  9006. } while (isIdentifierChar(ch) || ch === 45);
  9007. this.finishToken(140, this.input.slice(start, this.state.pos));
  9008. }
  9009. jsxParseIdentifier() {
  9010. const node = this.startNode();
  9011. if (this.match(140)) {
  9012. node.name = this.state.value;
  9013. } else if (tokenIsKeyword(this.state.type)) {
  9014. node.name = tokenLabelName(this.state.type);
  9015. } else {
  9016. this.unexpected();
  9017. }
  9018. this.next();
  9019. return this.finishNode(node, "JSXIdentifier");
  9020. }
  9021. jsxParseNamespacedName() {
  9022. const startLoc = this.state.startLoc;
  9023. const name = this.jsxParseIdentifier();
  9024. if (!this.eat(14)) return name;
  9025. const node = this.startNodeAt(startLoc);
  9026. node.namespace = name;
  9027. node.name = this.jsxParseIdentifier();
  9028. return this.finishNode(node, "JSXNamespacedName");
  9029. }
  9030. jsxParseElementName() {
  9031. const startLoc = this.state.startLoc;
  9032. let node = this.jsxParseNamespacedName();
  9033. if (node.type === "JSXNamespacedName") {
  9034. return node;
  9035. }
  9036. while (this.eat(16)) {
  9037. const newNode = this.startNodeAt(startLoc);
  9038. newNode.object = node;
  9039. newNode.property = this.jsxParseIdentifier();
  9040. node = this.finishNode(newNode, "JSXMemberExpression");
  9041. }
  9042. return node;
  9043. }
  9044. jsxParseAttributeValue() {
  9045. let node;
  9046. switch (this.state.type) {
  9047. case 5:
  9048. node = this.startNode();
  9049. this.setContext(types.brace);
  9050. this.next();
  9051. node = this.jsxParseExpressionContainer(node, types.j_oTag);
  9052. if (node.expression.type === "JSXEmptyExpression") {
  9053. this.raise(JsxErrors.AttributeIsEmpty, node);
  9054. }
  9055. return node;
  9056. case 142:
  9057. case 133:
  9058. return this.parseExprAtom();
  9059. default:
  9060. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  9061. }
  9062. }
  9063. jsxParseEmptyExpression() {
  9064. const node = this.startNodeAt(this.state.lastTokEndLoc);
  9065. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  9066. }
  9067. jsxParseSpreadChild(node) {
  9068. this.next();
  9069. node.expression = this.parseExpression();
  9070. this.setContext(types.j_expr);
  9071. this.state.canStartJSXElement = true;
  9072. this.expect(8);
  9073. return this.finishNode(node, "JSXSpreadChild");
  9074. }
  9075. jsxParseExpressionContainer(node, previousContext) {
  9076. if (this.match(8)) {
  9077. node.expression = this.jsxParseEmptyExpression();
  9078. } else {
  9079. const expression = this.parseExpression();
  9080. node.expression = expression;
  9081. }
  9082. this.setContext(previousContext);
  9083. this.state.canStartJSXElement = true;
  9084. this.expect(8);
  9085. return this.finishNode(node, "JSXExpressionContainer");
  9086. }
  9087. jsxParseAttribute() {
  9088. const node = this.startNode();
  9089. if (this.match(5)) {
  9090. this.setContext(types.brace);
  9091. this.next();
  9092. this.expect(21);
  9093. node.argument = this.parseMaybeAssignAllowIn();
  9094. this.setContext(types.j_oTag);
  9095. this.state.canStartJSXElement = true;
  9096. this.expect(8);
  9097. return this.finishNode(node, "JSXSpreadAttribute");
  9098. }
  9099. node.name = this.jsxParseNamespacedName();
  9100. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  9101. return this.finishNode(node, "JSXAttribute");
  9102. }
  9103. jsxParseOpeningElementAt(startLoc) {
  9104. const node = this.startNodeAt(startLoc);
  9105. if (this.eat(143)) {
  9106. return this.finishNode(node, "JSXOpeningFragment");
  9107. }
  9108. node.name = this.jsxParseElementName();
  9109. return this.jsxParseOpeningElementAfterName(node);
  9110. }
  9111. jsxParseOpeningElementAfterName(node) {
  9112. const attributes = [];
  9113. while (!this.match(56) && !this.match(143)) {
  9114. attributes.push(this.jsxParseAttribute());
  9115. }
  9116. node.attributes = attributes;
  9117. node.selfClosing = this.eat(56);
  9118. this.expect(143);
  9119. return this.finishNode(node, "JSXOpeningElement");
  9120. }
  9121. jsxParseClosingElementAt(startLoc) {
  9122. const node = this.startNodeAt(startLoc);
  9123. if (this.eat(143)) {
  9124. return this.finishNode(node, "JSXClosingFragment");
  9125. }
  9126. node.name = this.jsxParseElementName();
  9127. this.expect(143);
  9128. return this.finishNode(node, "JSXClosingElement");
  9129. }
  9130. jsxParseElementAt(startLoc) {
  9131. const node = this.startNodeAt(startLoc);
  9132. const children = [];
  9133. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  9134. let closingElement = null;
  9135. if (!openingElement.selfClosing) {
  9136. contents: for (;;) {
  9137. switch (this.state.type) {
  9138. case 142:
  9139. startLoc = this.state.startLoc;
  9140. this.next();
  9141. if (this.eat(56)) {
  9142. closingElement = this.jsxParseClosingElementAt(startLoc);
  9143. break contents;
  9144. }
  9145. children.push(this.jsxParseElementAt(startLoc));
  9146. break;
  9147. case 141:
  9148. children.push(this.parseLiteral(this.state.value, "JSXText"));
  9149. break;
  9150. case 5:
  9151. {
  9152. const node = this.startNode();
  9153. this.setContext(types.brace);
  9154. this.next();
  9155. if (this.match(21)) {
  9156. children.push(this.jsxParseSpreadChild(node));
  9157. } else {
  9158. children.push(this.jsxParseExpressionContainer(node, types.j_expr));
  9159. }
  9160. break;
  9161. }
  9162. default:
  9163. this.unexpected();
  9164. }
  9165. }
  9166. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  9167. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  9168. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  9169. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9170. openingTagName: getQualifiedJSXName(openingElement.name)
  9171. });
  9172. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  9173. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  9174. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9175. openingTagName: getQualifiedJSXName(openingElement.name)
  9176. });
  9177. }
  9178. }
  9179. }
  9180. if (isFragment(openingElement)) {
  9181. node.openingFragment = openingElement;
  9182. node.closingFragment = closingElement;
  9183. } else {
  9184. node.openingElement = openingElement;
  9185. node.closingElement = closingElement;
  9186. }
  9187. node.children = children;
  9188. if (this.match(47)) {
  9189. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  9190. }
  9191. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  9192. }
  9193. jsxParseElement() {
  9194. const startLoc = this.state.startLoc;
  9195. this.next();
  9196. return this.jsxParseElementAt(startLoc);
  9197. }
  9198. setContext(newContext) {
  9199. const {
  9200. context
  9201. } = this.state;
  9202. context[context.length - 1] = newContext;
  9203. }
  9204. parseExprAtom(refExpressionErrors) {
  9205. if (this.match(142)) {
  9206. return this.jsxParseElement();
  9207. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  9208. this.replaceToken(142);
  9209. return this.jsxParseElement();
  9210. } else {
  9211. return super.parseExprAtom(refExpressionErrors);
  9212. }
  9213. }
  9214. skipSpace() {
  9215. const curContext = this.curContext();
  9216. if (!curContext.preserveSpace) super.skipSpace();
  9217. }
  9218. getTokenFromCode(code) {
  9219. const context = this.curContext();
  9220. if (context === types.j_expr) {
  9221. this.jsxReadToken();
  9222. return;
  9223. }
  9224. if (context === types.j_oTag || context === types.j_cTag) {
  9225. if (isIdentifierStart(code)) {
  9226. this.jsxReadWord();
  9227. return;
  9228. }
  9229. if (code === 62) {
  9230. ++this.state.pos;
  9231. this.finishToken(143);
  9232. return;
  9233. }
  9234. if ((code === 34 || code === 39) && context === types.j_oTag) {
  9235. this.jsxReadString(code);
  9236. return;
  9237. }
  9238. }
  9239. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  9240. ++this.state.pos;
  9241. this.finishToken(142);
  9242. return;
  9243. }
  9244. super.getTokenFromCode(code);
  9245. }
  9246. updateContext(prevType) {
  9247. const {
  9248. context,
  9249. type
  9250. } = this.state;
  9251. if (type === 56 && prevType === 142) {
  9252. context.splice(-2, 2, types.j_cTag);
  9253. this.state.canStartJSXElement = false;
  9254. } else if (type === 142) {
  9255. context.push(types.j_oTag);
  9256. } else if (type === 143) {
  9257. const out = context[context.length - 1];
  9258. if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) {
  9259. context.pop();
  9260. this.state.canStartJSXElement = context[context.length - 1] === types.j_expr;
  9261. } else {
  9262. this.setContext(types.j_expr);
  9263. this.state.canStartJSXElement = true;
  9264. }
  9265. } else {
  9266. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  9267. }
  9268. }
  9269. };
  9270. class TypeScriptScope extends Scope {
  9271. constructor(...args) {
  9272. super(...args);
  9273. this.tsNames = new Map();
  9274. }
  9275. }
  9276. class TypeScriptScopeHandler extends ScopeHandler {
  9277. constructor(...args) {
  9278. super(...args);
  9279. this.importsStack = [];
  9280. }
  9281. createScope(flags) {
  9282. this.importsStack.push(new Set());
  9283. return new TypeScriptScope(flags);
  9284. }
  9285. enter(flags) {
  9286. if (flags === 256) {
  9287. this.importsStack.push(new Set());
  9288. }
  9289. super.enter(flags);
  9290. }
  9291. exit() {
  9292. const flags = super.exit();
  9293. if (flags === 256) {
  9294. this.importsStack.pop();
  9295. }
  9296. return flags;
  9297. }
  9298. hasImport(name, allowShadow) {
  9299. const len = this.importsStack.length;
  9300. if (this.importsStack[len - 1].has(name)) {
  9301. return true;
  9302. }
  9303. if (!allowShadow && len > 1) {
  9304. for (let i = 0; i < len - 1; i++) {
  9305. if (this.importsStack[i].has(name)) return true;
  9306. }
  9307. }
  9308. return false;
  9309. }
  9310. declareName(name, bindingType, loc) {
  9311. if (bindingType & 4096) {
  9312. if (this.hasImport(name, true)) {
  9313. this.parser.raise(Errors.VarRedeclaration, loc, {
  9314. identifierName: name
  9315. });
  9316. }
  9317. this.importsStack[this.importsStack.length - 1].add(name);
  9318. return;
  9319. }
  9320. const scope = this.currentScope();
  9321. let type = scope.tsNames.get(name) || 0;
  9322. if (bindingType & 1024) {
  9323. this.maybeExportDefined(scope, name);
  9324. scope.tsNames.set(name, type | 16);
  9325. return;
  9326. }
  9327. super.declareName(name, bindingType, loc);
  9328. if (bindingType & 2) {
  9329. if (!(bindingType & 1)) {
  9330. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  9331. this.maybeExportDefined(scope, name);
  9332. }
  9333. type = type | 1;
  9334. }
  9335. if (bindingType & 256) {
  9336. type = type | 2;
  9337. }
  9338. if (bindingType & 512) {
  9339. type = type | 4;
  9340. }
  9341. if (bindingType & 128) {
  9342. type = type | 8;
  9343. }
  9344. if (type) scope.tsNames.set(name, type);
  9345. }
  9346. isRedeclaredInScope(scope, name, bindingType) {
  9347. const type = scope.tsNames.get(name);
  9348. if ((type & 2) > 0) {
  9349. if (bindingType & 256) {
  9350. const isConst = !!(bindingType & 512);
  9351. const wasConst = (type & 4) > 0;
  9352. return isConst !== wasConst;
  9353. }
  9354. return true;
  9355. }
  9356. if (bindingType & 128 && (type & 8) > 0) {
  9357. if (scope.names.get(name) & 2) {
  9358. return !!(bindingType & 1);
  9359. } else {
  9360. return false;
  9361. }
  9362. }
  9363. if (bindingType & 2 && (type & 1) > 0) {
  9364. return true;
  9365. }
  9366. return super.isRedeclaredInScope(scope, name, bindingType);
  9367. }
  9368. checkLocalExport(id) {
  9369. const {
  9370. name
  9371. } = id;
  9372. if (this.hasImport(name)) return;
  9373. const len = this.scopeStack.length;
  9374. for (let i = len - 1; i >= 0; i--) {
  9375. const scope = this.scopeStack[i];
  9376. const type = scope.tsNames.get(name);
  9377. if ((type & 1) > 0 || (type & 16) > 0) {
  9378. return;
  9379. }
  9380. }
  9381. super.checkLocalExport(id);
  9382. }
  9383. }
  9384. const unwrapParenthesizedExpression = node => {
  9385. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9386. };
  9387. class LValParser extends NodeUtils {
  9388. toAssignable(node, isLHS = false) {
  9389. var _node$extra, _node$extra3;
  9390. let parenthesized = undefined;
  9391. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9392. parenthesized = unwrapParenthesizedExpression(node);
  9393. if (isLHS) {
  9394. if (parenthesized.type === "Identifier") {
  9395. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9396. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9397. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9398. }
  9399. } else {
  9400. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9401. }
  9402. }
  9403. switch (node.type) {
  9404. case "Identifier":
  9405. case "ObjectPattern":
  9406. case "ArrayPattern":
  9407. case "AssignmentPattern":
  9408. case "RestElement":
  9409. break;
  9410. case "ObjectExpression":
  9411. node.type = "ObjectPattern";
  9412. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9413. var _node$extra2;
  9414. const prop = node.properties[i];
  9415. const isLast = i === last;
  9416. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9417. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9418. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9419. }
  9420. }
  9421. break;
  9422. case "ObjectProperty":
  9423. {
  9424. const {
  9425. key,
  9426. value
  9427. } = node;
  9428. if (this.isPrivateName(key)) {
  9429. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9430. }
  9431. this.toAssignable(value, isLHS);
  9432. break;
  9433. }
  9434. case "SpreadElement":
  9435. {
  9436. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9437. }
  9438. case "ArrayExpression":
  9439. node.type = "ArrayPattern";
  9440. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9441. break;
  9442. case "AssignmentExpression":
  9443. if (node.operator !== "=") {
  9444. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9445. }
  9446. node.type = "AssignmentPattern";
  9447. delete node.operator;
  9448. this.toAssignable(node.left, isLHS);
  9449. break;
  9450. case "ParenthesizedExpression":
  9451. this.toAssignable(parenthesized, isLHS);
  9452. break;
  9453. }
  9454. }
  9455. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9456. if (prop.type === "ObjectMethod") {
  9457. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9458. } else if (prop.type === "SpreadElement") {
  9459. prop.type = "RestElement";
  9460. const arg = prop.argument;
  9461. this.checkToRestConversion(arg, false);
  9462. this.toAssignable(arg, isLHS);
  9463. if (!isLast) {
  9464. this.raise(Errors.RestTrailingComma, prop);
  9465. }
  9466. } else {
  9467. this.toAssignable(prop, isLHS);
  9468. }
  9469. }
  9470. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9471. const end = exprList.length - 1;
  9472. for (let i = 0; i <= end; i++) {
  9473. const elt = exprList[i];
  9474. if (!elt) continue;
  9475. if (elt.type === "SpreadElement") {
  9476. elt.type = "RestElement";
  9477. const arg = elt.argument;
  9478. this.checkToRestConversion(arg, true);
  9479. this.toAssignable(arg, isLHS);
  9480. } else {
  9481. this.toAssignable(elt, isLHS);
  9482. }
  9483. if (elt.type === "RestElement") {
  9484. if (i < end) {
  9485. this.raise(Errors.RestTrailingComma, elt);
  9486. } else if (trailingCommaLoc) {
  9487. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9488. }
  9489. }
  9490. }
  9491. }
  9492. isAssignable(node, isBinding) {
  9493. switch (node.type) {
  9494. case "Identifier":
  9495. case "ObjectPattern":
  9496. case "ArrayPattern":
  9497. case "AssignmentPattern":
  9498. case "RestElement":
  9499. return true;
  9500. case "ObjectExpression":
  9501. {
  9502. const last = node.properties.length - 1;
  9503. return node.properties.every((prop, i) => {
  9504. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9505. });
  9506. }
  9507. case "ObjectProperty":
  9508. return this.isAssignable(node.value);
  9509. case "SpreadElement":
  9510. return this.isAssignable(node.argument);
  9511. case "ArrayExpression":
  9512. return node.elements.every(element => element === null || this.isAssignable(element));
  9513. case "AssignmentExpression":
  9514. return node.operator === "=";
  9515. case "ParenthesizedExpression":
  9516. return this.isAssignable(node.expression);
  9517. case "MemberExpression":
  9518. case "OptionalMemberExpression":
  9519. return !isBinding;
  9520. default:
  9521. return false;
  9522. }
  9523. }
  9524. toReferencedList(exprList, isParenthesizedExpr) {
  9525. return exprList;
  9526. }
  9527. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9528. this.toReferencedList(exprList, isParenthesizedExpr);
  9529. for (const expr of exprList) {
  9530. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9531. this.toReferencedListDeep(expr.elements);
  9532. }
  9533. }
  9534. }
  9535. parseSpread(refExpressionErrors) {
  9536. const node = this.startNode();
  9537. this.next();
  9538. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9539. return this.finishNode(node, "SpreadElement");
  9540. }
  9541. parseRestBinding() {
  9542. const node = this.startNode();
  9543. this.next();
  9544. node.argument = this.parseBindingAtom();
  9545. return this.finishNode(node, "RestElement");
  9546. }
  9547. parseBindingAtom() {
  9548. switch (this.state.type) {
  9549. case 0:
  9550. {
  9551. const node = this.startNode();
  9552. this.next();
  9553. node.elements = this.parseBindingList(3, 93, 1);
  9554. return this.finishNode(node, "ArrayPattern");
  9555. }
  9556. case 5:
  9557. return this.parseObjectLike(8, true);
  9558. }
  9559. return this.parseIdentifier();
  9560. }
  9561. parseBindingList(close, closeCharCode, flags) {
  9562. const allowEmpty = flags & 1;
  9563. const elts = [];
  9564. let first = true;
  9565. while (!this.eat(close)) {
  9566. if (first) {
  9567. first = false;
  9568. } else {
  9569. this.expect(12);
  9570. }
  9571. if (allowEmpty && this.match(12)) {
  9572. elts.push(null);
  9573. } else if (this.eat(close)) {
  9574. break;
  9575. } else if (this.match(21)) {
  9576. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags));
  9577. if (!this.checkCommaAfterRest(closeCharCode)) {
  9578. this.expect(close);
  9579. break;
  9580. }
  9581. } else {
  9582. const decorators = [];
  9583. if (this.match(26) && this.hasPlugin("decorators")) {
  9584. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9585. }
  9586. while (this.match(26)) {
  9587. decorators.push(this.parseDecorator());
  9588. }
  9589. elts.push(this.parseAssignableListItem(flags, decorators));
  9590. }
  9591. }
  9592. return elts;
  9593. }
  9594. parseBindingRestProperty(prop) {
  9595. this.next();
  9596. prop.argument = this.parseIdentifier();
  9597. this.checkCommaAfterRest(125);
  9598. return this.finishNode(prop, "RestElement");
  9599. }
  9600. parseBindingProperty() {
  9601. const {
  9602. type,
  9603. startLoc
  9604. } = this.state;
  9605. if (type === 21) {
  9606. return this.parseBindingRestProperty(this.startNode());
  9607. }
  9608. const prop = this.startNode();
  9609. if (type === 138) {
  9610. this.expectPlugin("destructuringPrivate", startLoc);
  9611. this.classScope.usePrivateName(this.state.value, startLoc);
  9612. prop.key = this.parsePrivateName();
  9613. } else {
  9614. this.parsePropertyName(prop);
  9615. }
  9616. prop.method = false;
  9617. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9618. }
  9619. parseAssignableListItem(flags, decorators) {
  9620. const left = this.parseMaybeDefault();
  9621. this.parseAssignableListItemTypes(left, flags);
  9622. const elt = this.parseMaybeDefault(left.loc.start, left);
  9623. if (decorators.length) {
  9624. left.decorators = decorators;
  9625. }
  9626. return elt;
  9627. }
  9628. parseAssignableListItemTypes(param, flags) {
  9629. return param;
  9630. }
  9631. parseMaybeDefault(startLoc, left) {
  9632. var _startLoc, _left;
  9633. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  9634. left = (_left = left) != null ? _left : this.parseBindingAtom();
  9635. if (!this.eat(29)) return left;
  9636. const node = this.startNodeAt(startLoc);
  9637. node.left = left;
  9638. node.right = this.parseMaybeAssignAllowIn();
  9639. return this.finishNode(node, "AssignmentPattern");
  9640. }
  9641. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9642. switch (type) {
  9643. case "AssignmentPattern":
  9644. return "left";
  9645. case "RestElement":
  9646. return "argument";
  9647. case "ObjectProperty":
  9648. return "value";
  9649. case "ParenthesizedExpression":
  9650. return "expression";
  9651. case "ArrayPattern":
  9652. return "elements";
  9653. case "ObjectPattern":
  9654. return "properties";
  9655. }
  9656. return false;
  9657. }
  9658. isOptionalMemberExpression(expression) {
  9659. return expression.type === "OptionalMemberExpression";
  9660. }
  9661. checkLVal(expression, ancestor, binding = 64, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false) {
  9662. var _expression$extra;
  9663. const type = expression.type;
  9664. if (this.isObjectMethod(expression)) return;
  9665. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9666. if (isOptionalMemberExpression || type === "MemberExpression") {
  9667. if (isOptionalMemberExpression) {
  9668. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9669. if (ancestor.type !== "AssignmentExpression") {
  9670. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9671. ancestor
  9672. });
  9673. }
  9674. }
  9675. if (binding !== 64) {
  9676. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9677. }
  9678. return;
  9679. }
  9680. if (type === "Identifier") {
  9681. this.checkIdentifier(expression, binding, strictModeChanged);
  9682. const {
  9683. name
  9684. } = expression;
  9685. if (checkClashes) {
  9686. if (checkClashes.has(name)) {
  9687. this.raise(Errors.ParamDupe, expression);
  9688. } else {
  9689. checkClashes.add(name);
  9690. }
  9691. }
  9692. return;
  9693. }
  9694. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9695. if (validity === true) return;
  9696. if (validity === false) {
  9697. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9698. this.raise(ParseErrorClass, expression, {
  9699. ancestor
  9700. });
  9701. return;
  9702. }
  9703. let key, isParenthesizedExpression;
  9704. if (typeof validity === "string") {
  9705. key = validity;
  9706. isParenthesizedExpression = type === "ParenthesizedExpression";
  9707. } else {
  9708. [key, isParenthesizedExpression] = validity;
  9709. }
  9710. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9711. type
  9712. } : ancestor;
  9713. const val = expression[key];
  9714. if (Array.isArray(val)) {
  9715. for (const child of val) {
  9716. if (child) {
  9717. this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9718. }
  9719. }
  9720. } else if (val) {
  9721. this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9722. }
  9723. }
  9724. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9725. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9726. if (bindingType === 64) {
  9727. this.raise(Errors.StrictEvalArguments, at, {
  9728. referenceName: at.name
  9729. });
  9730. } else {
  9731. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9732. bindingName: at.name
  9733. });
  9734. }
  9735. }
  9736. if (bindingType & 8192 && at.name === "let") {
  9737. this.raise(Errors.LetInLexicalBinding, at);
  9738. }
  9739. if (!(bindingType & 64)) {
  9740. this.declareNameFromIdentifier(at, bindingType);
  9741. }
  9742. }
  9743. declareNameFromIdentifier(identifier, binding) {
  9744. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  9745. }
  9746. checkToRestConversion(node, allowPattern) {
  9747. switch (node.type) {
  9748. case "ParenthesizedExpression":
  9749. this.checkToRestConversion(node.expression, allowPattern);
  9750. break;
  9751. case "Identifier":
  9752. case "MemberExpression":
  9753. break;
  9754. case "ArrayExpression":
  9755. case "ObjectExpression":
  9756. if (allowPattern) break;
  9757. default:
  9758. this.raise(Errors.InvalidRestAssignmentPattern, node);
  9759. }
  9760. }
  9761. checkCommaAfterRest(close) {
  9762. if (!this.match(12)) {
  9763. return false;
  9764. }
  9765. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  9766. return true;
  9767. }
  9768. }
  9769. function nonNull(x) {
  9770. if (x == null) {
  9771. throw new Error(`Unexpected ${x} value.`);
  9772. }
  9773. return x;
  9774. }
  9775. function assert(x) {
  9776. if (!x) {
  9777. throw new Error("Assert fail");
  9778. }
  9779. }
  9780. const TSErrors = ParseErrorEnum`typescript`({
  9781. AbstractMethodHasImplementation: ({
  9782. methodName
  9783. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  9784. AbstractPropertyHasInitializer: ({
  9785. propertyName
  9786. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  9787. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  9788. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  9789. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  9790. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  9791. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  9792. ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  9793. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  9794. DeclareAccessor: ({
  9795. kind
  9796. }) => `'declare' is not allowed in ${kind}ters.`,
  9797. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  9798. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  9799. DuplicateAccessibilityModifier: ({
  9800. modifier
  9801. }) => `Accessibility modifier already seen.`,
  9802. DuplicateModifier: ({
  9803. modifier
  9804. }) => `Duplicate modifier: '${modifier}'.`,
  9805. EmptyHeritageClauseType: ({
  9806. token
  9807. }) => `'${token}' list cannot be empty.`,
  9808. EmptyTypeArguments: "Type argument list cannot be empty.",
  9809. EmptyTypeParameters: "Type parameter list cannot be empty.",
  9810. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  9811. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  9812. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  9813. IncompatibleModifiers: ({
  9814. modifiers
  9815. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  9816. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  9817. IndexSignatureHasAccessibility: ({
  9818. modifier
  9819. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  9820. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  9821. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  9822. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  9823. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  9824. InvalidModifierOnTypeMember: ({
  9825. modifier
  9826. }) => `'${modifier}' modifier cannot appear on a type member.`,
  9827. InvalidModifierOnTypeParameter: ({
  9828. modifier
  9829. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  9830. InvalidModifierOnTypeParameterPositions: ({
  9831. modifier
  9832. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  9833. InvalidModifiersOrder: ({
  9834. orderedModifiers
  9835. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  9836. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  9837. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  9838. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  9839. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  9840. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  9841. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  9842. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  9843. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  9844. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  9845. PrivateElementHasAccessibility: ({
  9846. modifier
  9847. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  9848. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  9849. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  9850. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  9851. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  9852. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  9853. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  9854. SingleTypeParameterWithoutTrailingComma: ({
  9855. typeParameterName
  9856. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  9857. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  9858. 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?`).",
  9859. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  9860. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  9861. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  9862. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  9863. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  9864. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  9865. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  9866. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  9867. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  9868. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  9869. UnsupportedSignatureParameterKind: ({
  9870. type
  9871. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`
  9872. });
  9873. function keywordTypeFromName(value) {
  9874. switch (value) {
  9875. case "any":
  9876. return "TSAnyKeyword";
  9877. case "boolean":
  9878. return "TSBooleanKeyword";
  9879. case "bigint":
  9880. return "TSBigIntKeyword";
  9881. case "never":
  9882. return "TSNeverKeyword";
  9883. case "number":
  9884. return "TSNumberKeyword";
  9885. case "object":
  9886. return "TSObjectKeyword";
  9887. case "string":
  9888. return "TSStringKeyword";
  9889. case "symbol":
  9890. return "TSSymbolKeyword";
  9891. case "undefined":
  9892. return "TSUndefinedKeyword";
  9893. case "unknown":
  9894. return "TSUnknownKeyword";
  9895. default:
  9896. return undefined;
  9897. }
  9898. }
  9899. function tsIsAccessModifier(modifier) {
  9900. return modifier === "private" || modifier === "public" || modifier === "protected";
  9901. }
  9902. function tsIsVarianceAnnotations(modifier) {
  9903. return modifier === "in" || modifier === "out";
  9904. }
  9905. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  9906. constructor(...args) {
  9907. super(...args);
  9908. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  9909. allowedModifiers: ["in", "out"],
  9910. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9911. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9912. });
  9913. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  9914. allowedModifiers: ["const"],
  9915. disallowedModifiers: ["in", "out"],
  9916. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  9917. });
  9918. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  9919. allowedModifiers: ["in", "out", "const"],
  9920. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9921. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9922. });
  9923. }
  9924. getScopeHandler() {
  9925. return TypeScriptScopeHandler;
  9926. }
  9927. tsIsIdentifier() {
  9928. return tokenIsIdentifier(this.state.type);
  9929. }
  9930. tsTokenCanFollowModifier() {
  9931. return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  9932. }
  9933. tsNextTokenCanFollowModifier() {
  9934. this.next();
  9935. return this.tsTokenCanFollowModifier();
  9936. }
  9937. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
  9938. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  9939. return undefined;
  9940. }
  9941. const modifier = this.state.value;
  9942. if (allowedModifiers.includes(modifier)) {
  9943. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  9944. return undefined;
  9945. }
  9946. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  9947. return modifier;
  9948. }
  9949. }
  9950. return undefined;
  9951. }
  9952. tsParseModifiers({
  9953. allowedModifiers,
  9954. disallowedModifiers,
  9955. stopOnStartOfClassStaticBlock,
  9956. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  9957. }, modified) {
  9958. const enforceOrder = (loc, modifier, before, after) => {
  9959. if (modifier === before && modified[after]) {
  9960. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  9961. orderedModifiers: [before, after]
  9962. });
  9963. }
  9964. };
  9965. const incompatible = (loc, modifier, mod1, mod2) => {
  9966. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  9967. this.raise(TSErrors.IncompatibleModifiers, loc, {
  9968. modifiers: [mod1, mod2]
  9969. });
  9970. }
  9971. };
  9972. for (;;) {
  9973. const {
  9974. startLoc
  9975. } = this.state;
  9976. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
  9977. if (!modifier) break;
  9978. if (tsIsAccessModifier(modifier)) {
  9979. if (modified.accessibility) {
  9980. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  9981. modifier
  9982. });
  9983. } else {
  9984. enforceOrder(startLoc, modifier, modifier, "override");
  9985. enforceOrder(startLoc, modifier, modifier, "static");
  9986. enforceOrder(startLoc, modifier, modifier, "readonly");
  9987. modified.accessibility = modifier;
  9988. }
  9989. } else if (tsIsVarianceAnnotations(modifier)) {
  9990. if (modified[modifier]) {
  9991. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9992. modifier
  9993. });
  9994. }
  9995. modified[modifier] = true;
  9996. enforceOrder(startLoc, modifier, "in", "out");
  9997. } else {
  9998. if (hasOwnProperty.call(modified, modifier)) {
  9999. this.raise(TSErrors.DuplicateModifier, startLoc, {
  10000. modifier
  10001. });
  10002. } else {
  10003. enforceOrder(startLoc, modifier, "static", "readonly");
  10004. enforceOrder(startLoc, modifier, "static", "override");
  10005. enforceOrder(startLoc, modifier, "override", "readonly");
  10006. enforceOrder(startLoc, modifier, "abstract", "override");
  10007. incompatible(startLoc, modifier, "declare", "override");
  10008. incompatible(startLoc, modifier, "static", "abstract");
  10009. }
  10010. modified[modifier] = true;
  10011. }
  10012. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  10013. this.raise(errorTemplate, startLoc, {
  10014. modifier
  10015. });
  10016. }
  10017. }
  10018. }
  10019. tsIsListTerminator(kind) {
  10020. switch (kind) {
  10021. case "EnumMembers":
  10022. case "TypeMembers":
  10023. return this.match(8);
  10024. case "HeritageClauseElement":
  10025. return this.match(5);
  10026. case "TupleElementTypes":
  10027. return this.match(3);
  10028. case "TypeParametersOrArguments":
  10029. return this.match(48);
  10030. }
  10031. }
  10032. tsParseList(kind, parseElement) {
  10033. const result = [];
  10034. while (!this.tsIsListTerminator(kind)) {
  10035. result.push(parseElement());
  10036. }
  10037. return result;
  10038. }
  10039. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  10040. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  10041. }
  10042. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  10043. const result = [];
  10044. let trailingCommaPos = -1;
  10045. for (;;) {
  10046. if (this.tsIsListTerminator(kind)) {
  10047. break;
  10048. }
  10049. trailingCommaPos = -1;
  10050. const element = parseElement();
  10051. if (element == null) {
  10052. return undefined;
  10053. }
  10054. result.push(element);
  10055. if (this.eat(12)) {
  10056. trailingCommaPos = this.state.lastTokStartLoc.index;
  10057. continue;
  10058. }
  10059. if (this.tsIsListTerminator(kind)) {
  10060. break;
  10061. }
  10062. if (expectSuccess) {
  10063. this.expect(12);
  10064. }
  10065. return undefined;
  10066. }
  10067. if (refTrailingCommaPos) {
  10068. refTrailingCommaPos.value = trailingCommaPos;
  10069. }
  10070. return result;
  10071. }
  10072. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  10073. if (!skipFirstToken) {
  10074. if (bracket) {
  10075. this.expect(0);
  10076. } else {
  10077. this.expect(47);
  10078. }
  10079. }
  10080. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  10081. if (bracket) {
  10082. this.expect(3);
  10083. } else {
  10084. this.expect(48);
  10085. }
  10086. return result;
  10087. }
  10088. tsParseImportType() {
  10089. const node = this.startNode();
  10090. this.expect(83);
  10091. this.expect(10);
  10092. if (!this.match(133)) {
  10093. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10094. }
  10095. node.argument = super.parseExprAtom();
  10096. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  10097. node.options = null;
  10098. }
  10099. if (this.eat(12)) {
  10100. this.expectImportAttributesPlugin();
  10101. if (!this.match(11)) {
  10102. node.options = super.parseMaybeAssignAllowIn();
  10103. this.eat(12);
  10104. }
  10105. }
  10106. this.expect(11);
  10107. if (this.eat(16)) {
  10108. node.qualifier = this.tsParseEntityName();
  10109. }
  10110. if (this.match(47)) {
  10111. node.typeParameters = this.tsParseTypeArguments();
  10112. }
  10113. return this.finishNode(node, "TSImportType");
  10114. }
  10115. tsParseEntityName(allowReservedWords = true) {
  10116. let entity = this.parseIdentifier(allowReservedWords);
  10117. while (this.eat(16)) {
  10118. const node = this.startNodeAtNode(entity);
  10119. node.left = entity;
  10120. node.right = this.parseIdentifier(allowReservedWords);
  10121. entity = this.finishNode(node, "TSQualifiedName");
  10122. }
  10123. return entity;
  10124. }
  10125. tsParseTypeReference() {
  10126. const node = this.startNode();
  10127. node.typeName = this.tsParseEntityName();
  10128. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10129. node.typeParameters = this.tsParseTypeArguments();
  10130. }
  10131. return this.finishNode(node, "TSTypeReference");
  10132. }
  10133. tsParseThisTypePredicate(lhs) {
  10134. this.next();
  10135. const node = this.startNodeAtNode(lhs);
  10136. node.parameterName = lhs;
  10137. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10138. node.asserts = false;
  10139. return this.finishNode(node, "TSTypePredicate");
  10140. }
  10141. tsParseThisTypeNode() {
  10142. const node = this.startNode();
  10143. this.next();
  10144. return this.finishNode(node, "TSThisType");
  10145. }
  10146. tsParseTypeQuery() {
  10147. const node = this.startNode();
  10148. this.expect(87);
  10149. if (this.match(83)) {
  10150. node.exprName = this.tsParseImportType();
  10151. } else {
  10152. node.exprName = this.tsParseEntityName();
  10153. }
  10154. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10155. node.typeParameters = this.tsParseTypeArguments();
  10156. }
  10157. return this.finishNode(node, "TSTypeQuery");
  10158. }
  10159. tsParseTypeParameter(parseModifiers) {
  10160. const node = this.startNode();
  10161. parseModifiers(node);
  10162. node.name = this.tsParseTypeParameterName();
  10163. node.constraint = this.tsEatThenParseType(81);
  10164. node.default = this.tsEatThenParseType(29);
  10165. return this.finishNode(node, "TSTypeParameter");
  10166. }
  10167. tsTryParseTypeParameters(parseModifiers) {
  10168. if (this.match(47)) {
  10169. return this.tsParseTypeParameters(parseModifiers);
  10170. }
  10171. }
  10172. tsParseTypeParameters(parseModifiers) {
  10173. const node = this.startNode();
  10174. if (this.match(47) || this.match(142)) {
  10175. this.next();
  10176. } else {
  10177. this.unexpected();
  10178. }
  10179. const refTrailingCommaPos = {
  10180. value: -1
  10181. };
  10182. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10183. if (node.params.length === 0) {
  10184. this.raise(TSErrors.EmptyTypeParameters, node);
  10185. }
  10186. if (refTrailingCommaPos.value !== -1) {
  10187. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10188. }
  10189. return this.finishNode(node, "TSTypeParameterDeclaration");
  10190. }
  10191. tsFillSignature(returnToken, signature) {
  10192. const returnTokenRequired = returnToken === 19;
  10193. const paramsKey = "parameters";
  10194. const returnTypeKey = "typeAnnotation";
  10195. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10196. this.expect(10);
  10197. signature[paramsKey] = this.tsParseBindingListForSignature();
  10198. if (returnTokenRequired) {
  10199. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10200. } else if (this.match(returnToken)) {
  10201. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10202. }
  10203. }
  10204. tsParseBindingListForSignature() {
  10205. const list = super.parseBindingList(11, 41, 2);
  10206. for (const pattern of list) {
  10207. const {
  10208. type
  10209. } = pattern;
  10210. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10211. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10212. type
  10213. });
  10214. }
  10215. }
  10216. return list;
  10217. }
  10218. tsParseTypeMemberSemicolon() {
  10219. if (!this.eat(12) && !this.isLineTerminator()) {
  10220. this.expect(13);
  10221. }
  10222. }
  10223. tsParseSignatureMember(kind, node) {
  10224. this.tsFillSignature(14, node);
  10225. this.tsParseTypeMemberSemicolon();
  10226. return this.finishNode(node, kind);
  10227. }
  10228. tsIsUnambiguouslyIndexSignature() {
  10229. this.next();
  10230. if (tokenIsIdentifier(this.state.type)) {
  10231. this.next();
  10232. return this.match(14);
  10233. }
  10234. return false;
  10235. }
  10236. tsTryParseIndexSignature(node) {
  10237. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10238. return;
  10239. }
  10240. this.expect(0);
  10241. const id = this.parseIdentifier();
  10242. id.typeAnnotation = this.tsParseTypeAnnotation();
  10243. this.resetEndLocation(id);
  10244. this.expect(3);
  10245. node.parameters = [id];
  10246. const type = this.tsTryParseTypeAnnotation();
  10247. if (type) node.typeAnnotation = type;
  10248. this.tsParseTypeMemberSemicolon();
  10249. return this.finishNode(node, "TSIndexSignature");
  10250. }
  10251. tsParsePropertyOrMethodSignature(node, readonly) {
  10252. if (this.eat(17)) node.optional = true;
  10253. const nodeAny = node;
  10254. if (this.match(10) || this.match(47)) {
  10255. if (readonly) {
  10256. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10257. }
  10258. const method = nodeAny;
  10259. if (method.kind && this.match(47)) {
  10260. this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition());
  10261. }
  10262. this.tsFillSignature(14, method);
  10263. this.tsParseTypeMemberSemicolon();
  10264. const paramsKey = "parameters";
  10265. const returnTypeKey = "typeAnnotation";
  10266. if (method.kind === "get") {
  10267. if (method[paramsKey].length > 0) {
  10268. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10269. if (this.isThisParam(method[paramsKey][0])) {
  10270. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10271. }
  10272. }
  10273. } else if (method.kind === "set") {
  10274. if (method[paramsKey].length !== 1) {
  10275. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10276. } else {
  10277. const firstParameter = method[paramsKey][0];
  10278. if (this.isThisParam(firstParameter)) {
  10279. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10280. }
  10281. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10282. this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition());
  10283. }
  10284. if (firstParameter.type === "RestElement") {
  10285. this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition());
  10286. }
  10287. }
  10288. if (method[returnTypeKey]) {
  10289. this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]);
  10290. }
  10291. } else {
  10292. method.kind = "method";
  10293. }
  10294. return this.finishNode(method, "TSMethodSignature");
  10295. } else {
  10296. const property = nodeAny;
  10297. if (readonly) property.readonly = true;
  10298. const type = this.tsTryParseTypeAnnotation();
  10299. if (type) property.typeAnnotation = type;
  10300. this.tsParseTypeMemberSemicolon();
  10301. return this.finishNode(property, "TSPropertySignature");
  10302. }
  10303. }
  10304. tsParseTypeMember() {
  10305. const node = this.startNode();
  10306. if (this.match(10) || this.match(47)) {
  10307. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10308. }
  10309. if (this.match(77)) {
  10310. const id = this.startNode();
  10311. this.next();
  10312. if (this.match(10) || this.match(47)) {
  10313. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10314. } else {
  10315. node.key = this.createIdentifier(id, "new");
  10316. return this.tsParsePropertyOrMethodSignature(node, false);
  10317. }
  10318. }
  10319. this.tsParseModifiers({
  10320. allowedModifiers: ["readonly"],
  10321. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10322. }, node);
  10323. const idx = this.tsTryParseIndexSignature(node);
  10324. if (idx) {
  10325. return idx;
  10326. }
  10327. super.parsePropertyName(node);
  10328. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10329. node.kind = node.key.name;
  10330. super.parsePropertyName(node);
  10331. }
  10332. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10333. }
  10334. tsParseTypeLiteral() {
  10335. const node = this.startNode();
  10336. node.members = this.tsParseObjectTypeMembers();
  10337. return this.finishNode(node, "TSTypeLiteral");
  10338. }
  10339. tsParseObjectTypeMembers() {
  10340. this.expect(5);
  10341. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10342. this.expect(8);
  10343. return members;
  10344. }
  10345. tsIsStartOfMappedType() {
  10346. this.next();
  10347. if (this.eat(53)) {
  10348. return this.isContextual(122);
  10349. }
  10350. if (this.isContextual(122)) {
  10351. this.next();
  10352. }
  10353. if (!this.match(0)) {
  10354. return false;
  10355. }
  10356. this.next();
  10357. if (!this.tsIsIdentifier()) {
  10358. return false;
  10359. }
  10360. this.next();
  10361. return this.match(58);
  10362. }
  10363. tsParseMappedTypeParameter() {
  10364. const node = this.startNode();
  10365. node.name = this.tsParseTypeParameterName();
  10366. node.constraint = this.tsExpectThenParseType(58);
  10367. return this.finishNode(node, "TSTypeParameter");
  10368. }
  10369. tsParseMappedType() {
  10370. const node = this.startNode();
  10371. this.expect(5);
  10372. if (this.match(53)) {
  10373. node.readonly = this.state.value;
  10374. this.next();
  10375. this.expectContextual(122);
  10376. } else if (this.eatContextual(122)) {
  10377. node.readonly = true;
  10378. }
  10379. this.expect(0);
  10380. node.typeParameter = this.tsParseMappedTypeParameter();
  10381. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10382. this.expect(3);
  10383. if (this.match(53)) {
  10384. node.optional = this.state.value;
  10385. this.next();
  10386. this.expect(17);
  10387. } else if (this.eat(17)) {
  10388. node.optional = true;
  10389. }
  10390. node.typeAnnotation = this.tsTryParseType();
  10391. this.semicolon();
  10392. this.expect(8);
  10393. return this.finishNode(node, "TSMappedType");
  10394. }
  10395. tsParseTupleType() {
  10396. const node = this.startNode();
  10397. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10398. let seenOptionalElement = false;
  10399. node.elementTypes.forEach(elementNode => {
  10400. const {
  10401. type
  10402. } = elementNode;
  10403. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10404. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10405. }
  10406. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10407. });
  10408. return this.finishNode(node, "TSTupleType");
  10409. }
  10410. tsParseTupleElementType() {
  10411. const {
  10412. startLoc
  10413. } = this.state;
  10414. const rest = this.eat(21);
  10415. let labeled;
  10416. let label;
  10417. let optional;
  10418. let type;
  10419. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10420. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10421. if (chAfterWord === 58) {
  10422. labeled = true;
  10423. optional = false;
  10424. label = this.parseIdentifier(true);
  10425. this.expect(14);
  10426. type = this.tsParseType();
  10427. } else if (chAfterWord === 63) {
  10428. optional = true;
  10429. const startLoc = this.state.startLoc;
  10430. const wordName = this.state.value;
  10431. const typeOrLabel = this.tsParseNonArrayType();
  10432. if (this.lookaheadCharCode() === 58) {
  10433. labeled = true;
  10434. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10435. this.expect(17);
  10436. this.expect(14);
  10437. type = this.tsParseType();
  10438. } else {
  10439. labeled = false;
  10440. type = typeOrLabel;
  10441. this.expect(17);
  10442. }
  10443. } else {
  10444. type = this.tsParseType();
  10445. optional = this.eat(17);
  10446. labeled = this.eat(14);
  10447. }
  10448. if (labeled) {
  10449. let labeledNode;
  10450. if (label) {
  10451. labeledNode = this.startNodeAtNode(label);
  10452. labeledNode.optional = optional;
  10453. labeledNode.label = label;
  10454. labeledNode.elementType = type;
  10455. if (this.eat(17)) {
  10456. labeledNode.optional = true;
  10457. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10458. }
  10459. } else {
  10460. labeledNode = this.startNodeAtNode(type);
  10461. labeledNode.optional = optional;
  10462. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10463. labeledNode.label = type;
  10464. labeledNode.elementType = this.tsParseType();
  10465. }
  10466. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10467. } else if (optional) {
  10468. const optionalTypeNode = this.startNodeAtNode(type);
  10469. optionalTypeNode.typeAnnotation = type;
  10470. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10471. }
  10472. if (rest) {
  10473. const restNode = this.startNodeAt(startLoc);
  10474. restNode.typeAnnotation = type;
  10475. type = this.finishNode(restNode, "TSRestType");
  10476. }
  10477. return type;
  10478. }
  10479. tsParseParenthesizedType() {
  10480. const node = this.startNode();
  10481. this.expect(10);
  10482. node.typeAnnotation = this.tsParseType();
  10483. this.expect(11);
  10484. return this.finishNode(node, "TSParenthesizedType");
  10485. }
  10486. tsParseFunctionOrConstructorType(type, abstract) {
  10487. const node = this.startNode();
  10488. if (type === "TSConstructorType") {
  10489. node.abstract = !!abstract;
  10490. if (abstract) this.next();
  10491. this.next();
  10492. }
  10493. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10494. return this.finishNode(node, type);
  10495. }
  10496. tsParseLiteralTypeNode() {
  10497. const node = this.startNode();
  10498. switch (this.state.type) {
  10499. case 134:
  10500. case 135:
  10501. case 133:
  10502. case 85:
  10503. case 86:
  10504. node.literal = super.parseExprAtom();
  10505. break;
  10506. default:
  10507. this.unexpected();
  10508. }
  10509. return this.finishNode(node, "TSLiteralType");
  10510. }
  10511. tsParseTemplateLiteralType() {
  10512. const node = this.startNode();
  10513. node.literal = super.parseTemplate(false);
  10514. return this.finishNode(node, "TSLiteralType");
  10515. }
  10516. parseTemplateSubstitution() {
  10517. if (this.state.inType) return this.tsParseType();
  10518. return super.parseTemplateSubstitution();
  10519. }
  10520. tsParseThisTypeOrThisTypePredicate() {
  10521. const thisKeyword = this.tsParseThisTypeNode();
  10522. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10523. return this.tsParseThisTypePredicate(thisKeyword);
  10524. } else {
  10525. return thisKeyword;
  10526. }
  10527. }
  10528. tsParseNonArrayType() {
  10529. switch (this.state.type) {
  10530. case 133:
  10531. case 134:
  10532. case 135:
  10533. case 85:
  10534. case 86:
  10535. return this.tsParseLiteralTypeNode();
  10536. case 53:
  10537. if (this.state.value === "-") {
  10538. const node = this.startNode();
  10539. const nextToken = this.lookahead();
  10540. if (nextToken.type !== 134 && nextToken.type !== 135) {
  10541. this.unexpected();
  10542. }
  10543. node.literal = this.parseMaybeUnary();
  10544. return this.finishNode(node, "TSLiteralType");
  10545. }
  10546. break;
  10547. case 78:
  10548. return this.tsParseThisTypeOrThisTypePredicate();
  10549. case 87:
  10550. return this.tsParseTypeQuery();
  10551. case 83:
  10552. return this.tsParseImportType();
  10553. case 5:
  10554. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10555. case 0:
  10556. return this.tsParseTupleType();
  10557. case 10:
  10558. return this.tsParseParenthesizedType();
  10559. case 25:
  10560. case 24:
  10561. return this.tsParseTemplateLiteralType();
  10562. default:
  10563. {
  10564. const {
  10565. type
  10566. } = this.state;
  10567. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10568. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10569. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10570. const node = this.startNode();
  10571. this.next();
  10572. return this.finishNode(node, nodeType);
  10573. }
  10574. return this.tsParseTypeReference();
  10575. }
  10576. }
  10577. }
  10578. this.unexpected();
  10579. }
  10580. tsParseArrayTypeOrHigher() {
  10581. let type = this.tsParseNonArrayType();
  10582. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10583. if (this.match(3)) {
  10584. const node = this.startNodeAtNode(type);
  10585. node.elementType = type;
  10586. this.expect(3);
  10587. type = this.finishNode(node, "TSArrayType");
  10588. } else {
  10589. const node = this.startNodeAtNode(type);
  10590. node.objectType = type;
  10591. node.indexType = this.tsParseType();
  10592. this.expect(3);
  10593. type = this.finishNode(node, "TSIndexedAccessType");
  10594. }
  10595. }
  10596. return type;
  10597. }
  10598. tsParseTypeOperator() {
  10599. const node = this.startNode();
  10600. const operator = this.state.value;
  10601. this.next();
  10602. node.operator = operator;
  10603. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10604. if (operator === "readonly") {
  10605. this.tsCheckTypeAnnotationForReadOnly(node);
  10606. }
  10607. return this.finishNode(node, "TSTypeOperator");
  10608. }
  10609. tsCheckTypeAnnotationForReadOnly(node) {
  10610. switch (node.typeAnnotation.type) {
  10611. case "TSTupleType":
  10612. case "TSArrayType":
  10613. return;
  10614. default:
  10615. this.raise(TSErrors.UnexpectedReadonly, node);
  10616. }
  10617. }
  10618. tsParseInferType() {
  10619. const node = this.startNode();
  10620. this.expectContextual(115);
  10621. const typeParameter = this.startNode();
  10622. typeParameter.name = this.tsParseTypeParameterName();
  10623. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10624. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10625. return this.finishNode(node, "TSInferType");
  10626. }
  10627. tsParseConstraintForInferType() {
  10628. if (this.eat(81)) {
  10629. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10630. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10631. return constraint;
  10632. }
  10633. }
  10634. }
  10635. tsParseTypeOperatorOrHigher() {
  10636. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10637. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10638. }
  10639. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10640. const node = this.startNode();
  10641. const hasLeadingOperator = this.eat(operator);
  10642. const types = [];
  10643. do {
  10644. types.push(parseConstituentType());
  10645. } while (this.eat(operator));
  10646. if (types.length === 1 && !hasLeadingOperator) {
  10647. return types[0];
  10648. }
  10649. node.types = types;
  10650. return this.finishNode(node, kind);
  10651. }
  10652. tsParseIntersectionTypeOrHigher() {
  10653. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10654. }
  10655. tsParseUnionTypeOrHigher() {
  10656. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  10657. }
  10658. tsIsStartOfFunctionType() {
  10659. if (this.match(47)) {
  10660. return true;
  10661. }
  10662. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  10663. }
  10664. tsSkipParameterStart() {
  10665. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  10666. this.next();
  10667. return true;
  10668. }
  10669. if (this.match(5)) {
  10670. const {
  10671. errors
  10672. } = this.state;
  10673. const previousErrorCount = errors.length;
  10674. try {
  10675. this.parseObjectLike(8, true);
  10676. return errors.length === previousErrorCount;
  10677. } catch (_unused) {
  10678. return false;
  10679. }
  10680. }
  10681. if (this.match(0)) {
  10682. this.next();
  10683. const {
  10684. errors
  10685. } = this.state;
  10686. const previousErrorCount = errors.length;
  10687. try {
  10688. super.parseBindingList(3, 93, 1);
  10689. return errors.length === previousErrorCount;
  10690. } catch (_unused2) {
  10691. return false;
  10692. }
  10693. }
  10694. return false;
  10695. }
  10696. tsIsUnambiguouslyStartOfFunctionType() {
  10697. this.next();
  10698. if (this.match(11) || this.match(21)) {
  10699. return true;
  10700. }
  10701. if (this.tsSkipParameterStart()) {
  10702. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  10703. return true;
  10704. }
  10705. if (this.match(11)) {
  10706. this.next();
  10707. if (this.match(19)) {
  10708. return true;
  10709. }
  10710. }
  10711. }
  10712. return false;
  10713. }
  10714. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  10715. return this.tsInType(() => {
  10716. const t = this.startNode();
  10717. this.expect(returnToken);
  10718. const node = this.startNode();
  10719. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  10720. if (asserts && this.match(78)) {
  10721. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  10722. if (thisTypePredicate.type === "TSThisType") {
  10723. node.parameterName = thisTypePredicate;
  10724. node.asserts = true;
  10725. node.typeAnnotation = null;
  10726. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  10727. } else {
  10728. this.resetStartLocationFromNode(thisTypePredicate, node);
  10729. thisTypePredicate.asserts = true;
  10730. }
  10731. t.typeAnnotation = thisTypePredicate;
  10732. return this.finishNode(t, "TSTypeAnnotation");
  10733. }
  10734. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  10735. if (!typePredicateVariable) {
  10736. if (!asserts) {
  10737. return this.tsParseTypeAnnotation(false, t);
  10738. }
  10739. node.parameterName = this.parseIdentifier();
  10740. node.asserts = asserts;
  10741. node.typeAnnotation = null;
  10742. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10743. return this.finishNode(t, "TSTypeAnnotation");
  10744. }
  10745. const type = this.tsParseTypeAnnotation(false);
  10746. node.parameterName = typePredicateVariable;
  10747. node.typeAnnotation = type;
  10748. node.asserts = asserts;
  10749. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10750. return this.finishNode(t, "TSTypeAnnotation");
  10751. });
  10752. }
  10753. tsTryParseTypeOrTypePredicateAnnotation() {
  10754. if (this.match(14)) {
  10755. return this.tsParseTypeOrTypePredicateAnnotation(14);
  10756. }
  10757. }
  10758. tsTryParseTypeAnnotation() {
  10759. if (this.match(14)) {
  10760. return this.tsParseTypeAnnotation();
  10761. }
  10762. }
  10763. tsTryParseType() {
  10764. return this.tsEatThenParseType(14);
  10765. }
  10766. tsParseTypePredicatePrefix() {
  10767. const id = this.parseIdentifier();
  10768. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10769. this.next();
  10770. return id;
  10771. }
  10772. }
  10773. tsParseTypePredicateAsserts() {
  10774. if (this.state.type !== 109) {
  10775. return false;
  10776. }
  10777. const containsEsc = this.state.containsEsc;
  10778. this.next();
  10779. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  10780. return false;
  10781. }
  10782. if (containsEsc) {
  10783. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  10784. reservedWord: "asserts"
  10785. });
  10786. }
  10787. return true;
  10788. }
  10789. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  10790. this.tsInType(() => {
  10791. if (eatColon) this.expect(14);
  10792. t.typeAnnotation = this.tsParseType();
  10793. });
  10794. return this.finishNode(t, "TSTypeAnnotation");
  10795. }
  10796. tsParseType() {
  10797. assert(this.state.inType);
  10798. const type = this.tsParseNonConditionalType();
  10799. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  10800. return type;
  10801. }
  10802. const node = this.startNodeAtNode(type);
  10803. node.checkType = type;
  10804. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  10805. this.expect(17);
  10806. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10807. this.expect(14);
  10808. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10809. return this.finishNode(node, "TSConditionalType");
  10810. }
  10811. isAbstractConstructorSignature() {
  10812. return this.isContextual(124) && this.lookahead().type === 77;
  10813. }
  10814. tsParseNonConditionalType() {
  10815. if (this.tsIsStartOfFunctionType()) {
  10816. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  10817. }
  10818. if (this.match(77)) {
  10819. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  10820. } else if (this.isAbstractConstructorSignature()) {
  10821. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  10822. }
  10823. return this.tsParseUnionTypeOrHigher();
  10824. }
  10825. tsParseTypeAssertion() {
  10826. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  10827. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  10828. }
  10829. const node = this.startNode();
  10830. node.typeAnnotation = this.tsInType(() => {
  10831. this.next();
  10832. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  10833. });
  10834. this.expect(48);
  10835. node.expression = this.parseMaybeUnary();
  10836. return this.finishNode(node, "TSTypeAssertion");
  10837. }
  10838. tsParseHeritageClause(token) {
  10839. const originalStartLoc = this.state.startLoc;
  10840. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  10841. const node = this.startNode();
  10842. node.expression = this.tsParseEntityName();
  10843. if (this.match(47)) {
  10844. node.typeParameters = this.tsParseTypeArguments();
  10845. }
  10846. return this.finishNode(node, "TSExpressionWithTypeArguments");
  10847. });
  10848. if (!delimitedList.length) {
  10849. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  10850. token
  10851. });
  10852. }
  10853. return delimitedList;
  10854. }
  10855. tsParseInterfaceDeclaration(node, properties = {}) {
  10856. if (this.hasFollowingLineBreak()) return null;
  10857. this.expectContextual(129);
  10858. if (properties.declare) node.declare = true;
  10859. if (tokenIsIdentifier(this.state.type)) {
  10860. node.id = this.parseIdentifier();
  10861. this.checkIdentifier(node.id, 130);
  10862. } else {
  10863. node.id = null;
  10864. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  10865. }
  10866. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  10867. if (this.eat(81)) {
  10868. node.extends = this.tsParseHeritageClause("extends");
  10869. }
  10870. const body = this.startNode();
  10871. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  10872. node.body = this.finishNode(body, "TSInterfaceBody");
  10873. return this.finishNode(node, "TSInterfaceDeclaration");
  10874. }
  10875. tsParseTypeAliasDeclaration(node) {
  10876. node.id = this.parseIdentifier();
  10877. this.checkIdentifier(node.id, 2);
  10878. node.typeAnnotation = this.tsInType(() => {
  10879. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  10880. this.expect(29);
  10881. if (this.isContextual(114) && this.lookahead().type !== 16) {
  10882. const node = this.startNode();
  10883. this.next();
  10884. return this.finishNode(node, "TSIntrinsicKeyword");
  10885. }
  10886. return this.tsParseType();
  10887. });
  10888. this.semicolon();
  10889. return this.finishNode(node, "TSTypeAliasDeclaration");
  10890. }
  10891. tsInNoContext(cb) {
  10892. const oldContext = this.state.context;
  10893. this.state.context = [oldContext[0]];
  10894. try {
  10895. return cb();
  10896. } finally {
  10897. this.state.context = oldContext;
  10898. }
  10899. }
  10900. tsInType(cb) {
  10901. const oldInType = this.state.inType;
  10902. this.state.inType = true;
  10903. try {
  10904. return cb();
  10905. } finally {
  10906. this.state.inType = oldInType;
  10907. }
  10908. }
  10909. tsInDisallowConditionalTypesContext(cb) {
  10910. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10911. this.state.inDisallowConditionalTypesContext = true;
  10912. try {
  10913. return cb();
  10914. } finally {
  10915. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10916. }
  10917. }
  10918. tsInAllowConditionalTypesContext(cb) {
  10919. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10920. this.state.inDisallowConditionalTypesContext = false;
  10921. try {
  10922. return cb();
  10923. } finally {
  10924. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10925. }
  10926. }
  10927. tsEatThenParseType(token) {
  10928. if (this.match(token)) {
  10929. return this.tsNextThenParseType();
  10930. }
  10931. }
  10932. tsExpectThenParseType(token) {
  10933. return this.tsInType(() => {
  10934. this.expect(token);
  10935. return this.tsParseType();
  10936. });
  10937. }
  10938. tsNextThenParseType() {
  10939. return this.tsInType(() => {
  10940. this.next();
  10941. return this.tsParseType();
  10942. });
  10943. }
  10944. tsParseEnumMember() {
  10945. const node = this.startNode();
  10946. node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  10947. if (this.eat(29)) {
  10948. node.initializer = super.parseMaybeAssignAllowIn();
  10949. }
  10950. return this.finishNode(node, "TSEnumMember");
  10951. }
  10952. tsParseEnumDeclaration(node, properties = {}) {
  10953. if (properties.const) node.const = true;
  10954. if (properties.declare) node.declare = true;
  10955. this.expectContextual(126);
  10956. node.id = this.parseIdentifier();
  10957. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  10958. this.expect(5);
  10959. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  10960. this.expect(8);
  10961. return this.finishNode(node, "TSEnumDeclaration");
  10962. }
  10963. tsParseModuleBlock() {
  10964. const node = this.startNode();
  10965. this.scope.enter(0);
  10966. this.expect(5);
  10967. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  10968. this.scope.exit();
  10969. return this.finishNode(node, "TSModuleBlock");
  10970. }
  10971. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  10972. node.id = this.parseIdentifier();
  10973. if (!nested) {
  10974. this.checkIdentifier(node.id, 1024);
  10975. }
  10976. if (this.eat(16)) {
  10977. const inner = this.startNode();
  10978. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  10979. node.body = inner;
  10980. } else {
  10981. this.scope.enter(256);
  10982. this.prodParam.enter(0);
  10983. node.body = this.tsParseModuleBlock();
  10984. this.prodParam.exit();
  10985. this.scope.exit();
  10986. }
  10987. return this.finishNode(node, "TSModuleDeclaration");
  10988. }
  10989. tsParseAmbientExternalModuleDeclaration(node) {
  10990. if (this.isContextual(112)) {
  10991. node.global = true;
  10992. node.id = this.parseIdentifier();
  10993. } else if (this.match(133)) {
  10994. node.id = super.parseStringLiteral(this.state.value);
  10995. } else {
  10996. this.unexpected();
  10997. }
  10998. if (this.match(5)) {
  10999. this.scope.enter(256);
  11000. this.prodParam.enter(0);
  11001. node.body = this.tsParseModuleBlock();
  11002. this.prodParam.exit();
  11003. this.scope.exit();
  11004. } else {
  11005. this.semicolon();
  11006. }
  11007. return this.finishNode(node, "TSModuleDeclaration");
  11008. }
  11009. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  11010. node.isExport = isExport || false;
  11011. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  11012. this.checkIdentifier(node.id, 4096);
  11013. this.expect(29);
  11014. const moduleReference = this.tsParseModuleReference();
  11015. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  11016. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  11017. }
  11018. node.moduleReference = moduleReference;
  11019. this.semicolon();
  11020. return this.finishNode(node, "TSImportEqualsDeclaration");
  11021. }
  11022. tsIsExternalModuleReference() {
  11023. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  11024. }
  11025. tsParseModuleReference() {
  11026. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  11027. }
  11028. tsParseExternalModuleReference() {
  11029. const node = this.startNode();
  11030. this.expectContextual(119);
  11031. this.expect(10);
  11032. if (!this.match(133)) {
  11033. this.unexpected();
  11034. }
  11035. node.expression = super.parseExprAtom();
  11036. this.expect(11);
  11037. this.sawUnambiguousESM = true;
  11038. return this.finishNode(node, "TSExternalModuleReference");
  11039. }
  11040. tsLookAhead(f) {
  11041. const state = this.state.clone();
  11042. const res = f();
  11043. this.state = state;
  11044. return res;
  11045. }
  11046. tsTryParseAndCatch(f) {
  11047. const result = this.tryParse(abort => f() || abort());
  11048. if (result.aborted || !result.node) return;
  11049. if (result.error) this.state = result.failState;
  11050. return result.node;
  11051. }
  11052. tsTryParse(f) {
  11053. const state = this.state.clone();
  11054. const result = f();
  11055. if (result !== undefined && result !== false) {
  11056. return result;
  11057. }
  11058. this.state = state;
  11059. }
  11060. tsTryParseDeclare(nany) {
  11061. if (this.isLineTerminator()) {
  11062. return;
  11063. }
  11064. let startType = this.state.type;
  11065. let kind;
  11066. if (this.isContextual(100)) {
  11067. startType = 74;
  11068. kind = "let";
  11069. }
  11070. return this.tsInAmbientContext(() => {
  11071. switch (startType) {
  11072. case 68:
  11073. nany.declare = true;
  11074. return super.parseFunctionStatement(nany, false, false);
  11075. case 80:
  11076. nany.declare = true;
  11077. return this.parseClass(nany, true, false);
  11078. case 126:
  11079. return this.tsParseEnumDeclaration(nany, {
  11080. declare: true
  11081. });
  11082. case 112:
  11083. return this.tsParseAmbientExternalModuleDeclaration(nany);
  11084. case 75:
  11085. case 74:
  11086. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11087. nany.declare = true;
  11088. return this.parseVarStatement(nany, kind || this.state.value, true);
  11089. }
  11090. this.expect(75);
  11091. return this.tsParseEnumDeclaration(nany, {
  11092. const: true,
  11093. declare: true
  11094. });
  11095. case 129:
  11096. {
  11097. const result = this.tsParseInterfaceDeclaration(nany, {
  11098. declare: true
  11099. });
  11100. if (result) return result;
  11101. }
  11102. default:
  11103. if (tokenIsIdentifier(startType)) {
  11104. return this.tsParseDeclaration(nany, this.state.value, true, null);
  11105. }
  11106. }
  11107. });
  11108. }
  11109. tsTryParseExportDeclaration() {
  11110. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11111. }
  11112. tsParseExpressionStatement(node, expr, decorators) {
  11113. switch (expr.name) {
  11114. case "declare":
  11115. {
  11116. const declaration = this.tsTryParseDeclare(node);
  11117. if (declaration) {
  11118. declaration.declare = true;
  11119. }
  11120. return declaration;
  11121. }
  11122. case "global":
  11123. if (this.match(5)) {
  11124. this.scope.enter(256);
  11125. this.prodParam.enter(0);
  11126. const mod = node;
  11127. mod.global = true;
  11128. mod.id = expr;
  11129. mod.body = this.tsParseModuleBlock();
  11130. this.scope.exit();
  11131. this.prodParam.exit();
  11132. return this.finishNode(mod, "TSModuleDeclaration");
  11133. }
  11134. break;
  11135. default:
  11136. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11137. }
  11138. }
  11139. tsParseDeclaration(node, value, next, decorators) {
  11140. switch (value) {
  11141. case "abstract":
  11142. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11143. return this.tsParseAbstractDeclaration(node, decorators);
  11144. }
  11145. break;
  11146. case "module":
  11147. if (this.tsCheckLineTerminator(next)) {
  11148. if (this.match(133)) {
  11149. return this.tsParseAmbientExternalModuleDeclaration(node);
  11150. } else if (tokenIsIdentifier(this.state.type)) {
  11151. return this.tsParseModuleOrNamespaceDeclaration(node);
  11152. }
  11153. }
  11154. break;
  11155. case "namespace":
  11156. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11157. return this.tsParseModuleOrNamespaceDeclaration(node);
  11158. }
  11159. break;
  11160. case "type":
  11161. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11162. return this.tsParseTypeAliasDeclaration(node);
  11163. }
  11164. break;
  11165. }
  11166. }
  11167. tsCheckLineTerminator(next) {
  11168. if (next) {
  11169. if (this.hasFollowingLineBreak()) return false;
  11170. this.next();
  11171. return true;
  11172. }
  11173. return !this.isLineTerminator();
  11174. }
  11175. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11176. if (!this.match(47)) return;
  11177. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11178. this.state.maybeInArrowParameters = true;
  11179. const res = this.tsTryParseAndCatch(() => {
  11180. const node = this.startNodeAt(startLoc);
  11181. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11182. super.parseFunctionParams(node);
  11183. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11184. this.expect(19);
  11185. return node;
  11186. });
  11187. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11188. if (!res) return;
  11189. return super.parseArrowExpression(res, null, true);
  11190. }
  11191. tsParseTypeArgumentsInExpression() {
  11192. if (this.reScan_lt() !== 47) return;
  11193. return this.tsParseTypeArguments();
  11194. }
  11195. tsParseTypeArguments() {
  11196. const node = this.startNode();
  11197. node.params = this.tsInType(() => this.tsInNoContext(() => {
  11198. this.expect(47);
  11199. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11200. }));
  11201. if (node.params.length === 0) {
  11202. this.raise(TSErrors.EmptyTypeArguments, node);
  11203. } else if (!this.state.inType && this.curContext() === types.brace) {
  11204. this.reScan_lt_gt();
  11205. }
  11206. this.expect(48);
  11207. return this.finishNode(node, "TSTypeParameterInstantiation");
  11208. }
  11209. tsIsDeclarationStart() {
  11210. return tokenIsTSDeclarationStart(this.state.type);
  11211. }
  11212. isExportDefaultSpecifier() {
  11213. if (this.tsIsDeclarationStart()) return false;
  11214. return super.isExportDefaultSpecifier();
  11215. }
  11216. parseAssignableListItem(flags, decorators) {
  11217. const startLoc = this.state.startLoc;
  11218. const modified = {};
  11219. this.tsParseModifiers({
  11220. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11221. }, modified);
  11222. const accessibility = modified.accessibility;
  11223. const override = modified.override;
  11224. const readonly = modified.readonly;
  11225. if (!(flags & 4) && (accessibility || readonly || override)) {
  11226. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11227. }
  11228. const left = this.parseMaybeDefault();
  11229. this.parseAssignableListItemTypes(left, flags);
  11230. const elt = this.parseMaybeDefault(left.loc.start, left);
  11231. if (accessibility || readonly || override) {
  11232. const pp = this.startNodeAt(startLoc);
  11233. if (decorators.length) {
  11234. pp.decorators = decorators;
  11235. }
  11236. if (accessibility) pp.accessibility = accessibility;
  11237. if (readonly) pp.readonly = readonly;
  11238. if (override) pp.override = override;
  11239. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11240. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11241. }
  11242. pp.parameter = elt;
  11243. return this.finishNode(pp, "TSParameterProperty");
  11244. }
  11245. if (decorators.length) {
  11246. left.decorators = decorators;
  11247. }
  11248. return elt;
  11249. }
  11250. isSimpleParameter(node) {
  11251. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11252. }
  11253. tsDisallowOptionalPattern(node) {
  11254. for (const param of node.params) {
  11255. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11256. this.raise(TSErrors.PatternIsOptional, param);
  11257. }
  11258. }
  11259. }
  11260. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11261. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11262. this.tsDisallowOptionalPattern(node);
  11263. }
  11264. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11265. if (this.match(14)) {
  11266. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11267. }
  11268. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11269. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11270. return this.finishNode(node, bodilessType);
  11271. }
  11272. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11273. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11274. if (node.declare) {
  11275. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11276. }
  11277. }
  11278. this.tsDisallowOptionalPattern(node);
  11279. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11280. }
  11281. registerFunctionStatementId(node) {
  11282. if (!node.body && node.id) {
  11283. this.checkIdentifier(node.id, 1024);
  11284. } else {
  11285. super.registerFunctionStatementId(node);
  11286. }
  11287. }
  11288. tsCheckForInvalidTypeCasts(items) {
  11289. items.forEach(node => {
  11290. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11291. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11292. }
  11293. });
  11294. }
  11295. toReferencedList(exprList, isInParens) {
  11296. this.tsCheckForInvalidTypeCasts(exprList);
  11297. return exprList;
  11298. }
  11299. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11300. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11301. if (node.type === "ArrayExpression") {
  11302. this.tsCheckForInvalidTypeCasts(node.elements);
  11303. }
  11304. return node;
  11305. }
  11306. parseSubscript(base, startLoc, noCalls, state) {
  11307. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11308. this.state.canStartJSXElement = false;
  11309. this.next();
  11310. const nonNullExpression = this.startNodeAt(startLoc);
  11311. nonNullExpression.expression = base;
  11312. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11313. }
  11314. let isOptionalCall = false;
  11315. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11316. if (noCalls) {
  11317. state.stop = true;
  11318. return base;
  11319. }
  11320. state.optionalChainMember = isOptionalCall = true;
  11321. this.next();
  11322. }
  11323. if (this.match(47) || this.match(51)) {
  11324. let missingParenErrorLoc;
  11325. const result = this.tsTryParseAndCatch(() => {
  11326. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11327. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11328. if (asyncArrowFn) {
  11329. return asyncArrowFn;
  11330. }
  11331. }
  11332. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11333. if (!typeArguments) return;
  11334. if (isOptionalCall && !this.match(10)) {
  11335. missingParenErrorLoc = this.state.curPosition();
  11336. return;
  11337. }
  11338. if (tokenIsTemplate(this.state.type)) {
  11339. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11340. result.typeParameters = typeArguments;
  11341. return result;
  11342. }
  11343. if (!noCalls && this.eat(10)) {
  11344. const node = this.startNodeAt(startLoc);
  11345. node.callee = base;
  11346. node.arguments = this.parseCallExpressionArguments(11, false);
  11347. this.tsCheckForInvalidTypeCasts(node.arguments);
  11348. node.typeParameters = typeArguments;
  11349. if (state.optionalChainMember) {
  11350. node.optional = isOptionalCall;
  11351. }
  11352. return this.finishCallExpression(node, state.optionalChainMember);
  11353. }
  11354. const tokenType = this.state.type;
  11355. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11356. return;
  11357. }
  11358. const node = this.startNodeAt(startLoc);
  11359. node.expression = base;
  11360. node.typeParameters = typeArguments;
  11361. return this.finishNode(node, "TSInstantiationExpression");
  11362. });
  11363. if (missingParenErrorLoc) {
  11364. this.unexpected(missingParenErrorLoc, 10);
  11365. }
  11366. if (result) {
  11367. if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
  11368. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11369. }
  11370. return result;
  11371. }
  11372. }
  11373. return super.parseSubscript(base, startLoc, noCalls, state);
  11374. }
  11375. parseNewCallee(node) {
  11376. var _callee$extra;
  11377. super.parseNewCallee(node);
  11378. const {
  11379. callee
  11380. } = node;
  11381. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11382. node.typeParameters = callee.typeParameters;
  11383. node.callee = callee.expression;
  11384. }
  11385. }
  11386. parseExprOp(left, leftStartLoc, minPrec) {
  11387. let isSatisfies;
  11388. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11389. const node = this.startNodeAt(leftStartLoc);
  11390. node.expression = left;
  11391. node.typeAnnotation = this.tsInType(() => {
  11392. this.next();
  11393. if (this.match(75)) {
  11394. if (isSatisfies) {
  11395. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11396. keyword: "const"
  11397. });
  11398. }
  11399. return this.tsParseTypeReference();
  11400. }
  11401. return this.tsParseType();
  11402. });
  11403. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11404. this.reScan_lt_gt();
  11405. return this.parseExprOp(node, leftStartLoc, minPrec);
  11406. }
  11407. return super.parseExprOp(left, leftStartLoc, minPrec);
  11408. }
  11409. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11410. if (!this.state.isAmbientContext) {
  11411. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11412. }
  11413. }
  11414. checkImportReflection(node) {
  11415. super.checkImportReflection(node);
  11416. if (node.module && node.importKind !== "value") {
  11417. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11418. }
  11419. }
  11420. checkDuplicateExports() {}
  11421. isPotentialImportPhase(isExport) {
  11422. if (super.isPotentialImportPhase(isExport)) return true;
  11423. if (this.isContextual(130)) {
  11424. const ch = this.lookaheadCharCode();
  11425. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11426. }
  11427. return !isExport && this.isContextual(87);
  11428. }
  11429. applyImportPhase(node, isExport, phase, loc) {
  11430. super.applyImportPhase(node, isExport, phase, loc);
  11431. if (isExport) {
  11432. node.exportKind = phase === "type" ? "type" : "value";
  11433. } else {
  11434. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11435. }
  11436. }
  11437. parseImport(node) {
  11438. if (this.match(133)) {
  11439. node.importKind = "value";
  11440. return super.parseImport(node);
  11441. }
  11442. let importNode;
  11443. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11444. node.importKind = "value";
  11445. return this.tsParseImportEqualsDeclaration(node);
  11446. } else if (this.isContextual(130)) {
  11447. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11448. if (this.lookaheadCharCode() === 61) {
  11449. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11450. } else {
  11451. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11452. }
  11453. } else {
  11454. importNode = super.parseImport(node);
  11455. }
  11456. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11457. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11458. }
  11459. return importNode;
  11460. }
  11461. parseExport(node, decorators) {
  11462. if (this.match(83)) {
  11463. this.next();
  11464. const nodeImportEquals = node;
  11465. let maybeDefaultIdentifier = null;
  11466. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11467. maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
  11468. } else {
  11469. nodeImportEquals.importKind = "value";
  11470. }
  11471. return this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier, true);
  11472. } else if (this.eat(29)) {
  11473. const assign = node;
  11474. assign.expression = super.parseExpression();
  11475. this.semicolon();
  11476. this.sawUnambiguousESM = true;
  11477. return this.finishNode(assign, "TSExportAssignment");
  11478. } else if (this.eatContextual(93)) {
  11479. const decl = node;
  11480. this.expectContextual(128);
  11481. decl.id = this.parseIdentifier();
  11482. this.semicolon();
  11483. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11484. } else {
  11485. return super.parseExport(node, decorators);
  11486. }
  11487. }
  11488. isAbstractClass() {
  11489. return this.isContextual(124) && this.lookahead().type === 80;
  11490. }
  11491. parseExportDefaultExpression() {
  11492. if (this.isAbstractClass()) {
  11493. const cls = this.startNode();
  11494. this.next();
  11495. cls.abstract = true;
  11496. return this.parseClass(cls, true, true);
  11497. }
  11498. if (this.match(129)) {
  11499. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11500. if (result) return result;
  11501. }
  11502. return super.parseExportDefaultExpression();
  11503. }
  11504. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11505. const {
  11506. isAmbientContext
  11507. } = this.state;
  11508. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11509. if (!isAmbientContext) return declaration;
  11510. for (const {
  11511. id,
  11512. init
  11513. } of declaration.declarations) {
  11514. if (!init) continue;
  11515. if (kind !== "const" || !!id.typeAnnotation) {
  11516. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11517. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11518. this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11519. }
  11520. }
  11521. return declaration;
  11522. }
  11523. parseStatementContent(flags, decorators) {
  11524. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11525. const node = this.startNode();
  11526. this.expect(75);
  11527. return this.tsParseEnumDeclaration(node, {
  11528. const: true
  11529. });
  11530. }
  11531. if (this.isContextual(126)) {
  11532. return this.tsParseEnumDeclaration(this.startNode());
  11533. }
  11534. if (this.isContextual(129)) {
  11535. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11536. if (result) return result;
  11537. }
  11538. return super.parseStatementContent(flags, decorators);
  11539. }
  11540. parseAccessModifier() {
  11541. return this.tsParseModifier(["public", "protected", "private"]);
  11542. }
  11543. tsHasSomeModifiers(member, modifiers) {
  11544. return modifiers.some(modifier => {
  11545. if (tsIsAccessModifier(modifier)) {
  11546. return member.accessibility === modifier;
  11547. }
  11548. return !!member[modifier];
  11549. });
  11550. }
  11551. tsIsStartOfStaticBlocks() {
  11552. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11553. }
  11554. parseClassMember(classBody, member, state) {
  11555. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11556. this.tsParseModifiers({
  11557. allowedModifiers: modifiers,
  11558. disallowedModifiers: ["in", "out"],
  11559. stopOnStartOfClassStaticBlock: true,
  11560. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11561. }, member);
  11562. const callParseClassMemberWithIsStatic = () => {
  11563. if (this.tsIsStartOfStaticBlocks()) {
  11564. this.next();
  11565. this.next();
  11566. if (this.tsHasSomeModifiers(member, modifiers)) {
  11567. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11568. }
  11569. super.parseClassStaticBlock(classBody, member);
  11570. } else {
  11571. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11572. }
  11573. };
  11574. if (member.declare) {
  11575. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11576. } else {
  11577. callParseClassMemberWithIsStatic();
  11578. }
  11579. }
  11580. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11581. const idx = this.tsTryParseIndexSignature(member);
  11582. if (idx) {
  11583. classBody.body.push(idx);
  11584. if (member.abstract) {
  11585. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11586. }
  11587. if (member.accessibility) {
  11588. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11589. modifier: member.accessibility
  11590. });
  11591. }
  11592. if (member.declare) {
  11593. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  11594. }
  11595. if (member.override) {
  11596. this.raise(TSErrors.IndexSignatureHasOverride, member);
  11597. }
  11598. return;
  11599. }
  11600. if (!this.state.inAbstractClass && member.abstract) {
  11601. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  11602. }
  11603. if (member.override) {
  11604. if (!state.hadSuperClass) {
  11605. this.raise(TSErrors.OverrideNotInSubClass, member);
  11606. }
  11607. }
  11608. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  11609. }
  11610. parsePostMemberNameModifiers(methodOrProp) {
  11611. const optional = this.eat(17);
  11612. if (optional) methodOrProp.optional = true;
  11613. if (methodOrProp.readonly && this.match(10)) {
  11614. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  11615. }
  11616. if (methodOrProp.declare && this.match(10)) {
  11617. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  11618. }
  11619. }
  11620. parseExpressionStatement(node, expr, decorators) {
  11621. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  11622. return decl || super.parseExpressionStatement(node, expr, decorators);
  11623. }
  11624. shouldParseExportDeclaration() {
  11625. if (this.tsIsDeclarationStart()) return true;
  11626. return super.shouldParseExportDeclaration();
  11627. }
  11628. parseConditional(expr, startLoc, refExpressionErrors) {
  11629. if (!this.state.maybeInArrowParameters || !this.match(17)) {
  11630. return super.parseConditional(expr, startLoc, refExpressionErrors);
  11631. }
  11632. const result = this.tryParse(() => super.parseConditional(expr, startLoc));
  11633. if (!result.node) {
  11634. if (result.error) {
  11635. super.setOptionalParametersError(refExpressionErrors, result.error);
  11636. }
  11637. return expr;
  11638. }
  11639. if (result.error) this.state = result.failState;
  11640. return result.node;
  11641. }
  11642. parseParenItem(node, startLoc) {
  11643. const newNode = super.parseParenItem(node, startLoc);
  11644. if (this.eat(17)) {
  11645. newNode.optional = true;
  11646. this.resetEndLocation(node);
  11647. }
  11648. if (this.match(14)) {
  11649. const typeCastNode = this.startNodeAt(startLoc);
  11650. typeCastNode.expression = node;
  11651. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  11652. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  11653. }
  11654. return node;
  11655. }
  11656. parseExportDeclaration(node) {
  11657. if (!this.state.isAmbientContext && this.isContextual(125)) {
  11658. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  11659. }
  11660. const startLoc = this.state.startLoc;
  11661. const isDeclare = this.eatContextual(125);
  11662. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  11663. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  11664. }
  11665. const isIdentifier = tokenIsIdentifier(this.state.type);
  11666. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  11667. if (!declaration) return null;
  11668. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  11669. node.exportKind = "type";
  11670. }
  11671. if (isDeclare) {
  11672. this.resetStartLocation(declaration, startLoc);
  11673. declaration.declare = true;
  11674. }
  11675. return declaration;
  11676. }
  11677. parseClassId(node, isStatement, optionalId, bindingType) {
  11678. if ((!isStatement || optionalId) && this.isContextual(113)) {
  11679. return;
  11680. }
  11681. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  11682. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11683. if (typeParameters) node.typeParameters = typeParameters;
  11684. }
  11685. parseClassPropertyAnnotation(node) {
  11686. if (!node.optional) {
  11687. if (this.eat(35)) {
  11688. node.definite = true;
  11689. } else if (this.eat(17)) {
  11690. node.optional = true;
  11691. }
  11692. }
  11693. const type = this.tsTryParseTypeAnnotation();
  11694. if (type) node.typeAnnotation = type;
  11695. }
  11696. parseClassProperty(node) {
  11697. this.parseClassPropertyAnnotation(node);
  11698. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  11699. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  11700. }
  11701. if (node.abstract && this.match(29)) {
  11702. const {
  11703. key
  11704. } = node;
  11705. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  11706. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  11707. });
  11708. }
  11709. return super.parseClassProperty(node);
  11710. }
  11711. parseClassPrivateProperty(node) {
  11712. if (node.abstract) {
  11713. this.raise(TSErrors.PrivateElementHasAbstract, node);
  11714. }
  11715. if (node.accessibility) {
  11716. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  11717. modifier: node.accessibility
  11718. });
  11719. }
  11720. this.parseClassPropertyAnnotation(node);
  11721. return super.parseClassPrivateProperty(node);
  11722. }
  11723. parseClassAccessorProperty(node) {
  11724. this.parseClassPropertyAnnotation(node);
  11725. if (node.optional) {
  11726. this.raise(TSErrors.AccessorCannotBeOptional, node);
  11727. }
  11728. return super.parseClassAccessorProperty(node);
  11729. }
  11730. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  11731. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11732. if (typeParameters && isConstructor) {
  11733. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  11734. }
  11735. const {
  11736. declare = false,
  11737. kind
  11738. } = method;
  11739. if (declare && (kind === "get" || kind === "set")) {
  11740. this.raise(TSErrors.DeclareAccessor, method, {
  11741. kind
  11742. });
  11743. }
  11744. if (typeParameters) method.typeParameters = typeParameters;
  11745. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  11746. }
  11747. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  11748. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11749. if (typeParameters) method.typeParameters = typeParameters;
  11750. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  11751. }
  11752. declareClassPrivateMethodInScope(node, kind) {
  11753. if (node.type === "TSDeclareMethod") return;
  11754. if (node.type === "MethodDefinition" && !hasOwnProperty.call(node.value, "body")) {
  11755. return;
  11756. }
  11757. super.declareClassPrivateMethodInScope(node, kind);
  11758. }
  11759. parseClassSuper(node) {
  11760. super.parseClassSuper(node);
  11761. if (node.superClass && (this.match(47) || this.match(51))) {
  11762. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  11763. }
  11764. if (this.eatContextual(113)) {
  11765. node.implements = this.tsParseHeritageClause("implements");
  11766. }
  11767. }
  11768. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  11769. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11770. if (typeParameters) prop.typeParameters = typeParameters;
  11771. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  11772. }
  11773. parseFunctionParams(node, isConstructor) {
  11774. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11775. if (typeParameters) node.typeParameters = typeParameters;
  11776. super.parseFunctionParams(node, isConstructor);
  11777. }
  11778. parseVarId(decl, kind) {
  11779. super.parseVarId(decl, kind);
  11780. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  11781. decl.definite = true;
  11782. }
  11783. const type = this.tsTryParseTypeAnnotation();
  11784. if (type) {
  11785. decl.id.typeAnnotation = type;
  11786. this.resetEndLocation(decl.id);
  11787. }
  11788. }
  11789. parseAsyncArrowFromCallExpression(node, call) {
  11790. if (this.match(14)) {
  11791. node.returnType = this.tsParseTypeAnnotation();
  11792. }
  11793. return super.parseAsyncArrowFromCallExpression(node, call);
  11794. }
  11795. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  11796. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  11797. let state;
  11798. let jsx;
  11799. let typeCast;
  11800. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  11801. state = this.state.clone();
  11802. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11803. if (!jsx.error) return jsx.node;
  11804. const {
  11805. context
  11806. } = this.state;
  11807. const currentContext = context[context.length - 1];
  11808. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  11809. context.pop();
  11810. }
  11811. }
  11812. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  11813. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11814. }
  11815. if (!state || state === this.state) state = this.state.clone();
  11816. let typeParameters;
  11817. const arrow = this.tryParse(abort => {
  11818. var _expr$extra, _typeParameters;
  11819. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11820. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11821. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  11822. abort();
  11823. }
  11824. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  11825. this.resetStartLocationFromNode(expr, typeParameters);
  11826. }
  11827. expr.typeParameters = typeParameters;
  11828. return expr;
  11829. }, state);
  11830. if (!arrow.error && !arrow.aborted) {
  11831. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11832. return arrow.node;
  11833. }
  11834. if (!jsx) {
  11835. assert(!this.hasPlugin("jsx"));
  11836. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11837. if (!typeCast.error) return typeCast.node;
  11838. }
  11839. if ((_jsx2 = jsx) != null && _jsx2.node) {
  11840. this.state = jsx.failState;
  11841. return jsx.node;
  11842. }
  11843. if (arrow.node) {
  11844. this.state = arrow.failState;
  11845. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11846. return arrow.node;
  11847. }
  11848. if ((_typeCast = typeCast) != null && _typeCast.node) {
  11849. this.state = typeCast.failState;
  11850. return typeCast.node;
  11851. }
  11852. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  11853. }
  11854. reportReservedArrowTypeParam(node) {
  11855. var _node$extra;
  11856. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11857. this.raise(TSErrors.ReservedArrowTypeParam, node);
  11858. }
  11859. }
  11860. parseMaybeUnary(refExpressionErrors, sawUnary) {
  11861. if (!this.hasPlugin("jsx") && this.match(47)) {
  11862. return this.tsParseTypeAssertion();
  11863. }
  11864. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  11865. }
  11866. parseArrow(node) {
  11867. if (this.match(14)) {
  11868. const result = this.tryParse(abort => {
  11869. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11870. if (this.canInsertSemicolon() || !this.match(19)) abort();
  11871. return returnType;
  11872. });
  11873. if (result.aborted) return;
  11874. if (!result.thrown) {
  11875. if (result.error) this.state = result.failState;
  11876. node.returnType = result.node;
  11877. }
  11878. }
  11879. return super.parseArrow(node);
  11880. }
  11881. parseAssignableListItemTypes(param, flags) {
  11882. if (!(flags & 2)) return param;
  11883. if (this.eat(17)) {
  11884. param.optional = true;
  11885. }
  11886. const type = this.tsTryParseTypeAnnotation();
  11887. if (type) param.typeAnnotation = type;
  11888. this.resetEndLocation(param);
  11889. return param;
  11890. }
  11891. isAssignable(node, isBinding) {
  11892. switch (node.type) {
  11893. case "TSTypeCastExpression":
  11894. return this.isAssignable(node.expression, isBinding);
  11895. case "TSParameterProperty":
  11896. return true;
  11897. default:
  11898. return super.isAssignable(node, isBinding);
  11899. }
  11900. }
  11901. toAssignable(node, isLHS = false) {
  11902. switch (node.type) {
  11903. case "ParenthesizedExpression":
  11904. this.toAssignableParenthesizedExpression(node, isLHS);
  11905. break;
  11906. case "TSAsExpression":
  11907. case "TSSatisfiesExpression":
  11908. case "TSNonNullExpression":
  11909. case "TSTypeAssertion":
  11910. if (isLHS) {
  11911. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  11912. } else {
  11913. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  11914. }
  11915. this.toAssignable(node.expression, isLHS);
  11916. break;
  11917. case "AssignmentExpression":
  11918. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  11919. node.left = this.typeCastToParameter(node.left);
  11920. }
  11921. default:
  11922. super.toAssignable(node, isLHS);
  11923. }
  11924. }
  11925. toAssignableParenthesizedExpression(node, isLHS) {
  11926. switch (node.expression.type) {
  11927. case "TSAsExpression":
  11928. case "TSSatisfiesExpression":
  11929. case "TSNonNullExpression":
  11930. case "TSTypeAssertion":
  11931. case "ParenthesizedExpression":
  11932. this.toAssignable(node.expression, isLHS);
  11933. break;
  11934. default:
  11935. super.toAssignable(node, isLHS);
  11936. }
  11937. }
  11938. checkToRestConversion(node, allowPattern) {
  11939. switch (node.type) {
  11940. case "TSAsExpression":
  11941. case "TSSatisfiesExpression":
  11942. case "TSTypeAssertion":
  11943. case "TSNonNullExpression":
  11944. this.checkToRestConversion(node.expression, false);
  11945. break;
  11946. default:
  11947. super.checkToRestConversion(node, allowPattern);
  11948. }
  11949. }
  11950. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  11951. switch (type) {
  11952. case "TSTypeCastExpression":
  11953. return true;
  11954. case "TSParameterProperty":
  11955. return "parameter";
  11956. case "TSNonNullExpression":
  11957. case "TSInstantiationExpression":
  11958. return "expression";
  11959. case "TSAsExpression":
  11960. case "TSSatisfiesExpression":
  11961. case "TSTypeAssertion":
  11962. return (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true];
  11963. default:
  11964. return super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  11965. }
  11966. }
  11967. parseBindingAtom() {
  11968. if (this.state.type === 78) {
  11969. return this.parseIdentifier(true);
  11970. }
  11971. return super.parseBindingAtom();
  11972. }
  11973. parseMaybeDecoratorArguments(expr) {
  11974. if (this.match(47) || this.match(51)) {
  11975. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11976. if (this.match(10)) {
  11977. const call = super.parseMaybeDecoratorArguments(expr);
  11978. call.typeParameters = typeArguments;
  11979. return call;
  11980. }
  11981. this.unexpected(null, 10);
  11982. }
  11983. return super.parseMaybeDecoratorArguments(expr);
  11984. }
  11985. checkCommaAfterRest(close) {
  11986. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  11987. this.next();
  11988. return false;
  11989. }
  11990. return super.checkCommaAfterRest(close);
  11991. }
  11992. isClassMethod() {
  11993. return this.match(47) || super.isClassMethod();
  11994. }
  11995. isClassProperty() {
  11996. return this.match(35) || this.match(14) || super.isClassProperty();
  11997. }
  11998. parseMaybeDefault(startLoc, left) {
  11999. const node = super.parseMaybeDefault(startLoc, left);
  12000. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  12001. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  12002. }
  12003. return node;
  12004. }
  12005. getTokenFromCode(code) {
  12006. if (this.state.inType) {
  12007. if (code === 62) {
  12008. this.finishOp(48, 1);
  12009. return;
  12010. }
  12011. if (code === 60) {
  12012. this.finishOp(47, 1);
  12013. return;
  12014. }
  12015. }
  12016. super.getTokenFromCode(code);
  12017. }
  12018. reScan_lt_gt() {
  12019. const {
  12020. type
  12021. } = this.state;
  12022. if (type === 47) {
  12023. this.state.pos -= 1;
  12024. this.readToken_lt();
  12025. } else if (type === 48) {
  12026. this.state.pos -= 1;
  12027. this.readToken_gt();
  12028. }
  12029. }
  12030. reScan_lt() {
  12031. const {
  12032. type
  12033. } = this.state;
  12034. if (type === 51) {
  12035. this.state.pos -= 2;
  12036. this.finishOp(47, 1);
  12037. return 47;
  12038. }
  12039. return type;
  12040. }
  12041. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  12042. for (let i = 0; i < exprList.length; i++) {
  12043. const expr = exprList[i];
  12044. if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
  12045. exprList[i] = this.typeCastToParameter(expr);
  12046. }
  12047. }
  12048. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  12049. }
  12050. typeCastToParameter(node) {
  12051. node.expression.typeAnnotation = node.typeAnnotation;
  12052. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  12053. return node.expression;
  12054. }
  12055. shouldParseArrow(params) {
  12056. if (this.match(14)) {
  12057. return params.every(expr => this.isAssignable(expr, true));
  12058. }
  12059. return super.shouldParseArrow(params);
  12060. }
  12061. shouldParseAsyncArrow() {
  12062. return this.match(14) || super.shouldParseAsyncArrow();
  12063. }
  12064. canHaveLeadingDecorator() {
  12065. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  12066. }
  12067. jsxParseOpeningElementAfterName(node) {
  12068. if (this.match(47) || this.match(51)) {
  12069. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  12070. if (typeArguments) node.typeParameters = typeArguments;
  12071. }
  12072. return super.jsxParseOpeningElementAfterName(node);
  12073. }
  12074. getGetterSetterExpectedParamCount(method) {
  12075. const baseCount = super.getGetterSetterExpectedParamCount(method);
  12076. const params = this.getObjectOrClassMethodParams(method);
  12077. const firstParam = params[0];
  12078. const hasContextParam = firstParam && this.isThisParam(firstParam);
  12079. return hasContextParam ? baseCount + 1 : baseCount;
  12080. }
  12081. parseCatchClauseParam() {
  12082. const param = super.parseCatchClauseParam();
  12083. const type = this.tsTryParseTypeAnnotation();
  12084. if (type) {
  12085. param.typeAnnotation = type;
  12086. this.resetEndLocation(param);
  12087. }
  12088. return param;
  12089. }
  12090. tsInAmbientContext(cb) {
  12091. const {
  12092. isAmbientContext: oldIsAmbientContext,
  12093. strict: oldStrict
  12094. } = this.state;
  12095. this.state.isAmbientContext = true;
  12096. this.state.strict = false;
  12097. try {
  12098. return cb();
  12099. } finally {
  12100. this.state.isAmbientContext = oldIsAmbientContext;
  12101. this.state.strict = oldStrict;
  12102. }
  12103. }
  12104. parseClass(node, isStatement, optionalId) {
  12105. const oldInAbstractClass = this.state.inAbstractClass;
  12106. this.state.inAbstractClass = !!node.abstract;
  12107. try {
  12108. return super.parseClass(node, isStatement, optionalId);
  12109. } finally {
  12110. this.state.inAbstractClass = oldInAbstractClass;
  12111. }
  12112. }
  12113. tsParseAbstractDeclaration(node, decorators) {
  12114. if (this.match(80)) {
  12115. node.abstract = true;
  12116. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12117. } else if (this.isContextual(129)) {
  12118. if (!this.hasFollowingLineBreak()) {
  12119. node.abstract = true;
  12120. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node);
  12121. return this.tsParseInterfaceDeclaration(node);
  12122. }
  12123. } else {
  12124. this.unexpected(null, 80);
  12125. }
  12126. }
  12127. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12128. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12129. if (method.abstract) {
  12130. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  12131. if (hasBody) {
  12132. const {
  12133. key
  12134. } = method;
  12135. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12136. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  12137. });
  12138. }
  12139. }
  12140. return method;
  12141. }
  12142. tsParseTypeParameterName() {
  12143. const typeName = this.parseIdentifier();
  12144. return typeName.name;
  12145. }
  12146. shouldParseAsAmbientContext() {
  12147. return !!this.getPluginOption("typescript", "dts");
  12148. }
  12149. parse() {
  12150. if (this.shouldParseAsAmbientContext()) {
  12151. this.state.isAmbientContext = true;
  12152. }
  12153. return super.parse();
  12154. }
  12155. getExpression() {
  12156. if (this.shouldParseAsAmbientContext()) {
  12157. this.state.isAmbientContext = true;
  12158. }
  12159. return super.getExpression();
  12160. }
  12161. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12162. if (!isString && isMaybeTypeOnly) {
  12163. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12164. return this.finishNode(node, "ExportSpecifier");
  12165. }
  12166. node.exportKind = "value";
  12167. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12168. }
  12169. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12170. if (!importedIsString && isMaybeTypeOnly) {
  12171. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12172. return this.finishNode(specifier, "ImportSpecifier");
  12173. }
  12174. specifier.importKind = "value";
  12175. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12176. }
  12177. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12178. const leftOfAsKey = isImport ? "imported" : "local";
  12179. const rightOfAsKey = isImport ? "local" : "exported";
  12180. let leftOfAs = node[leftOfAsKey];
  12181. let rightOfAs;
  12182. let hasTypeSpecifier = false;
  12183. let canParseAsKeyword = true;
  12184. const loc = leftOfAs.loc.start;
  12185. if (this.isContextual(93)) {
  12186. const firstAs = this.parseIdentifier();
  12187. if (this.isContextual(93)) {
  12188. const secondAs = this.parseIdentifier();
  12189. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12190. hasTypeSpecifier = true;
  12191. leftOfAs = firstAs;
  12192. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12193. canParseAsKeyword = false;
  12194. } else {
  12195. rightOfAs = secondAs;
  12196. canParseAsKeyword = false;
  12197. }
  12198. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12199. canParseAsKeyword = false;
  12200. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12201. } else {
  12202. hasTypeSpecifier = true;
  12203. leftOfAs = firstAs;
  12204. }
  12205. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12206. hasTypeSpecifier = true;
  12207. if (isImport) {
  12208. leftOfAs = this.parseIdentifier(true);
  12209. if (!this.isContextual(93)) {
  12210. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12211. }
  12212. } else {
  12213. leftOfAs = this.parseModuleExportName();
  12214. }
  12215. }
  12216. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12217. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12218. }
  12219. node[leftOfAsKey] = leftOfAs;
  12220. node[rightOfAsKey] = rightOfAs;
  12221. const kindKey = isImport ? "importKind" : "exportKind";
  12222. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12223. if (canParseAsKeyword && this.eatContextual(93)) {
  12224. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12225. }
  12226. if (!node[rightOfAsKey]) {
  12227. node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]);
  12228. }
  12229. if (isImport) {
  12230. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12231. }
  12232. }
  12233. };
  12234. function isPossiblyLiteralEnum(expression) {
  12235. if (expression.type !== "MemberExpression") return false;
  12236. const {
  12237. computed,
  12238. property
  12239. } = expression;
  12240. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12241. return false;
  12242. }
  12243. return isUncomputedMemberExpressionChain(expression.object);
  12244. }
  12245. function isValidAmbientConstInitializer(expression, estree) {
  12246. var _expression$extra;
  12247. const {
  12248. type
  12249. } = expression;
  12250. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12251. return false;
  12252. }
  12253. if (estree) {
  12254. if (type === "Literal") {
  12255. const {
  12256. value
  12257. } = expression;
  12258. if (typeof value === "string" || typeof value === "boolean") {
  12259. return true;
  12260. }
  12261. }
  12262. } else {
  12263. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12264. return true;
  12265. }
  12266. }
  12267. if (isNumber(expression, estree) || isNegativeNumber(expression, estree)) {
  12268. return true;
  12269. }
  12270. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12271. return true;
  12272. }
  12273. if (isPossiblyLiteralEnum(expression)) {
  12274. return true;
  12275. }
  12276. return false;
  12277. }
  12278. function isNumber(expression, estree) {
  12279. if (estree) {
  12280. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12281. }
  12282. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12283. }
  12284. function isNegativeNumber(expression, estree) {
  12285. if (expression.type === "UnaryExpression") {
  12286. const {
  12287. operator,
  12288. argument
  12289. } = expression;
  12290. if (operator === "-" && isNumber(argument, estree)) {
  12291. return true;
  12292. }
  12293. }
  12294. return false;
  12295. }
  12296. function isUncomputedMemberExpressionChain(expression) {
  12297. if (expression.type === "Identifier") return true;
  12298. if (expression.type !== "MemberExpression" || expression.computed) {
  12299. return false;
  12300. }
  12301. return isUncomputedMemberExpressionChain(expression.object);
  12302. }
  12303. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12304. ClassNameIsRequired: "A class name is required.",
  12305. UnexpectedSpace: "Unexpected space in placeholder."
  12306. });
  12307. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12308. parsePlaceholder(expectedNode) {
  12309. if (this.match(144)) {
  12310. const node = this.startNode();
  12311. this.next();
  12312. this.assertNoSpace();
  12313. node.name = super.parseIdentifier(true);
  12314. this.assertNoSpace();
  12315. this.expect(144);
  12316. return this.finishPlaceholder(node, expectedNode);
  12317. }
  12318. }
  12319. finishPlaceholder(node, expectedNode) {
  12320. let placeholder = node;
  12321. if (!placeholder.expectedNode || !placeholder.type) {
  12322. placeholder = this.finishNode(placeholder, "Placeholder");
  12323. }
  12324. placeholder.expectedNode = expectedNode;
  12325. return placeholder;
  12326. }
  12327. getTokenFromCode(code) {
  12328. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12329. this.finishOp(144, 2);
  12330. } else {
  12331. super.getTokenFromCode(code);
  12332. }
  12333. }
  12334. parseExprAtom(refExpressionErrors) {
  12335. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12336. }
  12337. parseIdentifier(liberal) {
  12338. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12339. }
  12340. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12341. if (word !== undefined) {
  12342. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12343. }
  12344. }
  12345. parseBindingAtom() {
  12346. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12347. }
  12348. isValidLVal(type, isParenthesized, binding) {
  12349. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12350. }
  12351. toAssignable(node, isLHS) {
  12352. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12353. node.expectedNode = "Pattern";
  12354. } else {
  12355. super.toAssignable(node, isLHS);
  12356. }
  12357. }
  12358. chStartsBindingIdentifier(ch, pos) {
  12359. if (super.chStartsBindingIdentifier(ch, pos)) {
  12360. return true;
  12361. }
  12362. const nextToken = this.lookahead();
  12363. if (nextToken.type === 144) {
  12364. return true;
  12365. }
  12366. return false;
  12367. }
  12368. verifyBreakContinue(node, isBreak) {
  12369. if (node.label && node.label.type === "Placeholder") return;
  12370. super.verifyBreakContinue(node, isBreak);
  12371. }
  12372. parseExpressionStatement(node, expr) {
  12373. var _expr$extra;
  12374. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12375. return super.parseExpressionStatement(node, expr);
  12376. }
  12377. if (this.match(14)) {
  12378. const stmt = node;
  12379. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12380. this.next();
  12381. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12382. return this.finishNode(stmt, "LabeledStatement");
  12383. }
  12384. this.semicolon();
  12385. const stmtPlaceholder = node;
  12386. stmtPlaceholder.name = expr.name;
  12387. return this.finishPlaceholder(stmtPlaceholder, "Statement");
  12388. }
  12389. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12390. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12391. }
  12392. parseFunctionId(requireId) {
  12393. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12394. }
  12395. parseClass(node, isStatement, optionalId) {
  12396. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12397. this.next();
  12398. const oldStrict = this.state.strict;
  12399. const placeholder = this.parsePlaceholder("Identifier");
  12400. if (placeholder) {
  12401. if (this.match(81) || this.match(144) || this.match(5)) {
  12402. node.id = placeholder;
  12403. } else if (optionalId || !isStatement) {
  12404. node.id = null;
  12405. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12406. return this.finishNode(node, type);
  12407. } else {
  12408. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12409. }
  12410. } else {
  12411. this.parseClassId(node, isStatement, optionalId);
  12412. }
  12413. super.parseClassSuper(node);
  12414. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12415. return this.finishNode(node, type);
  12416. }
  12417. parseExport(node, decorators) {
  12418. const placeholder = this.parsePlaceholder("Identifier");
  12419. if (!placeholder) return super.parseExport(node, decorators);
  12420. const node2 = node;
  12421. if (!this.isContextual(98) && !this.match(12)) {
  12422. node2.specifiers = [];
  12423. node2.source = null;
  12424. node2.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12425. return this.finishNode(node2, "ExportNamedDeclaration");
  12426. }
  12427. this.expectPlugin("exportDefaultFrom");
  12428. const specifier = this.startNode();
  12429. specifier.exported = placeholder;
  12430. node2.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12431. return super.parseExport(node2, decorators);
  12432. }
  12433. isExportDefaultSpecifier() {
  12434. if (this.match(65)) {
  12435. const next = this.nextTokenStart();
  12436. if (this.isUnparsedContextual(next, "from")) {
  12437. if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
  12438. return true;
  12439. }
  12440. }
  12441. }
  12442. return super.isExportDefaultSpecifier();
  12443. }
  12444. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12445. var _specifiers;
  12446. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12447. return true;
  12448. }
  12449. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12450. }
  12451. checkExport(node) {
  12452. const {
  12453. specifiers
  12454. } = node;
  12455. if (specifiers != null && specifiers.length) {
  12456. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12457. }
  12458. super.checkExport(node);
  12459. node.specifiers = specifiers;
  12460. }
  12461. parseImport(node) {
  12462. const placeholder = this.parsePlaceholder("Identifier");
  12463. if (!placeholder) return super.parseImport(node);
  12464. node.specifiers = [];
  12465. if (!this.isContextual(98) && !this.match(12)) {
  12466. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12467. this.semicolon();
  12468. return this.finishNode(node, "ImportDeclaration");
  12469. }
  12470. const specifier = this.startNodeAtNode(placeholder);
  12471. specifier.local = placeholder;
  12472. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  12473. if (this.eat(12)) {
  12474. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  12475. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  12476. }
  12477. this.expectContextual(98);
  12478. node.source = this.parseImportSource();
  12479. this.semicolon();
  12480. return this.finishNode(node, "ImportDeclaration");
  12481. }
  12482. parseImportSource() {
  12483. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  12484. }
  12485. assertNoSpace() {
  12486. if (this.state.start > this.state.lastTokEndLoc.index) {
  12487. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  12488. }
  12489. }
  12490. };
  12491. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  12492. parseV8Intrinsic() {
  12493. if (this.match(54)) {
  12494. const v8IntrinsicStartLoc = this.state.startLoc;
  12495. const node = this.startNode();
  12496. this.next();
  12497. if (tokenIsIdentifier(this.state.type)) {
  12498. const name = this.parseIdentifierName();
  12499. const identifier = this.createIdentifier(node, name);
  12500. identifier.type = "V8IntrinsicIdentifier";
  12501. if (this.match(10)) {
  12502. return identifier;
  12503. }
  12504. }
  12505. this.unexpected(v8IntrinsicStartLoc);
  12506. }
  12507. }
  12508. parseExprAtom(refExpressionErrors) {
  12509. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  12510. }
  12511. };
  12512. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  12513. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  12514. function validatePlugins(pluginsMap) {
  12515. if (pluginsMap.has("decorators")) {
  12516. if (pluginsMap.has("decorators-legacy")) {
  12517. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  12518. }
  12519. const decoratorsBeforeExport = pluginsMap.get("decorators").decoratorsBeforeExport;
  12520. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  12521. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  12522. }
  12523. const allowCallParenthesized = pluginsMap.get("decorators").allowCallParenthesized;
  12524. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  12525. throw new Error("'allowCallParenthesized' must be a boolean.");
  12526. }
  12527. }
  12528. if (pluginsMap.has("flow") && pluginsMap.has("typescript")) {
  12529. throw new Error("Cannot combine flow and typescript plugins.");
  12530. }
  12531. if (pluginsMap.has("placeholders") && pluginsMap.has("v8intrinsic")) {
  12532. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  12533. }
  12534. if (pluginsMap.has("pipelineOperator")) {
  12535. var _pluginsMap$get;
  12536. const proposal = pluginsMap.get("pipelineOperator").proposal;
  12537. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  12538. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  12539. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  12540. }
  12541. const tupleSyntaxIsHash = ((_pluginsMap$get = pluginsMap.get("recordAndTuple")) == null ? void 0 : _pluginsMap$get.syntaxType) === "hash";
  12542. if (proposal === "hack") {
  12543. if (pluginsMap.has("placeholders")) {
  12544. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  12545. }
  12546. if (pluginsMap.has("v8intrinsic")) {
  12547. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  12548. }
  12549. const topicToken = pluginsMap.get("pipelineOperator").topicToken;
  12550. if (!TOPIC_TOKENS.includes(topicToken)) {
  12551. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  12552. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  12553. }
  12554. if (topicToken === "#" && tupleSyntaxIsHash) {
  12555. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  12556. }
  12557. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  12558. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  12559. }
  12560. }
  12561. if (pluginsMap.has("moduleAttributes")) {
  12562. {
  12563. if (pluginsMap.has("importAttributes") || pluginsMap.has("importAssertions")) {
  12564. throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");
  12565. }
  12566. const moduleAttributesVersionPluginOption = pluginsMap.get("moduleAttributes").version;
  12567. if (moduleAttributesVersionPluginOption !== "may-2020") {
  12568. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  12569. }
  12570. }
  12571. }
  12572. if (pluginsMap.has("importAttributes") && pluginsMap.has("importAssertions")) {
  12573. throw new Error("Cannot combine importAssertions and importAttributes plugins.");
  12574. }
  12575. if (pluginsMap.has("recordAndTuple")) {
  12576. const syntaxType = pluginsMap.get("recordAndTuple").syntaxType;
  12577. if (syntaxType != null) {
  12578. {
  12579. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  12580. if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) {
  12581. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  12582. }
  12583. }
  12584. }
  12585. }
  12586. if (pluginsMap.has("asyncDoExpressions") && !pluginsMap.has("doExpressions")) {
  12587. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  12588. error.missingPlugins = "doExpressions";
  12589. throw error;
  12590. }
  12591. if (pluginsMap.has("optionalChainingAssign") && pluginsMap.get("optionalChainingAssign").version !== "2023-07") {
  12592. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  12593. }
  12594. }
  12595. const mixinPlugins = {
  12596. estree,
  12597. jsx,
  12598. flow,
  12599. typescript,
  12600. v8intrinsic,
  12601. placeholders
  12602. };
  12603. const mixinPluginNames = Object.keys(mixinPlugins);
  12604. const defaultOptions = {
  12605. sourceType: "script",
  12606. sourceFilename: undefined,
  12607. startColumn: 0,
  12608. startLine: 1,
  12609. allowAwaitOutsideFunction: false,
  12610. allowReturnOutsideFunction: false,
  12611. allowNewTargetOutsideFunction: false,
  12612. allowImportExportEverywhere: false,
  12613. allowSuperOutsideMethod: false,
  12614. allowUndeclaredExports: false,
  12615. plugins: [],
  12616. strictMode: null,
  12617. ranges: false,
  12618. tokens: false,
  12619. createImportExpressions: false,
  12620. createParenthesizedExpressions: false,
  12621. errorRecovery: false,
  12622. attachComment: true,
  12623. annexB: true
  12624. };
  12625. function getOptions(opts) {
  12626. if (opts == null) {
  12627. return Object.assign({}, defaultOptions);
  12628. }
  12629. if (opts.annexB != null && opts.annexB !== false) {
  12630. throw new Error("The `annexB` option can only be set to `false`.");
  12631. }
  12632. const options = {};
  12633. for (const key of Object.keys(defaultOptions)) {
  12634. var _opts$key;
  12635. options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key];
  12636. }
  12637. return options;
  12638. }
  12639. class ExpressionParser extends LValParser {
  12640. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  12641. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  12642. return;
  12643. }
  12644. const key = prop.key;
  12645. const name = key.type === "Identifier" ? key.name : key.value;
  12646. if (name === "__proto__") {
  12647. if (isRecord) {
  12648. this.raise(Errors.RecordNoProto, key);
  12649. return;
  12650. }
  12651. if (protoRef.used) {
  12652. if (refExpressionErrors) {
  12653. if (refExpressionErrors.doubleProtoLoc === null) {
  12654. refExpressionErrors.doubleProtoLoc = key.loc.start;
  12655. }
  12656. } else {
  12657. this.raise(Errors.DuplicateProto, key);
  12658. }
  12659. }
  12660. protoRef.used = true;
  12661. }
  12662. }
  12663. shouldExitDescending(expr, potentialArrowAt) {
  12664. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  12665. }
  12666. getExpression() {
  12667. this.enterInitialScopes();
  12668. this.nextToken();
  12669. const expr = this.parseExpression();
  12670. if (!this.match(139)) {
  12671. this.unexpected();
  12672. }
  12673. this.finalizeRemainingComments();
  12674. expr.comments = this.comments;
  12675. expr.errors = this.state.errors;
  12676. if (this.options.tokens) {
  12677. expr.tokens = this.tokens;
  12678. }
  12679. return expr;
  12680. }
  12681. parseExpression(disallowIn, refExpressionErrors) {
  12682. if (disallowIn) {
  12683. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12684. }
  12685. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12686. }
  12687. parseExpressionBase(refExpressionErrors) {
  12688. const startLoc = this.state.startLoc;
  12689. const expr = this.parseMaybeAssign(refExpressionErrors);
  12690. if (this.match(12)) {
  12691. const node = this.startNodeAt(startLoc);
  12692. node.expressions = [expr];
  12693. while (this.eat(12)) {
  12694. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  12695. }
  12696. this.toReferencedList(node.expressions);
  12697. return this.finishNode(node, "SequenceExpression");
  12698. }
  12699. return expr;
  12700. }
  12701. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  12702. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12703. }
  12704. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  12705. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12706. }
  12707. setOptionalParametersError(refExpressionErrors, resultError) {
  12708. var _resultError$loc;
  12709. refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
  12710. }
  12711. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12712. const startLoc = this.state.startLoc;
  12713. if (this.isContextual(108)) {
  12714. if (this.prodParam.hasYield) {
  12715. let left = this.parseYield();
  12716. if (afterLeftParse) {
  12717. left = afterLeftParse.call(this, left, startLoc);
  12718. }
  12719. return left;
  12720. }
  12721. }
  12722. let ownExpressionErrors;
  12723. if (refExpressionErrors) {
  12724. ownExpressionErrors = false;
  12725. } else {
  12726. refExpressionErrors = new ExpressionErrors();
  12727. ownExpressionErrors = true;
  12728. }
  12729. const {
  12730. type
  12731. } = this.state;
  12732. if (type === 10 || tokenIsIdentifier(type)) {
  12733. this.state.potentialArrowAt = this.state.start;
  12734. }
  12735. let left = this.parseMaybeConditional(refExpressionErrors);
  12736. if (afterLeftParse) {
  12737. left = afterLeftParse.call(this, left, startLoc);
  12738. }
  12739. if (tokenIsAssignment(this.state.type)) {
  12740. const node = this.startNodeAt(startLoc);
  12741. const operator = this.state.value;
  12742. node.operator = operator;
  12743. if (this.match(29)) {
  12744. this.toAssignable(left, true);
  12745. node.left = left;
  12746. const startIndex = startLoc.index;
  12747. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  12748. refExpressionErrors.doubleProtoLoc = null;
  12749. }
  12750. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  12751. refExpressionErrors.shorthandAssignLoc = null;
  12752. }
  12753. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  12754. this.checkDestructuringPrivate(refExpressionErrors);
  12755. refExpressionErrors.privateKeyLoc = null;
  12756. }
  12757. } else {
  12758. node.left = left;
  12759. }
  12760. this.next();
  12761. node.right = this.parseMaybeAssign();
  12762. this.checkLVal(left, this.finishNode(node, "AssignmentExpression"));
  12763. return node;
  12764. } else if (ownExpressionErrors) {
  12765. this.checkExpressionErrors(refExpressionErrors, true);
  12766. }
  12767. return left;
  12768. }
  12769. parseMaybeConditional(refExpressionErrors) {
  12770. const startLoc = this.state.startLoc;
  12771. const potentialArrowAt = this.state.potentialArrowAt;
  12772. const expr = this.parseExprOps(refExpressionErrors);
  12773. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12774. return expr;
  12775. }
  12776. return this.parseConditional(expr, startLoc, refExpressionErrors);
  12777. }
  12778. parseConditional(expr, startLoc, refExpressionErrors) {
  12779. if (this.eat(17)) {
  12780. const node = this.startNodeAt(startLoc);
  12781. node.test = expr;
  12782. node.consequent = this.parseMaybeAssignAllowIn();
  12783. this.expect(14);
  12784. node.alternate = this.parseMaybeAssign();
  12785. return this.finishNode(node, "ConditionalExpression");
  12786. }
  12787. return expr;
  12788. }
  12789. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  12790. return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  12791. }
  12792. parseExprOps(refExpressionErrors) {
  12793. const startLoc = this.state.startLoc;
  12794. const potentialArrowAt = this.state.potentialArrowAt;
  12795. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  12796. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12797. return expr;
  12798. }
  12799. return this.parseExprOp(expr, startLoc, -1);
  12800. }
  12801. parseExprOp(left, leftStartLoc, minPrec) {
  12802. if (this.isPrivateName(left)) {
  12803. const value = this.getPrivateNameSV(left);
  12804. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  12805. this.raise(Errors.PrivateInExpectedIn, left, {
  12806. identifierName: value
  12807. });
  12808. }
  12809. this.classScope.usePrivateName(value, left.loc.start);
  12810. }
  12811. const op = this.state.type;
  12812. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  12813. let prec = tokenOperatorPrecedence(op);
  12814. if (prec > minPrec) {
  12815. if (op === 39) {
  12816. this.expectPlugin("pipelineOperator");
  12817. if (this.state.inFSharpPipelineDirectBody) {
  12818. return left;
  12819. }
  12820. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  12821. }
  12822. const node = this.startNodeAt(leftStartLoc);
  12823. node.left = left;
  12824. node.operator = this.state.value;
  12825. const logical = op === 41 || op === 42;
  12826. const coalesce = op === 40;
  12827. if (coalesce) {
  12828. prec = tokenOperatorPrecedence(42);
  12829. }
  12830. this.next();
  12831. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  12832. proposal: "minimal"
  12833. }])) {
  12834. if (this.state.type === 96 && this.prodParam.hasAwait) {
  12835. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  12836. }
  12837. }
  12838. node.right = this.parseExprOpRightExpr(op, prec);
  12839. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  12840. const nextOp = this.state.type;
  12841. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  12842. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  12843. }
  12844. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  12845. }
  12846. }
  12847. return left;
  12848. }
  12849. parseExprOpRightExpr(op, prec) {
  12850. const startLoc = this.state.startLoc;
  12851. switch (op) {
  12852. case 39:
  12853. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  12854. case "hack":
  12855. return this.withTopicBindingContext(() => {
  12856. return this.parseHackPipeBody();
  12857. });
  12858. case "smart":
  12859. return this.withTopicBindingContext(() => {
  12860. if (this.prodParam.hasYield && this.isContextual(108)) {
  12861. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  12862. }
  12863. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  12864. });
  12865. case "fsharp":
  12866. return this.withSoloAwaitPermittingContext(() => {
  12867. return this.parseFSharpPipelineBody(prec);
  12868. });
  12869. }
  12870. default:
  12871. return this.parseExprOpBaseRightExpr(op, prec);
  12872. }
  12873. }
  12874. parseExprOpBaseRightExpr(op, prec) {
  12875. const startLoc = this.state.startLoc;
  12876. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  12877. }
  12878. parseHackPipeBody() {
  12879. var _body$extra;
  12880. const {
  12881. startLoc
  12882. } = this.state;
  12883. const body = this.parseMaybeAssign();
  12884. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  12885. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  12886. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  12887. type: body.type
  12888. });
  12889. }
  12890. if (!this.topicReferenceWasUsedInCurrentContext()) {
  12891. this.raise(Errors.PipeTopicUnused, startLoc);
  12892. }
  12893. return body;
  12894. }
  12895. checkExponentialAfterUnary(node) {
  12896. if (this.match(57)) {
  12897. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  12898. }
  12899. }
  12900. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12901. const startLoc = this.state.startLoc;
  12902. const isAwait = this.isContextual(96);
  12903. if (isAwait && this.recordAwaitIfAllowed()) {
  12904. this.next();
  12905. const expr = this.parseAwait(startLoc);
  12906. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  12907. return expr;
  12908. }
  12909. const update = this.match(34);
  12910. const node = this.startNode();
  12911. if (tokenIsPrefix(this.state.type)) {
  12912. node.operator = this.state.value;
  12913. node.prefix = true;
  12914. if (this.match(72)) {
  12915. this.expectPlugin("throwExpressions");
  12916. }
  12917. const isDelete = this.match(89);
  12918. this.next();
  12919. node.argument = this.parseMaybeUnary(null, true);
  12920. this.checkExpressionErrors(refExpressionErrors, true);
  12921. if (this.state.strict && isDelete) {
  12922. const arg = node.argument;
  12923. if (arg.type === "Identifier") {
  12924. this.raise(Errors.StrictDelete, node);
  12925. } else if (this.hasPropertyAsPrivateName(arg)) {
  12926. this.raise(Errors.DeletePrivateField, node);
  12927. }
  12928. }
  12929. if (!update) {
  12930. if (!sawUnary) {
  12931. this.checkExponentialAfterUnary(node);
  12932. }
  12933. return this.finishNode(node, "UnaryExpression");
  12934. }
  12935. }
  12936. const expr = this.parseUpdate(node, update, refExpressionErrors);
  12937. if (isAwait) {
  12938. const {
  12939. type
  12940. } = this.state;
  12941. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  12942. if (startsExpr && !this.isAmbiguousAwait()) {
  12943. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  12944. return this.parseAwait(startLoc);
  12945. }
  12946. }
  12947. return expr;
  12948. }
  12949. parseUpdate(node, update, refExpressionErrors) {
  12950. if (update) {
  12951. const updateExpressionNode = node;
  12952. this.checkLVal(updateExpressionNode.argument, this.finishNode(updateExpressionNode, "UpdateExpression"));
  12953. return node;
  12954. }
  12955. const startLoc = this.state.startLoc;
  12956. let expr = this.parseExprSubscripts(refExpressionErrors);
  12957. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  12958. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  12959. const node = this.startNodeAt(startLoc);
  12960. node.operator = this.state.value;
  12961. node.prefix = false;
  12962. node.argument = expr;
  12963. this.next();
  12964. this.checkLVal(expr, expr = this.finishNode(node, "UpdateExpression"));
  12965. }
  12966. return expr;
  12967. }
  12968. parseExprSubscripts(refExpressionErrors) {
  12969. const startLoc = this.state.startLoc;
  12970. const potentialArrowAt = this.state.potentialArrowAt;
  12971. const expr = this.parseExprAtom(refExpressionErrors);
  12972. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12973. return expr;
  12974. }
  12975. return this.parseSubscripts(expr, startLoc);
  12976. }
  12977. parseSubscripts(base, startLoc, noCalls) {
  12978. const state = {
  12979. optionalChainMember: false,
  12980. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  12981. stop: false
  12982. };
  12983. do {
  12984. base = this.parseSubscript(base, startLoc, noCalls, state);
  12985. state.maybeAsyncArrow = false;
  12986. } while (!state.stop);
  12987. return base;
  12988. }
  12989. parseSubscript(base, startLoc, noCalls, state) {
  12990. const {
  12991. type
  12992. } = this.state;
  12993. if (!noCalls && type === 15) {
  12994. return this.parseBind(base, startLoc, noCalls, state);
  12995. } else if (tokenIsTemplate(type)) {
  12996. return this.parseTaggedTemplateExpression(base, startLoc, state);
  12997. }
  12998. let optional = false;
  12999. if (type === 18) {
  13000. if (noCalls) {
  13001. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  13002. if (this.lookaheadCharCode() === 40) {
  13003. state.stop = true;
  13004. return base;
  13005. }
  13006. }
  13007. state.optionalChainMember = optional = true;
  13008. this.next();
  13009. }
  13010. if (!noCalls && this.match(10)) {
  13011. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  13012. } else {
  13013. const computed = this.eat(0);
  13014. if (computed || optional || this.eat(16)) {
  13015. return this.parseMember(base, startLoc, state, computed, optional);
  13016. } else {
  13017. state.stop = true;
  13018. return base;
  13019. }
  13020. }
  13021. }
  13022. parseMember(base, startLoc, state, computed, optional) {
  13023. const node = this.startNodeAt(startLoc);
  13024. node.object = base;
  13025. node.computed = computed;
  13026. if (computed) {
  13027. node.property = this.parseExpression();
  13028. this.expect(3);
  13029. } else if (this.match(138)) {
  13030. if (base.type === "Super") {
  13031. this.raise(Errors.SuperPrivateField, startLoc);
  13032. }
  13033. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  13034. node.property = this.parsePrivateName();
  13035. } else {
  13036. node.property = this.parseIdentifier(true);
  13037. }
  13038. if (state.optionalChainMember) {
  13039. node.optional = optional;
  13040. return this.finishNode(node, "OptionalMemberExpression");
  13041. } else {
  13042. return this.finishNode(node, "MemberExpression");
  13043. }
  13044. }
  13045. parseBind(base, startLoc, noCalls, state) {
  13046. const node = this.startNodeAt(startLoc);
  13047. node.object = base;
  13048. this.next();
  13049. node.callee = this.parseNoCallExpr();
  13050. state.stop = true;
  13051. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  13052. }
  13053. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13054. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13055. let refExpressionErrors = null;
  13056. this.state.maybeInArrowParameters = true;
  13057. this.next();
  13058. const node = this.startNodeAt(startLoc);
  13059. node.callee = base;
  13060. const {
  13061. maybeAsyncArrow,
  13062. optionalChainMember
  13063. } = state;
  13064. if (maybeAsyncArrow) {
  13065. this.expressionScope.enter(newAsyncArrowScope());
  13066. refExpressionErrors = new ExpressionErrors();
  13067. }
  13068. if (optionalChainMember) {
  13069. node.optional = optional;
  13070. }
  13071. if (optional) {
  13072. node.arguments = this.parseCallExpressionArguments(11);
  13073. } else {
  13074. node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  13075. }
  13076. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13077. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13078. state.stop = true;
  13079. this.checkDestructuringPrivate(refExpressionErrors);
  13080. this.expressionScope.validateAsPattern();
  13081. this.expressionScope.exit();
  13082. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13083. } else {
  13084. if (maybeAsyncArrow) {
  13085. this.checkExpressionErrors(refExpressionErrors, true);
  13086. this.expressionScope.exit();
  13087. }
  13088. this.toReferencedArguments(finishedNode);
  13089. }
  13090. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13091. return finishedNode;
  13092. }
  13093. toReferencedArguments(node, isParenthesizedExpr) {
  13094. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13095. }
  13096. parseTaggedTemplateExpression(base, startLoc, state) {
  13097. const node = this.startNodeAt(startLoc);
  13098. node.tag = base;
  13099. node.quasi = this.parseTemplate(true);
  13100. if (state.optionalChainMember) {
  13101. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13102. }
  13103. return this.finishNode(node, "TaggedTemplateExpression");
  13104. }
  13105. atPossibleAsyncArrow(base) {
  13106. 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;
  13107. }
  13108. expectImportAttributesPlugin() {
  13109. if (!this.hasPlugin("importAssertions")) {
  13110. this.expectPlugin("importAttributes");
  13111. }
  13112. }
  13113. finishCallExpression(node, optional) {
  13114. if (node.callee.type === "Import") {
  13115. if (node.arguments.length === 2) {
  13116. {
  13117. if (!this.hasPlugin("moduleAttributes")) {
  13118. this.expectImportAttributesPlugin();
  13119. }
  13120. }
  13121. }
  13122. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13123. this.raise(Errors.ImportCallArity, node, {
  13124. maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1
  13125. });
  13126. } else {
  13127. for (const arg of node.arguments) {
  13128. if (arg.type === "SpreadElement") {
  13129. this.raise(Errors.ImportCallSpreadArgument, arg);
  13130. }
  13131. }
  13132. }
  13133. }
  13134. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13135. }
  13136. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13137. const elts = [];
  13138. let first = true;
  13139. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13140. this.state.inFSharpPipelineDirectBody = false;
  13141. while (!this.eat(close)) {
  13142. if (first) {
  13143. first = false;
  13144. } else {
  13145. this.expect(12);
  13146. if (this.match(close)) {
  13147. if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  13148. this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc);
  13149. }
  13150. if (nodeForExtra) {
  13151. this.addTrailingCommaExtraToNode(nodeForExtra);
  13152. }
  13153. this.next();
  13154. break;
  13155. }
  13156. }
  13157. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  13158. }
  13159. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13160. return elts;
  13161. }
  13162. shouldParseAsyncArrow() {
  13163. return this.match(19) && !this.canInsertSemicolon();
  13164. }
  13165. parseAsyncArrowFromCallExpression(node, call) {
  13166. var _call$extra;
  13167. this.resetPreviousNodeTrailingComments(call);
  13168. this.expect(19);
  13169. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13170. if (call.innerComments) {
  13171. setInnerComments(node, call.innerComments);
  13172. }
  13173. if (call.callee.trailingComments) {
  13174. setInnerComments(node, call.callee.trailingComments);
  13175. }
  13176. return node;
  13177. }
  13178. parseNoCallExpr() {
  13179. const startLoc = this.state.startLoc;
  13180. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13181. }
  13182. parseExprAtom(refExpressionErrors) {
  13183. let node;
  13184. let decorators = null;
  13185. const {
  13186. type
  13187. } = this.state;
  13188. switch (type) {
  13189. case 79:
  13190. return this.parseSuper();
  13191. case 83:
  13192. node = this.startNode();
  13193. this.next();
  13194. if (this.match(16)) {
  13195. return this.parseImportMetaProperty(node);
  13196. }
  13197. if (this.match(10)) {
  13198. if (this.options.createImportExpressions) {
  13199. return this.parseImportCall(node);
  13200. } else {
  13201. return this.finishNode(node, "Import");
  13202. }
  13203. } else {
  13204. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13205. return this.finishNode(node, "Import");
  13206. }
  13207. case 78:
  13208. node = this.startNode();
  13209. this.next();
  13210. return this.finishNode(node, "ThisExpression");
  13211. case 90:
  13212. {
  13213. return this.parseDo(this.startNode(), false);
  13214. }
  13215. case 56:
  13216. case 31:
  13217. {
  13218. this.readRegexp();
  13219. return this.parseRegExpLiteral(this.state.value);
  13220. }
  13221. case 134:
  13222. return this.parseNumericLiteral(this.state.value);
  13223. case 135:
  13224. return this.parseBigIntLiteral(this.state.value);
  13225. case 136:
  13226. return this.parseDecimalLiteral(this.state.value);
  13227. case 133:
  13228. return this.parseStringLiteral(this.state.value);
  13229. case 84:
  13230. return this.parseNullLiteral();
  13231. case 85:
  13232. return this.parseBooleanLiteral(true);
  13233. case 86:
  13234. return this.parseBooleanLiteral(false);
  13235. case 10:
  13236. {
  13237. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13238. return this.parseParenAndDistinguishExpression(canBeArrow);
  13239. }
  13240. case 2:
  13241. case 1:
  13242. {
  13243. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13244. }
  13245. case 0:
  13246. {
  13247. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13248. }
  13249. case 6:
  13250. case 7:
  13251. {
  13252. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13253. }
  13254. case 5:
  13255. {
  13256. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13257. }
  13258. case 68:
  13259. return this.parseFunctionOrFunctionSent();
  13260. case 26:
  13261. decorators = this.parseDecorators();
  13262. case 80:
  13263. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13264. case 77:
  13265. return this.parseNewOrNewTarget();
  13266. case 25:
  13267. case 24:
  13268. return this.parseTemplate(false);
  13269. case 15:
  13270. {
  13271. node = this.startNode();
  13272. this.next();
  13273. node.object = null;
  13274. const callee = node.callee = this.parseNoCallExpr();
  13275. if (callee.type === "MemberExpression") {
  13276. return this.finishNode(node, "BindExpression");
  13277. } else {
  13278. throw this.raise(Errors.UnsupportedBind, callee);
  13279. }
  13280. }
  13281. case 138:
  13282. {
  13283. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13284. identifierName: this.state.value
  13285. });
  13286. return this.parsePrivateName();
  13287. }
  13288. case 33:
  13289. {
  13290. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13291. }
  13292. case 32:
  13293. {
  13294. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13295. }
  13296. case 37:
  13297. case 38:
  13298. {
  13299. return this.parseTopicReference("hack");
  13300. }
  13301. case 44:
  13302. case 54:
  13303. case 27:
  13304. {
  13305. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13306. if (pipeProposal) {
  13307. return this.parseTopicReference(pipeProposal);
  13308. }
  13309. this.unexpected();
  13310. break;
  13311. }
  13312. case 47:
  13313. {
  13314. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13315. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13316. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13317. } else {
  13318. this.unexpected();
  13319. }
  13320. break;
  13321. }
  13322. default:
  13323. if (tokenIsIdentifier(type)) {
  13324. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13325. return this.parseModuleExpression();
  13326. }
  13327. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13328. const containsEsc = this.state.containsEsc;
  13329. const id = this.parseIdentifier();
  13330. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13331. const {
  13332. type
  13333. } = this.state;
  13334. if (type === 68) {
  13335. this.resetPreviousNodeTrailingComments(id);
  13336. this.next();
  13337. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13338. } else if (tokenIsIdentifier(type)) {
  13339. if (this.lookaheadCharCode() === 61) {
  13340. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13341. } else {
  13342. return id;
  13343. }
  13344. } else if (type === 90) {
  13345. this.resetPreviousNodeTrailingComments(id);
  13346. return this.parseDo(this.startNodeAtNode(id), true);
  13347. }
  13348. }
  13349. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13350. this.next();
  13351. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13352. }
  13353. return id;
  13354. } else {
  13355. this.unexpected();
  13356. }
  13357. }
  13358. }
  13359. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13360. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13361. if (pipeProposal) {
  13362. this.state.type = topicTokenType;
  13363. this.state.value = topicTokenValue;
  13364. this.state.pos--;
  13365. this.state.end--;
  13366. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13367. return this.parseTopicReference(pipeProposal);
  13368. } else {
  13369. this.unexpected();
  13370. }
  13371. }
  13372. parseTopicReference(pipeProposal) {
  13373. const node = this.startNode();
  13374. const startLoc = this.state.startLoc;
  13375. const tokenType = this.state.type;
  13376. this.next();
  13377. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13378. }
  13379. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13380. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13381. const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
  13382. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13383. this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc);
  13384. }
  13385. this.registerTopicReference();
  13386. return this.finishNode(node, nodeType);
  13387. } else {
  13388. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13389. token: tokenLabelName(tokenType)
  13390. });
  13391. }
  13392. }
  13393. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13394. switch (pipeProposal) {
  13395. case "hack":
  13396. {
  13397. return this.hasPlugin(["pipelineOperator", {
  13398. topicToken: tokenLabelName(tokenType)
  13399. }]);
  13400. }
  13401. case "smart":
  13402. return tokenType === 27;
  13403. default:
  13404. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13405. }
  13406. }
  13407. parseAsyncArrowUnaryFunction(node) {
  13408. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13409. const params = [this.parseIdentifier()];
  13410. this.prodParam.exit();
  13411. if (this.hasPrecedingLineBreak()) {
  13412. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13413. }
  13414. this.expect(19);
  13415. return this.parseArrowExpression(node, params, true);
  13416. }
  13417. parseDo(node, isAsync) {
  13418. this.expectPlugin("doExpressions");
  13419. if (isAsync) {
  13420. this.expectPlugin("asyncDoExpressions");
  13421. }
  13422. node.async = isAsync;
  13423. this.next();
  13424. const oldLabels = this.state.labels;
  13425. this.state.labels = [];
  13426. if (isAsync) {
  13427. this.prodParam.enter(2);
  13428. node.body = this.parseBlock();
  13429. this.prodParam.exit();
  13430. } else {
  13431. node.body = this.parseBlock();
  13432. }
  13433. this.state.labels = oldLabels;
  13434. return this.finishNode(node, "DoExpression");
  13435. }
  13436. parseSuper() {
  13437. const node = this.startNode();
  13438. this.next();
  13439. if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  13440. this.raise(Errors.SuperNotAllowed, node);
  13441. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  13442. this.raise(Errors.UnexpectedSuper, node);
  13443. }
  13444. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13445. this.raise(Errors.UnsupportedSuper, node);
  13446. }
  13447. return this.finishNode(node, "Super");
  13448. }
  13449. parsePrivateName() {
  13450. const node = this.startNode();
  13451. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13452. const name = this.state.value;
  13453. this.next();
  13454. node.id = this.createIdentifier(id, name);
  13455. return this.finishNode(node, "PrivateName");
  13456. }
  13457. parseFunctionOrFunctionSent() {
  13458. const node = this.startNode();
  13459. this.next();
  13460. if (this.prodParam.hasYield && this.match(16)) {
  13461. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13462. this.next();
  13463. if (this.match(103)) {
  13464. this.expectPlugin("functionSent");
  13465. } else if (!this.hasPlugin("functionSent")) {
  13466. this.unexpected();
  13467. }
  13468. return this.parseMetaProperty(node, meta, "sent");
  13469. }
  13470. return this.parseFunction(node);
  13471. }
  13472. parseMetaProperty(node, meta, propertyName) {
  13473. node.meta = meta;
  13474. const containsEsc = this.state.containsEsc;
  13475. node.property = this.parseIdentifier(true);
  13476. if (node.property.name !== propertyName || containsEsc) {
  13477. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13478. target: meta.name,
  13479. onlyValidPropertyName: propertyName
  13480. });
  13481. }
  13482. return this.finishNode(node, "MetaProperty");
  13483. }
  13484. parseImportMetaProperty(node) {
  13485. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  13486. this.next();
  13487. if (this.isContextual(101)) {
  13488. if (!this.inModule) {
  13489. this.raise(Errors.ImportMetaOutsideModule, id);
  13490. }
  13491. this.sawUnambiguousESM = true;
  13492. } else if (this.isContextual(105) || this.isContextual(97)) {
  13493. const isSource = this.isContextual(105);
  13494. if (!isSource) this.unexpected();
  13495. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  13496. if (!this.options.createImportExpressions) {
  13497. throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, {
  13498. phase: this.state.value
  13499. });
  13500. }
  13501. this.next();
  13502. node.phase = isSource ? "source" : "defer";
  13503. return this.parseImportCall(node);
  13504. }
  13505. return this.parseMetaProperty(node, id, "meta");
  13506. }
  13507. parseLiteralAtNode(value, type, node) {
  13508. this.addExtra(node, "rawValue", value);
  13509. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13510. node.value = value;
  13511. this.next();
  13512. return this.finishNode(node, type);
  13513. }
  13514. parseLiteral(value, type) {
  13515. const node = this.startNode();
  13516. return this.parseLiteralAtNode(value, type, node);
  13517. }
  13518. parseStringLiteral(value) {
  13519. return this.parseLiteral(value, "StringLiteral");
  13520. }
  13521. parseNumericLiteral(value) {
  13522. return this.parseLiteral(value, "NumericLiteral");
  13523. }
  13524. parseBigIntLiteral(value) {
  13525. return this.parseLiteral(value, "BigIntLiteral");
  13526. }
  13527. parseDecimalLiteral(value) {
  13528. return this.parseLiteral(value, "DecimalLiteral");
  13529. }
  13530. parseRegExpLiteral(value) {
  13531. const node = this.startNode();
  13532. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13533. node.pattern = value.pattern;
  13534. node.flags = value.flags;
  13535. this.next();
  13536. return this.finishNode(node, "RegExpLiteral");
  13537. }
  13538. parseBooleanLiteral(value) {
  13539. const node = this.startNode();
  13540. node.value = value;
  13541. this.next();
  13542. return this.finishNode(node, "BooleanLiteral");
  13543. }
  13544. parseNullLiteral() {
  13545. const node = this.startNode();
  13546. this.next();
  13547. return this.finishNode(node, "NullLiteral");
  13548. }
  13549. parseParenAndDistinguishExpression(canBeArrow) {
  13550. const startLoc = this.state.startLoc;
  13551. let val;
  13552. this.next();
  13553. this.expressionScope.enter(newArrowHeadScope());
  13554. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13555. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13556. this.state.maybeInArrowParameters = true;
  13557. this.state.inFSharpPipelineDirectBody = false;
  13558. const innerStartLoc = this.state.startLoc;
  13559. const exprList = [];
  13560. const refExpressionErrors = new ExpressionErrors();
  13561. let first = true;
  13562. let spreadStartLoc;
  13563. let optionalCommaStartLoc;
  13564. while (!this.match(11)) {
  13565. if (first) {
  13566. first = false;
  13567. } else {
  13568. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  13569. if (this.match(11)) {
  13570. optionalCommaStartLoc = this.state.startLoc;
  13571. break;
  13572. }
  13573. }
  13574. if (this.match(21)) {
  13575. const spreadNodeStartLoc = this.state.startLoc;
  13576. spreadStartLoc = this.state.startLoc;
  13577. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  13578. if (!this.checkCommaAfterRest(41)) {
  13579. break;
  13580. }
  13581. } else {
  13582. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  13583. }
  13584. }
  13585. const innerEndLoc = this.state.lastTokEndLoc;
  13586. this.expect(11);
  13587. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13588. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13589. let arrowNode = this.startNodeAt(startLoc);
  13590. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  13591. this.checkDestructuringPrivate(refExpressionErrors);
  13592. this.expressionScope.validateAsPattern();
  13593. this.expressionScope.exit();
  13594. this.parseArrowExpression(arrowNode, exprList, false);
  13595. return arrowNode;
  13596. }
  13597. this.expressionScope.exit();
  13598. if (!exprList.length) {
  13599. this.unexpected(this.state.lastTokStartLoc);
  13600. }
  13601. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  13602. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  13603. this.checkExpressionErrors(refExpressionErrors, true);
  13604. this.toReferencedListDeep(exprList, true);
  13605. if (exprList.length > 1) {
  13606. val = this.startNodeAt(innerStartLoc);
  13607. val.expressions = exprList;
  13608. this.finishNode(val, "SequenceExpression");
  13609. this.resetEndLocation(val, innerEndLoc);
  13610. } else {
  13611. val = exprList[0];
  13612. }
  13613. return this.wrapParenthesis(startLoc, val);
  13614. }
  13615. wrapParenthesis(startLoc, expression) {
  13616. if (!this.options.createParenthesizedExpressions) {
  13617. this.addExtra(expression, "parenthesized", true);
  13618. this.addExtra(expression, "parenStart", startLoc.index);
  13619. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  13620. return expression;
  13621. }
  13622. const parenExpression = this.startNodeAt(startLoc);
  13623. parenExpression.expression = expression;
  13624. return this.finishNode(parenExpression, "ParenthesizedExpression");
  13625. }
  13626. shouldParseArrow(params) {
  13627. return !this.canInsertSemicolon();
  13628. }
  13629. parseArrow(node) {
  13630. if (this.eat(19)) {
  13631. return node;
  13632. }
  13633. }
  13634. parseParenItem(node, startLoc) {
  13635. return node;
  13636. }
  13637. parseNewOrNewTarget() {
  13638. const node = this.startNode();
  13639. this.next();
  13640. if (this.match(16)) {
  13641. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  13642. this.next();
  13643. const metaProp = this.parseMetaProperty(node, meta, "target");
  13644. if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) {
  13645. this.raise(Errors.UnexpectedNewTarget, metaProp);
  13646. }
  13647. return metaProp;
  13648. }
  13649. return this.parseNew(node);
  13650. }
  13651. parseNew(node) {
  13652. this.parseNewCallee(node);
  13653. if (this.eat(10)) {
  13654. const args = this.parseExprList(11);
  13655. this.toReferencedList(args);
  13656. node.arguments = args;
  13657. } else {
  13658. node.arguments = [];
  13659. }
  13660. return this.finishNode(node, "NewExpression");
  13661. }
  13662. parseNewCallee(node) {
  13663. const isImport = this.match(83);
  13664. const callee = this.parseNoCallExpr();
  13665. node.callee = callee;
  13666. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  13667. this.raise(Errors.ImportCallNotNewExpression, callee);
  13668. }
  13669. }
  13670. parseTemplateElement(isTagged) {
  13671. const {
  13672. start,
  13673. startLoc,
  13674. end,
  13675. value
  13676. } = this.state;
  13677. const elemStart = start + 1;
  13678. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  13679. if (value === null) {
  13680. if (!isTagged) {
  13681. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  13682. }
  13683. }
  13684. const isTail = this.match(24);
  13685. const endOffset = isTail ? -1 : -2;
  13686. const elemEnd = end + endOffset;
  13687. elem.value = {
  13688. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  13689. cooked: value === null ? null : value.slice(1, endOffset)
  13690. };
  13691. elem.tail = isTail;
  13692. this.next();
  13693. const finishedNode = this.finishNode(elem, "TemplateElement");
  13694. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  13695. return finishedNode;
  13696. }
  13697. parseTemplate(isTagged) {
  13698. const node = this.startNode();
  13699. let curElt = this.parseTemplateElement(isTagged);
  13700. const quasis = [curElt];
  13701. const substitutions = [];
  13702. while (!curElt.tail) {
  13703. substitutions.push(this.parseTemplateSubstitution());
  13704. this.readTemplateContinuation();
  13705. quasis.push(curElt = this.parseTemplateElement(isTagged));
  13706. }
  13707. node.expressions = substitutions;
  13708. node.quasis = quasis;
  13709. return this.finishNode(node, "TemplateLiteral");
  13710. }
  13711. parseTemplateSubstitution() {
  13712. return this.parseExpression();
  13713. }
  13714. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  13715. if (isRecord) {
  13716. this.expectPlugin("recordAndTuple");
  13717. }
  13718. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13719. this.state.inFSharpPipelineDirectBody = false;
  13720. const propHash = Object.create(null);
  13721. let first = true;
  13722. const node = this.startNode();
  13723. node.properties = [];
  13724. this.next();
  13725. while (!this.match(close)) {
  13726. if (first) {
  13727. first = false;
  13728. } else {
  13729. this.expect(12);
  13730. if (this.match(close)) {
  13731. this.addTrailingCommaExtraToNode(node);
  13732. break;
  13733. }
  13734. }
  13735. let prop;
  13736. if (isPattern) {
  13737. prop = this.parseBindingProperty();
  13738. } else {
  13739. prop = this.parsePropertyDefinition(refExpressionErrors);
  13740. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  13741. }
  13742. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  13743. this.raise(Errors.InvalidRecordProperty, prop);
  13744. }
  13745. {
  13746. if (prop.shorthand) {
  13747. this.addExtra(prop, "shorthand", true);
  13748. }
  13749. }
  13750. node.properties.push(prop);
  13751. }
  13752. this.next();
  13753. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13754. let type = "ObjectExpression";
  13755. if (isPattern) {
  13756. type = "ObjectPattern";
  13757. } else if (isRecord) {
  13758. type = "RecordExpression";
  13759. }
  13760. return this.finishNode(node, type);
  13761. }
  13762. addTrailingCommaExtraToNode(node) {
  13763. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  13764. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  13765. }
  13766. maybeAsyncOrAccessorProp(prop) {
  13767. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  13768. }
  13769. parsePropertyDefinition(refExpressionErrors) {
  13770. let decorators = [];
  13771. if (this.match(26)) {
  13772. if (this.hasPlugin("decorators")) {
  13773. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  13774. }
  13775. while (this.match(26)) {
  13776. decorators.push(this.parseDecorator());
  13777. }
  13778. }
  13779. const prop = this.startNode();
  13780. let isAsync = false;
  13781. let isAccessor = false;
  13782. let startLoc;
  13783. if (this.match(21)) {
  13784. if (decorators.length) this.unexpected();
  13785. return this.parseSpread();
  13786. }
  13787. if (decorators.length) {
  13788. prop.decorators = decorators;
  13789. decorators = [];
  13790. }
  13791. prop.method = false;
  13792. if (refExpressionErrors) {
  13793. startLoc = this.state.startLoc;
  13794. }
  13795. let isGenerator = this.eat(55);
  13796. this.parsePropertyNamePrefixOperator(prop);
  13797. const containsEsc = this.state.containsEsc;
  13798. this.parsePropertyName(prop, refExpressionErrors);
  13799. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  13800. const {
  13801. key
  13802. } = prop;
  13803. const keyName = key.name;
  13804. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  13805. isAsync = true;
  13806. this.resetPreviousNodeTrailingComments(key);
  13807. isGenerator = this.eat(55);
  13808. this.parsePropertyName(prop);
  13809. }
  13810. if (keyName === "get" || keyName === "set") {
  13811. isAccessor = true;
  13812. this.resetPreviousNodeTrailingComments(key);
  13813. prop.kind = keyName;
  13814. if (this.match(55)) {
  13815. isGenerator = true;
  13816. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  13817. kind: keyName
  13818. });
  13819. this.next();
  13820. }
  13821. this.parsePropertyName(prop);
  13822. }
  13823. }
  13824. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  13825. }
  13826. getGetterSetterExpectedParamCount(method) {
  13827. return method.kind === "get" ? 0 : 1;
  13828. }
  13829. getObjectOrClassMethodParams(method) {
  13830. return method.params;
  13831. }
  13832. checkGetterSetterParams(method) {
  13833. var _params;
  13834. const paramCount = this.getGetterSetterExpectedParamCount(method);
  13835. const params = this.getObjectOrClassMethodParams(method);
  13836. if (params.length !== paramCount) {
  13837. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  13838. }
  13839. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  13840. this.raise(Errors.BadSetterRestParameter, method);
  13841. }
  13842. }
  13843. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  13844. if (isAccessor) {
  13845. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  13846. this.checkGetterSetterParams(finishedProp);
  13847. return finishedProp;
  13848. }
  13849. if (isAsync || isGenerator || this.match(10)) {
  13850. if (isPattern) this.unexpected();
  13851. prop.kind = "method";
  13852. prop.method = true;
  13853. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  13854. }
  13855. }
  13856. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  13857. prop.shorthand = false;
  13858. if (this.eat(14)) {
  13859. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  13860. return this.finishNode(prop, "ObjectProperty");
  13861. }
  13862. if (!prop.computed && prop.key.type === "Identifier") {
  13863. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  13864. if (isPattern) {
  13865. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13866. } else if (this.match(29)) {
  13867. const shorthandAssignLoc = this.state.startLoc;
  13868. if (refExpressionErrors != null) {
  13869. if (refExpressionErrors.shorthandAssignLoc === null) {
  13870. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  13871. }
  13872. } else {
  13873. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  13874. }
  13875. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13876. } else {
  13877. prop.value = cloneIdentifier(prop.key);
  13878. }
  13879. prop.shorthand = true;
  13880. return this.finishNode(prop, "ObjectProperty");
  13881. }
  13882. }
  13883. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  13884. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  13885. if (!node) this.unexpected();
  13886. return node;
  13887. }
  13888. parsePropertyName(prop, refExpressionErrors) {
  13889. if (this.eat(0)) {
  13890. prop.computed = true;
  13891. prop.key = this.parseMaybeAssignAllowIn();
  13892. this.expect(3);
  13893. } else {
  13894. const {
  13895. type,
  13896. value
  13897. } = this.state;
  13898. let key;
  13899. if (tokenIsKeywordOrIdentifier(type)) {
  13900. key = this.parseIdentifier(true);
  13901. } else {
  13902. switch (type) {
  13903. case 134:
  13904. key = this.parseNumericLiteral(value);
  13905. break;
  13906. case 133:
  13907. key = this.parseStringLiteral(value);
  13908. break;
  13909. case 135:
  13910. key = this.parseBigIntLiteral(value);
  13911. break;
  13912. case 136:
  13913. key = this.parseDecimalLiteral(value);
  13914. break;
  13915. case 138:
  13916. {
  13917. const privateKeyLoc = this.state.startLoc;
  13918. if (refExpressionErrors != null) {
  13919. if (refExpressionErrors.privateKeyLoc === null) {
  13920. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  13921. }
  13922. } else {
  13923. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  13924. }
  13925. key = this.parsePrivateName();
  13926. break;
  13927. }
  13928. default:
  13929. this.unexpected();
  13930. }
  13931. }
  13932. prop.key = key;
  13933. if (type !== 138) {
  13934. prop.computed = false;
  13935. }
  13936. }
  13937. }
  13938. initFunction(node, isAsync) {
  13939. node.id = null;
  13940. node.generator = false;
  13941. node.async = isAsync;
  13942. }
  13943. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  13944. this.initFunction(node, isAsync);
  13945. node.generator = isGenerator;
  13946. this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
  13947. this.prodParam.enter(functionFlags(isAsync, node.generator));
  13948. this.parseFunctionParams(node, isConstructor);
  13949. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  13950. this.prodParam.exit();
  13951. this.scope.exit();
  13952. return finishedNode;
  13953. }
  13954. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  13955. if (isTuple) {
  13956. this.expectPlugin("recordAndTuple");
  13957. }
  13958. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13959. this.state.inFSharpPipelineDirectBody = false;
  13960. const node = this.startNode();
  13961. this.next();
  13962. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  13963. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13964. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  13965. }
  13966. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  13967. this.scope.enter(2 | 4);
  13968. let flags = functionFlags(isAsync, false);
  13969. if (!this.match(5) && this.prodParam.hasIn) {
  13970. flags |= 8;
  13971. }
  13972. this.prodParam.enter(flags);
  13973. this.initFunction(node, isAsync);
  13974. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13975. if (params) {
  13976. this.state.maybeInArrowParameters = true;
  13977. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  13978. }
  13979. this.state.maybeInArrowParameters = false;
  13980. this.parseFunctionBody(node, true);
  13981. this.prodParam.exit();
  13982. this.scope.exit();
  13983. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13984. return this.finishNode(node, "ArrowFunctionExpression");
  13985. }
  13986. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  13987. this.toAssignableList(params, trailingCommaLoc, false);
  13988. node.params = params;
  13989. }
  13990. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  13991. this.parseFunctionBody(node, false, isMethod);
  13992. return this.finishNode(node, type);
  13993. }
  13994. parseFunctionBody(node, allowExpression, isMethod = false) {
  13995. const isExpression = allowExpression && !this.match(5);
  13996. this.expressionScope.enter(newExpressionScope());
  13997. if (isExpression) {
  13998. node.body = this.parseMaybeAssign();
  13999. this.checkParams(node, false, allowExpression, false);
  14000. } else {
  14001. const oldStrict = this.state.strict;
  14002. const oldLabels = this.state.labels;
  14003. this.state.labels = [];
  14004. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  14005. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  14006. const nonSimple = !this.isSimpleParamList(node.params);
  14007. if (hasStrictModeDirective && nonSimple) {
  14008. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  14009. }
  14010. const strictModeChanged = !oldStrict && this.state.strict;
  14011. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  14012. if (this.state.strict && node.id) {
  14013. this.checkIdentifier(node.id, 65, strictModeChanged);
  14014. }
  14015. });
  14016. this.prodParam.exit();
  14017. this.state.labels = oldLabels;
  14018. }
  14019. this.expressionScope.exit();
  14020. }
  14021. isSimpleParameter(node) {
  14022. return node.type === "Identifier";
  14023. }
  14024. isSimpleParamList(params) {
  14025. for (let i = 0, len = params.length; i < len; i++) {
  14026. if (!this.isSimpleParameter(params[i])) return false;
  14027. }
  14028. return true;
  14029. }
  14030. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  14031. const checkClashes = !allowDuplicates && new Set();
  14032. const formalParameters = {
  14033. type: "FormalParameters"
  14034. };
  14035. for (const param of node.params) {
  14036. this.checkLVal(param, formalParameters, 5, checkClashes, strictModeChanged);
  14037. }
  14038. }
  14039. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  14040. const elts = [];
  14041. let first = true;
  14042. while (!this.eat(close)) {
  14043. if (first) {
  14044. first = false;
  14045. } else {
  14046. this.expect(12);
  14047. if (this.match(close)) {
  14048. if (nodeForExtra) {
  14049. this.addTrailingCommaExtraToNode(nodeForExtra);
  14050. }
  14051. this.next();
  14052. break;
  14053. }
  14054. }
  14055. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  14056. }
  14057. return elts;
  14058. }
  14059. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  14060. let elt;
  14061. if (this.match(12)) {
  14062. if (!allowEmpty) {
  14063. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14064. unexpected: ","
  14065. });
  14066. }
  14067. elt = null;
  14068. } else if (this.match(21)) {
  14069. const spreadNodeStartLoc = this.state.startLoc;
  14070. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14071. } else if (this.match(17)) {
  14072. this.expectPlugin("partialApplication");
  14073. if (!allowPlaceholder) {
  14074. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14075. }
  14076. const node = this.startNode();
  14077. this.next();
  14078. elt = this.finishNode(node, "ArgumentPlaceholder");
  14079. } else {
  14080. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  14081. }
  14082. return elt;
  14083. }
  14084. parseIdentifier(liberal) {
  14085. const node = this.startNode();
  14086. const name = this.parseIdentifierName(liberal);
  14087. return this.createIdentifier(node, name);
  14088. }
  14089. createIdentifier(node, name) {
  14090. node.name = name;
  14091. node.loc.identifierName = name;
  14092. return this.finishNode(node, "Identifier");
  14093. }
  14094. parseIdentifierName(liberal) {
  14095. let name;
  14096. const {
  14097. startLoc,
  14098. type
  14099. } = this.state;
  14100. if (tokenIsKeywordOrIdentifier(type)) {
  14101. name = this.state.value;
  14102. } else {
  14103. this.unexpected();
  14104. }
  14105. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14106. if (liberal) {
  14107. if (tokenIsKeyword) {
  14108. this.replaceToken(132);
  14109. }
  14110. } else {
  14111. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14112. }
  14113. this.next();
  14114. return name;
  14115. }
  14116. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14117. if (word.length > 10) {
  14118. return;
  14119. }
  14120. if (!canBeReservedWord(word)) {
  14121. return;
  14122. }
  14123. if (checkKeywords && isKeyword(word)) {
  14124. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14125. keyword: word
  14126. });
  14127. return;
  14128. }
  14129. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14130. if (reservedTest(word, this.inModule)) {
  14131. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14132. reservedWord: word
  14133. });
  14134. return;
  14135. } else if (word === "yield") {
  14136. if (this.prodParam.hasYield) {
  14137. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14138. return;
  14139. }
  14140. } else if (word === "await") {
  14141. if (this.prodParam.hasAwait) {
  14142. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14143. return;
  14144. }
  14145. if (this.scope.inStaticBlock) {
  14146. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14147. return;
  14148. }
  14149. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14150. } else if (word === "arguments") {
  14151. if (this.scope.inClassAndNotInNonArrowFunction) {
  14152. this.raise(Errors.ArgumentsInClass, startLoc);
  14153. return;
  14154. }
  14155. }
  14156. }
  14157. recordAwaitIfAllowed() {
  14158. const isAwaitAllowed = this.prodParam.hasAwait || this.options.allowAwaitOutsideFunction && !this.scope.inFunction;
  14159. if (isAwaitAllowed && !this.scope.inFunction) {
  14160. this.state.hasTopLevelAwait = true;
  14161. }
  14162. return isAwaitAllowed;
  14163. }
  14164. parseAwait(startLoc) {
  14165. const node = this.startNodeAt(startLoc);
  14166. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14167. if (this.eat(55)) {
  14168. this.raise(Errors.ObsoleteAwaitStar, node);
  14169. }
  14170. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  14171. if (this.isAmbiguousAwait()) {
  14172. this.ambiguousScriptDifferentAst = true;
  14173. } else {
  14174. this.sawUnambiguousESM = true;
  14175. }
  14176. }
  14177. if (!this.state.soloAwait) {
  14178. node.argument = this.parseMaybeUnary(null, true);
  14179. }
  14180. return this.finishNode(node, "AwaitExpression");
  14181. }
  14182. isAmbiguousAwait() {
  14183. if (this.hasPrecedingLineBreak()) return true;
  14184. const {
  14185. type
  14186. } = this.state;
  14187. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14188. }
  14189. parseYield() {
  14190. const node = this.startNode();
  14191. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14192. this.next();
  14193. let delegating = false;
  14194. let argument = null;
  14195. if (!this.hasPrecedingLineBreak()) {
  14196. delegating = this.eat(55);
  14197. switch (this.state.type) {
  14198. case 13:
  14199. case 139:
  14200. case 8:
  14201. case 11:
  14202. case 3:
  14203. case 9:
  14204. case 14:
  14205. case 12:
  14206. if (!delegating) break;
  14207. default:
  14208. argument = this.parseMaybeAssign();
  14209. }
  14210. }
  14211. node.delegate = delegating;
  14212. node.argument = argument;
  14213. return this.finishNode(node, "YieldExpression");
  14214. }
  14215. parseImportCall(node) {
  14216. this.next();
  14217. node.source = this.parseMaybeAssignAllowIn();
  14218. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  14219. node.options = null;
  14220. }
  14221. if (this.eat(12)) {
  14222. this.expectImportAttributesPlugin();
  14223. if (!this.match(11)) {
  14224. node.options = this.parseMaybeAssignAllowIn();
  14225. this.eat(12);
  14226. }
  14227. }
  14228. this.expect(11);
  14229. return this.finishNode(node, "ImportExpression");
  14230. }
  14231. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14232. if (this.hasPlugin(["pipelineOperator", {
  14233. proposal: "smart"
  14234. }])) {
  14235. if (left.type === "SequenceExpression") {
  14236. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14237. }
  14238. }
  14239. }
  14240. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14241. if (this.isSimpleReference(childExpr)) {
  14242. const bodyNode = this.startNodeAt(startLoc);
  14243. bodyNode.callee = childExpr;
  14244. return this.finishNode(bodyNode, "PipelineBareFunction");
  14245. } else {
  14246. const bodyNode = this.startNodeAt(startLoc);
  14247. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14248. bodyNode.expression = childExpr;
  14249. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14250. }
  14251. }
  14252. isSimpleReference(expression) {
  14253. switch (expression.type) {
  14254. case "MemberExpression":
  14255. return !expression.computed && this.isSimpleReference(expression.object);
  14256. case "Identifier":
  14257. return true;
  14258. default:
  14259. return false;
  14260. }
  14261. }
  14262. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14263. if (this.match(19)) {
  14264. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14265. }
  14266. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14267. this.raise(Errors.PipelineTopicUnused, startLoc);
  14268. }
  14269. }
  14270. withTopicBindingContext(callback) {
  14271. const outerContextTopicState = this.state.topicContext;
  14272. this.state.topicContext = {
  14273. maxNumOfResolvableTopics: 1,
  14274. maxTopicIndex: null
  14275. };
  14276. try {
  14277. return callback();
  14278. } finally {
  14279. this.state.topicContext = outerContextTopicState;
  14280. }
  14281. }
  14282. withSmartMixTopicForbiddingContext(callback) {
  14283. if (this.hasPlugin(["pipelineOperator", {
  14284. proposal: "smart"
  14285. }])) {
  14286. const outerContextTopicState = this.state.topicContext;
  14287. this.state.topicContext = {
  14288. maxNumOfResolvableTopics: 0,
  14289. maxTopicIndex: null
  14290. };
  14291. try {
  14292. return callback();
  14293. } finally {
  14294. this.state.topicContext = outerContextTopicState;
  14295. }
  14296. } else {
  14297. return callback();
  14298. }
  14299. }
  14300. withSoloAwaitPermittingContext(callback) {
  14301. const outerContextSoloAwaitState = this.state.soloAwait;
  14302. this.state.soloAwait = true;
  14303. try {
  14304. return callback();
  14305. } finally {
  14306. this.state.soloAwait = outerContextSoloAwaitState;
  14307. }
  14308. }
  14309. allowInAnd(callback) {
  14310. const flags = this.prodParam.currentFlags();
  14311. const prodParamToSet = 8 & ~flags;
  14312. if (prodParamToSet) {
  14313. this.prodParam.enter(flags | 8);
  14314. try {
  14315. return callback();
  14316. } finally {
  14317. this.prodParam.exit();
  14318. }
  14319. }
  14320. return callback();
  14321. }
  14322. disallowInAnd(callback) {
  14323. const flags = this.prodParam.currentFlags();
  14324. const prodParamToClear = 8 & flags;
  14325. if (prodParamToClear) {
  14326. this.prodParam.enter(flags & ~8);
  14327. try {
  14328. return callback();
  14329. } finally {
  14330. this.prodParam.exit();
  14331. }
  14332. }
  14333. return callback();
  14334. }
  14335. registerTopicReference() {
  14336. this.state.topicContext.maxTopicIndex = 0;
  14337. }
  14338. topicReferenceIsAllowedInCurrentContext() {
  14339. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14340. }
  14341. topicReferenceWasUsedInCurrentContext() {
  14342. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14343. }
  14344. parseFSharpPipelineBody(prec) {
  14345. const startLoc = this.state.startLoc;
  14346. this.state.potentialArrowAt = this.state.start;
  14347. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14348. this.state.inFSharpPipelineDirectBody = true;
  14349. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14350. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14351. return ret;
  14352. }
  14353. parseModuleExpression() {
  14354. this.expectPlugin("moduleBlocks");
  14355. const node = this.startNode();
  14356. this.next();
  14357. if (!this.match(5)) {
  14358. this.unexpected(null, 5);
  14359. }
  14360. const program = this.startNodeAt(this.state.endLoc);
  14361. this.next();
  14362. const revertScopes = this.initializeScopes(true);
  14363. this.enterInitialScopes();
  14364. try {
  14365. node.body = this.parseProgram(program, 8, "module");
  14366. } finally {
  14367. revertScopes();
  14368. }
  14369. return this.finishNode(node, "ModuleExpression");
  14370. }
  14371. parsePropertyNamePrefixOperator(prop) {}
  14372. }
  14373. const loopLabel = {
  14374. kind: 1
  14375. },
  14376. switchLabel = {
  14377. kind: 2
  14378. };
  14379. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14380. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14381. function babel7CompatTokens(tokens, input) {
  14382. for (let i = 0; i < tokens.length; i++) {
  14383. const token = tokens[i];
  14384. const {
  14385. type
  14386. } = token;
  14387. if (typeof type === "number") {
  14388. {
  14389. if (type === 138) {
  14390. const {
  14391. loc,
  14392. start,
  14393. value,
  14394. end
  14395. } = token;
  14396. const hashEndPos = start + 1;
  14397. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14398. tokens.splice(i, 1, new Token({
  14399. type: getExportedToken(27),
  14400. value: "#",
  14401. start: start,
  14402. end: hashEndPos,
  14403. startLoc: loc.start,
  14404. endLoc: hashEndLoc
  14405. }), new Token({
  14406. type: getExportedToken(132),
  14407. value: value,
  14408. start: hashEndPos,
  14409. end: end,
  14410. startLoc: hashEndLoc,
  14411. endLoc: loc.end
  14412. }));
  14413. i++;
  14414. continue;
  14415. }
  14416. if (tokenIsTemplate(type)) {
  14417. const {
  14418. loc,
  14419. start,
  14420. value,
  14421. end
  14422. } = token;
  14423. const backquoteEnd = start + 1;
  14424. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14425. let startToken;
  14426. if (input.charCodeAt(start) === 96) {
  14427. startToken = new Token({
  14428. type: getExportedToken(22),
  14429. value: "`",
  14430. start: start,
  14431. end: backquoteEnd,
  14432. startLoc: loc.start,
  14433. endLoc: backquoteEndLoc
  14434. });
  14435. } else {
  14436. startToken = new Token({
  14437. type: getExportedToken(8),
  14438. value: "}",
  14439. start: start,
  14440. end: backquoteEnd,
  14441. startLoc: loc.start,
  14442. endLoc: backquoteEndLoc
  14443. });
  14444. }
  14445. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14446. if (type === 24) {
  14447. templateElementEnd = end - 1;
  14448. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14449. templateValue = value === null ? null : value.slice(1, -1);
  14450. endToken = new Token({
  14451. type: getExportedToken(22),
  14452. value: "`",
  14453. start: templateElementEnd,
  14454. end: end,
  14455. startLoc: templateElementEndLoc,
  14456. endLoc: loc.end
  14457. });
  14458. } else {
  14459. templateElementEnd = end - 2;
  14460. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  14461. templateValue = value === null ? null : value.slice(1, -2);
  14462. endToken = new Token({
  14463. type: getExportedToken(23),
  14464. value: "${",
  14465. start: templateElementEnd,
  14466. end: end,
  14467. startLoc: templateElementEndLoc,
  14468. endLoc: loc.end
  14469. });
  14470. }
  14471. tokens.splice(i, 1, startToken, new Token({
  14472. type: getExportedToken(20),
  14473. value: templateValue,
  14474. start: backquoteEnd,
  14475. end: templateElementEnd,
  14476. startLoc: backquoteEndLoc,
  14477. endLoc: templateElementEndLoc
  14478. }), endToken);
  14479. i += 2;
  14480. continue;
  14481. }
  14482. }
  14483. token.type = getExportedToken(type);
  14484. }
  14485. }
  14486. return tokens;
  14487. }
  14488. class StatementParser extends ExpressionParser {
  14489. parseTopLevel(file, program) {
  14490. file.program = this.parseProgram(program);
  14491. file.comments = this.comments;
  14492. if (this.options.tokens) {
  14493. file.tokens = babel7CompatTokens(this.tokens, this.input);
  14494. }
  14495. return this.finishNode(file, "File");
  14496. }
  14497. parseProgram(program, end = 139, sourceType = this.options.sourceType) {
  14498. program.sourceType = sourceType;
  14499. program.interpreter = this.parseInterpreterDirective();
  14500. this.parseBlockBody(program, true, true, end);
  14501. if (this.inModule) {
  14502. if (!this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  14503. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  14504. this.raise(Errors.ModuleExportUndefined, at, {
  14505. localName
  14506. });
  14507. }
  14508. }
  14509. this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
  14510. }
  14511. let finishedProgram;
  14512. if (end === 139) {
  14513. finishedProgram = this.finishNode(program, "Program");
  14514. } else {
  14515. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  14516. }
  14517. return finishedProgram;
  14518. }
  14519. stmtToDirective(stmt) {
  14520. const directive = stmt;
  14521. directive.type = "Directive";
  14522. directive.value = directive.expression;
  14523. delete directive.expression;
  14524. const directiveLiteral = directive.value;
  14525. const expressionValue = directiveLiteral.value;
  14526. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  14527. const val = directiveLiteral.value = raw.slice(1, -1);
  14528. this.addExtra(directiveLiteral, "raw", raw);
  14529. this.addExtra(directiveLiteral, "rawValue", val);
  14530. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  14531. directiveLiteral.type = "DirectiveLiteral";
  14532. return directive;
  14533. }
  14534. parseInterpreterDirective() {
  14535. if (!this.match(28)) {
  14536. return null;
  14537. }
  14538. const node = this.startNode();
  14539. node.value = this.state.value;
  14540. this.next();
  14541. return this.finishNode(node, "InterpreterDirective");
  14542. }
  14543. isLet() {
  14544. if (!this.isContextual(100)) {
  14545. return false;
  14546. }
  14547. return this.hasFollowingBindingAtom();
  14548. }
  14549. chStartsBindingIdentifier(ch, pos) {
  14550. if (isIdentifierStart(ch)) {
  14551. keywordRelationalOperator.lastIndex = pos;
  14552. if (keywordRelationalOperator.test(this.input)) {
  14553. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  14554. if (!isIdentifierChar(endCh) && endCh !== 92) {
  14555. return false;
  14556. }
  14557. }
  14558. return true;
  14559. } else if (ch === 92) {
  14560. return true;
  14561. } else {
  14562. return false;
  14563. }
  14564. }
  14565. chStartsBindingPattern(ch) {
  14566. return ch === 91 || ch === 123;
  14567. }
  14568. hasFollowingBindingAtom() {
  14569. const next = this.nextTokenStart();
  14570. const nextCh = this.codePointAtPos(next);
  14571. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  14572. }
  14573. hasInLineFollowingBindingIdentifierOrBrace() {
  14574. const next = this.nextTokenInLineStart();
  14575. const nextCh = this.codePointAtPos(next);
  14576. return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next);
  14577. }
  14578. startsUsingForOf() {
  14579. const {
  14580. type,
  14581. containsEsc
  14582. } = this.lookahead();
  14583. if (type === 102 && !containsEsc) {
  14584. return false;
  14585. } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) {
  14586. this.expectPlugin("explicitResourceManagement");
  14587. return true;
  14588. }
  14589. }
  14590. startsAwaitUsing() {
  14591. let next = this.nextTokenInLineStart();
  14592. if (this.isUnparsedContextual(next, "using")) {
  14593. next = this.nextTokenInLineStartSince(next + 5);
  14594. const nextCh = this.codePointAtPos(next);
  14595. if (this.chStartsBindingIdentifier(nextCh, next)) {
  14596. this.expectPlugin("explicitResourceManagement");
  14597. return true;
  14598. }
  14599. }
  14600. return false;
  14601. }
  14602. parseModuleItem() {
  14603. return this.parseStatementLike(1 | 2 | 4 | 8);
  14604. }
  14605. parseStatementListItem() {
  14606. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  14607. }
  14608. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  14609. let flags = 0;
  14610. if (this.options.annexB && !this.state.strict) {
  14611. flags |= 4;
  14612. if (allowLabeledFunction) {
  14613. flags |= 8;
  14614. }
  14615. }
  14616. return this.parseStatementLike(flags);
  14617. }
  14618. parseStatement() {
  14619. return this.parseStatementLike(0);
  14620. }
  14621. parseStatementLike(flags) {
  14622. let decorators = null;
  14623. if (this.match(26)) {
  14624. decorators = this.parseDecorators(true);
  14625. }
  14626. return this.parseStatementContent(flags, decorators);
  14627. }
  14628. parseStatementContent(flags, decorators) {
  14629. const startType = this.state.type;
  14630. const node = this.startNode();
  14631. const allowDeclaration = !!(flags & 2);
  14632. const allowFunctionDeclaration = !!(flags & 4);
  14633. const topLevel = flags & 1;
  14634. switch (startType) {
  14635. case 60:
  14636. return this.parseBreakContinueStatement(node, true);
  14637. case 63:
  14638. return this.parseBreakContinueStatement(node, false);
  14639. case 64:
  14640. return this.parseDebuggerStatement(node);
  14641. case 90:
  14642. return this.parseDoWhileStatement(node);
  14643. case 91:
  14644. return this.parseForStatement(node);
  14645. case 68:
  14646. if (this.lookaheadCharCode() === 46) break;
  14647. if (!allowFunctionDeclaration) {
  14648. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  14649. }
  14650. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  14651. case 80:
  14652. if (!allowDeclaration) this.unexpected();
  14653. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  14654. case 69:
  14655. return this.parseIfStatement(node);
  14656. case 70:
  14657. return this.parseReturnStatement(node);
  14658. case 71:
  14659. return this.parseSwitchStatement(node);
  14660. case 72:
  14661. return this.parseThrowStatement(node);
  14662. case 73:
  14663. return this.parseTryStatement(node);
  14664. case 96:
  14665. if (!this.state.containsEsc && this.startsAwaitUsing()) {
  14666. if (!this.recordAwaitIfAllowed()) {
  14667. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  14668. } else if (!allowDeclaration) {
  14669. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  14670. }
  14671. this.next();
  14672. return this.parseVarStatement(node, "await using");
  14673. }
  14674. break;
  14675. case 107:
  14676. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) {
  14677. break;
  14678. }
  14679. this.expectPlugin("explicitResourceManagement");
  14680. if (!this.scope.inModule && this.scope.inTopLevel) {
  14681. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  14682. } else if (!allowDeclaration) {
  14683. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14684. }
  14685. return this.parseVarStatement(node, "using");
  14686. case 100:
  14687. {
  14688. if (this.state.containsEsc) {
  14689. break;
  14690. }
  14691. const next = this.nextTokenStart();
  14692. const nextCh = this.codePointAtPos(next);
  14693. if (nextCh !== 91) {
  14694. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  14695. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  14696. break;
  14697. }
  14698. }
  14699. }
  14700. case 75:
  14701. {
  14702. if (!allowDeclaration) {
  14703. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14704. }
  14705. }
  14706. case 74:
  14707. {
  14708. const kind = this.state.value;
  14709. return this.parseVarStatement(node, kind);
  14710. }
  14711. case 92:
  14712. return this.parseWhileStatement(node);
  14713. case 76:
  14714. return this.parseWithStatement(node);
  14715. case 5:
  14716. return this.parseBlock();
  14717. case 13:
  14718. return this.parseEmptyStatement(node);
  14719. case 83:
  14720. {
  14721. const nextTokenCharCode = this.lookaheadCharCode();
  14722. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  14723. break;
  14724. }
  14725. }
  14726. case 82:
  14727. {
  14728. if (!this.options.allowImportExportEverywhere && !topLevel) {
  14729. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  14730. }
  14731. this.next();
  14732. let result;
  14733. if (startType === 83) {
  14734. result = this.parseImport(node);
  14735. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  14736. this.sawUnambiguousESM = true;
  14737. }
  14738. } else {
  14739. result = this.parseExport(node, decorators);
  14740. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  14741. this.sawUnambiguousESM = true;
  14742. }
  14743. }
  14744. this.assertModuleNodeAllowed(result);
  14745. return result;
  14746. }
  14747. default:
  14748. {
  14749. if (this.isAsyncFunction()) {
  14750. if (!allowDeclaration) {
  14751. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  14752. }
  14753. this.next();
  14754. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  14755. }
  14756. }
  14757. }
  14758. const maybeName = this.state.value;
  14759. const expr = this.parseExpression();
  14760. if (tokenIsIdentifier(startType) && expr.type === "Identifier" && this.eat(14)) {
  14761. return this.parseLabeledStatement(node, maybeName, expr, flags);
  14762. } else {
  14763. return this.parseExpressionStatement(node, expr, decorators);
  14764. }
  14765. }
  14766. assertModuleNodeAllowed(node) {
  14767. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  14768. this.raise(Errors.ImportOutsideModule, node);
  14769. }
  14770. }
  14771. decoratorsEnabledBeforeExport() {
  14772. if (this.hasPlugin("decorators-legacy")) return true;
  14773. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  14774. }
  14775. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  14776. if (maybeDecorators) {
  14777. if (classNode.decorators && classNode.decorators.length > 0) {
  14778. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  14779. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  14780. }
  14781. classNode.decorators.unshift(...maybeDecorators);
  14782. } else {
  14783. classNode.decorators = maybeDecorators;
  14784. }
  14785. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  14786. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  14787. }
  14788. return classNode;
  14789. }
  14790. canHaveLeadingDecorator() {
  14791. return this.match(80);
  14792. }
  14793. parseDecorators(allowExport) {
  14794. const decorators = [];
  14795. do {
  14796. decorators.push(this.parseDecorator());
  14797. } while (this.match(26));
  14798. if (this.match(82)) {
  14799. if (!allowExport) {
  14800. this.unexpected();
  14801. }
  14802. if (!this.decoratorsEnabledBeforeExport()) {
  14803. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  14804. }
  14805. } else if (!this.canHaveLeadingDecorator()) {
  14806. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  14807. }
  14808. return decorators;
  14809. }
  14810. parseDecorator() {
  14811. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  14812. const node = this.startNode();
  14813. this.next();
  14814. if (this.hasPlugin("decorators")) {
  14815. const startLoc = this.state.startLoc;
  14816. let expr;
  14817. if (this.match(10)) {
  14818. const startLoc = this.state.startLoc;
  14819. this.next();
  14820. expr = this.parseExpression();
  14821. this.expect(11);
  14822. expr = this.wrapParenthesis(startLoc, expr);
  14823. const paramsStartLoc = this.state.startLoc;
  14824. node.expression = this.parseMaybeDecoratorArguments(expr);
  14825. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  14826. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  14827. }
  14828. } else {
  14829. expr = this.parseIdentifier(false);
  14830. while (this.eat(16)) {
  14831. const node = this.startNodeAt(startLoc);
  14832. node.object = expr;
  14833. if (this.match(138)) {
  14834. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  14835. node.property = this.parsePrivateName();
  14836. } else {
  14837. node.property = this.parseIdentifier(true);
  14838. }
  14839. node.computed = false;
  14840. expr = this.finishNode(node, "MemberExpression");
  14841. }
  14842. node.expression = this.parseMaybeDecoratorArguments(expr);
  14843. }
  14844. } else {
  14845. node.expression = this.parseExprSubscripts();
  14846. }
  14847. return this.finishNode(node, "Decorator");
  14848. }
  14849. parseMaybeDecoratorArguments(expr) {
  14850. if (this.eat(10)) {
  14851. const node = this.startNodeAtNode(expr);
  14852. node.callee = expr;
  14853. node.arguments = this.parseCallExpressionArguments(11, false);
  14854. this.toReferencedList(node.arguments);
  14855. return this.finishNode(node, "CallExpression");
  14856. }
  14857. return expr;
  14858. }
  14859. parseBreakContinueStatement(node, isBreak) {
  14860. this.next();
  14861. if (this.isLineTerminator()) {
  14862. node.label = null;
  14863. } else {
  14864. node.label = this.parseIdentifier();
  14865. this.semicolon();
  14866. }
  14867. this.verifyBreakContinue(node, isBreak);
  14868. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  14869. }
  14870. verifyBreakContinue(node, isBreak) {
  14871. let i;
  14872. for (i = 0; i < this.state.labels.length; ++i) {
  14873. const lab = this.state.labels[i];
  14874. if (node.label == null || lab.name === node.label.name) {
  14875. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  14876. break;
  14877. }
  14878. if (node.label && isBreak) break;
  14879. }
  14880. }
  14881. if (i === this.state.labels.length) {
  14882. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  14883. this.raise(Errors.IllegalBreakContinue, node, {
  14884. type
  14885. });
  14886. }
  14887. }
  14888. parseDebuggerStatement(node) {
  14889. this.next();
  14890. this.semicolon();
  14891. return this.finishNode(node, "DebuggerStatement");
  14892. }
  14893. parseHeaderExpression() {
  14894. this.expect(10);
  14895. const val = this.parseExpression();
  14896. this.expect(11);
  14897. return val;
  14898. }
  14899. parseDoWhileStatement(node) {
  14900. this.next();
  14901. this.state.labels.push(loopLabel);
  14902. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  14903. this.state.labels.pop();
  14904. this.expect(92);
  14905. node.test = this.parseHeaderExpression();
  14906. this.eat(13);
  14907. return this.finishNode(node, "DoWhileStatement");
  14908. }
  14909. parseForStatement(node) {
  14910. this.next();
  14911. this.state.labels.push(loopLabel);
  14912. let awaitAt = null;
  14913. if (this.isContextual(96) && this.recordAwaitIfAllowed()) {
  14914. awaitAt = this.state.startLoc;
  14915. this.next();
  14916. }
  14917. this.scope.enter(0);
  14918. this.expect(10);
  14919. if (this.match(13)) {
  14920. if (awaitAt !== null) {
  14921. this.unexpected(awaitAt);
  14922. }
  14923. return this.parseFor(node, null);
  14924. }
  14925. const startsWithLet = this.isContextual(100);
  14926. {
  14927. const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing();
  14928. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf();
  14929. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  14930. if (this.match(74) || this.match(75) || isLetOrUsing) {
  14931. const initNode = this.startNode();
  14932. let kind;
  14933. if (startsWithAwaitUsing) {
  14934. kind = "await using";
  14935. if (!this.recordAwaitIfAllowed()) {
  14936. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  14937. }
  14938. this.next();
  14939. } else {
  14940. kind = this.state.value;
  14941. }
  14942. this.next();
  14943. this.parseVar(initNode, true, kind);
  14944. const init = this.finishNode(initNode, "VariableDeclaration");
  14945. const isForIn = this.match(58);
  14946. if (isForIn && starsWithUsingDeclaration) {
  14947. this.raise(Errors.ForInUsing, init);
  14948. }
  14949. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  14950. return this.parseForIn(node, init, awaitAt);
  14951. }
  14952. if (awaitAt !== null) {
  14953. this.unexpected(awaitAt);
  14954. }
  14955. return this.parseFor(node, init);
  14956. }
  14957. }
  14958. const startsWithAsync = this.isContextual(95);
  14959. const refExpressionErrors = new ExpressionErrors();
  14960. const init = this.parseExpression(true, refExpressionErrors);
  14961. const isForOf = this.isContextual(102);
  14962. if (isForOf) {
  14963. if (startsWithLet) {
  14964. this.raise(Errors.ForOfLet, init);
  14965. }
  14966. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  14967. this.raise(Errors.ForOfAsync, init);
  14968. }
  14969. }
  14970. if (isForOf || this.match(58)) {
  14971. this.checkDestructuringPrivate(refExpressionErrors);
  14972. this.toAssignable(init, true);
  14973. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  14974. this.checkLVal(init, {
  14975. type
  14976. });
  14977. return this.parseForIn(node, init, awaitAt);
  14978. } else {
  14979. this.checkExpressionErrors(refExpressionErrors, true);
  14980. }
  14981. if (awaitAt !== null) {
  14982. this.unexpected(awaitAt);
  14983. }
  14984. return this.parseFor(node, init);
  14985. }
  14986. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  14987. this.next();
  14988. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  14989. }
  14990. parseIfStatement(node) {
  14991. this.next();
  14992. node.test = this.parseHeaderExpression();
  14993. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  14994. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  14995. return this.finishNode(node, "IfStatement");
  14996. }
  14997. parseReturnStatement(node) {
  14998. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  14999. this.raise(Errors.IllegalReturn, this.state.startLoc);
  15000. }
  15001. this.next();
  15002. if (this.isLineTerminator()) {
  15003. node.argument = null;
  15004. } else {
  15005. node.argument = this.parseExpression();
  15006. this.semicolon();
  15007. }
  15008. return this.finishNode(node, "ReturnStatement");
  15009. }
  15010. parseSwitchStatement(node) {
  15011. this.next();
  15012. node.discriminant = this.parseHeaderExpression();
  15013. const cases = node.cases = [];
  15014. this.expect(5);
  15015. this.state.labels.push(switchLabel);
  15016. this.scope.enter(0);
  15017. let cur;
  15018. for (let sawDefault; !this.match(8);) {
  15019. if (this.match(61) || this.match(65)) {
  15020. const isCase = this.match(61);
  15021. if (cur) this.finishNode(cur, "SwitchCase");
  15022. cases.push(cur = this.startNode());
  15023. cur.consequent = [];
  15024. this.next();
  15025. if (isCase) {
  15026. cur.test = this.parseExpression();
  15027. } else {
  15028. if (sawDefault) {
  15029. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  15030. }
  15031. sawDefault = true;
  15032. cur.test = null;
  15033. }
  15034. this.expect(14);
  15035. } else {
  15036. if (cur) {
  15037. cur.consequent.push(this.parseStatementListItem());
  15038. } else {
  15039. this.unexpected();
  15040. }
  15041. }
  15042. }
  15043. this.scope.exit();
  15044. if (cur) this.finishNode(cur, "SwitchCase");
  15045. this.next();
  15046. this.state.labels.pop();
  15047. return this.finishNode(node, "SwitchStatement");
  15048. }
  15049. parseThrowStatement(node) {
  15050. this.next();
  15051. if (this.hasPrecedingLineBreak()) {
  15052. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  15053. }
  15054. node.argument = this.parseExpression();
  15055. this.semicolon();
  15056. return this.finishNode(node, "ThrowStatement");
  15057. }
  15058. parseCatchClauseParam() {
  15059. const param = this.parseBindingAtom();
  15060. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15061. this.checkLVal(param, {
  15062. type: "CatchClause"
  15063. }, 9);
  15064. return param;
  15065. }
  15066. parseTryStatement(node) {
  15067. this.next();
  15068. node.block = this.parseBlock();
  15069. node.handler = null;
  15070. if (this.match(62)) {
  15071. const clause = this.startNode();
  15072. this.next();
  15073. if (this.match(10)) {
  15074. this.expect(10);
  15075. clause.param = this.parseCatchClauseParam();
  15076. this.expect(11);
  15077. } else {
  15078. clause.param = null;
  15079. this.scope.enter(0);
  15080. }
  15081. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15082. this.scope.exit();
  15083. node.handler = this.finishNode(clause, "CatchClause");
  15084. }
  15085. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15086. if (!node.handler && !node.finalizer) {
  15087. this.raise(Errors.NoCatchOrFinally, node);
  15088. }
  15089. return this.finishNode(node, "TryStatement");
  15090. }
  15091. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15092. this.next();
  15093. this.parseVar(node, false, kind, allowMissingInitializer);
  15094. this.semicolon();
  15095. return this.finishNode(node, "VariableDeclaration");
  15096. }
  15097. parseWhileStatement(node) {
  15098. this.next();
  15099. node.test = this.parseHeaderExpression();
  15100. this.state.labels.push(loopLabel);
  15101. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15102. this.state.labels.pop();
  15103. return this.finishNode(node, "WhileStatement");
  15104. }
  15105. parseWithStatement(node) {
  15106. if (this.state.strict) {
  15107. this.raise(Errors.StrictWith, this.state.startLoc);
  15108. }
  15109. this.next();
  15110. node.object = this.parseHeaderExpression();
  15111. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15112. return this.finishNode(node, "WithStatement");
  15113. }
  15114. parseEmptyStatement(node) {
  15115. this.next();
  15116. return this.finishNode(node, "EmptyStatement");
  15117. }
  15118. parseLabeledStatement(node, maybeName, expr, flags) {
  15119. for (const label of this.state.labels) {
  15120. if (label.name === maybeName) {
  15121. this.raise(Errors.LabelRedeclaration, expr, {
  15122. labelName: maybeName
  15123. });
  15124. }
  15125. }
  15126. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15127. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15128. const label = this.state.labels[i];
  15129. if (label.statementStart === node.start) {
  15130. label.statementStart = this.state.start;
  15131. label.kind = kind;
  15132. } else {
  15133. break;
  15134. }
  15135. }
  15136. this.state.labels.push({
  15137. name: maybeName,
  15138. kind: kind,
  15139. statementStart: this.state.start
  15140. });
  15141. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15142. this.state.labels.pop();
  15143. node.label = expr;
  15144. return this.finishNode(node, "LabeledStatement");
  15145. }
  15146. parseExpressionStatement(node, expr, decorators) {
  15147. node.expression = expr;
  15148. this.semicolon();
  15149. return this.finishNode(node, "ExpressionStatement");
  15150. }
  15151. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15152. const node = this.startNode();
  15153. if (allowDirectives) {
  15154. this.state.strictErrors.clear();
  15155. }
  15156. this.expect(5);
  15157. if (createNewLexicalScope) {
  15158. this.scope.enter(0);
  15159. }
  15160. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15161. if (createNewLexicalScope) {
  15162. this.scope.exit();
  15163. }
  15164. return this.finishNode(node, "BlockStatement");
  15165. }
  15166. isValidDirective(stmt) {
  15167. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15168. }
  15169. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15170. const body = node.body = [];
  15171. const directives = node.directives = [];
  15172. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15173. }
  15174. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15175. const oldStrict = this.state.strict;
  15176. let hasStrictModeDirective = false;
  15177. let parsedNonDirective = false;
  15178. while (!this.match(end)) {
  15179. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15180. if (directives && !parsedNonDirective) {
  15181. if (this.isValidDirective(stmt)) {
  15182. const directive = this.stmtToDirective(stmt);
  15183. directives.push(directive);
  15184. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15185. hasStrictModeDirective = true;
  15186. this.setStrict(true);
  15187. }
  15188. continue;
  15189. }
  15190. parsedNonDirective = true;
  15191. this.state.strictErrors.clear();
  15192. }
  15193. body.push(stmt);
  15194. }
  15195. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15196. if (!oldStrict) {
  15197. this.setStrict(false);
  15198. }
  15199. this.next();
  15200. }
  15201. parseFor(node, init) {
  15202. node.init = init;
  15203. this.semicolon(false);
  15204. node.test = this.match(13) ? null : this.parseExpression();
  15205. this.semicolon(false);
  15206. node.update = this.match(11) ? null : this.parseExpression();
  15207. this.expect(11);
  15208. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15209. this.scope.exit();
  15210. this.state.labels.pop();
  15211. return this.finishNode(node, "ForStatement");
  15212. }
  15213. parseForIn(node, init, awaitAt) {
  15214. const isForIn = this.match(58);
  15215. this.next();
  15216. if (isForIn) {
  15217. if (awaitAt !== null) this.unexpected(awaitAt);
  15218. } else {
  15219. node.await = awaitAt !== null;
  15220. }
  15221. 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")) {
  15222. this.raise(Errors.ForInOfLoopInitializer, init, {
  15223. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15224. });
  15225. }
  15226. if (init.type === "AssignmentPattern") {
  15227. this.raise(Errors.InvalidLhs, init, {
  15228. ancestor: {
  15229. type: "ForStatement"
  15230. }
  15231. });
  15232. }
  15233. node.left = init;
  15234. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15235. this.expect(11);
  15236. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15237. this.scope.exit();
  15238. this.state.labels.pop();
  15239. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15240. }
  15241. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15242. const declarations = node.declarations = [];
  15243. node.kind = kind;
  15244. for (;;) {
  15245. const decl = this.startNode();
  15246. this.parseVarId(decl, kind);
  15247. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15248. if (decl.init === null && !allowMissingInitializer) {
  15249. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15250. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15251. kind: "destructuring"
  15252. });
  15253. } else if ((kind === "const" || kind === "using" || kind === "await using") && !(this.match(58) || this.isContextual(102))) {
  15254. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15255. kind
  15256. });
  15257. }
  15258. }
  15259. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15260. if (!this.eat(12)) break;
  15261. }
  15262. return node;
  15263. }
  15264. parseVarId(decl, kind) {
  15265. const id = this.parseBindingAtom();
  15266. if (kind === "using" || kind === "await using") {
  15267. if (id.type === "ArrayPattern" || id.type === "ObjectPattern") {
  15268. this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start);
  15269. }
  15270. }
  15271. this.checkLVal(id, {
  15272. type: "VariableDeclarator"
  15273. }, kind === "var" ? 5 : 8201);
  15274. decl.id = id;
  15275. }
  15276. parseAsyncFunctionExpression(node) {
  15277. return this.parseFunction(node, 8);
  15278. }
  15279. parseFunction(node, flags = 0) {
  15280. const hangingDeclaration = flags & 2;
  15281. const isDeclaration = !!(flags & 1);
  15282. const requireId = isDeclaration && !(flags & 4);
  15283. const isAsync = !!(flags & 8);
  15284. this.initFunction(node, isAsync);
  15285. if (this.match(55)) {
  15286. if (hangingDeclaration) {
  15287. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15288. }
  15289. this.next();
  15290. node.generator = true;
  15291. }
  15292. if (isDeclaration) {
  15293. node.id = this.parseFunctionId(requireId);
  15294. }
  15295. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15296. this.state.maybeInArrowParameters = false;
  15297. this.scope.enter(2);
  15298. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15299. if (!isDeclaration) {
  15300. node.id = this.parseFunctionId();
  15301. }
  15302. this.parseFunctionParams(node, false);
  15303. this.withSmartMixTopicForbiddingContext(() => {
  15304. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15305. });
  15306. this.prodParam.exit();
  15307. this.scope.exit();
  15308. if (isDeclaration && !hangingDeclaration) {
  15309. this.registerFunctionStatementId(node);
  15310. }
  15311. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15312. return node;
  15313. }
  15314. parseFunctionId(requireId) {
  15315. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15316. }
  15317. parseFunctionParams(node, isConstructor) {
  15318. this.expect(10);
  15319. this.expressionScope.enter(newParameterDeclarationScope());
  15320. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15321. this.expressionScope.exit();
  15322. }
  15323. registerFunctionStatementId(node) {
  15324. if (!node.id) return;
  15325. 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);
  15326. }
  15327. parseClass(node, isStatement, optionalId) {
  15328. this.next();
  15329. const oldStrict = this.state.strict;
  15330. this.state.strict = true;
  15331. this.parseClassId(node, isStatement, optionalId);
  15332. this.parseClassSuper(node);
  15333. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15334. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15335. }
  15336. isClassProperty() {
  15337. return this.match(29) || this.match(13) || this.match(8);
  15338. }
  15339. isClassMethod() {
  15340. return this.match(10);
  15341. }
  15342. nameIsConstructor(key) {
  15343. return key.type === "Identifier" && key.name === "constructor" || key.type === "StringLiteral" && key.value === "constructor";
  15344. }
  15345. isNonstaticConstructor(method) {
  15346. return !method.computed && !method.static && this.nameIsConstructor(method.key);
  15347. }
  15348. parseClassBody(hadSuperClass, oldStrict) {
  15349. this.classScope.enter();
  15350. const state = {
  15351. hadConstructor: false,
  15352. hadSuperClass
  15353. };
  15354. let decorators = [];
  15355. const classBody = this.startNode();
  15356. classBody.body = [];
  15357. this.expect(5);
  15358. this.withSmartMixTopicForbiddingContext(() => {
  15359. while (!this.match(8)) {
  15360. if (this.eat(13)) {
  15361. if (decorators.length > 0) {
  15362. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15363. }
  15364. continue;
  15365. }
  15366. if (this.match(26)) {
  15367. decorators.push(this.parseDecorator());
  15368. continue;
  15369. }
  15370. const member = this.startNode();
  15371. if (decorators.length) {
  15372. member.decorators = decorators;
  15373. this.resetStartLocationFromNode(member, decorators[0]);
  15374. decorators = [];
  15375. }
  15376. this.parseClassMember(classBody, member, state);
  15377. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15378. this.raise(Errors.DecoratorConstructor, member);
  15379. }
  15380. }
  15381. });
  15382. this.state.strict = oldStrict;
  15383. this.next();
  15384. if (decorators.length) {
  15385. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15386. }
  15387. this.classScope.exit();
  15388. return this.finishNode(classBody, "ClassBody");
  15389. }
  15390. parseClassMemberFromModifier(classBody, member) {
  15391. const key = this.parseIdentifier(true);
  15392. if (this.isClassMethod()) {
  15393. const method = member;
  15394. method.kind = "method";
  15395. method.computed = false;
  15396. method.key = key;
  15397. method.static = false;
  15398. this.pushClassMethod(classBody, method, false, false, false, false);
  15399. return true;
  15400. } else if (this.isClassProperty()) {
  15401. const prop = member;
  15402. prop.computed = false;
  15403. prop.key = key;
  15404. prop.static = false;
  15405. classBody.body.push(this.parseClassProperty(prop));
  15406. return true;
  15407. }
  15408. this.resetPreviousNodeTrailingComments(key);
  15409. return false;
  15410. }
  15411. parseClassMember(classBody, member, state) {
  15412. const isStatic = this.isContextual(106);
  15413. if (isStatic) {
  15414. if (this.parseClassMemberFromModifier(classBody, member)) {
  15415. return;
  15416. }
  15417. if (this.eat(5)) {
  15418. this.parseClassStaticBlock(classBody, member);
  15419. return;
  15420. }
  15421. }
  15422. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15423. }
  15424. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15425. const publicMethod = member;
  15426. const privateMethod = member;
  15427. const publicProp = member;
  15428. const privateProp = member;
  15429. const accessorProp = member;
  15430. const method = publicMethod;
  15431. const publicMember = publicMethod;
  15432. member.static = isStatic;
  15433. this.parsePropertyNamePrefixOperator(member);
  15434. if (this.eat(55)) {
  15435. method.kind = "method";
  15436. const isPrivateName = this.match(138);
  15437. this.parseClassElementName(method);
  15438. if (isPrivateName) {
  15439. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  15440. return;
  15441. }
  15442. if (this.isNonstaticConstructor(publicMethod)) {
  15443. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  15444. }
  15445. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  15446. return;
  15447. }
  15448. const isContextual = !this.state.containsEsc && tokenIsIdentifier(this.state.type);
  15449. const key = this.parseClassElementName(member);
  15450. const maybeContextualKw = isContextual ? key.name : null;
  15451. const isPrivate = this.isPrivateName(key);
  15452. const maybeQuestionTokenStartLoc = this.state.startLoc;
  15453. this.parsePostMemberNameModifiers(publicMember);
  15454. if (this.isClassMethod()) {
  15455. method.kind = "method";
  15456. if (isPrivate) {
  15457. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15458. return;
  15459. }
  15460. const isConstructor = this.isNonstaticConstructor(publicMethod);
  15461. let allowsDirectSuper = false;
  15462. if (isConstructor) {
  15463. publicMethod.kind = "constructor";
  15464. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  15465. this.raise(Errors.DuplicateConstructor, key);
  15466. }
  15467. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  15468. this.raise(Errors.OverrideOnConstructor, key);
  15469. }
  15470. state.hadConstructor = true;
  15471. allowsDirectSuper = state.hadSuperClass;
  15472. }
  15473. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  15474. } else if (this.isClassProperty()) {
  15475. if (isPrivate) {
  15476. this.pushClassPrivateProperty(classBody, privateProp);
  15477. } else {
  15478. this.pushClassProperty(classBody, publicProp);
  15479. }
  15480. } else if (maybeContextualKw === "async" && !this.isLineTerminator()) {
  15481. this.resetPreviousNodeTrailingComments(key);
  15482. const isGenerator = this.eat(55);
  15483. if (publicMember.optional) {
  15484. this.unexpected(maybeQuestionTokenStartLoc);
  15485. }
  15486. method.kind = "method";
  15487. const isPrivate = this.match(138);
  15488. this.parseClassElementName(method);
  15489. this.parsePostMemberNameModifiers(publicMember);
  15490. if (isPrivate) {
  15491. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  15492. } else {
  15493. if (this.isNonstaticConstructor(publicMethod)) {
  15494. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  15495. }
  15496. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  15497. }
  15498. } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) {
  15499. this.resetPreviousNodeTrailingComments(key);
  15500. method.kind = maybeContextualKw;
  15501. const isPrivate = this.match(138);
  15502. this.parseClassElementName(publicMethod);
  15503. if (isPrivate) {
  15504. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15505. } else {
  15506. if (this.isNonstaticConstructor(publicMethod)) {
  15507. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  15508. }
  15509. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  15510. }
  15511. this.checkGetterSetterParams(publicMethod);
  15512. } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
  15513. this.expectPlugin("decoratorAutoAccessors");
  15514. this.resetPreviousNodeTrailingComments(key);
  15515. const isPrivate = this.match(138);
  15516. this.parseClassElementName(publicProp);
  15517. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  15518. } else if (this.isLineTerminator()) {
  15519. if (isPrivate) {
  15520. this.pushClassPrivateProperty(classBody, privateProp);
  15521. } else {
  15522. this.pushClassProperty(classBody, publicProp);
  15523. }
  15524. } else {
  15525. this.unexpected();
  15526. }
  15527. }
  15528. parseClassElementName(member) {
  15529. const {
  15530. type,
  15531. value
  15532. } = this.state;
  15533. if ((type === 132 || type === 133) && member.static && value === "prototype") {
  15534. this.raise(Errors.StaticPrototype, this.state.startLoc);
  15535. }
  15536. if (type === 138) {
  15537. if (value === "constructor") {
  15538. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  15539. }
  15540. const key = this.parsePrivateName();
  15541. member.key = key;
  15542. return key;
  15543. }
  15544. this.parsePropertyName(member);
  15545. return member.key;
  15546. }
  15547. parseClassStaticBlock(classBody, member) {
  15548. var _member$decorators;
  15549. this.scope.enter(64 | 128 | 16);
  15550. const oldLabels = this.state.labels;
  15551. this.state.labels = [];
  15552. this.prodParam.enter(0);
  15553. const body = member.body = [];
  15554. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  15555. this.prodParam.exit();
  15556. this.scope.exit();
  15557. this.state.labels = oldLabels;
  15558. classBody.body.push(this.finishNode(member, "StaticBlock"));
  15559. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  15560. this.raise(Errors.DecoratorStaticBlock, member);
  15561. }
  15562. }
  15563. pushClassProperty(classBody, prop) {
  15564. if (!prop.computed && this.nameIsConstructor(prop.key)) {
  15565. this.raise(Errors.ConstructorClassField, prop.key);
  15566. }
  15567. classBody.body.push(this.parseClassProperty(prop));
  15568. }
  15569. pushClassPrivateProperty(classBody, prop) {
  15570. const node = this.parseClassPrivateProperty(prop);
  15571. classBody.body.push(node);
  15572. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15573. }
  15574. pushClassAccessorProperty(classBody, prop, isPrivate) {
  15575. if (!isPrivate && !prop.computed && this.nameIsConstructor(prop.key)) {
  15576. this.raise(Errors.ConstructorClassField, prop.key);
  15577. }
  15578. const node = this.parseClassAccessorProperty(prop);
  15579. classBody.body.push(node);
  15580. if (isPrivate) {
  15581. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15582. }
  15583. }
  15584. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  15585. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  15586. }
  15587. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  15588. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  15589. classBody.body.push(node);
  15590. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  15591. this.declareClassPrivateMethodInScope(node, kind);
  15592. }
  15593. declareClassPrivateMethodInScope(node, kind) {
  15594. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  15595. }
  15596. parsePostMemberNameModifiers(methodOrProp) {}
  15597. parseClassPrivateProperty(node) {
  15598. this.parseInitializer(node);
  15599. this.semicolon();
  15600. return this.finishNode(node, "ClassPrivateProperty");
  15601. }
  15602. parseClassProperty(node) {
  15603. this.parseInitializer(node);
  15604. this.semicolon();
  15605. return this.finishNode(node, "ClassProperty");
  15606. }
  15607. parseClassAccessorProperty(node) {
  15608. this.parseInitializer(node);
  15609. this.semicolon();
  15610. return this.finishNode(node, "ClassAccessorProperty");
  15611. }
  15612. parseInitializer(node) {
  15613. this.scope.enter(64 | 16);
  15614. this.expressionScope.enter(newExpressionScope());
  15615. this.prodParam.enter(0);
  15616. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  15617. this.expressionScope.exit();
  15618. this.prodParam.exit();
  15619. this.scope.exit();
  15620. }
  15621. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  15622. if (tokenIsIdentifier(this.state.type)) {
  15623. node.id = this.parseIdentifier();
  15624. if (isStatement) {
  15625. this.declareNameFromIdentifier(node.id, bindingType);
  15626. }
  15627. } else {
  15628. if (optionalId || !isStatement) {
  15629. node.id = null;
  15630. } else {
  15631. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  15632. }
  15633. }
  15634. }
  15635. parseClassSuper(node) {
  15636. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  15637. }
  15638. parseExport(node, decorators) {
  15639. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  15640. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  15641. const parseAfterDefault = !hasDefault || this.eat(12);
  15642. const hasStar = parseAfterDefault && this.eatExportStar(node);
  15643. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  15644. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  15645. const isFromRequired = hasDefault || hasStar;
  15646. if (hasStar && !hasNamespace) {
  15647. if (hasDefault) this.unexpected();
  15648. if (decorators) {
  15649. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15650. }
  15651. this.parseExportFrom(node, true);
  15652. return this.finishNode(node, "ExportAllDeclaration");
  15653. }
  15654. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  15655. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  15656. this.unexpected(null, 5);
  15657. }
  15658. if (hasNamespace && parseAfterNamespace) {
  15659. this.unexpected(null, 98);
  15660. }
  15661. let hasDeclaration;
  15662. if (isFromRequired || hasSpecifiers) {
  15663. hasDeclaration = false;
  15664. if (decorators) {
  15665. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15666. }
  15667. this.parseExportFrom(node, isFromRequired);
  15668. } else {
  15669. hasDeclaration = this.maybeParseExportDeclaration(node);
  15670. }
  15671. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  15672. var _node2$declaration;
  15673. const node2 = node;
  15674. this.checkExport(node2, true, false, !!node2.source);
  15675. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  15676. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  15677. } else if (decorators) {
  15678. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15679. }
  15680. return this.finishNode(node2, "ExportNamedDeclaration");
  15681. }
  15682. if (this.eat(65)) {
  15683. const node2 = node;
  15684. const decl = this.parseExportDefaultExpression();
  15685. node2.declaration = decl;
  15686. if (decl.type === "ClassDeclaration") {
  15687. this.maybeTakeDecorators(decorators, decl, node2);
  15688. } else if (decorators) {
  15689. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15690. }
  15691. this.checkExport(node2, true, true);
  15692. return this.finishNode(node2, "ExportDefaultDeclaration");
  15693. }
  15694. this.unexpected(null, 5);
  15695. }
  15696. eatExportStar(node) {
  15697. return this.eat(55);
  15698. }
  15699. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  15700. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  15701. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  15702. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  15703. const specifier = this.startNodeAtNode(id);
  15704. specifier.exported = id;
  15705. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  15706. return true;
  15707. }
  15708. return false;
  15709. }
  15710. maybeParseExportNamespaceSpecifier(node) {
  15711. if (this.isContextual(93)) {
  15712. var _ref, _ref$specifiers;
  15713. (_ref$specifiers = (_ref = node).specifiers) != null ? _ref$specifiers : _ref.specifiers = [];
  15714. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  15715. this.next();
  15716. specifier.exported = this.parseModuleExportName();
  15717. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  15718. return true;
  15719. }
  15720. return false;
  15721. }
  15722. maybeParseExportNamedSpecifiers(node) {
  15723. if (this.match(5)) {
  15724. const node2 = node;
  15725. if (!node2.specifiers) node2.specifiers = [];
  15726. const isTypeExport = node2.exportKind === "type";
  15727. node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  15728. node2.source = null;
  15729. node2.declaration = null;
  15730. if (this.hasPlugin("importAssertions")) {
  15731. node2.assertions = [];
  15732. }
  15733. return true;
  15734. }
  15735. return false;
  15736. }
  15737. maybeParseExportDeclaration(node) {
  15738. if (this.shouldParseExportDeclaration()) {
  15739. node.specifiers = [];
  15740. node.source = null;
  15741. if (this.hasPlugin("importAssertions")) {
  15742. node.assertions = [];
  15743. }
  15744. node.declaration = this.parseExportDeclaration(node);
  15745. return true;
  15746. }
  15747. return false;
  15748. }
  15749. isAsyncFunction() {
  15750. if (!this.isContextual(95)) return false;
  15751. const next = this.nextTokenInLineStart();
  15752. return this.isUnparsedContextual(next, "function");
  15753. }
  15754. parseExportDefaultExpression() {
  15755. const expr = this.startNode();
  15756. if (this.match(68)) {
  15757. this.next();
  15758. return this.parseFunction(expr, 1 | 4);
  15759. } else if (this.isAsyncFunction()) {
  15760. this.next();
  15761. this.next();
  15762. return this.parseFunction(expr, 1 | 4 | 8);
  15763. }
  15764. if (this.match(80)) {
  15765. return this.parseClass(expr, true, true);
  15766. }
  15767. if (this.match(26)) {
  15768. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15769. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15770. }
  15771. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  15772. }
  15773. if (this.match(75) || this.match(74) || this.isLet()) {
  15774. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  15775. }
  15776. const res = this.parseMaybeAssignAllowIn();
  15777. this.semicolon();
  15778. return res;
  15779. }
  15780. parseExportDeclaration(node) {
  15781. if (this.match(80)) {
  15782. const node = this.parseClass(this.startNode(), true, false);
  15783. return node;
  15784. }
  15785. return this.parseStatementListItem();
  15786. }
  15787. isExportDefaultSpecifier() {
  15788. const {
  15789. type
  15790. } = this.state;
  15791. if (tokenIsIdentifier(type)) {
  15792. if (type === 95 && !this.state.containsEsc || type === 100) {
  15793. return false;
  15794. }
  15795. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  15796. const {
  15797. type: nextType
  15798. } = this.lookahead();
  15799. if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
  15800. this.expectOnePlugin(["flow", "typescript"]);
  15801. return false;
  15802. }
  15803. }
  15804. } else if (!this.match(65)) {
  15805. return false;
  15806. }
  15807. const next = this.nextTokenStart();
  15808. const hasFrom = this.isUnparsedContextual(next, "from");
  15809. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  15810. return true;
  15811. }
  15812. if (this.match(65) && hasFrom) {
  15813. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  15814. return nextAfterFrom === 34 || nextAfterFrom === 39;
  15815. }
  15816. return false;
  15817. }
  15818. parseExportFrom(node, expect) {
  15819. if (this.eatContextual(98)) {
  15820. node.source = this.parseImportSource();
  15821. this.checkExport(node);
  15822. this.maybeParseImportAttributes(node);
  15823. this.checkJSONModuleImport(node);
  15824. } else if (expect) {
  15825. this.unexpected();
  15826. }
  15827. this.semicolon();
  15828. }
  15829. shouldParseExportDeclaration() {
  15830. const {
  15831. type
  15832. } = this.state;
  15833. if (type === 26) {
  15834. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15835. if (this.hasPlugin("decorators")) {
  15836. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15837. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15838. }
  15839. return true;
  15840. }
  15841. }
  15842. if (this.isContextual(107)) {
  15843. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15844. return true;
  15845. }
  15846. if (this.isContextual(96) && this.startsAwaitUsing()) {
  15847. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15848. return true;
  15849. }
  15850. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  15851. }
  15852. checkExport(node, checkNames, isDefault, isFrom) {
  15853. if (checkNames) {
  15854. var _node$specifiers;
  15855. if (isDefault) {
  15856. this.checkDuplicateExports(node, "default");
  15857. if (this.hasPlugin("exportDefaultFrom")) {
  15858. var _declaration$extra;
  15859. const declaration = node.declaration;
  15860. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  15861. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  15862. }
  15863. }
  15864. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  15865. for (const specifier of node.specifiers) {
  15866. const {
  15867. exported
  15868. } = specifier;
  15869. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  15870. this.checkDuplicateExports(specifier, exportName);
  15871. if (!isFrom && specifier.local) {
  15872. const {
  15873. local
  15874. } = specifier;
  15875. if (local.type !== "Identifier") {
  15876. this.raise(Errors.ExportBindingIsString, specifier, {
  15877. localName: local.value,
  15878. exportName
  15879. });
  15880. } else {
  15881. this.checkReservedWord(local.name, local.loc.start, true, false);
  15882. this.scope.checkLocalExport(local);
  15883. }
  15884. }
  15885. }
  15886. } else if (node.declaration) {
  15887. const decl = node.declaration;
  15888. if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
  15889. const {
  15890. id
  15891. } = decl;
  15892. if (!id) throw new Error("Assertion failure");
  15893. this.checkDuplicateExports(node, id.name);
  15894. } else if (decl.type === "VariableDeclaration") {
  15895. for (const declaration of decl.declarations) {
  15896. this.checkDeclaration(declaration.id);
  15897. }
  15898. }
  15899. }
  15900. }
  15901. }
  15902. checkDeclaration(node) {
  15903. if (node.type === "Identifier") {
  15904. this.checkDuplicateExports(node, node.name);
  15905. } else if (node.type === "ObjectPattern") {
  15906. for (const prop of node.properties) {
  15907. this.checkDeclaration(prop);
  15908. }
  15909. } else if (node.type === "ArrayPattern") {
  15910. for (const elem of node.elements) {
  15911. if (elem) {
  15912. this.checkDeclaration(elem);
  15913. }
  15914. }
  15915. } else if (node.type === "ObjectProperty") {
  15916. this.checkDeclaration(node.value);
  15917. } else if (node.type === "RestElement") {
  15918. this.checkDeclaration(node.argument);
  15919. } else if (node.type === "AssignmentPattern") {
  15920. this.checkDeclaration(node.left);
  15921. }
  15922. }
  15923. checkDuplicateExports(node, exportName) {
  15924. if (this.exportedIdentifiers.has(exportName)) {
  15925. if (exportName === "default") {
  15926. this.raise(Errors.DuplicateDefaultExport, node);
  15927. } else {
  15928. this.raise(Errors.DuplicateExport, node, {
  15929. exportName
  15930. });
  15931. }
  15932. }
  15933. this.exportedIdentifiers.add(exportName);
  15934. }
  15935. parseExportSpecifiers(isInTypeExport) {
  15936. const nodes = [];
  15937. let first = true;
  15938. this.expect(5);
  15939. while (!this.eat(8)) {
  15940. if (first) {
  15941. first = false;
  15942. } else {
  15943. this.expect(12);
  15944. if (this.eat(8)) break;
  15945. }
  15946. const isMaybeTypeOnly = this.isContextual(130);
  15947. const isString = this.match(133);
  15948. const node = this.startNode();
  15949. node.local = this.parseModuleExportName();
  15950. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  15951. }
  15952. return nodes;
  15953. }
  15954. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  15955. if (this.eatContextual(93)) {
  15956. node.exported = this.parseModuleExportName();
  15957. } else if (isString) {
  15958. node.exported = cloneStringLiteral(node.local);
  15959. } else if (!node.exported) {
  15960. node.exported = cloneIdentifier(node.local);
  15961. }
  15962. return this.finishNode(node, "ExportSpecifier");
  15963. }
  15964. parseModuleExportName() {
  15965. if (this.match(133)) {
  15966. const result = this.parseStringLiteral(this.state.value);
  15967. const surrogate = loneSurrogate.exec(result.value);
  15968. if (surrogate) {
  15969. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  15970. surrogateCharCode: surrogate[0].charCodeAt(0)
  15971. });
  15972. }
  15973. return result;
  15974. }
  15975. return this.parseIdentifier(true);
  15976. }
  15977. isJSONModuleImport(node) {
  15978. if (node.assertions != null) {
  15979. return node.assertions.some(({
  15980. key,
  15981. value
  15982. }) => {
  15983. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  15984. });
  15985. }
  15986. return false;
  15987. }
  15988. checkImportReflection(node) {
  15989. const {
  15990. specifiers
  15991. } = node;
  15992. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  15993. if (node.phase === "source") {
  15994. if (singleBindingType !== "ImportDefaultSpecifier") {
  15995. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  15996. }
  15997. } else if (node.phase === "defer") {
  15998. if (singleBindingType !== "ImportNamespaceSpecifier") {
  15999. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  16000. }
  16001. } else if (node.module) {
  16002. var _node$assertions;
  16003. if (singleBindingType !== "ImportDefaultSpecifier") {
  16004. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  16005. }
  16006. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  16007. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  16008. }
  16009. }
  16010. }
  16011. checkJSONModuleImport(node) {
  16012. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  16013. const {
  16014. specifiers
  16015. } = node;
  16016. if (specifiers != null) {
  16017. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  16018. let imported;
  16019. if (specifier.type === "ExportSpecifier") {
  16020. imported = specifier.local;
  16021. } else if (specifier.type === "ImportSpecifier") {
  16022. imported = specifier.imported;
  16023. }
  16024. if (imported !== undefined) {
  16025. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  16026. }
  16027. });
  16028. if (nonDefaultNamedSpecifier !== undefined) {
  16029. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  16030. }
  16031. }
  16032. }
  16033. }
  16034. isPotentialImportPhase(isExport) {
  16035. if (isExport) return false;
  16036. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  16037. }
  16038. applyImportPhase(node, isExport, phase, loc) {
  16039. if (isExport) {
  16040. return;
  16041. }
  16042. if (phase === "module") {
  16043. this.expectPlugin("importReflection", loc);
  16044. node.module = true;
  16045. } else if (this.hasPlugin("importReflection")) {
  16046. node.module = false;
  16047. }
  16048. if (phase === "source") {
  16049. this.expectPlugin("sourcePhaseImports", loc);
  16050. node.phase = "source";
  16051. } else if (phase === "defer") {
  16052. this.expectPlugin("deferredImportEvaluation", loc);
  16053. node.phase = "defer";
  16054. } else if (this.hasPlugin("sourcePhaseImports")) {
  16055. node.phase = null;
  16056. }
  16057. }
  16058. parseMaybeImportPhase(node, isExport) {
  16059. if (!this.isPotentialImportPhase(isExport)) {
  16060. this.applyImportPhase(node, isExport, null);
  16061. return null;
  16062. }
  16063. const phaseIdentifier = this.parseIdentifier(true);
  16064. const {
  16065. type
  16066. } = this.state;
  16067. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16068. if (isImportPhase) {
  16069. this.resetPreviousIdentifierLeadingComments(phaseIdentifier);
  16070. this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start);
  16071. return null;
  16072. } else {
  16073. this.applyImportPhase(node, isExport, null);
  16074. return phaseIdentifier;
  16075. }
  16076. }
  16077. isPrecedingIdImportPhase(phase) {
  16078. const {
  16079. type
  16080. } = this.state;
  16081. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16082. }
  16083. parseImport(node) {
  16084. if (this.match(133)) {
  16085. return this.parseImportSourceAndAttributes(node);
  16086. }
  16087. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16088. }
  16089. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16090. node.specifiers = [];
  16091. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16092. const parseNext = !hasDefault || this.eat(12);
  16093. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16094. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16095. this.expectContextual(98);
  16096. return this.parseImportSourceAndAttributes(node);
  16097. }
  16098. parseImportSourceAndAttributes(node) {
  16099. var _node$specifiers2;
  16100. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16101. node.source = this.parseImportSource();
  16102. this.maybeParseImportAttributes(node);
  16103. this.checkImportReflection(node);
  16104. this.checkJSONModuleImport(node);
  16105. this.semicolon();
  16106. return this.finishNode(node, "ImportDeclaration");
  16107. }
  16108. parseImportSource() {
  16109. if (!this.match(133)) this.unexpected();
  16110. return this.parseExprAtom();
  16111. }
  16112. parseImportSpecifierLocal(node, specifier, type) {
  16113. specifier.local = this.parseIdentifier();
  16114. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16115. }
  16116. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16117. this.checkLVal(specifier.local, {
  16118. type
  16119. }, bindingType);
  16120. return this.finishNode(specifier, type);
  16121. }
  16122. parseImportAttributes() {
  16123. this.expect(5);
  16124. const attrs = [];
  16125. const attrNames = new Set();
  16126. do {
  16127. if (this.match(8)) {
  16128. break;
  16129. }
  16130. const node = this.startNode();
  16131. const keyName = this.state.value;
  16132. if (attrNames.has(keyName)) {
  16133. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16134. key: keyName
  16135. });
  16136. }
  16137. attrNames.add(keyName);
  16138. if (this.match(133)) {
  16139. node.key = this.parseStringLiteral(keyName);
  16140. } else {
  16141. node.key = this.parseIdentifier(true);
  16142. }
  16143. this.expect(14);
  16144. if (!this.match(133)) {
  16145. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16146. }
  16147. node.value = this.parseStringLiteral(this.state.value);
  16148. attrs.push(this.finishNode(node, "ImportAttribute"));
  16149. } while (this.eat(12));
  16150. this.expect(8);
  16151. return attrs;
  16152. }
  16153. parseModuleAttributes() {
  16154. const attrs = [];
  16155. const attributes = new Set();
  16156. do {
  16157. const node = this.startNode();
  16158. node.key = this.parseIdentifier(true);
  16159. if (node.key.name !== "type") {
  16160. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16161. }
  16162. if (attributes.has(node.key.name)) {
  16163. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16164. key: node.key.name
  16165. });
  16166. }
  16167. attributes.add(node.key.name);
  16168. this.expect(14);
  16169. if (!this.match(133)) {
  16170. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16171. }
  16172. node.value = this.parseStringLiteral(this.state.value);
  16173. attrs.push(this.finishNode(node, "ImportAttribute"));
  16174. } while (this.eat(12));
  16175. return attrs;
  16176. }
  16177. maybeParseImportAttributes(node) {
  16178. let attributes;
  16179. let useWith = false;
  16180. if (this.match(76)) {
  16181. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16182. return;
  16183. }
  16184. this.next();
  16185. {
  16186. if (this.hasPlugin("moduleAttributes")) {
  16187. attributes = this.parseModuleAttributes();
  16188. } else {
  16189. this.expectImportAttributesPlugin();
  16190. attributes = this.parseImportAttributes();
  16191. }
  16192. }
  16193. useWith = true;
  16194. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16195. if (this.hasPlugin("importAttributes")) {
  16196. if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) {
  16197. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16198. }
  16199. this.addExtra(node, "deprecatedAssertSyntax", true);
  16200. } else {
  16201. this.expectOnePlugin(["importAttributes", "importAssertions"]);
  16202. }
  16203. this.next();
  16204. attributes = this.parseImportAttributes();
  16205. } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  16206. attributes = [];
  16207. } else {
  16208. if (this.hasPlugin("moduleAttributes")) {
  16209. attributes = [];
  16210. } else return;
  16211. }
  16212. if (!useWith && this.hasPlugin("importAssertions")) {
  16213. node.assertions = attributes;
  16214. } else {
  16215. node.attributes = attributes;
  16216. }
  16217. }
  16218. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16219. if (maybeDefaultIdentifier) {
  16220. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16221. specifier.local = maybeDefaultIdentifier;
  16222. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16223. return true;
  16224. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16225. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16226. return true;
  16227. }
  16228. return false;
  16229. }
  16230. maybeParseStarImportSpecifier(node) {
  16231. if (this.match(55)) {
  16232. const specifier = this.startNode();
  16233. this.next();
  16234. this.expectContextual(93);
  16235. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16236. return true;
  16237. }
  16238. return false;
  16239. }
  16240. parseNamedImportSpecifiers(node) {
  16241. let first = true;
  16242. this.expect(5);
  16243. while (!this.eat(8)) {
  16244. if (first) {
  16245. first = false;
  16246. } else {
  16247. if (this.eat(14)) {
  16248. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16249. }
  16250. this.expect(12);
  16251. if (this.eat(8)) break;
  16252. }
  16253. const specifier = this.startNode();
  16254. const importedIsString = this.match(133);
  16255. const isMaybeTypeOnly = this.isContextual(130);
  16256. specifier.imported = this.parseModuleExportName();
  16257. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16258. node.specifiers.push(importSpecifier);
  16259. }
  16260. }
  16261. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16262. if (this.eatContextual(93)) {
  16263. specifier.local = this.parseIdentifier();
  16264. } else {
  16265. const {
  16266. imported
  16267. } = specifier;
  16268. if (importedIsString) {
  16269. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16270. importName: imported.value
  16271. });
  16272. }
  16273. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16274. if (!specifier.local) {
  16275. specifier.local = cloneIdentifier(imported);
  16276. }
  16277. }
  16278. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16279. }
  16280. isThisParam(param) {
  16281. return param.type === "Identifier" && param.name === "this";
  16282. }
  16283. }
  16284. class Parser extends StatementParser {
  16285. constructor(options, input, pluginsMap) {
  16286. options = getOptions(options);
  16287. super(options, input);
  16288. this.options = options;
  16289. this.initializeScopes();
  16290. this.plugins = pluginsMap;
  16291. this.filename = options.sourceFilename;
  16292. }
  16293. getScopeHandler() {
  16294. return ScopeHandler;
  16295. }
  16296. parse() {
  16297. this.enterInitialScopes();
  16298. const file = this.startNode();
  16299. const program = this.startNode();
  16300. this.nextToken();
  16301. file.errors = null;
  16302. this.parseTopLevel(file, program);
  16303. file.errors = this.state.errors;
  16304. file.comments.length = this.state.commentsLen;
  16305. return file;
  16306. }
  16307. }
  16308. function parse(input, options) {
  16309. var _options;
  16310. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16311. options = Object.assign({}, options);
  16312. try {
  16313. options.sourceType = "module";
  16314. const parser = getParser(options, input);
  16315. const ast = parser.parse();
  16316. if (parser.sawUnambiguousESM) {
  16317. return ast;
  16318. }
  16319. if (parser.ambiguousScriptDifferentAst) {
  16320. try {
  16321. options.sourceType = "script";
  16322. return getParser(options, input).parse();
  16323. } catch (_unused) {}
  16324. } else {
  16325. ast.program.sourceType = "script";
  16326. }
  16327. return ast;
  16328. } catch (moduleError) {
  16329. try {
  16330. options.sourceType = "script";
  16331. return getParser(options, input).parse();
  16332. } catch (_unused2) {}
  16333. throw moduleError;
  16334. }
  16335. } else {
  16336. return getParser(options, input).parse();
  16337. }
  16338. }
  16339. function parseExpression(input, options) {
  16340. const parser = getParser(options, input);
  16341. if (parser.options.strictMode) {
  16342. parser.state.strict = true;
  16343. }
  16344. return parser.getExpression();
  16345. }
  16346. function generateExportedTokenTypes(internalTokenTypes) {
  16347. const tokenTypes = {};
  16348. for (const typeName of Object.keys(internalTokenTypes)) {
  16349. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16350. }
  16351. return tokenTypes;
  16352. }
  16353. const tokTypes = generateExportedTokenTypes(tt);
  16354. function getParser(options, input) {
  16355. let cls = Parser;
  16356. const pluginsMap = new Map();
  16357. if (options != null && options.plugins) {
  16358. for (const plugin of options.plugins) {
  16359. let name, opts;
  16360. if (typeof plugin === "string") {
  16361. name = plugin;
  16362. } else {
  16363. [name, opts] = plugin;
  16364. }
  16365. if (!pluginsMap.has(name)) {
  16366. pluginsMap.set(name, opts || {});
  16367. }
  16368. }
  16369. validatePlugins(pluginsMap);
  16370. cls = getParserClass(pluginsMap);
  16371. }
  16372. return new cls(options, input, pluginsMap);
  16373. }
  16374. const parserClassCache = new Map();
  16375. function getParserClass(pluginsMap) {
  16376. const pluginList = [];
  16377. for (const name of mixinPluginNames) {
  16378. if (pluginsMap.has(name)) {
  16379. pluginList.push(name);
  16380. }
  16381. }
  16382. const key = pluginList.join("|");
  16383. let cls = parserClassCache.get(key);
  16384. if (!cls) {
  16385. cls = Parser;
  16386. for (const plugin of pluginList) {
  16387. cls = mixinPlugins[plugin](cls);
  16388. }
  16389. parserClassCache.set(key, cls);
  16390. }
  16391. return cls;
  16392. }
  16393. lib.parse = parse;
  16394. lib.parseExpression = parseExpression;
  16395. lib.tokTypes = tokTypes;
  16396. return lib;
  16397. }
  16398. var libExports = /*@__PURE__*/ requireLib();
  16399. // @ts-check
  16400. /** @typedef { import('estree').BaseNode} BaseNode */
  16401. /** @typedef {{
  16402. skip: () => void;
  16403. remove: () => void;
  16404. replace: (node: BaseNode) => void;
  16405. }} WalkerContext */
  16406. class WalkerBase {
  16407. constructor() {
  16408. /** @type {boolean} */
  16409. this.should_skip = false;
  16410. /** @type {boolean} */
  16411. this.should_remove = false;
  16412. /** @type {BaseNode | null} */
  16413. this.replacement = null;
  16414. /** @type {WalkerContext} */
  16415. this.context = {
  16416. skip: () => (this.should_skip = true),
  16417. remove: () => (this.should_remove = true),
  16418. replace: (node) => (this.replacement = node)
  16419. };
  16420. }
  16421. /**
  16422. *
  16423. * @param {any} parent
  16424. * @param {string} prop
  16425. * @param {number} index
  16426. * @param {BaseNode} node
  16427. */
  16428. replace(parent, prop, index, node) {
  16429. if (parent) {
  16430. if (index !== null) {
  16431. parent[prop][index] = node;
  16432. } else {
  16433. parent[prop] = node;
  16434. }
  16435. }
  16436. }
  16437. /**
  16438. *
  16439. * @param {any} parent
  16440. * @param {string} prop
  16441. * @param {number} index
  16442. */
  16443. remove(parent, prop, index) {
  16444. if (parent) {
  16445. if (index !== null) {
  16446. parent[prop].splice(index, 1);
  16447. } else {
  16448. delete parent[prop];
  16449. }
  16450. }
  16451. }
  16452. }
  16453. // @ts-check
  16454. /** @typedef { import('estree').BaseNode} BaseNode */
  16455. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  16456. /** @typedef {(
  16457. * this: WalkerContext,
  16458. * node: BaseNode,
  16459. * parent: BaseNode,
  16460. * key: string,
  16461. * index: number
  16462. * ) => void} SyncHandler */
  16463. class SyncWalker extends WalkerBase {
  16464. /**
  16465. *
  16466. * @param {SyncHandler} enter
  16467. * @param {SyncHandler} leave
  16468. */
  16469. constructor(enter, leave) {
  16470. super();
  16471. /** @type {SyncHandler} */
  16472. this.enter = enter;
  16473. /** @type {SyncHandler} */
  16474. this.leave = leave;
  16475. }
  16476. /**
  16477. *
  16478. * @param {BaseNode} node
  16479. * @param {BaseNode} parent
  16480. * @param {string} [prop]
  16481. * @param {number} [index]
  16482. * @returns {BaseNode}
  16483. */
  16484. visit(node, parent, prop, index) {
  16485. if (node) {
  16486. if (this.enter) {
  16487. const _should_skip = this.should_skip;
  16488. const _should_remove = this.should_remove;
  16489. const _replacement = this.replacement;
  16490. this.should_skip = false;
  16491. this.should_remove = false;
  16492. this.replacement = null;
  16493. this.enter.call(this.context, node, parent, prop, index);
  16494. if (this.replacement) {
  16495. node = this.replacement;
  16496. this.replace(parent, prop, index, node);
  16497. }
  16498. if (this.should_remove) {
  16499. this.remove(parent, prop, index);
  16500. }
  16501. const skipped = this.should_skip;
  16502. const removed = this.should_remove;
  16503. this.should_skip = _should_skip;
  16504. this.should_remove = _should_remove;
  16505. this.replacement = _replacement;
  16506. if (skipped) return node;
  16507. if (removed) return null;
  16508. }
  16509. for (const key in node) {
  16510. const value = node[key];
  16511. if (typeof value !== "object") {
  16512. continue;
  16513. } else if (Array.isArray(value)) {
  16514. for (let i = 0; i < value.length; i += 1) {
  16515. if (value[i] !== null && typeof value[i].type === 'string') {
  16516. if (!this.visit(value[i], node, key, i)) {
  16517. // removed
  16518. i--;
  16519. }
  16520. }
  16521. }
  16522. } else if (value !== null && typeof value.type === "string") {
  16523. this.visit(value, node, key, null);
  16524. }
  16525. }
  16526. if (this.leave) {
  16527. const _replacement = this.replacement;
  16528. const _should_remove = this.should_remove;
  16529. this.replacement = null;
  16530. this.should_remove = false;
  16531. this.leave.call(this.context, node, parent, prop, index);
  16532. if (this.replacement) {
  16533. node = this.replacement;
  16534. this.replace(parent, prop, index, node);
  16535. }
  16536. if (this.should_remove) {
  16537. this.remove(parent, prop, index);
  16538. }
  16539. const removed = this.should_remove;
  16540. this.replacement = _replacement;
  16541. this.should_remove = _should_remove;
  16542. if (removed) return null;
  16543. }
  16544. }
  16545. return node;
  16546. }
  16547. }
  16548. // @ts-check
  16549. /** @typedef { import('estree').BaseNode} BaseNode */
  16550. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  16551. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  16552. /**
  16553. *
  16554. * @param {BaseNode} ast
  16555. * @param {{
  16556. * enter?: SyncHandler
  16557. * leave?: SyncHandler
  16558. * }} walker
  16559. * @returns {BaseNode}
  16560. */
  16561. function walk$2(ast, { enter, leave }) {
  16562. const instance = new SyncWalker(enter, leave);
  16563. return instance.visit(ast, null);
  16564. }
  16565. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  16566. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  16567. walk$2(root, {
  16568. enter(node, parent) {
  16569. parent && parentStack.push(parent);
  16570. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  16571. return this.skip();
  16572. }
  16573. if (node.type === "Identifier") {
  16574. const isLocal = !!knownIds[node.name];
  16575. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  16576. if (includeAll || isRefed && !isLocal) {
  16577. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  16578. }
  16579. } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
  16580. (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  16581. node.inPattern = true;
  16582. } else if (isFunctionType(node)) {
  16583. if (node.scopeIds) {
  16584. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16585. } else {
  16586. walkFunctionParams(
  16587. node,
  16588. (id) => markScopeIdentifier(node, id, knownIds)
  16589. );
  16590. }
  16591. } else if (node.type === "BlockStatement") {
  16592. if (node.scopeIds) {
  16593. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16594. } else {
  16595. walkBlockDeclarations(
  16596. node,
  16597. (id) => markScopeIdentifier(node, id, knownIds)
  16598. );
  16599. }
  16600. } else if (node.type === "CatchClause" && node.param) {
  16601. for (const id of extractIdentifiers$1(node.param)) {
  16602. markScopeIdentifier(node, id, knownIds);
  16603. }
  16604. } else if (isForStatement(node)) {
  16605. walkForStatement(
  16606. node,
  16607. false,
  16608. (id) => markScopeIdentifier(node, id, knownIds)
  16609. );
  16610. }
  16611. },
  16612. leave(node, parent) {
  16613. parent && parentStack.pop();
  16614. if (node !== rootExp && node.scopeIds) {
  16615. for (const id of node.scopeIds) {
  16616. knownIds[id]--;
  16617. if (knownIds[id] === 0) {
  16618. delete knownIds[id];
  16619. }
  16620. }
  16621. }
  16622. }
  16623. });
  16624. }
  16625. function isReferencedIdentifier(id, parent, parentStack) {
  16626. if (!parent) {
  16627. return true;
  16628. }
  16629. if (id.name === "arguments") {
  16630. return false;
  16631. }
  16632. if (isReferenced(id, parent)) {
  16633. return true;
  16634. }
  16635. switch (parent.type) {
  16636. case "AssignmentExpression":
  16637. case "AssignmentPattern":
  16638. return true;
  16639. case "ObjectPattern":
  16640. case "ArrayPattern":
  16641. return isInDestructureAssignment(parent, parentStack);
  16642. }
  16643. return false;
  16644. }
  16645. function isInDestructureAssignment(parent, parentStack) {
  16646. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  16647. let i = parentStack.length;
  16648. while (i--) {
  16649. const p = parentStack[i];
  16650. if (p.type === "AssignmentExpression") {
  16651. return true;
  16652. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  16653. break;
  16654. }
  16655. }
  16656. }
  16657. return false;
  16658. }
  16659. function isInNewExpression(parentStack) {
  16660. let i = parentStack.length;
  16661. while (i--) {
  16662. const p = parentStack[i];
  16663. if (p.type === "NewExpression") {
  16664. return true;
  16665. } else if (p.type !== "MemberExpression") {
  16666. break;
  16667. }
  16668. }
  16669. return false;
  16670. }
  16671. function walkFunctionParams(node, onIdent) {
  16672. for (const p of node.params) {
  16673. for (const id of extractIdentifiers$1(p)) {
  16674. onIdent(id);
  16675. }
  16676. }
  16677. }
  16678. function walkBlockDeclarations(block, onIdent) {
  16679. for (const stmt of block.body) {
  16680. if (stmt.type === "VariableDeclaration") {
  16681. if (stmt.declare) continue;
  16682. for (const decl of stmt.declarations) {
  16683. for (const id of extractIdentifiers$1(decl.id)) {
  16684. onIdent(id);
  16685. }
  16686. }
  16687. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  16688. if (stmt.declare || !stmt.id) continue;
  16689. onIdent(stmt.id);
  16690. } else if (isForStatement(stmt)) {
  16691. walkForStatement(stmt, true, onIdent);
  16692. }
  16693. }
  16694. }
  16695. function isForStatement(stmt) {
  16696. return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
  16697. }
  16698. function walkForStatement(stmt, isVar, onIdent) {
  16699. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  16700. if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
  16701. for (const decl of variable.declarations) {
  16702. for (const id of extractIdentifiers$1(decl.id)) {
  16703. onIdent(id);
  16704. }
  16705. }
  16706. }
  16707. }
  16708. function extractIdentifiers$1(param, nodes = []) {
  16709. switch (param.type) {
  16710. case "Identifier":
  16711. nodes.push(param);
  16712. break;
  16713. case "MemberExpression":
  16714. let object = param;
  16715. while (object.type === "MemberExpression") {
  16716. object = object.object;
  16717. }
  16718. nodes.push(object);
  16719. break;
  16720. case "ObjectPattern":
  16721. for (const prop of param.properties) {
  16722. if (prop.type === "RestElement") {
  16723. extractIdentifiers$1(prop.argument, nodes);
  16724. } else {
  16725. extractIdentifiers$1(prop.value, nodes);
  16726. }
  16727. }
  16728. break;
  16729. case "ArrayPattern":
  16730. param.elements.forEach((element) => {
  16731. if (element) extractIdentifiers$1(element, nodes);
  16732. });
  16733. break;
  16734. case "RestElement":
  16735. extractIdentifiers$1(param.argument, nodes);
  16736. break;
  16737. case "AssignmentPattern":
  16738. extractIdentifiers$1(param.left, nodes);
  16739. break;
  16740. }
  16741. return nodes;
  16742. }
  16743. function markKnownIds(name, knownIds) {
  16744. if (name in knownIds) {
  16745. knownIds[name]++;
  16746. } else {
  16747. knownIds[name] = 1;
  16748. }
  16749. }
  16750. function markScopeIdentifier(node, child, knownIds) {
  16751. const { name } = child;
  16752. if (node.scopeIds && node.scopeIds.has(name)) {
  16753. return;
  16754. }
  16755. markKnownIds(name, knownIds);
  16756. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  16757. }
  16758. const isFunctionType = (node) => {
  16759. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  16760. };
  16761. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  16762. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  16763. function isReferenced(node, parent, grandparent) {
  16764. switch (parent.type) {
  16765. // yes: PARENT[NODE]
  16766. // yes: NODE.child
  16767. // no: parent.NODE
  16768. case "MemberExpression":
  16769. case "OptionalMemberExpression":
  16770. if (parent.property === node) {
  16771. return !!parent.computed;
  16772. }
  16773. return parent.object === node;
  16774. case "JSXMemberExpression":
  16775. return parent.object === node;
  16776. // no: let NODE = init;
  16777. // yes: let id = NODE;
  16778. case "VariableDeclarator":
  16779. return parent.init === node;
  16780. // yes: () => NODE
  16781. // no: (NODE) => {}
  16782. case "ArrowFunctionExpression":
  16783. return parent.body === node;
  16784. // no: class { #NODE; }
  16785. // no: class { get #NODE() {} }
  16786. // no: class { #NODE() {} }
  16787. // no: class { fn() { return this.#NODE; } }
  16788. case "PrivateName":
  16789. return false;
  16790. // no: class { NODE() {} }
  16791. // yes: class { [NODE]() {} }
  16792. // no: class { foo(NODE) {} }
  16793. case "ClassMethod":
  16794. case "ClassPrivateMethod":
  16795. case "ObjectMethod":
  16796. if (parent.key === node) {
  16797. return !!parent.computed;
  16798. }
  16799. return false;
  16800. // yes: { [NODE]: "" }
  16801. // no: { NODE: "" }
  16802. // depends: { NODE }
  16803. // depends: { key: NODE }
  16804. case "ObjectProperty":
  16805. if (parent.key === node) {
  16806. return !!parent.computed;
  16807. }
  16808. return !grandparent;
  16809. // no: class { NODE = value; }
  16810. // yes: class { [NODE] = value; }
  16811. // yes: class { key = NODE; }
  16812. case "ClassProperty":
  16813. if (parent.key === node) {
  16814. return !!parent.computed;
  16815. }
  16816. return true;
  16817. case "ClassPrivateProperty":
  16818. return parent.key !== node;
  16819. // no: class NODE {}
  16820. // yes: class Foo extends NODE {}
  16821. case "ClassDeclaration":
  16822. case "ClassExpression":
  16823. return parent.superClass === node;
  16824. // yes: left = NODE;
  16825. // no: NODE = right;
  16826. case "AssignmentExpression":
  16827. return parent.right === node;
  16828. // no: [NODE = foo] = [];
  16829. // yes: [foo = NODE] = [];
  16830. case "AssignmentPattern":
  16831. return parent.right === node;
  16832. // no: NODE: for (;;) {}
  16833. case "LabeledStatement":
  16834. return false;
  16835. // no: try {} catch (NODE) {}
  16836. case "CatchClause":
  16837. return false;
  16838. // no: function foo(...NODE) {}
  16839. case "RestElement":
  16840. return false;
  16841. case "BreakStatement":
  16842. case "ContinueStatement":
  16843. return false;
  16844. // no: function NODE() {}
  16845. // no: function foo(NODE) {}
  16846. case "FunctionDeclaration":
  16847. case "FunctionExpression":
  16848. return false;
  16849. // no: export NODE from "foo";
  16850. // no: export * as NODE from "foo";
  16851. case "ExportNamespaceSpecifier":
  16852. case "ExportDefaultSpecifier":
  16853. return false;
  16854. // no: export { foo as NODE };
  16855. // yes: export { NODE as foo };
  16856. // no: export { NODE as foo } from "foo";
  16857. case "ExportSpecifier":
  16858. return parent.local === node;
  16859. // no: import NODE from "foo";
  16860. // no: import * as NODE from "foo";
  16861. // no: import { NODE as foo } from "foo";
  16862. // no: import { foo as NODE } from "foo";
  16863. // no: import NODE from "bar";
  16864. case "ImportDefaultSpecifier":
  16865. case "ImportNamespaceSpecifier":
  16866. case "ImportSpecifier":
  16867. return false;
  16868. // no: import "foo" assert { NODE: "json" }
  16869. case "ImportAttribute":
  16870. return false;
  16871. // no: <div NODE="foo" />
  16872. case "JSXAttribute":
  16873. return false;
  16874. // no: [NODE] = [];
  16875. // no: ({ NODE }) = [];
  16876. case "ObjectPattern":
  16877. case "ArrayPattern":
  16878. return false;
  16879. // no: new.NODE
  16880. // no: NODE.target
  16881. case "MetaProperty":
  16882. return false;
  16883. // yes: type X = { someProperty: NODE }
  16884. // no: type X = { NODE: OtherType }
  16885. case "ObjectTypeProperty":
  16886. return parent.key !== node;
  16887. // yes: enum X { Foo = NODE }
  16888. // no: enum X { NODE }
  16889. case "TSEnumMember":
  16890. return parent.id !== node;
  16891. // yes: { [NODE]: value }
  16892. // no: { NODE: value }
  16893. case "TSPropertySignature":
  16894. if (parent.key === node) {
  16895. return !!parent.computed;
  16896. }
  16897. return true;
  16898. }
  16899. return true;
  16900. }
  16901. const TS_NODE_TYPES = [
  16902. "TSAsExpression",
  16903. // foo as number
  16904. "TSTypeAssertion",
  16905. // (<number>foo)
  16906. "TSNonNullExpression",
  16907. // foo!
  16908. "TSInstantiationExpression",
  16909. // foo<string>
  16910. "TSSatisfiesExpression"
  16911. // foo satisfies T
  16912. ];
  16913. function unwrapTSNode(node) {
  16914. if (TS_NODE_TYPES.includes(node.type)) {
  16915. return unwrapTSNode(node.expression);
  16916. } else {
  16917. return node;
  16918. }
  16919. }
  16920. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  16921. function isCoreComponent(tag) {
  16922. switch (tag) {
  16923. case "Teleport":
  16924. case "teleport":
  16925. return TELEPORT;
  16926. case "Suspense":
  16927. case "suspense":
  16928. return SUSPENSE;
  16929. case "KeepAlive":
  16930. case "keep-alive":
  16931. return KEEP_ALIVE;
  16932. case "BaseTransition":
  16933. case "base-transition":
  16934. return BASE_TRANSITION;
  16935. }
  16936. }
  16937. const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
  16938. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  16939. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  16940. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  16941. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  16942. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  16943. const isMemberExpressionBrowser = (exp) => {
  16944. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  16945. let state = 0 /* inMemberExp */;
  16946. let stateStack = [];
  16947. let currentOpenBracketCount = 0;
  16948. let currentOpenParensCount = 0;
  16949. let currentStringType = null;
  16950. for (let i = 0; i < path.length; i++) {
  16951. const char = path.charAt(i);
  16952. switch (state) {
  16953. case 0 /* inMemberExp */:
  16954. if (char === "[") {
  16955. stateStack.push(state);
  16956. state = 1 /* inBrackets */;
  16957. currentOpenBracketCount++;
  16958. } else if (char === "(") {
  16959. stateStack.push(state);
  16960. state = 2 /* inParens */;
  16961. currentOpenParensCount++;
  16962. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  16963. return false;
  16964. }
  16965. break;
  16966. case 1 /* inBrackets */:
  16967. if (char === `'` || char === `"` || char === "`") {
  16968. stateStack.push(state);
  16969. state = 3 /* inString */;
  16970. currentStringType = char;
  16971. } else if (char === `[`) {
  16972. currentOpenBracketCount++;
  16973. } else if (char === `]`) {
  16974. if (!--currentOpenBracketCount) {
  16975. state = stateStack.pop();
  16976. }
  16977. }
  16978. break;
  16979. case 2 /* inParens */:
  16980. if (char === `'` || char === `"` || char === "`") {
  16981. stateStack.push(state);
  16982. state = 3 /* inString */;
  16983. currentStringType = char;
  16984. } else if (char === `(`) {
  16985. currentOpenParensCount++;
  16986. } else if (char === `)`) {
  16987. if (i === path.length - 1) {
  16988. return false;
  16989. }
  16990. if (!--currentOpenParensCount) {
  16991. state = stateStack.pop();
  16992. }
  16993. }
  16994. break;
  16995. case 3 /* inString */:
  16996. if (char === currentStringType) {
  16997. state = stateStack.pop();
  16998. currentStringType = null;
  16999. }
  17000. break;
  17001. }
  17002. }
  17003. return !currentOpenBracketCount && !currentOpenParensCount;
  17004. };
  17005. const isMemberExpressionNode = (exp, context) => {
  17006. try {
  17007. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17008. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17009. });
  17010. ret = unwrapTSNode(ret);
  17011. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  17012. } catch (e) {
  17013. return false;
  17014. }
  17015. };
  17016. const isMemberExpression = isMemberExpressionNode;
  17017. const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  17018. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  17019. const isFnExpressionNode = (exp, context) => {
  17020. try {
  17021. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17022. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17023. });
  17024. if (ret.type === "Program") {
  17025. ret = ret.body[0];
  17026. if (ret.type === "ExpressionStatement") {
  17027. ret = ret.expression;
  17028. }
  17029. }
  17030. ret = unwrapTSNode(ret);
  17031. return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
  17032. } catch (e) {
  17033. return false;
  17034. }
  17035. };
  17036. const isFnExpression = isFnExpressionNode;
  17037. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  17038. return advancePositionWithMutation(
  17039. {
  17040. offset: pos.offset,
  17041. line: pos.line,
  17042. column: pos.column
  17043. },
  17044. source,
  17045. numberOfCharacters
  17046. );
  17047. }
  17048. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  17049. let linesCount = 0;
  17050. let lastNewLinePos = -1;
  17051. for (let i = 0; i < numberOfCharacters; i++) {
  17052. if (source.charCodeAt(i) === 10) {
  17053. linesCount++;
  17054. lastNewLinePos = i;
  17055. }
  17056. }
  17057. pos.offset += numberOfCharacters;
  17058. pos.line += linesCount;
  17059. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  17060. return pos;
  17061. }
  17062. function assert(condition, msg) {
  17063. if (!condition) {
  17064. throw new Error(msg || `unexpected compiler condition`);
  17065. }
  17066. }
  17067. function findDir(node, name, allowEmpty = false) {
  17068. for (let i = 0; i < node.props.length; i++) {
  17069. const p = node.props[i];
  17070. if (p.type === 7 && (allowEmpty || p.exp) && (isString$1(name) ? p.name === name : name.test(p.name))) {
  17071. return p;
  17072. }
  17073. }
  17074. }
  17075. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  17076. for (let i = 0; i < node.props.length; i++) {
  17077. const p = node.props[i];
  17078. if (p.type === 6) {
  17079. if (dynamicOnly) continue;
  17080. if (p.name === name && (p.value || allowEmpty)) {
  17081. return p;
  17082. }
  17083. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  17084. return p;
  17085. }
  17086. }
  17087. }
  17088. function isStaticArgOf(arg, name) {
  17089. return !!(arg && isStaticExp(arg) && arg.content === name);
  17090. }
  17091. function hasDynamicKeyVBind(node) {
  17092. return node.props.some(
  17093. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  17094. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  17095. !p.arg.isStatic)
  17096. // v-bind:[foo]
  17097. );
  17098. }
  17099. function isText$1(node) {
  17100. return node.type === 5 || node.type === 2;
  17101. }
  17102. function isVSlot(p) {
  17103. return p.type === 7 && p.name === "slot";
  17104. }
  17105. function isTemplateNode(node) {
  17106. return node.type === 1 && node.tagType === 3;
  17107. }
  17108. function isSlotOutlet(node) {
  17109. return node.type === 1 && node.tagType === 2;
  17110. }
  17111. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  17112. function getUnnormalizedProps(props, callPath = []) {
  17113. if (props && !isString$1(props) && props.type === 14) {
  17114. const callee = props.callee;
  17115. if (!isString$1(callee) && propsHelperSet.has(callee)) {
  17116. return getUnnormalizedProps(
  17117. props.arguments[0],
  17118. callPath.concat(props)
  17119. );
  17120. }
  17121. }
  17122. return [props, callPath];
  17123. }
  17124. function injectProp(node, prop, context) {
  17125. let propsWithInjection;
  17126. let props = node.type === 13 ? node.props : node.arguments[2];
  17127. let callPath = [];
  17128. let parentCall;
  17129. if (props && !isString$1(props) && props.type === 14) {
  17130. const ret = getUnnormalizedProps(props);
  17131. props = ret[0];
  17132. callPath = ret[1];
  17133. parentCall = callPath[callPath.length - 1];
  17134. }
  17135. if (props == null || isString$1(props)) {
  17136. propsWithInjection = createObjectExpression([prop]);
  17137. } else if (props.type === 14) {
  17138. const first = props.arguments[0];
  17139. if (!isString$1(first) && first.type === 15) {
  17140. if (!hasProp(prop, first)) {
  17141. first.properties.unshift(prop);
  17142. }
  17143. } else {
  17144. if (props.callee === TO_HANDLERS) {
  17145. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17146. createObjectExpression([prop]),
  17147. props
  17148. ]);
  17149. } else {
  17150. props.arguments.unshift(createObjectExpression([prop]));
  17151. }
  17152. }
  17153. !propsWithInjection && (propsWithInjection = props);
  17154. } else if (props.type === 15) {
  17155. if (!hasProp(prop, props)) {
  17156. props.properties.unshift(prop);
  17157. }
  17158. propsWithInjection = props;
  17159. } else {
  17160. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17161. createObjectExpression([prop]),
  17162. props
  17163. ]);
  17164. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17165. parentCall = callPath[callPath.length - 2];
  17166. }
  17167. }
  17168. if (node.type === 13) {
  17169. if (parentCall) {
  17170. parentCall.arguments[0] = propsWithInjection;
  17171. } else {
  17172. node.props = propsWithInjection;
  17173. }
  17174. } else {
  17175. if (parentCall) {
  17176. parentCall.arguments[0] = propsWithInjection;
  17177. } else {
  17178. node.arguments[2] = propsWithInjection;
  17179. }
  17180. }
  17181. }
  17182. function hasProp(prop, props) {
  17183. let result = false;
  17184. if (prop.key.type === 4) {
  17185. const propKeyName = prop.key.content;
  17186. result = props.properties.some(
  17187. (p) => p.key.type === 4 && p.key.content === propKeyName
  17188. );
  17189. }
  17190. return result;
  17191. }
  17192. function toValidAssetId(name, type) {
  17193. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17194. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17195. })}`;
  17196. }
  17197. function hasScopeRef(node, ids) {
  17198. if (!node || Object.keys(ids).length === 0) {
  17199. return false;
  17200. }
  17201. switch (node.type) {
  17202. case 1:
  17203. for (let i = 0; i < node.props.length; i++) {
  17204. const p = node.props[i];
  17205. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17206. return true;
  17207. }
  17208. }
  17209. return node.children.some((c) => hasScopeRef(c, ids));
  17210. case 11:
  17211. if (hasScopeRef(node.source, ids)) {
  17212. return true;
  17213. }
  17214. return node.children.some((c) => hasScopeRef(c, ids));
  17215. case 9:
  17216. return node.branches.some((b) => hasScopeRef(b, ids));
  17217. case 10:
  17218. if (hasScopeRef(node.condition, ids)) {
  17219. return true;
  17220. }
  17221. return node.children.some((c) => hasScopeRef(c, ids));
  17222. case 4:
  17223. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17224. case 8:
  17225. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17226. case 5:
  17227. case 12:
  17228. return hasScopeRef(node.content, ids);
  17229. case 2:
  17230. case 3:
  17231. case 20:
  17232. return false;
  17233. default:
  17234. return false;
  17235. }
  17236. }
  17237. function getMemoedVNodeCall(node) {
  17238. if (node.type === 14 && node.callee === WITH_MEMO) {
  17239. return node.arguments[1].returns;
  17240. } else {
  17241. return node;
  17242. }
  17243. }
  17244. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  17245. const defaultParserOptions = {
  17246. parseMode: "base",
  17247. ns: 0,
  17248. delimiters: [`{{`, `}}`],
  17249. getNamespace: () => 0,
  17250. isVoidTag: NO,
  17251. isPreTag: NO,
  17252. isIgnoreNewlineTag: NO,
  17253. isCustomElement: NO,
  17254. onError: defaultOnError,
  17255. onWarn: defaultOnWarn,
  17256. comments: true,
  17257. prefixIdentifiers: false
  17258. };
  17259. let currentOptions = defaultParserOptions;
  17260. let currentRoot = null;
  17261. let currentInput = "";
  17262. let currentOpenTag = null;
  17263. let currentProp = null;
  17264. let currentAttrValue = "";
  17265. let currentAttrStartIndex = -1;
  17266. let currentAttrEndIndex = -1;
  17267. let inPre = 0;
  17268. let inVPre = false;
  17269. let currentVPreBoundary = null;
  17270. const stack = [];
  17271. const tokenizer = new Tokenizer(stack, {
  17272. onerr: emitError,
  17273. ontext(start, end) {
  17274. onText(getSlice(start, end), start, end);
  17275. },
  17276. ontextentity(char, start, end) {
  17277. onText(char, start, end);
  17278. },
  17279. oninterpolation(start, end) {
  17280. if (inVPre) {
  17281. return onText(getSlice(start, end), start, end);
  17282. }
  17283. let innerStart = start + tokenizer.delimiterOpen.length;
  17284. let innerEnd = end - tokenizer.delimiterClose.length;
  17285. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  17286. innerStart++;
  17287. }
  17288. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  17289. innerEnd--;
  17290. }
  17291. let exp = getSlice(innerStart, innerEnd);
  17292. if (exp.includes("&")) {
  17293. {
  17294. exp = decodeHTML(exp);
  17295. }
  17296. }
  17297. addNode({
  17298. type: 5,
  17299. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17300. loc: getLoc(start, end)
  17301. });
  17302. },
  17303. onopentagname(start, end) {
  17304. const name = getSlice(start, end);
  17305. currentOpenTag = {
  17306. type: 1,
  17307. tag: name,
  17308. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17309. tagType: 0,
  17310. // will be refined on tag close
  17311. props: [],
  17312. children: [],
  17313. loc: getLoc(start - 1, end),
  17314. codegenNode: void 0
  17315. };
  17316. },
  17317. onopentagend(end) {
  17318. endOpenTag(end);
  17319. },
  17320. onclosetag(start, end) {
  17321. const name = getSlice(start, end);
  17322. if (!currentOptions.isVoidTag(name)) {
  17323. let found = false;
  17324. for (let i = 0; i < stack.length; i++) {
  17325. const e = stack[i];
  17326. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17327. found = true;
  17328. if (i > 0) {
  17329. emitError(24, stack[0].loc.start.offset);
  17330. }
  17331. for (let j = 0; j <= i; j++) {
  17332. const el = stack.shift();
  17333. onCloseTag(el, end, j < i);
  17334. }
  17335. break;
  17336. }
  17337. }
  17338. if (!found) {
  17339. emitError(23, backTrack(start, 60));
  17340. }
  17341. }
  17342. },
  17343. onselfclosingtag(end) {
  17344. const name = currentOpenTag.tag;
  17345. currentOpenTag.isSelfClosing = true;
  17346. endOpenTag(end);
  17347. if (stack[0] && stack[0].tag === name) {
  17348. onCloseTag(stack.shift(), end);
  17349. }
  17350. },
  17351. onattribname(start, end) {
  17352. currentProp = {
  17353. type: 6,
  17354. name: getSlice(start, end),
  17355. nameLoc: getLoc(start, end),
  17356. value: void 0,
  17357. loc: getLoc(start)
  17358. };
  17359. },
  17360. ondirname(start, end) {
  17361. const raw = getSlice(start, end);
  17362. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  17363. if (!inVPre && name === "") {
  17364. emitError(26, start);
  17365. }
  17366. if (inVPre || name === "") {
  17367. currentProp = {
  17368. type: 6,
  17369. name: raw,
  17370. nameLoc: getLoc(start, end),
  17371. value: void 0,
  17372. loc: getLoc(start)
  17373. };
  17374. } else {
  17375. currentProp = {
  17376. type: 7,
  17377. name,
  17378. rawName: raw,
  17379. exp: void 0,
  17380. arg: void 0,
  17381. modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
  17382. loc: getLoc(start)
  17383. };
  17384. if (name === "pre") {
  17385. inVPre = tokenizer.inVPre = true;
  17386. currentVPreBoundary = currentOpenTag;
  17387. const props = currentOpenTag.props;
  17388. for (let i = 0; i < props.length; i++) {
  17389. if (props[i].type === 7) {
  17390. props[i] = dirToAttr(props[i]);
  17391. }
  17392. }
  17393. }
  17394. }
  17395. },
  17396. ondirarg(start, end) {
  17397. if (start === end) return;
  17398. const arg = getSlice(start, end);
  17399. if (inVPre) {
  17400. currentProp.name += arg;
  17401. setLocEnd(currentProp.nameLoc, end);
  17402. } else {
  17403. const isStatic = arg[0] !== `[`;
  17404. currentProp.arg = createExp(
  17405. isStatic ? arg : arg.slice(1, -1),
  17406. isStatic,
  17407. getLoc(start, end),
  17408. isStatic ? 3 : 0
  17409. );
  17410. }
  17411. },
  17412. ondirmodifier(start, end) {
  17413. const mod = getSlice(start, end);
  17414. if (inVPre) {
  17415. currentProp.name += "." + mod;
  17416. setLocEnd(currentProp.nameLoc, end);
  17417. } else if (currentProp.name === "slot") {
  17418. const arg = currentProp.arg;
  17419. if (arg) {
  17420. arg.content += "." + mod;
  17421. setLocEnd(arg.loc, end);
  17422. }
  17423. } else {
  17424. const exp = createSimpleExpression(mod, true, getLoc(start, end));
  17425. currentProp.modifiers.push(exp);
  17426. }
  17427. },
  17428. onattribdata(start, end) {
  17429. currentAttrValue += getSlice(start, end);
  17430. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17431. currentAttrEndIndex = end;
  17432. },
  17433. onattribentity(char, start, end) {
  17434. currentAttrValue += char;
  17435. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17436. currentAttrEndIndex = end;
  17437. },
  17438. onattribnameend(end) {
  17439. const start = currentProp.loc.start.offset;
  17440. const name = getSlice(start, end);
  17441. if (currentProp.type === 7) {
  17442. currentProp.rawName = name;
  17443. }
  17444. if (currentOpenTag.props.some(
  17445. (p) => (p.type === 7 ? p.rawName : p.name) === name
  17446. )) {
  17447. emitError(2, start);
  17448. }
  17449. },
  17450. onattribend(quote, end) {
  17451. if (currentOpenTag && currentProp) {
  17452. setLocEnd(currentProp.loc, end);
  17453. if (quote !== 0) {
  17454. if (currentProp.type === 6) {
  17455. if (currentProp.name === "class") {
  17456. currentAttrValue = condense(currentAttrValue).trim();
  17457. }
  17458. if (quote === 1 && !currentAttrValue) {
  17459. emitError(13, end);
  17460. }
  17461. currentProp.value = {
  17462. type: 2,
  17463. content: currentAttrValue,
  17464. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  17465. };
  17466. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  17467. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  17468. }
  17469. } else {
  17470. let expParseMode = 0 /* Normal */;
  17471. {
  17472. if (currentProp.name === "for") {
  17473. expParseMode = 3 /* Skip */;
  17474. } else if (currentProp.name === "slot") {
  17475. expParseMode = 1 /* Params */;
  17476. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  17477. expParseMode = 2 /* Statements */;
  17478. }
  17479. }
  17480. currentProp.exp = createExp(
  17481. currentAttrValue,
  17482. false,
  17483. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  17484. 0,
  17485. expParseMode
  17486. );
  17487. if (currentProp.name === "for") {
  17488. currentProp.forParseResult = parseForExpression(currentProp.exp);
  17489. }
  17490. }
  17491. }
  17492. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  17493. currentOpenTag.props.push(currentProp);
  17494. }
  17495. }
  17496. currentAttrValue = "";
  17497. currentAttrStartIndex = currentAttrEndIndex = -1;
  17498. },
  17499. oncomment(start, end) {
  17500. if (currentOptions.comments) {
  17501. addNode({
  17502. type: 3,
  17503. content: getSlice(start, end),
  17504. loc: getLoc(start - 4, end + 3)
  17505. });
  17506. }
  17507. },
  17508. onend() {
  17509. const end = currentInput.length;
  17510. if (tokenizer.state !== 1) {
  17511. switch (tokenizer.state) {
  17512. case 5:
  17513. case 8:
  17514. emitError(5, end);
  17515. break;
  17516. case 3:
  17517. case 4:
  17518. emitError(
  17519. 25,
  17520. tokenizer.sectionStart
  17521. );
  17522. break;
  17523. case 28:
  17524. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  17525. emitError(6, end);
  17526. } else {
  17527. emitError(7, end);
  17528. }
  17529. break;
  17530. case 6:
  17531. case 7:
  17532. case 9:
  17533. case 11:
  17534. case 12:
  17535. case 13:
  17536. case 14:
  17537. case 15:
  17538. case 16:
  17539. case 17:
  17540. case 18:
  17541. case 19:
  17542. // "
  17543. case 20:
  17544. // '
  17545. case 21:
  17546. emitError(9, end);
  17547. break;
  17548. }
  17549. }
  17550. for (let index = 0; index < stack.length; index++) {
  17551. onCloseTag(stack[index], end - 1);
  17552. emitError(24, stack[index].loc.start.offset);
  17553. }
  17554. },
  17555. oncdata(start, end) {
  17556. if (stack[0].ns !== 0) {
  17557. onText(getSlice(start, end), start, end);
  17558. } else {
  17559. emitError(1, start - 9);
  17560. }
  17561. },
  17562. onprocessinginstruction(start) {
  17563. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17564. emitError(
  17565. 21,
  17566. start - 1
  17567. );
  17568. }
  17569. }
  17570. });
  17571. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  17572. const stripParensRE = /^\(|\)$/g;
  17573. function parseForExpression(input) {
  17574. const loc = input.loc;
  17575. const exp = input.content;
  17576. const inMatch = exp.match(forAliasRE);
  17577. if (!inMatch) return;
  17578. const [, LHS, RHS] = inMatch;
  17579. const createAliasExpression = (content, offset, asParam = false) => {
  17580. const start = loc.start.offset + offset;
  17581. const end = start + content.length;
  17582. return createExp(
  17583. content,
  17584. false,
  17585. getLoc(start, end),
  17586. 0,
  17587. asParam ? 1 /* Params */ : 0 /* Normal */
  17588. );
  17589. };
  17590. const result = {
  17591. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  17592. value: void 0,
  17593. key: void 0,
  17594. index: void 0,
  17595. finalized: false
  17596. };
  17597. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  17598. const trimmedOffset = LHS.indexOf(valueContent);
  17599. const iteratorMatch = valueContent.match(forIteratorRE);
  17600. if (iteratorMatch) {
  17601. valueContent = valueContent.replace(forIteratorRE, "").trim();
  17602. const keyContent = iteratorMatch[1].trim();
  17603. let keyOffset;
  17604. if (keyContent) {
  17605. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  17606. result.key = createAliasExpression(keyContent, keyOffset, true);
  17607. }
  17608. if (iteratorMatch[2]) {
  17609. const indexContent = iteratorMatch[2].trim();
  17610. if (indexContent) {
  17611. result.index = createAliasExpression(
  17612. indexContent,
  17613. exp.indexOf(
  17614. indexContent,
  17615. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  17616. ),
  17617. true
  17618. );
  17619. }
  17620. }
  17621. }
  17622. if (valueContent) {
  17623. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  17624. }
  17625. return result;
  17626. }
  17627. function getSlice(start, end) {
  17628. return currentInput.slice(start, end);
  17629. }
  17630. function endOpenTag(end) {
  17631. if (tokenizer.inSFCRoot) {
  17632. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  17633. }
  17634. addNode(currentOpenTag);
  17635. const { tag, ns } = currentOpenTag;
  17636. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17637. inPre++;
  17638. }
  17639. if (currentOptions.isVoidTag(tag)) {
  17640. onCloseTag(currentOpenTag, end);
  17641. } else {
  17642. stack.unshift(currentOpenTag);
  17643. if (ns === 1 || ns === 2) {
  17644. tokenizer.inXML = true;
  17645. }
  17646. }
  17647. currentOpenTag = null;
  17648. }
  17649. function onText(content, start, end) {
  17650. const parent = stack[0] || currentRoot;
  17651. const lastNode = parent.children[parent.children.length - 1];
  17652. if (lastNode && lastNode.type === 2) {
  17653. lastNode.content += content;
  17654. setLocEnd(lastNode.loc, end);
  17655. } else {
  17656. parent.children.push({
  17657. type: 2,
  17658. content,
  17659. loc: getLoc(start, end)
  17660. });
  17661. }
  17662. }
  17663. function onCloseTag(el, end, isImplied = false) {
  17664. if (isImplied) {
  17665. setLocEnd(el.loc, backTrack(end, 60));
  17666. } else {
  17667. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  17668. }
  17669. if (tokenizer.inSFCRoot) {
  17670. if (el.children.length) {
  17671. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  17672. } else {
  17673. el.innerLoc.end = extend({}, el.innerLoc.start);
  17674. }
  17675. el.innerLoc.source = getSlice(
  17676. el.innerLoc.start.offset,
  17677. el.innerLoc.end.offset
  17678. );
  17679. }
  17680. const { tag, ns, children } = el;
  17681. if (!inVPre) {
  17682. if (tag === "slot") {
  17683. el.tagType = 2;
  17684. } else if (isFragmentTemplate(el)) {
  17685. el.tagType = 3;
  17686. } else if (isComponent(el)) {
  17687. el.tagType = 1;
  17688. }
  17689. }
  17690. if (!tokenizer.inRCDATA) {
  17691. el.children = condenseWhitespace(children);
  17692. }
  17693. if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
  17694. const first = children[0];
  17695. if (first && first.type === 2) {
  17696. first.content = first.content.replace(/^\r?\n/, "");
  17697. }
  17698. }
  17699. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17700. inPre--;
  17701. }
  17702. if (currentVPreBoundary === el) {
  17703. inVPre = tokenizer.inVPre = false;
  17704. currentVPreBoundary = null;
  17705. }
  17706. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17707. tokenizer.inXML = false;
  17708. }
  17709. }
  17710. function lookAhead(index, c) {
  17711. let i = index;
  17712. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  17713. return i;
  17714. }
  17715. function backTrack(index, c) {
  17716. let i = index;
  17717. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  17718. return i;
  17719. }
  17720. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  17721. function isFragmentTemplate({ tag, props }) {
  17722. if (tag === "template") {
  17723. for (let i = 0; i < props.length; i++) {
  17724. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  17725. return true;
  17726. }
  17727. }
  17728. }
  17729. return false;
  17730. }
  17731. function isComponent({ tag, props }) {
  17732. if (currentOptions.isCustomElement(tag)) {
  17733. return false;
  17734. }
  17735. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  17736. return true;
  17737. }
  17738. for (let i = 0; i < props.length; i++) {
  17739. const p = props[i];
  17740. if (p.type === 6) {
  17741. if (p.name === "is" && p.value) {
  17742. if (p.value.content.startsWith("vue:")) {
  17743. return true;
  17744. }
  17745. }
  17746. }
  17747. }
  17748. return false;
  17749. }
  17750. function isUpperCase(c) {
  17751. return c > 64 && c < 91;
  17752. }
  17753. const windowsNewlineRE = /\r\n/g;
  17754. function condenseWhitespace(nodes, tag) {
  17755. const shouldCondense = currentOptions.whitespace !== "preserve";
  17756. let removedWhitespace = false;
  17757. for (let i = 0; i < nodes.length; i++) {
  17758. const node = nodes[i];
  17759. if (node.type === 2) {
  17760. if (!inPre) {
  17761. if (isAllWhitespace(node.content)) {
  17762. const prev = nodes[i - 1] && nodes[i - 1].type;
  17763. const next = nodes[i + 1] && nodes[i + 1].type;
  17764. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  17765. removedWhitespace = true;
  17766. nodes[i] = null;
  17767. } else {
  17768. node.content = " ";
  17769. }
  17770. } else if (shouldCondense) {
  17771. node.content = condense(node.content);
  17772. }
  17773. } else {
  17774. node.content = node.content.replace(windowsNewlineRE, "\n");
  17775. }
  17776. }
  17777. }
  17778. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  17779. }
  17780. function isAllWhitespace(str) {
  17781. for (let i = 0; i < str.length; i++) {
  17782. if (!isWhitespace(str.charCodeAt(i))) {
  17783. return false;
  17784. }
  17785. }
  17786. return true;
  17787. }
  17788. function hasNewlineChar(str) {
  17789. for (let i = 0; i < str.length; i++) {
  17790. const c = str.charCodeAt(i);
  17791. if (c === 10 || c === 13) {
  17792. return true;
  17793. }
  17794. }
  17795. return false;
  17796. }
  17797. function condense(str) {
  17798. let ret = "";
  17799. let prevCharIsWhitespace = false;
  17800. for (let i = 0; i < str.length; i++) {
  17801. if (isWhitespace(str.charCodeAt(i))) {
  17802. if (!prevCharIsWhitespace) {
  17803. ret += " ";
  17804. prevCharIsWhitespace = true;
  17805. }
  17806. } else {
  17807. ret += str[i];
  17808. prevCharIsWhitespace = false;
  17809. }
  17810. }
  17811. return ret;
  17812. }
  17813. function addNode(node) {
  17814. (stack[0] || currentRoot).children.push(node);
  17815. }
  17816. function getLoc(start, end) {
  17817. return {
  17818. start: tokenizer.getPos(start),
  17819. // @ts-expect-error allow late attachment
  17820. end: end == null ? end : tokenizer.getPos(end),
  17821. // @ts-expect-error allow late attachment
  17822. source: end == null ? end : getSlice(start, end)
  17823. };
  17824. }
  17825. function cloneLoc(loc) {
  17826. return getLoc(loc.start.offset, loc.end.offset);
  17827. }
  17828. function setLocEnd(loc, end) {
  17829. loc.end = tokenizer.getPos(end);
  17830. loc.source = getSlice(loc.start.offset, end);
  17831. }
  17832. function dirToAttr(dir) {
  17833. const attr = {
  17834. type: 6,
  17835. name: dir.rawName,
  17836. nameLoc: getLoc(
  17837. dir.loc.start.offset,
  17838. dir.loc.start.offset + dir.rawName.length
  17839. ),
  17840. value: void 0,
  17841. loc: dir.loc
  17842. };
  17843. if (dir.exp) {
  17844. const loc = dir.exp.loc;
  17845. if (loc.end.offset < dir.loc.end.offset) {
  17846. loc.start.offset--;
  17847. loc.start.column--;
  17848. loc.end.offset++;
  17849. loc.end.column++;
  17850. }
  17851. attr.value = {
  17852. type: 2,
  17853. content: dir.exp.content,
  17854. loc
  17855. };
  17856. }
  17857. return attr;
  17858. }
  17859. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  17860. const exp = createSimpleExpression(content, isStatic, loc, constType);
  17861. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  17862. if (isSimpleIdentifier(content)) {
  17863. exp.ast = null;
  17864. return exp;
  17865. }
  17866. try {
  17867. const plugins = currentOptions.expressionPlugins;
  17868. const options = {
  17869. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  17870. };
  17871. if (parseMode === 2 /* Statements */) {
  17872. exp.ast = libExports.parse(` ${content} `, options).program;
  17873. } else if (parseMode === 1 /* Params */) {
  17874. exp.ast = libExports.parseExpression(`(${content})=>{}`, options);
  17875. } else {
  17876. exp.ast = libExports.parseExpression(`(${content})`, options);
  17877. }
  17878. } catch (e) {
  17879. exp.ast = false;
  17880. emitError(45, loc.start.offset, e.message);
  17881. }
  17882. }
  17883. return exp;
  17884. }
  17885. function emitError(code, index, message) {
  17886. currentOptions.onError(
  17887. createCompilerError(code, getLoc(index, index), void 0, message)
  17888. );
  17889. }
  17890. function reset() {
  17891. tokenizer.reset();
  17892. currentOpenTag = null;
  17893. currentProp = null;
  17894. currentAttrValue = "";
  17895. currentAttrStartIndex = -1;
  17896. currentAttrEndIndex = -1;
  17897. stack.length = 0;
  17898. }
  17899. function baseParse(input, options) {
  17900. reset();
  17901. currentInput = input;
  17902. currentOptions = extend({}, defaultParserOptions);
  17903. if (options) {
  17904. let key;
  17905. for (key in options) {
  17906. if (options[key] != null) {
  17907. currentOptions[key] = options[key];
  17908. }
  17909. }
  17910. }
  17911. {
  17912. if (currentOptions.decodeEntities) {
  17913. console.warn(
  17914. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  17915. );
  17916. }
  17917. }
  17918. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  17919. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  17920. const delimiters = options && options.delimiters;
  17921. if (delimiters) {
  17922. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  17923. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  17924. }
  17925. const root = currentRoot = createRoot([], input);
  17926. tokenizer.parse(currentInput);
  17927. root.loc = getLoc(0, input.length);
  17928. root.children = condenseWhitespace(root.children);
  17929. currentRoot = null;
  17930. return root;
  17931. }
  17932. function cacheStatic(root, context) {
  17933. walk$1(
  17934. root,
  17935. void 0,
  17936. context,
  17937. // Root node is unfortunately non-hoistable due to potential parent
  17938. // fallthrough attributes.
  17939. isSingleElementRoot(root, root.children[0])
  17940. );
  17941. }
  17942. function isSingleElementRoot(root, child) {
  17943. const { children } = root;
  17944. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  17945. }
  17946. function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
  17947. const { children } = node;
  17948. const toCache = [];
  17949. for (let i = 0; i < children.length; i++) {
  17950. const child = children[i];
  17951. if (child.type === 1 && child.tagType === 0) {
  17952. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17953. if (constantType > 0) {
  17954. if (constantType >= 2) {
  17955. child.codegenNode.patchFlag = -1;
  17956. toCache.push(child);
  17957. continue;
  17958. }
  17959. } else {
  17960. const codegenNode = child.codegenNode;
  17961. if (codegenNode.type === 13) {
  17962. const flag = codegenNode.patchFlag;
  17963. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  17964. const props = getNodeProps(child);
  17965. if (props) {
  17966. codegenNode.props = context.hoist(props);
  17967. }
  17968. }
  17969. if (codegenNode.dynamicProps) {
  17970. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  17971. }
  17972. }
  17973. }
  17974. } else if (child.type === 12) {
  17975. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17976. if (constantType >= 2) {
  17977. toCache.push(child);
  17978. continue;
  17979. }
  17980. }
  17981. if (child.type === 1) {
  17982. const isComponent = child.tagType === 1;
  17983. if (isComponent) {
  17984. context.scopes.vSlot++;
  17985. }
  17986. walk$1(child, node, context, false, inFor);
  17987. if (isComponent) {
  17988. context.scopes.vSlot--;
  17989. }
  17990. } else if (child.type === 11) {
  17991. walk$1(child, node, context, child.children.length === 1, true);
  17992. } else if (child.type === 9) {
  17993. for (let i2 = 0; i2 < child.branches.length; i2++) {
  17994. walk$1(
  17995. child.branches[i2],
  17996. node,
  17997. context,
  17998. child.branches[i2].children.length === 1,
  17999. inFor
  18000. );
  18001. }
  18002. }
  18003. }
  18004. let cachedAsArray = false;
  18005. if (toCache.length === children.length && node.type === 1) {
  18006. if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  18007. node.codegenNode.children = getCacheExpression(
  18008. createArrayExpression(node.codegenNode.children)
  18009. );
  18010. cachedAsArray = true;
  18011. } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray$3(node.codegenNode.children) && node.codegenNode.children.type === 15) {
  18012. const slot = getSlotNode(node.codegenNode, "default");
  18013. if (slot) {
  18014. slot.returns = getCacheExpression(
  18015. createArrayExpression(slot.returns)
  18016. );
  18017. cachedAsArray = true;
  18018. }
  18019. } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
  18020. const slotName = findDir(node, "slot", true);
  18021. const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
  18022. if (slot) {
  18023. slot.returns = getCacheExpression(
  18024. createArrayExpression(slot.returns)
  18025. );
  18026. cachedAsArray = true;
  18027. }
  18028. }
  18029. }
  18030. if (!cachedAsArray) {
  18031. for (const child of toCache) {
  18032. child.codegenNode = context.cache(child.codegenNode);
  18033. }
  18034. }
  18035. function getCacheExpression(value) {
  18036. const exp = context.cache(value);
  18037. if (inFor && context.hmr) {
  18038. exp.needArraySpread = true;
  18039. }
  18040. return exp;
  18041. }
  18042. function getSlotNode(node2, name) {
  18043. if (node2.children && !isArray$3(node2.children) && node2.children.type === 15) {
  18044. const slot = node2.children.properties.find(
  18045. (p) => p.key === name || p.key.content === name
  18046. );
  18047. return slot && slot.value;
  18048. }
  18049. }
  18050. if (toCache.length && context.transformHoist) {
  18051. context.transformHoist(children, context, node);
  18052. }
  18053. }
  18054. function getConstantType(node, context) {
  18055. const { constantCache } = context;
  18056. switch (node.type) {
  18057. case 1:
  18058. if (node.tagType !== 0) {
  18059. return 0;
  18060. }
  18061. const cached = constantCache.get(node);
  18062. if (cached !== void 0) {
  18063. return cached;
  18064. }
  18065. const codegenNode = node.codegenNode;
  18066. if (codegenNode.type !== 13) {
  18067. return 0;
  18068. }
  18069. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  18070. return 0;
  18071. }
  18072. if (codegenNode.patchFlag === void 0) {
  18073. let returnType2 = 3;
  18074. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  18075. if (generatedPropsType === 0) {
  18076. constantCache.set(node, 0);
  18077. return 0;
  18078. }
  18079. if (generatedPropsType < returnType2) {
  18080. returnType2 = generatedPropsType;
  18081. }
  18082. for (let i = 0; i < node.children.length; i++) {
  18083. const childType = getConstantType(node.children[i], context);
  18084. if (childType === 0) {
  18085. constantCache.set(node, 0);
  18086. return 0;
  18087. }
  18088. if (childType < returnType2) {
  18089. returnType2 = childType;
  18090. }
  18091. }
  18092. if (returnType2 > 1) {
  18093. for (let i = 0; i < node.props.length; i++) {
  18094. const p = node.props[i];
  18095. if (p.type === 7 && p.name === "bind" && p.exp) {
  18096. const expType = getConstantType(p.exp, context);
  18097. if (expType === 0) {
  18098. constantCache.set(node, 0);
  18099. return 0;
  18100. }
  18101. if (expType < returnType2) {
  18102. returnType2 = expType;
  18103. }
  18104. }
  18105. }
  18106. }
  18107. if (codegenNode.isBlock) {
  18108. for (let i = 0; i < node.props.length; i++) {
  18109. const p = node.props[i];
  18110. if (p.type === 7) {
  18111. constantCache.set(node, 0);
  18112. return 0;
  18113. }
  18114. }
  18115. context.removeHelper(OPEN_BLOCK);
  18116. context.removeHelper(
  18117. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  18118. );
  18119. codegenNode.isBlock = false;
  18120. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  18121. }
  18122. constantCache.set(node, returnType2);
  18123. return returnType2;
  18124. } else {
  18125. constantCache.set(node, 0);
  18126. return 0;
  18127. }
  18128. case 2:
  18129. case 3:
  18130. return 3;
  18131. case 9:
  18132. case 11:
  18133. case 10:
  18134. return 0;
  18135. case 5:
  18136. case 12:
  18137. return getConstantType(node.content, context);
  18138. case 4:
  18139. return node.constType;
  18140. case 8:
  18141. let returnType = 3;
  18142. for (let i = 0; i < node.children.length; i++) {
  18143. const child = node.children[i];
  18144. if (isString$1(child) || isSymbol$1(child)) {
  18145. continue;
  18146. }
  18147. const childType = getConstantType(child, context);
  18148. if (childType === 0) {
  18149. return 0;
  18150. } else if (childType < returnType) {
  18151. returnType = childType;
  18152. }
  18153. }
  18154. return returnType;
  18155. case 20:
  18156. return 2;
  18157. default:
  18158. return 0;
  18159. }
  18160. }
  18161. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  18162. NORMALIZE_CLASS,
  18163. NORMALIZE_STYLE,
  18164. NORMALIZE_PROPS,
  18165. GUARD_REACTIVE_PROPS
  18166. ]);
  18167. function getConstantTypeOfHelperCall(value, context) {
  18168. if (value.type === 14 && !isString$1(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  18169. const arg = value.arguments[0];
  18170. if (arg.type === 4) {
  18171. return getConstantType(arg, context);
  18172. } else if (arg.type === 14) {
  18173. return getConstantTypeOfHelperCall(arg, context);
  18174. }
  18175. }
  18176. return 0;
  18177. }
  18178. function getGeneratedPropsConstantType(node, context) {
  18179. let returnType = 3;
  18180. const props = getNodeProps(node);
  18181. if (props && props.type === 15) {
  18182. const { properties } = props;
  18183. for (let i = 0; i < properties.length; i++) {
  18184. const { key, value } = properties[i];
  18185. const keyType = getConstantType(key, context);
  18186. if (keyType === 0) {
  18187. return keyType;
  18188. }
  18189. if (keyType < returnType) {
  18190. returnType = keyType;
  18191. }
  18192. let valueType;
  18193. if (value.type === 4) {
  18194. valueType = getConstantType(value, context);
  18195. } else if (value.type === 14) {
  18196. valueType = getConstantTypeOfHelperCall(value, context);
  18197. } else {
  18198. valueType = 0;
  18199. }
  18200. if (valueType === 0) {
  18201. return valueType;
  18202. }
  18203. if (valueType < returnType) {
  18204. returnType = valueType;
  18205. }
  18206. }
  18207. }
  18208. return returnType;
  18209. }
  18210. function getNodeProps(node) {
  18211. const codegenNode = node.codegenNode;
  18212. if (codegenNode.type === 13) {
  18213. return codegenNode.props;
  18214. }
  18215. }
  18216. function createTransformContext(root, {
  18217. filename = "",
  18218. prefixIdentifiers = false,
  18219. hoistStatic = false,
  18220. hmr = false,
  18221. cacheHandlers = false,
  18222. nodeTransforms = [],
  18223. directiveTransforms = {},
  18224. transformHoist = null,
  18225. isBuiltInComponent = NOOP,
  18226. isCustomElement = NOOP,
  18227. expressionPlugins = [],
  18228. scopeId = null,
  18229. slotted = true,
  18230. ssr = false,
  18231. inSSR = false,
  18232. ssrCssVars = ``,
  18233. bindingMetadata = EMPTY_OBJ,
  18234. inline = false,
  18235. isTS = false,
  18236. onError = defaultOnError,
  18237. onWarn = defaultOnWarn,
  18238. compatConfig
  18239. }) {
  18240. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18241. const context = {
  18242. // options
  18243. filename,
  18244. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  18245. prefixIdentifiers,
  18246. hoistStatic,
  18247. hmr,
  18248. cacheHandlers,
  18249. nodeTransforms,
  18250. directiveTransforms,
  18251. transformHoist,
  18252. isBuiltInComponent,
  18253. isCustomElement,
  18254. expressionPlugins,
  18255. scopeId,
  18256. slotted,
  18257. ssr,
  18258. inSSR,
  18259. ssrCssVars,
  18260. bindingMetadata,
  18261. inline,
  18262. isTS,
  18263. onError,
  18264. onWarn,
  18265. compatConfig,
  18266. // state
  18267. root,
  18268. helpers: /* @__PURE__ */ new Map(),
  18269. components: /* @__PURE__ */ new Set(),
  18270. directives: /* @__PURE__ */ new Set(),
  18271. hoists: [],
  18272. imports: [],
  18273. cached: [],
  18274. constantCache: /* @__PURE__ */ new WeakMap(),
  18275. temps: 0,
  18276. identifiers: /* @__PURE__ */ Object.create(null),
  18277. scopes: {
  18278. vFor: 0,
  18279. vSlot: 0,
  18280. vPre: 0,
  18281. vOnce: 0
  18282. },
  18283. parent: null,
  18284. grandParent: null,
  18285. currentNode: root,
  18286. childIndex: 0,
  18287. inVOnce: false,
  18288. // methods
  18289. helper(name) {
  18290. const count = context.helpers.get(name) || 0;
  18291. context.helpers.set(name, count + 1);
  18292. return name;
  18293. },
  18294. removeHelper(name) {
  18295. const count = context.helpers.get(name);
  18296. if (count) {
  18297. const currentCount = count - 1;
  18298. if (!currentCount) {
  18299. context.helpers.delete(name);
  18300. } else {
  18301. context.helpers.set(name, currentCount);
  18302. }
  18303. }
  18304. },
  18305. helperString(name) {
  18306. return `_${helperNameMap[context.helper(name)]}`;
  18307. },
  18308. replaceNode(node) {
  18309. {
  18310. if (!context.currentNode) {
  18311. throw new Error(`Node being replaced is already removed.`);
  18312. }
  18313. if (!context.parent) {
  18314. throw new Error(`Cannot replace root node.`);
  18315. }
  18316. }
  18317. context.parent.children[context.childIndex] = context.currentNode = node;
  18318. },
  18319. removeNode(node) {
  18320. if (!context.parent) {
  18321. throw new Error(`Cannot remove root node.`);
  18322. }
  18323. const list = context.parent.children;
  18324. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18325. if (removalIndex < 0) {
  18326. throw new Error(`node being removed is not a child of current parent`);
  18327. }
  18328. if (!node || node === context.currentNode) {
  18329. context.currentNode = null;
  18330. context.onNodeRemoved();
  18331. } else {
  18332. if (context.childIndex > removalIndex) {
  18333. context.childIndex--;
  18334. context.onNodeRemoved();
  18335. }
  18336. }
  18337. context.parent.children.splice(removalIndex, 1);
  18338. },
  18339. onNodeRemoved: NOOP,
  18340. addIdentifiers(exp) {
  18341. {
  18342. if (isString$1(exp)) {
  18343. addId(exp);
  18344. } else if (exp.identifiers) {
  18345. exp.identifiers.forEach(addId);
  18346. } else if (exp.type === 4) {
  18347. addId(exp.content);
  18348. }
  18349. }
  18350. },
  18351. removeIdentifiers(exp) {
  18352. {
  18353. if (isString$1(exp)) {
  18354. removeId(exp);
  18355. } else if (exp.identifiers) {
  18356. exp.identifiers.forEach(removeId);
  18357. } else if (exp.type === 4) {
  18358. removeId(exp.content);
  18359. }
  18360. }
  18361. },
  18362. hoist(exp) {
  18363. if (isString$1(exp)) exp = createSimpleExpression(exp);
  18364. context.hoists.push(exp);
  18365. const identifier = createSimpleExpression(
  18366. `_hoisted_${context.hoists.length}`,
  18367. false,
  18368. exp.loc,
  18369. 2
  18370. );
  18371. identifier.hoisted = exp;
  18372. return identifier;
  18373. },
  18374. cache(exp, isVNode = false, inVOnce = false) {
  18375. const cacheExp = createCacheExpression(
  18376. context.cached.length,
  18377. exp,
  18378. isVNode,
  18379. inVOnce
  18380. );
  18381. context.cached.push(cacheExp);
  18382. return cacheExp;
  18383. }
  18384. };
  18385. function addId(id) {
  18386. const { identifiers } = context;
  18387. if (identifiers[id] === void 0) {
  18388. identifiers[id] = 0;
  18389. }
  18390. identifiers[id]++;
  18391. }
  18392. function removeId(id) {
  18393. context.identifiers[id]--;
  18394. }
  18395. return context;
  18396. }
  18397. function transform(root, options) {
  18398. const context = createTransformContext(root, options);
  18399. traverseNode(root, context);
  18400. if (options.hoistStatic) {
  18401. cacheStatic(root, context);
  18402. }
  18403. if (!options.ssr) {
  18404. createRootCodegen(root, context);
  18405. }
  18406. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  18407. root.components = [...context.components];
  18408. root.directives = [...context.directives];
  18409. root.imports = context.imports;
  18410. root.hoists = context.hoists;
  18411. root.temps = context.temps;
  18412. root.cached = context.cached;
  18413. root.transformed = true;
  18414. }
  18415. function createRootCodegen(root, context) {
  18416. const { helper } = context;
  18417. const { children } = root;
  18418. if (children.length === 1) {
  18419. const child = children[0];
  18420. if (isSingleElementRoot(root, child) && child.codegenNode) {
  18421. const codegenNode = child.codegenNode;
  18422. if (codegenNode.type === 13) {
  18423. convertToBlock(codegenNode, context);
  18424. }
  18425. root.codegenNode = codegenNode;
  18426. } else {
  18427. root.codegenNode = child;
  18428. }
  18429. } else if (children.length > 1) {
  18430. let patchFlag = 64;
  18431. if (children.filter((c) => c.type !== 3).length === 1) {
  18432. patchFlag |= 2048;
  18433. }
  18434. root.codegenNode = createVNodeCall(
  18435. context,
  18436. helper(FRAGMENT),
  18437. void 0,
  18438. root.children,
  18439. patchFlag,
  18440. void 0,
  18441. void 0,
  18442. true,
  18443. void 0,
  18444. false
  18445. );
  18446. } else ;
  18447. }
  18448. function traverseChildren(parent, context) {
  18449. let i = 0;
  18450. const nodeRemoved = () => {
  18451. i--;
  18452. };
  18453. for (; i < parent.children.length; i++) {
  18454. const child = parent.children[i];
  18455. if (isString$1(child)) continue;
  18456. context.grandParent = context.parent;
  18457. context.parent = parent;
  18458. context.childIndex = i;
  18459. context.onNodeRemoved = nodeRemoved;
  18460. traverseNode(child, context);
  18461. }
  18462. }
  18463. function traverseNode(node, context) {
  18464. context.currentNode = node;
  18465. const { nodeTransforms } = context;
  18466. const exitFns = [];
  18467. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  18468. const onExit = nodeTransforms[i2](node, context);
  18469. if (onExit) {
  18470. if (isArray$3(onExit)) {
  18471. exitFns.push(...onExit);
  18472. } else {
  18473. exitFns.push(onExit);
  18474. }
  18475. }
  18476. if (!context.currentNode) {
  18477. return;
  18478. } else {
  18479. node = context.currentNode;
  18480. }
  18481. }
  18482. switch (node.type) {
  18483. case 3:
  18484. if (!context.ssr) {
  18485. context.helper(CREATE_COMMENT);
  18486. }
  18487. break;
  18488. case 5:
  18489. if (!context.ssr) {
  18490. context.helper(TO_DISPLAY_STRING);
  18491. }
  18492. break;
  18493. // for container types, further traverse downwards
  18494. case 9:
  18495. for (let i2 = 0; i2 < node.branches.length; i2++) {
  18496. traverseNode(node.branches[i2], context);
  18497. }
  18498. break;
  18499. case 10:
  18500. case 11:
  18501. case 1:
  18502. case 0:
  18503. traverseChildren(node, context);
  18504. break;
  18505. }
  18506. context.currentNode = node;
  18507. let i = exitFns.length;
  18508. while (i--) {
  18509. exitFns[i]();
  18510. }
  18511. }
  18512. function createStructuralDirectiveTransform(name, fn) {
  18513. const matches = isString$1(name) ? (n) => n === name : (n) => name.test(n);
  18514. return (node, context) => {
  18515. if (node.type === 1) {
  18516. const { props } = node;
  18517. if (node.tagType === 3 && props.some(isVSlot)) {
  18518. return;
  18519. }
  18520. const exitFns = [];
  18521. for (let i = 0; i < props.length; i++) {
  18522. const prop = props[i];
  18523. if (prop.type === 7 && matches(prop.name)) {
  18524. props.splice(i, 1);
  18525. i--;
  18526. const onExit = fn(node, prop, context);
  18527. if (onExit) exitFns.push(onExit);
  18528. }
  18529. }
  18530. return exitFns;
  18531. }
  18532. };
  18533. }
  18534. var sourceMap$2 = {};
  18535. var sourceMapGenerator$2 = {};
  18536. var base64Vlq$2 = {};
  18537. var base64$2 = {};
  18538. /* -*- Mode: js; js-indent-level: 2; -*- */
  18539. var hasRequiredBase64$2;
  18540. function requireBase64$2 () {
  18541. if (hasRequiredBase64$2) return base64$2;
  18542. hasRequiredBase64$2 = 1;
  18543. /*
  18544. * Copyright 2011 Mozilla Foundation and contributors
  18545. * Licensed under the New BSD license. See LICENSE or:
  18546. * http://opensource.org/licenses/BSD-3-Clause
  18547. */
  18548. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  18549. /**
  18550. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  18551. */
  18552. base64$2.encode = function (number) {
  18553. if (0 <= number && number < intToCharMap.length) {
  18554. return intToCharMap[number];
  18555. }
  18556. throw new TypeError("Must be between 0 and 63: " + number);
  18557. };
  18558. /**
  18559. * Decode a single base 64 character code digit to an integer. Returns -1 on
  18560. * failure.
  18561. */
  18562. base64$2.decode = function (charCode) {
  18563. var bigA = 65; // 'A'
  18564. var bigZ = 90; // 'Z'
  18565. var littleA = 97; // 'a'
  18566. var littleZ = 122; // 'z'
  18567. var zero = 48; // '0'
  18568. var nine = 57; // '9'
  18569. var plus = 43; // '+'
  18570. var slash = 47; // '/'
  18571. var littleOffset = 26;
  18572. var numberOffset = 52;
  18573. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  18574. if (bigA <= charCode && charCode <= bigZ) {
  18575. return (charCode - bigA);
  18576. }
  18577. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  18578. if (littleA <= charCode && charCode <= littleZ) {
  18579. return (charCode - littleA + littleOffset);
  18580. }
  18581. // 52 - 61: 0123456789
  18582. if (zero <= charCode && charCode <= nine) {
  18583. return (charCode - zero + numberOffset);
  18584. }
  18585. // 62: +
  18586. if (charCode == plus) {
  18587. return 62;
  18588. }
  18589. // 63: /
  18590. if (charCode == slash) {
  18591. return 63;
  18592. }
  18593. // Invalid base64 digit.
  18594. return -1;
  18595. };
  18596. return base64$2;
  18597. }
  18598. /* -*- Mode: js; js-indent-level: 2; -*- */
  18599. var hasRequiredBase64Vlq$2;
  18600. function requireBase64Vlq$2 () {
  18601. if (hasRequiredBase64Vlq$2) return base64Vlq$2;
  18602. hasRequiredBase64Vlq$2 = 1;
  18603. /*
  18604. * Copyright 2011 Mozilla Foundation and contributors
  18605. * Licensed under the New BSD license. See LICENSE or:
  18606. * http://opensource.org/licenses/BSD-3-Clause
  18607. *
  18608. * Based on the Base 64 VLQ implementation in Closure Compiler:
  18609. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  18610. *
  18611. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  18612. * Redistribution and use in source and binary forms, with or without
  18613. * modification, are permitted provided that the following conditions are
  18614. * met:
  18615. *
  18616. * * Redistributions of source code must retain the above copyright
  18617. * notice, this list of conditions and the following disclaimer.
  18618. * * Redistributions in binary form must reproduce the above
  18619. * copyright notice, this list of conditions and the following
  18620. * disclaimer in the documentation and/or other materials provided
  18621. * with the distribution.
  18622. * * Neither the name of Google Inc. nor the names of its
  18623. * contributors may be used to endorse or promote products derived
  18624. * from this software without specific prior written permission.
  18625. *
  18626. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18627. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18628. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18629. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18630. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18631. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18632. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18633. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18634. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18635. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18636. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18637. */
  18638. var base64 = /*@__PURE__*/ requireBase64$2();
  18639. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  18640. // length quantities we use in the source map spec, the first bit is the sign,
  18641. // the next four bits are the actual value, and the 6th bit is the
  18642. // continuation bit. The continuation bit tells us whether there are more
  18643. // digits in this value following this digit.
  18644. //
  18645. // Continuation
  18646. // | Sign
  18647. // | |
  18648. // V V
  18649. // 101011
  18650. var VLQ_BASE_SHIFT = 5;
  18651. // binary: 100000
  18652. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  18653. // binary: 011111
  18654. var VLQ_BASE_MASK = VLQ_BASE - 1;
  18655. // binary: 100000
  18656. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  18657. /**
  18658. * Converts from a two-complement value to a value where the sign bit is
  18659. * placed in the least significant bit. For example, as decimals:
  18660. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  18661. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  18662. */
  18663. function toVLQSigned(aValue) {
  18664. return aValue < 0
  18665. ? ((-aValue) << 1) + 1
  18666. : (aValue << 1) + 0;
  18667. }
  18668. /**
  18669. * Converts to a two-complement value from a value where the sign bit is
  18670. * placed in the least significant bit. For example, as decimals:
  18671. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  18672. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  18673. */
  18674. function fromVLQSigned(aValue) {
  18675. var isNegative = (aValue & 1) === 1;
  18676. var shifted = aValue >> 1;
  18677. return isNegative
  18678. ? -shifted
  18679. : shifted;
  18680. }
  18681. /**
  18682. * Returns the base 64 VLQ encoded value.
  18683. */
  18684. base64Vlq$2.encode = function base64VLQ_encode(aValue) {
  18685. var encoded = "";
  18686. var digit;
  18687. var vlq = toVLQSigned(aValue);
  18688. do {
  18689. digit = vlq & VLQ_BASE_MASK;
  18690. vlq >>>= VLQ_BASE_SHIFT;
  18691. if (vlq > 0) {
  18692. // There are still more digits in this value, so we must make sure the
  18693. // continuation bit is marked.
  18694. digit |= VLQ_CONTINUATION_BIT;
  18695. }
  18696. encoded += base64.encode(digit);
  18697. } while (vlq > 0);
  18698. return encoded;
  18699. };
  18700. /**
  18701. * Decodes the next base 64 VLQ value from the given string and returns the
  18702. * value and the rest of the string via the out parameter.
  18703. */
  18704. base64Vlq$2.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  18705. var strLen = aStr.length;
  18706. var result = 0;
  18707. var shift = 0;
  18708. var continuation, digit;
  18709. do {
  18710. if (aIndex >= strLen) {
  18711. throw new Error("Expected more digits in base 64 VLQ value.");
  18712. }
  18713. digit = base64.decode(aStr.charCodeAt(aIndex++));
  18714. if (digit === -1) {
  18715. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  18716. }
  18717. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  18718. digit &= VLQ_BASE_MASK;
  18719. result = result + (digit << shift);
  18720. shift += VLQ_BASE_SHIFT;
  18721. } while (continuation);
  18722. aOutParam.value = fromVLQSigned(result);
  18723. aOutParam.rest = aIndex;
  18724. };
  18725. return base64Vlq$2;
  18726. }
  18727. var util$3 = {};
  18728. /* -*- Mode: js; js-indent-level: 2; -*- */
  18729. var hasRequiredUtil$3;
  18730. function requireUtil$3 () {
  18731. if (hasRequiredUtil$3) return util$3;
  18732. hasRequiredUtil$3 = 1;
  18733. (function (exports) {
  18734. /*
  18735. * Copyright 2011 Mozilla Foundation and contributors
  18736. * Licensed under the New BSD license. See LICENSE or:
  18737. * http://opensource.org/licenses/BSD-3-Clause
  18738. */
  18739. /**
  18740. * This is a helper function for getting values from parameter/options
  18741. * objects.
  18742. *
  18743. * @param args The object we are extracting values from
  18744. * @param name The name of the property we are getting.
  18745. * @param defaultValue An optional value to return if the property is missing
  18746. * from the object. If this is not specified and the property is missing, an
  18747. * error will be thrown.
  18748. */
  18749. function getArg(aArgs, aName, aDefaultValue) {
  18750. if (aName in aArgs) {
  18751. return aArgs[aName];
  18752. } else if (arguments.length === 3) {
  18753. return aDefaultValue;
  18754. } else {
  18755. throw new Error('"' + aName + '" is a required argument.');
  18756. }
  18757. }
  18758. exports.getArg = getArg;
  18759. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  18760. var dataUrlRegexp = /^data:.+\,.+$/;
  18761. function urlParse(aUrl) {
  18762. var match = aUrl.match(urlRegexp);
  18763. if (!match) {
  18764. return null;
  18765. }
  18766. return {
  18767. scheme: match[1],
  18768. auth: match[2],
  18769. host: match[3],
  18770. port: match[4],
  18771. path: match[5]
  18772. };
  18773. }
  18774. exports.urlParse = urlParse;
  18775. function urlGenerate(aParsedUrl) {
  18776. var url = '';
  18777. if (aParsedUrl.scheme) {
  18778. url += aParsedUrl.scheme + ':';
  18779. }
  18780. url += '//';
  18781. if (aParsedUrl.auth) {
  18782. url += aParsedUrl.auth + '@';
  18783. }
  18784. if (aParsedUrl.host) {
  18785. url += aParsedUrl.host;
  18786. }
  18787. if (aParsedUrl.port) {
  18788. url += ":" + aParsedUrl.port;
  18789. }
  18790. if (aParsedUrl.path) {
  18791. url += aParsedUrl.path;
  18792. }
  18793. return url;
  18794. }
  18795. exports.urlGenerate = urlGenerate;
  18796. var MAX_CACHED_INPUTS = 32;
  18797. /**
  18798. * Takes some function `f(input) -> result` and returns a memoized version of
  18799. * `f`.
  18800. *
  18801. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  18802. * memoization is a dumb-simple, linear least-recently-used cache.
  18803. */
  18804. function lruMemoize(f) {
  18805. var cache = [];
  18806. return function(input) {
  18807. for (var i = 0; i < cache.length; i++) {
  18808. if (cache[i].input === input) {
  18809. var temp = cache[0];
  18810. cache[0] = cache[i];
  18811. cache[i] = temp;
  18812. return cache[0].result;
  18813. }
  18814. }
  18815. var result = f(input);
  18816. cache.unshift({
  18817. input,
  18818. result,
  18819. });
  18820. if (cache.length > MAX_CACHED_INPUTS) {
  18821. cache.pop();
  18822. }
  18823. return result;
  18824. };
  18825. }
  18826. /**
  18827. * Normalizes a path, or the path portion of a URL:
  18828. *
  18829. * - Replaces consecutive slashes with one slash.
  18830. * - Removes unnecessary '.' parts.
  18831. * - Removes unnecessary '<dir>/..' parts.
  18832. *
  18833. * Based on code in the Node.js 'path' core module.
  18834. *
  18835. * @param aPath The path or url to normalize.
  18836. */
  18837. var normalize = lruMemoize(function normalize(aPath) {
  18838. var path = aPath;
  18839. var url = urlParse(aPath);
  18840. if (url) {
  18841. if (!url.path) {
  18842. return aPath;
  18843. }
  18844. path = url.path;
  18845. }
  18846. var isAbsolute = exports.isAbsolute(path);
  18847. // Split the path into parts between `/` characters. This is much faster than
  18848. // using `.split(/\/+/g)`.
  18849. var parts = [];
  18850. var start = 0;
  18851. var i = 0;
  18852. while (true) {
  18853. start = i;
  18854. i = path.indexOf("/", start);
  18855. if (i === -1) {
  18856. parts.push(path.slice(start));
  18857. break;
  18858. } else {
  18859. parts.push(path.slice(start, i));
  18860. while (i < path.length && path[i] === "/") {
  18861. i++;
  18862. }
  18863. }
  18864. }
  18865. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  18866. part = parts[i];
  18867. if (part === '.') {
  18868. parts.splice(i, 1);
  18869. } else if (part === '..') {
  18870. up++;
  18871. } else if (up > 0) {
  18872. if (part === '') {
  18873. // The first part is blank if the path is absolute. Trying to go
  18874. // above the root is a no-op. Therefore we can remove all '..' parts
  18875. // directly after the root.
  18876. parts.splice(i + 1, up);
  18877. up = 0;
  18878. } else {
  18879. parts.splice(i, 2);
  18880. up--;
  18881. }
  18882. }
  18883. }
  18884. path = parts.join('/');
  18885. if (path === '') {
  18886. path = isAbsolute ? '/' : '.';
  18887. }
  18888. if (url) {
  18889. url.path = path;
  18890. return urlGenerate(url);
  18891. }
  18892. return path;
  18893. });
  18894. exports.normalize = normalize;
  18895. /**
  18896. * Joins two paths/URLs.
  18897. *
  18898. * @param aRoot The root path or URL.
  18899. * @param aPath The path or URL to be joined with the root.
  18900. *
  18901. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  18902. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  18903. * first.
  18904. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  18905. * is updated with the result and aRoot is returned. Otherwise the result
  18906. * is returned.
  18907. * - If aPath is absolute, the result is aPath.
  18908. * - Otherwise the two paths are joined with a slash.
  18909. * - Joining for example 'http://' and 'www.example.com' is also supported.
  18910. */
  18911. function join(aRoot, aPath) {
  18912. if (aRoot === "") {
  18913. aRoot = ".";
  18914. }
  18915. if (aPath === "") {
  18916. aPath = ".";
  18917. }
  18918. var aPathUrl = urlParse(aPath);
  18919. var aRootUrl = urlParse(aRoot);
  18920. if (aRootUrl) {
  18921. aRoot = aRootUrl.path || '/';
  18922. }
  18923. // `join(foo, '//www.example.org')`
  18924. if (aPathUrl && !aPathUrl.scheme) {
  18925. if (aRootUrl) {
  18926. aPathUrl.scheme = aRootUrl.scheme;
  18927. }
  18928. return urlGenerate(aPathUrl);
  18929. }
  18930. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  18931. return aPath;
  18932. }
  18933. // `join('http://', 'www.example.com')`
  18934. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  18935. aRootUrl.host = aPath;
  18936. return urlGenerate(aRootUrl);
  18937. }
  18938. var joined = aPath.charAt(0) === '/'
  18939. ? aPath
  18940. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  18941. if (aRootUrl) {
  18942. aRootUrl.path = joined;
  18943. return urlGenerate(aRootUrl);
  18944. }
  18945. return joined;
  18946. }
  18947. exports.join = join;
  18948. exports.isAbsolute = function (aPath) {
  18949. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  18950. };
  18951. /**
  18952. * Make a path relative to a URL or another path.
  18953. *
  18954. * @param aRoot The root path or URL.
  18955. * @param aPath The path or URL to be made relative to aRoot.
  18956. */
  18957. function relative(aRoot, aPath) {
  18958. if (aRoot === "") {
  18959. aRoot = ".";
  18960. }
  18961. aRoot = aRoot.replace(/\/$/, '');
  18962. // It is possible for the path to be above the root. In this case, simply
  18963. // checking whether the root is a prefix of the path won't work. Instead, we
  18964. // need to remove components from the root one by one, until either we find
  18965. // a prefix that fits, or we run out of components to remove.
  18966. var level = 0;
  18967. while (aPath.indexOf(aRoot + '/') !== 0) {
  18968. var index = aRoot.lastIndexOf("/");
  18969. if (index < 0) {
  18970. return aPath;
  18971. }
  18972. // If the only part of the root that is left is the scheme (i.e. http://,
  18973. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  18974. // have exhausted all components, so the path is not relative to the root.
  18975. aRoot = aRoot.slice(0, index);
  18976. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  18977. return aPath;
  18978. }
  18979. ++level;
  18980. }
  18981. // Make sure we add a "../" for each component we removed from the root.
  18982. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  18983. }
  18984. exports.relative = relative;
  18985. var supportsNullProto = (function () {
  18986. var obj = Object.create(null);
  18987. return !('__proto__' in obj);
  18988. }());
  18989. function identity (s) {
  18990. return s;
  18991. }
  18992. /**
  18993. * Because behavior goes wacky when you set `__proto__` on objects, we
  18994. * have to prefix all the strings in our set with an arbitrary character.
  18995. *
  18996. * See https://github.com/mozilla/source-map/pull/31 and
  18997. * https://github.com/mozilla/source-map/issues/30
  18998. *
  18999. * @param String aStr
  19000. */
  19001. function toSetString(aStr) {
  19002. if (isProtoString(aStr)) {
  19003. return '$' + aStr;
  19004. }
  19005. return aStr;
  19006. }
  19007. exports.toSetString = supportsNullProto ? identity : toSetString;
  19008. function fromSetString(aStr) {
  19009. if (isProtoString(aStr)) {
  19010. return aStr.slice(1);
  19011. }
  19012. return aStr;
  19013. }
  19014. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  19015. function isProtoString(s) {
  19016. if (!s) {
  19017. return false;
  19018. }
  19019. var length = s.length;
  19020. if (length < 9 /* "__proto__".length */) {
  19021. return false;
  19022. }
  19023. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  19024. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  19025. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  19026. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  19027. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  19028. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  19029. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  19030. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  19031. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  19032. return false;
  19033. }
  19034. for (var i = length - 10; i >= 0; i--) {
  19035. if (s.charCodeAt(i) !== 36 /* '$' */) {
  19036. return false;
  19037. }
  19038. }
  19039. return true;
  19040. }
  19041. /**
  19042. * Comparator between two mappings where the original positions are compared.
  19043. *
  19044. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19045. * mappings with the same original source/line/column, but different generated
  19046. * line and column the same. Useful when searching for a mapping with a
  19047. * stubbed out mapping.
  19048. */
  19049. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  19050. var cmp = strcmp(mappingA.source, mappingB.source);
  19051. if (cmp !== 0) {
  19052. return cmp;
  19053. }
  19054. cmp = mappingA.originalLine - mappingB.originalLine;
  19055. if (cmp !== 0) {
  19056. return cmp;
  19057. }
  19058. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19059. if (cmp !== 0 || onlyCompareOriginal) {
  19060. return cmp;
  19061. }
  19062. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19063. if (cmp !== 0) {
  19064. return cmp;
  19065. }
  19066. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19067. if (cmp !== 0) {
  19068. return cmp;
  19069. }
  19070. return strcmp(mappingA.name, mappingB.name);
  19071. }
  19072. exports.compareByOriginalPositions = compareByOriginalPositions;
  19073. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  19074. var cmp;
  19075. cmp = mappingA.originalLine - mappingB.originalLine;
  19076. if (cmp !== 0) {
  19077. return cmp;
  19078. }
  19079. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19080. if (cmp !== 0 || onlyCompareOriginal) {
  19081. return cmp;
  19082. }
  19083. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19084. if (cmp !== 0) {
  19085. return cmp;
  19086. }
  19087. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19088. if (cmp !== 0) {
  19089. return cmp;
  19090. }
  19091. return strcmp(mappingA.name, mappingB.name);
  19092. }
  19093. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  19094. /**
  19095. * Comparator between two mappings with deflated source and name indices where
  19096. * the generated positions are compared.
  19097. *
  19098. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19099. * mappings with the same generated line and column, but different
  19100. * source/name/original line and column the same. Useful when searching for a
  19101. * mapping with a stubbed out mapping.
  19102. */
  19103. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  19104. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19105. if (cmp !== 0) {
  19106. return cmp;
  19107. }
  19108. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19109. if (cmp !== 0 || onlyCompareGenerated) {
  19110. return cmp;
  19111. }
  19112. cmp = strcmp(mappingA.source, mappingB.source);
  19113. if (cmp !== 0) {
  19114. return cmp;
  19115. }
  19116. cmp = mappingA.originalLine - mappingB.originalLine;
  19117. if (cmp !== 0) {
  19118. return cmp;
  19119. }
  19120. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19121. if (cmp !== 0) {
  19122. return cmp;
  19123. }
  19124. return strcmp(mappingA.name, mappingB.name);
  19125. }
  19126. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  19127. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  19128. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19129. if (cmp !== 0 || onlyCompareGenerated) {
  19130. return cmp;
  19131. }
  19132. cmp = strcmp(mappingA.source, mappingB.source);
  19133. if (cmp !== 0) {
  19134. return cmp;
  19135. }
  19136. cmp = mappingA.originalLine - mappingB.originalLine;
  19137. if (cmp !== 0) {
  19138. return cmp;
  19139. }
  19140. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19141. if (cmp !== 0) {
  19142. return cmp;
  19143. }
  19144. return strcmp(mappingA.name, mappingB.name);
  19145. }
  19146. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  19147. function strcmp(aStr1, aStr2) {
  19148. if (aStr1 === aStr2) {
  19149. return 0;
  19150. }
  19151. if (aStr1 === null) {
  19152. return 1; // aStr2 !== null
  19153. }
  19154. if (aStr2 === null) {
  19155. return -1; // aStr1 !== null
  19156. }
  19157. if (aStr1 > aStr2) {
  19158. return 1;
  19159. }
  19160. return -1;
  19161. }
  19162. /**
  19163. * Comparator between two mappings with inflated source and name strings where
  19164. * the generated positions are compared.
  19165. */
  19166. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  19167. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19168. if (cmp !== 0) {
  19169. return cmp;
  19170. }
  19171. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19172. if (cmp !== 0) {
  19173. return cmp;
  19174. }
  19175. cmp = strcmp(mappingA.source, mappingB.source);
  19176. if (cmp !== 0) {
  19177. return cmp;
  19178. }
  19179. cmp = mappingA.originalLine - mappingB.originalLine;
  19180. if (cmp !== 0) {
  19181. return cmp;
  19182. }
  19183. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19184. if (cmp !== 0) {
  19185. return cmp;
  19186. }
  19187. return strcmp(mappingA.name, mappingB.name);
  19188. }
  19189. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  19190. /**
  19191. * Strip any JSON XSSI avoidance prefix from the string (as documented
  19192. * in the source maps specification), and then parse the string as
  19193. * JSON.
  19194. */
  19195. function parseSourceMapInput(str) {
  19196. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  19197. }
  19198. exports.parseSourceMapInput = parseSourceMapInput;
  19199. /**
  19200. * Compute the URL of a source given the the source root, the source's
  19201. * URL, and the source map's URL.
  19202. */
  19203. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  19204. sourceURL = sourceURL || '';
  19205. if (sourceRoot) {
  19206. // This follows what Chrome does.
  19207. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  19208. sourceRoot += '/';
  19209. }
  19210. // The spec says:
  19211. // Line 4: An optional source root, useful for relocating source
  19212. // files on a server or removing repeated values in the
  19213. // “sources” entry. This value is prepended to the individual
  19214. // entries in the “source” field.
  19215. sourceURL = sourceRoot + sourceURL;
  19216. }
  19217. // Historically, SourceMapConsumer did not take the sourceMapURL as
  19218. // a parameter. This mode is still somewhat supported, which is why
  19219. // this code block is conditional. However, it's preferable to pass
  19220. // the source map URL to SourceMapConsumer, so that this function
  19221. // can implement the source URL resolution algorithm as outlined in
  19222. // the spec. This block is basically the equivalent of:
  19223. // new URL(sourceURL, sourceMapURL).toString()
  19224. // ... except it avoids using URL, which wasn't available in the
  19225. // older releases of node still supported by this library.
  19226. //
  19227. // The spec says:
  19228. // If the sources are not absolute URLs after prepending of the
  19229. // “sourceRoot”, the sources are resolved relative to the
  19230. // SourceMap (like resolving script src in a html document).
  19231. if (sourceMapURL) {
  19232. var parsed = urlParse(sourceMapURL);
  19233. if (!parsed) {
  19234. throw new Error("sourceMapURL could not be parsed");
  19235. }
  19236. if (parsed.path) {
  19237. // Strip the last path component, but keep the "/".
  19238. var index = parsed.path.lastIndexOf('/');
  19239. if (index >= 0) {
  19240. parsed.path = parsed.path.substring(0, index + 1);
  19241. }
  19242. }
  19243. sourceURL = join(urlGenerate(parsed), sourceURL);
  19244. }
  19245. return normalize(sourceURL);
  19246. }
  19247. exports.computeSourceURL = computeSourceURL;
  19248. } (util$3));
  19249. return util$3;
  19250. }
  19251. var arraySet$2 = {};
  19252. /* -*- Mode: js; js-indent-level: 2; -*- */
  19253. var hasRequiredArraySet$2;
  19254. function requireArraySet$2 () {
  19255. if (hasRequiredArraySet$2) return arraySet$2;
  19256. hasRequiredArraySet$2 = 1;
  19257. /*
  19258. * Copyright 2011 Mozilla Foundation and contributors
  19259. * Licensed under the New BSD license. See LICENSE or:
  19260. * http://opensource.org/licenses/BSD-3-Clause
  19261. */
  19262. var util = /*@__PURE__*/ requireUtil$3();
  19263. var has = Object.prototype.hasOwnProperty;
  19264. var hasNativeMap = typeof Map !== "undefined";
  19265. /**
  19266. * A data structure which is a combination of an array and a set. Adding a new
  19267. * member is O(1), testing for membership is O(1), and finding the index of an
  19268. * element is O(1). Removing elements from the set is not supported. Only
  19269. * strings are supported for membership.
  19270. */
  19271. function ArraySet() {
  19272. this._array = [];
  19273. this._set = hasNativeMap ? new Map() : Object.create(null);
  19274. }
  19275. /**
  19276. * Static method for creating ArraySet instances from an existing array.
  19277. */
  19278. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19279. var set = new ArraySet();
  19280. for (var i = 0, len = aArray.length; i < len; i++) {
  19281. set.add(aArray[i], aAllowDuplicates);
  19282. }
  19283. return set;
  19284. };
  19285. /**
  19286. * Return how many unique items are in this ArraySet. If duplicates have been
  19287. * added, than those do not count towards the size.
  19288. *
  19289. * @returns Number
  19290. */
  19291. ArraySet.prototype.size = function ArraySet_size() {
  19292. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19293. };
  19294. /**
  19295. * Add the given string to this set.
  19296. *
  19297. * @param String aStr
  19298. */
  19299. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19300. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  19301. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  19302. var idx = this._array.length;
  19303. if (!isDuplicate || aAllowDuplicates) {
  19304. this._array.push(aStr);
  19305. }
  19306. if (!isDuplicate) {
  19307. if (hasNativeMap) {
  19308. this._set.set(aStr, idx);
  19309. } else {
  19310. this._set[sStr] = idx;
  19311. }
  19312. }
  19313. };
  19314. /**
  19315. * Is the given string a member of this set?
  19316. *
  19317. * @param String aStr
  19318. */
  19319. ArraySet.prototype.has = function ArraySet_has(aStr) {
  19320. if (hasNativeMap) {
  19321. return this._set.has(aStr);
  19322. } else {
  19323. var sStr = util.toSetString(aStr);
  19324. return has.call(this._set, sStr);
  19325. }
  19326. };
  19327. /**
  19328. * What is the index of the given string in the array?
  19329. *
  19330. * @param String aStr
  19331. */
  19332. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19333. if (hasNativeMap) {
  19334. var idx = this._set.get(aStr);
  19335. if (idx >= 0) {
  19336. return idx;
  19337. }
  19338. } else {
  19339. var sStr = util.toSetString(aStr);
  19340. if (has.call(this._set, sStr)) {
  19341. return this._set[sStr];
  19342. }
  19343. }
  19344. throw new Error('"' + aStr + '" is not in the set.');
  19345. };
  19346. /**
  19347. * What is the element at the given index?
  19348. *
  19349. * @param Number aIdx
  19350. */
  19351. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  19352. if (aIdx >= 0 && aIdx < this._array.length) {
  19353. return this._array[aIdx];
  19354. }
  19355. throw new Error('No element indexed by ' + aIdx);
  19356. };
  19357. /**
  19358. * Returns the array representation of this set (which has the proper indices
  19359. * indicated by indexOf). Note that this is a copy of the internal array used
  19360. * for storing the members so that no one can mess with internal state.
  19361. */
  19362. ArraySet.prototype.toArray = function ArraySet_toArray() {
  19363. return this._array.slice();
  19364. };
  19365. arraySet$2.ArraySet = ArraySet;
  19366. return arraySet$2;
  19367. }
  19368. var mappingList$2 = {};
  19369. /* -*- Mode: js; js-indent-level: 2; -*- */
  19370. var hasRequiredMappingList$2;
  19371. function requireMappingList$2 () {
  19372. if (hasRequiredMappingList$2) return mappingList$2;
  19373. hasRequiredMappingList$2 = 1;
  19374. /*
  19375. * Copyright 2014 Mozilla Foundation and contributors
  19376. * Licensed under the New BSD license. See LICENSE or:
  19377. * http://opensource.org/licenses/BSD-3-Clause
  19378. */
  19379. var util = /*@__PURE__*/ requireUtil$3();
  19380. /**
  19381. * Determine whether mappingB is after mappingA with respect to generated
  19382. * position.
  19383. */
  19384. function generatedPositionAfter(mappingA, mappingB) {
  19385. // Optimized for most common case
  19386. var lineA = mappingA.generatedLine;
  19387. var lineB = mappingB.generatedLine;
  19388. var columnA = mappingA.generatedColumn;
  19389. var columnB = mappingB.generatedColumn;
  19390. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  19391. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  19392. }
  19393. /**
  19394. * A data structure to provide a sorted view of accumulated mappings in a
  19395. * performance conscious manner. It trades a neglibable overhead in general
  19396. * case for a large speedup in case of mappings being added in order.
  19397. */
  19398. function MappingList() {
  19399. this._array = [];
  19400. this._sorted = true;
  19401. // Serves as infimum
  19402. this._last = {generatedLine: -1, generatedColumn: 0};
  19403. }
  19404. /**
  19405. * Iterate through internal items. This method takes the same arguments that
  19406. * `Array.prototype.forEach` takes.
  19407. *
  19408. * NOTE: The order of the mappings is NOT guaranteed.
  19409. */
  19410. MappingList.prototype.unsortedForEach =
  19411. function MappingList_forEach(aCallback, aThisArg) {
  19412. this._array.forEach(aCallback, aThisArg);
  19413. };
  19414. /**
  19415. * Add the given source mapping.
  19416. *
  19417. * @param Object aMapping
  19418. */
  19419. MappingList.prototype.add = function MappingList_add(aMapping) {
  19420. if (generatedPositionAfter(this._last, aMapping)) {
  19421. this._last = aMapping;
  19422. this._array.push(aMapping);
  19423. } else {
  19424. this._sorted = false;
  19425. this._array.push(aMapping);
  19426. }
  19427. };
  19428. /**
  19429. * Returns the flat, sorted array of mappings. The mappings are sorted by
  19430. * generated position.
  19431. *
  19432. * WARNING: This method returns internal data without copying, for
  19433. * performance. The return value must NOT be mutated, and should be treated as
  19434. * an immutable borrow. If you want to take ownership, you must make your own
  19435. * copy.
  19436. */
  19437. MappingList.prototype.toArray = function MappingList_toArray() {
  19438. if (!this._sorted) {
  19439. this._array.sort(util.compareByGeneratedPositionsInflated);
  19440. this._sorted = true;
  19441. }
  19442. return this._array;
  19443. };
  19444. mappingList$2.MappingList = MappingList;
  19445. return mappingList$2;
  19446. }
  19447. /* -*- Mode: js; js-indent-level: 2; -*- */
  19448. var hasRequiredSourceMapGenerator$2;
  19449. function requireSourceMapGenerator$2 () {
  19450. if (hasRequiredSourceMapGenerator$2) return sourceMapGenerator$2;
  19451. hasRequiredSourceMapGenerator$2 = 1;
  19452. /*
  19453. * Copyright 2011 Mozilla Foundation and contributors
  19454. * Licensed under the New BSD license. See LICENSE or:
  19455. * http://opensource.org/licenses/BSD-3-Clause
  19456. */
  19457. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$2();
  19458. var util = /*@__PURE__*/ requireUtil$3();
  19459. var ArraySet = /*@__PURE__*/ requireArraySet$2().ArraySet;
  19460. var MappingList = /*@__PURE__*/ requireMappingList$2().MappingList;
  19461. /**
  19462. * An instance of the SourceMapGenerator represents a source map which is
  19463. * being built incrementally. You may pass an object with the following
  19464. * properties:
  19465. *
  19466. * - file: The filename of the generated source.
  19467. * - sourceRoot: A root for all relative URLs in this source map.
  19468. */
  19469. function SourceMapGenerator(aArgs) {
  19470. if (!aArgs) {
  19471. aArgs = {};
  19472. }
  19473. this._file = util.getArg(aArgs, 'file', null);
  19474. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  19475. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  19476. this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
  19477. this._sources = new ArraySet();
  19478. this._names = new ArraySet();
  19479. this._mappings = new MappingList();
  19480. this._sourcesContents = null;
  19481. }
  19482. SourceMapGenerator.prototype._version = 3;
  19483. /**
  19484. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  19485. *
  19486. * @param aSourceMapConsumer The SourceMap.
  19487. */
  19488. SourceMapGenerator.fromSourceMap =
  19489. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  19490. var sourceRoot = aSourceMapConsumer.sourceRoot;
  19491. var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
  19492. file: aSourceMapConsumer.file,
  19493. sourceRoot: sourceRoot
  19494. }));
  19495. aSourceMapConsumer.eachMapping(function (mapping) {
  19496. var newMapping = {
  19497. generated: {
  19498. line: mapping.generatedLine,
  19499. column: mapping.generatedColumn
  19500. }
  19501. };
  19502. if (mapping.source != null) {
  19503. newMapping.source = mapping.source;
  19504. if (sourceRoot != null) {
  19505. newMapping.source = util.relative(sourceRoot, newMapping.source);
  19506. }
  19507. newMapping.original = {
  19508. line: mapping.originalLine,
  19509. column: mapping.originalColumn
  19510. };
  19511. if (mapping.name != null) {
  19512. newMapping.name = mapping.name;
  19513. }
  19514. }
  19515. generator.addMapping(newMapping);
  19516. });
  19517. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19518. var sourceRelative = sourceFile;
  19519. if (sourceRoot !== null) {
  19520. sourceRelative = util.relative(sourceRoot, sourceFile);
  19521. }
  19522. if (!generator._sources.has(sourceRelative)) {
  19523. generator._sources.add(sourceRelative);
  19524. }
  19525. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19526. if (content != null) {
  19527. generator.setSourceContent(sourceFile, content);
  19528. }
  19529. });
  19530. return generator;
  19531. };
  19532. /**
  19533. * Add a single mapping from original source line and column to the generated
  19534. * source's line and column for this source map being created. The mapping
  19535. * object should have the following properties:
  19536. *
  19537. * - generated: An object with the generated line and column positions.
  19538. * - original: An object with the original line and column positions.
  19539. * - source: The original source file (relative to the sourceRoot).
  19540. * - name: An optional original token name for this mapping.
  19541. */
  19542. SourceMapGenerator.prototype.addMapping =
  19543. function SourceMapGenerator_addMapping(aArgs) {
  19544. var generated = util.getArg(aArgs, 'generated');
  19545. var original = util.getArg(aArgs, 'original', null);
  19546. var source = util.getArg(aArgs, 'source', null);
  19547. var name = util.getArg(aArgs, 'name', null);
  19548. if (!this._skipValidation) {
  19549. if (this._validateMapping(generated, original, source, name) === false) {
  19550. return;
  19551. }
  19552. }
  19553. if (source != null) {
  19554. source = String(source);
  19555. if (!this._sources.has(source)) {
  19556. this._sources.add(source);
  19557. }
  19558. }
  19559. if (name != null) {
  19560. name = String(name);
  19561. if (!this._names.has(name)) {
  19562. this._names.add(name);
  19563. }
  19564. }
  19565. this._mappings.add({
  19566. generatedLine: generated.line,
  19567. generatedColumn: generated.column,
  19568. originalLine: original != null && original.line,
  19569. originalColumn: original != null && original.column,
  19570. source: source,
  19571. name: name
  19572. });
  19573. };
  19574. /**
  19575. * Set the source content for a source file.
  19576. */
  19577. SourceMapGenerator.prototype.setSourceContent =
  19578. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  19579. var source = aSourceFile;
  19580. if (this._sourceRoot != null) {
  19581. source = util.relative(this._sourceRoot, source);
  19582. }
  19583. if (aSourceContent != null) {
  19584. // Add the source content to the _sourcesContents map.
  19585. // Create a new _sourcesContents map if the property is null.
  19586. if (!this._sourcesContents) {
  19587. this._sourcesContents = Object.create(null);
  19588. }
  19589. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  19590. } else if (this._sourcesContents) {
  19591. // Remove the source file from the _sourcesContents map.
  19592. // If the _sourcesContents map is empty, set the property to null.
  19593. delete this._sourcesContents[util.toSetString(source)];
  19594. if (Object.keys(this._sourcesContents).length === 0) {
  19595. this._sourcesContents = null;
  19596. }
  19597. }
  19598. };
  19599. /**
  19600. * Applies the mappings of a sub-source-map for a specific source file to the
  19601. * source map being generated. Each mapping to the supplied source file is
  19602. * rewritten using the supplied source map. Note: The resolution for the
  19603. * resulting mappings is the minimium of this map and the supplied map.
  19604. *
  19605. * @param aSourceMapConsumer The source map to be applied.
  19606. * @param aSourceFile Optional. The filename of the source file.
  19607. * If omitted, SourceMapConsumer's file property will be used.
  19608. * @param aSourceMapPath Optional. The dirname of the path to the source map
  19609. * to be applied. If relative, it is relative to the SourceMapConsumer.
  19610. * This parameter is needed when the two source maps aren't in the same
  19611. * directory, and the source map to be applied contains relative source
  19612. * paths. If so, those relative source paths need to be rewritten
  19613. * relative to the SourceMapGenerator.
  19614. */
  19615. SourceMapGenerator.prototype.applySourceMap =
  19616. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  19617. var sourceFile = aSourceFile;
  19618. // If aSourceFile is omitted, we will use the file property of the SourceMap
  19619. if (aSourceFile == null) {
  19620. if (aSourceMapConsumer.file == null) {
  19621. throw new Error(
  19622. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  19623. 'or the source map\'s "file" property. Both were omitted.'
  19624. );
  19625. }
  19626. sourceFile = aSourceMapConsumer.file;
  19627. }
  19628. var sourceRoot = this._sourceRoot;
  19629. // Make "sourceFile" relative if an absolute Url is passed.
  19630. if (sourceRoot != null) {
  19631. sourceFile = util.relative(sourceRoot, sourceFile);
  19632. }
  19633. // Applying the SourceMap can add and remove items from the sources and
  19634. // the names array.
  19635. var newSources = new ArraySet();
  19636. var newNames = new ArraySet();
  19637. // Find mappings for the "sourceFile"
  19638. this._mappings.unsortedForEach(function (mapping) {
  19639. if (mapping.source === sourceFile && mapping.originalLine != null) {
  19640. // Check if it can be mapped by the source map, then update the mapping.
  19641. var original = aSourceMapConsumer.originalPositionFor({
  19642. line: mapping.originalLine,
  19643. column: mapping.originalColumn
  19644. });
  19645. if (original.source != null) {
  19646. // Copy mapping
  19647. mapping.source = original.source;
  19648. if (aSourceMapPath != null) {
  19649. mapping.source = util.join(aSourceMapPath, mapping.source);
  19650. }
  19651. if (sourceRoot != null) {
  19652. mapping.source = util.relative(sourceRoot, mapping.source);
  19653. }
  19654. mapping.originalLine = original.line;
  19655. mapping.originalColumn = original.column;
  19656. if (original.name != null) {
  19657. mapping.name = original.name;
  19658. }
  19659. }
  19660. }
  19661. var source = mapping.source;
  19662. if (source != null && !newSources.has(source)) {
  19663. newSources.add(source);
  19664. }
  19665. var name = mapping.name;
  19666. if (name != null && !newNames.has(name)) {
  19667. newNames.add(name);
  19668. }
  19669. }, this);
  19670. this._sources = newSources;
  19671. this._names = newNames;
  19672. // Copy sourcesContents of applied map.
  19673. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19674. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19675. if (content != null) {
  19676. if (aSourceMapPath != null) {
  19677. sourceFile = util.join(aSourceMapPath, sourceFile);
  19678. }
  19679. if (sourceRoot != null) {
  19680. sourceFile = util.relative(sourceRoot, sourceFile);
  19681. }
  19682. this.setSourceContent(sourceFile, content);
  19683. }
  19684. }, this);
  19685. };
  19686. /**
  19687. * A mapping can have one of the three levels of data:
  19688. *
  19689. * 1. Just the generated position.
  19690. * 2. The Generated position, original position, and original source.
  19691. * 3. Generated and original position, original source, as well as a name
  19692. * token.
  19693. *
  19694. * To maintain consistency, we validate that any new mapping being added falls
  19695. * in to one of these categories.
  19696. */
  19697. SourceMapGenerator.prototype._validateMapping =
  19698. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  19699. aName) {
  19700. // When aOriginal is truthy but has empty values for .line and .column,
  19701. // it is most likely a programmer error. In this case we throw a very
  19702. // specific error message to try to guide them the right way.
  19703. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  19704. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  19705. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  19706. 'the original mapping entirely and only map the generated position. If so, pass ' +
  19707. 'null for the original mapping instead of an object with empty or null values.';
  19708. if (this._ignoreInvalidMapping) {
  19709. if (typeof console !== 'undefined' && console.warn) {
  19710. console.warn(message);
  19711. }
  19712. return false;
  19713. } else {
  19714. throw new Error(message);
  19715. }
  19716. }
  19717. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19718. && aGenerated.line > 0 && aGenerated.column >= 0
  19719. && !aOriginal && !aSource && !aName) {
  19720. // Case 1.
  19721. return;
  19722. }
  19723. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19724. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  19725. && aGenerated.line > 0 && aGenerated.column >= 0
  19726. && aOriginal.line > 0 && aOriginal.column >= 0
  19727. && aSource) {
  19728. // Cases 2 and 3.
  19729. return;
  19730. }
  19731. else {
  19732. var message = 'Invalid mapping: ' + JSON.stringify({
  19733. generated: aGenerated,
  19734. source: aSource,
  19735. original: aOriginal,
  19736. name: aName
  19737. });
  19738. if (this._ignoreInvalidMapping) {
  19739. if (typeof console !== 'undefined' && console.warn) {
  19740. console.warn(message);
  19741. }
  19742. return false;
  19743. } else {
  19744. throw new Error(message)
  19745. }
  19746. }
  19747. };
  19748. /**
  19749. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  19750. * specified by the source map format.
  19751. */
  19752. SourceMapGenerator.prototype._serializeMappings =
  19753. function SourceMapGenerator_serializeMappings() {
  19754. var previousGeneratedColumn = 0;
  19755. var previousGeneratedLine = 1;
  19756. var previousOriginalColumn = 0;
  19757. var previousOriginalLine = 0;
  19758. var previousName = 0;
  19759. var previousSource = 0;
  19760. var result = '';
  19761. var next;
  19762. var mapping;
  19763. var nameIdx;
  19764. var sourceIdx;
  19765. var mappings = this._mappings.toArray();
  19766. for (var i = 0, len = mappings.length; i < len; i++) {
  19767. mapping = mappings[i];
  19768. next = '';
  19769. if (mapping.generatedLine !== previousGeneratedLine) {
  19770. previousGeneratedColumn = 0;
  19771. while (mapping.generatedLine !== previousGeneratedLine) {
  19772. next += ';';
  19773. previousGeneratedLine++;
  19774. }
  19775. }
  19776. else {
  19777. if (i > 0) {
  19778. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  19779. continue;
  19780. }
  19781. next += ',';
  19782. }
  19783. }
  19784. next += base64VLQ.encode(mapping.generatedColumn
  19785. - previousGeneratedColumn);
  19786. previousGeneratedColumn = mapping.generatedColumn;
  19787. if (mapping.source != null) {
  19788. sourceIdx = this._sources.indexOf(mapping.source);
  19789. next += base64VLQ.encode(sourceIdx - previousSource);
  19790. previousSource = sourceIdx;
  19791. // lines are stored 0-based in SourceMap spec version 3
  19792. next += base64VLQ.encode(mapping.originalLine - 1
  19793. - previousOriginalLine);
  19794. previousOriginalLine = mapping.originalLine - 1;
  19795. next += base64VLQ.encode(mapping.originalColumn
  19796. - previousOriginalColumn);
  19797. previousOriginalColumn = mapping.originalColumn;
  19798. if (mapping.name != null) {
  19799. nameIdx = this._names.indexOf(mapping.name);
  19800. next += base64VLQ.encode(nameIdx - previousName);
  19801. previousName = nameIdx;
  19802. }
  19803. }
  19804. result += next;
  19805. }
  19806. return result;
  19807. };
  19808. SourceMapGenerator.prototype._generateSourcesContent =
  19809. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  19810. return aSources.map(function (source) {
  19811. if (!this._sourcesContents) {
  19812. return null;
  19813. }
  19814. if (aSourceRoot != null) {
  19815. source = util.relative(aSourceRoot, source);
  19816. }
  19817. var key = util.toSetString(source);
  19818. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  19819. ? this._sourcesContents[key]
  19820. : null;
  19821. }, this);
  19822. };
  19823. /**
  19824. * Externalize the source map.
  19825. */
  19826. SourceMapGenerator.prototype.toJSON =
  19827. function SourceMapGenerator_toJSON() {
  19828. var map = {
  19829. version: this._version,
  19830. sources: this._sources.toArray(),
  19831. names: this._names.toArray(),
  19832. mappings: this._serializeMappings()
  19833. };
  19834. if (this._file != null) {
  19835. map.file = this._file;
  19836. }
  19837. if (this._sourceRoot != null) {
  19838. map.sourceRoot = this._sourceRoot;
  19839. }
  19840. if (this._sourcesContents) {
  19841. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  19842. }
  19843. return map;
  19844. };
  19845. /**
  19846. * Render the source map being generated to a string.
  19847. */
  19848. SourceMapGenerator.prototype.toString =
  19849. function SourceMapGenerator_toString() {
  19850. return JSON.stringify(this.toJSON());
  19851. };
  19852. sourceMapGenerator$2.SourceMapGenerator = SourceMapGenerator;
  19853. return sourceMapGenerator$2;
  19854. }
  19855. var sourceMapConsumer$2 = {};
  19856. var binarySearch$2 = {};
  19857. /* -*- Mode: js; js-indent-level: 2; -*- */
  19858. var hasRequiredBinarySearch$2;
  19859. function requireBinarySearch$2 () {
  19860. if (hasRequiredBinarySearch$2) return binarySearch$2;
  19861. hasRequiredBinarySearch$2 = 1;
  19862. (function (exports) {
  19863. /*
  19864. * Copyright 2011 Mozilla Foundation and contributors
  19865. * Licensed under the New BSD license. See LICENSE or:
  19866. * http://opensource.org/licenses/BSD-3-Clause
  19867. */
  19868. exports.GREATEST_LOWER_BOUND = 1;
  19869. exports.LEAST_UPPER_BOUND = 2;
  19870. /**
  19871. * Recursive implementation of binary search.
  19872. *
  19873. * @param aLow Indices here and lower do not contain the needle.
  19874. * @param aHigh Indices here and higher do not contain the needle.
  19875. * @param aNeedle The element being searched for.
  19876. * @param aHaystack The non-empty array being searched.
  19877. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  19878. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19879. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19880. * closest element that is smaller than or greater than the one we are
  19881. * searching for, respectively, if the exact element cannot be found.
  19882. */
  19883. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  19884. // This function terminates when one of the following is true:
  19885. //
  19886. // 1. We find the exact element we are looking for.
  19887. //
  19888. // 2. We did not find the exact element, but we can return the index of
  19889. // the next-closest element.
  19890. //
  19891. // 3. We did not find the exact element, and there is no next-closest
  19892. // element than the one we are searching for, so we return -1.
  19893. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  19894. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  19895. if (cmp === 0) {
  19896. // Found the element we are looking for.
  19897. return mid;
  19898. }
  19899. else if (cmp > 0) {
  19900. // Our needle is greater than aHaystack[mid].
  19901. if (aHigh - mid > 1) {
  19902. // The element is in the upper half.
  19903. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  19904. }
  19905. // The exact needle element was not found in this haystack. Determine if
  19906. // we are in termination case (3) or (2) and return the appropriate thing.
  19907. if (aBias == exports.LEAST_UPPER_BOUND) {
  19908. return aHigh < aHaystack.length ? aHigh : -1;
  19909. } else {
  19910. return mid;
  19911. }
  19912. }
  19913. else {
  19914. // Our needle is less than aHaystack[mid].
  19915. if (mid - aLow > 1) {
  19916. // The element is in the lower half.
  19917. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  19918. }
  19919. // we are in termination case (3) or (2) and return the appropriate thing.
  19920. if (aBias == exports.LEAST_UPPER_BOUND) {
  19921. return mid;
  19922. } else {
  19923. return aLow < 0 ? -1 : aLow;
  19924. }
  19925. }
  19926. }
  19927. /**
  19928. * This is an implementation of binary search which will always try and return
  19929. * the index of the closest element if there is no exact hit. This is because
  19930. * mappings between original and generated line/col pairs are single points,
  19931. * and there is an implicit region between each of them, so a miss just means
  19932. * that you aren't on the very start of a region.
  19933. *
  19934. * @param aNeedle The element you are looking for.
  19935. * @param aHaystack The array that is being searched.
  19936. * @param aCompare A function which takes the needle and an element in the
  19937. * array and returns -1, 0, or 1 depending on whether the needle is less
  19938. * than, equal to, or greater than the element, respectively.
  19939. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19940. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19941. * closest element that is smaller than or greater than the one we are
  19942. * searching for, respectively, if the exact element cannot be found.
  19943. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  19944. */
  19945. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  19946. if (aHaystack.length === 0) {
  19947. return -1;
  19948. }
  19949. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  19950. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  19951. if (index < 0) {
  19952. return -1;
  19953. }
  19954. // We have found either the exact element, or the next-closest element than
  19955. // the one we are searching for. However, there may be more than one such
  19956. // element. Make sure we always return the smallest of these.
  19957. while (index - 1 >= 0) {
  19958. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  19959. break;
  19960. }
  19961. --index;
  19962. }
  19963. return index;
  19964. };
  19965. } (binarySearch$2));
  19966. return binarySearch$2;
  19967. }
  19968. var quickSort$2 = {};
  19969. /* -*- Mode: js; js-indent-level: 2; -*- */
  19970. var hasRequiredQuickSort$2;
  19971. function requireQuickSort$2 () {
  19972. if (hasRequiredQuickSort$2) return quickSort$2;
  19973. hasRequiredQuickSort$2 = 1;
  19974. /*
  19975. * Copyright 2011 Mozilla Foundation and contributors
  19976. * Licensed under the New BSD license. See LICENSE or:
  19977. * http://opensource.org/licenses/BSD-3-Clause
  19978. */
  19979. // It turns out that some (most?) JavaScript engines don't self-host
  19980. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  19981. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  19982. // custom comparator function, calling back and forth between the VM's C++ and
  19983. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  19984. // worse generated code for the comparator function than would be optimal. In
  19985. // fact, when sorting with a comparator, these costs outweigh the benefits of
  19986. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  19987. // a ~3500ms mean speed-up in `bench/bench.html`.
  19988. function SortTemplate(comparator) {
  19989. /**
  19990. * Swap the elements indexed by `x` and `y` in the array `ary`.
  19991. *
  19992. * @param {Array} ary
  19993. * The array.
  19994. * @param {Number} x
  19995. * The index of the first item.
  19996. * @param {Number} y
  19997. * The index of the second item.
  19998. */
  19999. function swap(ary, x, y) {
  20000. var temp = ary[x];
  20001. ary[x] = ary[y];
  20002. ary[y] = temp;
  20003. }
  20004. /**
  20005. * Returns a random integer within the range `low .. high` inclusive.
  20006. *
  20007. * @param {Number} low
  20008. * The lower bound on the range.
  20009. * @param {Number} high
  20010. * The upper bound on the range.
  20011. */
  20012. function randomIntInRange(low, high) {
  20013. return Math.round(low + (Math.random() * (high - low)));
  20014. }
  20015. /**
  20016. * The Quick Sort algorithm.
  20017. *
  20018. * @param {Array} ary
  20019. * An array to sort.
  20020. * @param {function} comparator
  20021. * Function to use to compare two items.
  20022. * @param {Number} p
  20023. * Start index of the array
  20024. * @param {Number} r
  20025. * End index of the array
  20026. */
  20027. function doQuickSort(ary, comparator, p, r) {
  20028. // If our lower bound is less than our upper bound, we (1) partition the
  20029. // array into two pieces and (2) recurse on each half. If it is not, this is
  20030. // the empty array and our base case.
  20031. if (p < r) {
  20032. // (1) Partitioning.
  20033. //
  20034. // The partitioning chooses a pivot between `p` and `r` and moves all
  20035. // elements that are less than or equal to the pivot to the before it, and
  20036. // all the elements that are greater than it after it. The effect is that
  20037. // once partition is done, the pivot is in the exact place it will be when
  20038. // the array is put in sorted order, and it will not need to be moved
  20039. // again. This runs in O(n) time.
  20040. // Always choose a random pivot so that an input array which is reverse
  20041. // sorted does not cause O(n^2) running time.
  20042. var pivotIndex = randomIntInRange(p, r);
  20043. var i = p - 1;
  20044. swap(ary, pivotIndex, r);
  20045. var pivot = ary[r];
  20046. // Immediately after `j` is incremented in this loop, the following hold
  20047. // true:
  20048. //
  20049. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  20050. //
  20051. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  20052. for (var j = p; j < r; j++) {
  20053. if (comparator(ary[j], pivot, false) <= 0) {
  20054. i += 1;
  20055. swap(ary, i, j);
  20056. }
  20057. }
  20058. swap(ary, i + 1, j);
  20059. var q = i + 1;
  20060. // (2) Recurse on each half.
  20061. doQuickSort(ary, comparator, p, q - 1);
  20062. doQuickSort(ary, comparator, q + 1, r);
  20063. }
  20064. }
  20065. return doQuickSort;
  20066. }
  20067. function cloneSort(comparator) {
  20068. let template = SortTemplate.toString();
  20069. let templateFn = new Function(`return ${template}`)();
  20070. return templateFn(comparator);
  20071. }
  20072. /**
  20073. * Sort the given array in-place with the given comparator function.
  20074. *
  20075. * @param {Array} ary
  20076. * An array to sort.
  20077. * @param {function} comparator
  20078. * Function to use to compare two items.
  20079. */
  20080. let sortCache = new WeakMap();
  20081. quickSort$2.quickSort = function (ary, comparator, start = 0) {
  20082. let doQuickSort = sortCache.get(comparator);
  20083. if (doQuickSort === void 0) {
  20084. doQuickSort = cloneSort(comparator);
  20085. sortCache.set(comparator, doQuickSort);
  20086. }
  20087. doQuickSort(ary, comparator, start, ary.length - 1);
  20088. };
  20089. return quickSort$2;
  20090. }
  20091. /* -*- Mode: js; js-indent-level: 2; -*- */
  20092. var hasRequiredSourceMapConsumer$2;
  20093. function requireSourceMapConsumer$2 () {
  20094. if (hasRequiredSourceMapConsumer$2) return sourceMapConsumer$2;
  20095. hasRequiredSourceMapConsumer$2 = 1;
  20096. /*
  20097. * Copyright 2011 Mozilla Foundation and contributors
  20098. * Licensed under the New BSD license. See LICENSE or:
  20099. * http://opensource.org/licenses/BSD-3-Clause
  20100. */
  20101. var util = /*@__PURE__*/ requireUtil$3();
  20102. var binarySearch = /*@__PURE__*/ requireBinarySearch$2();
  20103. var ArraySet = /*@__PURE__*/ requireArraySet$2().ArraySet;
  20104. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$2();
  20105. var quickSort = /*@__PURE__*/ requireQuickSort$2().quickSort;
  20106. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  20107. var sourceMap = aSourceMap;
  20108. if (typeof aSourceMap === 'string') {
  20109. sourceMap = util.parseSourceMapInput(aSourceMap);
  20110. }
  20111. return sourceMap.sections != null
  20112. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  20113. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  20114. }
  20115. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  20116. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  20117. };
  20118. /**
  20119. * The version of the source mapping spec that we are consuming.
  20120. */
  20121. SourceMapConsumer.prototype._version = 3;
  20122. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  20123. // parsed mapping coordinates from the source map's "mappings" attribute. They
  20124. // are lazily instantiated, accessed via the `_generatedMappings` and
  20125. // `_originalMappings` getters respectively, and we only parse the mappings
  20126. // and create these arrays once queried for a source location. We jump through
  20127. // these hoops because there can be many thousands of mappings, and parsing
  20128. // them is expensive, so we only want to do it if we must.
  20129. //
  20130. // Each object in the arrays is of the form:
  20131. //
  20132. // {
  20133. // generatedLine: The line number in the generated code,
  20134. // generatedColumn: The column number in the generated code,
  20135. // source: The path to the original source file that generated this
  20136. // chunk of code,
  20137. // originalLine: The line number in the original source that
  20138. // corresponds to this chunk of generated code,
  20139. // originalColumn: The column number in the original source that
  20140. // corresponds to this chunk of generated code,
  20141. // name: The name of the original symbol which generated this chunk of
  20142. // code.
  20143. // }
  20144. //
  20145. // All properties except for `generatedLine` and `generatedColumn` can be
  20146. // `null`.
  20147. //
  20148. // `_generatedMappings` is ordered by the generated positions.
  20149. //
  20150. // `_originalMappings` is ordered by the original positions.
  20151. SourceMapConsumer.prototype.__generatedMappings = null;
  20152. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  20153. configurable: true,
  20154. enumerable: true,
  20155. get: function () {
  20156. if (!this.__generatedMappings) {
  20157. this._parseMappings(this._mappings, this.sourceRoot);
  20158. }
  20159. return this.__generatedMappings;
  20160. }
  20161. });
  20162. SourceMapConsumer.prototype.__originalMappings = null;
  20163. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  20164. configurable: true,
  20165. enumerable: true,
  20166. get: function () {
  20167. if (!this.__originalMappings) {
  20168. this._parseMappings(this._mappings, this.sourceRoot);
  20169. }
  20170. return this.__originalMappings;
  20171. }
  20172. });
  20173. SourceMapConsumer.prototype._charIsMappingSeparator =
  20174. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  20175. var c = aStr.charAt(index);
  20176. return c === ";" || c === ",";
  20177. };
  20178. /**
  20179. * Parse the mappings in a string in to a data structure which we can easily
  20180. * query (the ordered arrays in the `this.__generatedMappings` and
  20181. * `this.__originalMappings` properties).
  20182. */
  20183. SourceMapConsumer.prototype._parseMappings =
  20184. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20185. throw new Error("Subclasses must implement _parseMappings");
  20186. };
  20187. SourceMapConsumer.GENERATED_ORDER = 1;
  20188. SourceMapConsumer.ORIGINAL_ORDER = 2;
  20189. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  20190. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  20191. /**
  20192. * Iterate over each mapping between an original source/line/column and a
  20193. * generated line/column in this source map.
  20194. *
  20195. * @param Function aCallback
  20196. * The function that is called with each mapping.
  20197. * @param Object aContext
  20198. * Optional. If specified, this object will be the value of `this` every
  20199. * time that `aCallback` is called.
  20200. * @param aOrder
  20201. * Either `SourceMapConsumer.GENERATED_ORDER` or
  20202. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  20203. * iterate over the mappings sorted by the generated file's line/column
  20204. * order or the original's source/line/column order, respectively. Defaults to
  20205. * `SourceMapConsumer.GENERATED_ORDER`.
  20206. */
  20207. SourceMapConsumer.prototype.eachMapping =
  20208. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  20209. var context = aContext || null;
  20210. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  20211. var mappings;
  20212. switch (order) {
  20213. case SourceMapConsumer.GENERATED_ORDER:
  20214. mappings = this._generatedMappings;
  20215. break;
  20216. case SourceMapConsumer.ORIGINAL_ORDER:
  20217. mappings = this._originalMappings;
  20218. break;
  20219. default:
  20220. throw new Error("Unknown order of iteration.");
  20221. }
  20222. var sourceRoot = this.sourceRoot;
  20223. var boundCallback = aCallback.bind(context);
  20224. var names = this._names;
  20225. var sources = this._sources;
  20226. var sourceMapURL = this._sourceMapURL;
  20227. for (var i = 0, n = mappings.length; i < n; i++) {
  20228. var mapping = mappings[i];
  20229. var source = mapping.source === null ? null : sources.at(mapping.source);
  20230. source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
  20231. boundCallback({
  20232. source: source,
  20233. generatedLine: mapping.generatedLine,
  20234. generatedColumn: mapping.generatedColumn,
  20235. originalLine: mapping.originalLine,
  20236. originalColumn: mapping.originalColumn,
  20237. name: mapping.name === null ? null : names.at(mapping.name)
  20238. });
  20239. }
  20240. };
  20241. /**
  20242. * Returns all generated line and column information for the original source,
  20243. * line, and column provided. If no column is provided, returns all mappings
  20244. * corresponding to a either the line we are searching for or the next
  20245. * closest line that has any mappings. Otherwise, returns all mappings
  20246. * corresponding to the given line and either the column we are searching for
  20247. * or the next closest column that has any offsets.
  20248. *
  20249. * The only argument is an object with the following properties:
  20250. *
  20251. * - source: The filename of the original source.
  20252. * - line: The line number in the original source. The line number is 1-based.
  20253. * - column: Optional. the column number in the original source.
  20254. * The column number is 0-based.
  20255. *
  20256. * and an array of objects is returned, each with the following properties:
  20257. *
  20258. * - line: The line number in the generated source, or null. The
  20259. * line number is 1-based.
  20260. * - column: The column number in the generated source, or null.
  20261. * The column number is 0-based.
  20262. */
  20263. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  20264. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  20265. var line = util.getArg(aArgs, 'line');
  20266. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  20267. // returns the index of the closest mapping less than the needle. By
  20268. // setting needle.originalColumn to 0, we thus find the last mapping for
  20269. // the given line, provided such a mapping exists.
  20270. var needle = {
  20271. source: util.getArg(aArgs, 'source'),
  20272. originalLine: line,
  20273. originalColumn: util.getArg(aArgs, 'column', 0)
  20274. };
  20275. needle.source = this._findSourceIndex(needle.source);
  20276. if (needle.source < 0) {
  20277. return [];
  20278. }
  20279. var mappings = [];
  20280. var index = this._findMapping(needle,
  20281. this._originalMappings,
  20282. "originalLine",
  20283. "originalColumn",
  20284. util.compareByOriginalPositions,
  20285. binarySearch.LEAST_UPPER_BOUND);
  20286. if (index >= 0) {
  20287. var mapping = this._originalMappings[index];
  20288. if (aArgs.column === undefined) {
  20289. var originalLine = mapping.originalLine;
  20290. // Iterate until either we run out of mappings, or we run into
  20291. // a mapping for a different line than the one we found. Since
  20292. // mappings are sorted, this is guaranteed to find all mappings for
  20293. // the line we found.
  20294. while (mapping && mapping.originalLine === originalLine) {
  20295. mappings.push({
  20296. line: util.getArg(mapping, 'generatedLine', null),
  20297. column: util.getArg(mapping, 'generatedColumn', null),
  20298. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20299. });
  20300. mapping = this._originalMappings[++index];
  20301. }
  20302. } else {
  20303. var originalColumn = mapping.originalColumn;
  20304. // Iterate until either we run out of mappings, or we run into
  20305. // a mapping for a different line than the one we were searching for.
  20306. // Since mappings are sorted, this is guaranteed to find all mappings for
  20307. // the line we are searching for.
  20308. while (mapping &&
  20309. mapping.originalLine === line &&
  20310. mapping.originalColumn == originalColumn) {
  20311. mappings.push({
  20312. line: util.getArg(mapping, 'generatedLine', null),
  20313. column: util.getArg(mapping, 'generatedColumn', null),
  20314. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20315. });
  20316. mapping = this._originalMappings[++index];
  20317. }
  20318. }
  20319. }
  20320. return mappings;
  20321. };
  20322. sourceMapConsumer$2.SourceMapConsumer = SourceMapConsumer;
  20323. /**
  20324. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20325. * query for information about the original file positions by giving it a file
  20326. * position in the generated source.
  20327. *
  20328. * The first parameter is the raw source map (either as a JSON string, or
  20329. * already parsed to an object). According to the spec, source maps have the
  20330. * following attributes:
  20331. *
  20332. * - version: Which version of the source map spec this map is following.
  20333. * - sources: An array of URLs to the original source files.
  20334. * - names: An array of identifiers which can be referrenced by individual mappings.
  20335. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20336. * - sourcesContent: Optional. An array of contents of the original source files.
  20337. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20338. * - file: Optional. The generated file this source map is associated with.
  20339. *
  20340. * Here is an example source map, taken from the source map spec[0]:
  20341. *
  20342. * {
  20343. * version : 3,
  20344. * file: "out.js",
  20345. * sourceRoot : "",
  20346. * sources: ["foo.js", "bar.js"],
  20347. * names: ["src", "maps", "are", "fun"],
  20348. * mappings: "AA,AB;;ABCDE;"
  20349. * }
  20350. *
  20351. * The second parameter, if given, is a string whose value is the URL
  20352. * at which the source map was found. This URL is used to compute the
  20353. * sources array.
  20354. *
  20355. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  20356. */
  20357. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  20358. var sourceMap = aSourceMap;
  20359. if (typeof aSourceMap === 'string') {
  20360. sourceMap = util.parseSourceMapInput(aSourceMap);
  20361. }
  20362. var version = util.getArg(sourceMap, 'version');
  20363. var sources = util.getArg(sourceMap, 'sources');
  20364. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  20365. // requires the array) to play nice here.
  20366. var names = util.getArg(sourceMap, 'names', []);
  20367. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  20368. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  20369. var mappings = util.getArg(sourceMap, 'mappings');
  20370. var file = util.getArg(sourceMap, 'file', null);
  20371. // Once again, Sass deviates from the spec and supplies the version as a
  20372. // string rather than a number, so we use loose equality checking here.
  20373. if (version != this._version) {
  20374. throw new Error('Unsupported version: ' + version);
  20375. }
  20376. if (sourceRoot) {
  20377. sourceRoot = util.normalize(sourceRoot);
  20378. }
  20379. sources = sources
  20380. .map(String)
  20381. // Some source maps produce relative source paths like "./foo.js" instead of
  20382. // "foo.js". Normalize these first so that future comparisons will succeed.
  20383. // See bugzil.la/1090768.
  20384. .map(util.normalize)
  20385. // Always ensure that absolute sources are internally stored relative to
  20386. // the source root, if the source root is absolute. Not doing this would
  20387. // be particularly problematic when the source root is a prefix of the
  20388. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  20389. .map(function (source) {
  20390. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  20391. ? util.relative(sourceRoot, source)
  20392. : source;
  20393. });
  20394. // Pass `true` below to allow duplicate names and sources. While source maps
  20395. // are intended to be compressed and deduplicated, the TypeScript compiler
  20396. // sometimes generates source maps with duplicates in them. See Github issue
  20397. // #72 and bugzil.la/889492.
  20398. this._names = ArraySet.fromArray(names.map(String), true);
  20399. this._sources = ArraySet.fromArray(sources, true);
  20400. this._absoluteSources = this._sources.toArray().map(function (s) {
  20401. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  20402. });
  20403. this.sourceRoot = sourceRoot;
  20404. this.sourcesContent = sourcesContent;
  20405. this._mappings = mappings;
  20406. this._sourceMapURL = aSourceMapURL;
  20407. this.file = file;
  20408. }
  20409. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  20410. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  20411. /**
  20412. * Utility function to find the index of a source. Returns -1 if not
  20413. * found.
  20414. */
  20415. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  20416. var relativeSource = aSource;
  20417. if (this.sourceRoot != null) {
  20418. relativeSource = util.relative(this.sourceRoot, relativeSource);
  20419. }
  20420. if (this._sources.has(relativeSource)) {
  20421. return this._sources.indexOf(relativeSource);
  20422. }
  20423. // Maybe aSource is an absolute URL as returned by |sources|. In
  20424. // this case we can't simply undo the transform.
  20425. var i;
  20426. for (i = 0; i < this._absoluteSources.length; ++i) {
  20427. if (this._absoluteSources[i] == aSource) {
  20428. return i;
  20429. }
  20430. }
  20431. return -1;
  20432. };
  20433. /**
  20434. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  20435. *
  20436. * @param SourceMapGenerator aSourceMap
  20437. * The source map that will be consumed.
  20438. * @param String aSourceMapURL
  20439. * The URL at which the source map can be found (optional)
  20440. * @returns BasicSourceMapConsumer
  20441. */
  20442. BasicSourceMapConsumer.fromSourceMap =
  20443. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  20444. var smc = Object.create(BasicSourceMapConsumer.prototype);
  20445. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  20446. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  20447. smc.sourceRoot = aSourceMap._sourceRoot;
  20448. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  20449. smc.sourceRoot);
  20450. smc.file = aSourceMap._file;
  20451. smc._sourceMapURL = aSourceMapURL;
  20452. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  20453. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  20454. });
  20455. // Because we are modifying the entries (by converting string sources and
  20456. // names to indices into the sources and names ArraySets), we have to make
  20457. // a copy of the entry or else bad things happen. Shared mutable state
  20458. // strikes again! See github issue #191.
  20459. var generatedMappings = aSourceMap._mappings.toArray().slice();
  20460. var destGeneratedMappings = smc.__generatedMappings = [];
  20461. var destOriginalMappings = smc.__originalMappings = [];
  20462. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  20463. var srcMapping = generatedMappings[i];
  20464. var destMapping = new Mapping;
  20465. destMapping.generatedLine = srcMapping.generatedLine;
  20466. destMapping.generatedColumn = srcMapping.generatedColumn;
  20467. if (srcMapping.source) {
  20468. destMapping.source = sources.indexOf(srcMapping.source);
  20469. destMapping.originalLine = srcMapping.originalLine;
  20470. destMapping.originalColumn = srcMapping.originalColumn;
  20471. if (srcMapping.name) {
  20472. destMapping.name = names.indexOf(srcMapping.name);
  20473. }
  20474. destOriginalMappings.push(destMapping);
  20475. }
  20476. destGeneratedMappings.push(destMapping);
  20477. }
  20478. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  20479. return smc;
  20480. };
  20481. /**
  20482. * The version of the source mapping spec that we are consuming.
  20483. */
  20484. BasicSourceMapConsumer.prototype._version = 3;
  20485. /**
  20486. * The list of original sources.
  20487. */
  20488. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  20489. get: function () {
  20490. return this._absoluteSources.slice();
  20491. }
  20492. });
  20493. /**
  20494. * Provide the JIT with a nice shape / hidden class.
  20495. */
  20496. function Mapping() {
  20497. this.generatedLine = 0;
  20498. this.generatedColumn = 0;
  20499. this.source = null;
  20500. this.originalLine = null;
  20501. this.originalColumn = null;
  20502. this.name = null;
  20503. }
  20504. /**
  20505. * Parse the mappings in a string in to a data structure which we can easily
  20506. * query (the ordered arrays in the `this.__generatedMappings` and
  20507. * `this.__originalMappings` properties).
  20508. */
  20509. const compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
  20510. function sortGenerated(array, start) {
  20511. let l = array.length;
  20512. let n = array.length - start;
  20513. if (n <= 1) {
  20514. return;
  20515. } else if (n == 2) {
  20516. let a = array[start];
  20517. let b = array[start + 1];
  20518. if (compareGenerated(a, b) > 0) {
  20519. array[start] = b;
  20520. array[start + 1] = a;
  20521. }
  20522. } else if (n < 20) {
  20523. for (let i = start; i < l; i++) {
  20524. for (let j = i; j > start; j--) {
  20525. let a = array[j - 1];
  20526. let b = array[j];
  20527. if (compareGenerated(a, b) <= 0) {
  20528. break;
  20529. }
  20530. array[j - 1] = b;
  20531. array[j] = a;
  20532. }
  20533. }
  20534. } else {
  20535. quickSort(array, compareGenerated, start);
  20536. }
  20537. }
  20538. BasicSourceMapConsumer.prototype._parseMappings =
  20539. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20540. var generatedLine = 1;
  20541. var previousGeneratedColumn = 0;
  20542. var previousOriginalLine = 0;
  20543. var previousOriginalColumn = 0;
  20544. var previousSource = 0;
  20545. var previousName = 0;
  20546. var length = aStr.length;
  20547. var index = 0;
  20548. var temp = {};
  20549. var originalMappings = [];
  20550. var generatedMappings = [];
  20551. var mapping, segment, end, value;
  20552. let subarrayStart = 0;
  20553. while (index < length) {
  20554. if (aStr.charAt(index) === ';') {
  20555. generatedLine++;
  20556. index++;
  20557. previousGeneratedColumn = 0;
  20558. sortGenerated(generatedMappings, subarrayStart);
  20559. subarrayStart = generatedMappings.length;
  20560. }
  20561. else if (aStr.charAt(index) === ',') {
  20562. index++;
  20563. }
  20564. else {
  20565. mapping = new Mapping();
  20566. mapping.generatedLine = generatedLine;
  20567. for (end = index; end < length; end++) {
  20568. if (this._charIsMappingSeparator(aStr, end)) {
  20569. break;
  20570. }
  20571. }
  20572. aStr.slice(index, end);
  20573. segment = [];
  20574. while (index < end) {
  20575. base64VLQ.decode(aStr, index, temp);
  20576. value = temp.value;
  20577. index = temp.rest;
  20578. segment.push(value);
  20579. }
  20580. if (segment.length === 2) {
  20581. throw new Error('Found a source, but no line and column');
  20582. }
  20583. if (segment.length === 3) {
  20584. throw new Error('Found a source and line, but no column');
  20585. }
  20586. // Generated column.
  20587. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  20588. previousGeneratedColumn = mapping.generatedColumn;
  20589. if (segment.length > 1) {
  20590. // Original source.
  20591. mapping.source = previousSource + segment[1];
  20592. previousSource += segment[1];
  20593. // Original line.
  20594. mapping.originalLine = previousOriginalLine + segment[2];
  20595. previousOriginalLine = mapping.originalLine;
  20596. // Lines are stored 0-based
  20597. mapping.originalLine += 1;
  20598. // Original column.
  20599. mapping.originalColumn = previousOriginalColumn + segment[3];
  20600. previousOriginalColumn = mapping.originalColumn;
  20601. if (segment.length > 4) {
  20602. // Original name.
  20603. mapping.name = previousName + segment[4];
  20604. previousName += segment[4];
  20605. }
  20606. }
  20607. generatedMappings.push(mapping);
  20608. if (typeof mapping.originalLine === 'number') {
  20609. let currentSource = mapping.source;
  20610. while (originalMappings.length <= currentSource) {
  20611. originalMappings.push(null);
  20612. }
  20613. if (originalMappings[currentSource] === null) {
  20614. originalMappings[currentSource] = [];
  20615. }
  20616. originalMappings[currentSource].push(mapping);
  20617. }
  20618. }
  20619. }
  20620. sortGenerated(generatedMappings, subarrayStart);
  20621. this.__generatedMappings = generatedMappings;
  20622. for (var i = 0; i < originalMappings.length; i++) {
  20623. if (originalMappings[i] != null) {
  20624. quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
  20625. }
  20626. }
  20627. this.__originalMappings = [].concat(...originalMappings);
  20628. };
  20629. /**
  20630. * Find the mapping that best matches the hypothetical "needle" mapping that
  20631. * we are searching for in the given "haystack" of mappings.
  20632. */
  20633. BasicSourceMapConsumer.prototype._findMapping =
  20634. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  20635. aColumnName, aComparator, aBias) {
  20636. // To return the position we are searching for, we must first find the
  20637. // mapping for the given position and then return the opposite position it
  20638. // points to. Because the mappings are sorted, we can use binary search to
  20639. // find the best mapping.
  20640. if (aNeedle[aLineName] <= 0) {
  20641. throw new TypeError('Line must be greater than or equal to 1, got '
  20642. + aNeedle[aLineName]);
  20643. }
  20644. if (aNeedle[aColumnName] < 0) {
  20645. throw new TypeError('Column must be greater than or equal to 0, got '
  20646. + aNeedle[aColumnName]);
  20647. }
  20648. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  20649. };
  20650. /**
  20651. * Compute the last column for each generated mapping. The last column is
  20652. * inclusive.
  20653. */
  20654. BasicSourceMapConsumer.prototype.computeColumnSpans =
  20655. function SourceMapConsumer_computeColumnSpans() {
  20656. for (var index = 0; index < this._generatedMappings.length; ++index) {
  20657. var mapping = this._generatedMappings[index];
  20658. // Mappings do not contain a field for the last generated columnt. We
  20659. // can come up with an optimistic estimate, however, by assuming that
  20660. // mappings are contiguous (i.e. given two consecutive mappings, the
  20661. // first mapping ends where the second one starts).
  20662. if (index + 1 < this._generatedMappings.length) {
  20663. var nextMapping = this._generatedMappings[index + 1];
  20664. if (mapping.generatedLine === nextMapping.generatedLine) {
  20665. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  20666. continue;
  20667. }
  20668. }
  20669. // The last mapping for each line spans the entire line.
  20670. mapping.lastGeneratedColumn = Infinity;
  20671. }
  20672. };
  20673. /**
  20674. * Returns the original source, line, and column information for the generated
  20675. * source's line and column positions provided. The only argument is an object
  20676. * with the following properties:
  20677. *
  20678. * - line: The line number in the generated source. The line number
  20679. * is 1-based.
  20680. * - column: The column number in the generated source. The column
  20681. * number is 0-based.
  20682. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20683. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20684. * closest element that is smaller than or greater than the one we are
  20685. * searching for, respectively, if the exact element cannot be found.
  20686. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20687. *
  20688. * and an object is returned with the following properties:
  20689. *
  20690. * - source: The original source file, or null.
  20691. * - line: The line number in the original source, or null. The
  20692. * line number is 1-based.
  20693. * - column: The column number in the original source, or null. The
  20694. * column number is 0-based.
  20695. * - name: The original identifier, or null.
  20696. */
  20697. BasicSourceMapConsumer.prototype.originalPositionFor =
  20698. function SourceMapConsumer_originalPositionFor(aArgs) {
  20699. var needle = {
  20700. generatedLine: util.getArg(aArgs, 'line'),
  20701. generatedColumn: util.getArg(aArgs, 'column')
  20702. };
  20703. var index = this._findMapping(
  20704. needle,
  20705. this._generatedMappings,
  20706. "generatedLine",
  20707. "generatedColumn",
  20708. util.compareByGeneratedPositionsDeflated,
  20709. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  20710. );
  20711. if (index >= 0) {
  20712. var mapping = this._generatedMappings[index];
  20713. if (mapping.generatedLine === needle.generatedLine) {
  20714. var source = util.getArg(mapping, 'source', null);
  20715. if (source !== null) {
  20716. source = this._sources.at(source);
  20717. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  20718. }
  20719. var name = util.getArg(mapping, 'name', null);
  20720. if (name !== null) {
  20721. name = this._names.at(name);
  20722. }
  20723. return {
  20724. source: source,
  20725. line: util.getArg(mapping, 'originalLine', null),
  20726. column: util.getArg(mapping, 'originalColumn', null),
  20727. name: name
  20728. };
  20729. }
  20730. }
  20731. return {
  20732. source: null,
  20733. line: null,
  20734. column: null,
  20735. name: null
  20736. };
  20737. };
  20738. /**
  20739. * Return true if we have the source content for every source in the source
  20740. * map, false otherwise.
  20741. */
  20742. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  20743. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  20744. if (!this.sourcesContent) {
  20745. return false;
  20746. }
  20747. return this.sourcesContent.length >= this._sources.size() &&
  20748. !this.sourcesContent.some(function (sc) { return sc == null; });
  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. BasicSourceMapConsumer.prototype.sourceContentFor =
  20756. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20757. if (!this.sourcesContent) {
  20758. return null;
  20759. }
  20760. var index = this._findSourceIndex(aSource);
  20761. if (index >= 0) {
  20762. return this.sourcesContent[index];
  20763. }
  20764. var relativeSource = aSource;
  20765. if (this.sourceRoot != null) {
  20766. relativeSource = util.relative(this.sourceRoot, relativeSource);
  20767. }
  20768. var url;
  20769. if (this.sourceRoot != null
  20770. && (url = util.urlParse(this.sourceRoot))) {
  20771. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  20772. // many users. We can help them out when they expect file:// URIs to
  20773. // behave like it would if they were running a local HTTP server. See
  20774. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  20775. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  20776. if (url.scheme == "file"
  20777. && this._sources.has(fileUriAbsPath)) {
  20778. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  20779. }
  20780. if ((!url.path || url.path == "/")
  20781. && this._sources.has("/" + relativeSource)) {
  20782. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  20783. }
  20784. }
  20785. // This function is used recursively from
  20786. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  20787. // don't want to throw if we can't find the source - we just want to
  20788. // return null, so we provide a flag to exit gracefully.
  20789. if (nullOnMissing) {
  20790. return null;
  20791. }
  20792. else {
  20793. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  20794. }
  20795. };
  20796. /**
  20797. * Returns the generated line and column information for the original source,
  20798. * line, and column positions provided. The only argument is an object with
  20799. * the following properties:
  20800. *
  20801. * - source: The filename of the original source.
  20802. * - line: The line number in the original source. The line number
  20803. * is 1-based.
  20804. * - column: The column number in the original source. The column
  20805. * number is 0-based.
  20806. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20807. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20808. * closest element that is smaller than or greater than the one we are
  20809. * searching for, respectively, if the exact element cannot be found.
  20810. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20811. *
  20812. * and an object is returned with the following properties:
  20813. *
  20814. * - line: The line number in the generated source, or null. The
  20815. * line number is 1-based.
  20816. * - column: The column number in the generated source, or null.
  20817. * The column number is 0-based.
  20818. */
  20819. BasicSourceMapConsumer.prototype.generatedPositionFor =
  20820. function SourceMapConsumer_generatedPositionFor(aArgs) {
  20821. var source = util.getArg(aArgs, 'source');
  20822. source = this._findSourceIndex(source);
  20823. if (source < 0) {
  20824. return {
  20825. line: null,
  20826. column: null,
  20827. lastColumn: null
  20828. };
  20829. }
  20830. var needle = {
  20831. source: source,
  20832. originalLine: util.getArg(aArgs, 'line'),
  20833. originalColumn: util.getArg(aArgs, 'column')
  20834. };
  20835. var index = this._findMapping(
  20836. needle,
  20837. this._originalMappings,
  20838. "originalLine",
  20839. "originalColumn",
  20840. util.compareByOriginalPositions,
  20841. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  20842. );
  20843. if (index >= 0) {
  20844. var mapping = this._originalMappings[index];
  20845. if (mapping.source === needle.source) {
  20846. return {
  20847. line: util.getArg(mapping, 'generatedLine', null),
  20848. column: util.getArg(mapping, 'generatedColumn', null),
  20849. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20850. };
  20851. }
  20852. }
  20853. return {
  20854. line: null,
  20855. column: null,
  20856. lastColumn: null
  20857. };
  20858. };
  20859. sourceMapConsumer$2.BasicSourceMapConsumer = BasicSourceMapConsumer;
  20860. /**
  20861. * An IndexedSourceMapConsumer instance represents a parsed source map which
  20862. * we can query for information. It differs from BasicSourceMapConsumer in
  20863. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  20864. * input.
  20865. *
  20866. * The first parameter is a raw source map (either as a JSON string, or already
  20867. * parsed to an object). According to the spec for indexed source maps, they
  20868. * have the following attributes:
  20869. *
  20870. * - version: Which version of the source map spec this map is following.
  20871. * - file: Optional. The generated file this source map is associated with.
  20872. * - sections: A list of section definitions.
  20873. *
  20874. * Each value under the "sections" field has two fields:
  20875. * - offset: The offset into the original specified at which this section
  20876. * begins to apply, defined as an object with a "line" and "column"
  20877. * field.
  20878. * - map: A source map definition. This source map could also be indexed,
  20879. * but doesn't have to be.
  20880. *
  20881. * Instead of the "map" field, it's also possible to have a "url" field
  20882. * specifying a URL to retrieve a source map from, but that's currently
  20883. * unsupported.
  20884. *
  20885. * Here's an example source map, taken from the source map spec[0], but
  20886. * modified to omit a section which uses the "url" field.
  20887. *
  20888. * {
  20889. * version : 3,
  20890. * file: "app.js",
  20891. * sections: [{
  20892. * offset: {line:100, column:10},
  20893. * map: {
  20894. * version : 3,
  20895. * file: "section.js",
  20896. * sources: ["foo.js", "bar.js"],
  20897. * names: ["src", "maps", "are", "fun"],
  20898. * mappings: "AAAA,E;;ABCDE;"
  20899. * }
  20900. * }],
  20901. * }
  20902. *
  20903. * The second parameter, if given, is a string whose value is the URL
  20904. * at which the source map was found. This URL is used to compute the
  20905. * sources array.
  20906. *
  20907. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  20908. */
  20909. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  20910. var sourceMap = aSourceMap;
  20911. if (typeof aSourceMap === 'string') {
  20912. sourceMap = util.parseSourceMapInput(aSourceMap);
  20913. }
  20914. var version = util.getArg(sourceMap, 'version');
  20915. var sections = util.getArg(sourceMap, 'sections');
  20916. if (version != this._version) {
  20917. throw new Error('Unsupported version: ' + version);
  20918. }
  20919. this._sources = new ArraySet();
  20920. this._names = new ArraySet();
  20921. var lastOffset = {
  20922. line: -1,
  20923. column: 0
  20924. };
  20925. this._sections = sections.map(function (s) {
  20926. if (s.url) {
  20927. // The url field will require support for asynchronicity.
  20928. // See https://github.com/mozilla/source-map/issues/16
  20929. throw new Error('Support for url field in sections not implemented.');
  20930. }
  20931. var offset = util.getArg(s, 'offset');
  20932. var offsetLine = util.getArg(offset, 'line');
  20933. var offsetColumn = util.getArg(offset, 'column');
  20934. if (offsetLine < lastOffset.line ||
  20935. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  20936. throw new Error('Section offsets must be ordered and non-overlapping.');
  20937. }
  20938. lastOffset = offset;
  20939. return {
  20940. generatedOffset: {
  20941. // The offset fields are 0-based, but we use 1-based indices when
  20942. // encoding/decoding from VLQ.
  20943. generatedLine: offsetLine + 1,
  20944. generatedColumn: offsetColumn + 1
  20945. },
  20946. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  20947. }
  20948. });
  20949. }
  20950. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  20951. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  20952. /**
  20953. * The version of the source mapping spec that we are consuming.
  20954. */
  20955. IndexedSourceMapConsumer.prototype._version = 3;
  20956. /**
  20957. * The list of original sources.
  20958. */
  20959. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  20960. get: function () {
  20961. var sources = [];
  20962. for (var i = 0; i < this._sections.length; i++) {
  20963. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  20964. sources.push(this._sections[i].consumer.sources[j]);
  20965. }
  20966. }
  20967. return sources;
  20968. }
  20969. });
  20970. /**
  20971. * Returns the original source, line, and column information for the generated
  20972. * source's line and column positions provided. The only argument is an object
  20973. * with the following properties:
  20974. *
  20975. * - line: The line number in the generated source. The line number
  20976. * is 1-based.
  20977. * - column: The column number in the generated source. The column
  20978. * number is 0-based.
  20979. *
  20980. * and an object is returned with the following properties:
  20981. *
  20982. * - source: The original source file, or null.
  20983. * - line: The line number in the original source, or null. The
  20984. * line number is 1-based.
  20985. * - column: The column number in the original source, or null. The
  20986. * column number is 0-based.
  20987. * - name: The original identifier, or null.
  20988. */
  20989. IndexedSourceMapConsumer.prototype.originalPositionFor =
  20990. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  20991. var needle = {
  20992. generatedLine: util.getArg(aArgs, 'line'),
  20993. generatedColumn: util.getArg(aArgs, 'column')
  20994. };
  20995. // Find the section containing the generated position we're trying to map
  20996. // to an original position.
  20997. var sectionIndex = binarySearch.search(needle, this._sections,
  20998. function(needle, section) {
  20999. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  21000. if (cmp) {
  21001. return cmp;
  21002. }
  21003. return (needle.generatedColumn -
  21004. section.generatedOffset.generatedColumn);
  21005. });
  21006. var section = this._sections[sectionIndex];
  21007. if (!section) {
  21008. return {
  21009. source: null,
  21010. line: null,
  21011. column: null,
  21012. name: null
  21013. };
  21014. }
  21015. return section.consumer.originalPositionFor({
  21016. line: needle.generatedLine -
  21017. (section.generatedOffset.generatedLine - 1),
  21018. column: needle.generatedColumn -
  21019. (section.generatedOffset.generatedLine === needle.generatedLine
  21020. ? section.generatedOffset.generatedColumn - 1
  21021. : 0),
  21022. bias: aArgs.bias
  21023. });
  21024. };
  21025. /**
  21026. * Return true if we have the source content for every source in the source
  21027. * map, false otherwise.
  21028. */
  21029. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  21030. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  21031. return this._sections.every(function (s) {
  21032. return s.consumer.hasContentsOfAllSources();
  21033. });
  21034. };
  21035. /**
  21036. * Returns the original source content. The only argument is the url of the
  21037. * original source file. Returns null if no original source content is
  21038. * available.
  21039. */
  21040. IndexedSourceMapConsumer.prototype.sourceContentFor =
  21041. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  21042. for (var i = 0; i < this._sections.length; i++) {
  21043. var section = this._sections[i];
  21044. var content = section.consumer.sourceContentFor(aSource, true);
  21045. if (content || content === '') {
  21046. return content;
  21047. }
  21048. }
  21049. if (nullOnMissing) {
  21050. return null;
  21051. }
  21052. else {
  21053. throw new Error('"' + aSource + '" is not in the SourceMap.');
  21054. }
  21055. };
  21056. /**
  21057. * Returns the generated line and column information for the original source,
  21058. * line, and column positions provided. The only argument is an object with
  21059. * the following properties:
  21060. *
  21061. * - source: The filename of the original source.
  21062. * - line: The line number in the original source. The line number
  21063. * is 1-based.
  21064. * - column: The column number in the original source. The column
  21065. * number is 0-based.
  21066. *
  21067. * and an object is returned with the following properties:
  21068. *
  21069. * - line: The line number in the generated source, or null. The
  21070. * line number is 1-based.
  21071. * - column: The column number in the generated source, or null.
  21072. * The column number is 0-based.
  21073. */
  21074. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  21075. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  21076. for (var i = 0; i < this._sections.length; i++) {
  21077. var section = this._sections[i];
  21078. // Only consider this section if the requested source is in the list of
  21079. // sources of the consumer.
  21080. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  21081. continue;
  21082. }
  21083. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  21084. if (generatedPosition) {
  21085. var ret = {
  21086. line: generatedPosition.line +
  21087. (section.generatedOffset.generatedLine - 1),
  21088. column: generatedPosition.column +
  21089. (section.generatedOffset.generatedLine === generatedPosition.line
  21090. ? section.generatedOffset.generatedColumn - 1
  21091. : 0)
  21092. };
  21093. return ret;
  21094. }
  21095. }
  21096. return {
  21097. line: null,
  21098. column: null
  21099. };
  21100. };
  21101. /**
  21102. * Parse the mappings in a string in to a data structure which we can easily
  21103. * query (the ordered arrays in the `this.__generatedMappings` and
  21104. * `this.__originalMappings` properties).
  21105. */
  21106. IndexedSourceMapConsumer.prototype._parseMappings =
  21107. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  21108. this.__generatedMappings = [];
  21109. this.__originalMappings = [];
  21110. for (var i = 0; i < this._sections.length; i++) {
  21111. var section = this._sections[i];
  21112. var sectionMappings = section.consumer._generatedMappings;
  21113. for (var j = 0; j < sectionMappings.length; j++) {
  21114. var mapping = sectionMappings[j];
  21115. var source = section.consumer._sources.at(mapping.source);
  21116. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  21117. this._sources.add(source);
  21118. source = this._sources.indexOf(source);
  21119. var name = null;
  21120. if (mapping.name) {
  21121. name = section.consumer._names.at(mapping.name);
  21122. this._names.add(name);
  21123. name = this._names.indexOf(name);
  21124. }
  21125. // The mappings coming from the consumer for the section have
  21126. // generated positions relative to the start of the section, so we
  21127. // need to offset them to be relative to the start of the concatenated
  21128. // generated file.
  21129. var adjustedMapping = {
  21130. source: source,
  21131. generatedLine: mapping.generatedLine +
  21132. (section.generatedOffset.generatedLine - 1),
  21133. generatedColumn: mapping.generatedColumn +
  21134. (section.generatedOffset.generatedLine === mapping.generatedLine
  21135. ? section.generatedOffset.generatedColumn - 1
  21136. : 0),
  21137. originalLine: mapping.originalLine,
  21138. originalColumn: mapping.originalColumn,
  21139. name: name
  21140. };
  21141. this.__generatedMappings.push(adjustedMapping);
  21142. if (typeof adjustedMapping.originalLine === 'number') {
  21143. this.__originalMappings.push(adjustedMapping);
  21144. }
  21145. }
  21146. }
  21147. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  21148. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  21149. };
  21150. sourceMapConsumer$2.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  21151. return sourceMapConsumer$2;
  21152. }
  21153. var sourceNode$2 = {};
  21154. /* -*- Mode: js; js-indent-level: 2; -*- */
  21155. var hasRequiredSourceNode$2;
  21156. function requireSourceNode$2 () {
  21157. if (hasRequiredSourceNode$2) return sourceNode$2;
  21158. hasRequiredSourceNode$2 = 1;
  21159. /*
  21160. * Copyright 2011 Mozilla Foundation and contributors
  21161. * Licensed under the New BSD license. See LICENSE or:
  21162. * http://opensource.org/licenses/BSD-3-Clause
  21163. */
  21164. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$2().SourceMapGenerator;
  21165. var util = /*@__PURE__*/ requireUtil$3();
  21166. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  21167. // operating systems these days (capturing the result).
  21168. var REGEX_NEWLINE = /(\r?\n)/;
  21169. // Newline character code for charCodeAt() comparisons
  21170. var NEWLINE_CODE = 10;
  21171. // Private symbol for identifying `SourceNode`s when multiple versions of
  21172. // the source-map library are loaded. This MUST NOT CHANGE across
  21173. // versions!
  21174. var isSourceNode = "$$$isSourceNode$$$";
  21175. /**
  21176. * SourceNodes provide a way to abstract over interpolating/concatenating
  21177. * snippets of generated JavaScript source code while maintaining the line and
  21178. * column information associated with the original source code.
  21179. *
  21180. * @param aLine The original line number.
  21181. * @param aColumn The original column number.
  21182. * @param aSource The original source's filename.
  21183. * @param aChunks Optional. An array of strings which are snippets of
  21184. * generated JS, or other SourceNodes.
  21185. * @param aName The original identifier.
  21186. */
  21187. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  21188. this.children = [];
  21189. this.sourceContents = {};
  21190. this.line = aLine == null ? null : aLine;
  21191. this.column = aColumn == null ? null : aColumn;
  21192. this.source = aSource == null ? null : aSource;
  21193. this.name = aName == null ? null : aName;
  21194. this[isSourceNode] = true;
  21195. if (aChunks != null) this.add(aChunks);
  21196. }
  21197. /**
  21198. * Creates a SourceNode from generated code and a SourceMapConsumer.
  21199. *
  21200. * @param aGeneratedCode The generated code
  21201. * @param aSourceMapConsumer The SourceMap for the generated code
  21202. * @param aRelativePath Optional. The path that relative sources in the
  21203. * SourceMapConsumer should be relative to.
  21204. */
  21205. SourceNode.fromStringWithSourceMap =
  21206. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  21207. // The SourceNode we want to fill with the generated code
  21208. // and the SourceMap
  21209. var node = new SourceNode();
  21210. // All even indices of this array are one line of the generated code,
  21211. // while all odd indices are the newlines between two adjacent lines
  21212. // (since `REGEX_NEWLINE` captures its match).
  21213. // Processed fragments are accessed by calling `shiftNextLine`.
  21214. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  21215. var remainingLinesIndex = 0;
  21216. var shiftNextLine = function() {
  21217. var lineContents = getNextLine();
  21218. // The last line of a file might not have a newline.
  21219. var newLine = getNextLine() || "";
  21220. return lineContents + newLine;
  21221. function getNextLine() {
  21222. return remainingLinesIndex < remainingLines.length ?
  21223. remainingLines[remainingLinesIndex++] : undefined;
  21224. }
  21225. };
  21226. // We need to remember the position of "remainingLines"
  21227. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  21228. // The generate SourceNodes we need a code range.
  21229. // To extract it current and last mapping is used.
  21230. // Here we store the last mapping.
  21231. var lastMapping = null;
  21232. aSourceMapConsumer.eachMapping(function (mapping) {
  21233. if (lastMapping !== null) {
  21234. // We add the code from "lastMapping" to "mapping":
  21235. // First check if there is a new line in between.
  21236. if (lastGeneratedLine < mapping.generatedLine) {
  21237. // Associate first line with "lastMapping"
  21238. addMappingWithCode(lastMapping, shiftNextLine());
  21239. lastGeneratedLine++;
  21240. lastGeneratedColumn = 0;
  21241. // The remaining code is added without mapping
  21242. } else {
  21243. // There is no new line in between.
  21244. // Associate the code between "lastGeneratedColumn" and
  21245. // "mapping.generatedColumn" with "lastMapping"
  21246. var nextLine = remainingLines[remainingLinesIndex] || '';
  21247. var code = nextLine.substr(0, mapping.generatedColumn -
  21248. lastGeneratedColumn);
  21249. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  21250. lastGeneratedColumn);
  21251. lastGeneratedColumn = mapping.generatedColumn;
  21252. addMappingWithCode(lastMapping, code);
  21253. // No more remaining code, continue
  21254. lastMapping = mapping;
  21255. return;
  21256. }
  21257. }
  21258. // We add the generated code until the first mapping
  21259. // to the SourceNode without any mapping.
  21260. // Each line is added as separate string.
  21261. while (lastGeneratedLine < mapping.generatedLine) {
  21262. node.add(shiftNextLine());
  21263. lastGeneratedLine++;
  21264. }
  21265. if (lastGeneratedColumn < mapping.generatedColumn) {
  21266. var nextLine = remainingLines[remainingLinesIndex] || '';
  21267. node.add(nextLine.substr(0, mapping.generatedColumn));
  21268. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  21269. lastGeneratedColumn = mapping.generatedColumn;
  21270. }
  21271. lastMapping = mapping;
  21272. }, this);
  21273. // We have processed all mappings.
  21274. if (remainingLinesIndex < remainingLines.length) {
  21275. if (lastMapping) {
  21276. // Associate the remaining code in the current line with "lastMapping"
  21277. addMappingWithCode(lastMapping, shiftNextLine());
  21278. }
  21279. // and add the remaining lines without any mapping
  21280. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  21281. }
  21282. // Copy sourcesContent into SourceNode
  21283. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  21284. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  21285. if (content != null) {
  21286. if (aRelativePath != null) {
  21287. sourceFile = util.join(aRelativePath, sourceFile);
  21288. }
  21289. node.setSourceContent(sourceFile, content);
  21290. }
  21291. });
  21292. return node;
  21293. function addMappingWithCode(mapping, code) {
  21294. if (mapping === null || mapping.source === undefined) {
  21295. node.add(code);
  21296. } else {
  21297. var source = aRelativePath
  21298. ? util.join(aRelativePath, mapping.source)
  21299. : mapping.source;
  21300. node.add(new SourceNode(mapping.originalLine,
  21301. mapping.originalColumn,
  21302. source,
  21303. code,
  21304. mapping.name));
  21305. }
  21306. }
  21307. };
  21308. /**
  21309. * Add a chunk of generated JS to this source node.
  21310. *
  21311. * @param aChunk A string snippet of generated JS code, another instance of
  21312. * SourceNode, or an array where each member is one of those things.
  21313. */
  21314. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  21315. if (Array.isArray(aChunk)) {
  21316. aChunk.forEach(function (chunk) {
  21317. this.add(chunk);
  21318. }, this);
  21319. }
  21320. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  21321. if (aChunk) {
  21322. this.children.push(aChunk);
  21323. }
  21324. }
  21325. else {
  21326. throw new TypeError(
  21327. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21328. );
  21329. }
  21330. return this;
  21331. };
  21332. /**
  21333. * Add a chunk of generated JS to the beginning of this source node.
  21334. *
  21335. * @param aChunk A string snippet of generated JS code, another instance of
  21336. * SourceNode, or an array where each member is one of those things.
  21337. */
  21338. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  21339. if (Array.isArray(aChunk)) {
  21340. for (var i = aChunk.length-1; i >= 0; i--) {
  21341. this.prepend(aChunk[i]);
  21342. }
  21343. }
  21344. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  21345. this.children.unshift(aChunk);
  21346. }
  21347. else {
  21348. throw new TypeError(
  21349. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21350. );
  21351. }
  21352. return this;
  21353. };
  21354. /**
  21355. * Walk over the tree of JS snippets in this node and its children. The
  21356. * walking function is called once for each snippet of JS and is passed that
  21357. * snippet and the its original associated source's line/column location.
  21358. *
  21359. * @param aFn The traversal function.
  21360. */
  21361. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  21362. var chunk;
  21363. for (var i = 0, len = this.children.length; i < len; i++) {
  21364. chunk = this.children[i];
  21365. if (chunk[isSourceNode]) {
  21366. chunk.walk(aFn);
  21367. }
  21368. else {
  21369. if (chunk !== '') {
  21370. aFn(chunk, { source: this.source,
  21371. line: this.line,
  21372. column: this.column,
  21373. name: this.name });
  21374. }
  21375. }
  21376. }
  21377. };
  21378. /**
  21379. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  21380. * each of `this.children`.
  21381. *
  21382. * @param aSep The separator.
  21383. */
  21384. SourceNode.prototype.join = function SourceNode_join(aSep) {
  21385. var newChildren;
  21386. var i;
  21387. var len = this.children.length;
  21388. if (len > 0) {
  21389. newChildren = [];
  21390. for (i = 0; i < len-1; i++) {
  21391. newChildren.push(this.children[i]);
  21392. newChildren.push(aSep);
  21393. }
  21394. newChildren.push(this.children[i]);
  21395. this.children = newChildren;
  21396. }
  21397. return this;
  21398. };
  21399. /**
  21400. * Call String.prototype.replace on the very right-most source snippet. Useful
  21401. * for trimming whitespace from the end of a source node, etc.
  21402. *
  21403. * @param aPattern The pattern to replace.
  21404. * @param aReplacement The thing to replace the pattern with.
  21405. */
  21406. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  21407. var lastChild = this.children[this.children.length - 1];
  21408. if (lastChild[isSourceNode]) {
  21409. lastChild.replaceRight(aPattern, aReplacement);
  21410. }
  21411. else if (typeof lastChild === 'string') {
  21412. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  21413. }
  21414. else {
  21415. this.children.push(''.replace(aPattern, aReplacement));
  21416. }
  21417. return this;
  21418. };
  21419. /**
  21420. * Set the source content for a source file. This will be added to the SourceMapGenerator
  21421. * in the sourcesContent field.
  21422. *
  21423. * @param aSourceFile The filename of the source file
  21424. * @param aSourceContent The content of the source file
  21425. */
  21426. SourceNode.prototype.setSourceContent =
  21427. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  21428. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  21429. };
  21430. /**
  21431. * Walk over the tree of SourceNodes. The walking function is called for each
  21432. * source file content and is passed the filename and source content.
  21433. *
  21434. * @param aFn The traversal function.
  21435. */
  21436. SourceNode.prototype.walkSourceContents =
  21437. function SourceNode_walkSourceContents(aFn) {
  21438. for (var i = 0, len = this.children.length; i < len; i++) {
  21439. if (this.children[i][isSourceNode]) {
  21440. this.children[i].walkSourceContents(aFn);
  21441. }
  21442. }
  21443. var sources = Object.keys(this.sourceContents);
  21444. for (var i = 0, len = sources.length; i < len; i++) {
  21445. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  21446. }
  21447. };
  21448. /**
  21449. * Return the string representation of this source node. Walks over the tree
  21450. * and concatenates all the various snippets together to one string.
  21451. */
  21452. SourceNode.prototype.toString = function SourceNode_toString() {
  21453. var str = "";
  21454. this.walk(function (chunk) {
  21455. str += chunk;
  21456. });
  21457. return str;
  21458. };
  21459. /**
  21460. * Returns the string representation of this source node along with a source
  21461. * map.
  21462. */
  21463. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  21464. var generated = {
  21465. code: "",
  21466. line: 1,
  21467. column: 0
  21468. };
  21469. var map = new SourceMapGenerator(aArgs);
  21470. var sourceMappingActive = false;
  21471. var lastOriginalSource = null;
  21472. var lastOriginalLine = null;
  21473. var lastOriginalColumn = null;
  21474. var lastOriginalName = null;
  21475. this.walk(function (chunk, original) {
  21476. generated.code += chunk;
  21477. if (original.source !== null
  21478. && original.line !== null
  21479. && original.column !== null) {
  21480. if(lastOriginalSource !== original.source
  21481. || lastOriginalLine !== original.line
  21482. || lastOriginalColumn !== original.column
  21483. || lastOriginalName !== original.name) {
  21484. map.addMapping({
  21485. source: original.source,
  21486. original: {
  21487. line: original.line,
  21488. column: original.column
  21489. },
  21490. generated: {
  21491. line: generated.line,
  21492. column: generated.column
  21493. },
  21494. name: original.name
  21495. });
  21496. }
  21497. lastOriginalSource = original.source;
  21498. lastOriginalLine = original.line;
  21499. lastOriginalColumn = original.column;
  21500. lastOriginalName = original.name;
  21501. sourceMappingActive = true;
  21502. } else if (sourceMappingActive) {
  21503. map.addMapping({
  21504. generated: {
  21505. line: generated.line,
  21506. column: generated.column
  21507. }
  21508. });
  21509. lastOriginalSource = null;
  21510. sourceMappingActive = false;
  21511. }
  21512. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  21513. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  21514. generated.line++;
  21515. generated.column = 0;
  21516. // Mappings end at eol
  21517. if (idx + 1 === length) {
  21518. lastOriginalSource = null;
  21519. sourceMappingActive = false;
  21520. } else if (sourceMappingActive) {
  21521. map.addMapping({
  21522. source: original.source,
  21523. original: {
  21524. line: original.line,
  21525. column: original.column
  21526. },
  21527. generated: {
  21528. line: generated.line,
  21529. column: generated.column
  21530. },
  21531. name: original.name
  21532. });
  21533. }
  21534. } else {
  21535. generated.column++;
  21536. }
  21537. }
  21538. });
  21539. this.walkSourceContents(function (sourceFile, sourceContent) {
  21540. map.setSourceContent(sourceFile, sourceContent);
  21541. });
  21542. return { code: generated.code, map: map };
  21543. };
  21544. sourceNode$2.SourceNode = SourceNode;
  21545. return sourceNode$2;
  21546. }
  21547. /*
  21548. * Copyright 2009-2011 Mozilla Foundation and contributors
  21549. * Licensed under the New BSD license. See LICENSE.txt or:
  21550. * http://opensource.org/licenses/BSD-3-Clause
  21551. */
  21552. var hasRequiredSourceMap$2;
  21553. function requireSourceMap$2 () {
  21554. if (hasRequiredSourceMap$2) return sourceMap$2;
  21555. hasRequiredSourceMap$2 = 1;
  21556. sourceMap$2.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$2().SourceMapGenerator;
  21557. sourceMap$2.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer$2().SourceMapConsumer;
  21558. sourceMap$2.SourceNode = /*@__PURE__*/ requireSourceNode$2().SourceNode;
  21559. return sourceMap$2;
  21560. }
  21561. var sourceMapExports = /*@__PURE__*/ requireSourceMap$2();
  21562. const PURE_ANNOTATION = `/*@__PURE__*/`;
  21563. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  21564. function createCodegenContext(ast, {
  21565. mode = "function",
  21566. prefixIdentifiers = mode === "module",
  21567. sourceMap = false,
  21568. filename = `template.vue.html`,
  21569. scopeId = null,
  21570. optimizeImports = false,
  21571. runtimeGlobalName = `Vue`,
  21572. runtimeModuleName = `vue`,
  21573. ssrRuntimeModuleName = "vue/server-renderer",
  21574. ssr = false,
  21575. isTS = false,
  21576. inSSR = false
  21577. }) {
  21578. const context = {
  21579. mode,
  21580. prefixIdentifiers,
  21581. sourceMap,
  21582. filename,
  21583. scopeId,
  21584. optimizeImports,
  21585. runtimeGlobalName,
  21586. runtimeModuleName,
  21587. ssrRuntimeModuleName,
  21588. ssr,
  21589. isTS,
  21590. inSSR,
  21591. source: ast.source,
  21592. code: ``,
  21593. column: 1,
  21594. line: 1,
  21595. offset: 0,
  21596. indentLevel: 0,
  21597. pure: false,
  21598. map: void 0,
  21599. helper(key) {
  21600. return `_${helperNameMap[key]}`;
  21601. },
  21602. push(code, newlineIndex = -2 /* None */, node) {
  21603. context.code += code;
  21604. if (context.map) {
  21605. if (node) {
  21606. let name;
  21607. if (node.type === 4 && !node.isStatic) {
  21608. const content = node.content.replace(/^_ctx\./, "");
  21609. if (content !== node.content && isSimpleIdentifier(content)) {
  21610. name = content;
  21611. }
  21612. }
  21613. addMapping(node.loc.start, name);
  21614. }
  21615. if (newlineIndex === -3 /* Unknown */) {
  21616. advancePositionWithMutation(context, code);
  21617. } else {
  21618. context.offset += code.length;
  21619. if (newlineIndex === -2 /* None */) {
  21620. context.column += code.length;
  21621. } else {
  21622. if (newlineIndex === -1 /* End */) {
  21623. newlineIndex = code.length - 1;
  21624. }
  21625. context.line++;
  21626. context.column = code.length - newlineIndex;
  21627. }
  21628. }
  21629. if (node && node.loc !== locStub) {
  21630. addMapping(node.loc.end);
  21631. }
  21632. }
  21633. },
  21634. indent() {
  21635. newline(++context.indentLevel);
  21636. },
  21637. deindent(withoutNewLine = false) {
  21638. if (withoutNewLine) {
  21639. --context.indentLevel;
  21640. } else {
  21641. newline(--context.indentLevel);
  21642. }
  21643. },
  21644. newline() {
  21645. newline(context.indentLevel);
  21646. }
  21647. };
  21648. function newline(n) {
  21649. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  21650. }
  21651. function addMapping(loc, name = null) {
  21652. const { _names, _mappings } = context.map;
  21653. if (name !== null && !_names.has(name)) _names.add(name);
  21654. _mappings.add({
  21655. originalLine: loc.line,
  21656. originalColumn: loc.column - 1,
  21657. // source-map column is 0 based
  21658. generatedLine: context.line,
  21659. generatedColumn: context.column - 1,
  21660. source: filename,
  21661. name
  21662. });
  21663. }
  21664. if (sourceMap) {
  21665. context.map = new sourceMapExports.SourceMapGenerator();
  21666. context.map.setSourceContent(filename, context.source);
  21667. context.map._sources.add(filename);
  21668. }
  21669. return context;
  21670. }
  21671. function generate(ast, options = {}) {
  21672. const context = createCodegenContext(ast, options);
  21673. if (options.onContextCreated) options.onContextCreated(context);
  21674. const {
  21675. mode,
  21676. push,
  21677. prefixIdentifiers,
  21678. indent,
  21679. deindent,
  21680. newline,
  21681. scopeId,
  21682. ssr
  21683. } = context;
  21684. const helpers = Array.from(ast.helpers);
  21685. const hasHelpers = helpers.length > 0;
  21686. const useWithBlock = !prefixIdentifiers && mode !== "module";
  21687. const genScopeId = scopeId != null && mode === "module";
  21688. const isSetupInlined = !!options.inline;
  21689. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  21690. if (mode === "module") {
  21691. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  21692. } else {
  21693. genFunctionPreamble(ast, preambleContext);
  21694. }
  21695. const functionName = ssr ? `ssrRender` : `render`;
  21696. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  21697. if (options.bindingMetadata && !options.inline) {
  21698. args.push("$props", "$setup", "$data", "$options");
  21699. }
  21700. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  21701. if (isSetupInlined) {
  21702. push(`(${signature}) => {`);
  21703. } else {
  21704. push(`function ${functionName}(${signature}) {`);
  21705. }
  21706. indent();
  21707. if (useWithBlock) {
  21708. push(`with (_ctx) {`);
  21709. indent();
  21710. if (hasHelpers) {
  21711. push(
  21712. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  21713. `,
  21714. -1 /* End */
  21715. );
  21716. newline();
  21717. }
  21718. }
  21719. if (ast.components.length) {
  21720. genAssets(ast.components, "component", context);
  21721. if (ast.directives.length || ast.temps > 0) {
  21722. newline();
  21723. }
  21724. }
  21725. if (ast.directives.length) {
  21726. genAssets(ast.directives, "directive", context);
  21727. if (ast.temps > 0) {
  21728. newline();
  21729. }
  21730. }
  21731. if (ast.temps > 0) {
  21732. push(`let `);
  21733. for (let i = 0; i < ast.temps; i++) {
  21734. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  21735. }
  21736. }
  21737. if (ast.components.length || ast.directives.length || ast.temps) {
  21738. push(`
  21739. `, 0 /* Start */);
  21740. newline();
  21741. }
  21742. if (!ssr) {
  21743. push(`return `);
  21744. }
  21745. if (ast.codegenNode) {
  21746. genNode(ast.codegenNode, context);
  21747. } else {
  21748. push(`null`);
  21749. }
  21750. if (useWithBlock) {
  21751. deindent();
  21752. push(`}`);
  21753. }
  21754. deindent();
  21755. push(`}`);
  21756. return {
  21757. ast,
  21758. code: context.code,
  21759. preamble: isSetupInlined ? preambleContext.code : ``,
  21760. map: context.map ? context.map.toJSON() : void 0
  21761. };
  21762. }
  21763. function genFunctionPreamble(ast, context) {
  21764. const {
  21765. ssr,
  21766. prefixIdentifiers,
  21767. push,
  21768. newline,
  21769. runtimeModuleName,
  21770. runtimeGlobalName,
  21771. ssrRuntimeModuleName
  21772. } = context;
  21773. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  21774. const helpers = Array.from(ast.helpers);
  21775. if (helpers.length > 0) {
  21776. if (prefixIdentifiers) {
  21777. push(
  21778. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  21779. `,
  21780. -1 /* End */
  21781. );
  21782. } else {
  21783. push(`const _Vue = ${VueBinding}
  21784. `, -1 /* End */);
  21785. if (ast.hoists.length) {
  21786. const staticHelpers = [
  21787. CREATE_VNODE,
  21788. CREATE_ELEMENT_VNODE,
  21789. CREATE_COMMENT,
  21790. CREATE_TEXT,
  21791. CREATE_STATIC
  21792. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  21793. push(`const { ${staticHelpers} } = _Vue
  21794. `, -1 /* End */);
  21795. }
  21796. }
  21797. }
  21798. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21799. push(
  21800. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  21801. `,
  21802. -1 /* End */
  21803. );
  21804. }
  21805. genHoists(ast.hoists, context);
  21806. newline();
  21807. push(`return `);
  21808. }
  21809. function genModulePreamble(ast, context, genScopeId, inline) {
  21810. const {
  21811. push,
  21812. newline,
  21813. optimizeImports,
  21814. runtimeModuleName,
  21815. ssrRuntimeModuleName
  21816. } = context;
  21817. if (ast.helpers.size) {
  21818. const helpers = Array.from(ast.helpers);
  21819. if (optimizeImports) {
  21820. push(
  21821. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21822. `,
  21823. -1 /* End */
  21824. );
  21825. push(
  21826. `
  21827. // Binding optimization for webpack code-split
  21828. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  21829. `,
  21830. -1 /* End */
  21831. );
  21832. } else {
  21833. push(
  21834. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21835. `,
  21836. -1 /* End */
  21837. );
  21838. }
  21839. }
  21840. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21841. push(
  21842. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  21843. `,
  21844. -1 /* End */
  21845. );
  21846. }
  21847. if (ast.imports.length) {
  21848. genImports(ast.imports, context);
  21849. newline();
  21850. }
  21851. genHoists(ast.hoists, context);
  21852. newline();
  21853. if (!inline) {
  21854. push(`export `);
  21855. }
  21856. }
  21857. function genAssets(assets, type, { helper, push, newline, isTS }) {
  21858. const resolver = helper(
  21859. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  21860. );
  21861. for (let i = 0; i < assets.length; i++) {
  21862. let id = assets[i];
  21863. const maybeSelfReference = id.endsWith("__self");
  21864. if (maybeSelfReference) {
  21865. id = id.slice(0, -6);
  21866. }
  21867. push(
  21868. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  21869. );
  21870. if (i < assets.length - 1) {
  21871. newline();
  21872. }
  21873. }
  21874. }
  21875. function genHoists(hoists, context) {
  21876. if (!hoists.length) {
  21877. return;
  21878. }
  21879. context.pure = true;
  21880. const { push, newline } = context;
  21881. newline();
  21882. for (let i = 0; i < hoists.length; i++) {
  21883. const exp = hoists[i];
  21884. if (exp) {
  21885. push(`const _hoisted_${i + 1} = `);
  21886. genNode(exp, context);
  21887. newline();
  21888. }
  21889. }
  21890. context.pure = false;
  21891. }
  21892. function genImports(importsOptions, context) {
  21893. if (!importsOptions.length) {
  21894. return;
  21895. }
  21896. importsOptions.forEach((imports) => {
  21897. context.push(`import `);
  21898. genNode(imports.exp, context);
  21899. context.push(` from '${imports.path}'`);
  21900. context.newline();
  21901. });
  21902. }
  21903. function isText(n) {
  21904. return isString$1(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  21905. }
  21906. function genNodeListAsArray(nodes, context) {
  21907. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  21908. context.push(`[`);
  21909. multilines && context.indent();
  21910. genNodeList(nodes, context, multilines);
  21911. multilines && context.deindent();
  21912. context.push(`]`);
  21913. }
  21914. function genNodeList(nodes, context, multilines = false, comma = true) {
  21915. const { push, newline } = context;
  21916. for (let i = 0; i < nodes.length; i++) {
  21917. const node = nodes[i];
  21918. if (isString$1(node)) {
  21919. push(node, -3 /* Unknown */);
  21920. } else if (isArray$3(node)) {
  21921. genNodeListAsArray(node, context);
  21922. } else {
  21923. genNode(node, context);
  21924. }
  21925. if (i < nodes.length - 1) {
  21926. if (multilines) {
  21927. comma && push(",");
  21928. newline();
  21929. } else {
  21930. comma && push(", ");
  21931. }
  21932. }
  21933. }
  21934. }
  21935. function genNode(node, context) {
  21936. if (isString$1(node)) {
  21937. context.push(node, -3 /* Unknown */);
  21938. return;
  21939. }
  21940. if (isSymbol$1(node)) {
  21941. context.push(context.helper(node));
  21942. return;
  21943. }
  21944. switch (node.type) {
  21945. case 1:
  21946. case 9:
  21947. case 11:
  21948. assert(
  21949. node.codegenNode != null,
  21950. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  21951. );
  21952. genNode(node.codegenNode, context);
  21953. break;
  21954. case 2:
  21955. genText(node, context);
  21956. break;
  21957. case 4:
  21958. genExpression(node, context);
  21959. break;
  21960. case 5:
  21961. genInterpolation(node, context);
  21962. break;
  21963. case 12:
  21964. genNode(node.codegenNode, context);
  21965. break;
  21966. case 8:
  21967. genCompoundExpression(node, context);
  21968. break;
  21969. case 3:
  21970. genComment(node, context);
  21971. break;
  21972. case 13:
  21973. genVNodeCall(node, context);
  21974. break;
  21975. case 14:
  21976. genCallExpression(node, context);
  21977. break;
  21978. case 15:
  21979. genObjectExpression(node, context);
  21980. break;
  21981. case 17:
  21982. genArrayExpression(node, context);
  21983. break;
  21984. case 18:
  21985. genFunctionExpression(node, context);
  21986. break;
  21987. case 19:
  21988. genConditionalExpression(node, context);
  21989. break;
  21990. case 20:
  21991. genCacheExpression(node, context);
  21992. break;
  21993. case 21:
  21994. genNodeList(node.body, context, true, false);
  21995. break;
  21996. // SSR only types
  21997. case 22:
  21998. genTemplateLiteral(node, context);
  21999. break;
  22000. case 23:
  22001. genIfStatement(node, context);
  22002. break;
  22003. case 24:
  22004. genAssignmentExpression(node, context);
  22005. break;
  22006. case 25:
  22007. genSequenceExpression(node, context);
  22008. break;
  22009. case 26:
  22010. genReturnStatement(node, context);
  22011. break;
  22012. /* v8 ignore start */
  22013. case 10:
  22014. break;
  22015. default:
  22016. {
  22017. assert(false, `unhandled codegen node type: ${node.type}`);
  22018. const exhaustiveCheck = node;
  22019. return exhaustiveCheck;
  22020. }
  22021. }
  22022. }
  22023. function genText(node, context) {
  22024. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  22025. }
  22026. function genExpression(node, context) {
  22027. const { content, isStatic } = node;
  22028. context.push(
  22029. isStatic ? JSON.stringify(content) : content,
  22030. -3 /* Unknown */,
  22031. node
  22032. );
  22033. }
  22034. function genInterpolation(node, context) {
  22035. const { push, helper, pure } = context;
  22036. if (pure) push(PURE_ANNOTATION);
  22037. push(`${helper(TO_DISPLAY_STRING)}(`);
  22038. genNode(node.content, context);
  22039. push(`)`);
  22040. }
  22041. function genCompoundExpression(node, context) {
  22042. for (let i = 0; i < node.children.length; i++) {
  22043. const child = node.children[i];
  22044. if (isString$1(child)) {
  22045. context.push(child, -3 /* Unknown */);
  22046. } else {
  22047. genNode(child, context);
  22048. }
  22049. }
  22050. }
  22051. function genExpressionAsPropertyKey(node, context) {
  22052. const { push } = context;
  22053. if (node.type === 8) {
  22054. push(`[`);
  22055. genCompoundExpression(node, context);
  22056. push(`]`);
  22057. } else if (node.isStatic) {
  22058. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  22059. push(text, -2 /* None */, node);
  22060. } else {
  22061. push(`[${node.content}]`, -3 /* Unknown */, node);
  22062. }
  22063. }
  22064. function genComment(node, context) {
  22065. const { push, helper, pure } = context;
  22066. if (pure) {
  22067. push(PURE_ANNOTATION);
  22068. }
  22069. push(
  22070. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  22071. -3 /* Unknown */,
  22072. node
  22073. );
  22074. }
  22075. function genVNodeCall(node, context) {
  22076. const { push, helper, pure } = context;
  22077. const {
  22078. tag,
  22079. props,
  22080. children,
  22081. patchFlag,
  22082. dynamicProps,
  22083. directives,
  22084. isBlock,
  22085. disableTracking,
  22086. isComponent
  22087. } = node;
  22088. let patchFlagString;
  22089. if (patchFlag) {
  22090. {
  22091. if (patchFlag < 0) {
  22092. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  22093. } else {
  22094. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  22095. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  22096. }
  22097. }
  22098. }
  22099. if (directives) {
  22100. push(helper(WITH_DIRECTIVES) + `(`);
  22101. }
  22102. if (isBlock) {
  22103. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  22104. }
  22105. if (pure) {
  22106. push(PURE_ANNOTATION);
  22107. }
  22108. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  22109. push(helper(callHelper) + `(`, -2 /* None */, node);
  22110. genNodeList(
  22111. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  22112. context
  22113. );
  22114. push(`)`);
  22115. if (isBlock) {
  22116. push(`)`);
  22117. }
  22118. if (directives) {
  22119. push(`, `);
  22120. genNode(directives, context);
  22121. push(`)`);
  22122. }
  22123. }
  22124. function genNullableArgs(args) {
  22125. let i = args.length;
  22126. while (i--) {
  22127. if (args[i] != null) break;
  22128. }
  22129. return args.slice(0, i + 1).map((arg) => arg || `null`);
  22130. }
  22131. function genCallExpression(node, context) {
  22132. const { push, helper, pure } = context;
  22133. const callee = isString$1(node.callee) ? node.callee : helper(node.callee);
  22134. if (pure) {
  22135. push(PURE_ANNOTATION);
  22136. }
  22137. push(callee + `(`, -2 /* None */, node);
  22138. genNodeList(node.arguments, context);
  22139. push(`)`);
  22140. }
  22141. function genObjectExpression(node, context) {
  22142. const { push, indent, deindent, newline } = context;
  22143. const { properties } = node;
  22144. if (!properties.length) {
  22145. push(`{}`, -2 /* None */, node);
  22146. return;
  22147. }
  22148. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  22149. push(multilines ? `{` : `{ `);
  22150. multilines && indent();
  22151. for (let i = 0; i < properties.length; i++) {
  22152. const { key, value } = properties[i];
  22153. genExpressionAsPropertyKey(key, context);
  22154. push(`: `);
  22155. genNode(value, context);
  22156. if (i < properties.length - 1) {
  22157. push(`,`);
  22158. newline();
  22159. }
  22160. }
  22161. multilines && deindent();
  22162. push(multilines ? `}` : ` }`);
  22163. }
  22164. function genArrayExpression(node, context) {
  22165. genNodeListAsArray(node.elements, context);
  22166. }
  22167. function genFunctionExpression(node, context) {
  22168. const { push, indent, deindent } = context;
  22169. const { params, returns, body, newline, isSlot } = node;
  22170. if (isSlot) {
  22171. push(`_${helperNameMap[WITH_CTX]}(`);
  22172. }
  22173. push(`(`, -2 /* None */, node);
  22174. if (isArray$3(params)) {
  22175. genNodeList(params, context);
  22176. } else if (params) {
  22177. genNode(params, context);
  22178. }
  22179. push(`) => `);
  22180. if (newline || body) {
  22181. push(`{`);
  22182. indent();
  22183. }
  22184. if (returns) {
  22185. if (newline) {
  22186. push(`return `);
  22187. }
  22188. if (isArray$3(returns)) {
  22189. genNodeListAsArray(returns, context);
  22190. } else {
  22191. genNode(returns, context);
  22192. }
  22193. } else if (body) {
  22194. genNode(body, context);
  22195. }
  22196. if (newline || body) {
  22197. deindent();
  22198. push(`}`);
  22199. }
  22200. if (isSlot) {
  22201. push(`)`);
  22202. }
  22203. }
  22204. function genConditionalExpression(node, context) {
  22205. const { test, consequent, alternate, newline: needNewline } = node;
  22206. const { push, indent, deindent, newline } = context;
  22207. if (test.type === 4) {
  22208. const needsParens = !isSimpleIdentifier(test.content);
  22209. needsParens && push(`(`);
  22210. genExpression(test, context);
  22211. needsParens && push(`)`);
  22212. } else {
  22213. push(`(`);
  22214. genNode(test, context);
  22215. push(`)`);
  22216. }
  22217. needNewline && indent();
  22218. context.indentLevel++;
  22219. needNewline || push(` `);
  22220. push(`? `);
  22221. genNode(consequent, context);
  22222. context.indentLevel--;
  22223. needNewline && newline();
  22224. needNewline || push(` `);
  22225. push(`: `);
  22226. const isNested = alternate.type === 19;
  22227. if (!isNested) {
  22228. context.indentLevel++;
  22229. }
  22230. genNode(alternate, context);
  22231. if (!isNested) {
  22232. context.indentLevel--;
  22233. }
  22234. needNewline && deindent(
  22235. true
  22236. /* without newline */
  22237. );
  22238. }
  22239. function genCacheExpression(node, context) {
  22240. const { push, helper, indent, deindent, newline } = context;
  22241. const { needPauseTracking, needArraySpread } = node;
  22242. if (needArraySpread) {
  22243. push(`[...(`);
  22244. }
  22245. push(`_cache[${node.index}] || (`);
  22246. if (needPauseTracking) {
  22247. indent();
  22248. push(`${helper(SET_BLOCK_TRACKING)}(-1`);
  22249. if (node.inVOnce) push(`, true`);
  22250. push(`),`);
  22251. newline();
  22252. push(`(`);
  22253. }
  22254. push(`_cache[${node.index}] = `);
  22255. genNode(node.value, context);
  22256. if (needPauseTracking) {
  22257. push(`).cacheIndex = ${node.index},`);
  22258. newline();
  22259. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  22260. newline();
  22261. push(`_cache[${node.index}]`);
  22262. deindent();
  22263. }
  22264. push(`)`);
  22265. if (needArraySpread) {
  22266. push(`)]`);
  22267. }
  22268. }
  22269. function genTemplateLiteral(node, context) {
  22270. const { push, indent, deindent } = context;
  22271. push("`");
  22272. const l = node.elements.length;
  22273. const multilines = l > 3;
  22274. for (let i = 0; i < l; i++) {
  22275. const e = node.elements[i];
  22276. if (isString$1(e)) {
  22277. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  22278. } else {
  22279. push("${");
  22280. if (multilines) indent();
  22281. genNode(e, context);
  22282. if (multilines) deindent();
  22283. push("}");
  22284. }
  22285. }
  22286. push("`");
  22287. }
  22288. function genIfStatement(node, context) {
  22289. const { push, indent, deindent } = context;
  22290. const { test, consequent, alternate } = node;
  22291. push(`if (`);
  22292. genNode(test, context);
  22293. push(`) {`);
  22294. indent();
  22295. genNode(consequent, context);
  22296. deindent();
  22297. push(`}`);
  22298. if (alternate) {
  22299. push(` else `);
  22300. if (alternate.type === 23) {
  22301. genIfStatement(alternate, context);
  22302. } else {
  22303. push(`{`);
  22304. indent();
  22305. genNode(alternate, context);
  22306. deindent();
  22307. push(`}`);
  22308. }
  22309. }
  22310. }
  22311. function genAssignmentExpression(node, context) {
  22312. genNode(node.left, context);
  22313. context.push(` = `);
  22314. genNode(node.right, context);
  22315. }
  22316. function genSequenceExpression(node, context) {
  22317. context.push(`(`);
  22318. genNodeList(node.expressions, context);
  22319. context.push(`)`);
  22320. }
  22321. function genReturnStatement({ returns }, context) {
  22322. context.push(`return `);
  22323. if (isArray$3(returns)) {
  22324. genNodeListAsArray(returns, context);
  22325. } else {
  22326. genNode(returns, context);
  22327. }
  22328. }
  22329. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22330. const transformExpression = (node, context) => {
  22331. if (node.type === 5) {
  22332. node.content = processExpression(
  22333. node.content,
  22334. context
  22335. );
  22336. } else if (node.type === 1) {
  22337. const memo = findDir(node, "memo");
  22338. for (let i = 0; i < node.props.length; i++) {
  22339. const dir = node.props[i];
  22340. if (dir.type === 7 && dir.name !== "for") {
  22341. const exp = dir.exp;
  22342. const arg = dir.arg;
  22343. if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
  22344. !(memo && arg && arg.type === 4 && arg.content === "key")) {
  22345. dir.exp = processExpression(
  22346. exp,
  22347. context,
  22348. // slot args must be processed as function params
  22349. dir.name === "slot"
  22350. );
  22351. }
  22352. if (arg && arg.type === 4 && !arg.isStatic) {
  22353. dir.arg = processExpression(arg, context);
  22354. }
  22355. }
  22356. }
  22357. }
  22358. };
  22359. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  22360. if (!context.prefixIdentifiers || !node.content.trim()) {
  22361. return node;
  22362. }
  22363. const { inline, bindingMetadata } = context;
  22364. const rewriteIdentifier = (raw, parent, id) => {
  22365. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  22366. if (inline) {
  22367. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  22368. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  22369. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  22370. const isNewExpression = parent && isInNewExpression(parentStack);
  22371. const wrapWithUnref = (raw2) => {
  22372. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  22373. return isNewExpression ? `(${wrapped})` : wrapped;
  22374. };
  22375. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  22376. return raw;
  22377. } else if (type === "setup-ref") {
  22378. return `${raw}.value`;
  22379. } else if (type === "setup-maybe-ref") {
  22380. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  22381. } else if (type === "setup-let") {
  22382. if (isAssignmentLVal) {
  22383. const { right: rVal, operator } = parent;
  22384. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  22385. const rExpString = stringifyExpression(
  22386. processExpression(
  22387. createSimpleExpression(rExp, false),
  22388. context,
  22389. false,
  22390. false,
  22391. knownIds
  22392. )
  22393. );
  22394. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22395. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  22396. } else if (isUpdateArg) {
  22397. id.start = parent.start;
  22398. id.end = parent.end;
  22399. const { prefix: isPrefix, operator } = parent;
  22400. const prefix = isPrefix ? operator : ``;
  22401. const postfix = isPrefix ? `` : operator;
  22402. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22403. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  22404. } else if (isDestructureAssignment) {
  22405. return raw;
  22406. } else {
  22407. return wrapWithUnref(raw);
  22408. }
  22409. } else if (type === "props") {
  22410. return genPropsAccessExp(raw);
  22411. } else if (type === "props-aliased") {
  22412. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  22413. }
  22414. } else {
  22415. if (type && type.startsWith("setup") || type === "literal-const") {
  22416. return `$setup.${raw}`;
  22417. } else if (type === "props-aliased") {
  22418. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  22419. } else if (type) {
  22420. return `$${type}.${raw}`;
  22421. }
  22422. }
  22423. return `_ctx.${raw}`;
  22424. };
  22425. const rawExp = node.content;
  22426. let ast = node.ast;
  22427. if (ast === false) {
  22428. return node;
  22429. }
  22430. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  22431. const isScopeVarReference = context.identifiers[rawExp];
  22432. const isAllowedGlobal = isGloballyAllowed(rawExp);
  22433. const isLiteral = isLiteralWhitelisted(rawExp);
  22434. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  22435. if (isConst(bindingMetadata[rawExp])) {
  22436. node.constType = 1;
  22437. }
  22438. node.content = rewriteIdentifier(rawExp);
  22439. } else if (!isScopeVarReference) {
  22440. if (isLiteral) {
  22441. node.constType = 3;
  22442. } else {
  22443. node.constType = 2;
  22444. }
  22445. }
  22446. return node;
  22447. }
  22448. if (!ast) {
  22449. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  22450. try {
  22451. ast = libExports.parseExpression(source, {
  22452. sourceType: "module",
  22453. plugins: context.expressionPlugins
  22454. });
  22455. } catch (e) {
  22456. context.onError(
  22457. createCompilerError(
  22458. 45,
  22459. node.loc,
  22460. void 0,
  22461. e.message
  22462. )
  22463. );
  22464. return node;
  22465. }
  22466. }
  22467. const ids = [];
  22468. const parentStack = [];
  22469. const knownIds = Object.create(context.identifiers);
  22470. walkIdentifiers(
  22471. ast,
  22472. (node2, parent, _, isReferenced, isLocal) => {
  22473. if (isStaticPropertyKey(node2, parent)) {
  22474. return;
  22475. }
  22476. const needPrefix = isReferenced && canPrefix(node2);
  22477. if (needPrefix && !isLocal) {
  22478. if (isStaticProperty(parent) && parent.shorthand) {
  22479. node2.prefix = `${node2.name}: `;
  22480. }
  22481. node2.name = rewriteIdentifier(node2.name, parent, node2);
  22482. ids.push(node2);
  22483. } else {
  22484. if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
  22485. node2.isConstant = true;
  22486. }
  22487. ids.push(node2);
  22488. }
  22489. },
  22490. true,
  22491. // invoke on ALL identifiers
  22492. parentStack,
  22493. knownIds
  22494. );
  22495. const children = [];
  22496. ids.sort((a, b) => a.start - b.start);
  22497. ids.forEach((id, i) => {
  22498. const start = id.start - 1;
  22499. const end = id.end - 1;
  22500. const last = ids[i - 1];
  22501. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  22502. if (leadingText.length || id.prefix) {
  22503. children.push(leadingText + (id.prefix || ``));
  22504. }
  22505. const source = rawExp.slice(start, end);
  22506. children.push(
  22507. createSimpleExpression(
  22508. id.name,
  22509. false,
  22510. {
  22511. start: advancePositionWithClone(node.loc.start, source, start),
  22512. end: advancePositionWithClone(node.loc.start, source, end),
  22513. source
  22514. },
  22515. id.isConstant ? 3 : 0
  22516. )
  22517. );
  22518. if (i === ids.length - 1 && end < rawExp.length) {
  22519. children.push(rawExp.slice(end));
  22520. }
  22521. });
  22522. let ret;
  22523. if (children.length) {
  22524. ret = createCompoundExpression(children, node.loc);
  22525. ret.ast = ast;
  22526. } else {
  22527. ret = node;
  22528. ret.constType = 3;
  22529. }
  22530. ret.identifiers = Object.keys(knownIds);
  22531. return ret;
  22532. }
  22533. function canPrefix(id) {
  22534. if (isGloballyAllowed(id.name)) {
  22535. return false;
  22536. }
  22537. if (id.name === "require") {
  22538. return false;
  22539. }
  22540. return true;
  22541. }
  22542. function stringifyExpression(exp) {
  22543. if (isString$1(exp)) {
  22544. return exp;
  22545. } else if (exp.type === 4) {
  22546. return exp.content;
  22547. } else {
  22548. return exp.children.map(stringifyExpression).join("");
  22549. }
  22550. }
  22551. function isConst(type) {
  22552. return type === "setup-const" || type === "literal-const";
  22553. }
  22554. const transformIf = createStructuralDirectiveTransform(
  22555. /^(if|else|else-if)$/,
  22556. (node, dir, context) => {
  22557. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  22558. const siblings = context.parent.children;
  22559. let i = siblings.indexOf(ifNode);
  22560. let key = 0;
  22561. while (i-- >= 0) {
  22562. const sibling = siblings[i];
  22563. if (sibling && sibling.type === 9) {
  22564. key += sibling.branches.length;
  22565. }
  22566. }
  22567. return () => {
  22568. if (isRoot) {
  22569. ifNode.codegenNode = createCodegenNodeForBranch(
  22570. branch,
  22571. key,
  22572. context
  22573. );
  22574. } else {
  22575. const parentCondition = getParentCondition(ifNode.codegenNode);
  22576. parentCondition.alternate = createCodegenNodeForBranch(
  22577. branch,
  22578. key + ifNode.branches.length - 1,
  22579. context
  22580. );
  22581. }
  22582. };
  22583. });
  22584. }
  22585. );
  22586. function processIf(node, dir, context, processCodegen) {
  22587. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  22588. const loc = dir.exp ? dir.exp.loc : node.loc;
  22589. context.onError(
  22590. createCompilerError(28, dir.loc)
  22591. );
  22592. dir.exp = createSimpleExpression(`true`, false, loc);
  22593. }
  22594. if (context.prefixIdentifiers && dir.exp) {
  22595. dir.exp = processExpression(dir.exp, context);
  22596. }
  22597. if (dir.name === "if") {
  22598. const branch = createIfBranch(node, dir);
  22599. const ifNode = {
  22600. type: 9,
  22601. loc: cloneLoc(node.loc),
  22602. branches: [branch]
  22603. };
  22604. context.replaceNode(ifNode);
  22605. if (processCodegen) {
  22606. return processCodegen(ifNode, branch, true);
  22607. }
  22608. } else {
  22609. const siblings = context.parent.children;
  22610. const comments = [];
  22611. let i = siblings.indexOf(node);
  22612. while (i-- >= -1) {
  22613. const sibling = siblings[i];
  22614. if (sibling && sibling.type === 3) {
  22615. context.removeNode(sibling);
  22616. comments.unshift(sibling);
  22617. continue;
  22618. }
  22619. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  22620. context.removeNode(sibling);
  22621. continue;
  22622. }
  22623. if (sibling && sibling.type === 9) {
  22624. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  22625. context.onError(
  22626. createCompilerError(30, node.loc)
  22627. );
  22628. }
  22629. context.removeNode();
  22630. const branch = createIfBranch(node, dir);
  22631. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  22632. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  22633. branch.children = [...comments, ...branch.children];
  22634. }
  22635. {
  22636. const key = branch.userKey;
  22637. if (key) {
  22638. sibling.branches.forEach(({ userKey }) => {
  22639. if (isSameKey(userKey, key)) {
  22640. context.onError(
  22641. createCompilerError(
  22642. 29,
  22643. branch.userKey.loc
  22644. )
  22645. );
  22646. }
  22647. });
  22648. }
  22649. }
  22650. sibling.branches.push(branch);
  22651. const onExit = processCodegen && processCodegen(sibling, branch, false);
  22652. traverseNode(branch, context);
  22653. if (onExit) onExit();
  22654. context.currentNode = null;
  22655. } else {
  22656. context.onError(
  22657. createCompilerError(30, node.loc)
  22658. );
  22659. }
  22660. break;
  22661. }
  22662. }
  22663. }
  22664. function createIfBranch(node, dir) {
  22665. const isTemplateIf = node.tagType === 3;
  22666. return {
  22667. type: 10,
  22668. loc: node.loc,
  22669. condition: dir.name === "else" ? void 0 : dir.exp,
  22670. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  22671. userKey: findProp(node, `key`),
  22672. isTemplateIf
  22673. };
  22674. }
  22675. function createCodegenNodeForBranch(branch, keyIndex, context) {
  22676. if (branch.condition) {
  22677. return createConditionalExpression(
  22678. branch.condition,
  22679. createChildrenCodegenNode(branch, keyIndex, context),
  22680. // make sure to pass in asBlock: true so that the comment node call
  22681. // closes the current block.
  22682. createCallExpression(context.helper(CREATE_COMMENT), [
  22683. '"v-if"' ,
  22684. "true"
  22685. ])
  22686. );
  22687. } else {
  22688. return createChildrenCodegenNode(branch, keyIndex, context);
  22689. }
  22690. }
  22691. function createChildrenCodegenNode(branch, keyIndex, context) {
  22692. const { helper } = context;
  22693. const keyProperty = createObjectProperty(
  22694. `key`,
  22695. createSimpleExpression(
  22696. `${keyIndex}`,
  22697. false,
  22698. locStub,
  22699. 2
  22700. )
  22701. );
  22702. const { children } = branch;
  22703. const firstChild = children[0];
  22704. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  22705. if (needFragmentWrapper) {
  22706. if (children.length === 1 && firstChild.type === 11) {
  22707. const vnodeCall = firstChild.codegenNode;
  22708. injectProp(vnodeCall, keyProperty, context);
  22709. return vnodeCall;
  22710. } else {
  22711. let patchFlag = 64;
  22712. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  22713. patchFlag |= 2048;
  22714. }
  22715. return createVNodeCall(
  22716. context,
  22717. helper(FRAGMENT),
  22718. createObjectExpression([keyProperty]),
  22719. children,
  22720. patchFlag,
  22721. void 0,
  22722. void 0,
  22723. true,
  22724. false,
  22725. false,
  22726. branch.loc
  22727. );
  22728. }
  22729. } else {
  22730. const ret = firstChild.codegenNode;
  22731. const vnodeCall = getMemoedVNodeCall(ret);
  22732. if (vnodeCall.type === 13) {
  22733. convertToBlock(vnodeCall, context);
  22734. }
  22735. injectProp(vnodeCall, keyProperty, context);
  22736. return ret;
  22737. }
  22738. }
  22739. function isSameKey(a, b) {
  22740. if (!a || a.type !== b.type) {
  22741. return false;
  22742. }
  22743. if (a.type === 6) {
  22744. if (a.value.content !== b.value.content) {
  22745. return false;
  22746. }
  22747. } else {
  22748. const exp = a.exp;
  22749. const branchExp = b.exp;
  22750. if (exp.type !== branchExp.type) {
  22751. return false;
  22752. }
  22753. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  22754. return false;
  22755. }
  22756. }
  22757. return true;
  22758. }
  22759. function getParentCondition(node) {
  22760. while (true) {
  22761. if (node.type === 19) {
  22762. if (node.alternate.type === 19) {
  22763. node = node.alternate;
  22764. } else {
  22765. return node;
  22766. }
  22767. } else if (node.type === 20) {
  22768. node = node.value;
  22769. }
  22770. }
  22771. }
  22772. const transformBind = (dir, _node, context) => {
  22773. const { modifiers, loc } = dir;
  22774. const arg = dir.arg;
  22775. let { exp } = dir;
  22776. if (exp && exp.type === 4 && !exp.content.trim()) {
  22777. {
  22778. context.onError(
  22779. createCompilerError(34, loc)
  22780. );
  22781. return {
  22782. props: [
  22783. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22784. ]
  22785. };
  22786. }
  22787. }
  22788. if (!exp) {
  22789. if (arg.type !== 4 || !arg.isStatic) {
  22790. context.onError(
  22791. createCompilerError(
  22792. 52,
  22793. arg.loc
  22794. )
  22795. );
  22796. return {
  22797. props: [
  22798. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22799. ]
  22800. };
  22801. }
  22802. transformBindShorthand(dir, context);
  22803. exp = dir.exp;
  22804. }
  22805. if (arg.type !== 4) {
  22806. arg.children.unshift(`(`);
  22807. arg.children.push(`) || ""`);
  22808. } else if (!arg.isStatic) {
  22809. arg.content = `${arg.content} || ""`;
  22810. }
  22811. if (modifiers.some((mod) => mod.content === "camel")) {
  22812. if (arg.type === 4) {
  22813. if (arg.isStatic) {
  22814. arg.content = camelize(arg.content);
  22815. } else {
  22816. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  22817. }
  22818. } else {
  22819. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  22820. arg.children.push(`)`);
  22821. }
  22822. }
  22823. if (!context.inSSR) {
  22824. if (modifiers.some((mod) => mod.content === "prop")) {
  22825. injectPrefix(arg, ".");
  22826. }
  22827. if (modifiers.some((mod) => mod.content === "attr")) {
  22828. injectPrefix(arg, "^");
  22829. }
  22830. }
  22831. return {
  22832. props: [createObjectProperty(arg, exp)]
  22833. };
  22834. };
  22835. const transformBindShorthand = (dir, context) => {
  22836. const arg = dir.arg;
  22837. const propName = camelize(arg.content);
  22838. dir.exp = createSimpleExpression(propName, false, arg.loc);
  22839. {
  22840. dir.exp = processExpression(dir.exp, context);
  22841. }
  22842. };
  22843. const injectPrefix = (arg, prefix) => {
  22844. if (arg.type === 4) {
  22845. if (arg.isStatic) {
  22846. arg.content = prefix + arg.content;
  22847. } else {
  22848. arg.content = `\`${prefix}\${${arg.content}}\``;
  22849. }
  22850. } else {
  22851. arg.children.unshift(`'${prefix}' + (`);
  22852. arg.children.push(`)`);
  22853. }
  22854. };
  22855. const transformFor = createStructuralDirectiveTransform(
  22856. "for",
  22857. (node, dir, context) => {
  22858. const { helper, removeHelper } = context;
  22859. return processFor(node, dir, context, (forNode) => {
  22860. const renderExp = createCallExpression(helper(RENDER_LIST), [
  22861. forNode.source
  22862. ]);
  22863. const isTemplate = isTemplateNode(node);
  22864. const memo = findDir(node, "memo");
  22865. const keyProp = findProp(node, `key`, false, true);
  22866. const isDirKey = keyProp && keyProp.type === 7;
  22867. if (isDirKey && !keyProp.exp) {
  22868. transformBindShorthand(keyProp, context);
  22869. }
  22870. let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  22871. if (memo && keyExp && isDirKey) {
  22872. {
  22873. keyProp.exp = keyExp = processExpression(
  22874. keyExp,
  22875. context
  22876. );
  22877. }
  22878. }
  22879. const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
  22880. if (isTemplate) {
  22881. if (memo) {
  22882. memo.exp = processExpression(
  22883. memo.exp,
  22884. context
  22885. );
  22886. }
  22887. if (keyProperty && keyProp.type !== 6) {
  22888. keyProperty.value = processExpression(
  22889. keyProperty.value,
  22890. context
  22891. );
  22892. }
  22893. }
  22894. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  22895. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  22896. forNode.codegenNode = createVNodeCall(
  22897. context,
  22898. helper(FRAGMENT),
  22899. void 0,
  22900. renderExp,
  22901. fragmentFlag,
  22902. void 0,
  22903. void 0,
  22904. true,
  22905. !isStableFragment,
  22906. false,
  22907. node.loc
  22908. );
  22909. return () => {
  22910. let childBlock;
  22911. const { children } = forNode;
  22912. if (isTemplate) {
  22913. node.children.some((c) => {
  22914. if (c.type === 1) {
  22915. const key = findProp(c, "key");
  22916. if (key) {
  22917. context.onError(
  22918. createCompilerError(
  22919. 33,
  22920. key.loc
  22921. )
  22922. );
  22923. return true;
  22924. }
  22925. }
  22926. });
  22927. }
  22928. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  22929. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  22930. if (slotOutlet) {
  22931. childBlock = slotOutlet.codegenNode;
  22932. if (isTemplate && keyProperty) {
  22933. injectProp(childBlock, keyProperty, context);
  22934. }
  22935. } else if (needFragmentWrapper) {
  22936. childBlock = createVNodeCall(
  22937. context,
  22938. helper(FRAGMENT),
  22939. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  22940. node.children,
  22941. 64,
  22942. void 0,
  22943. void 0,
  22944. true,
  22945. void 0,
  22946. false
  22947. );
  22948. } else {
  22949. childBlock = children[0].codegenNode;
  22950. if (isTemplate && keyProperty) {
  22951. injectProp(childBlock, keyProperty, context);
  22952. }
  22953. if (childBlock.isBlock !== !isStableFragment) {
  22954. if (childBlock.isBlock) {
  22955. removeHelper(OPEN_BLOCK);
  22956. removeHelper(
  22957. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  22958. );
  22959. } else {
  22960. removeHelper(
  22961. getVNodeHelper(context.inSSR, childBlock.isComponent)
  22962. );
  22963. }
  22964. }
  22965. childBlock.isBlock = !isStableFragment;
  22966. if (childBlock.isBlock) {
  22967. helper(OPEN_BLOCK);
  22968. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  22969. } else {
  22970. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  22971. }
  22972. }
  22973. if (memo) {
  22974. const loop = createFunctionExpression(
  22975. createForLoopParams(forNode.parseResult, [
  22976. createSimpleExpression(`_cached`)
  22977. ])
  22978. );
  22979. loop.body = createBlockStatement([
  22980. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  22981. createCompoundExpression([
  22982. `if (_cached`,
  22983. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  22984. ` && ${context.helperString(
  22985. IS_MEMO_SAME
  22986. )}(_cached, _memo)) return _cached`
  22987. ]),
  22988. createCompoundExpression([`const _item = `, childBlock]),
  22989. createSimpleExpression(`_item.memo = _memo`),
  22990. createSimpleExpression(`return _item`)
  22991. ]);
  22992. renderExp.arguments.push(
  22993. loop,
  22994. createSimpleExpression(`_cache`),
  22995. createSimpleExpression(String(context.cached.length))
  22996. );
  22997. context.cached.push(null);
  22998. } else {
  22999. renderExp.arguments.push(
  23000. createFunctionExpression(
  23001. createForLoopParams(forNode.parseResult),
  23002. childBlock,
  23003. true
  23004. )
  23005. );
  23006. }
  23007. };
  23008. });
  23009. }
  23010. );
  23011. function processFor(node, dir, context, processCodegen) {
  23012. if (!dir.exp) {
  23013. context.onError(
  23014. createCompilerError(31, dir.loc)
  23015. );
  23016. return;
  23017. }
  23018. const parseResult = dir.forParseResult;
  23019. if (!parseResult) {
  23020. context.onError(
  23021. createCompilerError(32, dir.loc)
  23022. );
  23023. return;
  23024. }
  23025. finalizeForParseResult(parseResult, context);
  23026. const { addIdentifiers, removeIdentifiers, scopes } = context;
  23027. const { source, value, key, index } = parseResult;
  23028. const forNode = {
  23029. type: 11,
  23030. loc: dir.loc,
  23031. source,
  23032. valueAlias: value,
  23033. keyAlias: key,
  23034. objectIndexAlias: index,
  23035. parseResult,
  23036. children: isTemplateNode(node) ? node.children : [node]
  23037. };
  23038. context.replaceNode(forNode);
  23039. scopes.vFor++;
  23040. if (context.prefixIdentifiers) {
  23041. value && addIdentifiers(value);
  23042. key && addIdentifiers(key);
  23043. index && addIdentifiers(index);
  23044. }
  23045. const onExit = processCodegen && processCodegen(forNode);
  23046. return () => {
  23047. scopes.vFor--;
  23048. if (context.prefixIdentifiers) {
  23049. value && removeIdentifiers(value);
  23050. key && removeIdentifiers(key);
  23051. index && removeIdentifiers(index);
  23052. }
  23053. if (onExit) onExit();
  23054. };
  23055. }
  23056. function finalizeForParseResult(result, context) {
  23057. if (result.finalized) return;
  23058. if (context.prefixIdentifiers) {
  23059. result.source = processExpression(
  23060. result.source,
  23061. context
  23062. );
  23063. if (result.key) {
  23064. result.key = processExpression(
  23065. result.key,
  23066. context,
  23067. true
  23068. );
  23069. }
  23070. if (result.index) {
  23071. result.index = processExpression(
  23072. result.index,
  23073. context,
  23074. true
  23075. );
  23076. }
  23077. if (result.value) {
  23078. result.value = processExpression(
  23079. result.value,
  23080. context,
  23081. true
  23082. );
  23083. }
  23084. }
  23085. result.finalized = true;
  23086. }
  23087. function createForLoopParams({ value, key, index }, memoArgs = []) {
  23088. return createParamsList([value, key, index, ...memoArgs]);
  23089. }
  23090. function createParamsList(args) {
  23091. let i = args.length;
  23092. while (i--) {
  23093. if (args[i]) break;
  23094. }
  23095. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  23096. }
  23097. const defaultFallback = createSimpleExpression(`undefined`, false);
  23098. const trackSlotScopes = (node, context) => {
  23099. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  23100. const vSlot = findDir(node, "slot");
  23101. if (vSlot) {
  23102. const slotProps = vSlot.exp;
  23103. if (context.prefixIdentifiers) {
  23104. slotProps && context.addIdentifiers(slotProps);
  23105. }
  23106. context.scopes.vSlot++;
  23107. return () => {
  23108. if (context.prefixIdentifiers) {
  23109. slotProps && context.removeIdentifiers(slotProps);
  23110. }
  23111. context.scopes.vSlot--;
  23112. };
  23113. }
  23114. }
  23115. };
  23116. const trackVForSlotScopes = (node, context) => {
  23117. let vFor;
  23118. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  23119. const result = vFor.forParseResult;
  23120. if (result) {
  23121. finalizeForParseResult(result, context);
  23122. const { value, key, index } = result;
  23123. const { addIdentifiers, removeIdentifiers } = context;
  23124. value && addIdentifiers(value);
  23125. key && addIdentifiers(key);
  23126. index && addIdentifiers(index);
  23127. return () => {
  23128. value && removeIdentifiers(value);
  23129. key && removeIdentifiers(key);
  23130. index && removeIdentifiers(index);
  23131. };
  23132. }
  23133. }
  23134. };
  23135. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  23136. props,
  23137. children,
  23138. false,
  23139. true,
  23140. children.length ? children[0].loc : loc
  23141. );
  23142. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  23143. context.helper(WITH_CTX);
  23144. const { children, loc } = node;
  23145. const slotsProperties = [];
  23146. const dynamicSlots = [];
  23147. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  23148. if (!context.ssr && context.prefixIdentifiers) {
  23149. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  23150. }
  23151. const onComponentSlot = findDir(node, "slot", true);
  23152. if (onComponentSlot) {
  23153. const { arg, exp } = onComponentSlot;
  23154. if (arg && !isStaticExp(arg)) {
  23155. hasDynamicSlots = true;
  23156. }
  23157. slotsProperties.push(
  23158. createObjectProperty(
  23159. arg || createSimpleExpression("default", true),
  23160. buildSlotFn(exp, void 0, children, loc)
  23161. )
  23162. );
  23163. }
  23164. let hasTemplateSlots = false;
  23165. let hasNamedDefaultSlot = false;
  23166. const implicitDefaultChildren = [];
  23167. const seenSlotNames = /* @__PURE__ */ new Set();
  23168. let conditionalBranchIndex = 0;
  23169. for (let i = 0; i < children.length; i++) {
  23170. const slotElement = children[i];
  23171. let slotDir;
  23172. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  23173. if (slotElement.type !== 3) {
  23174. implicitDefaultChildren.push(slotElement);
  23175. }
  23176. continue;
  23177. }
  23178. if (onComponentSlot) {
  23179. context.onError(
  23180. createCompilerError(37, slotDir.loc)
  23181. );
  23182. break;
  23183. }
  23184. hasTemplateSlots = true;
  23185. const { children: slotChildren, loc: slotLoc } = slotElement;
  23186. const {
  23187. arg: slotName = createSimpleExpression(`default`, true),
  23188. exp: slotProps,
  23189. loc: dirLoc
  23190. } = slotDir;
  23191. let staticSlotName;
  23192. if (isStaticExp(slotName)) {
  23193. staticSlotName = slotName ? slotName.content : `default`;
  23194. } else {
  23195. hasDynamicSlots = true;
  23196. }
  23197. const vFor = findDir(slotElement, "for");
  23198. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  23199. let vIf;
  23200. let vElse;
  23201. if (vIf = findDir(slotElement, "if")) {
  23202. hasDynamicSlots = true;
  23203. dynamicSlots.push(
  23204. createConditionalExpression(
  23205. vIf.exp,
  23206. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  23207. defaultFallback
  23208. )
  23209. );
  23210. } else if (vElse = findDir(
  23211. slotElement,
  23212. /^else(-if)?$/,
  23213. true
  23214. /* allowEmpty */
  23215. )) {
  23216. let j = i;
  23217. let prev;
  23218. while (j--) {
  23219. prev = children[j];
  23220. if (prev.type !== 3) {
  23221. break;
  23222. }
  23223. }
  23224. if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
  23225. let conditional = dynamicSlots[dynamicSlots.length - 1];
  23226. while (conditional.alternate.type === 19) {
  23227. conditional = conditional.alternate;
  23228. }
  23229. conditional.alternate = vElse.exp ? createConditionalExpression(
  23230. vElse.exp,
  23231. buildDynamicSlot(
  23232. slotName,
  23233. slotFunction,
  23234. conditionalBranchIndex++
  23235. ),
  23236. defaultFallback
  23237. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  23238. } else {
  23239. context.onError(
  23240. createCompilerError(30, vElse.loc)
  23241. );
  23242. }
  23243. } else if (vFor) {
  23244. hasDynamicSlots = true;
  23245. const parseResult = vFor.forParseResult;
  23246. if (parseResult) {
  23247. finalizeForParseResult(parseResult, context);
  23248. dynamicSlots.push(
  23249. createCallExpression(context.helper(RENDER_LIST), [
  23250. parseResult.source,
  23251. createFunctionExpression(
  23252. createForLoopParams(parseResult),
  23253. buildDynamicSlot(slotName, slotFunction),
  23254. true
  23255. )
  23256. ])
  23257. );
  23258. } else {
  23259. context.onError(
  23260. createCompilerError(
  23261. 32,
  23262. vFor.loc
  23263. )
  23264. );
  23265. }
  23266. } else {
  23267. if (staticSlotName) {
  23268. if (seenSlotNames.has(staticSlotName)) {
  23269. context.onError(
  23270. createCompilerError(
  23271. 38,
  23272. dirLoc
  23273. )
  23274. );
  23275. continue;
  23276. }
  23277. seenSlotNames.add(staticSlotName);
  23278. if (staticSlotName === "default") {
  23279. hasNamedDefaultSlot = true;
  23280. }
  23281. }
  23282. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  23283. }
  23284. }
  23285. if (!onComponentSlot) {
  23286. const buildDefaultSlotProperty = (props, children2) => {
  23287. const fn = buildSlotFn(props, void 0, children2, loc);
  23288. return createObjectProperty(`default`, fn);
  23289. };
  23290. if (!hasTemplateSlots) {
  23291. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  23292. } else if (implicitDefaultChildren.length && // #3766
  23293. // with whitespace: 'preserve', whitespaces between slots will end up in
  23294. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  23295. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  23296. if (hasNamedDefaultSlot) {
  23297. context.onError(
  23298. createCompilerError(
  23299. 39,
  23300. implicitDefaultChildren[0].loc
  23301. )
  23302. );
  23303. } else {
  23304. slotsProperties.push(
  23305. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  23306. );
  23307. }
  23308. }
  23309. }
  23310. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  23311. let slots = createObjectExpression(
  23312. slotsProperties.concat(
  23313. createObjectProperty(
  23314. `_`,
  23315. // 2 = compiled but dynamic = can skip normalization, but must run diff
  23316. // 1 = compiled and static = can skip normalization AND diff as optimized
  23317. createSimpleExpression(
  23318. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  23319. false
  23320. )
  23321. )
  23322. ),
  23323. loc
  23324. );
  23325. if (dynamicSlots.length) {
  23326. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  23327. slots,
  23328. createArrayExpression(dynamicSlots)
  23329. ]);
  23330. }
  23331. return {
  23332. slots,
  23333. hasDynamicSlots
  23334. };
  23335. }
  23336. function buildDynamicSlot(name, fn, index) {
  23337. const props = [
  23338. createObjectProperty(`name`, name),
  23339. createObjectProperty(`fn`, fn)
  23340. ];
  23341. if (index != null) {
  23342. props.push(
  23343. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  23344. );
  23345. }
  23346. return createObjectExpression(props);
  23347. }
  23348. function hasForwardedSlots(children) {
  23349. for (let i = 0; i < children.length; i++) {
  23350. const child = children[i];
  23351. switch (child.type) {
  23352. case 1:
  23353. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  23354. return true;
  23355. }
  23356. break;
  23357. case 9:
  23358. if (hasForwardedSlots(child.branches)) return true;
  23359. break;
  23360. case 10:
  23361. case 11:
  23362. if (hasForwardedSlots(child.children)) return true;
  23363. break;
  23364. }
  23365. }
  23366. return false;
  23367. }
  23368. function isNonWhitespaceContent(node) {
  23369. if (node.type !== 2 && node.type !== 12)
  23370. return true;
  23371. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  23372. }
  23373. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  23374. const transformElement = (node, context) => {
  23375. return function postTransformElement() {
  23376. node = context.currentNode;
  23377. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  23378. return;
  23379. }
  23380. const { tag, props } = node;
  23381. const isComponent = node.tagType === 1;
  23382. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  23383. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23384. let vnodeProps;
  23385. let vnodeChildren;
  23386. let patchFlag = 0;
  23387. let vnodeDynamicProps;
  23388. let dynamicPropNames;
  23389. let vnodeDirectives;
  23390. let shouldUseBlock = (
  23391. // dynamic component may resolve to plain elements
  23392. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23393. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23394. // This is technically web-specific, but splitting the logic out of core
  23395. // leads to too much unnecessary complexity.
  23396. (tag === "svg" || tag === "foreignObject" || tag === "math")
  23397. );
  23398. if (props.length > 0) {
  23399. const propsBuildResult = buildProps(
  23400. node,
  23401. context,
  23402. void 0,
  23403. isComponent,
  23404. isDynamicComponent
  23405. );
  23406. vnodeProps = propsBuildResult.props;
  23407. patchFlag = propsBuildResult.patchFlag;
  23408. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23409. const directives = propsBuildResult.directives;
  23410. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23411. directives.map((dir) => buildDirectiveArgs(dir, context))
  23412. ) : void 0;
  23413. if (propsBuildResult.shouldUseBlock) {
  23414. shouldUseBlock = true;
  23415. }
  23416. }
  23417. if (node.children.length > 0) {
  23418. if (vnodeTag === KEEP_ALIVE) {
  23419. shouldUseBlock = true;
  23420. patchFlag |= 1024;
  23421. if (node.children.length > 1) {
  23422. context.onError(
  23423. createCompilerError(46, {
  23424. start: node.children[0].loc.start,
  23425. end: node.children[node.children.length - 1].loc.end,
  23426. source: ""
  23427. })
  23428. );
  23429. }
  23430. }
  23431. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  23432. vnodeTag !== TELEPORT && // explained above.
  23433. vnodeTag !== KEEP_ALIVE;
  23434. if (shouldBuildAsSlots) {
  23435. const { slots, hasDynamicSlots } = buildSlots(node, context);
  23436. vnodeChildren = slots;
  23437. if (hasDynamicSlots) {
  23438. patchFlag |= 1024;
  23439. }
  23440. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  23441. const child = node.children[0];
  23442. const type = child.type;
  23443. const hasDynamicTextChild = type === 5 || type === 8;
  23444. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  23445. patchFlag |= 1;
  23446. }
  23447. if (hasDynamicTextChild || type === 2) {
  23448. vnodeChildren = child;
  23449. } else {
  23450. vnodeChildren = node.children;
  23451. }
  23452. } else {
  23453. vnodeChildren = node.children;
  23454. }
  23455. }
  23456. if (dynamicPropNames && dynamicPropNames.length) {
  23457. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  23458. }
  23459. node.codegenNode = createVNodeCall(
  23460. context,
  23461. vnodeTag,
  23462. vnodeProps,
  23463. vnodeChildren,
  23464. patchFlag === 0 ? void 0 : patchFlag,
  23465. vnodeDynamicProps,
  23466. vnodeDirectives,
  23467. !!shouldUseBlock,
  23468. false,
  23469. isComponent,
  23470. node.loc
  23471. );
  23472. };
  23473. };
  23474. function resolveComponentType(node, context, ssr = false) {
  23475. let { tag } = node;
  23476. const isExplicitDynamic = isComponentTag(tag);
  23477. const isProp = findProp(
  23478. node,
  23479. "is",
  23480. false,
  23481. true
  23482. /* allow empty */
  23483. );
  23484. if (isProp) {
  23485. if (isExplicitDynamic || false) {
  23486. let exp;
  23487. if (isProp.type === 6) {
  23488. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  23489. } else {
  23490. exp = isProp.exp;
  23491. if (!exp) {
  23492. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  23493. {
  23494. exp = isProp.exp = processExpression(exp, context);
  23495. }
  23496. }
  23497. }
  23498. if (exp) {
  23499. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  23500. exp
  23501. ]);
  23502. }
  23503. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  23504. tag = isProp.value.content.slice(4);
  23505. }
  23506. }
  23507. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  23508. if (builtIn) {
  23509. if (!ssr) context.helper(builtIn);
  23510. return builtIn;
  23511. }
  23512. {
  23513. const fromSetup = resolveSetupReference(tag, context);
  23514. if (fromSetup) {
  23515. return fromSetup;
  23516. }
  23517. const dotIndex = tag.indexOf(".");
  23518. if (dotIndex > 0) {
  23519. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  23520. if (ns) {
  23521. return ns + tag.slice(dotIndex);
  23522. }
  23523. }
  23524. }
  23525. if (context.selfName && capitalize(camelize(tag)) === context.selfName) {
  23526. context.helper(RESOLVE_COMPONENT);
  23527. context.components.add(tag + `__self`);
  23528. return toValidAssetId(tag, `component`);
  23529. }
  23530. context.helper(RESOLVE_COMPONENT);
  23531. context.components.add(tag);
  23532. return toValidAssetId(tag, `component`);
  23533. }
  23534. function resolveSetupReference(name, context) {
  23535. const bindings = context.bindingMetadata;
  23536. if (!bindings || bindings.__isScriptSetup === false) {
  23537. return;
  23538. }
  23539. const camelName = camelize(name);
  23540. const PascalName = capitalize(camelName);
  23541. const checkType = (type) => {
  23542. if (bindings[name] === type) {
  23543. return name;
  23544. }
  23545. if (bindings[camelName] === type) {
  23546. return camelName;
  23547. }
  23548. if (bindings[PascalName] === type) {
  23549. return PascalName;
  23550. }
  23551. };
  23552. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  23553. if (fromConst) {
  23554. return context.inline ? (
  23555. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  23556. fromConst
  23557. ) : `$setup[${JSON.stringify(fromConst)}]`;
  23558. }
  23559. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  23560. if (fromMaybeRef) {
  23561. return context.inline ? (
  23562. // setup scope bindings that may be refs need to be unrefed
  23563. `${context.helperString(UNREF)}(${fromMaybeRef})`
  23564. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  23565. }
  23566. const fromProps = checkType("props");
  23567. if (fromProps) {
  23568. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  23569. }
  23570. }
  23571. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  23572. const { tag, loc: elementLoc, children } = node;
  23573. let properties = [];
  23574. const mergeArgs = [];
  23575. const runtimeDirectives = [];
  23576. const hasChildren = children.length > 0;
  23577. let shouldUseBlock = false;
  23578. let patchFlag = 0;
  23579. let hasRef = false;
  23580. let hasClassBinding = false;
  23581. let hasStyleBinding = false;
  23582. let hasHydrationEventBinding = false;
  23583. let hasDynamicKeys = false;
  23584. let hasVnodeHook = false;
  23585. const dynamicPropNames = [];
  23586. const pushMergeArg = (arg) => {
  23587. if (properties.length) {
  23588. mergeArgs.push(
  23589. createObjectExpression(dedupeProperties(properties), elementLoc)
  23590. );
  23591. properties = [];
  23592. }
  23593. if (arg) mergeArgs.push(arg);
  23594. };
  23595. const pushRefVForMarker = () => {
  23596. if (context.scopes.vFor > 0) {
  23597. properties.push(
  23598. createObjectProperty(
  23599. createSimpleExpression("ref_for", true),
  23600. createSimpleExpression("true")
  23601. )
  23602. );
  23603. }
  23604. };
  23605. const analyzePatchFlag = ({ key, value }) => {
  23606. if (isStaticExp(key)) {
  23607. const name = key.content;
  23608. const isEventHandler = isOn(name);
  23609. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  23610. // dedicated fast path.
  23611. name.toLowerCase() !== "onclick" && // omit v-model handlers
  23612. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  23613. !isReservedProp(name)) {
  23614. hasHydrationEventBinding = true;
  23615. }
  23616. if (isEventHandler && isReservedProp(name)) {
  23617. hasVnodeHook = true;
  23618. }
  23619. if (isEventHandler && value.type === 14) {
  23620. value = value.arguments[0];
  23621. }
  23622. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  23623. return;
  23624. }
  23625. if (name === "ref") {
  23626. hasRef = true;
  23627. } else if (name === "class") {
  23628. hasClassBinding = true;
  23629. } else if (name === "style") {
  23630. hasStyleBinding = true;
  23631. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  23632. dynamicPropNames.push(name);
  23633. }
  23634. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  23635. dynamicPropNames.push(name);
  23636. }
  23637. } else {
  23638. hasDynamicKeys = true;
  23639. }
  23640. };
  23641. for (let i = 0; i < props.length; i++) {
  23642. const prop = props[i];
  23643. if (prop.type === 6) {
  23644. const { loc, name, nameLoc, value } = prop;
  23645. let isStatic = true;
  23646. if (name === "ref") {
  23647. hasRef = true;
  23648. pushRefVForMarker();
  23649. if (value && context.inline) {
  23650. const binding = context.bindingMetadata[value.content];
  23651. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  23652. isStatic = false;
  23653. properties.push(
  23654. createObjectProperty(
  23655. createSimpleExpression("ref_key", true),
  23656. createSimpleExpression(value.content, true, value.loc)
  23657. )
  23658. );
  23659. }
  23660. }
  23661. }
  23662. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  23663. continue;
  23664. }
  23665. properties.push(
  23666. createObjectProperty(
  23667. createSimpleExpression(name, true, nameLoc),
  23668. createSimpleExpression(
  23669. value ? value.content : "",
  23670. isStatic,
  23671. value ? value.loc : loc
  23672. )
  23673. )
  23674. );
  23675. } else {
  23676. const { name, arg, exp, loc, modifiers } = prop;
  23677. const isVBind = name === "bind";
  23678. const isVOn = name === "on";
  23679. if (name === "slot") {
  23680. if (!isComponent) {
  23681. context.onError(
  23682. createCompilerError(40, loc)
  23683. );
  23684. }
  23685. continue;
  23686. }
  23687. if (name === "once" || name === "memo") {
  23688. continue;
  23689. }
  23690. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  23691. continue;
  23692. }
  23693. if (isVOn && ssr) {
  23694. continue;
  23695. }
  23696. if (
  23697. // #938: elements with dynamic keys should be forced into blocks
  23698. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  23699. // before children
  23700. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  23701. ) {
  23702. shouldUseBlock = true;
  23703. }
  23704. if (isVBind && isStaticArgOf(arg, "ref")) {
  23705. pushRefVForMarker();
  23706. }
  23707. if (!arg && (isVBind || isVOn)) {
  23708. hasDynamicKeys = true;
  23709. if (exp) {
  23710. if (isVBind) {
  23711. pushRefVForMarker();
  23712. pushMergeArg();
  23713. mergeArgs.push(exp);
  23714. } else {
  23715. pushMergeArg({
  23716. type: 14,
  23717. loc,
  23718. callee: context.helper(TO_HANDLERS),
  23719. arguments: isComponent ? [exp] : [exp, `true`]
  23720. });
  23721. }
  23722. } else {
  23723. context.onError(
  23724. createCompilerError(
  23725. isVBind ? 34 : 35,
  23726. loc
  23727. )
  23728. );
  23729. }
  23730. continue;
  23731. }
  23732. if (isVBind && modifiers.some((mod) => mod.content === "prop")) {
  23733. patchFlag |= 32;
  23734. }
  23735. const directiveTransform = context.directiveTransforms[name];
  23736. if (directiveTransform) {
  23737. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  23738. !ssr && props2.forEach(analyzePatchFlag);
  23739. if (isVOn && arg && !isStaticExp(arg)) {
  23740. pushMergeArg(createObjectExpression(props2, elementLoc));
  23741. } else {
  23742. properties.push(...props2);
  23743. }
  23744. if (needRuntime) {
  23745. runtimeDirectives.push(prop);
  23746. if (isSymbol$1(needRuntime)) {
  23747. directiveImportMap.set(prop, needRuntime);
  23748. }
  23749. }
  23750. } else if (!isBuiltInDirective(name)) {
  23751. runtimeDirectives.push(prop);
  23752. if (hasChildren) {
  23753. shouldUseBlock = true;
  23754. }
  23755. }
  23756. }
  23757. }
  23758. let propsExpression = void 0;
  23759. if (mergeArgs.length) {
  23760. pushMergeArg();
  23761. if (mergeArgs.length > 1) {
  23762. propsExpression = createCallExpression(
  23763. context.helper(MERGE_PROPS),
  23764. mergeArgs,
  23765. elementLoc
  23766. );
  23767. } else {
  23768. propsExpression = mergeArgs[0];
  23769. }
  23770. } else if (properties.length) {
  23771. propsExpression = createObjectExpression(
  23772. dedupeProperties(properties),
  23773. elementLoc
  23774. );
  23775. }
  23776. if (hasDynamicKeys) {
  23777. patchFlag |= 16;
  23778. } else {
  23779. if (hasClassBinding && !isComponent) {
  23780. patchFlag |= 2;
  23781. }
  23782. if (hasStyleBinding && !isComponent) {
  23783. patchFlag |= 4;
  23784. }
  23785. if (dynamicPropNames.length) {
  23786. patchFlag |= 8;
  23787. }
  23788. if (hasHydrationEventBinding) {
  23789. patchFlag |= 32;
  23790. }
  23791. }
  23792. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  23793. patchFlag |= 512;
  23794. }
  23795. if (!context.inSSR && propsExpression) {
  23796. switch (propsExpression.type) {
  23797. case 15:
  23798. let classKeyIndex = -1;
  23799. let styleKeyIndex = -1;
  23800. let hasDynamicKey = false;
  23801. for (let i = 0; i < propsExpression.properties.length; i++) {
  23802. const key = propsExpression.properties[i].key;
  23803. if (isStaticExp(key)) {
  23804. if (key.content === "class") {
  23805. classKeyIndex = i;
  23806. } else if (key.content === "style") {
  23807. styleKeyIndex = i;
  23808. }
  23809. } else if (!key.isHandlerKey) {
  23810. hasDynamicKey = true;
  23811. }
  23812. }
  23813. const classProp = propsExpression.properties[classKeyIndex];
  23814. const styleProp = propsExpression.properties[styleKeyIndex];
  23815. if (!hasDynamicKey) {
  23816. if (classProp && !isStaticExp(classProp.value)) {
  23817. classProp.value = createCallExpression(
  23818. context.helper(NORMALIZE_CLASS),
  23819. [classProp.value]
  23820. );
  23821. }
  23822. if (styleProp && // the static style is compiled into an object,
  23823. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  23824. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  23825. // v-bind:style with static literal object
  23826. styleProp.value.type === 17)) {
  23827. styleProp.value = createCallExpression(
  23828. context.helper(NORMALIZE_STYLE),
  23829. [styleProp.value]
  23830. );
  23831. }
  23832. } else {
  23833. propsExpression = createCallExpression(
  23834. context.helper(NORMALIZE_PROPS),
  23835. [propsExpression]
  23836. );
  23837. }
  23838. break;
  23839. case 14:
  23840. break;
  23841. default:
  23842. propsExpression = createCallExpression(
  23843. context.helper(NORMALIZE_PROPS),
  23844. [
  23845. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  23846. propsExpression
  23847. ])
  23848. ]
  23849. );
  23850. break;
  23851. }
  23852. }
  23853. return {
  23854. props: propsExpression,
  23855. directives: runtimeDirectives,
  23856. patchFlag,
  23857. dynamicPropNames,
  23858. shouldUseBlock
  23859. };
  23860. }
  23861. function dedupeProperties(properties) {
  23862. const knownProps = /* @__PURE__ */ new Map();
  23863. const deduped = [];
  23864. for (let i = 0; i < properties.length; i++) {
  23865. const prop = properties[i];
  23866. if (prop.key.type === 8 || !prop.key.isStatic) {
  23867. deduped.push(prop);
  23868. continue;
  23869. }
  23870. const name = prop.key.content;
  23871. const existing = knownProps.get(name);
  23872. if (existing) {
  23873. if (name === "style" || name === "class" || isOn(name)) {
  23874. mergeAsArray(existing, prop);
  23875. }
  23876. } else {
  23877. knownProps.set(name, prop);
  23878. deduped.push(prop);
  23879. }
  23880. }
  23881. return deduped;
  23882. }
  23883. function mergeAsArray(existing, incoming) {
  23884. if (existing.value.type === 17) {
  23885. existing.value.elements.push(incoming.value);
  23886. } else {
  23887. existing.value = createArrayExpression(
  23888. [existing.value, incoming.value],
  23889. existing.loc
  23890. );
  23891. }
  23892. }
  23893. function buildDirectiveArgs(dir, context) {
  23894. const dirArgs = [];
  23895. const runtime = directiveImportMap.get(dir);
  23896. if (runtime) {
  23897. dirArgs.push(context.helperString(runtime));
  23898. } else {
  23899. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  23900. if (fromSetup) {
  23901. dirArgs.push(fromSetup);
  23902. } else {
  23903. context.helper(RESOLVE_DIRECTIVE);
  23904. context.directives.add(dir.name);
  23905. dirArgs.push(toValidAssetId(dir.name, `directive`));
  23906. }
  23907. }
  23908. const { loc } = dir;
  23909. if (dir.exp) dirArgs.push(dir.exp);
  23910. if (dir.arg) {
  23911. if (!dir.exp) {
  23912. dirArgs.push(`void 0`);
  23913. }
  23914. dirArgs.push(dir.arg);
  23915. }
  23916. if (Object.keys(dir.modifiers).length) {
  23917. if (!dir.arg) {
  23918. if (!dir.exp) {
  23919. dirArgs.push(`void 0`);
  23920. }
  23921. dirArgs.push(`void 0`);
  23922. }
  23923. const trueExpression = createSimpleExpression(`true`, false, loc);
  23924. dirArgs.push(
  23925. createObjectExpression(
  23926. dir.modifiers.map(
  23927. (modifier) => createObjectProperty(modifier, trueExpression)
  23928. ),
  23929. loc
  23930. )
  23931. );
  23932. }
  23933. return createArrayExpression(dirArgs, dir.loc);
  23934. }
  23935. function stringifyDynamicPropNames(props) {
  23936. let propsNamesString = `[`;
  23937. for (let i = 0, l = props.length; i < l; i++) {
  23938. propsNamesString += JSON.stringify(props[i]);
  23939. if (i < l - 1) propsNamesString += ", ";
  23940. }
  23941. return propsNamesString + `]`;
  23942. }
  23943. function isComponentTag(tag) {
  23944. return tag === "component" || tag === "Component";
  23945. }
  23946. const transformSlotOutlet = (node, context) => {
  23947. if (isSlotOutlet(node)) {
  23948. const { children, loc } = node;
  23949. const { slotName, slotProps } = processSlotOutlet(node, context);
  23950. const slotArgs = [
  23951. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  23952. slotName,
  23953. "{}",
  23954. "undefined",
  23955. "true"
  23956. ];
  23957. let expectedLen = 2;
  23958. if (slotProps) {
  23959. slotArgs[2] = slotProps;
  23960. expectedLen = 3;
  23961. }
  23962. if (children.length) {
  23963. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  23964. expectedLen = 4;
  23965. }
  23966. if (context.scopeId && !context.slotted) {
  23967. expectedLen = 5;
  23968. }
  23969. slotArgs.splice(expectedLen);
  23970. node.codegenNode = createCallExpression(
  23971. context.helper(RENDER_SLOT),
  23972. slotArgs,
  23973. loc
  23974. );
  23975. }
  23976. };
  23977. function processSlotOutlet(node, context) {
  23978. let slotName = `"default"`;
  23979. let slotProps = void 0;
  23980. const nonNameProps = [];
  23981. for (let i = 0; i < node.props.length; i++) {
  23982. const p = node.props[i];
  23983. if (p.type === 6) {
  23984. if (p.value) {
  23985. if (p.name === "name") {
  23986. slotName = JSON.stringify(p.value.content);
  23987. } else {
  23988. p.name = camelize(p.name);
  23989. nonNameProps.push(p);
  23990. }
  23991. }
  23992. } else {
  23993. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  23994. if (p.exp) {
  23995. slotName = p.exp;
  23996. } else if (p.arg && p.arg.type === 4) {
  23997. const name = camelize(p.arg.content);
  23998. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  23999. {
  24000. slotName = p.exp = processExpression(p.exp, context);
  24001. }
  24002. }
  24003. } else {
  24004. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  24005. p.arg.content = camelize(p.arg.content);
  24006. }
  24007. nonNameProps.push(p);
  24008. }
  24009. }
  24010. }
  24011. if (nonNameProps.length > 0) {
  24012. const { props, directives } = buildProps(
  24013. node,
  24014. context,
  24015. nonNameProps,
  24016. false,
  24017. false
  24018. );
  24019. slotProps = props;
  24020. if (directives.length) {
  24021. context.onError(
  24022. createCompilerError(
  24023. 36,
  24024. directives[0].loc
  24025. )
  24026. );
  24027. }
  24028. }
  24029. return {
  24030. slotName,
  24031. slotProps
  24032. };
  24033. }
  24034. const transformOn$1 = (dir, node, context, augmentor) => {
  24035. const { loc, modifiers, arg } = dir;
  24036. if (!dir.exp && !modifiers.length) {
  24037. context.onError(createCompilerError(35, loc));
  24038. }
  24039. let eventName;
  24040. if (arg.type === 4) {
  24041. if (arg.isStatic) {
  24042. let rawName = arg.content;
  24043. if (rawName.startsWith("vnode")) {
  24044. context.onError(createCompilerError(51, arg.loc));
  24045. }
  24046. if (rawName.startsWith("vue:")) {
  24047. rawName = `vnode-${rawName.slice(4)}`;
  24048. }
  24049. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  24050. // for non-element and vnode lifecycle event listeners, auto convert
  24051. // it to camelCase. See issue #2249
  24052. toHandlerKey(camelize(rawName))
  24053. ) : (
  24054. // preserve case for plain element listeners that have uppercase
  24055. // letters, as these may be custom elements' custom events
  24056. `on:${rawName}`
  24057. );
  24058. eventName = createSimpleExpression(eventString, true, arg.loc);
  24059. } else {
  24060. eventName = createCompoundExpression([
  24061. `${context.helperString(TO_HANDLER_KEY)}(`,
  24062. arg,
  24063. `)`
  24064. ]);
  24065. }
  24066. } else {
  24067. eventName = arg;
  24068. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  24069. eventName.children.push(`)`);
  24070. }
  24071. let exp = dir.exp;
  24072. if (exp && !exp.content.trim()) {
  24073. exp = void 0;
  24074. }
  24075. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  24076. if (exp) {
  24077. const isMemberExp = isMemberExpression(exp, context);
  24078. const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
  24079. const hasMultipleStatements = exp.content.includes(`;`);
  24080. if (context.prefixIdentifiers) {
  24081. isInlineStatement && context.addIdentifiers(`$event`);
  24082. exp = dir.exp = processExpression(
  24083. exp,
  24084. context,
  24085. false,
  24086. hasMultipleStatements
  24087. );
  24088. isInlineStatement && context.removeIdentifiers(`$event`);
  24089. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  24090. !context.inVOnce && // runtime constants don't need to be cached
  24091. // (this is analyzed by compileScript in SFC <script setup>)
  24092. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  24093. // we need to use the original function to preserve arity,
  24094. // e.g. <transition> relies on checking cb.length to determine
  24095. // transition end handling. Inline function is ok since its arity
  24096. // is preserved even when cached.
  24097. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  24098. // it must be passed fresh to avoid stale values.
  24099. !hasScopeRef(exp, context.identifiers);
  24100. if (shouldCache && isMemberExp) {
  24101. if (exp.type === 4) {
  24102. exp.content = `${exp.content} && ${exp.content}(...args)`;
  24103. } else {
  24104. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  24105. }
  24106. }
  24107. }
  24108. if (isInlineStatement || shouldCache && isMemberExp) {
  24109. exp = createCompoundExpression([
  24110. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  24111. //@ts-ignore
  24112. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  24113. exp,
  24114. hasMultipleStatements ? `}` : `)`
  24115. ]);
  24116. }
  24117. }
  24118. let ret = {
  24119. props: [
  24120. createObjectProperty(
  24121. eventName,
  24122. exp || createSimpleExpression(`() => {}`, false, loc)
  24123. )
  24124. ]
  24125. };
  24126. if (augmentor) {
  24127. ret = augmentor(ret);
  24128. }
  24129. if (shouldCache) {
  24130. ret.props[0].value = context.cache(ret.props[0].value);
  24131. }
  24132. ret.props.forEach((p) => p.key.isHandlerKey = true);
  24133. return ret;
  24134. };
  24135. const transformText = (node, context) => {
  24136. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  24137. return () => {
  24138. const children = node.children;
  24139. let currentContainer = void 0;
  24140. let hasText = false;
  24141. for (let i = 0; i < children.length; i++) {
  24142. const child = children[i];
  24143. if (isText$1(child)) {
  24144. hasText = true;
  24145. for (let j = i + 1; j < children.length; j++) {
  24146. const next = children[j];
  24147. if (isText$1(next)) {
  24148. if (!currentContainer) {
  24149. currentContainer = children[i] = createCompoundExpression(
  24150. [child],
  24151. child.loc
  24152. );
  24153. }
  24154. currentContainer.children.push(` + `, next);
  24155. children.splice(j, 1);
  24156. j--;
  24157. } else {
  24158. currentContainer = void 0;
  24159. break;
  24160. }
  24161. }
  24162. }
  24163. }
  24164. if (!hasText || // if this is a plain element with a single text child, leave it
  24165. // as-is since the runtime has dedicated fast path for this by directly
  24166. // setting textContent of the element.
  24167. // for component root it's always normalized anyway.
  24168. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  24169. // custom directives can potentially add DOM elements arbitrarily,
  24170. // we need to avoid setting textContent of the element at runtime
  24171. // to avoid accidentally overwriting the DOM elements added
  24172. // by the user through custom directives.
  24173. !node.props.find(
  24174. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  24175. ) && // in compat mode, <template> tags with no special directives
  24176. // will be rendered as a fragment so its children must be
  24177. // converted into vnodes.
  24178. true)) {
  24179. return;
  24180. }
  24181. for (let i = 0; i < children.length; i++) {
  24182. const child = children[i];
  24183. if (isText$1(child) || child.type === 8) {
  24184. const callArgs = [];
  24185. if (child.type !== 2 || child.content !== " ") {
  24186. callArgs.push(child);
  24187. }
  24188. if (!context.ssr && getConstantType(child, context) === 0) {
  24189. callArgs.push(
  24190. 1 + (` /* ${PatchFlagNames[1]} */` )
  24191. );
  24192. }
  24193. children[i] = {
  24194. type: 12,
  24195. content: child,
  24196. loc: child.loc,
  24197. codegenNode: createCallExpression(
  24198. context.helper(CREATE_TEXT),
  24199. callArgs
  24200. )
  24201. };
  24202. }
  24203. }
  24204. };
  24205. }
  24206. };
  24207. const seen$1 = /* @__PURE__ */ new WeakSet();
  24208. const transformOnce = (node, context) => {
  24209. if (node.type === 1 && findDir(node, "once", true)) {
  24210. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  24211. return;
  24212. }
  24213. seen$1.add(node);
  24214. context.inVOnce = true;
  24215. context.helper(SET_BLOCK_TRACKING);
  24216. return () => {
  24217. context.inVOnce = false;
  24218. const cur = context.currentNode;
  24219. if (cur.codegenNode) {
  24220. cur.codegenNode = context.cache(
  24221. cur.codegenNode,
  24222. true,
  24223. true
  24224. );
  24225. }
  24226. };
  24227. }
  24228. };
  24229. const transformModel$1 = (dir, node, context) => {
  24230. const { exp, arg } = dir;
  24231. if (!exp) {
  24232. context.onError(
  24233. createCompilerError(41, dir.loc)
  24234. );
  24235. return createTransformProps();
  24236. }
  24237. const rawExp = exp.loc.source.trim();
  24238. const expString = exp.type === 4 ? exp.content : rawExp;
  24239. const bindingType = context.bindingMetadata[rawExp];
  24240. if (bindingType === "props" || bindingType === "props-aliased") {
  24241. context.onError(createCompilerError(44, exp.loc));
  24242. return createTransformProps();
  24243. }
  24244. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  24245. if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
  24246. context.onError(
  24247. createCompilerError(42, exp.loc)
  24248. );
  24249. return createTransformProps();
  24250. }
  24251. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  24252. context.onError(
  24253. createCompilerError(43, exp.loc)
  24254. );
  24255. return createTransformProps();
  24256. }
  24257. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  24258. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  24259. let assignmentExp;
  24260. const eventArg = context.isTS ? `($event: any)` : `$event`;
  24261. if (maybeRef) {
  24262. if (bindingType === "setup-ref") {
  24263. assignmentExp = createCompoundExpression([
  24264. `${eventArg} => ((`,
  24265. createSimpleExpression(rawExp, false, exp.loc),
  24266. `).value = $event)`
  24267. ]);
  24268. } else {
  24269. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  24270. assignmentExp = createCompoundExpression([
  24271. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  24272. createSimpleExpression(rawExp, false, exp.loc),
  24273. `).value = $event : ${altAssignment})`
  24274. ]);
  24275. }
  24276. } else {
  24277. assignmentExp = createCompoundExpression([
  24278. `${eventArg} => ((`,
  24279. exp,
  24280. `) = $event)`
  24281. ]);
  24282. }
  24283. const props = [
  24284. // modelValue: foo
  24285. createObjectProperty(propName, dir.exp),
  24286. // "onUpdate:modelValue": $event => (foo = $event)
  24287. createObjectProperty(eventName, assignmentExp)
  24288. ];
  24289. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  24290. props[1].value = context.cache(props[1].value);
  24291. }
  24292. if (dir.modifiers.length && node.tagType === 1) {
  24293. const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  24294. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  24295. props.push(
  24296. createObjectProperty(
  24297. modifiersKey,
  24298. createSimpleExpression(
  24299. `{ ${modifiers} }`,
  24300. false,
  24301. dir.loc,
  24302. 2
  24303. )
  24304. )
  24305. );
  24306. }
  24307. return createTransformProps(props);
  24308. };
  24309. function createTransformProps(props = []) {
  24310. return { props };
  24311. }
  24312. const seen = /* @__PURE__ */ new WeakSet();
  24313. const transformMemo = (node, context) => {
  24314. if (node.type === 1) {
  24315. const dir = findDir(node, "memo");
  24316. if (!dir || seen.has(node)) {
  24317. return;
  24318. }
  24319. seen.add(node);
  24320. return () => {
  24321. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24322. if (codegenNode && codegenNode.type === 13) {
  24323. if (node.tagType !== 1) {
  24324. convertToBlock(codegenNode, context);
  24325. }
  24326. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24327. dir.exp,
  24328. createFunctionExpression(void 0, codegenNode),
  24329. `_cache`,
  24330. String(context.cached.length)
  24331. ]);
  24332. context.cached.push(null);
  24333. }
  24334. };
  24335. }
  24336. };
  24337. function getBaseTransformPreset(prefixIdentifiers) {
  24338. return [
  24339. [
  24340. transformOnce,
  24341. transformIf,
  24342. transformMemo,
  24343. transformFor,
  24344. ...[],
  24345. ...prefixIdentifiers ? [
  24346. // order is important
  24347. trackVForSlotScopes,
  24348. transformExpression
  24349. ] : [],
  24350. transformSlotOutlet,
  24351. transformElement,
  24352. trackSlotScopes,
  24353. transformText
  24354. ],
  24355. {
  24356. on: transformOn$1,
  24357. bind: transformBind,
  24358. model: transformModel$1
  24359. }
  24360. ];
  24361. }
  24362. function baseCompile(source, options = {}) {
  24363. const onError = options.onError || defaultOnError;
  24364. const isModuleMode = options.mode === "module";
  24365. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  24366. if (!prefixIdentifiers && options.cacheHandlers) {
  24367. onError(createCompilerError(49));
  24368. }
  24369. if (options.scopeId && !isModuleMode) {
  24370. onError(createCompilerError(50));
  24371. }
  24372. const resolvedOptions = extend({}, options, {
  24373. prefixIdentifiers
  24374. });
  24375. const ast = isString$1(source) ? baseParse(source, resolvedOptions) : source;
  24376. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  24377. if (options.isTS) {
  24378. const { expressionPlugins } = options;
  24379. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  24380. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  24381. }
  24382. }
  24383. transform(
  24384. ast,
  24385. extend({}, resolvedOptions, {
  24386. nodeTransforms: [
  24387. ...nodeTransforms,
  24388. ...options.nodeTransforms || []
  24389. // user transforms
  24390. ],
  24391. directiveTransforms: extend(
  24392. {},
  24393. directiveTransforms,
  24394. options.directiveTransforms || {}
  24395. // user transforms
  24396. )
  24397. })
  24398. );
  24399. return generate(ast, resolvedOptions);
  24400. }
  24401. const BindingTypes = {
  24402. "DATA": "data",
  24403. "PROPS": "props",
  24404. "PROPS_ALIASED": "props-aliased",
  24405. "SETUP_LET": "setup-let",
  24406. "SETUP_CONST": "setup-const",
  24407. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  24408. "SETUP_MAYBE_REF": "setup-maybe-ref",
  24409. "SETUP_REF": "setup-ref",
  24410. "OPTIONS": "options",
  24411. "LITERAL_CONST": "literal-const"
  24412. };
  24413. const noopDirectiveTransform = () => ({ props: [] });
  24414. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  24415. const V_MODEL_CHECKBOX = Symbol(
  24416. `vModelCheckbox`
  24417. );
  24418. const V_MODEL_TEXT = Symbol(`vModelText` );
  24419. const V_MODEL_SELECT = Symbol(
  24420. `vModelSelect`
  24421. );
  24422. const V_MODEL_DYNAMIC = Symbol(
  24423. `vModelDynamic`
  24424. );
  24425. const V_ON_WITH_MODIFIERS = Symbol(
  24426. `vOnModifiersGuard`
  24427. );
  24428. const V_ON_WITH_KEYS = Symbol(
  24429. `vOnKeysGuard`
  24430. );
  24431. const V_SHOW = Symbol(`vShow` );
  24432. const TRANSITION = Symbol(`Transition` );
  24433. const TRANSITION_GROUP = Symbol(
  24434. `TransitionGroup`
  24435. );
  24436. registerRuntimeHelpers({
  24437. [V_MODEL_RADIO]: `vModelRadio`,
  24438. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  24439. [V_MODEL_TEXT]: `vModelText`,
  24440. [V_MODEL_SELECT]: `vModelSelect`,
  24441. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  24442. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  24443. [V_ON_WITH_KEYS]: `withKeys`,
  24444. [V_SHOW]: `vShow`,
  24445. [TRANSITION]: `Transition`,
  24446. [TRANSITION_GROUP]: `TransitionGroup`
  24447. });
  24448. const parserOptions = {
  24449. parseMode: "html",
  24450. isVoidTag,
  24451. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  24452. isPreTag: (tag) => tag === "pre",
  24453. isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
  24454. decodeEntities: void 0,
  24455. isBuiltInComponent: (tag) => {
  24456. if (tag === "Transition" || tag === "transition") {
  24457. return TRANSITION;
  24458. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  24459. return TRANSITION_GROUP;
  24460. }
  24461. },
  24462. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  24463. getNamespace(tag, parent, rootNamespace) {
  24464. let ns = parent ? parent.ns : rootNamespace;
  24465. if (parent && ns === 2) {
  24466. if (parent.tag === "annotation-xml") {
  24467. if (tag === "svg") {
  24468. return 1;
  24469. }
  24470. if (parent.props.some(
  24471. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  24472. )) {
  24473. ns = 0;
  24474. }
  24475. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  24476. ns = 0;
  24477. }
  24478. } else if (parent && ns === 1) {
  24479. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  24480. ns = 0;
  24481. }
  24482. }
  24483. if (ns === 0) {
  24484. if (tag === "svg") {
  24485. return 1;
  24486. }
  24487. if (tag === "math") {
  24488. return 2;
  24489. }
  24490. }
  24491. return ns;
  24492. }
  24493. };
  24494. const transformStyle = (node) => {
  24495. if (node.type === 1) {
  24496. node.props.forEach((p, i) => {
  24497. if (p.type === 6 && p.name === "style" && p.value) {
  24498. node.props[i] = {
  24499. type: 7,
  24500. name: `bind`,
  24501. arg: createSimpleExpression(`style`, true, p.loc),
  24502. exp: parseInlineCSS(p.value.content, p.loc),
  24503. modifiers: [],
  24504. loc: p.loc
  24505. };
  24506. }
  24507. });
  24508. }
  24509. };
  24510. const parseInlineCSS = (cssText, loc) => {
  24511. const normalized = parseStringStyle(cssText);
  24512. return createSimpleExpression(
  24513. JSON.stringify(normalized),
  24514. false,
  24515. loc,
  24516. 3
  24517. );
  24518. };
  24519. function createDOMCompilerError(code, loc) {
  24520. return createCompilerError(
  24521. code,
  24522. loc,
  24523. DOMErrorMessages
  24524. );
  24525. }
  24526. const DOMErrorCodes = {
  24527. "X_V_HTML_NO_EXPRESSION": 53,
  24528. "53": "X_V_HTML_NO_EXPRESSION",
  24529. "X_V_HTML_WITH_CHILDREN": 54,
  24530. "54": "X_V_HTML_WITH_CHILDREN",
  24531. "X_V_TEXT_NO_EXPRESSION": 55,
  24532. "55": "X_V_TEXT_NO_EXPRESSION",
  24533. "X_V_TEXT_WITH_CHILDREN": 56,
  24534. "56": "X_V_TEXT_WITH_CHILDREN",
  24535. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  24536. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  24537. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  24538. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  24539. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  24540. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  24541. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  24542. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  24543. "X_V_SHOW_NO_EXPRESSION": 61,
  24544. "61": "X_V_SHOW_NO_EXPRESSION",
  24545. "X_TRANSITION_INVALID_CHILDREN": 62,
  24546. "62": "X_TRANSITION_INVALID_CHILDREN",
  24547. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  24548. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  24549. "__EXTEND_POINT__": 64,
  24550. "64": "__EXTEND_POINT__"
  24551. };
  24552. const DOMErrorMessages = {
  24553. [53]: `v-html is missing expression.`,
  24554. [54]: `v-html will override element children.`,
  24555. [55]: `v-text is missing expression.`,
  24556. [56]: `v-text will override element children.`,
  24557. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  24558. [58]: `v-model argument is not supported on plain elements.`,
  24559. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  24560. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  24561. [61]: `v-show is missing expression.`,
  24562. [62]: `<Transition> expects exactly one child element or component.`,
  24563. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  24564. };
  24565. const transformVHtml = (dir, node, context) => {
  24566. const { exp, loc } = dir;
  24567. if (!exp) {
  24568. context.onError(
  24569. createDOMCompilerError(53, loc)
  24570. );
  24571. }
  24572. if (node.children.length) {
  24573. context.onError(
  24574. createDOMCompilerError(54, loc)
  24575. );
  24576. node.children.length = 0;
  24577. }
  24578. return {
  24579. props: [
  24580. createObjectProperty(
  24581. createSimpleExpression(`innerHTML`, true, loc),
  24582. exp || createSimpleExpression("", true)
  24583. )
  24584. ]
  24585. };
  24586. };
  24587. const transformVText = (dir, node, context) => {
  24588. const { exp, loc } = dir;
  24589. if (!exp) {
  24590. context.onError(
  24591. createDOMCompilerError(55, loc)
  24592. );
  24593. }
  24594. if (node.children.length) {
  24595. context.onError(
  24596. createDOMCompilerError(56, loc)
  24597. );
  24598. node.children.length = 0;
  24599. }
  24600. return {
  24601. props: [
  24602. createObjectProperty(
  24603. createSimpleExpression(`textContent`, true),
  24604. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  24605. context.helperString(TO_DISPLAY_STRING),
  24606. [exp],
  24607. loc
  24608. ) : createSimpleExpression("", true)
  24609. )
  24610. ]
  24611. };
  24612. };
  24613. const transformModel = (dir, node, context) => {
  24614. const baseResult = transformModel$1(dir, node, context);
  24615. if (!baseResult.props.length || node.tagType === 1) {
  24616. return baseResult;
  24617. }
  24618. if (dir.arg) {
  24619. context.onError(
  24620. createDOMCompilerError(
  24621. 58,
  24622. dir.arg.loc
  24623. )
  24624. );
  24625. }
  24626. function checkDuplicatedValue() {
  24627. const value = findDir(node, "bind");
  24628. if (value && isStaticArgOf(value.arg, "value")) {
  24629. context.onError(
  24630. createDOMCompilerError(
  24631. 60,
  24632. value.loc
  24633. )
  24634. );
  24635. }
  24636. }
  24637. const { tag } = node;
  24638. const isCustomElement = context.isCustomElement(tag);
  24639. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  24640. let directiveToUse = V_MODEL_TEXT;
  24641. let isInvalidType = false;
  24642. if (tag === "input" || isCustomElement) {
  24643. const type = findProp(node, `type`);
  24644. if (type) {
  24645. if (type.type === 7) {
  24646. directiveToUse = V_MODEL_DYNAMIC;
  24647. } else if (type.value) {
  24648. switch (type.value.content) {
  24649. case "radio":
  24650. directiveToUse = V_MODEL_RADIO;
  24651. break;
  24652. case "checkbox":
  24653. directiveToUse = V_MODEL_CHECKBOX;
  24654. break;
  24655. case "file":
  24656. isInvalidType = true;
  24657. context.onError(
  24658. createDOMCompilerError(
  24659. 59,
  24660. dir.loc
  24661. )
  24662. );
  24663. break;
  24664. default:
  24665. checkDuplicatedValue();
  24666. break;
  24667. }
  24668. }
  24669. } else if (hasDynamicKeyVBind(node)) {
  24670. directiveToUse = V_MODEL_DYNAMIC;
  24671. } else {
  24672. checkDuplicatedValue();
  24673. }
  24674. } else if (tag === "select") {
  24675. directiveToUse = V_MODEL_SELECT;
  24676. } else {
  24677. checkDuplicatedValue();
  24678. }
  24679. if (!isInvalidType) {
  24680. baseResult.needRuntime = context.helper(directiveToUse);
  24681. }
  24682. } else {
  24683. context.onError(
  24684. createDOMCompilerError(
  24685. 57,
  24686. dir.loc
  24687. )
  24688. );
  24689. }
  24690. baseResult.props = baseResult.props.filter(
  24691. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  24692. );
  24693. return baseResult;
  24694. };
  24695. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  24696. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  24697. // event propagation management
  24698. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  24699. );
  24700. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  24701. const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
  24702. const resolveModifiers = (key, modifiers, context, loc) => {
  24703. const keyModifiers = [];
  24704. const nonKeyModifiers = [];
  24705. const eventOptionModifiers = [];
  24706. for (let i = 0; i < modifiers.length; i++) {
  24707. const modifier = modifiers[i].content;
  24708. if (isEventOptionModifier(modifier)) {
  24709. eventOptionModifiers.push(modifier);
  24710. } else {
  24711. if (maybeKeyModifier(modifier)) {
  24712. if (isStaticExp(key)) {
  24713. if (isKeyboardEvent(key.content.toLowerCase())) {
  24714. keyModifiers.push(modifier);
  24715. } else {
  24716. nonKeyModifiers.push(modifier);
  24717. }
  24718. } else {
  24719. keyModifiers.push(modifier);
  24720. nonKeyModifiers.push(modifier);
  24721. }
  24722. } else {
  24723. if (isNonKeyModifier(modifier)) {
  24724. nonKeyModifiers.push(modifier);
  24725. } else {
  24726. keyModifiers.push(modifier);
  24727. }
  24728. }
  24729. }
  24730. }
  24731. return {
  24732. keyModifiers,
  24733. nonKeyModifiers,
  24734. eventOptionModifiers
  24735. };
  24736. };
  24737. const transformClick = (key, event) => {
  24738. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  24739. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  24740. `(`,
  24741. key,
  24742. `) === "onClick" ? "${event}" : (`,
  24743. key,
  24744. `)`
  24745. ]) : key;
  24746. };
  24747. const transformOn = (dir, node, context) => {
  24748. return transformOn$1(dir, node, context, (baseResult) => {
  24749. const { modifiers } = dir;
  24750. if (!modifiers.length) return baseResult;
  24751. let { key, value: handlerExp } = baseResult.props[0];
  24752. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  24753. if (nonKeyModifiers.includes("right")) {
  24754. key = transformClick(key, `onContextmenu`);
  24755. }
  24756. if (nonKeyModifiers.includes("middle")) {
  24757. key = transformClick(key, `onMouseup`);
  24758. }
  24759. if (nonKeyModifiers.length) {
  24760. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  24761. handlerExp,
  24762. JSON.stringify(nonKeyModifiers)
  24763. ]);
  24764. }
  24765. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  24766. (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
  24767. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  24768. handlerExp,
  24769. JSON.stringify(keyModifiers)
  24770. ]);
  24771. }
  24772. if (eventOptionModifiers.length) {
  24773. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  24774. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  24775. }
  24776. return {
  24777. props: [createObjectProperty(key, handlerExp)]
  24778. };
  24779. });
  24780. };
  24781. const transformShow = (dir, node, context) => {
  24782. const { exp, loc } = dir;
  24783. if (!exp) {
  24784. context.onError(
  24785. createDOMCompilerError(61, loc)
  24786. );
  24787. }
  24788. return {
  24789. props: [],
  24790. needRuntime: context.helper(V_SHOW)
  24791. };
  24792. };
  24793. const transformTransition = (node, context) => {
  24794. if (node.type === 1 && node.tagType === 1) {
  24795. const component = context.isBuiltInComponent(node.tag);
  24796. if (component === TRANSITION) {
  24797. return () => {
  24798. if (!node.children.length) {
  24799. return;
  24800. }
  24801. if (hasMultipleChildren(node)) {
  24802. context.onError(
  24803. createDOMCompilerError(
  24804. 62,
  24805. {
  24806. start: node.children[0].loc.start,
  24807. end: node.children[node.children.length - 1].loc.end,
  24808. source: ""
  24809. }
  24810. )
  24811. );
  24812. }
  24813. const child = node.children[0];
  24814. if (child.type === 1) {
  24815. for (const p of child.props) {
  24816. if (p.type === 7 && p.name === "show") {
  24817. node.props.push({
  24818. type: 6,
  24819. name: "persisted",
  24820. nameLoc: node.loc,
  24821. value: void 0,
  24822. loc: node.loc
  24823. });
  24824. }
  24825. }
  24826. }
  24827. };
  24828. }
  24829. }
  24830. };
  24831. function hasMultipleChildren(node) {
  24832. const children = node.children = node.children.filter(
  24833. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  24834. );
  24835. const child = children[0];
  24836. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  24837. }
  24838. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  24839. const stringifyStatic = (children, context, parent) => {
  24840. if (context.scopes.vSlot > 0) {
  24841. return;
  24842. }
  24843. const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
  24844. let nc = 0;
  24845. let ec = 0;
  24846. const currentChunk = [];
  24847. const stringifyCurrentChunk = (currentIndex) => {
  24848. if (nc >= 20 || ec >= 5) {
  24849. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  24850. JSON.stringify(
  24851. currentChunk.map((node) => stringifyNode(node, context)).join("")
  24852. ).replace(expReplaceRE, `" + $1 + "`),
  24853. // the 2nd argument indicates the number of DOM nodes this static vnode
  24854. // will insert / hydrate
  24855. String(currentChunk.length)
  24856. ]);
  24857. const deleteCount = currentChunk.length - 1;
  24858. if (isParentCached) {
  24859. children.splice(
  24860. currentIndex - currentChunk.length,
  24861. currentChunk.length,
  24862. // @ts-expect-error
  24863. staticCall
  24864. );
  24865. } else {
  24866. currentChunk[0].codegenNode.value = staticCall;
  24867. if (currentChunk.length > 1) {
  24868. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  24869. const cacheIndex = context.cached.indexOf(
  24870. currentChunk[currentChunk.length - 1].codegenNode
  24871. );
  24872. if (cacheIndex > -1) {
  24873. for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
  24874. const c = context.cached[i2];
  24875. if (c) c.index -= deleteCount;
  24876. }
  24877. context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
  24878. }
  24879. }
  24880. }
  24881. return deleteCount;
  24882. }
  24883. return 0;
  24884. };
  24885. let i = 0;
  24886. for (; i < children.length; i++) {
  24887. const child = children[i];
  24888. const isCached = isParentCached || getCachedNode(child);
  24889. if (isCached) {
  24890. const result = analyzeNode(child);
  24891. if (result) {
  24892. nc += result[0];
  24893. ec += result[1];
  24894. currentChunk.push(child);
  24895. continue;
  24896. }
  24897. }
  24898. i -= stringifyCurrentChunk(i);
  24899. nc = 0;
  24900. ec = 0;
  24901. currentChunk.length = 0;
  24902. }
  24903. stringifyCurrentChunk(i);
  24904. };
  24905. const getCachedNode = (node) => {
  24906. if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
  24907. return node.codegenNode;
  24908. }
  24909. };
  24910. const dataAriaRE = /^(data|aria)-/;
  24911. const isStringifiableAttr = (name, ns) => {
  24912. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : ns === 2 ? isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
  24913. };
  24914. const isNonStringifiable = /* @__PURE__ */ makeMap(
  24915. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  24916. );
  24917. function analyzeNode(node) {
  24918. if (node.type === 1 && isNonStringifiable(node.tag)) {
  24919. return false;
  24920. }
  24921. if (node.type === 12) {
  24922. return [1, 0];
  24923. }
  24924. let nc = 1;
  24925. let ec = node.props.length > 0 ? 1 : 0;
  24926. let bailed = false;
  24927. const bail = () => {
  24928. bailed = true;
  24929. return false;
  24930. };
  24931. function walk(node2) {
  24932. const isOptionTag = node2.tag === "option" && node2.ns === 0;
  24933. for (let i = 0; i < node2.props.length; i++) {
  24934. const p = node2.props[i];
  24935. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  24936. return bail();
  24937. }
  24938. if (p.type === 7 && p.name === "bind") {
  24939. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  24940. return bail();
  24941. }
  24942. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  24943. return bail();
  24944. }
  24945. if (isOptionTag && isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
  24946. return bail();
  24947. }
  24948. }
  24949. }
  24950. for (let i = 0; i < node2.children.length; i++) {
  24951. nc++;
  24952. const child = node2.children[i];
  24953. if (child.type === 1) {
  24954. if (child.props.length > 0) {
  24955. ec++;
  24956. }
  24957. walk(child);
  24958. if (bailed) {
  24959. return false;
  24960. }
  24961. }
  24962. }
  24963. return true;
  24964. }
  24965. return walk(node) ? [nc, ec] : false;
  24966. }
  24967. function stringifyNode(node, context) {
  24968. if (isString$1(node)) {
  24969. return node;
  24970. }
  24971. if (isSymbol$1(node)) {
  24972. return ``;
  24973. }
  24974. switch (node.type) {
  24975. case 1:
  24976. return stringifyElement(node, context);
  24977. case 2:
  24978. return escapeHtml(node.content);
  24979. case 3:
  24980. return `<!--${escapeHtml(node.content)}-->`;
  24981. case 5:
  24982. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  24983. case 8:
  24984. return escapeHtml(evaluateConstant(node));
  24985. case 12:
  24986. return stringifyNode(node.content, context);
  24987. default:
  24988. return "";
  24989. }
  24990. }
  24991. function stringifyElement(node, context) {
  24992. let res = `<${node.tag}`;
  24993. let innerHTML = "";
  24994. for (let i = 0; i < node.props.length; i++) {
  24995. const p = node.props[i];
  24996. if (p.type === 6) {
  24997. res += ` ${p.name}`;
  24998. if (p.value) {
  24999. res += `="${escapeHtml(p.value.content)}"`;
  25000. }
  25001. } else if (p.type === 7) {
  25002. if (p.name === "bind") {
  25003. const exp = p.exp;
  25004. if (exp.content[0] === "_") {
  25005. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  25006. continue;
  25007. }
  25008. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  25009. continue;
  25010. }
  25011. let evaluated = evaluateConstant(exp);
  25012. if (evaluated != null) {
  25013. const arg = p.arg && p.arg.content;
  25014. if (arg === "class") {
  25015. evaluated = normalizeClass(evaluated);
  25016. } else if (arg === "style") {
  25017. evaluated = stringifyStyle(normalizeStyle(evaluated));
  25018. }
  25019. res += ` ${p.arg.content}="${escapeHtml(
  25020. evaluated
  25021. )}"`;
  25022. }
  25023. } else if (p.name === "html") {
  25024. innerHTML = evaluateConstant(p.exp);
  25025. } else if (p.name === "text") {
  25026. innerHTML = escapeHtml(
  25027. toDisplayString(evaluateConstant(p.exp))
  25028. );
  25029. }
  25030. }
  25031. }
  25032. if (context.scopeId) {
  25033. res += ` ${context.scopeId}`;
  25034. }
  25035. res += `>`;
  25036. if (innerHTML) {
  25037. res += innerHTML;
  25038. } else {
  25039. for (let i = 0; i < node.children.length; i++) {
  25040. res += stringifyNode(node.children[i], context);
  25041. }
  25042. }
  25043. if (!isVoidTag(node.tag)) {
  25044. res += `</${node.tag}>`;
  25045. }
  25046. return res;
  25047. }
  25048. function evaluateConstant(exp) {
  25049. if (exp.type === 4) {
  25050. return new Function(`return (${exp.content})`)();
  25051. } else {
  25052. let res = ``;
  25053. exp.children.forEach((c) => {
  25054. if (isString$1(c) || isSymbol$1(c)) {
  25055. return;
  25056. }
  25057. if (c.type === 2) {
  25058. res += c.content;
  25059. } else if (c.type === 5) {
  25060. res += toDisplayString(evaluateConstant(c.content));
  25061. } else {
  25062. res += evaluateConstant(c);
  25063. }
  25064. });
  25065. return res;
  25066. }
  25067. }
  25068. const ignoreSideEffectTags = (node, context) => {
  25069. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  25070. context.onError(
  25071. createDOMCompilerError(
  25072. 63,
  25073. node.loc
  25074. )
  25075. );
  25076. context.removeNode();
  25077. }
  25078. };
  25079. function isValidHTMLNesting(parent, child) {
  25080. if (parent in onlyValidChildren) {
  25081. return onlyValidChildren[parent].has(child);
  25082. }
  25083. if (child in onlyValidParents) {
  25084. return onlyValidParents[child].has(parent);
  25085. }
  25086. if (parent in knownInvalidChildren) {
  25087. if (knownInvalidChildren[parent].has(child)) return false;
  25088. }
  25089. if (child in knownInvalidParents) {
  25090. if (knownInvalidParents[child].has(parent)) return false;
  25091. }
  25092. return true;
  25093. }
  25094. const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
  25095. const emptySet = /* @__PURE__ */ new Set([]);
  25096. const onlyValidChildren = {
  25097. head: /* @__PURE__ */ new Set([
  25098. "base",
  25099. "basefront",
  25100. "bgsound",
  25101. "link",
  25102. "meta",
  25103. "title",
  25104. "noscript",
  25105. "noframes",
  25106. "style",
  25107. "script",
  25108. "template"
  25109. ]),
  25110. optgroup: /* @__PURE__ */ new Set(["option"]),
  25111. select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
  25112. // table
  25113. table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
  25114. tr: /* @__PURE__ */ new Set(["td", "th"]),
  25115. colgroup: /* @__PURE__ */ new Set(["col"]),
  25116. tbody: /* @__PURE__ */ new Set(["tr"]),
  25117. thead: /* @__PURE__ */ new Set(["tr"]),
  25118. tfoot: /* @__PURE__ */ new Set(["tr"]),
  25119. // these elements can not have any children elements
  25120. script: emptySet,
  25121. iframe: emptySet,
  25122. option: emptySet,
  25123. textarea: emptySet,
  25124. style: emptySet,
  25125. title: emptySet
  25126. };
  25127. const onlyValidParents = {
  25128. // sections
  25129. html: emptySet,
  25130. body: /* @__PURE__ */ new Set(["html"]),
  25131. head: /* @__PURE__ */ new Set(["html"]),
  25132. // table
  25133. td: /* @__PURE__ */ new Set(["tr"]),
  25134. colgroup: /* @__PURE__ */ new Set(["table"]),
  25135. caption: /* @__PURE__ */ new Set(["table"]),
  25136. tbody: /* @__PURE__ */ new Set(["table"]),
  25137. tfoot: /* @__PURE__ */ new Set(["table"]),
  25138. col: /* @__PURE__ */ new Set(["colgroup"]),
  25139. th: /* @__PURE__ */ new Set(["tr"]),
  25140. thead: /* @__PURE__ */ new Set(["table"]),
  25141. tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
  25142. // data list
  25143. dd: /* @__PURE__ */ new Set(["dl", "div"]),
  25144. dt: /* @__PURE__ */ new Set(["dl", "div"]),
  25145. // other
  25146. figcaption: /* @__PURE__ */ new Set(["figure"]),
  25147. // li: new Set(["ul", "ol"]),
  25148. summary: /* @__PURE__ */ new Set(["details"]),
  25149. area: /* @__PURE__ */ new Set(["map"])
  25150. };
  25151. const knownInvalidChildren = {
  25152. p: /* @__PURE__ */ new Set([
  25153. "address",
  25154. "article",
  25155. "aside",
  25156. "blockquote",
  25157. "center",
  25158. "details",
  25159. "dialog",
  25160. "dir",
  25161. "div",
  25162. "dl",
  25163. "fieldset",
  25164. "figure",
  25165. "footer",
  25166. "form",
  25167. "h1",
  25168. "h2",
  25169. "h3",
  25170. "h4",
  25171. "h5",
  25172. "h6",
  25173. "header",
  25174. "hgroup",
  25175. "hr",
  25176. "li",
  25177. "main",
  25178. "nav",
  25179. "menu",
  25180. "ol",
  25181. "p",
  25182. "pre",
  25183. "section",
  25184. "table",
  25185. "ul"
  25186. ]),
  25187. svg: /* @__PURE__ */ new Set([
  25188. "b",
  25189. "blockquote",
  25190. "br",
  25191. "code",
  25192. "dd",
  25193. "div",
  25194. "dl",
  25195. "dt",
  25196. "em",
  25197. "embed",
  25198. "h1",
  25199. "h2",
  25200. "h3",
  25201. "h4",
  25202. "h5",
  25203. "h6",
  25204. "hr",
  25205. "i",
  25206. "img",
  25207. "li",
  25208. "menu",
  25209. "meta",
  25210. "ol",
  25211. "p",
  25212. "pre",
  25213. "ruby",
  25214. "s",
  25215. "small",
  25216. "span",
  25217. "strong",
  25218. "sub",
  25219. "sup",
  25220. "table",
  25221. "u",
  25222. "ul",
  25223. "var"
  25224. ])
  25225. };
  25226. const knownInvalidParents = {
  25227. a: /* @__PURE__ */ new Set(["a"]),
  25228. button: /* @__PURE__ */ new Set(["button"]),
  25229. dd: /* @__PURE__ */ new Set(["dd", "dt"]),
  25230. dt: /* @__PURE__ */ new Set(["dd", "dt"]),
  25231. form: /* @__PURE__ */ new Set(["form"]),
  25232. li: /* @__PURE__ */ new Set(["li"]),
  25233. h1: headings,
  25234. h2: headings,
  25235. h3: headings,
  25236. h4: headings,
  25237. h5: headings,
  25238. h6: headings
  25239. };
  25240. const validateHtmlNesting = (node, context) => {
  25241. if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
  25242. const error = new SyntaxError(
  25243. `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
  25244. );
  25245. error.loc = node.loc;
  25246. context.onWarn(error);
  25247. }
  25248. };
  25249. const DOMNodeTransforms = [
  25250. transformStyle,
  25251. ...[transformTransition, validateHtmlNesting]
  25252. ];
  25253. const DOMDirectiveTransforms = {
  25254. cloak: noopDirectiveTransform,
  25255. html: transformVHtml,
  25256. text: transformVText,
  25257. model: transformModel,
  25258. // override compiler-core
  25259. on: transformOn,
  25260. // override compiler-core
  25261. show: transformShow
  25262. };
  25263. function compile$1(src, options = {}) {
  25264. return baseCompile(
  25265. src,
  25266. extend({}, parserOptions, options, {
  25267. nodeTransforms: [
  25268. // ignore <script> and <tag>
  25269. // this is not put inside DOMNodeTransforms because that list is used
  25270. // by compiler-ssr to generate vnode fallback branches
  25271. ignoreSideEffectTags,
  25272. ...DOMNodeTransforms,
  25273. ...options.nodeTransforms || []
  25274. ],
  25275. directiveTransforms: extend(
  25276. {},
  25277. DOMDirectiveTransforms,
  25278. options.directiveTransforms || {}
  25279. ),
  25280. transformHoist: stringifyStatic
  25281. })
  25282. );
  25283. }
  25284. function parse$3(template, options = {}) {
  25285. return baseParse(template, extend({}, parserOptions, options));
  25286. }
  25287. var CompilerDOM = /*#__PURE__*/Object.freeze({
  25288. __proto__: null,
  25289. BASE_TRANSITION: BASE_TRANSITION,
  25290. BindingTypes: BindingTypes,
  25291. CAMELIZE: CAMELIZE,
  25292. CAPITALIZE: CAPITALIZE,
  25293. CREATE_BLOCK: CREATE_BLOCK,
  25294. CREATE_COMMENT: CREATE_COMMENT,
  25295. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  25296. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  25297. CREATE_SLOTS: CREATE_SLOTS,
  25298. CREATE_STATIC: CREATE_STATIC,
  25299. CREATE_TEXT: CREATE_TEXT,
  25300. CREATE_VNODE: CREATE_VNODE,
  25301. CompilerDeprecationTypes: CompilerDeprecationTypes,
  25302. ConstantTypes: ConstantTypes,
  25303. DOMDirectiveTransforms: DOMDirectiveTransforms,
  25304. DOMErrorCodes: DOMErrorCodes,
  25305. DOMErrorMessages: DOMErrorMessages,
  25306. DOMNodeTransforms: DOMNodeTransforms,
  25307. ElementTypes: ElementTypes,
  25308. ErrorCodes: ErrorCodes,
  25309. FRAGMENT: FRAGMENT,
  25310. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  25311. IS_MEMO_SAME: IS_MEMO_SAME,
  25312. IS_REF: IS_REF,
  25313. KEEP_ALIVE: KEEP_ALIVE,
  25314. MERGE_PROPS: MERGE_PROPS,
  25315. NORMALIZE_CLASS: NORMALIZE_CLASS,
  25316. NORMALIZE_PROPS: NORMALIZE_PROPS,
  25317. NORMALIZE_STYLE: NORMALIZE_STYLE,
  25318. Namespaces: Namespaces,
  25319. NodeTypes: NodeTypes,
  25320. OPEN_BLOCK: OPEN_BLOCK,
  25321. POP_SCOPE_ID: POP_SCOPE_ID,
  25322. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  25323. RENDER_LIST: RENDER_LIST,
  25324. RENDER_SLOT: RENDER_SLOT,
  25325. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  25326. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  25327. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  25328. RESOLVE_FILTER: RESOLVE_FILTER,
  25329. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  25330. SUSPENSE: SUSPENSE,
  25331. TELEPORT: TELEPORT,
  25332. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  25333. TO_HANDLERS: TO_HANDLERS,
  25334. TO_HANDLER_KEY: TO_HANDLER_KEY,
  25335. TRANSITION: TRANSITION,
  25336. TRANSITION_GROUP: TRANSITION_GROUP,
  25337. TS_NODE_TYPES: TS_NODE_TYPES,
  25338. UNREF: UNREF,
  25339. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  25340. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  25341. V_MODEL_RADIO: V_MODEL_RADIO,
  25342. V_MODEL_SELECT: V_MODEL_SELECT,
  25343. V_MODEL_TEXT: V_MODEL_TEXT,
  25344. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  25345. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  25346. V_SHOW: V_SHOW,
  25347. WITH_CTX: WITH_CTX,
  25348. WITH_DIRECTIVES: WITH_DIRECTIVES,
  25349. WITH_MEMO: WITH_MEMO,
  25350. advancePositionWithClone: advancePositionWithClone,
  25351. advancePositionWithMutation: advancePositionWithMutation,
  25352. assert: assert,
  25353. baseCompile: baseCompile,
  25354. baseParse: baseParse,
  25355. buildDirectiveArgs: buildDirectiveArgs,
  25356. buildProps: buildProps,
  25357. buildSlots: buildSlots,
  25358. checkCompatEnabled: checkCompatEnabled,
  25359. compile: compile$1,
  25360. convertToBlock: convertToBlock,
  25361. createArrayExpression: createArrayExpression,
  25362. createAssignmentExpression: createAssignmentExpression,
  25363. createBlockStatement: createBlockStatement,
  25364. createCacheExpression: createCacheExpression,
  25365. createCallExpression: createCallExpression,
  25366. createCompilerError: createCompilerError,
  25367. createCompoundExpression: createCompoundExpression,
  25368. createConditionalExpression: createConditionalExpression,
  25369. createDOMCompilerError: createDOMCompilerError,
  25370. createForLoopParams: createForLoopParams,
  25371. createFunctionExpression: createFunctionExpression,
  25372. createIfStatement: createIfStatement,
  25373. createInterpolation: createInterpolation,
  25374. createObjectExpression: createObjectExpression,
  25375. createObjectProperty: createObjectProperty,
  25376. createReturnStatement: createReturnStatement,
  25377. createRoot: createRoot,
  25378. createSequenceExpression: createSequenceExpression,
  25379. createSimpleExpression: createSimpleExpression,
  25380. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  25381. createTemplateLiteral: createTemplateLiteral,
  25382. createTransformContext: createTransformContext,
  25383. createVNodeCall: createVNodeCall,
  25384. errorMessages: errorMessages$1,
  25385. extractIdentifiers: extractIdentifiers$1,
  25386. findDir: findDir,
  25387. findProp: findProp,
  25388. forAliasRE: forAliasRE,
  25389. generate: generate,
  25390. generateCodeFrame: generateCodeFrame,
  25391. getBaseTransformPreset: getBaseTransformPreset,
  25392. getConstantType: getConstantType,
  25393. getMemoedVNodeCall: getMemoedVNodeCall,
  25394. getVNodeBlockHelper: getVNodeBlockHelper,
  25395. getVNodeHelper: getVNodeHelper,
  25396. hasDynamicKeyVBind: hasDynamicKeyVBind,
  25397. hasScopeRef: hasScopeRef,
  25398. helperNameMap: helperNameMap,
  25399. injectProp: injectProp,
  25400. isCoreComponent: isCoreComponent,
  25401. isFnExpression: isFnExpression,
  25402. isFnExpressionBrowser: isFnExpressionBrowser,
  25403. isFnExpressionNode: isFnExpressionNode,
  25404. isFunctionType: isFunctionType,
  25405. isInDestructureAssignment: isInDestructureAssignment,
  25406. isInNewExpression: isInNewExpression,
  25407. isMemberExpression: isMemberExpression,
  25408. isMemberExpressionBrowser: isMemberExpressionBrowser,
  25409. isMemberExpressionNode: isMemberExpressionNode,
  25410. isReferencedIdentifier: isReferencedIdentifier,
  25411. isSimpleIdentifier: isSimpleIdentifier,
  25412. isSlotOutlet: isSlotOutlet,
  25413. isStaticArgOf: isStaticArgOf,
  25414. isStaticExp: isStaticExp,
  25415. isStaticProperty: isStaticProperty,
  25416. isStaticPropertyKey: isStaticPropertyKey,
  25417. isTemplateNode: isTemplateNode,
  25418. isText: isText$1,
  25419. isVSlot: isVSlot,
  25420. locStub: locStub,
  25421. noopDirectiveTransform: noopDirectiveTransform,
  25422. parse: parse$3,
  25423. parserOptions: parserOptions,
  25424. processExpression: processExpression,
  25425. processFor: processFor,
  25426. processIf: processIf,
  25427. processSlotOutlet: processSlotOutlet,
  25428. registerRuntimeHelpers: registerRuntimeHelpers,
  25429. resolveComponentType: resolveComponentType,
  25430. stringifyExpression: stringifyExpression,
  25431. toValidAssetId: toValidAssetId,
  25432. trackSlotScopes: trackSlotScopes,
  25433. trackVForSlotScopes: trackVForSlotScopes,
  25434. transform: transform,
  25435. transformBind: transformBind,
  25436. transformElement: transformElement,
  25437. transformExpression: transformExpression,
  25438. transformModel: transformModel$1,
  25439. transformOn: transformOn$1,
  25440. transformStyle: transformStyle,
  25441. traverseNode: traverseNode,
  25442. unwrapTSNode: unwrapTSNode,
  25443. walkBlockDeclarations: walkBlockDeclarations,
  25444. walkFunctionParams: walkFunctionParams,
  25445. walkIdentifiers: walkIdentifiers,
  25446. warnDeprecation: warnDeprecation
  25447. });
  25448. var hashSum;
  25449. var hasRequiredHashSum;
  25450. function requireHashSum () {
  25451. if (hasRequiredHashSum) return hashSum;
  25452. hasRequiredHashSum = 1;
  25453. function pad (hash, len) {
  25454. while (hash.length < len) {
  25455. hash = '0' + hash;
  25456. }
  25457. return hash;
  25458. }
  25459. function fold (hash, text) {
  25460. var i;
  25461. var chr;
  25462. var len;
  25463. if (text.length === 0) {
  25464. return hash;
  25465. }
  25466. for (i = 0, len = text.length; i < len; i++) {
  25467. chr = text.charCodeAt(i);
  25468. hash = ((hash << 5) - hash) + chr;
  25469. hash |= 0;
  25470. }
  25471. return hash < 0 ? hash * -2 : hash;
  25472. }
  25473. function foldObject (hash, o, seen) {
  25474. return Object.keys(o).sort().reduce(foldKey, hash);
  25475. function foldKey (hash, key) {
  25476. return foldValue(hash, o[key], key, seen);
  25477. }
  25478. }
  25479. function foldValue (input, value, key, seen) {
  25480. var hash = fold(fold(fold(input, key), toString(value)), typeof value);
  25481. if (value === null) {
  25482. return fold(hash, 'null');
  25483. }
  25484. if (value === undefined) {
  25485. return fold(hash, 'undefined');
  25486. }
  25487. if (typeof value === 'object' || typeof value === 'function') {
  25488. if (seen.indexOf(value) !== -1) {
  25489. return fold(hash, '[Circular]' + key);
  25490. }
  25491. seen.push(value);
  25492. var objHash = foldObject(hash, value, seen);
  25493. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  25494. return objHash;
  25495. }
  25496. try {
  25497. return fold(objHash, String(value.valueOf()))
  25498. } catch (err) {
  25499. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  25500. }
  25501. }
  25502. return fold(hash, value.toString());
  25503. }
  25504. function toString (o) {
  25505. return Object.prototype.toString.call(o);
  25506. }
  25507. function sum (o) {
  25508. return pad(foldValue(0, o, '', []).toString(16), 8);
  25509. }
  25510. hashSum = sum;
  25511. return hashSum;
  25512. }
  25513. var hashSumExports = /*@__PURE__*/ requireHashSum();
  25514. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSumExports);
  25515. const CSS_VARS_HELPER = `useCssVars`;
  25516. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  25517. return `{
  25518. ${vars.map(
  25519. (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  25520. ).join(",\n ")}
  25521. }`;
  25522. }
  25523. function genVarName(id, raw, isProd, isSSR = false) {
  25524. if (isProd) {
  25525. return hash(id + raw);
  25526. } else {
  25527. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  25528. }
  25529. }
  25530. function normalizeExpression(exp) {
  25531. exp = exp.trim();
  25532. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  25533. return exp.slice(1, -1);
  25534. }
  25535. return exp;
  25536. }
  25537. const vBindRE = /v-bind\s*\(/g;
  25538. function parseCssVars(sfc) {
  25539. const vars = [];
  25540. sfc.styles.forEach((style) => {
  25541. let match;
  25542. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  25543. while (match = vBindRE.exec(content)) {
  25544. const start = match.index + match[0].length;
  25545. const end = lexBinding(content, start);
  25546. if (end !== null) {
  25547. const variable = normalizeExpression(content.slice(start, end));
  25548. if (!vars.includes(variable)) {
  25549. vars.push(variable);
  25550. }
  25551. }
  25552. }
  25553. });
  25554. return vars;
  25555. }
  25556. function lexBinding(content, start) {
  25557. let state = 0 /* inParens */;
  25558. let parenDepth = 0;
  25559. for (let i = start; i < content.length; i++) {
  25560. const char = content.charAt(i);
  25561. switch (state) {
  25562. case 0 /* inParens */:
  25563. if (char === `'`) {
  25564. state = 1 /* inSingleQuoteString */;
  25565. } else if (char === `"`) {
  25566. state = 2 /* inDoubleQuoteString */;
  25567. } else if (char === `(`) {
  25568. parenDepth++;
  25569. } else if (char === `)`) {
  25570. if (parenDepth > 0) {
  25571. parenDepth--;
  25572. } else {
  25573. return i;
  25574. }
  25575. }
  25576. break;
  25577. case 1 /* inSingleQuoteString */:
  25578. if (char === `'`) {
  25579. state = 0 /* inParens */;
  25580. }
  25581. break;
  25582. case 2 /* inDoubleQuoteString */:
  25583. if (char === `"`) {
  25584. state = 0 /* inParens */;
  25585. }
  25586. break;
  25587. }
  25588. }
  25589. return null;
  25590. }
  25591. const cssVarsPlugin = (opts) => {
  25592. const { id, isProd } = opts;
  25593. return {
  25594. postcssPlugin: "vue-sfc-vars",
  25595. Declaration(decl) {
  25596. const value = decl.value;
  25597. if (vBindRE.test(value)) {
  25598. vBindRE.lastIndex = 0;
  25599. let transformed = "";
  25600. let lastIndex = 0;
  25601. let match;
  25602. while (match = vBindRE.exec(value)) {
  25603. const start = match.index + match[0].length;
  25604. const end = lexBinding(value, start);
  25605. if (end !== null) {
  25606. const variable = normalizeExpression(value.slice(start, end));
  25607. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  25608. lastIndex = end + 1;
  25609. }
  25610. }
  25611. decl.value = transformed + value.slice(lastIndex);
  25612. }
  25613. }
  25614. };
  25615. };
  25616. cssVarsPlugin.postcss = true;
  25617. function genCssVarsCode(vars, bindings, id, isProd) {
  25618. const varsExp = genCssVarsFromList(vars, id, isProd);
  25619. const exp = createSimpleExpression(varsExp, false);
  25620. const context = createTransformContext(createRoot([]), {
  25621. prefixIdentifiers: true,
  25622. inline: true,
  25623. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  25624. });
  25625. const transformed = processExpression(exp, context);
  25626. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  25627. return typeof c === "string" ? c : c.content;
  25628. }).join("");
  25629. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  25630. }
  25631. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  25632. return `
  25633. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  25634. const __injectCSSVars__ = () => {
  25635. ${genCssVarsCode(
  25636. cssVars,
  25637. bindings,
  25638. id,
  25639. isProd
  25640. )}}
  25641. const __setup__ = ${defaultVar}.setup
  25642. ${defaultVar}.setup = __setup__
  25643. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  25644. : __injectCSSVars__
  25645. `;
  25646. }
  25647. var global$1 = (typeof global !== "undefined" ? global :
  25648. typeof self !== "undefined" ? self :
  25649. typeof window !== "undefined" ? window : {});
  25650. // shim for using process in browser
  25651. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  25652. function defaultSetTimout() {
  25653. throw new Error('setTimeout has not been defined');
  25654. }
  25655. function defaultClearTimeout () {
  25656. throw new Error('clearTimeout has not been defined');
  25657. }
  25658. var cachedSetTimeout = defaultSetTimout;
  25659. var cachedClearTimeout = defaultClearTimeout;
  25660. if (typeof global$1.setTimeout === 'function') {
  25661. cachedSetTimeout = setTimeout;
  25662. }
  25663. if (typeof global$1.clearTimeout === 'function') {
  25664. cachedClearTimeout = clearTimeout;
  25665. }
  25666. function runTimeout(fun) {
  25667. if (cachedSetTimeout === setTimeout) {
  25668. //normal enviroments in sane situations
  25669. return setTimeout(fun, 0);
  25670. }
  25671. // if setTimeout wasn't available but was latter defined
  25672. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  25673. cachedSetTimeout = setTimeout;
  25674. return setTimeout(fun, 0);
  25675. }
  25676. try {
  25677. // when when somebody has screwed with setTimeout but no I.E. maddness
  25678. return cachedSetTimeout(fun, 0);
  25679. } catch(e){
  25680. try {
  25681. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25682. return cachedSetTimeout.call(null, fun, 0);
  25683. } catch(e){
  25684. // 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
  25685. return cachedSetTimeout.call(this, fun, 0);
  25686. }
  25687. }
  25688. }
  25689. function runClearTimeout(marker) {
  25690. if (cachedClearTimeout === clearTimeout) {
  25691. //normal enviroments in sane situations
  25692. return clearTimeout(marker);
  25693. }
  25694. // if clearTimeout wasn't available but was latter defined
  25695. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  25696. cachedClearTimeout = clearTimeout;
  25697. return clearTimeout(marker);
  25698. }
  25699. try {
  25700. // when when somebody has screwed with setTimeout but no I.E. maddness
  25701. return cachedClearTimeout(marker);
  25702. } catch (e){
  25703. try {
  25704. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25705. return cachedClearTimeout.call(null, marker);
  25706. } catch (e){
  25707. // 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.
  25708. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  25709. return cachedClearTimeout.call(this, marker);
  25710. }
  25711. }
  25712. }
  25713. var queue = [];
  25714. var draining = false;
  25715. var currentQueue;
  25716. var queueIndex = -1;
  25717. function cleanUpNextTick() {
  25718. if (!draining || !currentQueue) {
  25719. return;
  25720. }
  25721. draining = false;
  25722. if (currentQueue.length) {
  25723. queue = currentQueue.concat(queue);
  25724. } else {
  25725. queueIndex = -1;
  25726. }
  25727. if (queue.length) {
  25728. drainQueue();
  25729. }
  25730. }
  25731. function drainQueue() {
  25732. if (draining) {
  25733. return;
  25734. }
  25735. var timeout = runTimeout(cleanUpNextTick);
  25736. draining = true;
  25737. var len = queue.length;
  25738. while(len) {
  25739. currentQueue = queue;
  25740. queue = [];
  25741. while (++queueIndex < len) {
  25742. if (currentQueue) {
  25743. currentQueue[queueIndex].run();
  25744. }
  25745. }
  25746. queueIndex = -1;
  25747. len = queue.length;
  25748. }
  25749. currentQueue = null;
  25750. draining = false;
  25751. runClearTimeout(timeout);
  25752. }
  25753. function nextTick(fun) {
  25754. var args = new Array(arguments.length - 1);
  25755. if (arguments.length > 1) {
  25756. for (var i = 1; i < arguments.length; i++) {
  25757. args[i - 1] = arguments[i];
  25758. }
  25759. }
  25760. queue.push(new Item(fun, args));
  25761. if (queue.length === 1 && !draining) {
  25762. runTimeout(drainQueue);
  25763. }
  25764. }
  25765. // v8 likes predictible objects
  25766. function Item(fun, array) {
  25767. this.fun = fun;
  25768. this.array = array;
  25769. }
  25770. Item.prototype.run = function () {
  25771. this.fun.apply(null, this.array);
  25772. };
  25773. var title = 'browser';
  25774. var platform = 'browser';
  25775. var browser = true;
  25776. var env = {};
  25777. var argv = [];
  25778. var version$1 = ''; // empty string to avoid regexp issues
  25779. var versions = {};
  25780. var release = {};
  25781. var config = {};
  25782. function noop() {}
  25783. var on = noop;
  25784. var addListener = noop;
  25785. var once = noop;
  25786. var off = noop;
  25787. var removeListener = noop;
  25788. var removeAllListeners = noop;
  25789. var emit = noop;
  25790. function binding(name) {
  25791. throw new Error('process.binding is not supported');
  25792. }
  25793. function cwd () { return '/' }
  25794. function chdir (dir) {
  25795. throw new Error('process.chdir is not supported');
  25796. }function umask() { return 0; }
  25797. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  25798. var performance = global$1.performance || {};
  25799. var performanceNow =
  25800. performance.now ||
  25801. performance.mozNow ||
  25802. performance.msNow ||
  25803. performance.oNow ||
  25804. performance.webkitNow ||
  25805. function(){ return (new Date()).getTime() };
  25806. // generate timestamp or delta
  25807. // see http://nodejs.org/api/process.html#process_process_hrtime
  25808. function hrtime(previousTimestamp){
  25809. var clocktime = performanceNow.call(performance)*1e-3;
  25810. var seconds = Math.floor(clocktime);
  25811. var nanoseconds = Math.floor((clocktime%1)*1e9);
  25812. if (previousTimestamp) {
  25813. seconds = seconds - previousTimestamp[0];
  25814. nanoseconds = nanoseconds - previousTimestamp[1];
  25815. if (nanoseconds<0) {
  25816. seconds--;
  25817. nanoseconds += 1e9;
  25818. }
  25819. }
  25820. return [seconds,nanoseconds]
  25821. }
  25822. var startTime = new Date();
  25823. function uptime() {
  25824. var currentTime = new Date();
  25825. var dif = currentTime - startTime;
  25826. return dif / 1000;
  25827. }
  25828. var browser$1 = {
  25829. nextTick: nextTick,
  25830. title: title,
  25831. browser: browser,
  25832. env: env,
  25833. argv: argv,
  25834. version: version$1,
  25835. versions: versions,
  25836. on: on,
  25837. addListener: addListener,
  25838. once: once,
  25839. off: off,
  25840. removeListener: removeListener,
  25841. removeAllListeners: removeAllListeners,
  25842. emit: emit,
  25843. binding: binding,
  25844. cwd: cwd,
  25845. chdir: chdir,
  25846. umask: umask,
  25847. hrtime: hrtime,
  25848. platform: platform,
  25849. release: release,
  25850. config: config,
  25851. uptime: uptime
  25852. };
  25853. function createCache(max = 500) {
  25854. {
  25855. return /* @__PURE__ */ new Map();
  25856. }
  25857. }
  25858. function isImportUsed(local, sfc) {
  25859. return resolveTemplateUsedIdentifiers(sfc).has(local);
  25860. }
  25861. const templateUsageCheckCache = createCache();
  25862. function resolveTemplateUsedIdentifiers(sfc) {
  25863. const { content, ast } = sfc.template;
  25864. const cached = templateUsageCheckCache.get(content);
  25865. if (cached) {
  25866. return cached;
  25867. }
  25868. const ids = /* @__PURE__ */ new Set();
  25869. ast.children.forEach(walk);
  25870. function walk(node) {
  25871. var _a;
  25872. switch (node.type) {
  25873. case 1:
  25874. let tag = node.tag;
  25875. if (tag.includes(".")) tag = tag.split(".")[0].trim();
  25876. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  25877. ids.add(camelize(tag));
  25878. ids.add(capitalize(camelize(tag)));
  25879. }
  25880. for (let i = 0; i < node.props.length; i++) {
  25881. const prop = node.props[i];
  25882. if (prop.type === 7) {
  25883. if (!isBuiltInDirective(prop.name)) {
  25884. ids.add(`v${capitalize(camelize(prop.name))}`);
  25885. }
  25886. if (prop.arg && !prop.arg.isStatic) {
  25887. extractIdentifiers(ids, prop.arg);
  25888. }
  25889. if (prop.name === "for") {
  25890. extractIdentifiers(ids, prop.forParseResult.source);
  25891. } else if (prop.exp) {
  25892. extractIdentifiers(ids, prop.exp);
  25893. } else if (prop.name === "bind" && !prop.exp) {
  25894. ids.add(camelize(prop.arg.content));
  25895. }
  25896. }
  25897. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  25898. ids.add(prop.value.content);
  25899. }
  25900. }
  25901. node.children.forEach(walk);
  25902. break;
  25903. case 5:
  25904. extractIdentifiers(ids, node.content);
  25905. break;
  25906. }
  25907. }
  25908. templateUsageCheckCache.set(content, ids);
  25909. return ids;
  25910. }
  25911. function extractIdentifiers(ids, node) {
  25912. if (node.ast) {
  25913. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  25914. } else if (node.ast === null) {
  25915. ids.add(node.content);
  25916. }
  25917. }
  25918. var __defProp$a = Object.defineProperty;
  25919. var __defProps$9 = Object.defineProperties;
  25920. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  25921. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  25922. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  25923. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  25924. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  25925. var __spreadValues$a = (a, b) => {
  25926. for (var prop in b || (b = {}))
  25927. if (__hasOwnProp$a.call(b, prop))
  25928. __defNormalProp$a(a, prop, b[prop]);
  25929. if (__getOwnPropSymbols$a)
  25930. for (var prop of __getOwnPropSymbols$a(b)) {
  25931. if (__propIsEnum$a.call(b, prop))
  25932. __defNormalProp$a(a, prop, b[prop]);
  25933. }
  25934. return a;
  25935. };
  25936. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  25937. const DEFAULT_FILENAME = "anonymous.vue";
  25938. const parseCache$1 = createCache();
  25939. function parse$2(source, options = {}) {
  25940. var _a;
  25941. const sourceKey = genCacheKey(source, __spreadProps$9(__spreadValues$a({}, options), {
  25942. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  25943. }));
  25944. const cache = parseCache$1.get(sourceKey);
  25945. if (cache) {
  25946. return cache;
  25947. }
  25948. const {
  25949. sourceMap = true,
  25950. filename = DEFAULT_FILENAME,
  25951. sourceRoot = "",
  25952. pad = false,
  25953. ignoreEmpty = true,
  25954. compiler = CompilerDOM,
  25955. templateParseOptions = {}
  25956. } = options;
  25957. const descriptor = {
  25958. filename,
  25959. source,
  25960. template: null,
  25961. script: null,
  25962. scriptSetup: null,
  25963. styles: [],
  25964. customBlocks: [],
  25965. cssVars: [],
  25966. slotted: false,
  25967. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  25968. };
  25969. const errors = [];
  25970. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  25971. parseMode: "sfc",
  25972. prefixIdentifiers: true
  25973. }, templateParseOptions), {
  25974. onError: (e) => {
  25975. errors.push(e);
  25976. }
  25977. }));
  25978. ast.children.forEach((node) => {
  25979. if (node.type !== 1) {
  25980. return;
  25981. }
  25982. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  25983. return;
  25984. }
  25985. switch (node.tag) {
  25986. case "template":
  25987. if (!descriptor.template) {
  25988. const templateBlock = descriptor.template = createBlock(
  25989. node,
  25990. source,
  25991. false
  25992. );
  25993. if (!templateBlock.attrs.src) {
  25994. templateBlock.ast = createRoot(node.children, source);
  25995. }
  25996. if (templateBlock.attrs.functional) {
  25997. const err = new SyntaxError(
  25998. `<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.`
  25999. );
  26000. err.loc = node.props.find(
  26001. (p) => p.type === 6 && p.name === "functional"
  26002. ).loc;
  26003. errors.push(err);
  26004. }
  26005. } else {
  26006. errors.push(createDuplicateBlockError(node));
  26007. }
  26008. break;
  26009. case "script":
  26010. const scriptBlock = createBlock(node, source, pad);
  26011. const isSetup = !!scriptBlock.attrs.setup;
  26012. if (isSetup && !descriptor.scriptSetup) {
  26013. descriptor.scriptSetup = scriptBlock;
  26014. break;
  26015. }
  26016. if (!isSetup && !descriptor.script) {
  26017. descriptor.script = scriptBlock;
  26018. break;
  26019. }
  26020. errors.push(createDuplicateBlockError(node, isSetup));
  26021. break;
  26022. case "style":
  26023. const styleBlock = createBlock(node, source, pad);
  26024. if (styleBlock.attrs.vars) {
  26025. errors.push(
  26026. new SyntaxError(
  26027. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  26028. )
  26029. );
  26030. }
  26031. descriptor.styles.push(styleBlock);
  26032. break;
  26033. default:
  26034. descriptor.customBlocks.push(createBlock(node, source, pad));
  26035. break;
  26036. }
  26037. });
  26038. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  26039. errors.push(
  26040. new SyntaxError(
  26041. `At least one <template> or <script> is required in a single file component. ${descriptor.filename}`
  26042. )
  26043. );
  26044. }
  26045. if (descriptor.scriptSetup) {
  26046. if (descriptor.scriptSetup.src) {
  26047. errors.push(
  26048. new SyntaxError(
  26049. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  26050. )
  26051. );
  26052. descriptor.scriptSetup = null;
  26053. }
  26054. if (descriptor.script && descriptor.script.src) {
  26055. errors.push(
  26056. new SyntaxError(
  26057. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  26058. )
  26059. );
  26060. descriptor.script = null;
  26061. }
  26062. }
  26063. let templateColumnOffset = 0;
  26064. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  26065. [descriptor.template.content, templateColumnOffset] = dedent(
  26066. descriptor.template.content
  26067. );
  26068. }
  26069. if (sourceMap) {
  26070. const genMap = (block, columnOffset = 0) => {
  26071. if (block && !block.src) {
  26072. block.map = generateSourceMap(
  26073. filename,
  26074. source,
  26075. block.content,
  26076. sourceRoot,
  26077. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  26078. columnOffset
  26079. );
  26080. }
  26081. };
  26082. genMap(descriptor.template, templateColumnOffset);
  26083. genMap(descriptor.script);
  26084. descriptor.styles.forEach((s) => genMap(s));
  26085. descriptor.customBlocks.forEach((s) => genMap(s));
  26086. }
  26087. descriptor.cssVars = parseCssVars(descriptor);
  26088. const slottedRE = /(?:::v-|:)slotted\(/;
  26089. descriptor.slotted = descriptor.styles.some(
  26090. (s) => s.scoped && slottedRE.test(s.content)
  26091. );
  26092. const result = {
  26093. descriptor,
  26094. errors
  26095. };
  26096. parseCache$1.set(sourceKey, result);
  26097. return result;
  26098. }
  26099. function createDuplicateBlockError(node, isScriptSetup = false) {
  26100. const err = new SyntaxError(
  26101. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  26102. );
  26103. err.loc = node.loc;
  26104. return err;
  26105. }
  26106. function createBlock(node, source, pad) {
  26107. const type = node.tag;
  26108. const loc = node.innerLoc;
  26109. const attrs = {};
  26110. const block = {
  26111. type,
  26112. content: source.slice(loc.start.offset, loc.end.offset),
  26113. loc,
  26114. attrs
  26115. };
  26116. if (pad) {
  26117. block.content = padContent(source, block, pad) + block.content;
  26118. }
  26119. node.props.forEach((p) => {
  26120. if (p.type === 6) {
  26121. const name = p.name;
  26122. attrs[name] = p.value ? p.value.content || true : true;
  26123. if (name === "lang") {
  26124. block.lang = p.value && p.value.content;
  26125. } else if (name === "src") {
  26126. block.src = p.value && p.value.content;
  26127. } else if (type === "style") {
  26128. if (name === "scoped") {
  26129. block.scoped = true;
  26130. } else if (name === "module") {
  26131. block.module = attrs[name];
  26132. }
  26133. } else if (type === "script" && name === "setup") {
  26134. block.setup = attrs.setup;
  26135. }
  26136. }
  26137. });
  26138. return block;
  26139. }
  26140. const splitRE = /\r?\n/g;
  26141. const emptyRE = /^(?:\/\/)?\s*$/;
  26142. const replaceRE = /./g;
  26143. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  26144. const map = new sourceMapExports.SourceMapGenerator({
  26145. file: filename.replace(/\\/g, "/"),
  26146. sourceRoot: sourceRoot.replace(/\\/g, "/")
  26147. });
  26148. map.setSourceContent(filename, source);
  26149. map._sources.add(filename);
  26150. generated.split(splitRE).forEach((line, index) => {
  26151. if (!emptyRE.test(line)) {
  26152. const originalLine = index + 1 + lineOffset;
  26153. const generatedLine = index + 1;
  26154. for (let i = 0; i < line.length; i++) {
  26155. if (!/\s/.test(line[i])) {
  26156. map._mappings.add({
  26157. originalLine,
  26158. originalColumn: i + columnOffset,
  26159. generatedLine,
  26160. generatedColumn: i,
  26161. source: filename,
  26162. name: null
  26163. });
  26164. }
  26165. }
  26166. }
  26167. });
  26168. return map.toJSON();
  26169. }
  26170. function padContent(content, block, pad) {
  26171. content = content.slice(0, block.loc.start.offset);
  26172. if (pad === "space") {
  26173. return content.replace(replaceRE, " ");
  26174. } else {
  26175. const offset = content.split(splitRE).length;
  26176. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  26177. return Array(offset).join(padChar);
  26178. }
  26179. }
  26180. function hasSrc(node) {
  26181. return node.props.some((p) => {
  26182. if (p.type !== 6) {
  26183. return false;
  26184. }
  26185. return p.name === "src";
  26186. });
  26187. }
  26188. function isEmpty(node) {
  26189. for (let i = 0; i < node.children.length; i++) {
  26190. const child = node.children[i];
  26191. if (child.type !== 2 || child.content.trim() !== "") {
  26192. return false;
  26193. }
  26194. }
  26195. return true;
  26196. }
  26197. function hmrShouldReload(prevImports, next) {
  26198. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  26199. return false;
  26200. }
  26201. for (const key in prevImports) {
  26202. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  26203. return true;
  26204. }
  26205. }
  26206. return false;
  26207. }
  26208. function dedent(s) {
  26209. const lines = s.split("\n");
  26210. const minIndent = lines.reduce(function(minIndent2, line) {
  26211. var _a, _b;
  26212. if (line.trim() === "") {
  26213. return minIndent2;
  26214. }
  26215. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  26216. return Math.min(indent, minIndent2);
  26217. }, Infinity);
  26218. if (minIndent === 0) {
  26219. return [s, minIndent];
  26220. }
  26221. return [
  26222. lines.map(function(line) {
  26223. return line.slice(minIndent);
  26224. }).join("\n"),
  26225. minIndent
  26226. ];
  26227. }
  26228. // Copyright Joyent, Inc. and other Node contributors.
  26229. //
  26230. // Permission is hereby granted, free of charge, to any person obtaining a
  26231. // copy of this software and associated documentation files (the
  26232. // "Software"), to deal in the Software without restriction, including
  26233. // without limitation the rights to use, copy, modify, merge, publish,
  26234. // distribute, sublicense, and/or sell copies of the Software, and to permit
  26235. // persons to whom the Software is furnished to do so, subject to the
  26236. // following conditions:
  26237. //
  26238. // The above copyright notice and this permission notice shall be included
  26239. // in all copies or substantial portions of the Software.
  26240. //
  26241. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26242. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26243. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26244. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  26245. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  26246. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  26247. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  26248. // resolves . and .. elements in a path array with directory names there
  26249. // must be no slashes, empty elements, or device names (c:\) in the array
  26250. // (so also no leading and trailing slashes - it does not distinguish
  26251. // relative and absolute paths)
  26252. function normalizeArray(parts, allowAboveRoot) {
  26253. // if the path tries to go above the root, `up` ends up > 0
  26254. var up = 0;
  26255. for (var i = parts.length - 1; i >= 0; i--) {
  26256. var last = parts[i];
  26257. if (last === '.') {
  26258. parts.splice(i, 1);
  26259. } else if (last === '..') {
  26260. parts.splice(i, 1);
  26261. up++;
  26262. } else if (up) {
  26263. parts.splice(i, 1);
  26264. up--;
  26265. }
  26266. }
  26267. // if the path is allowed to go above the root, restore leading ..s
  26268. if (allowAboveRoot) {
  26269. for (; up--; up) {
  26270. parts.unshift('..');
  26271. }
  26272. }
  26273. return parts;
  26274. }
  26275. // Split a filename into [root, dir, basename, ext], unix version
  26276. // 'root' is just a slash, or nothing.
  26277. var splitPathRe =
  26278. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  26279. var splitPath = function(filename) {
  26280. return splitPathRe.exec(filename).slice(1);
  26281. };
  26282. // path.resolve([from ...], to)
  26283. // posix version
  26284. function resolve() {
  26285. var resolvedPath = '',
  26286. resolvedAbsolute = false;
  26287. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  26288. var path = (i >= 0) ? arguments[i] : '/';
  26289. // Skip empty and invalid entries
  26290. if (typeof path !== 'string') {
  26291. throw new TypeError('Arguments to path.resolve must be strings');
  26292. } else if (!path) {
  26293. continue;
  26294. }
  26295. resolvedPath = path + '/' + resolvedPath;
  26296. resolvedAbsolute = path.charAt(0) === '/';
  26297. }
  26298. // At this point the path should be resolved to a full absolute path, but
  26299. // handle relative paths to be safe (might happen when process.cwd() fails)
  26300. // Normalize the path
  26301. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  26302. return !!p;
  26303. }), !resolvedAbsolute).join('/');
  26304. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  26305. }
  26306. // path.normalize(path)
  26307. // posix version
  26308. function normalize$1(path) {
  26309. var isPathAbsolute = isAbsolute(path),
  26310. trailingSlash = substr(path, -1) === '/';
  26311. // Normalize the path
  26312. path = normalizeArray(filter(path.split('/'), function(p) {
  26313. return !!p;
  26314. }), !isPathAbsolute).join('/');
  26315. if (!path && !isPathAbsolute) {
  26316. path = '.';
  26317. }
  26318. if (path && trailingSlash) {
  26319. path += '/';
  26320. }
  26321. return (isPathAbsolute ? '/' : '') + path;
  26322. }
  26323. // posix version
  26324. function isAbsolute(path) {
  26325. return path.charAt(0) === '/';
  26326. }
  26327. // posix version
  26328. function join() {
  26329. var paths = Array.prototype.slice.call(arguments, 0);
  26330. return normalize$1(filter(paths, function(p, index) {
  26331. if (typeof p !== 'string') {
  26332. throw new TypeError('Arguments to path.join must be strings');
  26333. }
  26334. return p;
  26335. }).join('/'));
  26336. }
  26337. // path.relative(from, to)
  26338. // posix version
  26339. function relative(from, to) {
  26340. from = resolve(from).substr(1);
  26341. to = resolve(to).substr(1);
  26342. function trim(arr) {
  26343. var start = 0;
  26344. for (; start < arr.length; start++) {
  26345. if (arr[start] !== '') break;
  26346. }
  26347. var end = arr.length - 1;
  26348. for (; end >= 0; end--) {
  26349. if (arr[end] !== '') break;
  26350. }
  26351. if (start > end) return [];
  26352. return arr.slice(start, end - start + 1);
  26353. }
  26354. var fromParts = trim(from.split('/'));
  26355. var toParts = trim(to.split('/'));
  26356. var length = Math.min(fromParts.length, toParts.length);
  26357. var samePartsLength = length;
  26358. for (var i = 0; i < length; i++) {
  26359. if (fromParts[i] !== toParts[i]) {
  26360. samePartsLength = i;
  26361. break;
  26362. }
  26363. }
  26364. var outputParts = [];
  26365. for (var i = samePartsLength; i < fromParts.length; i++) {
  26366. outputParts.push('..');
  26367. }
  26368. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  26369. return outputParts.join('/');
  26370. }
  26371. var sep = '/';
  26372. var delimiter$1 = ':';
  26373. function dirname(path) {
  26374. var result = splitPath(path),
  26375. root = result[0],
  26376. dir = result[1];
  26377. if (!root && !dir) {
  26378. // No dirname whatsoever
  26379. return '.';
  26380. }
  26381. if (dir) {
  26382. // It has a dirname, strip trailing slash
  26383. dir = dir.substr(0, dir.length - 1);
  26384. }
  26385. return root + dir;
  26386. }
  26387. function basename(path, ext) {
  26388. var f = splitPath(path)[2];
  26389. // TODO: make this comparison case-insensitive on windows?
  26390. if (ext && f.substr(-1 * ext.length) === ext) {
  26391. f = f.substr(0, f.length - ext.length);
  26392. }
  26393. return f;
  26394. }
  26395. function extname(path) {
  26396. return splitPath(path)[3];
  26397. }
  26398. var path = {
  26399. extname: extname,
  26400. basename: basename,
  26401. dirname: dirname,
  26402. sep: sep,
  26403. delimiter: delimiter$1,
  26404. relative: relative,
  26405. join: join,
  26406. isAbsolute: isAbsolute,
  26407. normalize: normalize$1,
  26408. resolve: resolve
  26409. };
  26410. function filter (xs, f) {
  26411. if (xs.filter) return xs.filter(f);
  26412. var res = [];
  26413. for (var i = 0; i < xs.length; i++) {
  26414. if (f(xs[i], i, xs)) res.push(xs[i]);
  26415. }
  26416. return res;
  26417. }
  26418. // String.prototype.substr - negative index don't work in IE8
  26419. var substr = 'ab'.substr(-1) === 'b' ?
  26420. function (str, start, len) { return str.substr(start, len) } :
  26421. function (str, start, len) {
  26422. if (start < 0) start = str.length + start;
  26423. return str.substr(start, len);
  26424. }
  26425. ;
  26426. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  26427. __proto__: null,
  26428. basename: basename,
  26429. default: path,
  26430. delimiter: delimiter$1,
  26431. dirname: dirname,
  26432. extname: extname,
  26433. isAbsolute: isAbsolute,
  26434. join: join,
  26435. normalize: normalize$1,
  26436. relative: relative,
  26437. resolve: resolve,
  26438. sep: sep
  26439. });
  26440. /*! https://mths.be/punycode v1.4.1 by @mathias */
  26441. /** Highest positive signed 32-bit float value */
  26442. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  26443. /** Bootstring parameters */
  26444. var base = 36;
  26445. var tMin = 1;
  26446. var tMax = 26;
  26447. var skew = 38;
  26448. var damp = 700;
  26449. var initialBias = 72;
  26450. var initialN = 128; // 0x80
  26451. var delimiter = '-'; // '\x2D'
  26452. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  26453. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  26454. /** Error messages */
  26455. var errors = {
  26456. 'overflow': 'Overflow: input needs wider integers to process',
  26457. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  26458. 'invalid-input': 'Invalid input'
  26459. };
  26460. /** Convenience shortcuts */
  26461. var baseMinusTMin = base - tMin;
  26462. var floor = Math.floor;
  26463. var stringFromCharCode = String.fromCharCode;
  26464. /*--------------------------------------------------------------------------*/
  26465. /**
  26466. * A generic error utility function.
  26467. * @private
  26468. * @param {String} type The error type.
  26469. * @returns {Error} Throws a `RangeError` with the applicable error message.
  26470. */
  26471. function error(type) {
  26472. throw new RangeError(errors[type]);
  26473. }
  26474. /**
  26475. * A generic `Array#map` utility function.
  26476. * @private
  26477. * @param {Array} array The array to iterate over.
  26478. * @param {Function} callback The function that gets called for every array
  26479. * item.
  26480. * @returns {Array} A new array of values returned by the callback function.
  26481. */
  26482. function map$1(array, fn) {
  26483. var length = array.length;
  26484. var result = [];
  26485. while (length--) {
  26486. result[length] = fn(array[length]);
  26487. }
  26488. return result;
  26489. }
  26490. /**
  26491. * A simple `Array#map`-like wrapper to work with domain name strings or email
  26492. * addresses.
  26493. * @private
  26494. * @param {String} domain The domain name or email address.
  26495. * @param {Function} callback The function that gets called for every
  26496. * character.
  26497. * @returns {Array} A new string of characters returned by the callback
  26498. * function.
  26499. */
  26500. function mapDomain(string, fn) {
  26501. var parts = string.split('@');
  26502. var result = '';
  26503. if (parts.length > 1) {
  26504. // In email addresses, only the domain name should be punycoded. Leave
  26505. // the local part (i.e. everything up to `@`) intact.
  26506. result = parts[0] + '@';
  26507. string = parts[1];
  26508. }
  26509. // Avoid `split(regex)` for IE8 compatibility. See #17.
  26510. string = string.replace(regexSeparators, '\x2E');
  26511. var labels = string.split('.');
  26512. var encoded = map$1(labels, fn).join('.');
  26513. return result + encoded;
  26514. }
  26515. /**
  26516. * Creates an array containing the numeric code points of each Unicode
  26517. * character in the string. While JavaScript uses UCS-2 internally,
  26518. * this function will convert a pair of surrogate halves (each of which
  26519. * UCS-2 exposes as separate characters) into a single code point,
  26520. * matching UTF-16.
  26521. * @see `punycode.ucs2.encode`
  26522. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  26523. * @memberOf punycode.ucs2
  26524. * @name decode
  26525. * @param {String} string The Unicode input string (UCS-2).
  26526. * @returns {Array} The new array of code points.
  26527. */
  26528. function ucs2decode(string) {
  26529. var output = [],
  26530. counter = 0,
  26531. length = string.length,
  26532. value,
  26533. extra;
  26534. while (counter < length) {
  26535. value = string.charCodeAt(counter++);
  26536. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  26537. // high surrogate, and there is a next character
  26538. extra = string.charCodeAt(counter++);
  26539. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  26540. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  26541. } else {
  26542. // unmatched surrogate; only append this code unit, in case the next
  26543. // code unit is the high surrogate of a surrogate pair
  26544. output.push(value);
  26545. counter--;
  26546. }
  26547. } else {
  26548. output.push(value);
  26549. }
  26550. }
  26551. return output;
  26552. }
  26553. /**
  26554. * Converts a digit/integer into a basic code point.
  26555. * @see `basicToDigit()`
  26556. * @private
  26557. * @param {Number} digit The numeric value of a basic code point.
  26558. * @returns {Number} The basic code point whose value (when used for
  26559. * representing integers) is `digit`, which needs to be in the range
  26560. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  26561. * used; else, the lowercase form is used. The behavior is undefined
  26562. * if `flag` is non-zero and `digit` has no uppercase form.
  26563. */
  26564. function digitToBasic(digit, flag) {
  26565. // 0..25 map to ASCII a..z or A..Z
  26566. // 26..35 map to ASCII 0..9
  26567. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  26568. }
  26569. /**
  26570. * Bias adaptation function as per section 3.4 of RFC 3492.
  26571. * https://tools.ietf.org/html/rfc3492#section-3.4
  26572. * @private
  26573. */
  26574. function adapt(delta, numPoints, firstTime) {
  26575. var k = 0;
  26576. delta = firstTime ? floor(delta / damp) : delta >> 1;
  26577. delta += floor(delta / numPoints);
  26578. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  26579. delta = floor(delta / baseMinusTMin);
  26580. }
  26581. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  26582. }
  26583. /**
  26584. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  26585. * Punycode string of ASCII-only symbols.
  26586. * @memberOf punycode
  26587. * @param {String} input The string of Unicode symbols.
  26588. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  26589. */
  26590. function encode$1(input) {
  26591. var n,
  26592. delta,
  26593. handledCPCount,
  26594. basicLength,
  26595. bias,
  26596. j,
  26597. m,
  26598. q,
  26599. k,
  26600. t,
  26601. currentValue,
  26602. output = [],
  26603. /** `inputLength` will hold the number of code points in `input`. */
  26604. inputLength,
  26605. /** Cached calculation results */
  26606. handledCPCountPlusOne,
  26607. baseMinusT,
  26608. qMinusT;
  26609. // Convert the input in UCS-2 to Unicode
  26610. input = ucs2decode(input);
  26611. // Cache the length
  26612. inputLength = input.length;
  26613. // Initialize the state
  26614. n = initialN;
  26615. delta = 0;
  26616. bias = initialBias;
  26617. // Handle the basic code points
  26618. for (j = 0; j < inputLength; ++j) {
  26619. currentValue = input[j];
  26620. if (currentValue < 0x80) {
  26621. output.push(stringFromCharCode(currentValue));
  26622. }
  26623. }
  26624. handledCPCount = basicLength = output.length;
  26625. // `handledCPCount` is the number of code points that have been handled;
  26626. // `basicLength` is the number of basic code points.
  26627. // Finish the basic string - if it is not empty - with a delimiter
  26628. if (basicLength) {
  26629. output.push(delimiter);
  26630. }
  26631. // Main encoding loop:
  26632. while (handledCPCount < inputLength) {
  26633. // All non-basic code points < n have been handled already. Find the next
  26634. // larger one:
  26635. for (m = maxInt, j = 0; j < inputLength; ++j) {
  26636. currentValue = input[j];
  26637. if (currentValue >= n && currentValue < m) {
  26638. m = currentValue;
  26639. }
  26640. }
  26641. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  26642. // but guard against overflow
  26643. handledCPCountPlusOne = handledCPCount + 1;
  26644. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  26645. error('overflow');
  26646. }
  26647. delta += (m - n) * handledCPCountPlusOne;
  26648. n = m;
  26649. for (j = 0; j < inputLength; ++j) {
  26650. currentValue = input[j];
  26651. if (currentValue < n && ++delta > maxInt) {
  26652. error('overflow');
  26653. }
  26654. if (currentValue == n) {
  26655. // Represent delta as a generalized variable-length integer
  26656. for (q = delta, k = base; /* no condition */ ; k += base) {
  26657. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  26658. if (q < t) {
  26659. break;
  26660. }
  26661. qMinusT = q - t;
  26662. baseMinusT = base - t;
  26663. output.push(
  26664. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  26665. );
  26666. q = floor(qMinusT / baseMinusT);
  26667. }
  26668. output.push(stringFromCharCode(digitToBasic(q, 0)));
  26669. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  26670. delta = 0;
  26671. ++handledCPCount;
  26672. }
  26673. }
  26674. ++delta;
  26675. ++n;
  26676. }
  26677. return output.join('');
  26678. }
  26679. /**
  26680. * Converts a Unicode string representing a domain name or an email address to
  26681. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  26682. * i.e. it doesn't matter if you call it with a domain that's already in
  26683. * ASCII.
  26684. * @memberOf punycode
  26685. * @param {String} input The domain name or email address to convert, as a
  26686. * Unicode string.
  26687. * @returns {String} The Punycode representation of the given domain name or
  26688. * email address.
  26689. */
  26690. function toASCII(input) {
  26691. return mapDomain(input, function(string) {
  26692. return regexNonASCII.test(string) ?
  26693. 'xn--' + encode$1(string) :
  26694. string;
  26695. });
  26696. }
  26697. var lookup = [];
  26698. var revLookup = [];
  26699. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26700. var inited = false;
  26701. function init () {
  26702. inited = true;
  26703. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26704. for (var i = 0, len = code.length; i < len; ++i) {
  26705. lookup[i] = code[i];
  26706. revLookup[code.charCodeAt(i)] = i;
  26707. }
  26708. revLookup['-'.charCodeAt(0)] = 62;
  26709. revLookup['_'.charCodeAt(0)] = 63;
  26710. }
  26711. function toByteArray (b64) {
  26712. if (!inited) {
  26713. init();
  26714. }
  26715. var i, j, l, tmp, placeHolders, arr;
  26716. var len = b64.length;
  26717. if (len % 4 > 0) {
  26718. throw new Error('Invalid string. Length must be a multiple of 4')
  26719. }
  26720. // the number of equal signs (place holders)
  26721. // if there are two placeholders, than the two characters before it
  26722. // represent one byte
  26723. // if there is only one, then the three characters before it represent 2 bytes
  26724. // this is just a cheap hack to not do indexOf twice
  26725. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  26726. // base64 is 4/3 + up to two characters of the original data
  26727. arr = new Arr(len * 3 / 4 - placeHolders);
  26728. // if there are placeholders, only get up to the last complete 4 chars
  26729. l = placeHolders > 0 ? len - 4 : len;
  26730. var L = 0;
  26731. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  26732. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  26733. arr[L++] = (tmp >> 16) & 0xFF;
  26734. arr[L++] = (tmp >> 8) & 0xFF;
  26735. arr[L++] = tmp & 0xFF;
  26736. }
  26737. if (placeHolders === 2) {
  26738. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  26739. arr[L++] = tmp & 0xFF;
  26740. } else if (placeHolders === 1) {
  26741. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  26742. arr[L++] = (tmp >> 8) & 0xFF;
  26743. arr[L++] = tmp & 0xFF;
  26744. }
  26745. return arr
  26746. }
  26747. function tripletToBase64 (num) {
  26748. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  26749. }
  26750. function encodeChunk (uint8, start, end) {
  26751. var tmp;
  26752. var output = [];
  26753. for (var i = start; i < end; i += 3) {
  26754. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  26755. output.push(tripletToBase64(tmp));
  26756. }
  26757. return output.join('')
  26758. }
  26759. function fromByteArray (uint8) {
  26760. if (!inited) {
  26761. init();
  26762. }
  26763. var tmp;
  26764. var len = uint8.length;
  26765. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26766. var output = '';
  26767. var parts = [];
  26768. var maxChunkLength = 16383; // must be multiple of 3
  26769. // go through the array every three bytes, we'll deal with trailing stuff later
  26770. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26771. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  26772. }
  26773. // pad the end with zeros, but make sure to not forget the extra bytes
  26774. if (extraBytes === 1) {
  26775. tmp = uint8[len - 1];
  26776. output += lookup[tmp >> 2];
  26777. output += lookup[(tmp << 4) & 0x3F];
  26778. output += '==';
  26779. } else if (extraBytes === 2) {
  26780. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  26781. output += lookup[tmp >> 10];
  26782. output += lookup[(tmp >> 4) & 0x3F];
  26783. output += lookup[(tmp << 2) & 0x3F];
  26784. output += '=';
  26785. }
  26786. parts.push(output);
  26787. return parts.join('')
  26788. }
  26789. function read (buffer, offset, isLE, mLen, nBytes) {
  26790. var e, m;
  26791. var eLen = nBytes * 8 - mLen - 1;
  26792. var eMax = (1 << eLen) - 1;
  26793. var eBias = eMax >> 1;
  26794. var nBits = -7;
  26795. var i = isLE ? (nBytes - 1) : 0;
  26796. var d = isLE ? -1 : 1;
  26797. var s = buffer[offset + i];
  26798. i += d;
  26799. e = s & ((1 << (-nBits)) - 1);
  26800. s >>= (-nBits);
  26801. nBits += eLen;
  26802. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26803. m = e & ((1 << (-nBits)) - 1);
  26804. e >>= (-nBits);
  26805. nBits += mLen;
  26806. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26807. if (e === 0) {
  26808. e = 1 - eBias;
  26809. } else if (e === eMax) {
  26810. return m ? NaN : ((s ? -1 : 1) * Infinity)
  26811. } else {
  26812. m = m + Math.pow(2, mLen);
  26813. e = e - eBias;
  26814. }
  26815. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  26816. }
  26817. function write (buffer, value, offset, isLE, mLen, nBytes) {
  26818. var e, m, c;
  26819. var eLen = nBytes * 8 - mLen - 1;
  26820. var eMax = (1 << eLen) - 1;
  26821. var eBias = eMax >> 1;
  26822. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  26823. var i = isLE ? 0 : (nBytes - 1);
  26824. var d = isLE ? 1 : -1;
  26825. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  26826. value = Math.abs(value);
  26827. if (isNaN(value) || value === Infinity) {
  26828. m = isNaN(value) ? 1 : 0;
  26829. e = eMax;
  26830. } else {
  26831. e = Math.floor(Math.log(value) / Math.LN2);
  26832. if (value * (c = Math.pow(2, -e)) < 1) {
  26833. e--;
  26834. c *= 2;
  26835. }
  26836. if (e + eBias >= 1) {
  26837. value += rt / c;
  26838. } else {
  26839. value += rt * Math.pow(2, 1 - eBias);
  26840. }
  26841. if (value * c >= 2) {
  26842. e++;
  26843. c /= 2;
  26844. }
  26845. if (e + eBias >= eMax) {
  26846. m = 0;
  26847. e = eMax;
  26848. } else if (e + eBias >= 1) {
  26849. m = (value * c - 1) * Math.pow(2, mLen);
  26850. e = e + eBias;
  26851. } else {
  26852. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  26853. e = 0;
  26854. }
  26855. }
  26856. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  26857. e = (e << mLen) | m;
  26858. eLen += mLen;
  26859. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  26860. buffer[offset + i - d] |= s * 128;
  26861. }
  26862. var toString$1 = {}.toString;
  26863. var isArray$2 = Array.isArray || function (arr) {
  26864. return toString$1.call(arr) == '[object Array]';
  26865. };
  26866. /*!
  26867. * The buffer module from node.js, for the browser.
  26868. *
  26869. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  26870. * @license MIT
  26871. */
  26872. /* eslint-disable no-proto */
  26873. var INSPECT_MAX_BYTES = 50;
  26874. /**
  26875. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  26876. * === true Use Uint8Array implementation (fastest)
  26877. * === false Use Object implementation (most compatible, even IE6)
  26878. *
  26879. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  26880. * Opera 11.6+, iOS 4.2+.
  26881. *
  26882. * Due to various browser bugs, sometimes the Object implementation will be used even
  26883. * when the browser supports typed arrays.
  26884. *
  26885. * Note:
  26886. *
  26887. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  26888. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  26889. *
  26890. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  26891. *
  26892. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  26893. * incorrect length in some situations.
  26894. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  26895. * get the Object implementation, which is slower but behaves correctly.
  26896. */
  26897. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  26898. ? global$1.TYPED_ARRAY_SUPPORT
  26899. : true;
  26900. /*
  26901. * Export kMaxLength after typed array support is determined.
  26902. */
  26903. kMaxLength();
  26904. function kMaxLength () {
  26905. return Buffer$1.TYPED_ARRAY_SUPPORT
  26906. ? 0x7fffffff
  26907. : 0x3fffffff
  26908. }
  26909. function createBuffer (that, length) {
  26910. if (kMaxLength() < length) {
  26911. throw new RangeError('Invalid typed array length')
  26912. }
  26913. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26914. // Return an augmented `Uint8Array` instance, for best performance
  26915. that = new Uint8Array(length);
  26916. that.__proto__ = Buffer$1.prototype;
  26917. } else {
  26918. // Fallback: Return an object instance of the Buffer class
  26919. if (that === null) {
  26920. that = new Buffer$1(length);
  26921. }
  26922. that.length = length;
  26923. }
  26924. return that
  26925. }
  26926. /**
  26927. * The Buffer constructor returns instances of `Uint8Array` that have their
  26928. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  26929. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  26930. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  26931. * returns a single octet.
  26932. *
  26933. * The `Uint8Array` prototype remains unmodified.
  26934. */
  26935. function Buffer$1 (arg, encodingOrOffset, length) {
  26936. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  26937. return new Buffer$1(arg, encodingOrOffset, length)
  26938. }
  26939. // Common case.
  26940. if (typeof arg === 'number') {
  26941. if (typeof encodingOrOffset === 'string') {
  26942. throw new Error(
  26943. 'If encoding is specified then the first argument must be a string'
  26944. )
  26945. }
  26946. return allocUnsafe(this, arg)
  26947. }
  26948. return from(this, arg, encodingOrOffset, length)
  26949. }
  26950. Buffer$1.poolSize = 8192; // not used by this implementation
  26951. // TODO: Legacy, not needed anymore. Remove in next major version.
  26952. Buffer$1._augment = function (arr) {
  26953. arr.__proto__ = Buffer$1.prototype;
  26954. return arr
  26955. };
  26956. function from (that, value, encodingOrOffset, length) {
  26957. if (typeof value === 'number') {
  26958. throw new TypeError('"value" argument must not be a number')
  26959. }
  26960. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  26961. return fromArrayBuffer(that, value, encodingOrOffset, length)
  26962. }
  26963. if (typeof value === 'string') {
  26964. return fromString(that, value, encodingOrOffset)
  26965. }
  26966. return fromObject(that, value)
  26967. }
  26968. /**
  26969. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  26970. * if value is a number.
  26971. * Buffer.from(str[, encoding])
  26972. * Buffer.from(array)
  26973. * Buffer.from(buffer)
  26974. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  26975. **/
  26976. Buffer$1.from = function (value, encodingOrOffset, length) {
  26977. return from(null, value, encodingOrOffset, length)
  26978. };
  26979. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26980. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  26981. Buffer$1.__proto__ = Uint8Array;
  26982. if (typeof Symbol !== 'undefined' && Symbol.species &&
  26983. Buffer$1[Symbol.species] === Buffer$1) ;
  26984. }
  26985. function assertSize (size) {
  26986. if (typeof size !== 'number') {
  26987. throw new TypeError('"size" argument must be a number')
  26988. } else if (size < 0) {
  26989. throw new RangeError('"size" argument must not be negative')
  26990. }
  26991. }
  26992. function alloc (that, size, fill, encoding) {
  26993. assertSize(size);
  26994. if (size <= 0) {
  26995. return createBuffer(that, size)
  26996. }
  26997. if (fill !== undefined) {
  26998. // Only pay attention to encoding if it's a string. This
  26999. // prevents accidentally sending in a number that would
  27000. // be interpretted as a start offset.
  27001. return typeof encoding === 'string'
  27002. ? createBuffer(that, size).fill(fill, encoding)
  27003. : createBuffer(that, size).fill(fill)
  27004. }
  27005. return createBuffer(that, size)
  27006. }
  27007. /**
  27008. * Creates a new filled Buffer instance.
  27009. * alloc(size[, fill[, encoding]])
  27010. **/
  27011. Buffer$1.alloc = function (size, fill, encoding) {
  27012. return alloc(null, size, fill, encoding)
  27013. };
  27014. function allocUnsafe (that, size) {
  27015. assertSize(size);
  27016. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  27017. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  27018. for (var i = 0; i < size; ++i) {
  27019. that[i] = 0;
  27020. }
  27021. }
  27022. return that
  27023. }
  27024. /**
  27025. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  27026. * */
  27027. Buffer$1.allocUnsafe = function (size) {
  27028. return allocUnsafe(null, size)
  27029. };
  27030. /**
  27031. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  27032. */
  27033. Buffer$1.allocUnsafeSlow = function (size) {
  27034. return allocUnsafe(null, size)
  27035. };
  27036. function fromString (that, string, encoding) {
  27037. if (typeof encoding !== 'string' || encoding === '') {
  27038. encoding = 'utf8';
  27039. }
  27040. if (!Buffer$1.isEncoding(encoding)) {
  27041. throw new TypeError('"encoding" must be a valid string encoding')
  27042. }
  27043. var length = byteLength(string, encoding) | 0;
  27044. that = createBuffer(that, length);
  27045. var actual = that.write(string, encoding);
  27046. if (actual !== length) {
  27047. // Writing a hex string, for example, that contains invalid characters will
  27048. // cause everything after the first invalid character to be ignored. (e.g.
  27049. // 'abxxcd' will be treated as 'ab')
  27050. that = that.slice(0, actual);
  27051. }
  27052. return that
  27053. }
  27054. function fromArrayLike (that, array) {
  27055. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  27056. that = createBuffer(that, length);
  27057. for (var i = 0; i < length; i += 1) {
  27058. that[i] = array[i] & 255;
  27059. }
  27060. return that
  27061. }
  27062. function fromArrayBuffer (that, array, byteOffset, length) {
  27063. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  27064. if (byteOffset < 0 || array.byteLength < byteOffset) {
  27065. throw new RangeError('\'offset\' is out of bounds')
  27066. }
  27067. if (array.byteLength < byteOffset + (length || 0)) {
  27068. throw new RangeError('\'length\' is out of bounds')
  27069. }
  27070. if (byteOffset === undefined && length === undefined) {
  27071. array = new Uint8Array(array);
  27072. } else if (length === undefined) {
  27073. array = new Uint8Array(array, byteOffset);
  27074. } else {
  27075. array = new Uint8Array(array, byteOffset, length);
  27076. }
  27077. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27078. // Return an augmented `Uint8Array` instance, for best performance
  27079. that = array;
  27080. that.__proto__ = Buffer$1.prototype;
  27081. } else {
  27082. // Fallback: Return an object instance of the Buffer class
  27083. that = fromArrayLike(that, array);
  27084. }
  27085. return that
  27086. }
  27087. function fromObject (that, obj) {
  27088. if (internalIsBuffer(obj)) {
  27089. var len = checked(obj.length) | 0;
  27090. that = createBuffer(that, len);
  27091. if (that.length === 0) {
  27092. return that
  27093. }
  27094. obj.copy(that, 0, 0, len);
  27095. return that
  27096. }
  27097. if (obj) {
  27098. if ((typeof ArrayBuffer !== 'undefined' &&
  27099. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  27100. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  27101. return createBuffer(that, 0)
  27102. }
  27103. return fromArrayLike(that, obj)
  27104. }
  27105. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  27106. return fromArrayLike(that, obj.data)
  27107. }
  27108. }
  27109. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  27110. }
  27111. function checked (length) {
  27112. // Note: cannot use `length < kMaxLength()` here because that fails when
  27113. // length is NaN (which is otherwise coerced to zero.)
  27114. if (length >= kMaxLength()) {
  27115. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  27116. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  27117. }
  27118. return length | 0
  27119. }
  27120. Buffer$1.isBuffer = isBuffer$1;
  27121. function internalIsBuffer (b) {
  27122. return !!(b != null && b._isBuffer)
  27123. }
  27124. Buffer$1.compare = function compare (a, b) {
  27125. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  27126. throw new TypeError('Arguments must be Buffers')
  27127. }
  27128. if (a === b) return 0
  27129. var x = a.length;
  27130. var y = b.length;
  27131. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  27132. if (a[i] !== b[i]) {
  27133. x = a[i];
  27134. y = b[i];
  27135. break
  27136. }
  27137. }
  27138. if (x < y) return -1
  27139. if (y < x) return 1
  27140. return 0
  27141. };
  27142. Buffer$1.isEncoding = function isEncoding (encoding) {
  27143. switch (String(encoding).toLowerCase()) {
  27144. case 'hex':
  27145. case 'utf8':
  27146. case 'utf-8':
  27147. case 'ascii':
  27148. case 'latin1':
  27149. case 'binary':
  27150. case 'base64':
  27151. case 'ucs2':
  27152. case 'ucs-2':
  27153. case 'utf16le':
  27154. case 'utf-16le':
  27155. return true
  27156. default:
  27157. return false
  27158. }
  27159. };
  27160. Buffer$1.concat = function concat (list, length) {
  27161. if (!isArray$2(list)) {
  27162. throw new TypeError('"list" argument must be an Array of Buffers')
  27163. }
  27164. if (list.length === 0) {
  27165. return Buffer$1.alloc(0)
  27166. }
  27167. var i;
  27168. if (length === undefined) {
  27169. length = 0;
  27170. for (i = 0; i < list.length; ++i) {
  27171. length += list[i].length;
  27172. }
  27173. }
  27174. var buffer = Buffer$1.allocUnsafe(length);
  27175. var pos = 0;
  27176. for (i = 0; i < list.length; ++i) {
  27177. var buf = list[i];
  27178. if (!internalIsBuffer(buf)) {
  27179. throw new TypeError('"list" argument must be an Array of Buffers')
  27180. }
  27181. buf.copy(buffer, pos);
  27182. pos += buf.length;
  27183. }
  27184. return buffer
  27185. };
  27186. function byteLength (string, encoding) {
  27187. if (internalIsBuffer(string)) {
  27188. return string.length
  27189. }
  27190. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  27191. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  27192. return string.byteLength
  27193. }
  27194. if (typeof string !== 'string') {
  27195. string = '' + string;
  27196. }
  27197. var len = string.length;
  27198. if (len === 0) return 0
  27199. // Use a for loop to avoid recursion
  27200. var loweredCase = false;
  27201. for (;;) {
  27202. switch (encoding) {
  27203. case 'ascii':
  27204. case 'latin1':
  27205. case 'binary':
  27206. return len
  27207. case 'utf8':
  27208. case 'utf-8':
  27209. case undefined:
  27210. return utf8ToBytes(string).length
  27211. case 'ucs2':
  27212. case 'ucs-2':
  27213. case 'utf16le':
  27214. case 'utf-16le':
  27215. return len * 2
  27216. case 'hex':
  27217. return len >>> 1
  27218. case 'base64':
  27219. return base64ToBytes(string).length
  27220. default:
  27221. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  27222. encoding = ('' + encoding).toLowerCase();
  27223. loweredCase = true;
  27224. }
  27225. }
  27226. }
  27227. Buffer$1.byteLength = byteLength;
  27228. function slowToString (encoding, start, end) {
  27229. var loweredCase = false;
  27230. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  27231. // property of a typed array.
  27232. // This behaves neither like String nor Uint8Array in that we set start/end
  27233. // to their upper/lower bounds if the value passed is out of range.
  27234. // undefined is handled specially as per ECMA-262 6th Edition,
  27235. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  27236. if (start === undefined || start < 0) {
  27237. start = 0;
  27238. }
  27239. // Return early if start > this.length. Done here to prevent potential uint32
  27240. // coercion fail below.
  27241. if (start > this.length) {
  27242. return ''
  27243. }
  27244. if (end === undefined || end > this.length) {
  27245. end = this.length;
  27246. }
  27247. if (end <= 0) {
  27248. return ''
  27249. }
  27250. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  27251. end >>>= 0;
  27252. start >>>= 0;
  27253. if (end <= start) {
  27254. return ''
  27255. }
  27256. if (!encoding) encoding = 'utf8';
  27257. while (true) {
  27258. switch (encoding) {
  27259. case 'hex':
  27260. return hexSlice(this, start, end)
  27261. case 'utf8':
  27262. case 'utf-8':
  27263. return utf8Slice(this, start, end)
  27264. case 'ascii':
  27265. return asciiSlice(this, start, end)
  27266. case 'latin1':
  27267. case 'binary':
  27268. return latin1Slice(this, start, end)
  27269. case 'base64':
  27270. return base64Slice(this, start, end)
  27271. case 'ucs2':
  27272. case 'ucs-2':
  27273. case 'utf16le':
  27274. case 'utf-16le':
  27275. return utf16leSlice(this, start, end)
  27276. default:
  27277. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27278. encoding = (encoding + '').toLowerCase();
  27279. loweredCase = true;
  27280. }
  27281. }
  27282. }
  27283. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  27284. // Buffer instances.
  27285. Buffer$1.prototype._isBuffer = true;
  27286. function swap (b, n, m) {
  27287. var i = b[n];
  27288. b[n] = b[m];
  27289. b[m] = i;
  27290. }
  27291. Buffer$1.prototype.swap16 = function swap16 () {
  27292. var len = this.length;
  27293. if (len % 2 !== 0) {
  27294. throw new RangeError('Buffer size must be a multiple of 16-bits')
  27295. }
  27296. for (var i = 0; i < len; i += 2) {
  27297. swap(this, i, i + 1);
  27298. }
  27299. return this
  27300. };
  27301. Buffer$1.prototype.swap32 = function swap32 () {
  27302. var len = this.length;
  27303. if (len % 4 !== 0) {
  27304. throw new RangeError('Buffer size must be a multiple of 32-bits')
  27305. }
  27306. for (var i = 0; i < len; i += 4) {
  27307. swap(this, i, i + 3);
  27308. swap(this, i + 1, i + 2);
  27309. }
  27310. return this
  27311. };
  27312. Buffer$1.prototype.swap64 = function swap64 () {
  27313. var len = this.length;
  27314. if (len % 8 !== 0) {
  27315. throw new RangeError('Buffer size must be a multiple of 64-bits')
  27316. }
  27317. for (var i = 0; i < len; i += 8) {
  27318. swap(this, i, i + 7);
  27319. swap(this, i + 1, i + 6);
  27320. swap(this, i + 2, i + 5);
  27321. swap(this, i + 3, i + 4);
  27322. }
  27323. return this
  27324. };
  27325. Buffer$1.prototype.toString = function toString () {
  27326. var length = this.length | 0;
  27327. if (length === 0) return ''
  27328. if (arguments.length === 0) return utf8Slice(this, 0, length)
  27329. return slowToString.apply(this, arguments)
  27330. };
  27331. Buffer$1.prototype.equals = function equals (b) {
  27332. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  27333. if (this === b) return true
  27334. return Buffer$1.compare(this, b) === 0
  27335. };
  27336. Buffer$1.prototype.inspect = function inspect () {
  27337. var str = '';
  27338. var max = INSPECT_MAX_BYTES;
  27339. if (this.length > 0) {
  27340. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  27341. if (this.length > max) str += ' ... ';
  27342. }
  27343. return '<Buffer ' + str + '>'
  27344. };
  27345. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  27346. if (!internalIsBuffer(target)) {
  27347. throw new TypeError('Argument must be a Buffer')
  27348. }
  27349. if (start === undefined) {
  27350. start = 0;
  27351. }
  27352. if (end === undefined) {
  27353. end = target ? target.length : 0;
  27354. }
  27355. if (thisStart === undefined) {
  27356. thisStart = 0;
  27357. }
  27358. if (thisEnd === undefined) {
  27359. thisEnd = this.length;
  27360. }
  27361. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  27362. throw new RangeError('out of range index')
  27363. }
  27364. if (thisStart >= thisEnd && start >= end) {
  27365. return 0
  27366. }
  27367. if (thisStart >= thisEnd) {
  27368. return -1
  27369. }
  27370. if (start >= end) {
  27371. return 1
  27372. }
  27373. start >>>= 0;
  27374. end >>>= 0;
  27375. thisStart >>>= 0;
  27376. thisEnd >>>= 0;
  27377. if (this === target) return 0
  27378. var x = thisEnd - thisStart;
  27379. var y = end - start;
  27380. var len = Math.min(x, y);
  27381. var thisCopy = this.slice(thisStart, thisEnd);
  27382. var targetCopy = target.slice(start, end);
  27383. for (var i = 0; i < len; ++i) {
  27384. if (thisCopy[i] !== targetCopy[i]) {
  27385. x = thisCopy[i];
  27386. y = targetCopy[i];
  27387. break
  27388. }
  27389. }
  27390. if (x < y) return -1
  27391. if (y < x) return 1
  27392. return 0
  27393. };
  27394. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  27395. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  27396. //
  27397. // Arguments:
  27398. // - buffer - a Buffer to search
  27399. // - val - a string, Buffer, or number
  27400. // - byteOffset - an index into `buffer`; will be clamped to an int32
  27401. // - encoding - an optional encoding, relevant is val is a string
  27402. // - dir - true for indexOf, false for lastIndexOf
  27403. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  27404. // Empty buffer means no match
  27405. if (buffer.length === 0) return -1
  27406. // Normalize byteOffset
  27407. if (typeof byteOffset === 'string') {
  27408. encoding = byteOffset;
  27409. byteOffset = 0;
  27410. } else if (byteOffset > 0x7fffffff) {
  27411. byteOffset = 0x7fffffff;
  27412. } else if (byteOffset < -0x80000000) {
  27413. byteOffset = -0x80000000;
  27414. }
  27415. byteOffset = +byteOffset; // Coerce to Number.
  27416. if (isNaN(byteOffset)) {
  27417. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  27418. byteOffset = dir ? 0 : (buffer.length - 1);
  27419. }
  27420. // Normalize byteOffset: negative offsets start from the end of the buffer
  27421. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  27422. if (byteOffset >= buffer.length) {
  27423. if (dir) return -1
  27424. else byteOffset = buffer.length - 1;
  27425. } else if (byteOffset < 0) {
  27426. if (dir) byteOffset = 0;
  27427. else return -1
  27428. }
  27429. // Normalize val
  27430. if (typeof val === 'string') {
  27431. val = Buffer$1.from(val, encoding);
  27432. }
  27433. // Finally, search either indexOf (if dir is true) or lastIndexOf
  27434. if (internalIsBuffer(val)) {
  27435. // Special case: looking for empty string/buffer always fails
  27436. if (val.length === 0) {
  27437. return -1
  27438. }
  27439. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  27440. } else if (typeof val === 'number') {
  27441. val = val & 0xFF; // Search for a byte value [0-255]
  27442. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  27443. typeof Uint8Array.prototype.indexOf === 'function') {
  27444. if (dir) {
  27445. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  27446. } else {
  27447. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  27448. }
  27449. }
  27450. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  27451. }
  27452. throw new TypeError('val must be string, number or Buffer')
  27453. }
  27454. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  27455. var indexSize = 1;
  27456. var arrLength = arr.length;
  27457. var valLength = val.length;
  27458. if (encoding !== undefined) {
  27459. encoding = String(encoding).toLowerCase();
  27460. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  27461. encoding === 'utf16le' || encoding === 'utf-16le') {
  27462. if (arr.length < 2 || val.length < 2) {
  27463. return -1
  27464. }
  27465. indexSize = 2;
  27466. arrLength /= 2;
  27467. valLength /= 2;
  27468. byteOffset /= 2;
  27469. }
  27470. }
  27471. function read (buf, i) {
  27472. if (indexSize === 1) {
  27473. return buf[i]
  27474. } else {
  27475. return buf.readUInt16BE(i * indexSize)
  27476. }
  27477. }
  27478. var i;
  27479. if (dir) {
  27480. var foundIndex = -1;
  27481. for (i = byteOffset; i < arrLength; i++) {
  27482. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  27483. if (foundIndex === -1) foundIndex = i;
  27484. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  27485. } else {
  27486. if (foundIndex !== -1) i -= i - foundIndex;
  27487. foundIndex = -1;
  27488. }
  27489. }
  27490. } else {
  27491. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  27492. for (i = byteOffset; i >= 0; i--) {
  27493. var found = true;
  27494. for (var j = 0; j < valLength; j++) {
  27495. if (read(arr, i + j) !== read(val, j)) {
  27496. found = false;
  27497. break
  27498. }
  27499. }
  27500. if (found) return i
  27501. }
  27502. }
  27503. return -1
  27504. }
  27505. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  27506. return this.indexOf(val, byteOffset, encoding) !== -1
  27507. };
  27508. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  27509. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  27510. };
  27511. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  27512. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  27513. };
  27514. function hexWrite (buf, string, offset, length) {
  27515. offset = Number(offset) || 0;
  27516. var remaining = buf.length - offset;
  27517. if (!length) {
  27518. length = remaining;
  27519. } else {
  27520. length = Number(length);
  27521. if (length > remaining) {
  27522. length = remaining;
  27523. }
  27524. }
  27525. // must be an even number of digits
  27526. var strLen = string.length;
  27527. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  27528. if (length > strLen / 2) {
  27529. length = strLen / 2;
  27530. }
  27531. for (var i = 0; i < length; ++i) {
  27532. var parsed = parseInt(string.substr(i * 2, 2), 16);
  27533. if (isNaN(parsed)) return i
  27534. buf[offset + i] = parsed;
  27535. }
  27536. return i
  27537. }
  27538. function utf8Write (buf, string, offset, length) {
  27539. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  27540. }
  27541. function asciiWrite (buf, string, offset, length) {
  27542. return blitBuffer(asciiToBytes(string), buf, offset, length)
  27543. }
  27544. function latin1Write (buf, string, offset, length) {
  27545. return asciiWrite(buf, string, offset, length)
  27546. }
  27547. function base64Write (buf, string, offset, length) {
  27548. return blitBuffer(base64ToBytes(string), buf, offset, length)
  27549. }
  27550. function ucs2Write (buf, string, offset, length) {
  27551. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  27552. }
  27553. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  27554. // Buffer#write(string)
  27555. if (offset === undefined) {
  27556. encoding = 'utf8';
  27557. length = this.length;
  27558. offset = 0;
  27559. // Buffer#write(string, encoding)
  27560. } else if (length === undefined && typeof offset === 'string') {
  27561. encoding = offset;
  27562. length = this.length;
  27563. offset = 0;
  27564. // Buffer#write(string, offset[, length][, encoding])
  27565. } else if (isFinite(offset)) {
  27566. offset = offset | 0;
  27567. if (isFinite(length)) {
  27568. length = length | 0;
  27569. if (encoding === undefined) encoding = 'utf8';
  27570. } else {
  27571. encoding = length;
  27572. length = undefined;
  27573. }
  27574. // legacy write(string, encoding, offset, length) - remove in v0.13
  27575. } else {
  27576. throw new Error(
  27577. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  27578. )
  27579. }
  27580. var remaining = this.length - offset;
  27581. if (length === undefined || length > remaining) length = remaining;
  27582. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  27583. throw new RangeError('Attempt to write outside buffer bounds')
  27584. }
  27585. if (!encoding) encoding = 'utf8';
  27586. var loweredCase = false;
  27587. for (;;) {
  27588. switch (encoding) {
  27589. case 'hex':
  27590. return hexWrite(this, string, offset, length)
  27591. case 'utf8':
  27592. case 'utf-8':
  27593. return utf8Write(this, string, offset, length)
  27594. case 'ascii':
  27595. return asciiWrite(this, string, offset, length)
  27596. case 'latin1':
  27597. case 'binary':
  27598. return latin1Write(this, string, offset, length)
  27599. case 'base64':
  27600. // Warning: maxLength not taken into account in base64Write
  27601. return base64Write(this, string, offset, length)
  27602. case 'ucs2':
  27603. case 'ucs-2':
  27604. case 'utf16le':
  27605. case 'utf-16le':
  27606. return ucs2Write(this, string, offset, length)
  27607. default:
  27608. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27609. encoding = ('' + encoding).toLowerCase();
  27610. loweredCase = true;
  27611. }
  27612. }
  27613. };
  27614. Buffer$1.prototype.toJSON = function toJSON () {
  27615. return {
  27616. type: 'Buffer',
  27617. data: Array.prototype.slice.call(this._arr || this, 0)
  27618. }
  27619. };
  27620. function base64Slice (buf, start, end) {
  27621. if (start === 0 && end === buf.length) {
  27622. return fromByteArray(buf)
  27623. } else {
  27624. return fromByteArray(buf.slice(start, end))
  27625. }
  27626. }
  27627. function utf8Slice (buf, start, end) {
  27628. end = Math.min(buf.length, end);
  27629. var res = [];
  27630. var i = start;
  27631. while (i < end) {
  27632. var firstByte = buf[i];
  27633. var codePoint = null;
  27634. var bytesPerSequence = (firstByte > 0xEF) ? 4
  27635. : (firstByte > 0xDF) ? 3
  27636. : (firstByte > 0xBF) ? 2
  27637. : 1;
  27638. if (i + bytesPerSequence <= end) {
  27639. var secondByte, thirdByte, fourthByte, tempCodePoint;
  27640. switch (bytesPerSequence) {
  27641. case 1:
  27642. if (firstByte < 0x80) {
  27643. codePoint = firstByte;
  27644. }
  27645. break
  27646. case 2:
  27647. secondByte = buf[i + 1];
  27648. if ((secondByte & 0xC0) === 0x80) {
  27649. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  27650. if (tempCodePoint > 0x7F) {
  27651. codePoint = tempCodePoint;
  27652. }
  27653. }
  27654. break
  27655. case 3:
  27656. secondByte = buf[i + 1];
  27657. thirdByte = buf[i + 2];
  27658. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  27659. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  27660. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  27661. codePoint = tempCodePoint;
  27662. }
  27663. }
  27664. break
  27665. case 4:
  27666. secondByte = buf[i + 1];
  27667. thirdByte = buf[i + 2];
  27668. fourthByte = buf[i + 3];
  27669. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  27670. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  27671. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  27672. codePoint = tempCodePoint;
  27673. }
  27674. }
  27675. }
  27676. }
  27677. if (codePoint === null) {
  27678. // we did not generate a valid codePoint so insert a
  27679. // replacement char (U+FFFD) and advance only 1 byte
  27680. codePoint = 0xFFFD;
  27681. bytesPerSequence = 1;
  27682. } else if (codePoint > 0xFFFF) {
  27683. // encode to utf16 (surrogate pair dance)
  27684. codePoint -= 0x10000;
  27685. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  27686. codePoint = 0xDC00 | codePoint & 0x3FF;
  27687. }
  27688. res.push(codePoint);
  27689. i += bytesPerSequence;
  27690. }
  27691. return decodeCodePointsArray(res)
  27692. }
  27693. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  27694. // the lowest limit is Chrome, with 0x10000 args.
  27695. // We go 1 magnitude less, for safety
  27696. var MAX_ARGUMENTS_LENGTH = 0x1000;
  27697. function decodeCodePointsArray (codePoints) {
  27698. var len = codePoints.length;
  27699. if (len <= MAX_ARGUMENTS_LENGTH) {
  27700. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  27701. }
  27702. // Decode in chunks to avoid "call stack size exceeded".
  27703. var res = '';
  27704. var i = 0;
  27705. while (i < len) {
  27706. res += String.fromCharCode.apply(
  27707. String,
  27708. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  27709. );
  27710. }
  27711. return res
  27712. }
  27713. function asciiSlice (buf, start, end) {
  27714. var ret = '';
  27715. end = Math.min(buf.length, end);
  27716. for (var i = start; i < end; ++i) {
  27717. ret += String.fromCharCode(buf[i] & 0x7F);
  27718. }
  27719. return ret
  27720. }
  27721. function latin1Slice (buf, start, end) {
  27722. var ret = '';
  27723. end = Math.min(buf.length, end);
  27724. for (var i = start; i < end; ++i) {
  27725. ret += String.fromCharCode(buf[i]);
  27726. }
  27727. return ret
  27728. }
  27729. function hexSlice (buf, start, end) {
  27730. var len = buf.length;
  27731. if (!start || start < 0) start = 0;
  27732. if (!end || end < 0 || end > len) end = len;
  27733. var out = '';
  27734. for (var i = start; i < end; ++i) {
  27735. out += toHex(buf[i]);
  27736. }
  27737. return out
  27738. }
  27739. function utf16leSlice (buf, start, end) {
  27740. var bytes = buf.slice(start, end);
  27741. var res = '';
  27742. for (var i = 0; i < bytes.length; i += 2) {
  27743. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  27744. }
  27745. return res
  27746. }
  27747. Buffer$1.prototype.slice = function slice (start, end) {
  27748. var len = this.length;
  27749. start = ~~start;
  27750. end = end === undefined ? len : ~~end;
  27751. if (start < 0) {
  27752. start += len;
  27753. if (start < 0) start = 0;
  27754. } else if (start > len) {
  27755. start = len;
  27756. }
  27757. if (end < 0) {
  27758. end += len;
  27759. if (end < 0) end = 0;
  27760. } else if (end > len) {
  27761. end = len;
  27762. }
  27763. if (end < start) end = start;
  27764. var newBuf;
  27765. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27766. newBuf = this.subarray(start, end);
  27767. newBuf.__proto__ = Buffer$1.prototype;
  27768. } else {
  27769. var sliceLen = end - start;
  27770. newBuf = new Buffer$1(sliceLen, undefined);
  27771. for (var i = 0; i < sliceLen; ++i) {
  27772. newBuf[i] = this[i + start];
  27773. }
  27774. }
  27775. return newBuf
  27776. };
  27777. /*
  27778. * Need to make sure that buffer isn't trying to write out of bounds.
  27779. */
  27780. function checkOffset (offset, ext, length) {
  27781. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  27782. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  27783. }
  27784. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  27785. offset = offset | 0;
  27786. byteLength = byteLength | 0;
  27787. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27788. var val = this[offset];
  27789. var mul = 1;
  27790. var i = 0;
  27791. while (++i < byteLength && (mul *= 0x100)) {
  27792. val += this[offset + i] * mul;
  27793. }
  27794. return val
  27795. };
  27796. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  27797. offset = offset | 0;
  27798. byteLength = byteLength | 0;
  27799. if (!noAssert) {
  27800. checkOffset(offset, byteLength, this.length);
  27801. }
  27802. var val = this[offset + --byteLength];
  27803. var mul = 1;
  27804. while (byteLength > 0 && (mul *= 0x100)) {
  27805. val += this[offset + --byteLength] * mul;
  27806. }
  27807. return val
  27808. };
  27809. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  27810. if (!noAssert) checkOffset(offset, 1, this.length);
  27811. return this[offset]
  27812. };
  27813. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  27814. if (!noAssert) checkOffset(offset, 2, this.length);
  27815. return this[offset] | (this[offset + 1] << 8)
  27816. };
  27817. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  27818. if (!noAssert) checkOffset(offset, 2, this.length);
  27819. return (this[offset] << 8) | this[offset + 1]
  27820. };
  27821. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  27822. if (!noAssert) checkOffset(offset, 4, this.length);
  27823. return ((this[offset]) |
  27824. (this[offset + 1] << 8) |
  27825. (this[offset + 2] << 16)) +
  27826. (this[offset + 3] * 0x1000000)
  27827. };
  27828. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  27829. if (!noAssert) checkOffset(offset, 4, this.length);
  27830. return (this[offset] * 0x1000000) +
  27831. ((this[offset + 1] << 16) |
  27832. (this[offset + 2] << 8) |
  27833. this[offset + 3])
  27834. };
  27835. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  27836. offset = offset | 0;
  27837. byteLength = byteLength | 0;
  27838. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27839. var val = this[offset];
  27840. var mul = 1;
  27841. var i = 0;
  27842. while (++i < byteLength && (mul *= 0x100)) {
  27843. val += this[offset + i] * mul;
  27844. }
  27845. mul *= 0x80;
  27846. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27847. return val
  27848. };
  27849. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  27850. offset = offset | 0;
  27851. byteLength = byteLength | 0;
  27852. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27853. var i = byteLength;
  27854. var mul = 1;
  27855. var val = this[offset + --i];
  27856. while (i > 0 && (mul *= 0x100)) {
  27857. val += this[offset + --i] * mul;
  27858. }
  27859. mul *= 0x80;
  27860. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27861. return val
  27862. };
  27863. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  27864. if (!noAssert) checkOffset(offset, 1, this.length);
  27865. if (!(this[offset] & 0x80)) return (this[offset])
  27866. return ((0xff - this[offset] + 1) * -1)
  27867. };
  27868. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  27869. if (!noAssert) checkOffset(offset, 2, this.length);
  27870. var val = this[offset] | (this[offset + 1] << 8);
  27871. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27872. };
  27873. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  27874. if (!noAssert) checkOffset(offset, 2, this.length);
  27875. var val = this[offset + 1] | (this[offset] << 8);
  27876. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27877. };
  27878. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  27879. if (!noAssert) checkOffset(offset, 4, this.length);
  27880. return (this[offset]) |
  27881. (this[offset + 1] << 8) |
  27882. (this[offset + 2] << 16) |
  27883. (this[offset + 3] << 24)
  27884. };
  27885. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  27886. if (!noAssert) checkOffset(offset, 4, this.length);
  27887. return (this[offset] << 24) |
  27888. (this[offset + 1] << 16) |
  27889. (this[offset + 2] << 8) |
  27890. (this[offset + 3])
  27891. };
  27892. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  27893. if (!noAssert) checkOffset(offset, 4, this.length);
  27894. return read(this, offset, true, 23, 4)
  27895. };
  27896. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  27897. if (!noAssert) checkOffset(offset, 4, this.length);
  27898. return read(this, offset, false, 23, 4)
  27899. };
  27900. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  27901. if (!noAssert) checkOffset(offset, 8, this.length);
  27902. return read(this, offset, true, 52, 8)
  27903. };
  27904. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  27905. if (!noAssert) checkOffset(offset, 8, this.length);
  27906. return read(this, offset, false, 52, 8)
  27907. };
  27908. function checkInt (buf, value, offset, ext, max, min) {
  27909. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  27910. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  27911. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27912. }
  27913. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  27914. value = +value;
  27915. offset = offset | 0;
  27916. byteLength = byteLength | 0;
  27917. if (!noAssert) {
  27918. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27919. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27920. }
  27921. var mul = 1;
  27922. var i = 0;
  27923. this[offset] = value & 0xFF;
  27924. while (++i < byteLength && (mul *= 0x100)) {
  27925. this[offset + i] = (value / mul) & 0xFF;
  27926. }
  27927. return offset + byteLength
  27928. };
  27929. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  27930. value = +value;
  27931. offset = offset | 0;
  27932. byteLength = byteLength | 0;
  27933. if (!noAssert) {
  27934. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27935. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27936. }
  27937. var i = byteLength - 1;
  27938. var mul = 1;
  27939. this[offset + i] = value & 0xFF;
  27940. while (--i >= 0 && (mul *= 0x100)) {
  27941. this[offset + i] = (value / mul) & 0xFF;
  27942. }
  27943. return offset + byteLength
  27944. };
  27945. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  27946. value = +value;
  27947. offset = offset | 0;
  27948. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  27949. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27950. this[offset] = (value & 0xff);
  27951. return offset + 1
  27952. };
  27953. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  27954. if (value < 0) value = 0xffff + value + 1;
  27955. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  27956. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  27957. (littleEndian ? i : 1 - i) * 8;
  27958. }
  27959. }
  27960. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  27961. value = +value;
  27962. offset = offset | 0;
  27963. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27964. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27965. this[offset] = (value & 0xff);
  27966. this[offset + 1] = (value >>> 8);
  27967. } else {
  27968. objectWriteUInt16(this, value, offset, true);
  27969. }
  27970. return offset + 2
  27971. };
  27972. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  27973. value = +value;
  27974. offset = offset | 0;
  27975. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27976. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27977. this[offset] = (value >>> 8);
  27978. this[offset + 1] = (value & 0xff);
  27979. } else {
  27980. objectWriteUInt16(this, value, offset, false);
  27981. }
  27982. return offset + 2
  27983. };
  27984. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  27985. if (value < 0) value = 0xffffffff + value + 1;
  27986. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  27987. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  27988. }
  27989. }
  27990. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  27991. value = +value;
  27992. offset = offset | 0;
  27993. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27994. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27995. this[offset + 3] = (value >>> 24);
  27996. this[offset + 2] = (value >>> 16);
  27997. this[offset + 1] = (value >>> 8);
  27998. this[offset] = (value & 0xff);
  27999. } else {
  28000. objectWriteUInt32(this, value, offset, true);
  28001. }
  28002. return offset + 4
  28003. };
  28004. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  28005. value = +value;
  28006. offset = offset | 0;
  28007. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  28008. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28009. this[offset] = (value >>> 24);
  28010. this[offset + 1] = (value >>> 16);
  28011. this[offset + 2] = (value >>> 8);
  28012. this[offset + 3] = (value & 0xff);
  28013. } else {
  28014. objectWriteUInt32(this, value, offset, false);
  28015. }
  28016. return offset + 4
  28017. };
  28018. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  28019. value = +value;
  28020. offset = offset | 0;
  28021. if (!noAssert) {
  28022. var limit = Math.pow(2, 8 * byteLength - 1);
  28023. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28024. }
  28025. var i = 0;
  28026. var mul = 1;
  28027. var sub = 0;
  28028. this[offset] = value & 0xFF;
  28029. while (++i < byteLength && (mul *= 0x100)) {
  28030. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  28031. sub = 1;
  28032. }
  28033. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28034. }
  28035. return offset + byteLength
  28036. };
  28037. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  28038. value = +value;
  28039. offset = offset | 0;
  28040. if (!noAssert) {
  28041. var limit = Math.pow(2, 8 * byteLength - 1);
  28042. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28043. }
  28044. var i = byteLength - 1;
  28045. var mul = 1;
  28046. var sub = 0;
  28047. this[offset + i] = value & 0xFF;
  28048. while (--i >= 0 && (mul *= 0x100)) {
  28049. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  28050. sub = 1;
  28051. }
  28052. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28053. }
  28054. return offset + byteLength
  28055. };
  28056. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  28057. value = +value;
  28058. offset = offset | 0;
  28059. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  28060. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  28061. if (value < 0) value = 0xff + value + 1;
  28062. this[offset] = (value & 0xff);
  28063. return offset + 1
  28064. };
  28065. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  28066. value = +value;
  28067. offset = offset | 0;
  28068. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  28069. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28070. this[offset] = (value & 0xff);
  28071. this[offset + 1] = (value >>> 8);
  28072. } else {
  28073. objectWriteUInt16(this, value, offset, true);
  28074. }
  28075. return offset + 2
  28076. };
  28077. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  28078. value = +value;
  28079. offset = offset | 0;
  28080. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  28081. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28082. this[offset] = (value >>> 8);
  28083. this[offset + 1] = (value & 0xff);
  28084. } else {
  28085. objectWriteUInt16(this, value, offset, false);
  28086. }
  28087. return offset + 2
  28088. };
  28089. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  28090. value = +value;
  28091. offset = offset | 0;
  28092. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  28093. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28094. this[offset] = (value & 0xff);
  28095. this[offset + 1] = (value >>> 8);
  28096. this[offset + 2] = (value >>> 16);
  28097. this[offset + 3] = (value >>> 24);
  28098. } else {
  28099. objectWriteUInt32(this, value, offset, true);
  28100. }
  28101. return offset + 4
  28102. };
  28103. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  28104. value = +value;
  28105. offset = offset | 0;
  28106. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  28107. if (value < 0) value = 0xffffffff + value + 1;
  28108. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28109. this[offset] = (value >>> 24);
  28110. this[offset + 1] = (value >>> 16);
  28111. this[offset + 2] = (value >>> 8);
  28112. this[offset + 3] = (value & 0xff);
  28113. } else {
  28114. objectWriteUInt32(this, value, offset, false);
  28115. }
  28116. return offset + 4
  28117. };
  28118. function checkIEEE754 (buf, value, offset, ext, max, min) {
  28119. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  28120. if (offset < 0) throw new RangeError('Index out of range')
  28121. }
  28122. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  28123. if (!noAssert) {
  28124. checkIEEE754(buf, value, offset, 4);
  28125. }
  28126. write(buf, value, offset, littleEndian, 23, 4);
  28127. return offset + 4
  28128. }
  28129. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  28130. return writeFloat(this, value, offset, true, noAssert)
  28131. };
  28132. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  28133. return writeFloat(this, value, offset, false, noAssert)
  28134. };
  28135. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  28136. if (!noAssert) {
  28137. checkIEEE754(buf, value, offset, 8);
  28138. }
  28139. write(buf, value, offset, littleEndian, 52, 8);
  28140. return offset + 8
  28141. }
  28142. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  28143. return writeDouble(this, value, offset, true, noAssert)
  28144. };
  28145. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  28146. return writeDouble(this, value, offset, false, noAssert)
  28147. };
  28148. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  28149. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  28150. if (!start) start = 0;
  28151. if (!end && end !== 0) end = this.length;
  28152. if (targetStart >= target.length) targetStart = target.length;
  28153. if (!targetStart) targetStart = 0;
  28154. if (end > 0 && end < start) end = start;
  28155. // Copy 0 bytes; we're done
  28156. if (end === start) return 0
  28157. if (target.length === 0 || this.length === 0) return 0
  28158. // Fatal error conditions
  28159. if (targetStart < 0) {
  28160. throw new RangeError('targetStart out of bounds')
  28161. }
  28162. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  28163. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  28164. // Are we oob?
  28165. if (end > this.length) end = this.length;
  28166. if (target.length - targetStart < end - start) {
  28167. end = target.length - targetStart + start;
  28168. }
  28169. var len = end - start;
  28170. var i;
  28171. if (this === target && start < targetStart && targetStart < end) {
  28172. // descending copy from end
  28173. for (i = len - 1; i >= 0; --i) {
  28174. target[i + targetStart] = this[i + start];
  28175. }
  28176. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  28177. // ascending copy from start
  28178. for (i = 0; i < len; ++i) {
  28179. target[i + targetStart] = this[i + start];
  28180. }
  28181. } else {
  28182. Uint8Array.prototype.set.call(
  28183. target,
  28184. this.subarray(start, start + len),
  28185. targetStart
  28186. );
  28187. }
  28188. return len
  28189. };
  28190. // Usage:
  28191. // buffer.fill(number[, offset[, end]])
  28192. // buffer.fill(buffer[, offset[, end]])
  28193. // buffer.fill(string[, offset[, end]][, encoding])
  28194. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  28195. // Handle string cases:
  28196. if (typeof val === 'string') {
  28197. if (typeof start === 'string') {
  28198. encoding = start;
  28199. start = 0;
  28200. end = this.length;
  28201. } else if (typeof end === 'string') {
  28202. encoding = end;
  28203. end = this.length;
  28204. }
  28205. if (val.length === 1) {
  28206. var code = val.charCodeAt(0);
  28207. if (code < 256) {
  28208. val = code;
  28209. }
  28210. }
  28211. if (encoding !== undefined && typeof encoding !== 'string') {
  28212. throw new TypeError('encoding must be a string')
  28213. }
  28214. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  28215. throw new TypeError('Unknown encoding: ' + encoding)
  28216. }
  28217. } else if (typeof val === 'number') {
  28218. val = val & 255;
  28219. }
  28220. // Invalid ranges are not set to a default, so can range check early.
  28221. if (start < 0 || this.length < start || this.length < end) {
  28222. throw new RangeError('Out of range index')
  28223. }
  28224. if (end <= start) {
  28225. return this
  28226. }
  28227. start = start >>> 0;
  28228. end = end === undefined ? this.length : end >>> 0;
  28229. if (!val) val = 0;
  28230. var i;
  28231. if (typeof val === 'number') {
  28232. for (i = start; i < end; ++i) {
  28233. this[i] = val;
  28234. }
  28235. } else {
  28236. var bytes = internalIsBuffer(val)
  28237. ? val
  28238. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  28239. var len = bytes.length;
  28240. for (i = 0; i < end - start; ++i) {
  28241. this[i + start] = bytes[i % len];
  28242. }
  28243. }
  28244. return this
  28245. };
  28246. // HELPER FUNCTIONS
  28247. // ================
  28248. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  28249. function base64clean (str) {
  28250. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  28251. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  28252. // Node converts strings with length < 2 to ''
  28253. if (str.length < 2) return ''
  28254. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  28255. while (str.length % 4 !== 0) {
  28256. str = str + '=';
  28257. }
  28258. return str
  28259. }
  28260. function stringtrim (str) {
  28261. if (str.trim) return str.trim()
  28262. return str.replace(/^\s+|\s+$/g, '')
  28263. }
  28264. function toHex (n) {
  28265. if (n < 16) return '0' + n.toString(16)
  28266. return n.toString(16)
  28267. }
  28268. function utf8ToBytes (string, units) {
  28269. units = units || Infinity;
  28270. var codePoint;
  28271. var length = string.length;
  28272. var leadSurrogate = null;
  28273. var bytes = [];
  28274. for (var i = 0; i < length; ++i) {
  28275. codePoint = string.charCodeAt(i);
  28276. // is surrogate component
  28277. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  28278. // last char was a lead
  28279. if (!leadSurrogate) {
  28280. // no lead yet
  28281. if (codePoint > 0xDBFF) {
  28282. // unexpected trail
  28283. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28284. continue
  28285. } else if (i + 1 === length) {
  28286. // unpaired lead
  28287. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28288. continue
  28289. }
  28290. // valid lead
  28291. leadSurrogate = codePoint;
  28292. continue
  28293. }
  28294. // 2 leads in a row
  28295. if (codePoint < 0xDC00) {
  28296. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28297. leadSurrogate = codePoint;
  28298. continue
  28299. }
  28300. // valid surrogate pair
  28301. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  28302. } else if (leadSurrogate) {
  28303. // valid bmp char, but last char was a lead
  28304. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28305. }
  28306. leadSurrogate = null;
  28307. // encode utf8
  28308. if (codePoint < 0x80) {
  28309. if ((units -= 1) < 0) break
  28310. bytes.push(codePoint);
  28311. } else if (codePoint < 0x800) {
  28312. if ((units -= 2) < 0) break
  28313. bytes.push(
  28314. codePoint >> 0x6 | 0xC0,
  28315. codePoint & 0x3F | 0x80
  28316. );
  28317. } else if (codePoint < 0x10000) {
  28318. if ((units -= 3) < 0) break
  28319. bytes.push(
  28320. codePoint >> 0xC | 0xE0,
  28321. codePoint >> 0x6 & 0x3F | 0x80,
  28322. codePoint & 0x3F | 0x80
  28323. );
  28324. } else if (codePoint < 0x110000) {
  28325. if ((units -= 4) < 0) break
  28326. bytes.push(
  28327. codePoint >> 0x12 | 0xF0,
  28328. codePoint >> 0xC & 0x3F | 0x80,
  28329. codePoint >> 0x6 & 0x3F | 0x80,
  28330. codePoint & 0x3F | 0x80
  28331. );
  28332. } else {
  28333. throw new Error('Invalid code point')
  28334. }
  28335. }
  28336. return bytes
  28337. }
  28338. function asciiToBytes (str) {
  28339. var byteArray = [];
  28340. for (var i = 0; i < str.length; ++i) {
  28341. // Node's code seems to be doing this and not & 0x7F..
  28342. byteArray.push(str.charCodeAt(i) & 0xFF);
  28343. }
  28344. return byteArray
  28345. }
  28346. function utf16leToBytes (str, units) {
  28347. var c, hi, lo;
  28348. var byteArray = [];
  28349. for (var i = 0; i < str.length; ++i) {
  28350. if ((units -= 2) < 0) break
  28351. c = str.charCodeAt(i);
  28352. hi = c >> 8;
  28353. lo = c % 256;
  28354. byteArray.push(lo);
  28355. byteArray.push(hi);
  28356. }
  28357. return byteArray
  28358. }
  28359. function base64ToBytes (str) {
  28360. return toByteArray(base64clean(str))
  28361. }
  28362. function blitBuffer (src, dst, offset, length) {
  28363. for (var i = 0; i < length; ++i) {
  28364. if ((i + offset >= dst.length) || (i >= src.length)) break
  28365. dst[i + offset] = src[i];
  28366. }
  28367. return i
  28368. }
  28369. function isnan (val) {
  28370. return val !== val // eslint-disable-line no-self-compare
  28371. }
  28372. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  28373. // The _isBuffer check is for Safari 5-7 support, because it's missing
  28374. // Object.prototype.constructor. Remove this eventually
  28375. function isBuffer$1(obj) {
  28376. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  28377. }
  28378. function isFastBuffer (obj) {
  28379. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  28380. }
  28381. // For Node v0.10 support. Remove this eventually.
  28382. function isSlowBuffer (obj) {
  28383. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  28384. }
  28385. var inherits;
  28386. if (typeof Object.create === 'function'){
  28387. inherits = function inherits(ctor, superCtor) {
  28388. // implementation from standard node.js 'util' module
  28389. ctor.super_ = superCtor;
  28390. ctor.prototype = Object.create(superCtor.prototype, {
  28391. constructor: {
  28392. value: ctor,
  28393. enumerable: false,
  28394. writable: true,
  28395. configurable: true
  28396. }
  28397. });
  28398. };
  28399. } else {
  28400. inherits = function inherits(ctor, superCtor) {
  28401. ctor.super_ = superCtor;
  28402. var TempCtor = function () {};
  28403. TempCtor.prototype = superCtor.prototype;
  28404. ctor.prototype = new TempCtor();
  28405. ctor.prototype.constructor = ctor;
  28406. };
  28407. }
  28408. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  28409. function getOwnPropertyDescriptors(obj) {
  28410. var keys = Object.keys(obj);
  28411. var descriptors = {};
  28412. for (var i = 0; i < keys.length; i++) {
  28413. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  28414. }
  28415. return descriptors;
  28416. };
  28417. var formatRegExp = /%[sdj%]/g;
  28418. function format$1(f) {
  28419. if (!isString(f)) {
  28420. var objects = [];
  28421. for (var i = 0; i < arguments.length; i++) {
  28422. objects.push(inspect(arguments[i]));
  28423. }
  28424. return objects.join(' ');
  28425. }
  28426. var i = 1;
  28427. var args = arguments;
  28428. var len = args.length;
  28429. var str = String(f).replace(formatRegExp, function(x) {
  28430. if (x === '%%') return '%';
  28431. if (i >= len) return x;
  28432. switch (x) {
  28433. case '%s': return String(args[i++]);
  28434. case '%d': return Number(args[i++]);
  28435. case '%j':
  28436. try {
  28437. return JSON.stringify(args[i++]);
  28438. } catch (_) {
  28439. return '[Circular]';
  28440. }
  28441. default:
  28442. return x;
  28443. }
  28444. });
  28445. for (var x = args[i]; i < len; x = args[++i]) {
  28446. if (isNull(x) || !isObject$1(x)) {
  28447. str += ' ' + x;
  28448. } else {
  28449. str += ' ' + inspect(x);
  28450. }
  28451. }
  28452. return str;
  28453. }
  28454. // Mark that a method should not be used.
  28455. // Returns a modified function which warns once by default.
  28456. // If --no-deprecation is set, then it is a no-op.
  28457. function deprecate(fn, msg) {
  28458. // Allow for deprecating things in the process of starting up.
  28459. if (isUndefined(global$1.process)) {
  28460. return function() {
  28461. return deprecate(fn, msg).apply(this, arguments);
  28462. };
  28463. }
  28464. if (browser$1.noDeprecation === true) {
  28465. return fn;
  28466. }
  28467. var warned = false;
  28468. function deprecated() {
  28469. if (!warned) {
  28470. if (browser$1.throwDeprecation) {
  28471. throw new Error(msg);
  28472. } else if (browser$1.traceDeprecation) {
  28473. console.trace(msg);
  28474. } else {
  28475. console.error(msg);
  28476. }
  28477. warned = true;
  28478. }
  28479. return fn.apply(this, arguments);
  28480. }
  28481. return deprecated;
  28482. }
  28483. var debugs = {};
  28484. var debugEnviron;
  28485. function debuglog(set) {
  28486. if (isUndefined(debugEnviron))
  28487. debugEnviron = browser$1.env.NODE_DEBUG || '';
  28488. set = set.toUpperCase();
  28489. if (!debugs[set]) {
  28490. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  28491. var pid = 0;
  28492. debugs[set] = function() {
  28493. var msg = format$1.apply(null, arguments);
  28494. console.error('%s %d: %s', set, pid, msg);
  28495. };
  28496. } else {
  28497. debugs[set] = function() {};
  28498. }
  28499. }
  28500. return debugs[set];
  28501. }
  28502. /**
  28503. * Echos the value of a value. Trys to print the value out
  28504. * in the best way possible given the different types.
  28505. *
  28506. * @param {Object} obj The object to print out.
  28507. * @param {Object} opts Optional options object that alters the output.
  28508. */
  28509. /* legacy: obj, showHidden, depth, colors*/
  28510. function inspect(obj, opts) {
  28511. // default options
  28512. var ctx = {
  28513. seen: [],
  28514. stylize: stylizeNoColor
  28515. };
  28516. // legacy...
  28517. if (arguments.length >= 3) ctx.depth = arguments[2];
  28518. if (arguments.length >= 4) ctx.colors = arguments[3];
  28519. if (isBoolean(opts)) {
  28520. // legacy...
  28521. ctx.showHidden = opts;
  28522. } else if (opts) {
  28523. // got an "options" object
  28524. _extend(ctx, opts);
  28525. }
  28526. // set default options
  28527. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  28528. if (isUndefined(ctx.depth)) ctx.depth = 2;
  28529. if (isUndefined(ctx.colors)) ctx.colors = false;
  28530. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  28531. if (ctx.colors) ctx.stylize = stylizeWithColor;
  28532. return formatValue(ctx, obj, ctx.depth);
  28533. }
  28534. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28535. inspect.colors = {
  28536. 'bold' : [1, 22],
  28537. 'italic' : [3, 23],
  28538. 'underline' : [4, 24],
  28539. 'inverse' : [7, 27],
  28540. 'white' : [37, 39],
  28541. 'grey' : [90, 39],
  28542. 'black' : [30, 39],
  28543. 'blue' : [34, 39],
  28544. 'cyan' : [36, 39],
  28545. 'green' : [32, 39],
  28546. 'magenta' : [35, 39],
  28547. 'red' : [31, 39],
  28548. 'yellow' : [33, 39]
  28549. };
  28550. // Don't use 'blue' not visible on cmd.exe
  28551. inspect.styles = {
  28552. 'special': 'cyan',
  28553. 'number': 'yellow',
  28554. 'boolean': 'yellow',
  28555. 'undefined': 'grey',
  28556. 'null': 'bold',
  28557. 'string': 'green',
  28558. 'date': 'magenta',
  28559. // "name": intentionally not styling
  28560. 'regexp': 'red'
  28561. };
  28562. function stylizeWithColor(str, styleType) {
  28563. var style = inspect.styles[styleType];
  28564. if (style) {
  28565. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  28566. '\u001b[' + inspect.colors[style][1] + 'm';
  28567. } else {
  28568. return str;
  28569. }
  28570. }
  28571. function stylizeNoColor(str, styleType) {
  28572. return str;
  28573. }
  28574. function arrayToHash(array) {
  28575. var hash = {};
  28576. array.forEach(function(val, idx) {
  28577. hash[val] = true;
  28578. });
  28579. return hash;
  28580. }
  28581. function formatValue(ctx, value, recurseTimes) {
  28582. // Provide a hook for user-specified inspect functions.
  28583. // Check that value is an object with an inspect function on it
  28584. if (ctx.customInspect &&
  28585. value &&
  28586. isFunction(value.inspect) &&
  28587. // Filter out the util module, it's inspect function is special
  28588. value.inspect !== inspect &&
  28589. // Also filter out any prototype objects using the circular check.
  28590. !(value.constructor && value.constructor.prototype === value)) {
  28591. var ret = value.inspect(recurseTimes, ctx);
  28592. if (!isString(ret)) {
  28593. ret = formatValue(ctx, ret, recurseTimes);
  28594. }
  28595. return ret;
  28596. }
  28597. // Primitive types cannot have properties
  28598. var primitive = formatPrimitive(ctx, value);
  28599. if (primitive) {
  28600. return primitive;
  28601. }
  28602. // Look up the keys of the object.
  28603. var keys = Object.keys(value);
  28604. var visibleKeys = arrayToHash(keys);
  28605. if (ctx.showHidden) {
  28606. keys = Object.getOwnPropertyNames(value);
  28607. }
  28608. // IE doesn't make error fields non-enumerable
  28609. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  28610. if (isError(value)
  28611. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  28612. return formatError(value);
  28613. }
  28614. // Some type of object without properties can be shortcutted.
  28615. if (keys.length === 0) {
  28616. if (isFunction(value)) {
  28617. var name = value.name ? ': ' + value.name : '';
  28618. return ctx.stylize('[Function' + name + ']', 'special');
  28619. }
  28620. if (isRegExp(value)) {
  28621. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28622. }
  28623. if (isDate(value)) {
  28624. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  28625. }
  28626. if (isError(value)) {
  28627. return formatError(value);
  28628. }
  28629. }
  28630. var base = '', array = false, braces = ['{', '}'];
  28631. // Make Array say that they are Array
  28632. if (isArray$1(value)) {
  28633. array = true;
  28634. braces = ['[', ']'];
  28635. }
  28636. // Make functions say that they are functions
  28637. if (isFunction(value)) {
  28638. var n = value.name ? ': ' + value.name : '';
  28639. base = ' [Function' + n + ']';
  28640. }
  28641. // Make RegExps say that they are RegExps
  28642. if (isRegExp(value)) {
  28643. base = ' ' + RegExp.prototype.toString.call(value);
  28644. }
  28645. // Make dates with properties first say the date
  28646. if (isDate(value)) {
  28647. base = ' ' + Date.prototype.toUTCString.call(value);
  28648. }
  28649. // Make error with message first say the error
  28650. if (isError(value)) {
  28651. base = ' ' + formatError(value);
  28652. }
  28653. if (keys.length === 0 && (!array || value.length == 0)) {
  28654. return braces[0] + base + braces[1];
  28655. }
  28656. if (recurseTimes < 0) {
  28657. if (isRegExp(value)) {
  28658. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28659. } else {
  28660. return ctx.stylize('[Object]', 'special');
  28661. }
  28662. }
  28663. ctx.seen.push(value);
  28664. var output;
  28665. if (array) {
  28666. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  28667. } else {
  28668. output = keys.map(function(key) {
  28669. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  28670. });
  28671. }
  28672. ctx.seen.pop();
  28673. return reduceToSingleString(output, base, braces);
  28674. }
  28675. function formatPrimitive(ctx, value) {
  28676. if (isUndefined(value))
  28677. return ctx.stylize('undefined', 'undefined');
  28678. if (isString(value)) {
  28679. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  28680. .replace(/'/g, "\\'")
  28681. .replace(/\\"/g, '"') + '\'';
  28682. return ctx.stylize(simple, 'string');
  28683. }
  28684. if (isNumber(value))
  28685. return ctx.stylize('' + value, 'number');
  28686. if (isBoolean(value))
  28687. return ctx.stylize('' + value, 'boolean');
  28688. // For some reason typeof null is "object", so special case here.
  28689. if (isNull(value))
  28690. return ctx.stylize('null', 'null');
  28691. }
  28692. function formatError(value) {
  28693. return '[' + Error.prototype.toString.call(value) + ']';
  28694. }
  28695. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  28696. var output = [];
  28697. for (var i = 0, l = value.length; i < l; ++i) {
  28698. if (hasOwnProperty$2(value, String(i))) {
  28699. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28700. String(i), true));
  28701. } else {
  28702. output.push('');
  28703. }
  28704. }
  28705. keys.forEach(function(key) {
  28706. if (!key.match(/^\d+$/)) {
  28707. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28708. key, true));
  28709. }
  28710. });
  28711. return output;
  28712. }
  28713. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  28714. var name, str, desc;
  28715. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  28716. if (desc.get) {
  28717. if (desc.set) {
  28718. str = ctx.stylize('[Getter/Setter]', 'special');
  28719. } else {
  28720. str = ctx.stylize('[Getter]', 'special');
  28721. }
  28722. } else {
  28723. if (desc.set) {
  28724. str = ctx.stylize('[Setter]', 'special');
  28725. }
  28726. }
  28727. if (!hasOwnProperty$2(visibleKeys, key)) {
  28728. name = '[' + key + ']';
  28729. }
  28730. if (!str) {
  28731. if (ctx.seen.indexOf(desc.value) < 0) {
  28732. if (isNull(recurseTimes)) {
  28733. str = formatValue(ctx, desc.value, null);
  28734. } else {
  28735. str = formatValue(ctx, desc.value, recurseTimes - 1);
  28736. }
  28737. if (str.indexOf('\n') > -1) {
  28738. if (array) {
  28739. str = str.split('\n').map(function(line) {
  28740. return ' ' + line;
  28741. }).join('\n').substr(2);
  28742. } else {
  28743. str = '\n' + str.split('\n').map(function(line) {
  28744. return ' ' + line;
  28745. }).join('\n');
  28746. }
  28747. }
  28748. } else {
  28749. str = ctx.stylize('[Circular]', 'special');
  28750. }
  28751. }
  28752. if (isUndefined(name)) {
  28753. if (array && key.match(/^\d+$/)) {
  28754. return str;
  28755. }
  28756. name = JSON.stringify('' + key);
  28757. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  28758. name = name.substr(1, name.length - 2);
  28759. name = ctx.stylize(name, 'name');
  28760. } else {
  28761. name = name.replace(/'/g, "\\'")
  28762. .replace(/\\"/g, '"')
  28763. .replace(/(^"|"$)/g, "'");
  28764. name = ctx.stylize(name, 'string');
  28765. }
  28766. }
  28767. return name + ': ' + str;
  28768. }
  28769. function reduceToSingleString(output, base, braces) {
  28770. var length = output.reduce(function(prev, cur) {
  28771. if (cur.indexOf('\n') >= 0) ;
  28772. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  28773. }, 0);
  28774. if (length > 60) {
  28775. return braces[0] +
  28776. (base === '' ? '' : base + '\n ') +
  28777. ' ' +
  28778. output.join(',\n ') +
  28779. ' ' +
  28780. braces[1];
  28781. }
  28782. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  28783. }
  28784. // NOTE: These type checking functions intentionally don't use `instanceof`
  28785. // because it is fragile and can be easily faked with `Object.create()`.
  28786. function isArray$1(ar) {
  28787. return Array.isArray(ar);
  28788. }
  28789. function isBoolean(arg) {
  28790. return typeof arg === 'boolean';
  28791. }
  28792. function isNull(arg) {
  28793. return arg === null;
  28794. }
  28795. function isNullOrUndefined(arg) {
  28796. return arg == null;
  28797. }
  28798. function isNumber(arg) {
  28799. return typeof arg === 'number';
  28800. }
  28801. function isString(arg) {
  28802. return typeof arg === 'string';
  28803. }
  28804. function isSymbol(arg) {
  28805. return typeof arg === 'symbol';
  28806. }
  28807. function isUndefined(arg) {
  28808. return arg === void 0;
  28809. }
  28810. function isRegExp(re) {
  28811. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  28812. }
  28813. function isObject$1(arg) {
  28814. return typeof arg === 'object' && arg !== null;
  28815. }
  28816. function isDate(d) {
  28817. return isObject$1(d) && objectToString(d) === '[object Date]';
  28818. }
  28819. function isError(e) {
  28820. return isObject$1(e) &&
  28821. (objectToString(e) === '[object Error]' || e instanceof Error);
  28822. }
  28823. function isFunction(arg) {
  28824. return typeof arg === 'function';
  28825. }
  28826. function isPrimitive(arg) {
  28827. return arg === null ||
  28828. typeof arg === 'boolean' ||
  28829. typeof arg === 'number' ||
  28830. typeof arg === 'string' ||
  28831. typeof arg === 'symbol' || // ES6 symbol
  28832. typeof arg === 'undefined';
  28833. }
  28834. function isBuffer(maybeBuf) {
  28835. return Buffer$1.isBuffer(maybeBuf);
  28836. }
  28837. function objectToString(o) {
  28838. return Object.prototype.toString.call(o);
  28839. }
  28840. function pad(n) {
  28841. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  28842. }
  28843. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  28844. 'Oct', 'Nov', 'Dec'];
  28845. // 26 Feb 16:19:34
  28846. function timestamp() {
  28847. var d = new Date();
  28848. var time = [pad(d.getHours()),
  28849. pad(d.getMinutes()),
  28850. pad(d.getSeconds())].join(':');
  28851. return [d.getDate(), months[d.getMonth()], time].join(' ');
  28852. }
  28853. // log is just a thin wrapper to console.log that prepends a timestamp
  28854. function log() {
  28855. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  28856. }
  28857. function _extend(origin, add) {
  28858. // Don't do anything if add isn't an object
  28859. if (!add || !isObject$1(add)) return origin;
  28860. var keys = Object.keys(add);
  28861. var i = keys.length;
  28862. while (i--) {
  28863. origin[keys[i]] = add[keys[i]];
  28864. }
  28865. return origin;
  28866. }
  28867. function hasOwnProperty$2(obj, prop) {
  28868. return Object.prototype.hasOwnProperty.call(obj, prop);
  28869. }
  28870. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  28871. function promisify(original) {
  28872. if (typeof original !== 'function')
  28873. throw new TypeError('The "original" argument must be of type Function');
  28874. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  28875. var fn = original[kCustomPromisifiedSymbol];
  28876. if (typeof fn !== 'function') {
  28877. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  28878. }
  28879. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28880. value: fn, enumerable: false, writable: false, configurable: true
  28881. });
  28882. return fn;
  28883. }
  28884. function fn() {
  28885. var promiseResolve, promiseReject;
  28886. var promise = new Promise(function (resolve, reject) {
  28887. promiseResolve = resolve;
  28888. promiseReject = reject;
  28889. });
  28890. var args = [];
  28891. for (var i = 0; i < arguments.length; i++) {
  28892. args.push(arguments[i]);
  28893. }
  28894. args.push(function (err, value) {
  28895. if (err) {
  28896. promiseReject(err);
  28897. } else {
  28898. promiseResolve(value);
  28899. }
  28900. });
  28901. try {
  28902. original.apply(this, args);
  28903. } catch (err) {
  28904. promiseReject(err);
  28905. }
  28906. return promise;
  28907. }
  28908. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  28909. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28910. value: fn, enumerable: false, writable: false, configurable: true
  28911. });
  28912. return Object.defineProperties(
  28913. fn,
  28914. getOwnPropertyDescriptors(original)
  28915. );
  28916. }
  28917. promisify.custom = kCustomPromisifiedSymbol;
  28918. function callbackifyOnRejected(reason, cb) {
  28919. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  28920. // Because `null` is a special error value in callbacks which means "no error
  28921. // occurred", we error-wrap so the callback consumer can distinguish between
  28922. // "the promise rejected with null" or "the promise fulfilled with undefined".
  28923. if (!reason) {
  28924. var newReason = new Error('Promise was rejected with a falsy value');
  28925. newReason.reason = reason;
  28926. reason = newReason;
  28927. }
  28928. return cb(reason);
  28929. }
  28930. function callbackify(original) {
  28931. if (typeof original !== 'function') {
  28932. throw new TypeError('The "original" argument must be of type Function');
  28933. }
  28934. // We DO NOT return the promise as it gives the user a false sense that
  28935. // the promise is actually somehow related to the callback's execution
  28936. // and that the callback throwing will reject the promise.
  28937. function callbackified() {
  28938. var args = [];
  28939. for (var i = 0; i < arguments.length; i++) {
  28940. args.push(arguments[i]);
  28941. }
  28942. var maybeCb = args.pop();
  28943. if (typeof maybeCb !== 'function') {
  28944. throw new TypeError('The last argument must be of type Function');
  28945. }
  28946. var self = this;
  28947. var cb = function() {
  28948. return maybeCb.apply(self, arguments);
  28949. };
  28950. // In true node style we process the callback on `nextTick` with all the
  28951. // implications (stack, `uncaughtException`, `async_hooks`)
  28952. original.apply(this, args)
  28953. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  28954. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  28955. }
  28956. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  28957. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  28958. return callbackified;
  28959. }
  28960. var _polyfillNode_util = {
  28961. inherits: inherits,
  28962. _extend: _extend,
  28963. log: log,
  28964. isBuffer: isBuffer,
  28965. isPrimitive: isPrimitive,
  28966. isFunction: isFunction,
  28967. isError: isError,
  28968. isDate: isDate,
  28969. isObject: isObject$1,
  28970. isRegExp: isRegExp,
  28971. isUndefined: isUndefined,
  28972. isSymbol: isSymbol,
  28973. isString: isString,
  28974. isNumber: isNumber,
  28975. isNullOrUndefined: isNullOrUndefined,
  28976. isNull: isNull,
  28977. isBoolean: isBoolean,
  28978. isArray: isArray$1,
  28979. inspect: inspect,
  28980. deprecate: deprecate,
  28981. format: format$1,
  28982. debuglog: debuglog,
  28983. promisify: promisify,
  28984. callbackify: callbackify,
  28985. };
  28986. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  28987. __proto__: null,
  28988. _extend: _extend,
  28989. callbackify: callbackify,
  28990. debuglog: debuglog,
  28991. default: _polyfillNode_util,
  28992. deprecate: deprecate,
  28993. format: format$1,
  28994. inherits: inherits,
  28995. inspect: inspect,
  28996. isArray: isArray$1,
  28997. isBoolean: isBoolean,
  28998. isBuffer: isBuffer,
  28999. isDate: isDate,
  29000. isError: isError,
  29001. isFunction: isFunction,
  29002. isNull: isNull,
  29003. isNullOrUndefined: isNullOrUndefined,
  29004. isNumber: isNumber,
  29005. isObject: isObject$1,
  29006. isPrimitive: isPrimitive,
  29007. isRegExp: isRegExp,
  29008. isString: isString,
  29009. isSymbol: isSymbol,
  29010. isUndefined: isUndefined,
  29011. log: log,
  29012. promisify: promisify
  29013. });
  29014. // Copyright Joyent, Inc. and other Node contributors.
  29015. //
  29016. // Permission is hereby granted, free of charge, to any person obtaining a
  29017. // copy of this software and associated documentation files (the
  29018. // "Software"), to deal in the Software without restriction, including
  29019. // without limitation the rights to use, copy, modify, merge, publish,
  29020. // distribute, sublicense, and/or sell copies of the Software, and to permit
  29021. // persons to whom the Software is furnished to do so, subject to the
  29022. // following conditions:
  29023. //
  29024. // The above copyright notice and this permission notice shall be included
  29025. // in all copies or substantial portions of the Software.
  29026. //
  29027. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  29028. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29029. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  29030. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  29031. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  29032. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29033. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  29034. // If obj.hasOwnProperty has been overridden, then calling
  29035. // obj.hasOwnProperty(prop) will break.
  29036. // See: https://github.com/joyent/node/issues/1707
  29037. function hasOwnProperty$1(obj, prop) {
  29038. return Object.prototype.hasOwnProperty.call(obj, prop);
  29039. }
  29040. var isArray = Array.isArray || function (xs) {
  29041. return Object.prototype.toString.call(xs) === '[object Array]';
  29042. };
  29043. function stringifyPrimitive(v) {
  29044. switch (typeof v) {
  29045. case 'string':
  29046. return v;
  29047. case 'boolean':
  29048. return v ? 'true' : 'false';
  29049. case 'number':
  29050. return isFinite(v) ? v : '';
  29051. default:
  29052. return '';
  29053. }
  29054. }
  29055. function stringify (obj, sep, eq, name) {
  29056. sep = sep || '&';
  29057. eq = eq || '=';
  29058. if (obj === null) {
  29059. obj = undefined;
  29060. }
  29061. if (typeof obj === 'object') {
  29062. return map(objectKeys(obj), function(k) {
  29063. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  29064. if (isArray(obj[k])) {
  29065. return map(obj[k], function(v) {
  29066. return ks + encodeURIComponent(stringifyPrimitive(v));
  29067. }).join(sep);
  29068. } else {
  29069. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  29070. }
  29071. }).join(sep);
  29072. }
  29073. if (!name) return '';
  29074. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  29075. encodeURIComponent(stringifyPrimitive(obj));
  29076. }
  29077. function map (xs, f) {
  29078. if (xs.map) return xs.map(f);
  29079. var res = [];
  29080. for (var i = 0; i < xs.length; i++) {
  29081. res.push(f(xs[i], i));
  29082. }
  29083. return res;
  29084. }
  29085. var objectKeys = Object.keys || function (obj) {
  29086. var res = [];
  29087. for (var key in obj) {
  29088. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  29089. }
  29090. return res;
  29091. };
  29092. function parse$1(qs, sep, eq, options) {
  29093. sep = sep || '&';
  29094. eq = eq || '=';
  29095. var obj = {};
  29096. if (typeof qs !== 'string' || qs.length === 0) {
  29097. return obj;
  29098. }
  29099. var regexp = /\+/g;
  29100. qs = qs.split(sep);
  29101. var maxKeys = 1000;
  29102. if (options && typeof options.maxKeys === 'number') {
  29103. maxKeys = options.maxKeys;
  29104. }
  29105. var len = qs.length;
  29106. // maxKeys <= 0 means that we should not limit keys count
  29107. if (maxKeys > 0 && len > maxKeys) {
  29108. len = maxKeys;
  29109. }
  29110. for (var i = 0; i < len; ++i) {
  29111. var x = qs[i].replace(regexp, '%20'),
  29112. idx = x.indexOf(eq),
  29113. kstr, vstr, k, v;
  29114. if (idx >= 0) {
  29115. kstr = x.substr(0, idx);
  29116. vstr = x.substr(idx + 1);
  29117. } else {
  29118. kstr = x;
  29119. vstr = '';
  29120. }
  29121. k = decodeURIComponent(kstr);
  29122. v = decodeURIComponent(vstr);
  29123. if (!hasOwnProperty$1(obj, k)) {
  29124. obj[k] = v;
  29125. } else if (isArray(obj[k])) {
  29126. obj[k].push(v);
  29127. } else {
  29128. obj[k] = [obj[k], v];
  29129. }
  29130. }
  29131. return obj;
  29132. }
  29133. // WHATWG API
  29134. const URL$1 = global$1.URL;
  29135. const URLSearchParams = global$1.URLSearchParams;
  29136. var _polyfillNode_url = {
  29137. parse: urlParse,
  29138. resolve: urlResolve,
  29139. resolveObject: urlResolveObject,
  29140. fileURLToPath: urlFileURLToPath,
  29141. format: urlFormat,
  29142. Url: Url,
  29143. // WHATWG API
  29144. URL: URL$1,
  29145. URLSearchParams,
  29146. };
  29147. function Url() {
  29148. this.protocol = null;
  29149. this.slashes = null;
  29150. this.auth = null;
  29151. this.host = null;
  29152. this.port = null;
  29153. this.hostname = null;
  29154. this.hash = null;
  29155. this.search = null;
  29156. this.query = null;
  29157. this.pathname = null;
  29158. this.path = null;
  29159. this.href = null;
  29160. }
  29161. // Reference: RFC 3986, RFC 1808, RFC 2396
  29162. // define these here so at least they only have to be
  29163. // compiled once on the first module load.
  29164. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  29165. portPattern = /:[0-9]*$/,
  29166. // Special case for a simple path URL
  29167. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  29168. // RFC 2396: characters reserved for delimiting URLs.
  29169. // We actually just auto-escape these.
  29170. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  29171. // RFC 2396: characters not allowed for various reasons.
  29172. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  29173. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  29174. autoEscape = ['\''].concat(unwise),
  29175. // Characters that are never ever allowed in a hostname.
  29176. // Note that any invalid chars are also handled, but these
  29177. // are the ones that are *expected* to be seen, so we fast-path
  29178. // them.
  29179. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  29180. hostEndingChars = ['/', '?', '#'],
  29181. hostnameMaxLen = 255,
  29182. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  29183. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  29184. // protocols that can allow "unsafe" and "unwise" chars.
  29185. unsafeProtocol = {
  29186. 'javascript': true,
  29187. 'javascript:': true
  29188. },
  29189. // protocols that never have a hostname.
  29190. hostlessProtocol = {
  29191. 'javascript': true,
  29192. 'javascript:': true
  29193. },
  29194. // protocols that always contain a // bit.
  29195. slashedProtocol = {
  29196. 'http': true,
  29197. 'https': true,
  29198. 'ftp': true,
  29199. 'gopher': true,
  29200. 'file': true,
  29201. 'http:': true,
  29202. 'https:': true,
  29203. 'ftp:': true,
  29204. 'gopher:': true,
  29205. 'file:': true
  29206. };
  29207. function urlParse(url, parseQueryString, slashesDenoteHost) {
  29208. if (url && isObject$1(url) && url instanceof Url) return url;
  29209. var u = new Url;
  29210. u.parse(url, parseQueryString, slashesDenoteHost);
  29211. return u;
  29212. }
  29213. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  29214. return parse(this, url, parseQueryString, slashesDenoteHost);
  29215. };
  29216. function parse(self, url, parseQueryString, slashesDenoteHost) {
  29217. if (!isString(url)) {
  29218. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  29219. }
  29220. // Copy chrome, IE, opera backslash-handling behavior.
  29221. // Back slashes before the query string get converted to forward slashes
  29222. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  29223. var queryIndex = url.indexOf('?'),
  29224. splitter =
  29225. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  29226. uSplit = url.split(splitter),
  29227. slashRegex = /\\/g;
  29228. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  29229. url = uSplit.join(splitter);
  29230. var rest = url;
  29231. // trim before proceeding.
  29232. // This is to support parse stuff like " http://foo.com \n"
  29233. rest = rest.trim();
  29234. if (!slashesDenoteHost && url.split('#').length === 1) {
  29235. // Try fast path regexp
  29236. var simplePath = simplePathPattern.exec(rest);
  29237. if (simplePath) {
  29238. self.path = rest;
  29239. self.href = rest;
  29240. self.pathname = simplePath[1];
  29241. if (simplePath[2]) {
  29242. self.search = simplePath[2];
  29243. if (parseQueryString) {
  29244. self.query = parse$1(self.search.substr(1));
  29245. } else {
  29246. self.query = self.search.substr(1);
  29247. }
  29248. } else if (parseQueryString) {
  29249. self.search = '';
  29250. self.query = {};
  29251. }
  29252. return self;
  29253. }
  29254. }
  29255. var proto = protocolPattern.exec(rest);
  29256. if (proto) {
  29257. proto = proto[0];
  29258. var lowerProto = proto.toLowerCase();
  29259. self.protocol = lowerProto;
  29260. rest = rest.substr(proto.length);
  29261. }
  29262. // figure out if it's got a host
  29263. // user@server is *always* interpreted as a hostname, and url
  29264. // resolution will treat //foo/bar as host=foo,path=bar because that's
  29265. // how the browser resolves relative URLs.
  29266. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  29267. var slashes = rest.substr(0, 2) === '//';
  29268. if (slashes && !(proto && hostlessProtocol[proto])) {
  29269. rest = rest.substr(2);
  29270. self.slashes = true;
  29271. }
  29272. }
  29273. var i, hec, l, p;
  29274. if (!hostlessProtocol[proto] &&
  29275. (slashes || (proto && !slashedProtocol[proto]))) {
  29276. // there's a hostname.
  29277. // the first instance of /, ?, ;, or # ends the host.
  29278. //
  29279. // If there is an @ in the hostname, then non-host chars *are* allowed
  29280. // to the left of the last @ sign, unless some host-ending character
  29281. // comes *before* the @-sign.
  29282. // URLs are obnoxious.
  29283. //
  29284. // ex:
  29285. // http://a@b@c/ => user:a@b host:c
  29286. // http://a@b?@c => user:a host:c path:/?@c
  29287. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  29288. // Review our test case against browsers more comprehensively.
  29289. // find the first instance of any hostEndingChars
  29290. var hostEnd = -1;
  29291. for (i = 0; i < hostEndingChars.length; i++) {
  29292. hec = rest.indexOf(hostEndingChars[i]);
  29293. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29294. hostEnd = hec;
  29295. }
  29296. // at this point, either we have an explicit point where the
  29297. // auth portion cannot go past, or the last @ char is the decider.
  29298. var auth, atSign;
  29299. if (hostEnd === -1) {
  29300. // atSign can be anywhere.
  29301. atSign = rest.lastIndexOf('@');
  29302. } else {
  29303. // atSign must be in auth portion.
  29304. // http://a@b/c@d => host:b auth:a path:/c@d
  29305. atSign = rest.lastIndexOf('@', hostEnd);
  29306. }
  29307. // Now we have a portion which is definitely the auth.
  29308. // Pull that off.
  29309. if (atSign !== -1) {
  29310. auth = rest.slice(0, atSign);
  29311. rest = rest.slice(atSign + 1);
  29312. self.auth = decodeURIComponent(auth);
  29313. }
  29314. // the host is the remaining to the left of the first non-host char
  29315. hostEnd = -1;
  29316. for (i = 0; i < nonHostChars.length; i++) {
  29317. hec = rest.indexOf(nonHostChars[i]);
  29318. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29319. hostEnd = hec;
  29320. }
  29321. // if we still have not hit it, then the entire thing is a host.
  29322. if (hostEnd === -1)
  29323. hostEnd = rest.length;
  29324. self.host = rest.slice(0, hostEnd);
  29325. rest = rest.slice(hostEnd);
  29326. // pull out port.
  29327. parseHost(self);
  29328. // we've indicated that there is a hostname,
  29329. // so even if it's empty, it has to be present.
  29330. self.hostname = self.hostname || '';
  29331. // if hostname begins with [ and ends with ]
  29332. // assume that it's an IPv6 address.
  29333. var ipv6Hostname = self.hostname[0] === '[' &&
  29334. self.hostname[self.hostname.length - 1] === ']';
  29335. // validate a little.
  29336. if (!ipv6Hostname) {
  29337. var hostparts = self.hostname.split(/\./);
  29338. for (i = 0, l = hostparts.length; i < l; i++) {
  29339. var part = hostparts[i];
  29340. if (!part) continue;
  29341. if (!part.match(hostnamePartPattern)) {
  29342. var newpart = '';
  29343. for (var j = 0, k = part.length; j < k; j++) {
  29344. if (part.charCodeAt(j) > 127) {
  29345. // we replace non-ASCII char with a temporary placeholder
  29346. // we need this to make sure size of hostname is not
  29347. // broken by replacing non-ASCII by nothing
  29348. newpart += 'x';
  29349. } else {
  29350. newpart += part[j];
  29351. }
  29352. }
  29353. // we test again with ASCII char only
  29354. if (!newpart.match(hostnamePartPattern)) {
  29355. var validParts = hostparts.slice(0, i);
  29356. var notHost = hostparts.slice(i + 1);
  29357. var bit = part.match(hostnamePartStart);
  29358. if (bit) {
  29359. validParts.push(bit[1]);
  29360. notHost.unshift(bit[2]);
  29361. }
  29362. if (notHost.length) {
  29363. rest = '/' + notHost.join('.') + rest;
  29364. }
  29365. self.hostname = validParts.join('.');
  29366. break;
  29367. }
  29368. }
  29369. }
  29370. }
  29371. if (self.hostname.length > hostnameMaxLen) {
  29372. self.hostname = '';
  29373. } else {
  29374. // hostnames are always lower case.
  29375. self.hostname = self.hostname.toLowerCase();
  29376. }
  29377. if (!ipv6Hostname) {
  29378. // IDNA Support: Returns a punycoded representation of "domain".
  29379. // It only converts parts of the domain name that
  29380. // have non-ASCII characters, i.e. it doesn't matter if
  29381. // you call it with a domain that already is ASCII-only.
  29382. self.hostname = toASCII(self.hostname);
  29383. }
  29384. p = self.port ? ':' + self.port : '';
  29385. var h = self.hostname || '';
  29386. self.host = h + p;
  29387. self.href += self.host;
  29388. // strip [ and ] from the hostname
  29389. // the host field still retains them, though
  29390. if (ipv6Hostname) {
  29391. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  29392. if (rest[0] !== '/') {
  29393. rest = '/' + rest;
  29394. }
  29395. }
  29396. }
  29397. // now rest is set to the post-host stuff.
  29398. // chop off any delim chars.
  29399. if (!unsafeProtocol[lowerProto]) {
  29400. // First, make 100% sure that any "autoEscape" chars get
  29401. // escaped, even if encodeURIComponent doesn't think they
  29402. // need to be.
  29403. for (i = 0, l = autoEscape.length; i < l; i++) {
  29404. var ae = autoEscape[i];
  29405. if (rest.indexOf(ae) === -1)
  29406. continue;
  29407. var esc = encodeURIComponent(ae);
  29408. if (esc === ae) {
  29409. esc = escape(ae);
  29410. }
  29411. rest = rest.split(ae).join(esc);
  29412. }
  29413. }
  29414. // chop off from the tail first.
  29415. var hash = rest.indexOf('#');
  29416. if (hash !== -1) {
  29417. // got a fragment string.
  29418. self.hash = rest.substr(hash);
  29419. rest = rest.slice(0, hash);
  29420. }
  29421. var qm = rest.indexOf('?');
  29422. if (qm !== -1) {
  29423. self.search = rest.substr(qm);
  29424. self.query = rest.substr(qm + 1);
  29425. if (parseQueryString) {
  29426. self.query = parse$1(self.query);
  29427. }
  29428. rest = rest.slice(0, qm);
  29429. } else if (parseQueryString) {
  29430. // no query string, but parseQueryString still requested
  29431. self.search = '';
  29432. self.query = {};
  29433. }
  29434. if (rest) self.pathname = rest;
  29435. if (slashedProtocol[lowerProto] &&
  29436. self.hostname && !self.pathname) {
  29437. self.pathname = '/';
  29438. }
  29439. //to support http.request
  29440. if (self.pathname || self.search) {
  29441. p = self.pathname || '';
  29442. var s = self.search || '';
  29443. self.path = p + s;
  29444. }
  29445. // finally, reconstruct the href based on what has been validated.
  29446. self.href = format(self);
  29447. return self;
  29448. }
  29449. function urlFileURLToPath(path) {
  29450. if (typeof path === 'string')
  29451. path = new Url().parse(path);
  29452. else if (!(path instanceof Url))
  29453. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  29454. if (path.protocol !== 'file:')
  29455. throw new TypeError('The URL must be of scheme file');
  29456. return getPathFromURLPosix(path);
  29457. }
  29458. function getPathFromURLPosix(url) {
  29459. const pathname = url.pathname;
  29460. for (let n = 0; n < pathname.length; n++) {
  29461. if (pathname[n] === '%') {
  29462. const third = pathname.codePointAt(n + 2) | 0x20;
  29463. if (pathname[n + 1] === '2' && third === 102) {
  29464. throw new TypeError(
  29465. 'must not include encoded / characters'
  29466. );
  29467. }
  29468. }
  29469. }
  29470. return decodeURIComponent(pathname);
  29471. }
  29472. // format a parsed object into a url string
  29473. function urlFormat(obj) {
  29474. // ensure it's an object, and not a string url.
  29475. // If it's an obj, this is a no-op.
  29476. // this way, you can call url_format() on strings
  29477. // to clean up potentially wonky urls.
  29478. if (isString(obj)) obj = parse({}, obj);
  29479. return format(obj);
  29480. }
  29481. function format(self) {
  29482. var auth = self.auth || '';
  29483. if (auth) {
  29484. auth = encodeURIComponent(auth);
  29485. auth = auth.replace(/%3A/i, ':');
  29486. auth += '@';
  29487. }
  29488. var protocol = self.protocol || '',
  29489. pathname = self.pathname || '',
  29490. hash = self.hash || '',
  29491. host = false,
  29492. query = '';
  29493. if (self.host) {
  29494. host = auth + self.host;
  29495. } else if (self.hostname) {
  29496. host = auth + (self.hostname.indexOf(':') === -1 ?
  29497. self.hostname :
  29498. '[' + this.hostname + ']');
  29499. if (self.port) {
  29500. host += ':' + self.port;
  29501. }
  29502. }
  29503. if (self.query &&
  29504. isObject$1(self.query) &&
  29505. Object.keys(self.query).length) {
  29506. query = stringify(self.query);
  29507. }
  29508. var search = self.search || (query && ('?' + query)) || '';
  29509. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  29510. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  29511. // unless they had them to begin with.
  29512. if (self.slashes ||
  29513. (!protocol || slashedProtocol[protocol]) && host !== false) {
  29514. host = '//' + (host || '');
  29515. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  29516. } else if (!host) {
  29517. host = '';
  29518. }
  29519. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  29520. if (search && search.charAt(0) !== '?') search = '?' + search;
  29521. pathname = pathname.replace(/[?#]/g, function(match) {
  29522. return encodeURIComponent(match);
  29523. });
  29524. search = search.replace('#', '%23');
  29525. return protocol + host + pathname + search + hash;
  29526. }
  29527. Url.prototype.format = function() {
  29528. return format(this);
  29529. };
  29530. function urlResolve(source, relative) {
  29531. return urlParse(source, false, true).resolve(relative);
  29532. }
  29533. Url.prototype.resolve = function(relative) {
  29534. return this.resolveObject(urlParse(relative, false, true)).format();
  29535. };
  29536. function urlResolveObject(source, relative) {
  29537. if (!source) return relative;
  29538. return urlParse(source, false, true).resolveObject(relative);
  29539. }
  29540. Url.prototype.resolveObject = function(relative) {
  29541. if (isString(relative)) {
  29542. var rel = new Url();
  29543. rel.parse(relative, false, true);
  29544. relative = rel;
  29545. }
  29546. var result = new Url();
  29547. var tkeys = Object.keys(this);
  29548. for (var tk = 0; tk < tkeys.length; tk++) {
  29549. var tkey = tkeys[tk];
  29550. result[tkey] = this[tkey];
  29551. }
  29552. // hash is always overridden, no matter what.
  29553. // even href="" will remove it.
  29554. result.hash = relative.hash;
  29555. // if the relative url is empty, then there's nothing left to do here.
  29556. if (relative.href === '') {
  29557. result.href = result.format();
  29558. return result;
  29559. }
  29560. // hrefs like //foo/bar always cut to the protocol.
  29561. if (relative.slashes && !relative.protocol) {
  29562. // take everything except the protocol from relative
  29563. var rkeys = Object.keys(relative);
  29564. for (var rk = 0; rk < rkeys.length; rk++) {
  29565. var rkey = rkeys[rk];
  29566. if (rkey !== 'protocol')
  29567. result[rkey] = relative[rkey];
  29568. }
  29569. //urlParse appends trailing / to urls like http://www.example.com
  29570. if (slashedProtocol[result.protocol] &&
  29571. result.hostname && !result.pathname) {
  29572. result.path = result.pathname = '/';
  29573. }
  29574. result.href = result.format();
  29575. return result;
  29576. }
  29577. var relPath;
  29578. if (relative.protocol && relative.protocol !== result.protocol) {
  29579. // if it's a known url protocol, then changing
  29580. // the protocol does weird things
  29581. // first, if it's not file:, then we MUST have a host,
  29582. // and if there was a path
  29583. // to begin with, then we MUST have a path.
  29584. // if it is file:, then the host is dropped,
  29585. // because that's known to be hostless.
  29586. // anything else is assumed to be absolute.
  29587. if (!slashedProtocol[relative.protocol]) {
  29588. var keys = Object.keys(relative);
  29589. for (var v = 0; v < keys.length; v++) {
  29590. var k = keys[v];
  29591. result[k] = relative[k];
  29592. }
  29593. result.href = result.format();
  29594. return result;
  29595. }
  29596. result.protocol = relative.protocol;
  29597. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  29598. relPath = (relative.pathname || '').split('/');
  29599. while (relPath.length && !(relative.host = relPath.shift()));
  29600. if (!relative.host) relative.host = '';
  29601. if (!relative.hostname) relative.hostname = '';
  29602. if (relPath[0] !== '') relPath.unshift('');
  29603. if (relPath.length < 2) relPath.unshift('');
  29604. result.pathname = relPath.join('/');
  29605. } else {
  29606. result.pathname = relative.pathname;
  29607. }
  29608. result.search = relative.search;
  29609. result.query = relative.query;
  29610. result.host = relative.host || '';
  29611. result.auth = relative.auth;
  29612. result.hostname = relative.hostname || relative.host;
  29613. result.port = relative.port;
  29614. // to support http.request
  29615. if (result.pathname || result.search) {
  29616. var p = result.pathname || '';
  29617. var s = result.search || '';
  29618. result.path = p + s;
  29619. }
  29620. result.slashes = result.slashes || relative.slashes;
  29621. result.href = result.format();
  29622. return result;
  29623. }
  29624. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  29625. isRelAbs = (
  29626. relative.host ||
  29627. relative.pathname && relative.pathname.charAt(0) === '/'
  29628. ),
  29629. mustEndAbs = (isRelAbs || isSourceAbs ||
  29630. (result.host && relative.pathname)),
  29631. removeAllDots = mustEndAbs,
  29632. srcPath = result.pathname && result.pathname.split('/') || [],
  29633. psychotic = result.protocol && !slashedProtocol[result.protocol];
  29634. relPath = relative.pathname && relative.pathname.split('/') || [];
  29635. // if the url is a non-slashed url, then relative
  29636. // links like ../.. should be able
  29637. // to crawl up to the hostname, as well. This is strange.
  29638. // result.protocol has already been set by now.
  29639. // Later on, put the first path part into the host field.
  29640. if (psychotic) {
  29641. result.hostname = '';
  29642. result.port = null;
  29643. if (result.host) {
  29644. if (srcPath[0] === '') srcPath[0] = result.host;
  29645. else srcPath.unshift(result.host);
  29646. }
  29647. result.host = '';
  29648. if (relative.protocol) {
  29649. relative.hostname = null;
  29650. relative.port = null;
  29651. if (relative.host) {
  29652. if (relPath[0] === '') relPath[0] = relative.host;
  29653. else relPath.unshift(relative.host);
  29654. }
  29655. relative.host = null;
  29656. }
  29657. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  29658. }
  29659. var authInHost;
  29660. if (isRelAbs) {
  29661. // it's absolute.
  29662. result.host = (relative.host || relative.host === '') ?
  29663. relative.host : result.host;
  29664. result.hostname = (relative.hostname || relative.hostname === '') ?
  29665. relative.hostname : result.hostname;
  29666. result.search = relative.search;
  29667. result.query = relative.query;
  29668. srcPath = relPath;
  29669. // fall through to the dot-handling below.
  29670. } else if (relPath.length) {
  29671. // it's relative
  29672. // throw away the existing file, and take the new path instead.
  29673. if (!srcPath) srcPath = [];
  29674. srcPath.pop();
  29675. srcPath = srcPath.concat(relPath);
  29676. result.search = relative.search;
  29677. result.query = relative.query;
  29678. } else if (!isNullOrUndefined(relative.search)) {
  29679. // just pull out the search.
  29680. // like href='?foo'.
  29681. // Put this after the other two cases because it simplifies the booleans
  29682. if (psychotic) {
  29683. result.hostname = result.host = srcPath.shift();
  29684. //occationaly the auth can get stuck only in host
  29685. //this especially happens in cases like
  29686. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29687. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29688. result.host.split('@') : false;
  29689. if (authInHost) {
  29690. result.auth = authInHost.shift();
  29691. result.host = result.hostname = authInHost.shift();
  29692. }
  29693. }
  29694. result.search = relative.search;
  29695. result.query = relative.query;
  29696. //to support http.request
  29697. if (!isNull(result.pathname) || !isNull(result.search)) {
  29698. result.path = (result.pathname ? result.pathname : '') +
  29699. (result.search ? result.search : '');
  29700. }
  29701. result.href = result.format();
  29702. return result;
  29703. }
  29704. if (!srcPath.length) {
  29705. // no path at all. easy.
  29706. // we've already handled the other stuff above.
  29707. result.pathname = null;
  29708. //to support http.request
  29709. if (result.search) {
  29710. result.path = '/' + result.search;
  29711. } else {
  29712. result.path = null;
  29713. }
  29714. result.href = result.format();
  29715. return result;
  29716. }
  29717. // if a url ENDs in . or .., then it must get a trailing slash.
  29718. // however, if it ends in anything else non-slashy,
  29719. // then it must NOT get a trailing slash.
  29720. var last = srcPath.slice(-1)[0];
  29721. var hasTrailingSlash = (
  29722. (result.host || relative.host || srcPath.length > 1) &&
  29723. (last === '.' || last === '..') || last === '');
  29724. // strip single dots, resolve double dots to parent dir
  29725. // if the path tries to go above the root, `up` ends up > 0
  29726. var up = 0;
  29727. for (var i = srcPath.length; i >= 0; i--) {
  29728. last = srcPath[i];
  29729. if (last === '.') {
  29730. srcPath.splice(i, 1);
  29731. } else if (last === '..') {
  29732. srcPath.splice(i, 1);
  29733. up++;
  29734. } else if (up) {
  29735. srcPath.splice(i, 1);
  29736. up--;
  29737. }
  29738. }
  29739. // if the path is allowed to go above the root, restore leading ..s
  29740. if (!mustEndAbs && !removeAllDots) {
  29741. for (; up--; up) {
  29742. srcPath.unshift('..');
  29743. }
  29744. }
  29745. if (mustEndAbs && srcPath[0] !== '' &&
  29746. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  29747. srcPath.unshift('');
  29748. }
  29749. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  29750. srcPath.push('');
  29751. }
  29752. var isAbsolute = srcPath[0] === '' ||
  29753. (srcPath[0] && srcPath[0].charAt(0) === '/');
  29754. // put the host back
  29755. if (psychotic) {
  29756. result.hostname = result.host = isAbsolute ? '' :
  29757. srcPath.length ? srcPath.shift() : '';
  29758. //occationaly the auth can get stuck only in host
  29759. //this especially happens in cases like
  29760. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29761. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29762. result.host.split('@') : false;
  29763. if (authInHost) {
  29764. result.auth = authInHost.shift();
  29765. result.host = result.hostname = authInHost.shift();
  29766. }
  29767. }
  29768. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  29769. if (mustEndAbs && !isAbsolute) {
  29770. srcPath.unshift('');
  29771. }
  29772. if (!srcPath.length) {
  29773. result.pathname = null;
  29774. result.path = null;
  29775. } else {
  29776. result.pathname = srcPath.join('/');
  29777. }
  29778. //to support request.http
  29779. if (!isNull(result.pathname) || !isNull(result.search)) {
  29780. result.path = (result.pathname ? result.pathname : '') +
  29781. (result.search ? result.search : '');
  29782. }
  29783. result.auth = relative.auth || result.auth;
  29784. result.slashes = result.slashes || relative.slashes;
  29785. result.href = result.format();
  29786. return result;
  29787. };
  29788. Url.prototype.parseHost = function() {
  29789. return parseHost(this);
  29790. };
  29791. function parseHost(self) {
  29792. var host = self.host;
  29793. var port = portPattern.exec(host);
  29794. if (port) {
  29795. port = port[0];
  29796. if (port !== ':') {
  29797. self.port = port.substr(1);
  29798. }
  29799. host = host.substr(0, host.length - port.length);
  29800. }
  29801. if (host) self.hostname = host;
  29802. }
  29803. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  29804. __proto__: null,
  29805. URL: URL$1,
  29806. URLSearchParams: URLSearchParams,
  29807. Url: Url,
  29808. default: _polyfillNode_url,
  29809. fileURLToPath: urlFileURLToPath,
  29810. format: urlFormat,
  29811. parse: urlParse,
  29812. resolve: urlResolve,
  29813. resolveObject: urlResolveObject
  29814. });
  29815. function isRelativeUrl(url) {
  29816. const firstChar = url.charAt(0);
  29817. return firstChar === "." || firstChar === "~" || firstChar === "@";
  29818. }
  29819. const externalRE = /^(https?:)?\/\//;
  29820. function isExternalUrl(url) {
  29821. return externalRE.test(url);
  29822. }
  29823. const dataUrlRE = /^\s*data:/i;
  29824. function isDataUrl(url) {
  29825. return dataUrlRE.test(url);
  29826. }
  29827. function parseUrl(url) {
  29828. const firstChar = url.charAt(0);
  29829. if (firstChar === "~") {
  29830. const secondChar = url.charAt(1);
  29831. url = url.slice(secondChar === "/" ? 2 : 1);
  29832. }
  29833. return parseUriParts(url);
  29834. }
  29835. function parseUriParts(urlString) {
  29836. return urlParse(isString$1(urlString) ? urlString : "", false, true);
  29837. }
  29838. var __defProp$9 = Object.defineProperty;
  29839. var __defProps$8 = Object.defineProperties;
  29840. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  29841. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  29842. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  29843. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  29844. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  29845. var __spreadValues$9 = (a, b) => {
  29846. for (var prop in b || (b = {}))
  29847. if (__hasOwnProp$9.call(b, prop))
  29848. __defNormalProp$9(a, prop, b[prop]);
  29849. if (__getOwnPropSymbols$9)
  29850. for (var prop of __getOwnPropSymbols$9(b)) {
  29851. if (__propIsEnum$9.call(b, prop))
  29852. __defNormalProp$9(a, prop, b[prop]);
  29853. }
  29854. return a;
  29855. };
  29856. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  29857. const defaultAssetUrlOptions = {
  29858. base: null,
  29859. includeAbsolute: false,
  29860. tags: {
  29861. video: ["src", "poster"],
  29862. source: ["src"],
  29863. img: ["src"],
  29864. image: ["xlink:href", "href"],
  29865. use: ["xlink:href", "href"]
  29866. }
  29867. };
  29868. const normalizeOptions = (options) => {
  29869. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  29870. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  29871. tags: options
  29872. });
  29873. }
  29874. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  29875. };
  29876. const createAssetUrlTransformWithOptions = (options) => {
  29877. return (node, context) => transformAssetUrl(node, context, options);
  29878. };
  29879. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  29880. if (node.type === 1) {
  29881. if (!node.props.length) {
  29882. return;
  29883. }
  29884. const tags = options.tags || defaultAssetUrlOptions.tags;
  29885. const attrs = tags[node.tag];
  29886. const wildCardAttrs = tags["*"];
  29887. if (!attrs && !wildCardAttrs) {
  29888. return;
  29889. }
  29890. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  29891. node.props.forEach((attr, index) => {
  29892. 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)) {
  29893. return;
  29894. }
  29895. const url = parseUrl(attr.value.content);
  29896. if (options.base && attr.value.content[0] === ".") {
  29897. const base = parseUrl(options.base);
  29898. const protocol = base.protocol || "";
  29899. const host = base.host ? protocol + "//" + base.host : "";
  29900. const basePath = base.path || "/";
  29901. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  29902. return;
  29903. }
  29904. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  29905. node.props[index] = {
  29906. type: 7,
  29907. name: "bind",
  29908. arg: createSimpleExpression(attr.name, true, attr.loc),
  29909. exp,
  29910. modifiers: [],
  29911. loc: attr.loc
  29912. };
  29913. });
  29914. }
  29915. };
  29916. function getImportsExpressionExp(path2, hash, loc, context) {
  29917. if (path2) {
  29918. let name;
  29919. let exp;
  29920. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  29921. if (existingIndex > -1) {
  29922. name = `_imports_${existingIndex}`;
  29923. exp = context.imports[existingIndex].exp;
  29924. } else {
  29925. name = `_imports_${context.imports.length}`;
  29926. exp = createSimpleExpression(
  29927. name,
  29928. false,
  29929. loc,
  29930. 3
  29931. );
  29932. context.imports.push({
  29933. exp,
  29934. path: decodeURIComponent(path2)
  29935. });
  29936. }
  29937. if (!hash) {
  29938. return exp;
  29939. }
  29940. const hashExp = `${name} + '${hash}'`;
  29941. const finalExp = createSimpleExpression(
  29942. hashExp,
  29943. false,
  29944. loc,
  29945. 3
  29946. );
  29947. if (!context.hoistStatic) {
  29948. return finalExp;
  29949. }
  29950. const existingHoistIndex = context.hoists.findIndex((h) => {
  29951. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  29952. });
  29953. if (existingHoistIndex > -1) {
  29954. return createSimpleExpression(
  29955. `_hoisted_${existingHoistIndex + 1}`,
  29956. false,
  29957. loc,
  29958. 3
  29959. );
  29960. }
  29961. return context.hoist(finalExp);
  29962. } else {
  29963. return createSimpleExpression(`''`, false, loc, 3);
  29964. }
  29965. }
  29966. const srcsetTags = ["img", "source"];
  29967. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  29968. const createSrcsetTransformWithOptions = (options) => {
  29969. return (node, context) => transformSrcset(node, context, options);
  29970. };
  29971. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  29972. if (node.type === 1) {
  29973. if (srcsetTags.includes(node.tag) && node.props.length) {
  29974. node.props.forEach((attr, index) => {
  29975. if (attr.name === "srcset" && attr.type === 6) {
  29976. if (!attr.value) return;
  29977. const value = attr.value.content;
  29978. if (!value) return;
  29979. const imageCandidates = value.split(",").map((s) => {
  29980. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  29981. return { url, descriptor };
  29982. });
  29983. for (let i = 0; i < imageCandidates.length; i++) {
  29984. const { url } = imageCandidates[i];
  29985. if (isDataUrl(url)) {
  29986. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  29987. imageCandidates.splice(i, 1);
  29988. }
  29989. }
  29990. const shouldProcessUrl = (url) => {
  29991. return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  29992. };
  29993. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  29994. return;
  29995. }
  29996. if (options.base) {
  29997. const base = options.base;
  29998. const set = [];
  29999. let needImportTransform = false;
  30000. imageCandidates.forEach((candidate) => {
  30001. let { url, descriptor } = candidate;
  30002. descriptor = descriptor ? ` ${descriptor}` : ``;
  30003. if (url[0] === ".") {
  30004. candidate.url = (path.posix || path).join(base, url);
  30005. set.push(candidate.url + descriptor);
  30006. } else if (shouldProcessUrl(url)) {
  30007. needImportTransform = true;
  30008. } else {
  30009. set.push(url + descriptor);
  30010. }
  30011. });
  30012. if (!needImportTransform) {
  30013. attr.value.content = set.join(", ");
  30014. return;
  30015. }
  30016. }
  30017. const compoundExpression = createCompoundExpression([], attr.loc);
  30018. imageCandidates.forEach(({ url, descriptor }, index2) => {
  30019. if (shouldProcessUrl(url)) {
  30020. const { path: path2 } = parseUrl(url);
  30021. let exp2;
  30022. if (path2) {
  30023. const existingImportsIndex = context.imports.findIndex(
  30024. (i) => i.path === path2
  30025. );
  30026. if (existingImportsIndex > -1) {
  30027. exp2 = createSimpleExpression(
  30028. `_imports_${existingImportsIndex}`,
  30029. false,
  30030. attr.loc,
  30031. 3
  30032. );
  30033. } else {
  30034. exp2 = createSimpleExpression(
  30035. `_imports_${context.imports.length}`,
  30036. false,
  30037. attr.loc,
  30038. 3
  30039. );
  30040. context.imports.push({ exp: exp2, path: path2 });
  30041. }
  30042. compoundExpression.children.push(exp2);
  30043. }
  30044. } else {
  30045. const exp2 = createSimpleExpression(
  30046. `"${url}"`,
  30047. false,
  30048. attr.loc,
  30049. 3
  30050. );
  30051. compoundExpression.children.push(exp2);
  30052. }
  30053. const isNotLast = imageCandidates.length - 1 > index2;
  30054. if (descriptor && isNotLast) {
  30055. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  30056. } else if (descriptor) {
  30057. compoundExpression.children.push(` + ' ${descriptor}'`);
  30058. } else if (isNotLast) {
  30059. compoundExpression.children.push(` + ', ' + `);
  30060. }
  30061. });
  30062. let exp = compoundExpression;
  30063. if (context.hoistStatic) {
  30064. exp = context.hoist(compoundExpression);
  30065. exp.constType = 3;
  30066. }
  30067. node.props[index] = {
  30068. type: 7,
  30069. name: "bind",
  30070. arg: createSimpleExpression("srcset", true, attr.loc),
  30071. exp,
  30072. modifiers: [],
  30073. loc: attr.loc
  30074. };
  30075. }
  30076. });
  30077. }
  30078. }
  30079. };
  30080. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  30081. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  30082. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  30083. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  30084. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  30085. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  30086. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  30087. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  30088. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  30089. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  30090. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  30091. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(
  30092. `ssrIncludeBooleanAttr`
  30093. );
  30094. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  30095. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  30096. const SSR_RENDER_DYNAMIC_MODEL = Symbol(
  30097. `ssrRenderDynamicModel`
  30098. );
  30099. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(
  30100. `ssrGetDynamicModelProps`
  30101. );
  30102. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  30103. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  30104. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  30105. const ssrHelpers = {
  30106. [SSR_INTERPOLATE]: `ssrInterpolate`,
  30107. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  30108. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  30109. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  30110. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  30111. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  30112. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  30113. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  30114. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  30115. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  30116. [SSR_RENDER_LIST]: `ssrRenderList`,
  30117. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  30118. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  30119. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  30120. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  30121. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  30122. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  30123. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  30124. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  30125. };
  30126. registerRuntimeHelpers(ssrHelpers);
  30127. const ssrTransformIf = createStructuralDirectiveTransform(
  30128. /^(if|else|else-if)$/,
  30129. processIf
  30130. );
  30131. function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
  30132. const [rootBranch] = node.branches;
  30133. const ifStatement = createIfStatement(
  30134. rootBranch.condition,
  30135. processIfBranch(rootBranch, context, disableNestedFragments)
  30136. );
  30137. context.pushStatement(ifStatement);
  30138. let currentIf = ifStatement;
  30139. for (let i = 1; i < node.branches.length; i++) {
  30140. const branch = node.branches[i];
  30141. const branchBlockStatement = processIfBranch(
  30142. branch,
  30143. context,
  30144. disableNestedFragments
  30145. );
  30146. if (branch.condition) {
  30147. currentIf = currentIf.alternate = createIfStatement(
  30148. branch.condition,
  30149. branchBlockStatement
  30150. );
  30151. } else {
  30152. currentIf.alternate = branchBlockStatement;
  30153. }
  30154. }
  30155. if (!currentIf.alternate && !disableComment) {
  30156. currentIf.alternate = createBlockStatement([
  30157. createCallExpression(`_push`, ["`<!---->`"])
  30158. ]);
  30159. }
  30160. }
  30161. function processIfBranch(branch, context, disableNestedFragments = false) {
  30162. const { children } = branch;
  30163. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  30164. !(children.length === 1 && children[0].type === 11);
  30165. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  30166. }
  30167. const ssrTransformFor = createStructuralDirectiveTransform("for", processFor);
  30168. function ssrProcessFor(node, context, disableNestedFragments = false) {
  30169. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  30170. const renderLoop = createFunctionExpression(
  30171. createForLoopParams(node.parseResult)
  30172. );
  30173. renderLoop.body = processChildrenAsStatement(
  30174. node,
  30175. context,
  30176. needFragmentWrapper
  30177. );
  30178. if (!disableNestedFragments) {
  30179. context.pushStringPart(`<!--[-->`);
  30180. }
  30181. context.pushStatement(
  30182. createCallExpression(context.helper(SSR_RENDER_LIST), [
  30183. node.source,
  30184. renderLoop
  30185. ])
  30186. );
  30187. if (!disableNestedFragments) {
  30188. context.pushStringPart(`<!--]-->`);
  30189. }
  30190. }
  30191. const ssrTransformSlotOutlet = (node, context) => {
  30192. if (isSlotOutlet(node)) {
  30193. const { slotName, slotProps } = processSlotOutlet(node, context);
  30194. const args = [
  30195. `_ctx.$slots`,
  30196. slotName,
  30197. slotProps || `{}`,
  30198. // fallback content placeholder. will be replaced in the process phase
  30199. `null`,
  30200. `_push`,
  30201. `_parent`
  30202. ];
  30203. if (context.scopeId && context.slotted !== false) {
  30204. args.push(`"${context.scopeId}-s"`);
  30205. }
  30206. let method = SSR_RENDER_SLOT;
  30207. let parent = context.parent;
  30208. if (parent) {
  30209. const children = parent.children;
  30210. if (parent.type === 10) {
  30211. parent = context.grandParent;
  30212. }
  30213. let componentType;
  30214. if (parent.type === 1 && parent.tagType === 1 && ((componentType = resolveComponentType(parent, context, true)) === TRANSITION || componentType === TRANSITION_GROUP) && children.filter((c) => c.type === 1).length === 1) {
  30215. method = SSR_RENDER_SLOT_INNER;
  30216. if (!(context.scopeId && context.slotted !== false)) {
  30217. args.push("null");
  30218. }
  30219. args.push("true");
  30220. }
  30221. }
  30222. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  30223. }
  30224. };
  30225. function ssrProcessSlotOutlet(node, context) {
  30226. const renderCall = node.ssrCodegenNode;
  30227. if (node.children.length) {
  30228. const fallbackRenderFn = createFunctionExpression([]);
  30229. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  30230. renderCall.arguments[3] = fallbackRenderFn;
  30231. }
  30232. if (context.withSlotScopeId) {
  30233. const slotScopeId = renderCall.arguments[6];
  30234. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  30235. }
  30236. context.pushStatement(node.ssrCodegenNode);
  30237. }
  30238. function createSSRCompilerError(code, loc) {
  30239. return createCompilerError(code, loc, SSRErrorMessages);
  30240. }
  30241. const SSRErrorMessages = {
  30242. [65]: `Unsafe attribute name for SSR.`,
  30243. [66]: `Missing the 'to' prop on teleport element.`,
  30244. [67]: `Invalid AST node during SSR transform.`
  30245. };
  30246. function ssrProcessTeleport(node, context) {
  30247. const targetProp = findProp(node, "to");
  30248. if (!targetProp) {
  30249. context.onError(
  30250. createSSRCompilerError(66, node.loc)
  30251. );
  30252. return;
  30253. }
  30254. let target;
  30255. if (targetProp.type === 6) {
  30256. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  30257. } else {
  30258. target = targetProp.exp;
  30259. }
  30260. if (!target) {
  30261. context.onError(
  30262. createSSRCompilerError(
  30263. 66,
  30264. targetProp.loc
  30265. )
  30266. );
  30267. return;
  30268. }
  30269. const disabledProp = findProp(
  30270. node,
  30271. "disabled",
  30272. false,
  30273. true
  30274. /* allow empty */
  30275. );
  30276. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  30277. const contentRenderFn = createFunctionExpression(
  30278. [`_push`],
  30279. void 0,
  30280. // Body is added later
  30281. true,
  30282. // newline
  30283. false,
  30284. // isSlot
  30285. node.loc
  30286. );
  30287. contentRenderFn.body = processChildrenAsStatement(node, context);
  30288. context.pushStatement(
  30289. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  30290. `_push`,
  30291. contentRenderFn,
  30292. target,
  30293. disabled,
  30294. `_parent`
  30295. ])
  30296. );
  30297. }
  30298. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  30299. function ssrTransformSuspense(node, context) {
  30300. return () => {
  30301. if (node.children.length) {
  30302. const wipEntry = {
  30303. slotsExp: null,
  30304. // to be immediately set
  30305. wipSlots: []
  30306. };
  30307. wipMap$3.set(node, wipEntry);
  30308. wipEntry.slotsExp = buildSlots(
  30309. node,
  30310. context,
  30311. (_props, _vForExp, children, loc) => {
  30312. const fn = createFunctionExpression(
  30313. [],
  30314. void 0,
  30315. // no return, assign body later
  30316. true,
  30317. // newline
  30318. false,
  30319. // suspense slots are not treated as normal slots
  30320. loc
  30321. );
  30322. wipEntry.wipSlots.push({
  30323. fn,
  30324. children
  30325. });
  30326. return fn;
  30327. }
  30328. ).slots;
  30329. }
  30330. };
  30331. }
  30332. function ssrProcessSuspense(node, context) {
  30333. const wipEntry = wipMap$3.get(node);
  30334. if (!wipEntry) {
  30335. return;
  30336. }
  30337. const { slotsExp, wipSlots } = wipEntry;
  30338. for (let i = 0; i < wipSlots.length; i++) {
  30339. const slot = wipSlots[i];
  30340. slot.fn.body = processChildrenAsStatement(slot, context);
  30341. }
  30342. context.pushStatement(
  30343. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  30344. `_push`,
  30345. slotsExp
  30346. ])
  30347. );
  30348. }
  30349. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  30350. const ssrTransformElement = (node, context) => {
  30351. if (node.type !== 1 || node.tagType !== 0) {
  30352. return;
  30353. }
  30354. return function ssrPostTransformElement() {
  30355. const openTag = [`<${node.tag}`];
  30356. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  30357. const hasDynamicVBind = hasDynamicKeyVBind(node);
  30358. const hasCustomDir = node.props.some(
  30359. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  30360. );
  30361. const needMergeProps = hasDynamicVBind || hasCustomDir;
  30362. if (needMergeProps) {
  30363. const { props, directives } = buildProps(
  30364. node,
  30365. context,
  30366. node.props,
  30367. false,
  30368. false,
  30369. true
  30370. );
  30371. if (props || directives.length) {
  30372. const mergedProps = buildSSRProps(props, directives, context);
  30373. const propsExp = createCallExpression(
  30374. context.helper(SSR_RENDER_ATTRS),
  30375. [mergedProps]
  30376. );
  30377. if (node.tag === "textarea") {
  30378. const existingText = node.children[0];
  30379. if (!existingText || existingText.type !== 5) {
  30380. const tempId = `_temp${context.temps++}`;
  30381. propsExp.arguments = [
  30382. createAssignmentExpression(
  30383. createSimpleExpression(tempId, false),
  30384. mergedProps
  30385. )
  30386. ];
  30387. rawChildrenMap.set(
  30388. node,
  30389. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30390. createConditionalExpression(
  30391. createSimpleExpression(`"value" in ${tempId}`, false),
  30392. createSimpleExpression(`${tempId}.value`, false),
  30393. createSimpleExpression(
  30394. existingText ? existingText.content : ``,
  30395. true
  30396. ),
  30397. false
  30398. )
  30399. ])
  30400. );
  30401. }
  30402. } else if (node.tag === "input") {
  30403. const vModel = findVModel(node);
  30404. if (vModel) {
  30405. const tempId = `_temp${context.temps++}`;
  30406. const tempExp = createSimpleExpression(tempId, false);
  30407. propsExp.arguments = [
  30408. createSequenceExpression([
  30409. createAssignmentExpression(tempExp, mergedProps),
  30410. createCallExpression(context.helper(MERGE_PROPS), [
  30411. tempExp,
  30412. createCallExpression(
  30413. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  30414. [
  30415. tempExp,
  30416. // existing props
  30417. vModel.exp
  30418. // model
  30419. ]
  30420. )
  30421. ])
  30422. ])
  30423. ];
  30424. }
  30425. } else if (directives.length && !node.children.length) {
  30426. const vText = findDir(node, "text");
  30427. if (!vText) {
  30428. const tempId = `_temp${context.temps++}`;
  30429. propsExp.arguments = [
  30430. createAssignmentExpression(
  30431. createSimpleExpression(tempId, false),
  30432. mergedProps
  30433. )
  30434. ];
  30435. rawChildrenMap.set(
  30436. node,
  30437. createConditionalExpression(
  30438. createSimpleExpression(`"textContent" in ${tempId}`, false),
  30439. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30440. createSimpleExpression(`${tempId}.textContent`, false)
  30441. ]),
  30442. createSimpleExpression(`${tempId}.innerHTML ?? ''`, false),
  30443. false
  30444. )
  30445. );
  30446. }
  30447. }
  30448. if (needTagForRuntime) {
  30449. propsExp.arguments.push(`"${node.tag}"`);
  30450. }
  30451. openTag.push(propsExp);
  30452. }
  30453. }
  30454. let dynamicClassBinding = void 0;
  30455. let staticClassBinding = void 0;
  30456. let dynamicStyleBinding = void 0;
  30457. for (let i = 0; i < node.props.length; i++) {
  30458. const prop = node.props[i];
  30459. if (node.tag === "input" && isTrueFalseValue(prop)) {
  30460. continue;
  30461. }
  30462. if (prop.type === 7) {
  30463. if (prop.name === "html" && prop.exp) {
  30464. rawChildrenMap.set(
  30465. node,
  30466. createCompoundExpression([`(`, prop.exp, `) ?? ''`])
  30467. );
  30468. } else if (prop.name === "text" && prop.exp) {
  30469. node.children = [createInterpolation(prop.exp, prop.loc)];
  30470. } else if (prop.name === "slot") {
  30471. context.onError(
  30472. createCompilerError(40, prop.loc)
  30473. );
  30474. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  30475. if (!needMergeProps) {
  30476. node.children = [createInterpolation(prop.exp, prop.loc)];
  30477. }
  30478. } else if (!needMergeProps && prop.name !== "on") {
  30479. const directiveTransform = context.directiveTransforms[prop.name];
  30480. if (directiveTransform) {
  30481. const { props, ssrTagParts } = directiveTransform(
  30482. prop,
  30483. node,
  30484. context
  30485. );
  30486. if (ssrTagParts) {
  30487. openTag.push(...ssrTagParts);
  30488. }
  30489. for (let j = 0; j < props.length; j++) {
  30490. const { key, value } = props[j];
  30491. if (isStaticExp(key)) {
  30492. let attrName = key.content;
  30493. if (attrName === "key" || attrName === "ref") {
  30494. continue;
  30495. }
  30496. if (attrName === "class") {
  30497. openTag.push(
  30498. ` class="`,
  30499. dynamicClassBinding = createCallExpression(
  30500. context.helper(SSR_RENDER_CLASS),
  30501. [value]
  30502. ),
  30503. `"`
  30504. );
  30505. } else if (attrName === "style") {
  30506. if (dynamicStyleBinding) {
  30507. mergeCall(dynamicStyleBinding, value);
  30508. } else {
  30509. openTag.push(
  30510. ` style="`,
  30511. dynamicStyleBinding = createCallExpression(
  30512. context.helper(SSR_RENDER_STYLE),
  30513. [value]
  30514. ),
  30515. `"`
  30516. );
  30517. }
  30518. } else {
  30519. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  30520. if (isBooleanAttr(attrName)) {
  30521. openTag.push(
  30522. createConditionalExpression(
  30523. createCallExpression(
  30524. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  30525. [value]
  30526. ),
  30527. createSimpleExpression(" " + attrName, true),
  30528. createSimpleExpression("", true),
  30529. false
  30530. )
  30531. );
  30532. } else if (isSSRSafeAttrName(attrName)) {
  30533. openTag.push(
  30534. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  30535. key,
  30536. value
  30537. ])
  30538. );
  30539. } else {
  30540. context.onError(
  30541. createSSRCompilerError(
  30542. 65,
  30543. key.loc
  30544. )
  30545. );
  30546. }
  30547. }
  30548. } else {
  30549. const args = [key, value];
  30550. if (needTagForRuntime) {
  30551. args.push(`"${node.tag}"`);
  30552. }
  30553. openTag.push(
  30554. createCallExpression(
  30555. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  30556. args
  30557. )
  30558. );
  30559. }
  30560. }
  30561. }
  30562. }
  30563. } else {
  30564. const name = prop.name;
  30565. if (node.tag === "textarea" && name === "value" && prop.value) {
  30566. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  30567. } else if (!needMergeProps) {
  30568. if (name === "key" || name === "ref") {
  30569. continue;
  30570. }
  30571. if (name === "class" && prop.value) {
  30572. staticClassBinding = JSON.stringify(prop.value.content);
  30573. }
  30574. openTag.push(
  30575. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  30576. );
  30577. }
  30578. }
  30579. }
  30580. if (dynamicClassBinding && staticClassBinding) {
  30581. mergeCall(dynamicClassBinding, staticClassBinding);
  30582. removeStaticBinding(openTag, "class");
  30583. }
  30584. if (context.scopeId) {
  30585. openTag.push(` ${context.scopeId}`);
  30586. }
  30587. node.ssrCodegenNode = createTemplateLiteral(openTag);
  30588. };
  30589. };
  30590. function buildSSRProps(props, directives, context) {
  30591. let mergePropsArgs = [];
  30592. if (props) {
  30593. if (props.type === 14) {
  30594. mergePropsArgs = props.arguments;
  30595. } else {
  30596. mergePropsArgs.push(props);
  30597. }
  30598. }
  30599. if (directives.length) {
  30600. for (const dir of directives) {
  30601. mergePropsArgs.push(
  30602. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  30603. `_ctx`,
  30604. ...buildDirectiveArgs(dir, context).elements
  30605. ])
  30606. );
  30607. }
  30608. }
  30609. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  30610. }
  30611. function isTrueFalseValue(prop) {
  30612. if (prop.type === 7) {
  30613. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  30614. } else {
  30615. return prop.name === "true-value" || prop.name === "false-value";
  30616. }
  30617. }
  30618. function isTextareaWithValue(node, prop) {
  30619. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  30620. }
  30621. function mergeCall(call, arg) {
  30622. const existing = call.arguments[0];
  30623. if (existing.type === 17) {
  30624. existing.elements.push(arg);
  30625. } else {
  30626. call.arguments[0] = createArrayExpression([existing, arg]);
  30627. }
  30628. }
  30629. function removeStaticBinding(tag, binding) {
  30630. const regExp = new RegExp(`^ ${binding}=".+"$`);
  30631. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  30632. if (i > -1) {
  30633. tag.splice(i, 1);
  30634. }
  30635. }
  30636. function findVModel(node) {
  30637. return node.props.find(
  30638. (p) => p.type === 7 && p.name === "model" && p.exp
  30639. );
  30640. }
  30641. function ssrProcessElement(node, context) {
  30642. const isVoidTag = context.options.isVoidTag || NO;
  30643. const elementsToAdd = node.ssrCodegenNode.elements;
  30644. for (let j = 0; j < elementsToAdd.length; j++) {
  30645. context.pushStringPart(elementsToAdd[j]);
  30646. }
  30647. if (context.withSlotScopeId) {
  30648. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  30649. }
  30650. context.pushStringPart(`>`);
  30651. const rawChildren = rawChildrenMap.get(node);
  30652. if (rawChildren) {
  30653. context.pushStringPart(rawChildren);
  30654. } else if (node.children.length) {
  30655. processChildren(node, context);
  30656. }
  30657. if (!isVoidTag(node.tag)) {
  30658. context.pushStringPart(`</${node.tag}>`);
  30659. }
  30660. }
  30661. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  30662. function ssrTransformTransitionGroup(node, context) {
  30663. return () => {
  30664. const tag = findProp(node, "tag");
  30665. if (tag) {
  30666. const otherProps = node.props.filter((p) => p !== tag);
  30667. const { props, directives } = buildProps(
  30668. node,
  30669. context,
  30670. otherProps,
  30671. true,
  30672. false,
  30673. true
  30674. );
  30675. let propsExp = null;
  30676. if (props || directives.length) {
  30677. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  30678. buildSSRProps(props, directives, context)
  30679. ]);
  30680. }
  30681. wipMap$2.set(node, {
  30682. tag,
  30683. propsExp,
  30684. scopeId: context.scopeId || null
  30685. });
  30686. }
  30687. };
  30688. }
  30689. function ssrProcessTransitionGroup(node, context) {
  30690. const entry = wipMap$2.get(node);
  30691. if (entry) {
  30692. const { tag, propsExp, scopeId } = entry;
  30693. if (tag.type === 7) {
  30694. context.pushStringPart(`<`);
  30695. context.pushStringPart(tag.exp);
  30696. if (propsExp) {
  30697. context.pushStringPart(propsExp);
  30698. }
  30699. if (scopeId) {
  30700. context.pushStringPart(` ${scopeId}`);
  30701. }
  30702. context.pushStringPart(`>`);
  30703. processChildren(
  30704. node,
  30705. context,
  30706. false,
  30707. /**
  30708. * TransitionGroup has the special runtime behavior of flattening and
  30709. * concatenating all children into a single fragment (in order for them to
  30710. * be patched using the same key map) so we need to account for that here
  30711. * by disabling nested fragment wrappers from being generated.
  30712. */
  30713. true,
  30714. /**
  30715. * TransitionGroup filters out comment children at runtime and thus
  30716. * doesn't expect comments to be present during hydration. We need to
  30717. * account for that by disabling the empty comment that is otherwise
  30718. * rendered for a falsy v-if that has no v-else specified. (#6715)
  30719. */
  30720. true
  30721. );
  30722. context.pushStringPart(`</`);
  30723. context.pushStringPart(tag.exp);
  30724. context.pushStringPart(`>`);
  30725. } else {
  30726. context.pushStringPart(`<${tag.value.content}`);
  30727. if (propsExp) {
  30728. context.pushStringPart(propsExp);
  30729. }
  30730. if (scopeId) {
  30731. context.pushStringPart(` ${scopeId}`);
  30732. }
  30733. context.pushStringPart(`>`);
  30734. processChildren(node, context, false, true, true);
  30735. context.pushStringPart(`</${tag.value.content}>`);
  30736. }
  30737. } else {
  30738. processChildren(node, context, true, true, true);
  30739. }
  30740. }
  30741. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  30742. function ssrTransformTransition(node, context) {
  30743. return () => {
  30744. const appear = findProp(node, "appear", false, true);
  30745. wipMap$1.set(node, !!appear);
  30746. };
  30747. }
  30748. function ssrProcessTransition(node, context) {
  30749. node.children = node.children.filter((c) => c.type !== 3);
  30750. const appear = wipMap$1.get(node);
  30751. if (appear) {
  30752. context.pushStringPart(`<template>`);
  30753. processChildren(node, context, false, true);
  30754. context.pushStringPart(`</template>`);
  30755. } else {
  30756. processChildren(node, context, false, true);
  30757. }
  30758. }
  30759. var __defProp$8 = Object.defineProperty;
  30760. var __defProps$7 = Object.defineProperties;
  30761. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  30762. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  30763. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  30764. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  30765. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30766. var __spreadValues$8 = (a, b) => {
  30767. for (var prop in b || (b = {}))
  30768. if (__hasOwnProp$8.call(b, prop))
  30769. __defNormalProp$8(a, prop, b[prop]);
  30770. if (__getOwnPropSymbols$8)
  30771. for (var prop of __getOwnPropSymbols$8(b)) {
  30772. if (__propIsEnum$8.call(b, prop))
  30773. __defNormalProp$8(a, prop, b[prop]);
  30774. }
  30775. return a;
  30776. };
  30777. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  30778. const wipMap = /* @__PURE__ */ new WeakMap();
  30779. const WIP_SLOT = Symbol();
  30780. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  30781. const ssrTransformComponent = (node, context) => {
  30782. if (node.type !== 1 || node.tagType !== 1) {
  30783. return;
  30784. }
  30785. const component = resolveComponentType(
  30786. node,
  30787. context,
  30788. true
  30789. /* ssr */
  30790. );
  30791. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  30792. componentTypeMap.set(node, component);
  30793. if (isSymbol$1(component)) {
  30794. if (component === SUSPENSE) {
  30795. return ssrTransformSuspense(node, context);
  30796. } else if (component === TRANSITION_GROUP) {
  30797. return ssrTransformTransitionGroup(node, context);
  30798. } else if (component === TRANSITION) {
  30799. return ssrTransformTransition(node);
  30800. }
  30801. return;
  30802. }
  30803. const vnodeBranches = [];
  30804. const clonedNode = clone(node);
  30805. return function ssrPostTransformComponent() {
  30806. if (clonedNode.children.length) {
  30807. buildSlots(clonedNode, context, (props, vFor, children) => {
  30808. vnodeBranches.push(
  30809. createVNodeSlotBranch(props, vFor, children, context)
  30810. );
  30811. return createFunctionExpression(void 0);
  30812. });
  30813. }
  30814. let propsExp = `null`;
  30815. if (node.props.length) {
  30816. const { props, directives } = buildProps(
  30817. node,
  30818. context,
  30819. void 0,
  30820. true,
  30821. isDynamicComponent
  30822. );
  30823. if (props || directives.length) {
  30824. propsExp = buildSSRProps(props, directives, context);
  30825. }
  30826. }
  30827. const wipEntries = [];
  30828. wipMap.set(node, wipEntries);
  30829. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  30830. const param0 = props && stringifyExpression(props) || `_`;
  30831. const fn = createFunctionExpression(
  30832. [param0, `_push`, `_parent`, `_scopeId`],
  30833. void 0,
  30834. // no return, assign body later
  30835. true,
  30836. // newline
  30837. true,
  30838. // isSlot
  30839. loc
  30840. );
  30841. wipEntries.push({
  30842. type: WIP_SLOT,
  30843. fn,
  30844. children,
  30845. // also collect the corresponding vnode branch built earlier
  30846. vnodeBranch: vnodeBranches[wipEntries.length]
  30847. });
  30848. return fn;
  30849. };
  30850. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  30851. if (typeof component !== "string") {
  30852. node.ssrCodegenNode = createCallExpression(
  30853. context.helper(SSR_RENDER_VNODE),
  30854. [
  30855. `_push`,
  30856. createCallExpression(context.helper(CREATE_VNODE), [
  30857. component,
  30858. propsExp,
  30859. slots
  30860. ]),
  30861. `_parent`
  30862. ]
  30863. );
  30864. } else {
  30865. node.ssrCodegenNode = createCallExpression(
  30866. context.helper(SSR_RENDER_COMPONENT),
  30867. [component, propsExp, slots, `_parent`]
  30868. );
  30869. }
  30870. };
  30871. };
  30872. function ssrProcessComponent(node, context, parent) {
  30873. const component = componentTypeMap.get(node);
  30874. if (!node.ssrCodegenNode) {
  30875. if (component === TELEPORT) {
  30876. return ssrProcessTeleport(node, context);
  30877. } else if (component === SUSPENSE) {
  30878. return ssrProcessSuspense(node, context);
  30879. } else if (component === TRANSITION_GROUP) {
  30880. return ssrProcessTransitionGroup(node, context);
  30881. } else {
  30882. if (parent.type === WIP_SLOT) {
  30883. context.pushStringPart(``);
  30884. }
  30885. if (component === TRANSITION) {
  30886. return ssrProcessTransition(node, context);
  30887. }
  30888. processChildren(node, context);
  30889. }
  30890. } else {
  30891. const wipEntries = wipMap.get(node) || [];
  30892. for (let i = 0; i < wipEntries.length; i++) {
  30893. const { fn, vnodeBranch } = wipEntries[i];
  30894. fn.body = createIfStatement(
  30895. createSimpleExpression(`_push`, false),
  30896. processChildrenAsStatement(
  30897. wipEntries[i],
  30898. context,
  30899. false,
  30900. true
  30901. ),
  30902. vnodeBranch
  30903. );
  30904. }
  30905. if (context.withSlotScopeId) {
  30906. node.ssrCodegenNode.arguments.push(`_scopeId`);
  30907. }
  30908. if (typeof component === "string") {
  30909. context.pushStatement(
  30910. createCallExpression(`_push`, [node.ssrCodegenNode])
  30911. );
  30912. } else {
  30913. context.pushStatement(node.ssrCodegenNode);
  30914. }
  30915. }
  30916. }
  30917. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  30918. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  30919. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  30920. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  30921. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  30922. const rawOptions = rawOptionsMap.get(parentContext.root);
  30923. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  30924. // overwrite with vnode-based transforms
  30925. nodeTransforms: [
  30926. ...vnodeNodeTransforms,
  30927. ...rawOptions.nodeTransforms || []
  30928. ],
  30929. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  30930. });
  30931. const wrapperProps = [];
  30932. if (slotProps) {
  30933. wrapperProps.push({
  30934. type: 7,
  30935. name: "slot",
  30936. exp: slotProps,
  30937. arg: void 0,
  30938. modifiers: [],
  30939. loc: locStub
  30940. });
  30941. }
  30942. if (vFor) {
  30943. wrapperProps.push(extend({}, vFor));
  30944. }
  30945. const wrapperNode = {
  30946. type: 1,
  30947. ns: 0,
  30948. tag: "template",
  30949. tagType: 3,
  30950. props: wrapperProps,
  30951. children,
  30952. loc: locStub,
  30953. codegenNode: void 0
  30954. };
  30955. subTransform(wrapperNode, subOptions, parentContext);
  30956. return createReturnStatement(children);
  30957. }
  30958. function subTransform(node, options, parentContext) {
  30959. const childRoot = createRoot([node]);
  30960. const childContext = createTransformContext(childRoot, options);
  30961. childContext.ssr = false;
  30962. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  30963. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  30964. childContext.imports = parentContext.imports;
  30965. traverseNode(childRoot, childContext);
  30966. ["helpers", "components", "directives"].forEach((key) => {
  30967. childContext[key].forEach((value, helperKey) => {
  30968. if (key === "helpers") {
  30969. const parentCount = parentContext.helpers.get(helperKey);
  30970. if (parentCount === void 0) {
  30971. parentContext.helpers.set(helperKey, value);
  30972. } else {
  30973. parentContext.helpers.set(helperKey, value + parentCount);
  30974. }
  30975. } else {
  30976. parentContext[key].add(value);
  30977. }
  30978. });
  30979. });
  30980. }
  30981. function clone(v) {
  30982. if (isArray$3(v)) {
  30983. return v.map(clone);
  30984. } else if (isPlainObject(v)) {
  30985. const res = {};
  30986. for (const key in v) {
  30987. res[key] = clone(v[key]);
  30988. }
  30989. return res;
  30990. } else {
  30991. return v;
  30992. }
  30993. }
  30994. function ssrCodegenTransform(ast, options) {
  30995. const context = createSSRTransformContext(ast, options);
  30996. if (options.ssrCssVars) {
  30997. const cssContext = createTransformContext(createRoot([]), options);
  30998. const varsExp = processExpression(
  30999. createSimpleExpression(options.ssrCssVars, false),
  31000. cssContext
  31001. );
  31002. context.body.push(
  31003. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  31004. );
  31005. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  31006. ast.helpers.add(helper);
  31007. });
  31008. }
  31009. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  31010. processChildren(ast, context, isFragment);
  31011. ast.codegenNode = createBlockStatement(context.body);
  31012. ast.ssrHelpers = Array.from(
  31013. /* @__PURE__ */ new Set([
  31014. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  31015. ...context.helpers
  31016. ])
  31017. );
  31018. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  31019. }
  31020. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  31021. const body = [];
  31022. let currentString = null;
  31023. return {
  31024. root,
  31025. options,
  31026. body,
  31027. helpers,
  31028. withSlotScopeId,
  31029. onError: options.onError || ((e) => {
  31030. throw e;
  31031. }),
  31032. helper(name) {
  31033. helpers.add(name);
  31034. return name;
  31035. },
  31036. pushStringPart(part) {
  31037. if (!currentString) {
  31038. const currentCall = createCallExpression(`_push`);
  31039. body.push(currentCall);
  31040. currentString = createTemplateLiteral([]);
  31041. currentCall.arguments.push(currentString);
  31042. }
  31043. const bufferedElements = currentString.elements;
  31044. const lastItem = bufferedElements[bufferedElements.length - 1];
  31045. if (isString$1(part) && isString$1(lastItem)) {
  31046. bufferedElements[bufferedElements.length - 1] += part;
  31047. } else {
  31048. bufferedElements.push(part);
  31049. }
  31050. },
  31051. pushStatement(statement) {
  31052. currentString = null;
  31053. body.push(statement);
  31054. }
  31055. };
  31056. }
  31057. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  31058. return createSSRTransformContext(
  31059. parent.root,
  31060. parent.options,
  31061. parent.helpers,
  31062. withSlotScopeId
  31063. );
  31064. }
  31065. function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableComment = false) {
  31066. if (asFragment) {
  31067. context.pushStringPart(`<!--[-->`);
  31068. }
  31069. const { children } = parent;
  31070. for (let i = 0; i < children.length; i++) {
  31071. const child = children[i];
  31072. switch (child.type) {
  31073. case 1:
  31074. switch (child.tagType) {
  31075. case 0:
  31076. ssrProcessElement(child, context);
  31077. break;
  31078. case 1:
  31079. ssrProcessComponent(child, context, parent);
  31080. break;
  31081. case 2:
  31082. ssrProcessSlotOutlet(child, context);
  31083. break;
  31084. case 3:
  31085. break;
  31086. default:
  31087. context.onError(
  31088. createSSRCompilerError(
  31089. 67,
  31090. child.loc
  31091. )
  31092. );
  31093. const exhaustiveCheck2 = child;
  31094. return exhaustiveCheck2;
  31095. }
  31096. break;
  31097. case 2:
  31098. context.pushStringPart(escapeHtml(child.content));
  31099. break;
  31100. case 3:
  31101. if (!disableComment) {
  31102. context.pushStringPart(`<!--${child.content}-->`);
  31103. }
  31104. break;
  31105. case 5:
  31106. context.pushStringPart(
  31107. createCallExpression(context.helper(SSR_INTERPOLATE), [
  31108. child.content
  31109. ])
  31110. );
  31111. break;
  31112. case 9:
  31113. ssrProcessIf(child, context, disableNestedFragments, disableComment);
  31114. break;
  31115. case 11:
  31116. ssrProcessFor(child, context, disableNestedFragments);
  31117. break;
  31118. case 10:
  31119. break;
  31120. case 12:
  31121. case 8:
  31122. break;
  31123. default:
  31124. context.onError(
  31125. createSSRCompilerError(
  31126. 67,
  31127. child.loc
  31128. )
  31129. );
  31130. const exhaustiveCheck = child;
  31131. return exhaustiveCheck;
  31132. }
  31133. }
  31134. if (asFragment) {
  31135. context.pushStringPart(`<!--]-->`);
  31136. }
  31137. }
  31138. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  31139. const childContext = createChildContext(parentContext, withSlotScopeId);
  31140. processChildren(parent, childContext, asFragment);
  31141. return createBlockStatement(childContext.body);
  31142. }
  31143. const ssrTransformModel = (dir, node, context) => {
  31144. const model = dir.exp;
  31145. function checkDuplicatedValue() {
  31146. const value = findProp(node, "value");
  31147. if (value) {
  31148. context.onError(
  31149. createDOMCompilerError(
  31150. 60,
  31151. value.loc
  31152. )
  31153. );
  31154. }
  31155. }
  31156. function processOption(plainNode) {
  31157. if (plainNode.tag === "option") {
  31158. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  31159. const value = findValueBinding(plainNode);
  31160. plainNode.ssrCodegenNode.elements.push(
  31161. createConditionalExpression(
  31162. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  31163. createConditionalExpression(
  31164. createCallExpression(`Array.isArray`, [model]),
  31165. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31166. model,
  31167. value
  31168. ]),
  31169. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31170. model,
  31171. value
  31172. ])
  31173. )
  31174. ]),
  31175. createSimpleExpression(" selected", true),
  31176. createSimpleExpression("", true),
  31177. false
  31178. )
  31179. );
  31180. }
  31181. } else if (plainNode.tag === "optgroup") {
  31182. plainNode.children.forEach(
  31183. (option) => processOption(option)
  31184. );
  31185. }
  31186. }
  31187. if (node.tagType === 0) {
  31188. const res = { props: [] };
  31189. const defaultProps = [
  31190. // default value binding for text type inputs
  31191. createObjectProperty(`value`, model)
  31192. ];
  31193. if (node.tag === "input") {
  31194. const type = findProp(node, "type");
  31195. if (type) {
  31196. const value = findValueBinding(node);
  31197. if (type.type === 7) {
  31198. res.ssrTagParts = [
  31199. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  31200. type.exp,
  31201. model,
  31202. value
  31203. ])
  31204. ];
  31205. } else if (type.value) {
  31206. switch (type.value.content) {
  31207. case "radio":
  31208. res.props = [
  31209. createObjectProperty(
  31210. `checked`,
  31211. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31212. model,
  31213. value
  31214. ])
  31215. )
  31216. ];
  31217. break;
  31218. case "checkbox":
  31219. const trueValueBinding = findProp(node, "true-value");
  31220. if (trueValueBinding) {
  31221. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  31222. res.props = [
  31223. createObjectProperty(
  31224. `checked`,
  31225. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31226. model,
  31227. trueValue
  31228. ])
  31229. )
  31230. ];
  31231. } else {
  31232. res.props = [
  31233. createObjectProperty(
  31234. `checked`,
  31235. createConditionalExpression(
  31236. createCallExpression(`Array.isArray`, [model]),
  31237. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31238. model,
  31239. value
  31240. ]),
  31241. model
  31242. )
  31243. )
  31244. ];
  31245. }
  31246. break;
  31247. case "file":
  31248. context.onError(
  31249. createDOMCompilerError(
  31250. 59,
  31251. dir.loc
  31252. )
  31253. );
  31254. break;
  31255. default:
  31256. checkDuplicatedValue();
  31257. res.props = defaultProps;
  31258. break;
  31259. }
  31260. }
  31261. } else if (hasDynamicKeyVBind(node)) ; else {
  31262. checkDuplicatedValue();
  31263. res.props = defaultProps;
  31264. }
  31265. } else if (node.tag === "textarea") {
  31266. checkDuplicatedValue();
  31267. node.children = [createInterpolation(model, model.loc)];
  31268. } else if (node.tag === "select") {
  31269. const processChildren = (children) => {
  31270. children.forEach((child) => {
  31271. if (child.type === 1) {
  31272. processOption(child);
  31273. } else if (child.type === 11) {
  31274. processChildren(child.children);
  31275. } else if (child.type === 9) {
  31276. child.branches.forEach((b) => processChildren(b.children));
  31277. }
  31278. });
  31279. };
  31280. processChildren(node.children);
  31281. } else {
  31282. context.onError(
  31283. createDOMCompilerError(
  31284. 57,
  31285. dir.loc
  31286. )
  31287. );
  31288. }
  31289. return res;
  31290. } else {
  31291. return transformModel$1(dir, node, context);
  31292. }
  31293. };
  31294. function findValueBinding(node) {
  31295. const valueBinding = findProp(node, "value");
  31296. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  31297. }
  31298. const ssrTransformShow = (dir, node, context) => {
  31299. if (!dir.exp) {
  31300. context.onError(
  31301. createDOMCompilerError(61)
  31302. );
  31303. }
  31304. return {
  31305. props: [
  31306. createObjectProperty(
  31307. `style`,
  31308. createConditionalExpression(
  31309. dir.exp,
  31310. createSimpleExpression(`null`, false),
  31311. createObjectExpression([
  31312. createObjectProperty(
  31313. `display`,
  31314. createSimpleExpression(`none`, true)
  31315. )
  31316. ]),
  31317. false
  31318. )
  31319. )
  31320. ]
  31321. };
  31322. };
  31323. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  31324. const hasSingleChild = (node) => filterChild(node).length === 1;
  31325. const ssrInjectFallthroughAttrs = (node, context) => {
  31326. if (node.type === 0) {
  31327. context.identifiers._attrs = 1;
  31328. }
  31329. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  31330. const rootChildren = filterChild(context.root);
  31331. if (rootChildren.length === 1 && rootChildren[0] === node) {
  31332. if (hasSingleChild(node)) {
  31333. injectFallthroughAttrs(node.children[0]);
  31334. }
  31335. return;
  31336. }
  31337. }
  31338. const parent = context.parent;
  31339. if (!parent || parent.type !== 0) {
  31340. return;
  31341. }
  31342. if (node.type === 10 && hasSingleChild(node)) {
  31343. let hasEncounteredIf = false;
  31344. for (const c of filterChild(parent)) {
  31345. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  31346. if (hasEncounteredIf) return;
  31347. hasEncounteredIf = true;
  31348. } else if (
  31349. // node before v-if
  31350. !hasEncounteredIf || // non else nodes
  31351. !(c.type === 1 && findDir(c, /else/, true))
  31352. ) {
  31353. return;
  31354. }
  31355. }
  31356. injectFallthroughAttrs(node.children[0]);
  31357. } else if (hasSingleChild(parent)) {
  31358. injectFallthroughAttrs(node);
  31359. }
  31360. };
  31361. function injectFallthroughAttrs(node) {
  31362. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  31363. node.props.push({
  31364. type: 7,
  31365. name: "bind",
  31366. arg: void 0,
  31367. exp: createSimpleExpression(`_attrs`, false),
  31368. modifiers: [],
  31369. loc: locStub
  31370. });
  31371. }
  31372. }
  31373. const ssrInjectCssVars = (node, context) => {
  31374. if (!context.ssrCssVars) {
  31375. return;
  31376. }
  31377. if (node.type === 0) {
  31378. context.identifiers._cssVars = 1;
  31379. }
  31380. const parent = context.parent;
  31381. if (!parent || parent.type !== 0) {
  31382. return;
  31383. }
  31384. if (node.type === 10) {
  31385. for (const child of node.children) {
  31386. injectCssVars(child);
  31387. }
  31388. } else {
  31389. injectCssVars(node);
  31390. }
  31391. };
  31392. function injectCssVars(node) {
  31393. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  31394. if (node.tag === "suspense" || node.tag === "Suspense") {
  31395. for (const child of node.children) {
  31396. if (child.type === 1 && child.tagType === 3) {
  31397. child.children.forEach(injectCssVars);
  31398. } else {
  31399. injectCssVars(child);
  31400. }
  31401. }
  31402. } else {
  31403. node.props.push({
  31404. type: 7,
  31405. name: "bind",
  31406. arg: void 0,
  31407. exp: createSimpleExpression(`_cssVars`, false),
  31408. modifiers: [],
  31409. loc: locStub
  31410. });
  31411. }
  31412. }
  31413. }
  31414. var __defProp$7 = Object.defineProperty;
  31415. var __defProps$6 = Object.defineProperties;
  31416. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  31417. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  31418. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  31419. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  31420. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31421. var __spreadValues$7 = (a, b) => {
  31422. for (var prop in b || (b = {}))
  31423. if (__hasOwnProp$7.call(b, prop))
  31424. __defNormalProp$7(a, prop, b[prop]);
  31425. if (__getOwnPropSymbols$7)
  31426. for (var prop of __getOwnPropSymbols$7(b)) {
  31427. if (__propIsEnum$7.call(b, prop))
  31428. __defNormalProp$7(a, prop, b[prop]);
  31429. }
  31430. return a;
  31431. };
  31432. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  31433. function compile(source, options = {}) {
  31434. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  31435. ssr: true,
  31436. inSSR: true,
  31437. scopeId: options.mode === "function" ? null : options.scopeId,
  31438. // always prefix since compiler-ssr doesn't have size concern
  31439. prefixIdentifiers: true,
  31440. // disable optimizations that are unnecessary for ssr
  31441. cacheHandlers: false,
  31442. hoistStatic: false
  31443. });
  31444. const ast = typeof source === "string" ? baseParse(source, options) : source;
  31445. rawOptionsMap.set(ast, options);
  31446. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  31447. hoistStatic: false,
  31448. nodeTransforms: [
  31449. ssrTransformIf,
  31450. ssrTransformFor,
  31451. trackVForSlotScopes,
  31452. transformExpression,
  31453. ssrTransformSlotOutlet,
  31454. ssrInjectFallthroughAttrs,
  31455. ssrInjectCssVars,
  31456. ssrTransformElement,
  31457. ssrTransformComponent,
  31458. trackSlotScopes,
  31459. transformStyle,
  31460. ...options.nodeTransforms || []
  31461. // user transforms
  31462. ],
  31463. directiveTransforms: __spreadValues$7({
  31464. // reusing core v-bind
  31465. bind: transformBind,
  31466. on: transformOn$1,
  31467. // model and show have dedicated SSR handling
  31468. model: ssrTransformModel,
  31469. show: ssrTransformShow,
  31470. // the following are ignored during SSR
  31471. // on: noopDirectiveTransform,
  31472. cloak: noopDirectiveTransform,
  31473. once: noopDirectiveTransform,
  31474. memo: noopDirectiveTransform
  31475. }, options.directiveTransforms || {})
  31476. }));
  31477. ssrCodegenTransform(ast, options);
  31478. return generate(ast, options);
  31479. }
  31480. var CompilerSSR = /*#__PURE__*/Object.freeze({
  31481. __proto__: null,
  31482. compile: compile
  31483. });
  31484. var _polyfillNode_fs = {};
  31485. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  31486. __proto__: null,
  31487. default: _polyfillNode_fs
  31488. });
  31489. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  31490. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  31491. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  31492. const hasWarned = {};
  31493. function warnOnce$1(msg) {
  31494. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  31495. if (!isNodeProd && true && !hasWarned[msg]) {
  31496. hasWarned[msg] = true;
  31497. warn(msg);
  31498. }
  31499. }
  31500. function warn(msg) {
  31501. console.warn(
  31502. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  31503. `
  31504. );
  31505. }
  31506. var __defProp$6 = Object.defineProperty;
  31507. var __defProps$5 = Object.defineProperties;
  31508. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  31509. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  31510. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  31511. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  31512. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31513. var __spreadValues$6 = (a, b) => {
  31514. for (var prop in b || (b = {}))
  31515. if (__hasOwnProp$6.call(b, prop))
  31516. __defNormalProp$6(a, prop, b[prop]);
  31517. if (__getOwnPropSymbols$6)
  31518. for (var prop of __getOwnPropSymbols$6(b)) {
  31519. if (__propIsEnum$6.call(b, prop))
  31520. __defNormalProp$6(a, prop, b[prop]);
  31521. }
  31522. return a;
  31523. };
  31524. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  31525. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  31526. let res = "";
  31527. let err = null;
  31528. preprocessor.render(
  31529. source,
  31530. __spreadValues$6({ filename }, preprocessOptions),
  31531. (_err, _res) => {
  31532. if (_err) err = _err;
  31533. res = _res;
  31534. }
  31535. );
  31536. if (err) throw err;
  31537. return res;
  31538. }
  31539. function compileTemplate(options) {
  31540. const { preprocessLang, preprocessCustomRequire } = options;
  31541. if (preprocessLang && !preprocessCustomRequire) {
  31542. throw new Error(
  31543. `[@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 }.`
  31544. );
  31545. }
  31546. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  31547. if (preprocessor) {
  31548. try {
  31549. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  31550. source: preprocess$1(options, preprocessor),
  31551. ast: void 0
  31552. // invalidate AST if template goes through preprocessor
  31553. }));
  31554. } catch (e) {
  31555. return {
  31556. code: `export default function render() {}`,
  31557. source: options.source,
  31558. tips: [],
  31559. errors: [e]
  31560. };
  31561. }
  31562. } else if (preprocessLang) {
  31563. return {
  31564. code: `export default function render() {}`,
  31565. source: options.source,
  31566. tips: [
  31567. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  31568. ],
  31569. errors: [
  31570. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  31571. ]
  31572. };
  31573. } else {
  31574. return doCompileTemplate(options);
  31575. }
  31576. }
  31577. function doCompileTemplate({
  31578. filename,
  31579. id,
  31580. scoped,
  31581. slotted,
  31582. inMap,
  31583. source,
  31584. ast: inAST,
  31585. ssr = false,
  31586. ssrCssVars,
  31587. isProd = false,
  31588. compiler,
  31589. compilerOptions = {},
  31590. transformAssetUrls
  31591. }) {
  31592. const errors = [];
  31593. const warnings = [];
  31594. let nodeTransforms = [];
  31595. if (isObject$2(transformAssetUrls)) {
  31596. const assetOptions = normalizeOptions(transformAssetUrls);
  31597. nodeTransforms = [
  31598. createAssetUrlTransformWithOptions(assetOptions),
  31599. createSrcsetTransformWithOptions(assetOptions)
  31600. ];
  31601. } else if (transformAssetUrls !== false) {
  31602. nodeTransforms = [transformAssetUrl, transformSrcset];
  31603. }
  31604. if (ssr && !ssrCssVars) {
  31605. warnOnce$1(
  31606. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.`
  31607. );
  31608. }
  31609. if (!id) {
  31610. warnOnce$1(`compileTemplate now requires the \`id\` option.`);
  31611. id = "";
  31612. }
  31613. const shortId = id.replace(/^data-v-/, "");
  31614. const longId = `data-v-${shortId}`;
  31615. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  31616. compiler = compiler || defaultCompiler;
  31617. if (compiler !== defaultCompiler) {
  31618. inAST = void 0;
  31619. }
  31620. if (inAST == null ? void 0 : inAST.transformed) {
  31621. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  31622. prefixIdentifiers: true
  31623. }, compilerOptions), {
  31624. parseMode: "sfc",
  31625. onError: (e) => errors.push(e)
  31626. }));
  31627. const template = newAST.children.find(
  31628. (node) => node.type === 1 && node.tag === "template"
  31629. );
  31630. inAST = createRoot(template.children, inAST.source);
  31631. }
  31632. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  31633. mode: "module",
  31634. prefixIdentifiers: true,
  31635. hoistStatic: true,
  31636. cacheHandlers: true,
  31637. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  31638. scopeId: scoped ? longId : void 0,
  31639. slotted,
  31640. sourceMap: true
  31641. }, compilerOptions), {
  31642. hmr: !isProd,
  31643. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  31644. filename,
  31645. onError: (e) => errors.push(e),
  31646. onWarn: (w) => warnings.push(w)
  31647. }));
  31648. if (inMap && !inAST) {
  31649. if (map) {
  31650. map = mapLines(inMap, map);
  31651. }
  31652. if (errors.length) {
  31653. patchErrors(errors, source, inMap);
  31654. }
  31655. }
  31656. const tips = warnings.map((w) => {
  31657. let msg = w.message;
  31658. if (w.loc) {
  31659. msg += `
  31660. ${generateCodeFrame(
  31661. (inAST == null ? void 0 : inAST.source) || source,
  31662. w.loc.start.offset,
  31663. w.loc.end.offset
  31664. )}`;
  31665. }
  31666. return msg;
  31667. });
  31668. return { code, ast, preamble, source, errors, tips, map };
  31669. }
  31670. function mapLines(oldMap, newMap) {
  31671. if (!oldMap) return newMap;
  31672. if (!newMap) return oldMap;
  31673. const oldMapConsumer = new sourceMapExports.SourceMapConsumer(oldMap);
  31674. const newMapConsumer = new sourceMapExports.SourceMapConsumer(newMap);
  31675. const mergedMapGenerator = new sourceMapExports.SourceMapGenerator();
  31676. newMapConsumer.eachMapping((m) => {
  31677. if (m.originalLine == null) {
  31678. return;
  31679. }
  31680. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  31681. line: m.originalLine,
  31682. column: m.originalColumn
  31683. });
  31684. if (origPosInOldMap.source == null) {
  31685. return;
  31686. }
  31687. mergedMapGenerator.addMapping({
  31688. generated: {
  31689. line: m.generatedLine,
  31690. column: m.generatedColumn
  31691. },
  31692. original: {
  31693. line: origPosInOldMap.line,
  31694. // map line
  31695. // use current column, since the oldMap produced by @vue/compiler-sfc
  31696. // does not
  31697. column: m.originalColumn
  31698. },
  31699. source: origPosInOldMap.source,
  31700. name: origPosInOldMap.name
  31701. });
  31702. });
  31703. const generator = mergedMapGenerator;
  31704. oldMapConsumer.sources.forEach((sourceFile) => {
  31705. generator._sources.add(sourceFile);
  31706. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  31707. if (sourceContent != null) {
  31708. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  31709. }
  31710. });
  31711. generator._sourceRoot = oldMap.sourceRoot;
  31712. generator._file = oldMap.file;
  31713. return generator.toJSON();
  31714. }
  31715. function patchErrors(errors, source, inMap) {
  31716. const originalSource = inMap.sourcesContent[0];
  31717. const offset = originalSource.indexOf(source);
  31718. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  31719. errors.forEach((err) => {
  31720. if (err.loc) {
  31721. err.loc.start.line += lineOffset;
  31722. err.loc.start.offset += offset;
  31723. if (err.loc.end !== err.loc.start) {
  31724. err.loc.end.line += lineOffset;
  31725. err.loc.end.offset += offset;
  31726. }
  31727. }
  31728. });
  31729. }
  31730. var picocolors = {exports: {}};
  31731. var hasRequiredPicocolors;
  31732. function requirePicocolors () {
  31733. if (hasRequiredPicocolors) return picocolors.exports;
  31734. hasRequiredPicocolors = 1;
  31735. let p = browser$1 || {}, argv = p.argv || [], env = p.env || {};
  31736. let isColorSupported =
  31737. !(!!env.NO_COLOR || argv.includes("--no-color")) &&
  31738. (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
  31739. let formatter = (open, close, replace = open) =>
  31740. input => {
  31741. let string = "" + input, index = string.indexOf(close, open.length);
  31742. return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
  31743. };
  31744. let replaceClose = (string, close, replace, index) => {
  31745. let result = "", cursor = 0;
  31746. do {
  31747. result += string.substring(cursor, index) + replace;
  31748. cursor = index + close.length;
  31749. index = string.indexOf(close, cursor);
  31750. } while (~index)
  31751. return result + string.substring(cursor)
  31752. };
  31753. let createColors = (enabled = isColorSupported) => {
  31754. let f = enabled ? formatter : () => String;
  31755. return {
  31756. isColorSupported: enabled,
  31757. reset: f("\x1b[0m", "\x1b[0m"),
  31758. bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
  31759. dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
  31760. italic: f("\x1b[3m", "\x1b[23m"),
  31761. underline: f("\x1b[4m", "\x1b[24m"),
  31762. inverse: f("\x1b[7m", "\x1b[27m"),
  31763. hidden: f("\x1b[8m", "\x1b[28m"),
  31764. strikethrough: f("\x1b[9m", "\x1b[29m"),
  31765. black: f("\x1b[30m", "\x1b[39m"),
  31766. red: f("\x1b[31m", "\x1b[39m"),
  31767. green: f("\x1b[32m", "\x1b[39m"),
  31768. yellow: f("\x1b[33m", "\x1b[39m"),
  31769. blue: f("\x1b[34m", "\x1b[39m"),
  31770. magenta: f("\x1b[35m", "\x1b[39m"),
  31771. cyan: f("\x1b[36m", "\x1b[39m"),
  31772. white: f("\x1b[37m", "\x1b[39m"),
  31773. gray: f("\x1b[90m", "\x1b[39m"),
  31774. bgBlack: f("\x1b[40m", "\x1b[49m"),
  31775. bgRed: f("\x1b[41m", "\x1b[49m"),
  31776. bgGreen: f("\x1b[42m", "\x1b[49m"),
  31777. bgYellow: f("\x1b[43m", "\x1b[49m"),
  31778. bgBlue: f("\x1b[44m", "\x1b[49m"),
  31779. bgMagenta: f("\x1b[45m", "\x1b[49m"),
  31780. bgCyan: f("\x1b[46m", "\x1b[49m"),
  31781. bgWhite: f("\x1b[47m", "\x1b[49m"),
  31782. blackBright: f("\x1b[90m", "\x1b[39m"),
  31783. redBright: f("\x1b[91m", "\x1b[39m"),
  31784. greenBright: f("\x1b[92m", "\x1b[39m"),
  31785. yellowBright: f("\x1b[93m", "\x1b[39m"),
  31786. blueBright: f("\x1b[94m", "\x1b[39m"),
  31787. magentaBright: f("\x1b[95m", "\x1b[39m"),
  31788. cyanBright: f("\x1b[96m", "\x1b[39m"),
  31789. whiteBright: f("\x1b[97m", "\x1b[39m"),
  31790. bgBlackBright: f("\x1b[100m", "\x1b[49m"),
  31791. bgRedBright: f("\x1b[101m", "\x1b[49m"),
  31792. bgGreenBright: f("\x1b[102m", "\x1b[49m"),
  31793. bgYellowBright: f("\x1b[103m", "\x1b[49m"),
  31794. bgBlueBright: f("\x1b[104m", "\x1b[49m"),
  31795. bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
  31796. bgCyanBright: f("\x1b[106m", "\x1b[49m"),
  31797. bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
  31798. }
  31799. };
  31800. picocolors.exports = createColors();
  31801. picocolors.exports.createColors = createColors;
  31802. return picocolors.exports;
  31803. }
  31804. var tokenize$1;
  31805. var hasRequiredTokenize$1;
  31806. function requireTokenize$1 () {
  31807. if (hasRequiredTokenize$1) return tokenize$1;
  31808. hasRequiredTokenize$1 = 1;
  31809. const SINGLE_QUOTE = "'".charCodeAt(0);
  31810. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  31811. const BACKSLASH = '\\'.charCodeAt(0);
  31812. const SLASH = '/'.charCodeAt(0);
  31813. const NEWLINE = '\n'.charCodeAt(0);
  31814. const SPACE = ' '.charCodeAt(0);
  31815. const FEED = '\f'.charCodeAt(0);
  31816. const TAB = '\t'.charCodeAt(0);
  31817. const CR = '\r'.charCodeAt(0);
  31818. const OPEN_SQUARE = '['.charCodeAt(0);
  31819. const CLOSE_SQUARE = ']'.charCodeAt(0);
  31820. const OPEN_PARENTHESES = '('.charCodeAt(0);
  31821. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  31822. const OPEN_CURLY = '{'.charCodeAt(0);
  31823. const CLOSE_CURLY = '}'.charCodeAt(0);
  31824. const SEMICOLON = ';'.charCodeAt(0);
  31825. const ASTERISK = '*'.charCodeAt(0);
  31826. const COLON = ':'.charCodeAt(0);
  31827. const AT = '@'.charCodeAt(0);
  31828. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  31829. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  31830. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  31831. const RE_HEX_ESCAPE = /[\da-f]/i;
  31832. tokenize$1 = function tokenizer(input, options = {}) {
  31833. let css = input.css.valueOf();
  31834. let ignore = options.ignoreErrors;
  31835. let code, content, escape, next, quote;
  31836. let currentToken, escaped, escapePos, n, prev;
  31837. let length = css.length;
  31838. let pos = 0;
  31839. let buffer = [];
  31840. let returned = [];
  31841. function position() {
  31842. return pos
  31843. }
  31844. function unclosed(what) {
  31845. throw input.error('Unclosed ' + what, pos)
  31846. }
  31847. function endOfFile() {
  31848. return returned.length === 0 && pos >= length
  31849. }
  31850. function nextToken(opts) {
  31851. if (returned.length) return returned.pop()
  31852. if (pos >= length) return
  31853. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  31854. code = css.charCodeAt(pos);
  31855. switch (code) {
  31856. case NEWLINE:
  31857. case SPACE:
  31858. case TAB:
  31859. case CR:
  31860. case FEED: {
  31861. next = pos;
  31862. do {
  31863. next += 1;
  31864. code = css.charCodeAt(next);
  31865. } while (
  31866. code === SPACE ||
  31867. code === NEWLINE ||
  31868. code === TAB ||
  31869. code === CR ||
  31870. code === FEED
  31871. )
  31872. currentToken = ['space', css.slice(pos, next)];
  31873. pos = next - 1;
  31874. break
  31875. }
  31876. case OPEN_SQUARE:
  31877. case CLOSE_SQUARE:
  31878. case OPEN_CURLY:
  31879. case CLOSE_CURLY:
  31880. case COLON:
  31881. case SEMICOLON:
  31882. case CLOSE_PARENTHESES: {
  31883. let controlChar = String.fromCharCode(code);
  31884. currentToken = [controlChar, controlChar, pos];
  31885. break
  31886. }
  31887. case OPEN_PARENTHESES: {
  31888. prev = buffer.length ? buffer.pop()[1] : '';
  31889. n = css.charCodeAt(pos + 1);
  31890. if (
  31891. prev === 'url' &&
  31892. n !== SINGLE_QUOTE &&
  31893. n !== DOUBLE_QUOTE &&
  31894. n !== SPACE &&
  31895. n !== NEWLINE &&
  31896. n !== TAB &&
  31897. n !== FEED &&
  31898. n !== CR
  31899. ) {
  31900. next = pos;
  31901. do {
  31902. escaped = false;
  31903. next = css.indexOf(')', next + 1);
  31904. if (next === -1) {
  31905. if (ignore || ignoreUnclosed) {
  31906. next = pos;
  31907. break
  31908. } else {
  31909. unclosed('bracket');
  31910. }
  31911. }
  31912. escapePos = next;
  31913. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31914. escapePos -= 1;
  31915. escaped = !escaped;
  31916. }
  31917. } while (escaped)
  31918. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  31919. pos = next;
  31920. } else {
  31921. next = css.indexOf(')', pos + 1);
  31922. content = css.slice(pos, next + 1);
  31923. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  31924. currentToken = ['(', '(', pos];
  31925. } else {
  31926. currentToken = ['brackets', content, pos, next];
  31927. pos = next;
  31928. }
  31929. }
  31930. break
  31931. }
  31932. case SINGLE_QUOTE:
  31933. case DOUBLE_QUOTE: {
  31934. quote = code === SINGLE_QUOTE ? "'" : '"';
  31935. next = pos;
  31936. do {
  31937. escaped = false;
  31938. next = css.indexOf(quote, next + 1);
  31939. if (next === -1) {
  31940. if (ignore || ignoreUnclosed) {
  31941. next = pos + 1;
  31942. break
  31943. } else {
  31944. unclosed('string');
  31945. }
  31946. }
  31947. escapePos = next;
  31948. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31949. escapePos -= 1;
  31950. escaped = !escaped;
  31951. }
  31952. } while (escaped)
  31953. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  31954. pos = next;
  31955. break
  31956. }
  31957. case AT: {
  31958. RE_AT_END.lastIndex = pos + 1;
  31959. RE_AT_END.test(css);
  31960. if (RE_AT_END.lastIndex === 0) {
  31961. next = css.length - 1;
  31962. } else {
  31963. next = RE_AT_END.lastIndex - 2;
  31964. }
  31965. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  31966. pos = next;
  31967. break
  31968. }
  31969. case BACKSLASH: {
  31970. next = pos;
  31971. escape = true;
  31972. while (css.charCodeAt(next + 1) === BACKSLASH) {
  31973. next += 1;
  31974. escape = !escape;
  31975. }
  31976. code = css.charCodeAt(next + 1);
  31977. if (
  31978. escape &&
  31979. code !== SLASH &&
  31980. code !== SPACE &&
  31981. code !== NEWLINE &&
  31982. code !== TAB &&
  31983. code !== CR &&
  31984. code !== FEED
  31985. ) {
  31986. next += 1;
  31987. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  31988. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  31989. next += 1;
  31990. }
  31991. if (css.charCodeAt(next + 1) === SPACE) {
  31992. next += 1;
  31993. }
  31994. }
  31995. }
  31996. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31997. pos = next;
  31998. break
  31999. }
  32000. default: {
  32001. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  32002. next = css.indexOf('*/', pos + 2) + 1;
  32003. if (next === 0) {
  32004. if (ignore || ignoreUnclosed) {
  32005. next = css.length;
  32006. } else {
  32007. unclosed('comment');
  32008. }
  32009. }
  32010. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  32011. pos = next;
  32012. } else {
  32013. RE_WORD_END.lastIndex = pos + 1;
  32014. RE_WORD_END.test(css);
  32015. if (RE_WORD_END.lastIndex === 0) {
  32016. next = css.length - 1;
  32017. } else {
  32018. next = RE_WORD_END.lastIndex - 2;
  32019. }
  32020. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  32021. buffer.push(currentToken);
  32022. pos = next;
  32023. }
  32024. break
  32025. }
  32026. }
  32027. pos++;
  32028. return currentToken
  32029. }
  32030. function back(token) {
  32031. returned.push(token);
  32032. }
  32033. return {
  32034. back,
  32035. endOfFile,
  32036. nextToken,
  32037. position
  32038. }
  32039. };
  32040. return tokenize$1;
  32041. }
  32042. var terminalHighlight_1;
  32043. var hasRequiredTerminalHighlight;
  32044. function requireTerminalHighlight () {
  32045. if (hasRequiredTerminalHighlight) return terminalHighlight_1;
  32046. hasRequiredTerminalHighlight = 1;
  32047. let pico = /*@__PURE__*/ requirePicocolors();
  32048. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  32049. let Input;
  32050. function registerInput(dependant) {
  32051. Input = dependant;
  32052. }
  32053. const HIGHLIGHT_THEME = {
  32054. ';': pico.yellow,
  32055. ':': pico.yellow,
  32056. '(': pico.cyan,
  32057. ')': pico.cyan,
  32058. '[': pico.yellow,
  32059. ']': pico.yellow,
  32060. '{': pico.yellow,
  32061. '}': pico.yellow,
  32062. 'at-word': pico.cyan,
  32063. 'brackets': pico.cyan,
  32064. 'call': pico.cyan,
  32065. 'class': pico.yellow,
  32066. 'comment': pico.gray,
  32067. 'hash': pico.magenta,
  32068. 'string': pico.green
  32069. };
  32070. function getTokenType([type, value], processor) {
  32071. if (type === 'word') {
  32072. if (value[0] === '.') {
  32073. return 'class'
  32074. }
  32075. if (value[0] === '#') {
  32076. return 'hash'
  32077. }
  32078. }
  32079. if (!processor.endOfFile()) {
  32080. let next = processor.nextToken();
  32081. processor.back(next);
  32082. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  32083. }
  32084. return type
  32085. }
  32086. function terminalHighlight(css) {
  32087. let processor = tokenizer(new Input(css), { ignoreErrors: true });
  32088. let result = '';
  32089. while (!processor.endOfFile()) {
  32090. let token = processor.nextToken();
  32091. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  32092. if (color) {
  32093. result += token[1]
  32094. .split(/\r?\n/)
  32095. .map(i => color(i))
  32096. .join('\n');
  32097. } else {
  32098. result += token[1];
  32099. }
  32100. }
  32101. return result
  32102. }
  32103. terminalHighlight.registerInput = registerInput;
  32104. terminalHighlight_1 = terminalHighlight;
  32105. return terminalHighlight_1;
  32106. }
  32107. var cssSyntaxError;
  32108. var hasRequiredCssSyntaxError;
  32109. function requireCssSyntaxError () {
  32110. if (hasRequiredCssSyntaxError) return cssSyntaxError;
  32111. hasRequiredCssSyntaxError = 1;
  32112. let pico = /*@__PURE__*/ requirePicocolors();
  32113. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  32114. class CssSyntaxError extends Error {
  32115. constructor(message, line, column, source, file, plugin) {
  32116. super(message);
  32117. this.name = 'CssSyntaxError';
  32118. this.reason = message;
  32119. if (file) {
  32120. this.file = file;
  32121. }
  32122. if (source) {
  32123. this.source = source;
  32124. }
  32125. if (plugin) {
  32126. this.plugin = plugin;
  32127. }
  32128. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  32129. if (typeof line === 'number') {
  32130. this.line = line;
  32131. this.column = column;
  32132. } else {
  32133. this.line = line.line;
  32134. this.column = line.column;
  32135. this.endLine = column.line;
  32136. this.endColumn = column.column;
  32137. }
  32138. }
  32139. this.setMessage();
  32140. if (Error.captureStackTrace) {
  32141. Error.captureStackTrace(this, CssSyntaxError);
  32142. }
  32143. }
  32144. setMessage() {
  32145. this.message = this.plugin ? this.plugin + ': ' : '';
  32146. this.message += this.file ? this.file : '<css input>';
  32147. if (typeof this.line !== 'undefined') {
  32148. this.message += ':' + this.line + ':' + this.column;
  32149. }
  32150. this.message += ': ' + this.reason;
  32151. }
  32152. showSourceCode(color) {
  32153. if (!this.source) return ''
  32154. let css = this.source;
  32155. if (color == null) color = pico.isColorSupported;
  32156. let aside = text => text;
  32157. let mark = text => text;
  32158. let highlight = text => text;
  32159. if (color) {
  32160. let { bold, gray, red } = pico.createColors(true);
  32161. mark = text => bold(red(text));
  32162. aside = text => gray(text);
  32163. if (terminalHighlight) {
  32164. highlight = text => terminalHighlight(text);
  32165. }
  32166. }
  32167. let lines = css.split(/\r?\n/);
  32168. let start = Math.max(this.line - 3, 0);
  32169. let end = Math.min(this.line + 2, lines.length);
  32170. let maxWidth = String(end).length;
  32171. return lines
  32172. .slice(start, end)
  32173. .map((line, index) => {
  32174. let number = start + 1 + index;
  32175. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  32176. if (number === this.line) {
  32177. if (line.length > 160) {
  32178. let padding = 20;
  32179. let subLineStart = Math.max(0, this.column - padding);
  32180. let subLineEnd = Math.max(
  32181. this.column + padding,
  32182. this.endColumn + padding
  32183. );
  32184. let subLine = line.slice(subLineStart, subLineEnd);
  32185. let spacing =
  32186. aside(gutter.replace(/\d/g, ' ')) +
  32187. line
  32188. .slice(0, Math.min(this.column - 1, padding - 1))
  32189. .replace(/[^\t]/g, ' ');
  32190. return (
  32191. mark('>') +
  32192. aside(gutter) +
  32193. highlight(subLine) +
  32194. '\n ' +
  32195. spacing +
  32196. mark('^')
  32197. )
  32198. }
  32199. let spacing =
  32200. aside(gutter.replace(/\d/g, ' ')) +
  32201. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  32202. return (
  32203. mark('>') +
  32204. aside(gutter) +
  32205. highlight(line) +
  32206. '\n ' +
  32207. spacing +
  32208. mark('^')
  32209. )
  32210. }
  32211. return ' ' + aside(gutter) + highlight(line)
  32212. })
  32213. .join('\n')
  32214. }
  32215. toString() {
  32216. let code = this.showSourceCode();
  32217. if (code) {
  32218. code = '\n\n' + code + '\n';
  32219. }
  32220. return this.name + ': ' + this.message + code
  32221. }
  32222. }
  32223. cssSyntaxError = CssSyntaxError;
  32224. CssSyntaxError.default = CssSyntaxError;
  32225. return cssSyntaxError;
  32226. }
  32227. var stringifier;
  32228. var hasRequiredStringifier;
  32229. function requireStringifier () {
  32230. if (hasRequiredStringifier) return stringifier;
  32231. hasRequiredStringifier = 1;
  32232. const DEFAULT_RAW = {
  32233. after: '\n',
  32234. beforeClose: '\n',
  32235. beforeComment: '\n',
  32236. beforeDecl: '\n',
  32237. beforeOpen: ' ',
  32238. beforeRule: '\n',
  32239. colon: ': ',
  32240. commentLeft: ' ',
  32241. commentRight: ' ',
  32242. emptyBody: '',
  32243. indent: ' ',
  32244. semicolon: false
  32245. };
  32246. function capitalize(str) {
  32247. return str[0].toUpperCase() + str.slice(1)
  32248. }
  32249. class Stringifier {
  32250. constructor(builder) {
  32251. this.builder = builder;
  32252. }
  32253. atrule(node, semicolon) {
  32254. let name = '@' + node.name;
  32255. let params = node.params ? this.rawValue(node, 'params') : '';
  32256. if (typeof node.raws.afterName !== 'undefined') {
  32257. name += node.raws.afterName;
  32258. } else if (params) {
  32259. name += ' ';
  32260. }
  32261. if (node.nodes) {
  32262. this.block(node, name + params);
  32263. } else {
  32264. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  32265. this.builder(name + params + end, node);
  32266. }
  32267. }
  32268. beforeAfter(node, detect) {
  32269. let value;
  32270. if (node.type === 'decl') {
  32271. value = this.raw(node, null, 'beforeDecl');
  32272. } else if (node.type === 'comment') {
  32273. value = this.raw(node, null, 'beforeComment');
  32274. } else if (detect === 'before') {
  32275. value = this.raw(node, null, 'beforeRule');
  32276. } else {
  32277. value = this.raw(node, null, 'beforeClose');
  32278. }
  32279. let buf = node.parent;
  32280. let depth = 0;
  32281. while (buf && buf.type !== 'root') {
  32282. depth += 1;
  32283. buf = buf.parent;
  32284. }
  32285. if (value.includes('\n')) {
  32286. let indent = this.raw(node, null, 'indent');
  32287. if (indent.length) {
  32288. for (let step = 0; step < depth; step++) value += indent;
  32289. }
  32290. }
  32291. return value
  32292. }
  32293. block(node, start) {
  32294. let between = this.raw(node, 'between', 'beforeOpen');
  32295. this.builder(start + between + '{', node, 'start');
  32296. let after;
  32297. if (node.nodes && node.nodes.length) {
  32298. this.body(node);
  32299. after = this.raw(node, 'after');
  32300. } else {
  32301. after = this.raw(node, 'after', 'emptyBody');
  32302. }
  32303. if (after) this.builder(after);
  32304. this.builder('}', node, 'end');
  32305. }
  32306. body(node) {
  32307. let last = node.nodes.length - 1;
  32308. while (last > 0) {
  32309. if (node.nodes[last].type !== 'comment') break
  32310. last -= 1;
  32311. }
  32312. let semicolon = this.raw(node, 'semicolon');
  32313. for (let i = 0; i < node.nodes.length; i++) {
  32314. let child = node.nodes[i];
  32315. let before = this.raw(child, 'before');
  32316. if (before) this.builder(before);
  32317. this.stringify(child, last !== i || semicolon);
  32318. }
  32319. }
  32320. comment(node) {
  32321. let left = this.raw(node, 'left', 'commentLeft');
  32322. let right = this.raw(node, 'right', 'commentRight');
  32323. this.builder('/*' + left + node.text + right + '*/', node);
  32324. }
  32325. decl(node, semicolon) {
  32326. let between = this.raw(node, 'between', 'colon');
  32327. let string = node.prop + between + this.rawValue(node, 'value');
  32328. if (node.important) {
  32329. string += node.raws.important || ' !important';
  32330. }
  32331. if (semicolon) string += ';';
  32332. this.builder(string, node);
  32333. }
  32334. document(node) {
  32335. this.body(node);
  32336. }
  32337. raw(node, own, detect) {
  32338. let value;
  32339. if (!detect) detect = own;
  32340. // Already had
  32341. if (own) {
  32342. value = node.raws[own];
  32343. if (typeof value !== 'undefined') return value
  32344. }
  32345. let parent = node.parent;
  32346. if (detect === 'before') {
  32347. // Hack for first rule in CSS
  32348. if (!parent || (parent.type === 'root' && parent.first === node)) {
  32349. return ''
  32350. }
  32351. // `root` nodes in `document` should use only their own raws
  32352. if (parent && parent.type === 'document') {
  32353. return ''
  32354. }
  32355. }
  32356. // Floating child without parent
  32357. if (!parent) return DEFAULT_RAW[detect]
  32358. // Detect style by other nodes
  32359. let root = node.root();
  32360. if (!root.rawCache) root.rawCache = {};
  32361. if (typeof root.rawCache[detect] !== 'undefined') {
  32362. return root.rawCache[detect]
  32363. }
  32364. if (detect === 'before' || detect === 'after') {
  32365. return this.beforeAfter(node, detect)
  32366. } else {
  32367. let method = 'raw' + capitalize(detect);
  32368. if (this[method]) {
  32369. value = this[method](root, node);
  32370. } else {
  32371. root.walk(i => {
  32372. value = i.raws[own];
  32373. if (typeof value !== 'undefined') return false
  32374. });
  32375. }
  32376. }
  32377. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  32378. root.rawCache[detect] = value;
  32379. return value
  32380. }
  32381. rawBeforeClose(root) {
  32382. let value;
  32383. root.walk(i => {
  32384. if (i.nodes && i.nodes.length > 0) {
  32385. if (typeof i.raws.after !== 'undefined') {
  32386. value = i.raws.after;
  32387. if (value.includes('\n')) {
  32388. value = value.replace(/[^\n]+$/, '');
  32389. }
  32390. return false
  32391. }
  32392. }
  32393. });
  32394. if (value) value = value.replace(/\S/g, '');
  32395. return value
  32396. }
  32397. rawBeforeComment(root, node) {
  32398. let value;
  32399. root.walkComments(i => {
  32400. if (typeof i.raws.before !== 'undefined') {
  32401. value = i.raws.before;
  32402. if (value.includes('\n')) {
  32403. value = value.replace(/[^\n]+$/, '');
  32404. }
  32405. return false
  32406. }
  32407. });
  32408. if (typeof value === 'undefined') {
  32409. value = this.raw(node, null, 'beforeDecl');
  32410. } else if (value) {
  32411. value = value.replace(/\S/g, '');
  32412. }
  32413. return value
  32414. }
  32415. rawBeforeDecl(root, node) {
  32416. let value;
  32417. root.walkDecls(i => {
  32418. if (typeof i.raws.before !== 'undefined') {
  32419. value = i.raws.before;
  32420. if (value.includes('\n')) {
  32421. value = value.replace(/[^\n]+$/, '');
  32422. }
  32423. return false
  32424. }
  32425. });
  32426. if (typeof value === 'undefined') {
  32427. value = this.raw(node, null, 'beforeRule');
  32428. } else if (value) {
  32429. value = value.replace(/\S/g, '');
  32430. }
  32431. return value
  32432. }
  32433. rawBeforeOpen(root) {
  32434. let value;
  32435. root.walk(i => {
  32436. if (i.type !== 'decl') {
  32437. value = i.raws.between;
  32438. if (typeof value !== 'undefined') return false
  32439. }
  32440. });
  32441. return value
  32442. }
  32443. rawBeforeRule(root) {
  32444. let value;
  32445. root.walk(i => {
  32446. if (i.nodes && (i.parent !== root || root.first !== i)) {
  32447. if (typeof i.raws.before !== 'undefined') {
  32448. value = i.raws.before;
  32449. if (value.includes('\n')) {
  32450. value = value.replace(/[^\n]+$/, '');
  32451. }
  32452. return false
  32453. }
  32454. }
  32455. });
  32456. if (value) value = value.replace(/\S/g, '');
  32457. return value
  32458. }
  32459. rawColon(root) {
  32460. let value;
  32461. root.walkDecls(i => {
  32462. if (typeof i.raws.between !== 'undefined') {
  32463. value = i.raws.between.replace(/[^\s:]/g, '');
  32464. return false
  32465. }
  32466. });
  32467. return value
  32468. }
  32469. rawEmptyBody(root) {
  32470. let value;
  32471. root.walk(i => {
  32472. if (i.nodes && i.nodes.length === 0) {
  32473. value = i.raws.after;
  32474. if (typeof value !== 'undefined') return false
  32475. }
  32476. });
  32477. return value
  32478. }
  32479. rawIndent(root) {
  32480. if (root.raws.indent) return root.raws.indent
  32481. let value;
  32482. root.walk(i => {
  32483. let p = i.parent;
  32484. if (p && p !== root && p.parent && p.parent === root) {
  32485. if (typeof i.raws.before !== 'undefined') {
  32486. let parts = i.raws.before.split('\n');
  32487. value = parts[parts.length - 1];
  32488. value = value.replace(/\S/g, '');
  32489. return false
  32490. }
  32491. }
  32492. });
  32493. return value
  32494. }
  32495. rawSemicolon(root) {
  32496. let value;
  32497. root.walk(i => {
  32498. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  32499. value = i.raws.semicolon;
  32500. if (typeof value !== 'undefined') return false
  32501. }
  32502. });
  32503. return value
  32504. }
  32505. rawValue(node, prop) {
  32506. let value = node[prop];
  32507. let raw = node.raws[prop];
  32508. if (raw && raw.value === value) {
  32509. return raw.raw
  32510. }
  32511. return value
  32512. }
  32513. root(node) {
  32514. this.body(node);
  32515. if (node.raws.after) this.builder(node.raws.after);
  32516. }
  32517. rule(node) {
  32518. this.block(node, this.rawValue(node, 'selector'));
  32519. if (node.raws.ownSemicolon) {
  32520. this.builder(node.raws.ownSemicolon, node, 'end');
  32521. }
  32522. }
  32523. stringify(node, semicolon) {
  32524. /* c8 ignore start */
  32525. if (!this[node.type]) {
  32526. throw new Error(
  32527. 'Unknown AST node type ' +
  32528. node.type +
  32529. '. ' +
  32530. 'Maybe you need to change PostCSS stringifier.'
  32531. )
  32532. }
  32533. /* c8 ignore stop */
  32534. this[node.type](node, semicolon);
  32535. }
  32536. }
  32537. stringifier = Stringifier;
  32538. Stringifier.default = Stringifier;
  32539. return stringifier;
  32540. }
  32541. var stringify_1;
  32542. var hasRequiredStringify;
  32543. function requireStringify () {
  32544. if (hasRequiredStringify) return stringify_1;
  32545. hasRequiredStringify = 1;
  32546. let Stringifier = /*@__PURE__*/ requireStringifier();
  32547. function stringify(node, builder) {
  32548. let str = new Stringifier(builder);
  32549. str.stringify(node);
  32550. }
  32551. stringify_1 = stringify;
  32552. stringify.default = stringify;
  32553. return stringify_1;
  32554. }
  32555. var symbols = {};
  32556. var hasRequiredSymbols;
  32557. function requireSymbols () {
  32558. if (hasRequiredSymbols) return symbols;
  32559. hasRequiredSymbols = 1;
  32560. symbols.isClean = Symbol('isClean');
  32561. symbols.my = Symbol('my');
  32562. return symbols;
  32563. }
  32564. var node$2;
  32565. var hasRequiredNode$2;
  32566. function requireNode$2 () {
  32567. if (hasRequiredNode$2) return node$2;
  32568. hasRequiredNode$2 = 1;
  32569. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  32570. let Stringifier = /*@__PURE__*/ requireStringifier();
  32571. let stringify = /*@__PURE__*/ requireStringify();
  32572. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  32573. function cloneNode(obj, parent) {
  32574. let cloned = new obj.constructor();
  32575. for (let i in obj) {
  32576. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  32577. /* c8 ignore next 2 */
  32578. continue
  32579. }
  32580. if (i === 'proxyCache') continue
  32581. let value = obj[i];
  32582. let type = typeof value;
  32583. if (i === 'parent' && type === 'object') {
  32584. if (parent) cloned[i] = parent;
  32585. } else if (i === 'source') {
  32586. cloned[i] = value;
  32587. } else if (Array.isArray(value)) {
  32588. cloned[i] = value.map(j => cloneNode(j, cloned));
  32589. } else {
  32590. if (type === 'object' && value !== null) value = cloneNode(value);
  32591. cloned[i] = value;
  32592. }
  32593. }
  32594. return cloned
  32595. }
  32596. class Node {
  32597. constructor(defaults = {}) {
  32598. this.raws = {};
  32599. this[isClean] = false;
  32600. this[my] = true;
  32601. for (let name in defaults) {
  32602. if (name === 'nodes') {
  32603. this.nodes = [];
  32604. for (let node of defaults[name]) {
  32605. if (typeof node.clone === 'function') {
  32606. this.append(node.clone());
  32607. } else {
  32608. this.append(node);
  32609. }
  32610. }
  32611. } else {
  32612. this[name] = defaults[name];
  32613. }
  32614. }
  32615. }
  32616. addToError(error) {
  32617. error.postcssNode = this;
  32618. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  32619. let s = this.source;
  32620. error.stack = error.stack.replace(
  32621. /\n\s{4}at /,
  32622. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  32623. );
  32624. }
  32625. return error
  32626. }
  32627. after(add) {
  32628. this.parent.insertAfter(this, add);
  32629. return this
  32630. }
  32631. assign(overrides = {}) {
  32632. for (let name in overrides) {
  32633. this[name] = overrides[name];
  32634. }
  32635. return this
  32636. }
  32637. before(add) {
  32638. this.parent.insertBefore(this, add);
  32639. return this
  32640. }
  32641. cleanRaws(keepBetween) {
  32642. delete this.raws.before;
  32643. delete this.raws.after;
  32644. if (!keepBetween) delete this.raws.between;
  32645. }
  32646. clone(overrides = {}) {
  32647. let cloned = cloneNode(this);
  32648. for (let name in overrides) {
  32649. cloned[name] = overrides[name];
  32650. }
  32651. return cloned
  32652. }
  32653. cloneAfter(overrides = {}) {
  32654. let cloned = this.clone(overrides);
  32655. this.parent.insertAfter(this, cloned);
  32656. return cloned
  32657. }
  32658. cloneBefore(overrides = {}) {
  32659. let cloned = this.clone(overrides);
  32660. this.parent.insertBefore(this, cloned);
  32661. return cloned
  32662. }
  32663. error(message, opts = {}) {
  32664. if (this.source) {
  32665. let { end, start } = this.rangeBy(opts);
  32666. return this.source.input.error(
  32667. message,
  32668. { column: start.column, line: start.line },
  32669. { column: end.column, line: end.line },
  32670. opts
  32671. )
  32672. }
  32673. return new CssSyntaxError(message)
  32674. }
  32675. getProxyProcessor() {
  32676. return {
  32677. get(node, prop) {
  32678. if (prop === 'proxyOf') {
  32679. return node
  32680. } else if (prop === 'root') {
  32681. return () => node.root().toProxy()
  32682. } else {
  32683. return node[prop]
  32684. }
  32685. },
  32686. set(node, prop, value) {
  32687. if (node[prop] === value) return true
  32688. node[prop] = value;
  32689. if (
  32690. prop === 'prop' ||
  32691. prop === 'value' ||
  32692. prop === 'name' ||
  32693. prop === 'params' ||
  32694. prop === 'important' ||
  32695. /* c8 ignore next */
  32696. prop === 'text'
  32697. ) {
  32698. node.markDirty();
  32699. }
  32700. return true
  32701. }
  32702. }
  32703. }
  32704. /* c8 ignore next 3 */
  32705. markClean() {
  32706. this[isClean] = true;
  32707. }
  32708. markDirty() {
  32709. if (this[isClean]) {
  32710. this[isClean] = false;
  32711. let next = this;
  32712. while ((next = next.parent)) {
  32713. next[isClean] = false;
  32714. }
  32715. }
  32716. }
  32717. next() {
  32718. if (!this.parent) return undefined
  32719. let index = this.parent.index(this);
  32720. return this.parent.nodes[index + 1]
  32721. }
  32722. positionBy(opts, stringRepresentation) {
  32723. let pos = this.source.start;
  32724. if (opts.index) {
  32725. pos = this.positionInside(opts.index);
  32726. } else if (opts.word) {
  32727. stringRepresentation = this.source.input.css.slice(this.source.start.offset, this.source.end.offset);
  32728. let index = stringRepresentation.indexOf(opts.word);
  32729. if (index !== -1) pos = this.positionInside(index);
  32730. }
  32731. return pos
  32732. }
  32733. positionInside(index) {
  32734. let column = this.source.start.column;
  32735. let line = this.source.start.line;
  32736. let offset = this.source.start.offset;
  32737. let end = offset + index;
  32738. for (let i = offset; i < end; i++) {
  32739. if (this.source.input.css[i] === '\n') {
  32740. column = 1;
  32741. line += 1;
  32742. } else {
  32743. column += 1;
  32744. }
  32745. }
  32746. return { column, line }
  32747. }
  32748. prev() {
  32749. if (!this.parent) return undefined
  32750. let index = this.parent.index(this);
  32751. return this.parent.nodes[index - 1]
  32752. }
  32753. rangeBy(opts) {
  32754. let start = {
  32755. column: this.source.start.column,
  32756. line: this.source.start.line
  32757. };
  32758. let end = this.source.end
  32759. ? {
  32760. column: this.source.end.column + 1,
  32761. line: this.source.end.line
  32762. }
  32763. : {
  32764. column: start.column + 1,
  32765. line: start.line
  32766. };
  32767. if (opts.word) {
  32768. let stringRepresentation = this.source.input.css.slice(this.source.start.offset, this.source.end.offset);
  32769. let index = stringRepresentation.indexOf(opts.word);
  32770. if (index !== -1) {
  32771. start = this.positionInside(index, stringRepresentation);
  32772. end = this.positionInside(
  32773. index + opts.word.length,
  32774. stringRepresentation
  32775. );
  32776. }
  32777. } else {
  32778. if (opts.start) {
  32779. start = {
  32780. column: opts.start.column,
  32781. line: opts.start.line
  32782. };
  32783. } else if (opts.index) {
  32784. start = this.positionInside(opts.index);
  32785. }
  32786. if (opts.end) {
  32787. end = {
  32788. column: opts.end.column,
  32789. line: opts.end.line
  32790. };
  32791. } else if (typeof opts.endIndex === 'number') {
  32792. end = this.positionInside(opts.endIndex);
  32793. } else if (opts.index) {
  32794. end = this.positionInside(opts.index + 1);
  32795. }
  32796. }
  32797. if (
  32798. end.line < start.line ||
  32799. (end.line === start.line && end.column <= start.column)
  32800. ) {
  32801. end = { column: start.column + 1, line: start.line };
  32802. }
  32803. return { end, start }
  32804. }
  32805. raw(prop, defaultType) {
  32806. let str = new Stringifier();
  32807. return str.raw(this, prop, defaultType)
  32808. }
  32809. remove() {
  32810. if (this.parent) {
  32811. this.parent.removeChild(this);
  32812. }
  32813. this.parent = undefined;
  32814. return this
  32815. }
  32816. replaceWith(...nodes) {
  32817. if (this.parent) {
  32818. let bookmark = this;
  32819. let foundSelf = false;
  32820. for (let node of nodes) {
  32821. if (node === this) {
  32822. foundSelf = true;
  32823. } else if (foundSelf) {
  32824. this.parent.insertAfter(bookmark, node);
  32825. bookmark = node;
  32826. } else {
  32827. this.parent.insertBefore(bookmark, node);
  32828. }
  32829. }
  32830. if (!foundSelf) {
  32831. this.remove();
  32832. }
  32833. }
  32834. return this
  32835. }
  32836. root() {
  32837. let result = this;
  32838. while (result.parent && result.parent.type !== 'document') {
  32839. result = result.parent;
  32840. }
  32841. return result
  32842. }
  32843. toJSON(_, inputs) {
  32844. let fixed = {};
  32845. let emitInputs = inputs == null;
  32846. inputs = inputs || new Map();
  32847. let inputsNextIndex = 0;
  32848. for (let name in this) {
  32849. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  32850. /* c8 ignore next 2 */
  32851. continue
  32852. }
  32853. if (name === 'parent' || name === 'proxyCache') continue
  32854. let value = this[name];
  32855. if (Array.isArray(value)) {
  32856. fixed[name] = value.map(i => {
  32857. if (typeof i === 'object' && i.toJSON) {
  32858. return i.toJSON(null, inputs)
  32859. } else {
  32860. return i
  32861. }
  32862. });
  32863. } else if (typeof value === 'object' && value.toJSON) {
  32864. fixed[name] = value.toJSON(null, inputs);
  32865. } else if (name === 'source') {
  32866. let inputId = inputs.get(value.input);
  32867. if (inputId == null) {
  32868. inputId = inputsNextIndex;
  32869. inputs.set(value.input, inputsNextIndex);
  32870. inputsNextIndex++;
  32871. }
  32872. fixed[name] = {
  32873. end: value.end,
  32874. inputId,
  32875. start: value.start
  32876. };
  32877. } else {
  32878. fixed[name] = value;
  32879. }
  32880. }
  32881. if (emitInputs) {
  32882. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  32883. }
  32884. return fixed
  32885. }
  32886. toProxy() {
  32887. if (!this.proxyCache) {
  32888. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  32889. }
  32890. return this.proxyCache
  32891. }
  32892. toString(stringifier = stringify) {
  32893. if (stringifier.stringify) stringifier = stringifier.stringify;
  32894. let result = '';
  32895. stringifier(this, i => {
  32896. result += i;
  32897. });
  32898. return result
  32899. }
  32900. warn(result, text, opts) {
  32901. let data = { node: this };
  32902. for (let i in opts) data[i] = opts[i];
  32903. return result.warn(text, data)
  32904. }
  32905. get proxyOf() {
  32906. return this
  32907. }
  32908. }
  32909. node$2 = Node;
  32910. Node.default = Node;
  32911. return node$2;
  32912. }
  32913. var comment$1;
  32914. var hasRequiredComment$1;
  32915. function requireComment$1 () {
  32916. if (hasRequiredComment$1) return comment$1;
  32917. hasRequiredComment$1 = 1;
  32918. let Node = /*@__PURE__*/ requireNode$2();
  32919. class Comment extends Node {
  32920. constructor(defaults) {
  32921. super(defaults);
  32922. this.type = 'comment';
  32923. }
  32924. }
  32925. comment$1 = Comment;
  32926. Comment.default = Comment;
  32927. return comment$1;
  32928. }
  32929. var declaration;
  32930. var hasRequiredDeclaration;
  32931. function requireDeclaration () {
  32932. if (hasRequiredDeclaration) return declaration;
  32933. hasRequiredDeclaration = 1;
  32934. let Node = /*@__PURE__*/ requireNode$2();
  32935. class Declaration extends Node {
  32936. constructor(defaults) {
  32937. if (
  32938. defaults &&
  32939. typeof defaults.value !== 'undefined' &&
  32940. typeof defaults.value !== 'string'
  32941. ) {
  32942. defaults = { ...defaults, value: String(defaults.value) };
  32943. }
  32944. super(defaults);
  32945. this.type = 'decl';
  32946. }
  32947. get variable() {
  32948. return this.prop.startsWith('--') || this.prop[0] === '$'
  32949. }
  32950. }
  32951. declaration = Declaration;
  32952. Declaration.default = Declaration;
  32953. return declaration;
  32954. }
  32955. var container$1;
  32956. var hasRequiredContainer$1;
  32957. function requireContainer$1 () {
  32958. if (hasRequiredContainer$1) return container$1;
  32959. hasRequiredContainer$1 = 1;
  32960. let Comment = /*@__PURE__*/ requireComment$1();
  32961. let Declaration = /*@__PURE__*/ requireDeclaration();
  32962. let Node = /*@__PURE__*/ requireNode$2();
  32963. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  32964. let AtRule, parse, Root, Rule;
  32965. function cleanSource(nodes) {
  32966. return nodes.map(i => {
  32967. if (i.nodes) i.nodes = cleanSource(i.nodes);
  32968. delete i.source;
  32969. return i
  32970. })
  32971. }
  32972. function markTreeDirty(node) {
  32973. node[isClean] = false;
  32974. if (node.proxyOf.nodes) {
  32975. for (let i of node.proxyOf.nodes) {
  32976. markTreeDirty(i);
  32977. }
  32978. }
  32979. }
  32980. class Container extends Node {
  32981. append(...children) {
  32982. for (let child of children) {
  32983. let nodes = this.normalize(child, this.last);
  32984. for (let node of nodes) this.proxyOf.nodes.push(node);
  32985. }
  32986. this.markDirty();
  32987. return this
  32988. }
  32989. cleanRaws(keepBetween) {
  32990. super.cleanRaws(keepBetween);
  32991. if (this.nodes) {
  32992. for (let node of this.nodes) node.cleanRaws(keepBetween);
  32993. }
  32994. }
  32995. each(callback) {
  32996. if (!this.proxyOf.nodes) return undefined
  32997. let iterator = this.getIterator();
  32998. let index, result;
  32999. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33000. index = this.indexes[iterator];
  33001. result = callback(this.proxyOf.nodes[index], index);
  33002. if (result === false) break
  33003. this.indexes[iterator] += 1;
  33004. }
  33005. delete this.indexes[iterator];
  33006. return result
  33007. }
  33008. every(condition) {
  33009. return this.nodes.every(condition)
  33010. }
  33011. getIterator() {
  33012. if (!this.lastEach) this.lastEach = 0;
  33013. if (!this.indexes) this.indexes = {};
  33014. this.lastEach += 1;
  33015. let iterator = this.lastEach;
  33016. this.indexes[iterator] = 0;
  33017. return iterator
  33018. }
  33019. getProxyProcessor() {
  33020. return {
  33021. get(node, prop) {
  33022. if (prop === 'proxyOf') {
  33023. return node
  33024. } else if (!node[prop]) {
  33025. return node[prop]
  33026. } else if (
  33027. prop === 'each' ||
  33028. (typeof prop === 'string' && prop.startsWith('walk'))
  33029. ) {
  33030. return (...args) => {
  33031. return node[prop](
  33032. ...args.map(i => {
  33033. if (typeof i === 'function') {
  33034. return (child, index) => i(child.toProxy(), index)
  33035. } else {
  33036. return i
  33037. }
  33038. })
  33039. )
  33040. }
  33041. } else if (prop === 'every' || prop === 'some') {
  33042. return cb => {
  33043. return node[prop]((child, ...other) =>
  33044. cb(child.toProxy(), ...other)
  33045. )
  33046. }
  33047. } else if (prop === 'root') {
  33048. return () => node.root().toProxy()
  33049. } else if (prop === 'nodes') {
  33050. return node.nodes.map(i => i.toProxy())
  33051. } else if (prop === 'first' || prop === 'last') {
  33052. return node[prop].toProxy()
  33053. } else {
  33054. return node[prop]
  33055. }
  33056. },
  33057. set(node, prop, value) {
  33058. if (node[prop] === value) return true
  33059. node[prop] = value;
  33060. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33061. node.markDirty();
  33062. }
  33063. return true
  33064. }
  33065. }
  33066. }
  33067. index(child) {
  33068. if (typeof child === 'number') return child
  33069. if (child.proxyOf) child = child.proxyOf;
  33070. return this.proxyOf.nodes.indexOf(child)
  33071. }
  33072. insertAfter(exist, add) {
  33073. let existIndex = this.index(exist);
  33074. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33075. existIndex = this.index(exist);
  33076. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33077. let index;
  33078. for (let id in this.indexes) {
  33079. index = this.indexes[id];
  33080. if (existIndex < index) {
  33081. this.indexes[id] = index + nodes.length;
  33082. }
  33083. }
  33084. this.markDirty();
  33085. return this
  33086. }
  33087. insertBefore(exist, add) {
  33088. let existIndex = this.index(exist);
  33089. let type = existIndex === 0 ? 'prepend' : false;
  33090. let nodes = this.normalize(
  33091. add,
  33092. this.proxyOf.nodes[existIndex],
  33093. type
  33094. ).reverse();
  33095. existIndex = this.index(exist);
  33096. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33097. let index;
  33098. for (let id in this.indexes) {
  33099. index = this.indexes[id];
  33100. if (existIndex <= index) {
  33101. this.indexes[id] = index + nodes.length;
  33102. }
  33103. }
  33104. this.markDirty();
  33105. return this
  33106. }
  33107. normalize(nodes, sample) {
  33108. if (typeof nodes === 'string') {
  33109. nodes = cleanSource(parse(nodes).nodes);
  33110. } else if (typeof nodes === 'undefined') {
  33111. nodes = [];
  33112. } else if (Array.isArray(nodes)) {
  33113. nodes = nodes.slice(0);
  33114. for (let i of nodes) {
  33115. if (i.parent) i.parent.removeChild(i, 'ignore');
  33116. }
  33117. } else if (nodes.type === 'root' && this.type !== 'document') {
  33118. nodes = nodes.nodes.slice(0);
  33119. for (let i of nodes) {
  33120. if (i.parent) i.parent.removeChild(i, 'ignore');
  33121. }
  33122. } else if (nodes.type) {
  33123. nodes = [nodes];
  33124. } else if (nodes.prop) {
  33125. if (typeof nodes.value === 'undefined') {
  33126. throw new Error('Value field is missed in node creation')
  33127. } else if (typeof nodes.value !== 'string') {
  33128. nodes.value = String(nodes.value);
  33129. }
  33130. nodes = [new Declaration(nodes)];
  33131. } else if (nodes.selector || nodes.selectors) {
  33132. nodes = [new Rule(nodes)];
  33133. } else if (nodes.name) {
  33134. nodes = [new AtRule(nodes)];
  33135. } else if (nodes.text) {
  33136. nodes = [new Comment(nodes)];
  33137. } else {
  33138. throw new Error('Unknown node type in node creation')
  33139. }
  33140. let processed = nodes.map(i => {
  33141. /* c8 ignore next */
  33142. if (!i[my]) Container.rebuild(i);
  33143. i = i.proxyOf;
  33144. if (i.parent) i.parent.removeChild(i);
  33145. if (i[isClean]) markTreeDirty(i);
  33146. if (!i.raws) i.raws = {};
  33147. if (typeof i.raws.before === 'undefined') {
  33148. if (sample && typeof sample.raws.before !== 'undefined') {
  33149. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33150. }
  33151. }
  33152. i.parent = this.proxyOf;
  33153. return i
  33154. });
  33155. return processed
  33156. }
  33157. prepend(...children) {
  33158. children = children.reverse();
  33159. for (let child of children) {
  33160. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33161. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33162. for (let id in this.indexes) {
  33163. this.indexes[id] = this.indexes[id] + nodes.length;
  33164. }
  33165. }
  33166. this.markDirty();
  33167. return this
  33168. }
  33169. push(child) {
  33170. child.parent = this;
  33171. this.proxyOf.nodes.push(child);
  33172. return this
  33173. }
  33174. removeAll() {
  33175. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33176. this.proxyOf.nodes = [];
  33177. this.markDirty();
  33178. return this
  33179. }
  33180. removeChild(child) {
  33181. child = this.index(child);
  33182. this.proxyOf.nodes[child].parent = undefined;
  33183. this.proxyOf.nodes.splice(child, 1);
  33184. let index;
  33185. for (let id in this.indexes) {
  33186. index = this.indexes[id];
  33187. if (index >= child) {
  33188. this.indexes[id] = index - 1;
  33189. }
  33190. }
  33191. this.markDirty();
  33192. return this
  33193. }
  33194. replaceValues(pattern, opts, callback) {
  33195. if (!callback) {
  33196. callback = opts;
  33197. opts = {};
  33198. }
  33199. this.walkDecls(decl => {
  33200. if (opts.props && !opts.props.includes(decl.prop)) return
  33201. if (opts.fast && !decl.value.includes(opts.fast)) return
  33202. decl.value = decl.value.replace(pattern, callback);
  33203. });
  33204. this.markDirty();
  33205. return this
  33206. }
  33207. some(condition) {
  33208. return this.nodes.some(condition)
  33209. }
  33210. walk(callback) {
  33211. return this.each((child, i) => {
  33212. let result;
  33213. try {
  33214. result = callback(child, i);
  33215. } catch (e) {
  33216. throw child.addToError(e)
  33217. }
  33218. if (result !== false && child.walk) {
  33219. result = child.walk(callback);
  33220. }
  33221. return result
  33222. })
  33223. }
  33224. walkAtRules(name, callback) {
  33225. if (!callback) {
  33226. callback = name;
  33227. return this.walk((child, i) => {
  33228. if (child.type === 'atrule') {
  33229. return callback(child, i)
  33230. }
  33231. })
  33232. }
  33233. if (name instanceof RegExp) {
  33234. return this.walk((child, i) => {
  33235. if (child.type === 'atrule' && name.test(child.name)) {
  33236. return callback(child, i)
  33237. }
  33238. })
  33239. }
  33240. return this.walk((child, i) => {
  33241. if (child.type === 'atrule' && child.name === name) {
  33242. return callback(child, i)
  33243. }
  33244. })
  33245. }
  33246. walkComments(callback) {
  33247. return this.walk((child, i) => {
  33248. if (child.type === 'comment') {
  33249. return callback(child, i)
  33250. }
  33251. })
  33252. }
  33253. walkDecls(prop, callback) {
  33254. if (!callback) {
  33255. callback = prop;
  33256. return this.walk((child, i) => {
  33257. if (child.type === 'decl') {
  33258. return callback(child, i)
  33259. }
  33260. })
  33261. }
  33262. if (prop instanceof RegExp) {
  33263. return this.walk((child, i) => {
  33264. if (child.type === 'decl' && prop.test(child.prop)) {
  33265. return callback(child, i)
  33266. }
  33267. })
  33268. }
  33269. return this.walk((child, i) => {
  33270. if (child.type === 'decl' && child.prop === prop) {
  33271. return callback(child, i)
  33272. }
  33273. })
  33274. }
  33275. walkRules(selector, callback) {
  33276. if (!callback) {
  33277. callback = selector;
  33278. return this.walk((child, i) => {
  33279. if (child.type === 'rule') {
  33280. return callback(child, i)
  33281. }
  33282. })
  33283. }
  33284. if (selector instanceof RegExp) {
  33285. return this.walk((child, i) => {
  33286. if (child.type === 'rule' && selector.test(child.selector)) {
  33287. return callback(child, i)
  33288. }
  33289. })
  33290. }
  33291. return this.walk((child, i) => {
  33292. if (child.type === 'rule' && child.selector === selector) {
  33293. return callback(child, i)
  33294. }
  33295. })
  33296. }
  33297. get first() {
  33298. if (!this.proxyOf.nodes) return undefined
  33299. return this.proxyOf.nodes[0]
  33300. }
  33301. get last() {
  33302. if (!this.proxyOf.nodes) return undefined
  33303. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33304. }
  33305. }
  33306. Container.registerParse = dependant => {
  33307. parse = dependant;
  33308. };
  33309. Container.registerRule = dependant => {
  33310. Rule = dependant;
  33311. };
  33312. Container.registerAtRule = dependant => {
  33313. AtRule = dependant;
  33314. };
  33315. Container.registerRoot = dependant => {
  33316. Root = dependant;
  33317. };
  33318. container$1 = Container;
  33319. Container.default = Container;
  33320. /* c8 ignore start */
  33321. Container.rebuild = node => {
  33322. if (node.type === 'atrule') {
  33323. Object.setPrototypeOf(node, AtRule.prototype);
  33324. } else if (node.type === 'rule') {
  33325. Object.setPrototypeOf(node, Rule.prototype);
  33326. } else if (node.type === 'decl') {
  33327. Object.setPrototypeOf(node, Declaration.prototype);
  33328. } else if (node.type === 'comment') {
  33329. Object.setPrototypeOf(node, Comment.prototype);
  33330. } else if (node.type === 'root') {
  33331. Object.setPrototypeOf(node, Root.prototype);
  33332. }
  33333. node[my] = true;
  33334. if (node.nodes) {
  33335. node.nodes.forEach(child => {
  33336. Container.rebuild(child);
  33337. });
  33338. }
  33339. };
  33340. /* c8 ignore stop */
  33341. return container$1;
  33342. }
  33343. var atRule;
  33344. var hasRequiredAtRule;
  33345. function requireAtRule () {
  33346. if (hasRequiredAtRule) return atRule;
  33347. hasRequiredAtRule = 1;
  33348. let Container = /*@__PURE__*/ requireContainer$1();
  33349. class AtRule extends Container {
  33350. constructor(defaults) {
  33351. super(defaults);
  33352. this.type = 'atrule';
  33353. }
  33354. append(...children) {
  33355. if (!this.proxyOf.nodes) this.nodes = [];
  33356. return super.append(...children)
  33357. }
  33358. prepend(...children) {
  33359. if (!this.proxyOf.nodes) this.nodes = [];
  33360. return super.prepend(...children)
  33361. }
  33362. }
  33363. atRule = AtRule;
  33364. AtRule.default = AtRule;
  33365. Container.registerAtRule(AtRule);
  33366. return atRule;
  33367. }
  33368. var document;
  33369. var hasRequiredDocument;
  33370. function requireDocument () {
  33371. if (hasRequiredDocument) return document;
  33372. hasRequiredDocument = 1;
  33373. let Container = /*@__PURE__*/ requireContainer$1();
  33374. let LazyResult, Processor;
  33375. class Document extends Container {
  33376. constructor(defaults) {
  33377. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  33378. super({ type: 'document', ...defaults });
  33379. if (!this.nodes) {
  33380. this.nodes = [];
  33381. }
  33382. }
  33383. toResult(opts = {}) {
  33384. let lazy = new LazyResult(new Processor(), this, opts);
  33385. return lazy.stringify()
  33386. }
  33387. }
  33388. Document.registerLazyResult = dependant => {
  33389. LazyResult = dependant;
  33390. };
  33391. Document.registerProcessor = dependant => {
  33392. Processor = dependant;
  33393. };
  33394. document = Document;
  33395. Document.default = Document;
  33396. return document;
  33397. }
  33398. var nonSecure;
  33399. var hasRequiredNonSecure;
  33400. function requireNonSecure () {
  33401. if (hasRequiredNonSecure) return nonSecure;
  33402. hasRequiredNonSecure = 1;
  33403. let urlAlphabet =
  33404. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  33405. let customAlphabet = (alphabet, defaultSize = 21) => {
  33406. return (size = defaultSize) => {
  33407. let id = '';
  33408. let i = size;
  33409. while (i--) {
  33410. id += alphabet[(Math.random() * alphabet.length) | 0];
  33411. }
  33412. return id
  33413. }
  33414. };
  33415. let nanoid = (size = 21) => {
  33416. let id = '';
  33417. let i = size;
  33418. while (i--) {
  33419. id += urlAlphabet[(Math.random() * 64) | 0];
  33420. }
  33421. return id
  33422. };
  33423. nonSecure = { nanoid, customAlphabet };
  33424. return nonSecure;
  33425. }
  33426. var sourceMap$1 = {};
  33427. var sourceMapGenerator$1 = {};
  33428. var base64Vlq$1 = {};
  33429. var base64$1 = {};
  33430. /* -*- Mode: js; js-indent-level: 2; -*- */
  33431. var hasRequiredBase64$1;
  33432. function requireBase64$1 () {
  33433. if (hasRequiredBase64$1) return base64$1;
  33434. hasRequiredBase64$1 = 1;
  33435. /*
  33436. * Copyright 2011 Mozilla Foundation and contributors
  33437. * Licensed under the New BSD license. See LICENSE or:
  33438. * http://opensource.org/licenses/BSD-3-Clause
  33439. */
  33440. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  33441. /**
  33442. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  33443. */
  33444. base64$1.encode = function (number) {
  33445. if (0 <= number && number < intToCharMap.length) {
  33446. return intToCharMap[number];
  33447. }
  33448. throw new TypeError("Must be between 0 and 63: " + number);
  33449. };
  33450. /**
  33451. * Decode a single base 64 character code digit to an integer. Returns -1 on
  33452. * failure.
  33453. */
  33454. base64$1.decode = function (charCode) {
  33455. var bigA = 65; // 'A'
  33456. var bigZ = 90; // 'Z'
  33457. var littleA = 97; // 'a'
  33458. var littleZ = 122; // 'z'
  33459. var zero = 48; // '0'
  33460. var nine = 57; // '9'
  33461. var plus = 43; // '+'
  33462. var slash = 47; // '/'
  33463. var littleOffset = 26;
  33464. var numberOffset = 52;
  33465. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  33466. if (bigA <= charCode && charCode <= bigZ) {
  33467. return (charCode - bigA);
  33468. }
  33469. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  33470. if (littleA <= charCode && charCode <= littleZ) {
  33471. return (charCode - littleA + littleOffset);
  33472. }
  33473. // 52 - 61: 0123456789
  33474. if (zero <= charCode && charCode <= nine) {
  33475. return (charCode - zero + numberOffset);
  33476. }
  33477. // 62: +
  33478. if (charCode == plus) {
  33479. return 62;
  33480. }
  33481. // 63: /
  33482. if (charCode == slash) {
  33483. return 63;
  33484. }
  33485. // Invalid base64 digit.
  33486. return -1;
  33487. };
  33488. return base64$1;
  33489. }
  33490. /* -*- Mode: js; js-indent-level: 2; -*- */
  33491. var hasRequiredBase64Vlq$1;
  33492. function requireBase64Vlq$1 () {
  33493. if (hasRequiredBase64Vlq$1) return base64Vlq$1;
  33494. hasRequiredBase64Vlq$1 = 1;
  33495. /*
  33496. * Copyright 2011 Mozilla Foundation and contributors
  33497. * Licensed under the New BSD license. See LICENSE or:
  33498. * http://opensource.org/licenses/BSD-3-Clause
  33499. *
  33500. * Based on the Base 64 VLQ implementation in Closure Compiler:
  33501. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  33502. *
  33503. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  33504. * Redistribution and use in source and binary forms, with or without
  33505. * modification, are permitted provided that the following conditions are
  33506. * met:
  33507. *
  33508. * * Redistributions of source code must retain the above copyright
  33509. * notice, this list of conditions and the following disclaimer.
  33510. * * Redistributions in binary form must reproduce the above
  33511. * copyright notice, this list of conditions and the following
  33512. * disclaimer in the documentation and/or other materials provided
  33513. * with the distribution.
  33514. * * Neither the name of Google Inc. nor the names of its
  33515. * contributors may be used to endorse or promote products derived
  33516. * from this software without specific prior written permission.
  33517. *
  33518. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33519. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33520. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  33521. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33522. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33523. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33524. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33525. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33526. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33527. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33528. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33529. */
  33530. var base64 = /*@__PURE__*/ requireBase64$1();
  33531. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  33532. // length quantities we use in the source map spec, the first bit is the sign,
  33533. // the next four bits are the actual value, and the 6th bit is the
  33534. // continuation bit. The continuation bit tells us whether there are more
  33535. // digits in this value following this digit.
  33536. //
  33537. // Continuation
  33538. // | Sign
  33539. // | |
  33540. // V V
  33541. // 101011
  33542. var VLQ_BASE_SHIFT = 5;
  33543. // binary: 100000
  33544. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  33545. // binary: 011111
  33546. var VLQ_BASE_MASK = VLQ_BASE - 1;
  33547. // binary: 100000
  33548. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  33549. /**
  33550. * Converts from a two-complement value to a value where the sign bit is
  33551. * placed in the least significant bit. For example, as decimals:
  33552. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  33553. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  33554. */
  33555. function toVLQSigned(aValue) {
  33556. return aValue < 0
  33557. ? ((-aValue) << 1) + 1
  33558. : (aValue << 1) + 0;
  33559. }
  33560. /**
  33561. * Converts to a two-complement value from a value where the sign bit is
  33562. * placed in the least significant bit. For example, as decimals:
  33563. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  33564. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  33565. */
  33566. function fromVLQSigned(aValue) {
  33567. var isNegative = (aValue & 1) === 1;
  33568. var shifted = aValue >> 1;
  33569. return isNegative
  33570. ? -shifted
  33571. : shifted;
  33572. }
  33573. /**
  33574. * Returns the base 64 VLQ encoded value.
  33575. */
  33576. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  33577. var encoded = "";
  33578. var digit;
  33579. var vlq = toVLQSigned(aValue);
  33580. do {
  33581. digit = vlq & VLQ_BASE_MASK;
  33582. vlq >>>= VLQ_BASE_SHIFT;
  33583. if (vlq > 0) {
  33584. // There are still more digits in this value, so we must make sure the
  33585. // continuation bit is marked.
  33586. digit |= VLQ_CONTINUATION_BIT;
  33587. }
  33588. encoded += base64.encode(digit);
  33589. } while (vlq > 0);
  33590. return encoded;
  33591. };
  33592. /**
  33593. * Decodes the next base 64 VLQ value from the given string and returns the
  33594. * value and the rest of the string via the out parameter.
  33595. */
  33596. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  33597. var strLen = aStr.length;
  33598. var result = 0;
  33599. var shift = 0;
  33600. var continuation, digit;
  33601. do {
  33602. if (aIndex >= strLen) {
  33603. throw new Error("Expected more digits in base 64 VLQ value.");
  33604. }
  33605. digit = base64.decode(aStr.charCodeAt(aIndex++));
  33606. if (digit === -1) {
  33607. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  33608. }
  33609. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  33610. digit &= VLQ_BASE_MASK;
  33611. result = result + (digit << shift);
  33612. shift += VLQ_BASE_SHIFT;
  33613. } while (continuation);
  33614. aOutParam.value = fromVLQSigned(result);
  33615. aOutParam.rest = aIndex;
  33616. };
  33617. return base64Vlq$1;
  33618. }
  33619. var util$2 = {};
  33620. /* -*- Mode: js; js-indent-level: 2; -*- */
  33621. var hasRequiredUtil$2;
  33622. function requireUtil$2 () {
  33623. if (hasRequiredUtil$2) return util$2;
  33624. hasRequiredUtil$2 = 1;
  33625. (function (exports) {
  33626. /*
  33627. * Copyright 2011 Mozilla Foundation and contributors
  33628. * Licensed under the New BSD license. See LICENSE or:
  33629. * http://opensource.org/licenses/BSD-3-Clause
  33630. */
  33631. /**
  33632. * This is a helper function for getting values from parameter/options
  33633. * objects.
  33634. *
  33635. * @param args The object we are extracting values from
  33636. * @param name The name of the property we are getting.
  33637. * @param defaultValue An optional value to return if the property is missing
  33638. * from the object. If this is not specified and the property is missing, an
  33639. * error will be thrown.
  33640. */
  33641. function getArg(aArgs, aName, aDefaultValue) {
  33642. if (aName in aArgs) {
  33643. return aArgs[aName];
  33644. } else if (arguments.length === 3) {
  33645. return aDefaultValue;
  33646. } else {
  33647. throw new Error('"' + aName + '" is a required argument.');
  33648. }
  33649. }
  33650. exports.getArg = getArg;
  33651. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  33652. var dataUrlRegexp = /^data:.+\,.+$/;
  33653. function urlParse(aUrl) {
  33654. var match = aUrl.match(urlRegexp);
  33655. if (!match) {
  33656. return null;
  33657. }
  33658. return {
  33659. scheme: match[1],
  33660. auth: match[2],
  33661. host: match[3],
  33662. port: match[4],
  33663. path: match[5]
  33664. };
  33665. }
  33666. exports.urlParse = urlParse;
  33667. function urlGenerate(aParsedUrl) {
  33668. var url = '';
  33669. if (aParsedUrl.scheme) {
  33670. url += aParsedUrl.scheme + ':';
  33671. }
  33672. url += '//';
  33673. if (aParsedUrl.auth) {
  33674. url += aParsedUrl.auth + '@';
  33675. }
  33676. if (aParsedUrl.host) {
  33677. url += aParsedUrl.host;
  33678. }
  33679. if (aParsedUrl.port) {
  33680. url += ":" + aParsedUrl.port;
  33681. }
  33682. if (aParsedUrl.path) {
  33683. url += aParsedUrl.path;
  33684. }
  33685. return url;
  33686. }
  33687. exports.urlGenerate = urlGenerate;
  33688. var MAX_CACHED_INPUTS = 32;
  33689. /**
  33690. * Takes some function `f(input) -> result` and returns a memoized version of
  33691. * `f`.
  33692. *
  33693. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  33694. * memoization is a dumb-simple, linear least-recently-used cache.
  33695. */
  33696. function lruMemoize(f) {
  33697. var cache = [];
  33698. return function(input) {
  33699. for (var i = 0; i < cache.length; i++) {
  33700. if (cache[i].input === input) {
  33701. var temp = cache[0];
  33702. cache[0] = cache[i];
  33703. cache[i] = temp;
  33704. return cache[0].result;
  33705. }
  33706. }
  33707. var result = f(input);
  33708. cache.unshift({
  33709. input,
  33710. result,
  33711. });
  33712. if (cache.length > MAX_CACHED_INPUTS) {
  33713. cache.pop();
  33714. }
  33715. return result;
  33716. };
  33717. }
  33718. /**
  33719. * Normalizes a path, or the path portion of a URL:
  33720. *
  33721. * - Replaces consecutive slashes with one slash.
  33722. * - Removes unnecessary '.' parts.
  33723. * - Removes unnecessary '<dir>/..' parts.
  33724. *
  33725. * Based on code in the Node.js 'path' core module.
  33726. *
  33727. * @param aPath The path or url to normalize.
  33728. */
  33729. var normalize = lruMemoize(function normalize(aPath) {
  33730. var path = aPath;
  33731. var url = urlParse(aPath);
  33732. if (url) {
  33733. if (!url.path) {
  33734. return aPath;
  33735. }
  33736. path = url.path;
  33737. }
  33738. var isAbsolute = exports.isAbsolute(path);
  33739. // Split the path into parts between `/` characters. This is much faster than
  33740. // using `.split(/\/+/g)`.
  33741. var parts = [];
  33742. var start = 0;
  33743. var i = 0;
  33744. while (true) {
  33745. start = i;
  33746. i = path.indexOf("/", start);
  33747. if (i === -1) {
  33748. parts.push(path.slice(start));
  33749. break;
  33750. } else {
  33751. parts.push(path.slice(start, i));
  33752. while (i < path.length && path[i] === "/") {
  33753. i++;
  33754. }
  33755. }
  33756. }
  33757. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  33758. part = parts[i];
  33759. if (part === '.') {
  33760. parts.splice(i, 1);
  33761. } else if (part === '..') {
  33762. up++;
  33763. } else if (up > 0) {
  33764. if (part === '') {
  33765. // The first part is blank if the path is absolute. Trying to go
  33766. // above the root is a no-op. Therefore we can remove all '..' parts
  33767. // directly after the root.
  33768. parts.splice(i + 1, up);
  33769. up = 0;
  33770. } else {
  33771. parts.splice(i, 2);
  33772. up--;
  33773. }
  33774. }
  33775. }
  33776. path = parts.join('/');
  33777. if (path === '') {
  33778. path = isAbsolute ? '/' : '.';
  33779. }
  33780. if (url) {
  33781. url.path = path;
  33782. return urlGenerate(url);
  33783. }
  33784. return path;
  33785. });
  33786. exports.normalize = normalize;
  33787. /**
  33788. * Joins two paths/URLs.
  33789. *
  33790. * @param aRoot The root path or URL.
  33791. * @param aPath The path or URL to be joined with the root.
  33792. *
  33793. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  33794. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  33795. * first.
  33796. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  33797. * is updated with the result and aRoot is returned. Otherwise the result
  33798. * is returned.
  33799. * - If aPath is absolute, the result is aPath.
  33800. * - Otherwise the two paths are joined with a slash.
  33801. * - Joining for example 'http://' and 'www.example.com' is also supported.
  33802. */
  33803. function join(aRoot, aPath) {
  33804. if (aRoot === "") {
  33805. aRoot = ".";
  33806. }
  33807. if (aPath === "") {
  33808. aPath = ".";
  33809. }
  33810. var aPathUrl = urlParse(aPath);
  33811. var aRootUrl = urlParse(aRoot);
  33812. if (aRootUrl) {
  33813. aRoot = aRootUrl.path || '/';
  33814. }
  33815. // `join(foo, '//www.example.org')`
  33816. if (aPathUrl && !aPathUrl.scheme) {
  33817. if (aRootUrl) {
  33818. aPathUrl.scheme = aRootUrl.scheme;
  33819. }
  33820. return urlGenerate(aPathUrl);
  33821. }
  33822. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  33823. return aPath;
  33824. }
  33825. // `join('http://', 'www.example.com')`
  33826. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  33827. aRootUrl.host = aPath;
  33828. return urlGenerate(aRootUrl);
  33829. }
  33830. var joined = aPath.charAt(0) === '/'
  33831. ? aPath
  33832. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  33833. if (aRootUrl) {
  33834. aRootUrl.path = joined;
  33835. return urlGenerate(aRootUrl);
  33836. }
  33837. return joined;
  33838. }
  33839. exports.join = join;
  33840. exports.isAbsolute = function (aPath) {
  33841. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  33842. };
  33843. /**
  33844. * Make a path relative to a URL or another path.
  33845. *
  33846. * @param aRoot The root path or URL.
  33847. * @param aPath The path or URL to be made relative to aRoot.
  33848. */
  33849. function relative(aRoot, aPath) {
  33850. if (aRoot === "") {
  33851. aRoot = ".";
  33852. }
  33853. aRoot = aRoot.replace(/\/$/, '');
  33854. // It is possible for the path to be above the root. In this case, simply
  33855. // checking whether the root is a prefix of the path won't work. Instead, we
  33856. // need to remove components from the root one by one, until either we find
  33857. // a prefix that fits, or we run out of components to remove.
  33858. var level = 0;
  33859. while (aPath.indexOf(aRoot + '/') !== 0) {
  33860. var index = aRoot.lastIndexOf("/");
  33861. if (index < 0) {
  33862. return aPath;
  33863. }
  33864. // If the only part of the root that is left is the scheme (i.e. http://,
  33865. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  33866. // have exhausted all components, so the path is not relative to the root.
  33867. aRoot = aRoot.slice(0, index);
  33868. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  33869. return aPath;
  33870. }
  33871. ++level;
  33872. }
  33873. // Make sure we add a "../" for each component we removed from the root.
  33874. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  33875. }
  33876. exports.relative = relative;
  33877. var supportsNullProto = (function () {
  33878. var obj = Object.create(null);
  33879. return !('__proto__' in obj);
  33880. }());
  33881. function identity (s) {
  33882. return s;
  33883. }
  33884. /**
  33885. * Because behavior goes wacky when you set `__proto__` on objects, we
  33886. * have to prefix all the strings in our set with an arbitrary character.
  33887. *
  33888. * See https://github.com/mozilla/source-map/pull/31 and
  33889. * https://github.com/mozilla/source-map/issues/30
  33890. *
  33891. * @param String aStr
  33892. */
  33893. function toSetString(aStr) {
  33894. if (isProtoString(aStr)) {
  33895. return '$' + aStr;
  33896. }
  33897. return aStr;
  33898. }
  33899. exports.toSetString = supportsNullProto ? identity : toSetString;
  33900. function fromSetString(aStr) {
  33901. if (isProtoString(aStr)) {
  33902. return aStr.slice(1);
  33903. }
  33904. return aStr;
  33905. }
  33906. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  33907. function isProtoString(s) {
  33908. if (!s) {
  33909. return false;
  33910. }
  33911. var length = s.length;
  33912. if (length < 9 /* "__proto__".length */) {
  33913. return false;
  33914. }
  33915. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  33916. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  33917. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  33918. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  33919. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  33920. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  33921. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  33922. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  33923. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  33924. return false;
  33925. }
  33926. for (var i = length - 10; i >= 0; i--) {
  33927. if (s.charCodeAt(i) !== 36 /* '$' */) {
  33928. return false;
  33929. }
  33930. }
  33931. return true;
  33932. }
  33933. /**
  33934. * Comparator between two mappings where the original positions are compared.
  33935. *
  33936. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  33937. * mappings with the same original source/line/column, but different generated
  33938. * line and column the same. Useful when searching for a mapping with a
  33939. * stubbed out mapping.
  33940. */
  33941. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  33942. var cmp = strcmp(mappingA.source, mappingB.source);
  33943. if (cmp !== 0) {
  33944. return cmp;
  33945. }
  33946. cmp = mappingA.originalLine - mappingB.originalLine;
  33947. if (cmp !== 0) {
  33948. return cmp;
  33949. }
  33950. cmp = mappingA.originalColumn - mappingB.originalColumn;
  33951. if (cmp !== 0 || onlyCompareOriginal) {
  33952. return cmp;
  33953. }
  33954. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  33955. if (cmp !== 0) {
  33956. return cmp;
  33957. }
  33958. cmp = mappingA.generatedLine - mappingB.generatedLine;
  33959. if (cmp !== 0) {
  33960. return cmp;
  33961. }
  33962. return strcmp(mappingA.name, mappingB.name);
  33963. }
  33964. exports.compareByOriginalPositions = compareByOriginalPositions;
  33965. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  33966. var cmp;
  33967. cmp = mappingA.originalLine - mappingB.originalLine;
  33968. if (cmp !== 0) {
  33969. return cmp;
  33970. }
  33971. cmp = mappingA.originalColumn - mappingB.originalColumn;
  33972. if (cmp !== 0 || onlyCompareOriginal) {
  33973. return cmp;
  33974. }
  33975. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  33976. if (cmp !== 0) {
  33977. return cmp;
  33978. }
  33979. cmp = mappingA.generatedLine - mappingB.generatedLine;
  33980. if (cmp !== 0) {
  33981. return cmp;
  33982. }
  33983. return strcmp(mappingA.name, mappingB.name);
  33984. }
  33985. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  33986. /**
  33987. * Comparator between two mappings with deflated source and name indices where
  33988. * the generated positions are compared.
  33989. *
  33990. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  33991. * mappings with the same generated line and column, but different
  33992. * source/name/original line and column the same. Useful when searching for a
  33993. * mapping with a stubbed out mapping.
  33994. */
  33995. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  33996. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  33997. if (cmp !== 0) {
  33998. return cmp;
  33999. }
  34000. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34001. if (cmp !== 0 || onlyCompareGenerated) {
  34002. return cmp;
  34003. }
  34004. cmp = strcmp(mappingA.source, mappingB.source);
  34005. if (cmp !== 0) {
  34006. return cmp;
  34007. }
  34008. cmp = mappingA.originalLine - mappingB.originalLine;
  34009. if (cmp !== 0) {
  34010. return cmp;
  34011. }
  34012. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34013. if (cmp !== 0) {
  34014. return cmp;
  34015. }
  34016. return strcmp(mappingA.name, mappingB.name);
  34017. }
  34018. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  34019. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  34020. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34021. if (cmp !== 0 || onlyCompareGenerated) {
  34022. return cmp;
  34023. }
  34024. cmp = strcmp(mappingA.source, mappingB.source);
  34025. if (cmp !== 0) {
  34026. return cmp;
  34027. }
  34028. cmp = mappingA.originalLine - mappingB.originalLine;
  34029. if (cmp !== 0) {
  34030. return cmp;
  34031. }
  34032. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34033. if (cmp !== 0) {
  34034. return cmp;
  34035. }
  34036. return strcmp(mappingA.name, mappingB.name);
  34037. }
  34038. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  34039. function strcmp(aStr1, aStr2) {
  34040. if (aStr1 === aStr2) {
  34041. return 0;
  34042. }
  34043. if (aStr1 === null) {
  34044. return 1; // aStr2 !== null
  34045. }
  34046. if (aStr2 === null) {
  34047. return -1; // aStr1 !== null
  34048. }
  34049. if (aStr1 > aStr2) {
  34050. return 1;
  34051. }
  34052. return -1;
  34053. }
  34054. /**
  34055. * Comparator between two mappings with inflated source and name strings where
  34056. * the generated positions are compared.
  34057. */
  34058. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  34059. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  34060. if (cmp !== 0) {
  34061. return cmp;
  34062. }
  34063. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34064. if (cmp !== 0) {
  34065. return cmp;
  34066. }
  34067. cmp = strcmp(mappingA.source, mappingB.source);
  34068. if (cmp !== 0) {
  34069. return cmp;
  34070. }
  34071. cmp = mappingA.originalLine - mappingB.originalLine;
  34072. if (cmp !== 0) {
  34073. return cmp;
  34074. }
  34075. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34076. if (cmp !== 0) {
  34077. return cmp;
  34078. }
  34079. return strcmp(mappingA.name, mappingB.name);
  34080. }
  34081. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  34082. /**
  34083. * Strip any JSON XSSI avoidance prefix from the string (as documented
  34084. * in the source maps specification), and then parse the string as
  34085. * JSON.
  34086. */
  34087. function parseSourceMapInput(str) {
  34088. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  34089. }
  34090. exports.parseSourceMapInput = parseSourceMapInput;
  34091. /**
  34092. * Compute the URL of a source given the the source root, the source's
  34093. * URL, and the source map's URL.
  34094. */
  34095. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  34096. sourceURL = sourceURL || '';
  34097. if (sourceRoot) {
  34098. // This follows what Chrome does.
  34099. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  34100. sourceRoot += '/';
  34101. }
  34102. // The spec says:
  34103. // Line 4: An optional source root, useful for relocating source
  34104. // files on a server or removing repeated values in the
  34105. // “sources” entry. This value is prepended to the individual
  34106. // entries in the “source” field.
  34107. sourceURL = sourceRoot + sourceURL;
  34108. }
  34109. // Historically, SourceMapConsumer did not take the sourceMapURL as
  34110. // a parameter. This mode is still somewhat supported, which is why
  34111. // this code block is conditional. However, it's preferable to pass
  34112. // the source map URL to SourceMapConsumer, so that this function
  34113. // can implement the source URL resolution algorithm as outlined in
  34114. // the spec. This block is basically the equivalent of:
  34115. // new URL(sourceURL, sourceMapURL).toString()
  34116. // ... except it avoids using URL, which wasn't available in the
  34117. // older releases of node still supported by this library.
  34118. //
  34119. // The spec says:
  34120. // If the sources are not absolute URLs after prepending of the
  34121. // “sourceRoot”, the sources are resolved relative to the
  34122. // SourceMap (like resolving script src in a html document).
  34123. if (sourceMapURL) {
  34124. var parsed = urlParse(sourceMapURL);
  34125. if (!parsed) {
  34126. throw new Error("sourceMapURL could not be parsed");
  34127. }
  34128. if (parsed.path) {
  34129. // Strip the last path component, but keep the "/".
  34130. var index = parsed.path.lastIndexOf('/');
  34131. if (index >= 0) {
  34132. parsed.path = parsed.path.substring(0, index + 1);
  34133. }
  34134. }
  34135. sourceURL = join(urlGenerate(parsed), sourceURL);
  34136. }
  34137. return normalize(sourceURL);
  34138. }
  34139. exports.computeSourceURL = computeSourceURL;
  34140. } (util$2));
  34141. return util$2;
  34142. }
  34143. var arraySet$1 = {};
  34144. /* -*- Mode: js; js-indent-level: 2; -*- */
  34145. var hasRequiredArraySet$1;
  34146. function requireArraySet$1 () {
  34147. if (hasRequiredArraySet$1) return arraySet$1;
  34148. hasRequiredArraySet$1 = 1;
  34149. /*
  34150. * Copyright 2011 Mozilla Foundation and contributors
  34151. * Licensed under the New BSD license. See LICENSE or:
  34152. * http://opensource.org/licenses/BSD-3-Clause
  34153. */
  34154. var util = /*@__PURE__*/ requireUtil$2();
  34155. var has = Object.prototype.hasOwnProperty;
  34156. var hasNativeMap = typeof Map !== "undefined";
  34157. /**
  34158. * A data structure which is a combination of an array and a set. Adding a new
  34159. * member is O(1), testing for membership is O(1), and finding the index of an
  34160. * element is O(1). Removing elements from the set is not supported. Only
  34161. * strings are supported for membership.
  34162. */
  34163. function ArraySet() {
  34164. this._array = [];
  34165. this._set = hasNativeMap ? new Map() : Object.create(null);
  34166. }
  34167. /**
  34168. * Static method for creating ArraySet instances from an existing array.
  34169. */
  34170. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  34171. var set = new ArraySet();
  34172. for (var i = 0, len = aArray.length; i < len; i++) {
  34173. set.add(aArray[i], aAllowDuplicates);
  34174. }
  34175. return set;
  34176. };
  34177. /**
  34178. * Return how many unique items are in this ArraySet. If duplicates have been
  34179. * added, than those do not count towards the size.
  34180. *
  34181. * @returns Number
  34182. */
  34183. ArraySet.prototype.size = function ArraySet_size() {
  34184. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  34185. };
  34186. /**
  34187. * Add the given string to this set.
  34188. *
  34189. * @param String aStr
  34190. */
  34191. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  34192. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  34193. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  34194. var idx = this._array.length;
  34195. if (!isDuplicate || aAllowDuplicates) {
  34196. this._array.push(aStr);
  34197. }
  34198. if (!isDuplicate) {
  34199. if (hasNativeMap) {
  34200. this._set.set(aStr, idx);
  34201. } else {
  34202. this._set[sStr] = idx;
  34203. }
  34204. }
  34205. };
  34206. /**
  34207. * Is the given string a member of this set?
  34208. *
  34209. * @param String aStr
  34210. */
  34211. ArraySet.prototype.has = function ArraySet_has(aStr) {
  34212. if (hasNativeMap) {
  34213. return this._set.has(aStr);
  34214. } else {
  34215. var sStr = util.toSetString(aStr);
  34216. return has.call(this._set, sStr);
  34217. }
  34218. };
  34219. /**
  34220. * What is the index of the given string in the array?
  34221. *
  34222. * @param String aStr
  34223. */
  34224. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  34225. if (hasNativeMap) {
  34226. var idx = this._set.get(aStr);
  34227. if (idx >= 0) {
  34228. return idx;
  34229. }
  34230. } else {
  34231. var sStr = util.toSetString(aStr);
  34232. if (has.call(this._set, sStr)) {
  34233. return this._set[sStr];
  34234. }
  34235. }
  34236. throw new Error('"' + aStr + '" is not in the set.');
  34237. };
  34238. /**
  34239. * What is the element at the given index?
  34240. *
  34241. * @param Number aIdx
  34242. */
  34243. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  34244. if (aIdx >= 0 && aIdx < this._array.length) {
  34245. return this._array[aIdx];
  34246. }
  34247. throw new Error('No element indexed by ' + aIdx);
  34248. };
  34249. /**
  34250. * Returns the array representation of this set (which has the proper indices
  34251. * indicated by indexOf). Note that this is a copy of the internal array used
  34252. * for storing the members so that no one can mess with internal state.
  34253. */
  34254. ArraySet.prototype.toArray = function ArraySet_toArray() {
  34255. return this._array.slice();
  34256. };
  34257. arraySet$1.ArraySet = ArraySet;
  34258. return arraySet$1;
  34259. }
  34260. var mappingList$1 = {};
  34261. /* -*- Mode: js; js-indent-level: 2; -*- */
  34262. var hasRequiredMappingList$1;
  34263. function requireMappingList$1 () {
  34264. if (hasRequiredMappingList$1) return mappingList$1;
  34265. hasRequiredMappingList$1 = 1;
  34266. /*
  34267. * Copyright 2014 Mozilla Foundation and contributors
  34268. * Licensed under the New BSD license. See LICENSE or:
  34269. * http://opensource.org/licenses/BSD-3-Clause
  34270. */
  34271. var util = /*@__PURE__*/ requireUtil$2();
  34272. /**
  34273. * Determine whether mappingB is after mappingA with respect to generated
  34274. * position.
  34275. */
  34276. function generatedPositionAfter(mappingA, mappingB) {
  34277. // Optimized for most common case
  34278. var lineA = mappingA.generatedLine;
  34279. var lineB = mappingB.generatedLine;
  34280. var columnA = mappingA.generatedColumn;
  34281. var columnB = mappingB.generatedColumn;
  34282. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  34283. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  34284. }
  34285. /**
  34286. * A data structure to provide a sorted view of accumulated mappings in a
  34287. * performance conscious manner. It trades a neglibable overhead in general
  34288. * case for a large speedup in case of mappings being added in order.
  34289. */
  34290. function MappingList() {
  34291. this._array = [];
  34292. this._sorted = true;
  34293. // Serves as infimum
  34294. this._last = {generatedLine: -1, generatedColumn: 0};
  34295. }
  34296. /**
  34297. * Iterate through internal items. This method takes the same arguments that
  34298. * `Array.prototype.forEach` takes.
  34299. *
  34300. * NOTE: The order of the mappings is NOT guaranteed.
  34301. */
  34302. MappingList.prototype.unsortedForEach =
  34303. function MappingList_forEach(aCallback, aThisArg) {
  34304. this._array.forEach(aCallback, aThisArg);
  34305. };
  34306. /**
  34307. * Add the given source mapping.
  34308. *
  34309. * @param Object aMapping
  34310. */
  34311. MappingList.prototype.add = function MappingList_add(aMapping) {
  34312. if (generatedPositionAfter(this._last, aMapping)) {
  34313. this._last = aMapping;
  34314. this._array.push(aMapping);
  34315. } else {
  34316. this._sorted = false;
  34317. this._array.push(aMapping);
  34318. }
  34319. };
  34320. /**
  34321. * Returns the flat, sorted array of mappings. The mappings are sorted by
  34322. * generated position.
  34323. *
  34324. * WARNING: This method returns internal data without copying, for
  34325. * performance. The return value must NOT be mutated, and should be treated as
  34326. * an immutable borrow. If you want to take ownership, you must make your own
  34327. * copy.
  34328. */
  34329. MappingList.prototype.toArray = function MappingList_toArray() {
  34330. if (!this._sorted) {
  34331. this._array.sort(util.compareByGeneratedPositionsInflated);
  34332. this._sorted = true;
  34333. }
  34334. return this._array;
  34335. };
  34336. mappingList$1.MappingList = MappingList;
  34337. return mappingList$1;
  34338. }
  34339. /* -*- Mode: js; js-indent-level: 2; -*- */
  34340. var hasRequiredSourceMapGenerator$1;
  34341. function requireSourceMapGenerator$1 () {
  34342. if (hasRequiredSourceMapGenerator$1) return sourceMapGenerator$1;
  34343. hasRequiredSourceMapGenerator$1 = 1;
  34344. /*
  34345. * Copyright 2011 Mozilla Foundation and contributors
  34346. * Licensed under the New BSD license. See LICENSE or:
  34347. * http://opensource.org/licenses/BSD-3-Clause
  34348. */
  34349. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  34350. var util = /*@__PURE__*/ requireUtil$2();
  34351. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  34352. var MappingList = /*@__PURE__*/ requireMappingList$1().MappingList;
  34353. /**
  34354. * An instance of the SourceMapGenerator represents a source map which is
  34355. * being built incrementally. You may pass an object with the following
  34356. * properties:
  34357. *
  34358. * - file: The filename of the generated source.
  34359. * - sourceRoot: A root for all relative URLs in this source map.
  34360. */
  34361. function SourceMapGenerator(aArgs) {
  34362. if (!aArgs) {
  34363. aArgs = {};
  34364. }
  34365. this._file = util.getArg(aArgs, 'file', null);
  34366. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  34367. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  34368. this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
  34369. this._sources = new ArraySet();
  34370. this._names = new ArraySet();
  34371. this._mappings = new MappingList();
  34372. this._sourcesContents = null;
  34373. }
  34374. SourceMapGenerator.prototype._version = 3;
  34375. /**
  34376. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  34377. *
  34378. * @param aSourceMapConsumer The SourceMap.
  34379. */
  34380. SourceMapGenerator.fromSourceMap =
  34381. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  34382. var sourceRoot = aSourceMapConsumer.sourceRoot;
  34383. var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
  34384. file: aSourceMapConsumer.file,
  34385. sourceRoot: sourceRoot
  34386. }));
  34387. aSourceMapConsumer.eachMapping(function (mapping) {
  34388. var newMapping = {
  34389. generated: {
  34390. line: mapping.generatedLine,
  34391. column: mapping.generatedColumn
  34392. }
  34393. };
  34394. if (mapping.source != null) {
  34395. newMapping.source = mapping.source;
  34396. if (sourceRoot != null) {
  34397. newMapping.source = util.relative(sourceRoot, newMapping.source);
  34398. }
  34399. newMapping.original = {
  34400. line: mapping.originalLine,
  34401. column: mapping.originalColumn
  34402. };
  34403. if (mapping.name != null) {
  34404. newMapping.name = mapping.name;
  34405. }
  34406. }
  34407. generator.addMapping(newMapping);
  34408. });
  34409. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  34410. var sourceRelative = sourceFile;
  34411. if (sourceRoot !== null) {
  34412. sourceRelative = util.relative(sourceRoot, sourceFile);
  34413. }
  34414. if (!generator._sources.has(sourceRelative)) {
  34415. generator._sources.add(sourceRelative);
  34416. }
  34417. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  34418. if (content != null) {
  34419. generator.setSourceContent(sourceFile, content);
  34420. }
  34421. });
  34422. return generator;
  34423. };
  34424. /**
  34425. * Add a single mapping from original source line and column to the generated
  34426. * source's line and column for this source map being created. The mapping
  34427. * object should have the following properties:
  34428. *
  34429. * - generated: An object with the generated line and column positions.
  34430. * - original: An object with the original line and column positions.
  34431. * - source: The original source file (relative to the sourceRoot).
  34432. * - name: An optional original token name for this mapping.
  34433. */
  34434. SourceMapGenerator.prototype.addMapping =
  34435. function SourceMapGenerator_addMapping(aArgs) {
  34436. var generated = util.getArg(aArgs, 'generated');
  34437. var original = util.getArg(aArgs, 'original', null);
  34438. var source = util.getArg(aArgs, 'source', null);
  34439. var name = util.getArg(aArgs, 'name', null);
  34440. if (!this._skipValidation) {
  34441. if (this._validateMapping(generated, original, source, name) === false) {
  34442. return;
  34443. }
  34444. }
  34445. if (source != null) {
  34446. source = String(source);
  34447. if (!this._sources.has(source)) {
  34448. this._sources.add(source);
  34449. }
  34450. }
  34451. if (name != null) {
  34452. name = String(name);
  34453. if (!this._names.has(name)) {
  34454. this._names.add(name);
  34455. }
  34456. }
  34457. this._mappings.add({
  34458. generatedLine: generated.line,
  34459. generatedColumn: generated.column,
  34460. originalLine: original != null && original.line,
  34461. originalColumn: original != null && original.column,
  34462. source: source,
  34463. name: name
  34464. });
  34465. };
  34466. /**
  34467. * Set the source content for a source file.
  34468. */
  34469. SourceMapGenerator.prototype.setSourceContent =
  34470. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  34471. var source = aSourceFile;
  34472. if (this._sourceRoot != null) {
  34473. source = util.relative(this._sourceRoot, source);
  34474. }
  34475. if (aSourceContent != null) {
  34476. // Add the source content to the _sourcesContents map.
  34477. // Create a new _sourcesContents map if the property is null.
  34478. if (!this._sourcesContents) {
  34479. this._sourcesContents = Object.create(null);
  34480. }
  34481. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  34482. } else if (this._sourcesContents) {
  34483. // Remove the source file from the _sourcesContents map.
  34484. // If the _sourcesContents map is empty, set the property to null.
  34485. delete this._sourcesContents[util.toSetString(source)];
  34486. if (Object.keys(this._sourcesContents).length === 0) {
  34487. this._sourcesContents = null;
  34488. }
  34489. }
  34490. };
  34491. /**
  34492. * Applies the mappings of a sub-source-map for a specific source file to the
  34493. * source map being generated. Each mapping to the supplied source file is
  34494. * rewritten using the supplied source map. Note: The resolution for the
  34495. * resulting mappings is the minimium of this map and the supplied map.
  34496. *
  34497. * @param aSourceMapConsumer The source map to be applied.
  34498. * @param aSourceFile Optional. The filename of the source file.
  34499. * If omitted, SourceMapConsumer's file property will be used.
  34500. * @param aSourceMapPath Optional. The dirname of the path to the source map
  34501. * to be applied. If relative, it is relative to the SourceMapConsumer.
  34502. * This parameter is needed when the two source maps aren't in the same
  34503. * directory, and the source map to be applied contains relative source
  34504. * paths. If so, those relative source paths need to be rewritten
  34505. * relative to the SourceMapGenerator.
  34506. */
  34507. SourceMapGenerator.prototype.applySourceMap =
  34508. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  34509. var sourceFile = aSourceFile;
  34510. // If aSourceFile is omitted, we will use the file property of the SourceMap
  34511. if (aSourceFile == null) {
  34512. if (aSourceMapConsumer.file == null) {
  34513. throw new Error(
  34514. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  34515. 'or the source map\'s "file" property. Both were omitted.'
  34516. );
  34517. }
  34518. sourceFile = aSourceMapConsumer.file;
  34519. }
  34520. var sourceRoot = this._sourceRoot;
  34521. // Make "sourceFile" relative if an absolute Url is passed.
  34522. if (sourceRoot != null) {
  34523. sourceFile = util.relative(sourceRoot, sourceFile);
  34524. }
  34525. // Applying the SourceMap can add and remove items from the sources and
  34526. // the names array.
  34527. var newSources = new ArraySet();
  34528. var newNames = new ArraySet();
  34529. // Find mappings for the "sourceFile"
  34530. this._mappings.unsortedForEach(function (mapping) {
  34531. if (mapping.source === sourceFile && mapping.originalLine != null) {
  34532. // Check if it can be mapped by the source map, then update the mapping.
  34533. var original = aSourceMapConsumer.originalPositionFor({
  34534. line: mapping.originalLine,
  34535. column: mapping.originalColumn
  34536. });
  34537. if (original.source != null) {
  34538. // Copy mapping
  34539. mapping.source = original.source;
  34540. if (aSourceMapPath != null) {
  34541. mapping.source = util.join(aSourceMapPath, mapping.source);
  34542. }
  34543. if (sourceRoot != null) {
  34544. mapping.source = util.relative(sourceRoot, mapping.source);
  34545. }
  34546. mapping.originalLine = original.line;
  34547. mapping.originalColumn = original.column;
  34548. if (original.name != null) {
  34549. mapping.name = original.name;
  34550. }
  34551. }
  34552. }
  34553. var source = mapping.source;
  34554. if (source != null && !newSources.has(source)) {
  34555. newSources.add(source);
  34556. }
  34557. var name = mapping.name;
  34558. if (name != null && !newNames.has(name)) {
  34559. newNames.add(name);
  34560. }
  34561. }, this);
  34562. this._sources = newSources;
  34563. this._names = newNames;
  34564. // Copy sourcesContents of applied map.
  34565. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  34566. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  34567. if (content != null) {
  34568. if (aSourceMapPath != null) {
  34569. sourceFile = util.join(aSourceMapPath, sourceFile);
  34570. }
  34571. if (sourceRoot != null) {
  34572. sourceFile = util.relative(sourceRoot, sourceFile);
  34573. }
  34574. this.setSourceContent(sourceFile, content);
  34575. }
  34576. }, this);
  34577. };
  34578. /**
  34579. * A mapping can have one of the three levels of data:
  34580. *
  34581. * 1. Just the generated position.
  34582. * 2. The Generated position, original position, and original source.
  34583. * 3. Generated and original position, original source, as well as a name
  34584. * token.
  34585. *
  34586. * To maintain consistency, we validate that any new mapping being added falls
  34587. * in to one of these categories.
  34588. */
  34589. SourceMapGenerator.prototype._validateMapping =
  34590. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  34591. aName) {
  34592. // When aOriginal is truthy but has empty values for .line and .column,
  34593. // it is most likely a programmer error. In this case we throw a very
  34594. // specific error message to try to guide them the right way.
  34595. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  34596. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  34597. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  34598. 'the original mapping entirely and only map the generated position. If so, pass ' +
  34599. 'null for the original mapping instead of an object with empty or null values.';
  34600. if (this._ignoreInvalidMapping) {
  34601. if (typeof console !== 'undefined' && console.warn) {
  34602. console.warn(message);
  34603. }
  34604. return false;
  34605. } else {
  34606. throw new Error(message);
  34607. }
  34608. }
  34609. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  34610. && aGenerated.line > 0 && aGenerated.column >= 0
  34611. && !aOriginal && !aSource && !aName) {
  34612. // Case 1.
  34613. return;
  34614. }
  34615. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  34616. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  34617. && aGenerated.line > 0 && aGenerated.column >= 0
  34618. && aOriginal.line > 0 && aOriginal.column >= 0
  34619. && aSource) {
  34620. // Cases 2 and 3.
  34621. return;
  34622. }
  34623. else {
  34624. var message = 'Invalid mapping: ' + JSON.stringify({
  34625. generated: aGenerated,
  34626. source: aSource,
  34627. original: aOriginal,
  34628. name: aName
  34629. });
  34630. if (this._ignoreInvalidMapping) {
  34631. if (typeof console !== 'undefined' && console.warn) {
  34632. console.warn(message);
  34633. }
  34634. return false;
  34635. } else {
  34636. throw new Error(message)
  34637. }
  34638. }
  34639. };
  34640. /**
  34641. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  34642. * specified by the source map format.
  34643. */
  34644. SourceMapGenerator.prototype._serializeMappings =
  34645. function SourceMapGenerator_serializeMappings() {
  34646. var previousGeneratedColumn = 0;
  34647. var previousGeneratedLine = 1;
  34648. var previousOriginalColumn = 0;
  34649. var previousOriginalLine = 0;
  34650. var previousName = 0;
  34651. var previousSource = 0;
  34652. var result = '';
  34653. var next;
  34654. var mapping;
  34655. var nameIdx;
  34656. var sourceIdx;
  34657. var mappings = this._mappings.toArray();
  34658. for (var i = 0, len = mappings.length; i < len; i++) {
  34659. mapping = mappings[i];
  34660. next = '';
  34661. if (mapping.generatedLine !== previousGeneratedLine) {
  34662. previousGeneratedColumn = 0;
  34663. while (mapping.generatedLine !== previousGeneratedLine) {
  34664. next += ';';
  34665. previousGeneratedLine++;
  34666. }
  34667. }
  34668. else {
  34669. if (i > 0) {
  34670. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  34671. continue;
  34672. }
  34673. next += ',';
  34674. }
  34675. }
  34676. next += base64VLQ.encode(mapping.generatedColumn
  34677. - previousGeneratedColumn);
  34678. previousGeneratedColumn = mapping.generatedColumn;
  34679. if (mapping.source != null) {
  34680. sourceIdx = this._sources.indexOf(mapping.source);
  34681. next += base64VLQ.encode(sourceIdx - previousSource);
  34682. previousSource = sourceIdx;
  34683. // lines are stored 0-based in SourceMap spec version 3
  34684. next += base64VLQ.encode(mapping.originalLine - 1
  34685. - previousOriginalLine);
  34686. previousOriginalLine = mapping.originalLine - 1;
  34687. next += base64VLQ.encode(mapping.originalColumn
  34688. - previousOriginalColumn);
  34689. previousOriginalColumn = mapping.originalColumn;
  34690. if (mapping.name != null) {
  34691. nameIdx = this._names.indexOf(mapping.name);
  34692. next += base64VLQ.encode(nameIdx - previousName);
  34693. previousName = nameIdx;
  34694. }
  34695. }
  34696. result += next;
  34697. }
  34698. return result;
  34699. };
  34700. SourceMapGenerator.prototype._generateSourcesContent =
  34701. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  34702. return aSources.map(function (source) {
  34703. if (!this._sourcesContents) {
  34704. return null;
  34705. }
  34706. if (aSourceRoot != null) {
  34707. source = util.relative(aSourceRoot, source);
  34708. }
  34709. var key = util.toSetString(source);
  34710. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  34711. ? this._sourcesContents[key]
  34712. : null;
  34713. }, this);
  34714. };
  34715. /**
  34716. * Externalize the source map.
  34717. */
  34718. SourceMapGenerator.prototype.toJSON =
  34719. function SourceMapGenerator_toJSON() {
  34720. var map = {
  34721. version: this._version,
  34722. sources: this._sources.toArray(),
  34723. names: this._names.toArray(),
  34724. mappings: this._serializeMappings()
  34725. };
  34726. if (this._file != null) {
  34727. map.file = this._file;
  34728. }
  34729. if (this._sourceRoot != null) {
  34730. map.sourceRoot = this._sourceRoot;
  34731. }
  34732. if (this._sourcesContents) {
  34733. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  34734. }
  34735. return map;
  34736. };
  34737. /**
  34738. * Render the source map being generated to a string.
  34739. */
  34740. SourceMapGenerator.prototype.toString =
  34741. function SourceMapGenerator_toString() {
  34742. return JSON.stringify(this.toJSON());
  34743. };
  34744. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator;
  34745. return sourceMapGenerator$1;
  34746. }
  34747. var sourceMapConsumer$1 = {};
  34748. var binarySearch$1 = {};
  34749. /* -*- Mode: js; js-indent-level: 2; -*- */
  34750. var hasRequiredBinarySearch$1;
  34751. function requireBinarySearch$1 () {
  34752. if (hasRequiredBinarySearch$1) return binarySearch$1;
  34753. hasRequiredBinarySearch$1 = 1;
  34754. (function (exports) {
  34755. /*
  34756. * Copyright 2011 Mozilla Foundation and contributors
  34757. * Licensed under the New BSD license. See LICENSE or:
  34758. * http://opensource.org/licenses/BSD-3-Clause
  34759. */
  34760. exports.GREATEST_LOWER_BOUND = 1;
  34761. exports.LEAST_UPPER_BOUND = 2;
  34762. /**
  34763. * Recursive implementation of binary search.
  34764. *
  34765. * @param aLow Indices here and lower do not contain the needle.
  34766. * @param aHigh Indices here and higher do not contain the needle.
  34767. * @param aNeedle The element being searched for.
  34768. * @param aHaystack The non-empty array being searched.
  34769. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  34770. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  34771. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  34772. * closest element that is smaller than or greater than the one we are
  34773. * searching for, respectively, if the exact element cannot be found.
  34774. */
  34775. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  34776. // This function terminates when one of the following is true:
  34777. //
  34778. // 1. We find the exact element we are looking for.
  34779. //
  34780. // 2. We did not find the exact element, but we can return the index of
  34781. // the next-closest element.
  34782. //
  34783. // 3. We did not find the exact element, and there is no next-closest
  34784. // element than the one we are searching for, so we return -1.
  34785. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  34786. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  34787. if (cmp === 0) {
  34788. // Found the element we are looking for.
  34789. return mid;
  34790. }
  34791. else if (cmp > 0) {
  34792. // Our needle is greater than aHaystack[mid].
  34793. if (aHigh - mid > 1) {
  34794. // The element is in the upper half.
  34795. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  34796. }
  34797. // The exact needle element was not found in this haystack. Determine if
  34798. // we are in termination case (3) or (2) and return the appropriate thing.
  34799. if (aBias == exports.LEAST_UPPER_BOUND) {
  34800. return aHigh < aHaystack.length ? aHigh : -1;
  34801. } else {
  34802. return mid;
  34803. }
  34804. }
  34805. else {
  34806. // Our needle is less than aHaystack[mid].
  34807. if (mid - aLow > 1) {
  34808. // The element is in the lower half.
  34809. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  34810. }
  34811. // we are in termination case (3) or (2) and return the appropriate thing.
  34812. if (aBias == exports.LEAST_UPPER_BOUND) {
  34813. return mid;
  34814. } else {
  34815. return aLow < 0 ? -1 : aLow;
  34816. }
  34817. }
  34818. }
  34819. /**
  34820. * This is an implementation of binary search which will always try and return
  34821. * the index of the closest element if there is no exact hit. This is because
  34822. * mappings between original and generated line/col pairs are single points,
  34823. * and there is an implicit region between each of them, so a miss just means
  34824. * that you aren't on the very start of a region.
  34825. *
  34826. * @param aNeedle The element you are looking for.
  34827. * @param aHaystack The array that is being searched.
  34828. * @param aCompare A function which takes the needle and an element in the
  34829. * array and returns -1, 0, or 1 depending on whether the needle is less
  34830. * than, equal to, or greater than the element, respectively.
  34831. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  34832. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  34833. * closest element that is smaller than or greater than the one we are
  34834. * searching for, respectively, if the exact element cannot be found.
  34835. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  34836. */
  34837. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  34838. if (aHaystack.length === 0) {
  34839. return -1;
  34840. }
  34841. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  34842. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  34843. if (index < 0) {
  34844. return -1;
  34845. }
  34846. // We have found either the exact element, or the next-closest element than
  34847. // the one we are searching for. However, there may be more than one such
  34848. // element. Make sure we always return the smallest of these.
  34849. while (index - 1 >= 0) {
  34850. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  34851. break;
  34852. }
  34853. --index;
  34854. }
  34855. return index;
  34856. };
  34857. } (binarySearch$1));
  34858. return binarySearch$1;
  34859. }
  34860. var quickSort$1 = {};
  34861. /* -*- Mode: js; js-indent-level: 2; -*- */
  34862. var hasRequiredQuickSort$1;
  34863. function requireQuickSort$1 () {
  34864. if (hasRequiredQuickSort$1) return quickSort$1;
  34865. hasRequiredQuickSort$1 = 1;
  34866. /*
  34867. * Copyright 2011 Mozilla Foundation and contributors
  34868. * Licensed under the New BSD license. See LICENSE or:
  34869. * http://opensource.org/licenses/BSD-3-Clause
  34870. */
  34871. // It turns out that some (most?) JavaScript engines don't self-host
  34872. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  34873. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  34874. // custom comparator function, calling back and forth between the VM's C++ and
  34875. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  34876. // worse generated code for the comparator function than would be optimal. In
  34877. // fact, when sorting with a comparator, these costs outweigh the benefits of
  34878. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  34879. // a ~3500ms mean speed-up in `bench/bench.html`.
  34880. function SortTemplate(comparator) {
  34881. /**
  34882. * Swap the elements indexed by `x` and `y` in the array `ary`.
  34883. *
  34884. * @param {Array} ary
  34885. * The array.
  34886. * @param {Number} x
  34887. * The index of the first item.
  34888. * @param {Number} y
  34889. * The index of the second item.
  34890. */
  34891. function swap(ary, x, y) {
  34892. var temp = ary[x];
  34893. ary[x] = ary[y];
  34894. ary[y] = temp;
  34895. }
  34896. /**
  34897. * Returns a random integer within the range `low .. high` inclusive.
  34898. *
  34899. * @param {Number} low
  34900. * The lower bound on the range.
  34901. * @param {Number} high
  34902. * The upper bound on the range.
  34903. */
  34904. function randomIntInRange(low, high) {
  34905. return Math.round(low + (Math.random() * (high - low)));
  34906. }
  34907. /**
  34908. * The Quick Sort algorithm.
  34909. *
  34910. * @param {Array} ary
  34911. * An array to sort.
  34912. * @param {function} comparator
  34913. * Function to use to compare two items.
  34914. * @param {Number} p
  34915. * Start index of the array
  34916. * @param {Number} r
  34917. * End index of the array
  34918. */
  34919. function doQuickSort(ary, comparator, p, r) {
  34920. // If our lower bound is less than our upper bound, we (1) partition the
  34921. // array into two pieces and (2) recurse on each half. If it is not, this is
  34922. // the empty array and our base case.
  34923. if (p < r) {
  34924. // (1) Partitioning.
  34925. //
  34926. // The partitioning chooses a pivot between `p` and `r` and moves all
  34927. // elements that are less than or equal to the pivot to the before it, and
  34928. // all the elements that are greater than it after it. The effect is that
  34929. // once partition is done, the pivot is in the exact place it will be when
  34930. // the array is put in sorted order, and it will not need to be moved
  34931. // again. This runs in O(n) time.
  34932. // Always choose a random pivot so that an input array which is reverse
  34933. // sorted does not cause O(n^2) running time.
  34934. var pivotIndex = randomIntInRange(p, r);
  34935. var i = p - 1;
  34936. swap(ary, pivotIndex, r);
  34937. var pivot = ary[r];
  34938. // Immediately after `j` is incremented in this loop, the following hold
  34939. // true:
  34940. //
  34941. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  34942. //
  34943. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  34944. for (var j = p; j < r; j++) {
  34945. if (comparator(ary[j], pivot, false) <= 0) {
  34946. i += 1;
  34947. swap(ary, i, j);
  34948. }
  34949. }
  34950. swap(ary, i + 1, j);
  34951. var q = i + 1;
  34952. // (2) Recurse on each half.
  34953. doQuickSort(ary, comparator, p, q - 1);
  34954. doQuickSort(ary, comparator, q + 1, r);
  34955. }
  34956. }
  34957. return doQuickSort;
  34958. }
  34959. function cloneSort(comparator) {
  34960. let template = SortTemplate.toString();
  34961. let templateFn = new Function(`return ${template}`)();
  34962. return templateFn(comparator);
  34963. }
  34964. /**
  34965. * Sort the given array in-place with the given comparator function.
  34966. *
  34967. * @param {Array} ary
  34968. * An array to sort.
  34969. * @param {function} comparator
  34970. * Function to use to compare two items.
  34971. */
  34972. let sortCache = new WeakMap();
  34973. quickSort$1.quickSort = function (ary, comparator, start = 0) {
  34974. let doQuickSort = sortCache.get(comparator);
  34975. if (doQuickSort === void 0) {
  34976. doQuickSort = cloneSort(comparator);
  34977. sortCache.set(comparator, doQuickSort);
  34978. }
  34979. doQuickSort(ary, comparator, start, ary.length - 1);
  34980. };
  34981. return quickSort$1;
  34982. }
  34983. /* -*- Mode: js; js-indent-level: 2; -*- */
  34984. var hasRequiredSourceMapConsumer$1;
  34985. function requireSourceMapConsumer$1 () {
  34986. if (hasRequiredSourceMapConsumer$1) return sourceMapConsumer$1;
  34987. hasRequiredSourceMapConsumer$1 = 1;
  34988. /*
  34989. * Copyright 2011 Mozilla Foundation and contributors
  34990. * Licensed under the New BSD license. See LICENSE or:
  34991. * http://opensource.org/licenses/BSD-3-Clause
  34992. */
  34993. var util = /*@__PURE__*/ requireUtil$2();
  34994. var binarySearch = /*@__PURE__*/ requireBinarySearch$1();
  34995. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  34996. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  34997. var quickSort = /*@__PURE__*/ requireQuickSort$1().quickSort;
  34998. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  34999. var sourceMap = aSourceMap;
  35000. if (typeof aSourceMap === 'string') {
  35001. sourceMap = util.parseSourceMapInput(aSourceMap);
  35002. }
  35003. return sourceMap.sections != null
  35004. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  35005. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  35006. }
  35007. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  35008. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  35009. };
  35010. /**
  35011. * The version of the source mapping spec that we are consuming.
  35012. */
  35013. SourceMapConsumer.prototype._version = 3;
  35014. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  35015. // parsed mapping coordinates from the source map's "mappings" attribute. They
  35016. // are lazily instantiated, accessed via the `_generatedMappings` and
  35017. // `_originalMappings` getters respectively, and we only parse the mappings
  35018. // and create these arrays once queried for a source location. We jump through
  35019. // these hoops because there can be many thousands of mappings, and parsing
  35020. // them is expensive, so we only want to do it if we must.
  35021. //
  35022. // Each object in the arrays is of the form:
  35023. //
  35024. // {
  35025. // generatedLine: The line number in the generated code,
  35026. // generatedColumn: The column number in the generated code,
  35027. // source: The path to the original source file that generated this
  35028. // chunk of code,
  35029. // originalLine: The line number in the original source that
  35030. // corresponds to this chunk of generated code,
  35031. // originalColumn: The column number in the original source that
  35032. // corresponds to this chunk of generated code,
  35033. // name: The name of the original symbol which generated this chunk of
  35034. // code.
  35035. // }
  35036. //
  35037. // All properties except for `generatedLine` and `generatedColumn` can be
  35038. // `null`.
  35039. //
  35040. // `_generatedMappings` is ordered by the generated positions.
  35041. //
  35042. // `_originalMappings` is ordered by the original positions.
  35043. SourceMapConsumer.prototype.__generatedMappings = null;
  35044. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  35045. configurable: true,
  35046. enumerable: true,
  35047. get: function () {
  35048. if (!this.__generatedMappings) {
  35049. this._parseMappings(this._mappings, this.sourceRoot);
  35050. }
  35051. return this.__generatedMappings;
  35052. }
  35053. });
  35054. SourceMapConsumer.prototype.__originalMappings = null;
  35055. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  35056. configurable: true,
  35057. enumerable: true,
  35058. get: function () {
  35059. if (!this.__originalMappings) {
  35060. this._parseMappings(this._mappings, this.sourceRoot);
  35061. }
  35062. return this.__originalMappings;
  35063. }
  35064. });
  35065. SourceMapConsumer.prototype._charIsMappingSeparator =
  35066. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  35067. var c = aStr.charAt(index);
  35068. return c === ";" || c === ",";
  35069. };
  35070. /**
  35071. * Parse the mappings in a string in to a data structure which we can easily
  35072. * query (the ordered arrays in the `this.__generatedMappings` and
  35073. * `this.__originalMappings` properties).
  35074. */
  35075. SourceMapConsumer.prototype._parseMappings =
  35076. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  35077. throw new Error("Subclasses must implement _parseMappings");
  35078. };
  35079. SourceMapConsumer.GENERATED_ORDER = 1;
  35080. SourceMapConsumer.ORIGINAL_ORDER = 2;
  35081. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  35082. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  35083. /**
  35084. * Iterate over each mapping between an original source/line/column and a
  35085. * generated line/column in this source map.
  35086. *
  35087. * @param Function aCallback
  35088. * The function that is called with each mapping.
  35089. * @param Object aContext
  35090. * Optional. If specified, this object will be the value of `this` every
  35091. * time that `aCallback` is called.
  35092. * @param aOrder
  35093. * Either `SourceMapConsumer.GENERATED_ORDER` or
  35094. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  35095. * iterate over the mappings sorted by the generated file's line/column
  35096. * order or the original's source/line/column order, respectively. Defaults to
  35097. * `SourceMapConsumer.GENERATED_ORDER`.
  35098. */
  35099. SourceMapConsumer.prototype.eachMapping =
  35100. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  35101. var context = aContext || null;
  35102. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  35103. var mappings;
  35104. switch (order) {
  35105. case SourceMapConsumer.GENERATED_ORDER:
  35106. mappings = this._generatedMappings;
  35107. break;
  35108. case SourceMapConsumer.ORIGINAL_ORDER:
  35109. mappings = this._originalMappings;
  35110. break;
  35111. default:
  35112. throw new Error("Unknown order of iteration.");
  35113. }
  35114. var sourceRoot = this.sourceRoot;
  35115. var boundCallback = aCallback.bind(context);
  35116. var names = this._names;
  35117. var sources = this._sources;
  35118. var sourceMapURL = this._sourceMapURL;
  35119. for (var i = 0, n = mappings.length; i < n; i++) {
  35120. var mapping = mappings[i];
  35121. var source = mapping.source === null ? null : sources.at(mapping.source);
  35122. if(source !== null) {
  35123. source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
  35124. }
  35125. boundCallback({
  35126. source: source,
  35127. generatedLine: mapping.generatedLine,
  35128. generatedColumn: mapping.generatedColumn,
  35129. originalLine: mapping.originalLine,
  35130. originalColumn: mapping.originalColumn,
  35131. name: mapping.name === null ? null : names.at(mapping.name)
  35132. });
  35133. }
  35134. };
  35135. /**
  35136. * Returns all generated line and column information for the original source,
  35137. * line, and column provided. If no column is provided, returns all mappings
  35138. * corresponding to a either the line we are searching for or the next
  35139. * closest line that has any mappings. Otherwise, returns all mappings
  35140. * corresponding to the given line and either the column we are searching for
  35141. * or the next closest column that has any offsets.
  35142. *
  35143. * The only argument is an object with the following properties:
  35144. *
  35145. * - source: The filename of the original source.
  35146. * - line: The line number in the original source. The line number is 1-based.
  35147. * - column: Optional. the column number in the original source.
  35148. * The column number is 0-based.
  35149. *
  35150. * and an array of objects is returned, each with the following properties:
  35151. *
  35152. * - line: The line number in the generated source, or null. The
  35153. * line number is 1-based.
  35154. * - column: The column number in the generated source, or null.
  35155. * The column number is 0-based.
  35156. */
  35157. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  35158. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  35159. var line = util.getArg(aArgs, 'line');
  35160. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  35161. // returns the index of the closest mapping less than the needle. By
  35162. // setting needle.originalColumn to 0, we thus find the last mapping for
  35163. // the given line, provided such a mapping exists.
  35164. var needle = {
  35165. source: util.getArg(aArgs, 'source'),
  35166. originalLine: line,
  35167. originalColumn: util.getArg(aArgs, 'column', 0)
  35168. };
  35169. needle.source = this._findSourceIndex(needle.source);
  35170. if (needle.source < 0) {
  35171. return [];
  35172. }
  35173. var mappings = [];
  35174. var index = this._findMapping(needle,
  35175. this._originalMappings,
  35176. "originalLine",
  35177. "originalColumn",
  35178. util.compareByOriginalPositions,
  35179. binarySearch.LEAST_UPPER_BOUND);
  35180. if (index >= 0) {
  35181. var mapping = this._originalMappings[index];
  35182. if (aArgs.column === undefined) {
  35183. var originalLine = mapping.originalLine;
  35184. // Iterate until either we run out of mappings, or we run into
  35185. // a mapping for a different line than the one we found. Since
  35186. // mappings are sorted, this is guaranteed to find all mappings for
  35187. // the line we found.
  35188. while (mapping && mapping.originalLine === originalLine) {
  35189. mappings.push({
  35190. line: util.getArg(mapping, 'generatedLine', null),
  35191. column: util.getArg(mapping, 'generatedColumn', null),
  35192. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35193. });
  35194. mapping = this._originalMappings[++index];
  35195. }
  35196. } else {
  35197. var originalColumn = mapping.originalColumn;
  35198. // Iterate until either we run out of mappings, or we run into
  35199. // a mapping for a different line than the one we were searching for.
  35200. // Since mappings are sorted, this is guaranteed to find all mappings for
  35201. // the line we are searching for.
  35202. while (mapping &&
  35203. mapping.originalLine === line &&
  35204. mapping.originalColumn == originalColumn) {
  35205. mappings.push({
  35206. line: util.getArg(mapping, 'generatedLine', null),
  35207. column: util.getArg(mapping, 'generatedColumn', null),
  35208. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35209. });
  35210. mapping = this._originalMappings[++index];
  35211. }
  35212. }
  35213. }
  35214. return mappings;
  35215. };
  35216. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer;
  35217. /**
  35218. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  35219. * query for information about the original file positions by giving it a file
  35220. * position in the generated source.
  35221. *
  35222. * The first parameter is the raw source map (either as a JSON string, or
  35223. * already parsed to an object). According to the spec, source maps have the
  35224. * following attributes:
  35225. *
  35226. * - version: Which version of the source map spec this map is following.
  35227. * - sources: An array of URLs to the original source files.
  35228. * - names: An array of identifiers which can be referrenced by individual mappings.
  35229. * - sourceRoot: Optional. The URL root from which all sources are relative.
  35230. * - sourcesContent: Optional. An array of contents of the original source files.
  35231. * - mappings: A string of base64 VLQs which contain the actual mappings.
  35232. * - file: Optional. The generated file this source map is associated with.
  35233. *
  35234. * Here is an example source map, taken from the source map spec[0]:
  35235. *
  35236. * {
  35237. * version : 3,
  35238. * file: "out.js",
  35239. * sourceRoot : "",
  35240. * sources: ["foo.js", "bar.js"],
  35241. * names: ["src", "maps", "are", "fun"],
  35242. * mappings: "AA,AB;;ABCDE;"
  35243. * }
  35244. *
  35245. * The second parameter, if given, is a string whose value is the URL
  35246. * at which the source map was found. This URL is used to compute the
  35247. * sources array.
  35248. *
  35249. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  35250. */
  35251. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  35252. var sourceMap = aSourceMap;
  35253. if (typeof aSourceMap === 'string') {
  35254. sourceMap = util.parseSourceMapInput(aSourceMap);
  35255. }
  35256. var version = util.getArg(sourceMap, 'version');
  35257. var sources = util.getArg(sourceMap, 'sources');
  35258. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  35259. // requires the array) to play nice here.
  35260. var names = util.getArg(sourceMap, 'names', []);
  35261. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  35262. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  35263. var mappings = util.getArg(sourceMap, 'mappings');
  35264. var file = util.getArg(sourceMap, 'file', null);
  35265. // Once again, Sass deviates from the spec and supplies the version as a
  35266. // string rather than a number, so we use loose equality checking here.
  35267. if (version != this._version) {
  35268. throw new Error('Unsupported version: ' + version);
  35269. }
  35270. if (sourceRoot) {
  35271. sourceRoot = util.normalize(sourceRoot);
  35272. }
  35273. sources = sources
  35274. .map(String)
  35275. // Some source maps produce relative source paths like "./foo.js" instead of
  35276. // "foo.js". Normalize these first so that future comparisons will succeed.
  35277. // See bugzil.la/1090768.
  35278. .map(util.normalize)
  35279. // Always ensure that absolute sources are internally stored relative to
  35280. // the source root, if the source root is absolute. Not doing this would
  35281. // be particularly problematic when the source root is a prefix of the
  35282. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  35283. .map(function (source) {
  35284. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  35285. ? util.relative(sourceRoot, source)
  35286. : source;
  35287. });
  35288. // Pass `true` below to allow duplicate names and sources. While source maps
  35289. // are intended to be compressed and deduplicated, the TypeScript compiler
  35290. // sometimes generates source maps with duplicates in them. See Github issue
  35291. // #72 and bugzil.la/889492.
  35292. this._names = ArraySet.fromArray(names.map(String), true);
  35293. this._sources = ArraySet.fromArray(sources, true);
  35294. this._absoluteSources = this._sources.toArray().map(function (s) {
  35295. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  35296. });
  35297. this.sourceRoot = sourceRoot;
  35298. this.sourcesContent = sourcesContent;
  35299. this._mappings = mappings;
  35300. this._sourceMapURL = aSourceMapURL;
  35301. this.file = file;
  35302. }
  35303. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  35304. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  35305. /**
  35306. * Utility function to find the index of a source. Returns -1 if not
  35307. * found.
  35308. */
  35309. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  35310. var relativeSource = aSource;
  35311. if (this.sourceRoot != null) {
  35312. relativeSource = util.relative(this.sourceRoot, relativeSource);
  35313. }
  35314. if (this._sources.has(relativeSource)) {
  35315. return this._sources.indexOf(relativeSource);
  35316. }
  35317. // Maybe aSource is an absolute URL as returned by |sources|. In
  35318. // this case we can't simply undo the transform.
  35319. var i;
  35320. for (i = 0; i < this._absoluteSources.length; ++i) {
  35321. if (this._absoluteSources[i] == aSource) {
  35322. return i;
  35323. }
  35324. }
  35325. return -1;
  35326. };
  35327. /**
  35328. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  35329. *
  35330. * @param SourceMapGenerator aSourceMap
  35331. * The source map that will be consumed.
  35332. * @param String aSourceMapURL
  35333. * The URL at which the source map can be found (optional)
  35334. * @returns BasicSourceMapConsumer
  35335. */
  35336. BasicSourceMapConsumer.fromSourceMap =
  35337. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  35338. var smc = Object.create(BasicSourceMapConsumer.prototype);
  35339. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  35340. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  35341. smc.sourceRoot = aSourceMap._sourceRoot;
  35342. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  35343. smc.sourceRoot);
  35344. smc.file = aSourceMap._file;
  35345. smc._sourceMapURL = aSourceMapURL;
  35346. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  35347. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  35348. });
  35349. // Because we are modifying the entries (by converting string sources and
  35350. // names to indices into the sources and names ArraySets), we have to make
  35351. // a copy of the entry or else bad things happen. Shared mutable state
  35352. // strikes again! See github issue #191.
  35353. var generatedMappings = aSourceMap._mappings.toArray().slice();
  35354. var destGeneratedMappings = smc.__generatedMappings = [];
  35355. var destOriginalMappings = smc.__originalMappings = [];
  35356. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  35357. var srcMapping = generatedMappings[i];
  35358. var destMapping = new Mapping;
  35359. destMapping.generatedLine = srcMapping.generatedLine;
  35360. destMapping.generatedColumn = srcMapping.generatedColumn;
  35361. if (srcMapping.source) {
  35362. destMapping.source = sources.indexOf(srcMapping.source);
  35363. destMapping.originalLine = srcMapping.originalLine;
  35364. destMapping.originalColumn = srcMapping.originalColumn;
  35365. if (srcMapping.name) {
  35366. destMapping.name = names.indexOf(srcMapping.name);
  35367. }
  35368. destOriginalMappings.push(destMapping);
  35369. }
  35370. destGeneratedMappings.push(destMapping);
  35371. }
  35372. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  35373. return smc;
  35374. };
  35375. /**
  35376. * The version of the source mapping spec that we are consuming.
  35377. */
  35378. BasicSourceMapConsumer.prototype._version = 3;
  35379. /**
  35380. * The list of original sources.
  35381. */
  35382. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  35383. get: function () {
  35384. return this._absoluteSources.slice();
  35385. }
  35386. });
  35387. /**
  35388. * Provide the JIT with a nice shape / hidden class.
  35389. */
  35390. function Mapping() {
  35391. this.generatedLine = 0;
  35392. this.generatedColumn = 0;
  35393. this.source = null;
  35394. this.originalLine = null;
  35395. this.originalColumn = null;
  35396. this.name = null;
  35397. }
  35398. /**
  35399. * Parse the mappings in a string in to a data structure which we can easily
  35400. * query (the ordered arrays in the `this.__generatedMappings` and
  35401. * `this.__originalMappings` properties).
  35402. */
  35403. const compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
  35404. function sortGenerated(array, start) {
  35405. let l = array.length;
  35406. let n = array.length - start;
  35407. if (n <= 1) {
  35408. return;
  35409. } else if (n == 2) {
  35410. let a = array[start];
  35411. let b = array[start + 1];
  35412. if (compareGenerated(a, b) > 0) {
  35413. array[start] = b;
  35414. array[start + 1] = a;
  35415. }
  35416. } else if (n < 20) {
  35417. for (let i = start; i < l; i++) {
  35418. for (let j = i; j > start; j--) {
  35419. let a = array[j - 1];
  35420. let b = array[j];
  35421. if (compareGenerated(a, b) <= 0) {
  35422. break;
  35423. }
  35424. array[j - 1] = b;
  35425. array[j] = a;
  35426. }
  35427. }
  35428. } else {
  35429. quickSort(array, compareGenerated, start);
  35430. }
  35431. }
  35432. BasicSourceMapConsumer.prototype._parseMappings =
  35433. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  35434. var generatedLine = 1;
  35435. var previousGeneratedColumn = 0;
  35436. var previousOriginalLine = 0;
  35437. var previousOriginalColumn = 0;
  35438. var previousSource = 0;
  35439. var previousName = 0;
  35440. var length = aStr.length;
  35441. var index = 0;
  35442. var temp = {};
  35443. var originalMappings = [];
  35444. var generatedMappings = [];
  35445. var mapping, segment, end, value;
  35446. let subarrayStart = 0;
  35447. while (index < length) {
  35448. if (aStr.charAt(index) === ';') {
  35449. generatedLine++;
  35450. index++;
  35451. previousGeneratedColumn = 0;
  35452. sortGenerated(generatedMappings, subarrayStart);
  35453. subarrayStart = generatedMappings.length;
  35454. }
  35455. else if (aStr.charAt(index) === ',') {
  35456. index++;
  35457. }
  35458. else {
  35459. mapping = new Mapping();
  35460. mapping.generatedLine = generatedLine;
  35461. for (end = index; end < length; end++) {
  35462. if (this._charIsMappingSeparator(aStr, end)) {
  35463. break;
  35464. }
  35465. }
  35466. aStr.slice(index, end);
  35467. segment = [];
  35468. while (index < end) {
  35469. base64VLQ.decode(aStr, index, temp);
  35470. value = temp.value;
  35471. index = temp.rest;
  35472. segment.push(value);
  35473. }
  35474. if (segment.length === 2) {
  35475. throw new Error('Found a source, but no line and column');
  35476. }
  35477. if (segment.length === 3) {
  35478. throw new Error('Found a source and line, but no column');
  35479. }
  35480. // Generated column.
  35481. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  35482. previousGeneratedColumn = mapping.generatedColumn;
  35483. if (segment.length > 1) {
  35484. // Original source.
  35485. mapping.source = previousSource + segment[1];
  35486. previousSource += segment[1];
  35487. // Original line.
  35488. mapping.originalLine = previousOriginalLine + segment[2];
  35489. previousOriginalLine = mapping.originalLine;
  35490. // Lines are stored 0-based
  35491. mapping.originalLine += 1;
  35492. // Original column.
  35493. mapping.originalColumn = previousOriginalColumn + segment[3];
  35494. previousOriginalColumn = mapping.originalColumn;
  35495. if (segment.length > 4) {
  35496. // Original name.
  35497. mapping.name = previousName + segment[4];
  35498. previousName += segment[4];
  35499. }
  35500. }
  35501. generatedMappings.push(mapping);
  35502. if (typeof mapping.originalLine === 'number') {
  35503. let currentSource = mapping.source;
  35504. while (originalMappings.length <= currentSource) {
  35505. originalMappings.push(null);
  35506. }
  35507. if (originalMappings[currentSource] === null) {
  35508. originalMappings[currentSource] = [];
  35509. }
  35510. originalMappings[currentSource].push(mapping);
  35511. }
  35512. }
  35513. }
  35514. sortGenerated(generatedMappings, subarrayStart);
  35515. this.__generatedMappings = generatedMappings;
  35516. for (var i = 0; i < originalMappings.length; i++) {
  35517. if (originalMappings[i] != null) {
  35518. quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
  35519. }
  35520. }
  35521. this.__originalMappings = [].concat(...originalMappings);
  35522. };
  35523. /**
  35524. * Find the mapping that best matches the hypothetical "needle" mapping that
  35525. * we are searching for in the given "haystack" of mappings.
  35526. */
  35527. BasicSourceMapConsumer.prototype._findMapping =
  35528. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  35529. aColumnName, aComparator, aBias) {
  35530. // To return the position we are searching for, we must first find the
  35531. // mapping for the given position and then return the opposite position it
  35532. // points to. Because the mappings are sorted, we can use binary search to
  35533. // find the best mapping.
  35534. if (aNeedle[aLineName] <= 0) {
  35535. throw new TypeError('Line must be greater than or equal to 1, got '
  35536. + aNeedle[aLineName]);
  35537. }
  35538. if (aNeedle[aColumnName] < 0) {
  35539. throw new TypeError('Column must be greater than or equal to 0, got '
  35540. + aNeedle[aColumnName]);
  35541. }
  35542. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  35543. };
  35544. /**
  35545. * Compute the last column for each generated mapping. The last column is
  35546. * inclusive.
  35547. */
  35548. BasicSourceMapConsumer.prototype.computeColumnSpans =
  35549. function SourceMapConsumer_computeColumnSpans() {
  35550. for (var index = 0; index < this._generatedMappings.length; ++index) {
  35551. var mapping = this._generatedMappings[index];
  35552. // Mappings do not contain a field for the last generated columnt. We
  35553. // can come up with an optimistic estimate, however, by assuming that
  35554. // mappings are contiguous (i.e. given two consecutive mappings, the
  35555. // first mapping ends where the second one starts).
  35556. if (index + 1 < this._generatedMappings.length) {
  35557. var nextMapping = this._generatedMappings[index + 1];
  35558. if (mapping.generatedLine === nextMapping.generatedLine) {
  35559. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  35560. continue;
  35561. }
  35562. }
  35563. // The last mapping for each line spans the entire line.
  35564. mapping.lastGeneratedColumn = Infinity;
  35565. }
  35566. };
  35567. /**
  35568. * Returns the original source, line, and column information for the generated
  35569. * source's line and column positions provided. The only argument is an object
  35570. * with the following properties:
  35571. *
  35572. * - line: The line number in the generated source. The line number
  35573. * is 1-based.
  35574. * - column: The column number in the generated source. The column
  35575. * number is 0-based.
  35576. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  35577. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  35578. * closest element that is smaller than or greater than the one we are
  35579. * searching for, respectively, if the exact element cannot be found.
  35580. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  35581. *
  35582. * and an object is returned with the following properties:
  35583. *
  35584. * - source: The original source file, or null.
  35585. * - line: The line number in the original source, or null. The
  35586. * line number is 1-based.
  35587. * - column: The column number in the original source, or null. The
  35588. * column number is 0-based.
  35589. * - name: The original identifier, or null.
  35590. */
  35591. BasicSourceMapConsumer.prototype.originalPositionFor =
  35592. function SourceMapConsumer_originalPositionFor(aArgs) {
  35593. var needle = {
  35594. generatedLine: util.getArg(aArgs, 'line'),
  35595. generatedColumn: util.getArg(aArgs, 'column')
  35596. };
  35597. var index = this._findMapping(
  35598. needle,
  35599. this._generatedMappings,
  35600. "generatedLine",
  35601. "generatedColumn",
  35602. util.compareByGeneratedPositionsDeflated,
  35603. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  35604. );
  35605. if (index >= 0) {
  35606. var mapping = this._generatedMappings[index];
  35607. if (mapping.generatedLine === needle.generatedLine) {
  35608. var source = util.getArg(mapping, 'source', null);
  35609. if (source !== null) {
  35610. source = this._sources.at(source);
  35611. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  35612. }
  35613. var name = util.getArg(mapping, 'name', null);
  35614. if (name !== null) {
  35615. name = this._names.at(name);
  35616. }
  35617. return {
  35618. source: source,
  35619. line: util.getArg(mapping, 'originalLine', null),
  35620. column: util.getArg(mapping, 'originalColumn', null),
  35621. name: name
  35622. };
  35623. }
  35624. }
  35625. return {
  35626. source: null,
  35627. line: null,
  35628. column: null,
  35629. name: null
  35630. };
  35631. };
  35632. /**
  35633. * Return true if we have the source content for every source in the source
  35634. * map, false otherwise.
  35635. */
  35636. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  35637. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  35638. if (!this.sourcesContent) {
  35639. return false;
  35640. }
  35641. return this.sourcesContent.length >= this._sources.size() &&
  35642. !this.sourcesContent.some(function (sc) { return sc == null; });
  35643. };
  35644. /**
  35645. * Returns the original source content. The only argument is the url of the
  35646. * original source file. Returns null if no original source content is
  35647. * available.
  35648. */
  35649. BasicSourceMapConsumer.prototype.sourceContentFor =
  35650. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  35651. if (!this.sourcesContent) {
  35652. return null;
  35653. }
  35654. var index = this._findSourceIndex(aSource);
  35655. if (index >= 0) {
  35656. return this.sourcesContent[index];
  35657. }
  35658. var relativeSource = aSource;
  35659. if (this.sourceRoot != null) {
  35660. relativeSource = util.relative(this.sourceRoot, relativeSource);
  35661. }
  35662. var url;
  35663. if (this.sourceRoot != null
  35664. && (url = util.urlParse(this.sourceRoot))) {
  35665. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  35666. // many users. We can help them out when they expect file:// URIs to
  35667. // behave like it would if they were running a local HTTP server. See
  35668. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  35669. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  35670. if (url.scheme == "file"
  35671. && this._sources.has(fileUriAbsPath)) {
  35672. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  35673. }
  35674. if ((!url.path || url.path == "/")
  35675. && this._sources.has("/" + relativeSource)) {
  35676. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  35677. }
  35678. }
  35679. // This function is used recursively from
  35680. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  35681. // don't want to throw if we can't find the source - we just want to
  35682. // return null, so we provide a flag to exit gracefully.
  35683. if (nullOnMissing) {
  35684. return null;
  35685. }
  35686. else {
  35687. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  35688. }
  35689. };
  35690. /**
  35691. * Returns the generated line and column information for the original source,
  35692. * line, and column positions provided. The only argument is an object with
  35693. * the following properties:
  35694. *
  35695. * - source: The filename of the original source.
  35696. * - line: The line number in the original source. The line number
  35697. * is 1-based.
  35698. * - column: The column number in the original source. The column
  35699. * number is 0-based.
  35700. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  35701. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  35702. * closest element that is smaller than or greater than the one we are
  35703. * searching for, respectively, if the exact element cannot be found.
  35704. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  35705. *
  35706. * and an object is returned with the following properties:
  35707. *
  35708. * - line: The line number in the generated source, or null. The
  35709. * line number is 1-based.
  35710. * - column: The column number in the generated source, or null.
  35711. * The column number is 0-based.
  35712. */
  35713. BasicSourceMapConsumer.prototype.generatedPositionFor =
  35714. function SourceMapConsumer_generatedPositionFor(aArgs) {
  35715. var source = util.getArg(aArgs, 'source');
  35716. source = this._findSourceIndex(source);
  35717. if (source < 0) {
  35718. return {
  35719. line: null,
  35720. column: null,
  35721. lastColumn: null
  35722. };
  35723. }
  35724. var needle = {
  35725. source: source,
  35726. originalLine: util.getArg(aArgs, 'line'),
  35727. originalColumn: util.getArg(aArgs, 'column')
  35728. };
  35729. var index = this._findMapping(
  35730. needle,
  35731. this._originalMappings,
  35732. "originalLine",
  35733. "originalColumn",
  35734. util.compareByOriginalPositions,
  35735. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  35736. );
  35737. if (index >= 0) {
  35738. var mapping = this._originalMappings[index];
  35739. if (mapping.source === needle.source) {
  35740. return {
  35741. line: util.getArg(mapping, 'generatedLine', null),
  35742. column: util.getArg(mapping, 'generatedColumn', null),
  35743. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35744. };
  35745. }
  35746. }
  35747. return {
  35748. line: null,
  35749. column: null,
  35750. lastColumn: null
  35751. };
  35752. };
  35753. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer;
  35754. /**
  35755. * An IndexedSourceMapConsumer instance represents a parsed source map which
  35756. * we can query for information. It differs from BasicSourceMapConsumer in
  35757. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  35758. * input.
  35759. *
  35760. * The first parameter is a raw source map (either as a JSON string, or already
  35761. * parsed to an object). According to the spec for indexed source maps, they
  35762. * have the following attributes:
  35763. *
  35764. * - version: Which version of the source map spec this map is following.
  35765. * - file: Optional. The generated file this source map is associated with.
  35766. * - sections: A list of section definitions.
  35767. *
  35768. * Each value under the "sections" field has two fields:
  35769. * - offset: The offset into the original specified at which this section
  35770. * begins to apply, defined as an object with a "line" and "column"
  35771. * field.
  35772. * - map: A source map definition. This source map could also be indexed,
  35773. * but doesn't have to be.
  35774. *
  35775. * Instead of the "map" field, it's also possible to have a "url" field
  35776. * specifying a URL to retrieve a source map from, but that's currently
  35777. * unsupported.
  35778. *
  35779. * Here's an example source map, taken from the source map spec[0], but
  35780. * modified to omit a section which uses the "url" field.
  35781. *
  35782. * {
  35783. * version : 3,
  35784. * file: "app.js",
  35785. * sections: [{
  35786. * offset: {line:100, column:10},
  35787. * map: {
  35788. * version : 3,
  35789. * file: "section.js",
  35790. * sources: ["foo.js", "bar.js"],
  35791. * names: ["src", "maps", "are", "fun"],
  35792. * mappings: "AAAA,E;;ABCDE;"
  35793. * }
  35794. * }],
  35795. * }
  35796. *
  35797. * The second parameter, if given, is a string whose value is the URL
  35798. * at which the source map was found. This URL is used to compute the
  35799. * sources array.
  35800. *
  35801. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  35802. */
  35803. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  35804. var sourceMap = aSourceMap;
  35805. if (typeof aSourceMap === 'string') {
  35806. sourceMap = util.parseSourceMapInput(aSourceMap);
  35807. }
  35808. var version = util.getArg(sourceMap, 'version');
  35809. var sections = util.getArg(sourceMap, 'sections');
  35810. if (version != this._version) {
  35811. throw new Error('Unsupported version: ' + version);
  35812. }
  35813. this._sources = new ArraySet();
  35814. this._names = new ArraySet();
  35815. var lastOffset = {
  35816. line: -1,
  35817. column: 0
  35818. };
  35819. this._sections = sections.map(function (s) {
  35820. if (s.url) {
  35821. // The url field will require support for asynchronicity.
  35822. // See https://github.com/mozilla/source-map/issues/16
  35823. throw new Error('Support for url field in sections not implemented.');
  35824. }
  35825. var offset = util.getArg(s, 'offset');
  35826. var offsetLine = util.getArg(offset, 'line');
  35827. var offsetColumn = util.getArg(offset, 'column');
  35828. if (offsetLine < lastOffset.line ||
  35829. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  35830. throw new Error('Section offsets must be ordered and non-overlapping.');
  35831. }
  35832. lastOffset = offset;
  35833. return {
  35834. generatedOffset: {
  35835. // The offset fields are 0-based, but we use 1-based indices when
  35836. // encoding/decoding from VLQ.
  35837. generatedLine: offsetLine + 1,
  35838. generatedColumn: offsetColumn + 1
  35839. },
  35840. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  35841. }
  35842. });
  35843. }
  35844. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  35845. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  35846. /**
  35847. * The version of the source mapping spec that we are consuming.
  35848. */
  35849. IndexedSourceMapConsumer.prototype._version = 3;
  35850. /**
  35851. * The list of original sources.
  35852. */
  35853. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  35854. get: function () {
  35855. var sources = [];
  35856. for (var i = 0; i < this._sections.length; i++) {
  35857. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  35858. sources.push(this._sections[i].consumer.sources[j]);
  35859. }
  35860. }
  35861. return sources;
  35862. }
  35863. });
  35864. /**
  35865. * Returns the original source, line, and column information for the generated
  35866. * source's line and column positions provided. The only argument is an object
  35867. * with the following properties:
  35868. *
  35869. * - line: The line number in the generated source. The line number
  35870. * is 1-based.
  35871. * - column: The column number in the generated source. The column
  35872. * number is 0-based.
  35873. *
  35874. * and an object is returned with the following properties:
  35875. *
  35876. * - source: The original source file, or null.
  35877. * - line: The line number in the original source, or null. The
  35878. * line number is 1-based.
  35879. * - column: The column number in the original source, or null. The
  35880. * column number is 0-based.
  35881. * - name: The original identifier, or null.
  35882. */
  35883. IndexedSourceMapConsumer.prototype.originalPositionFor =
  35884. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  35885. var needle = {
  35886. generatedLine: util.getArg(aArgs, 'line'),
  35887. generatedColumn: util.getArg(aArgs, 'column')
  35888. };
  35889. // Find the section containing the generated position we're trying to map
  35890. // to an original position.
  35891. var sectionIndex = binarySearch.search(needle, this._sections,
  35892. function(needle, section) {
  35893. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  35894. if (cmp) {
  35895. return cmp;
  35896. }
  35897. return (needle.generatedColumn -
  35898. section.generatedOffset.generatedColumn);
  35899. });
  35900. var section = this._sections[sectionIndex];
  35901. if (!section) {
  35902. return {
  35903. source: null,
  35904. line: null,
  35905. column: null,
  35906. name: null
  35907. };
  35908. }
  35909. return section.consumer.originalPositionFor({
  35910. line: needle.generatedLine -
  35911. (section.generatedOffset.generatedLine - 1),
  35912. column: needle.generatedColumn -
  35913. (section.generatedOffset.generatedLine === needle.generatedLine
  35914. ? section.generatedOffset.generatedColumn - 1
  35915. : 0),
  35916. bias: aArgs.bias
  35917. });
  35918. };
  35919. /**
  35920. * Return true if we have the source content for every source in the source
  35921. * map, false otherwise.
  35922. */
  35923. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  35924. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  35925. return this._sections.every(function (s) {
  35926. return s.consumer.hasContentsOfAllSources();
  35927. });
  35928. };
  35929. /**
  35930. * Returns the original source content. The only argument is the url of the
  35931. * original source file. Returns null if no original source content is
  35932. * available.
  35933. */
  35934. IndexedSourceMapConsumer.prototype.sourceContentFor =
  35935. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  35936. for (var i = 0; i < this._sections.length; i++) {
  35937. var section = this._sections[i];
  35938. var content = section.consumer.sourceContentFor(aSource, true);
  35939. if (content || content === '') {
  35940. return content;
  35941. }
  35942. }
  35943. if (nullOnMissing) {
  35944. return null;
  35945. }
  35946. else {
  35947. throw new Error('"' + aSource + '" is not in the SourceMap.');
  35948. }
  35949. };
  35950. /**
  35951. * Returns the generated line and column information for the original source,
  35952. * line, and column positions provided. The only argument is an object with
  35953. * the following properties:
  35954. *
  35955. * - source: The filename of the original source.
  35956. * - line: The line number in the original source. The line number
  35957. * is 1-based.
  35958. * - column: The column number in the original source. The column
  35959. * number is 0-based.
  35960. *
  35961. * and an object is returned with the following properties:
  35962. *
  35963. * - line: The line number in the generated source, or null. The
  35964. * line number is 1-based.
  35965. * - column: The column number in the generated source, or null.
  35966. * The column number is 0-based.
  35967. */
  35968. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  35969. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  35970. for (var i = 0; i < this._sections.length; i++) {
  35971. var section = this._sections[i];
  35972. // Only consider this section if the requested source is in the list of
  35973. // sources of the consumer.
  35974. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  35975. continue;
  35976. }
  35977. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  35978. if (generatedPosition) {
  35979. var ret = {
  35980. line: generatedPosition.line +
  35981. (section.generatedOffset.generatedLine - 1),
  35982. column: generatedPosition.column +
  35983. (section.generatedOffset.generatedLine === generatedPosition.line
  35984. ? section.generatedOffset.generatedColumn - 1
  35985. : 0)
  35986. };
  35987. return ret;
  35988. }
  35989. }
  35990. return {
  35991. line: null,
  35992. column: null
  35993. };
  35994. };
  35995. /**
  35996. * Parse the mappings in a string in to a data structure which we can easily
  35997. * query (the ordered arrays in the `this.__generatedMappings` and
  35998. * `this.__originalMappings` properties).
  35999. */
  36000. IndexedSourceMapConsumer.prototype._parseMappings =
  36001. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  36002. this.__generatedMappings = [];
  36003. this.__originalMappings = [];
  36004. for (var i = 0; i < this._sections.length; i++) {
  36005. var section = this._sections[i];
  36006. var sectionMappings = section.consumer._generatedMappings;
  36007. for (var j = 0; j < sectionMappings.length; j++) {
  36008. var mapping = sectionMappings[j];
  36009. var source = section.consumer._sources.at(mapping.source);
  36010. if(source !== null) {
  36011. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  36012. }
  36013. this._sources.add(source);
  36014. source = this._sources.indexOf(source);
  36015. var name = null;
  36016. if (mapping.name) {
  36017. name = section.consumer._names.at(mapping.name);
  36018. this._names.add(name);
  36019. name = this._names.indexOf(name);
  36020. }
  36021. // The mappings coming from the consumer for the section have
  36022. // generated positions relative to the start of the section, so we
  36023. // need to offset them to be relative to the start of the concatenated
  36024. // generated file.
  36025. var adjustedMapping = {
  36026. source: source,
  36027. generatedLine: mapping.generatedLine +
  36028. (section.generatedOffset.generatedLine - 1),
  36029. generatedColumn: mapping.generatedColumn +
  36030. (section.generatedOffset.generatedLine === mapping.generatedLine
  36031. ? section.generatedOffset.generatedColumn - 1
  36032. : 0),
  36033. originalLine: mapping.originalLine,
  36034. originalColumn: mapping.originalColumn,
  36035. name: name
  36036. };
  36037. this.__generatedMappings.push(adjustedMapping);
  36038. if (typeof adjustedMapping.originalLine === 'number') {
  36039. this.__originalMappings.push(adjustedMapping);
  36040. }
  36041. }
  36042. }
  36043. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  36044. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  36045. };
  36046. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  36047. return sourceMapConsumer$1;
  36048. }
  36049. var sourceNode$1 = {};
  36050. /* -*- Mode: js; js-indent-level: 2; -*- */
  36051. var hasRequiredSourceNode$1;
  36052. function requireSourceNode$1 () {
  36053. if (hasRequiredSourceNode$1) return sourceNode$1;
  36054. hasRequiredSourceNode$1 = 1;
  36055. /*
  36056. * Copyright 2011 Mozilla Foundation and contributors
  36057. * Licensed under the New BSD license. See LICENSE or:
  36058. * http://opensource.org/licenses/BSD-3-Clause
  36059. */
  36060. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  36061. var util = /*@__PURE__*/ requireUtil$2();
  36062. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  36063. // operating systems these days (capturing the result).
  36064. var REGEX_NEWLINE = /(\r?\n)/;
  36065. // Newline character code for charCodeAt() comparisons
  36066. var NEWLINE_CODE = 10;
  36067. // Private symbol for identifying `SourceNode`s when multiple versions of
  36068. // the source-map library are loaded. This MUST NOT CHANGE across
  36069. // versions!
  36070. var isSourceNode = "$$$isSourceNode$$$";
  36071. /**
  36072. * SourceNodes provide a way to abstract over interpolating/concatenating
  36073. * snippets of generated JavaScript source code while maintaining the line and
  36074. * column information associated with the original source code.
  36075. *
  36076. * @param aLine The original line number.
  36077. * @param aColumn The original column number.
  36078. * @param aSource The original source's filename.
  36079. * @param aChunks Optional. An array of strings which are snippets of
  36080. * generated JS, or other SourceNodes.
  36081. * @param aName The original identifier.
  36082. */
  36083. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  36084. this.children = [];
  36085. this.sourceContents = {};
  36086. this.line = aLine == null ? null : aLine;
  36087. this.column = aColumn == null ? null : aColumn;
  36088. this.source = aSource == null ? null : aSource;
  36089. this.name = aName == null ? null : aName;
  36090. this[isSourceNode] = true;
  36091. if (aChunks != null) this.add(aChunks);
  36092. }
  36093. /**
  36094. * Creates a SourceNode from generated code and a SourceMapConsumer.
  36095. *
  36096. * @param aGeneratedCode The generated code
  36097. * @param aSourceMapConsumer The SourceMap for the generated code
  36098. * @param aRelativePath Optional. The path that relative sources in the
  36099. * SourceMapConsumer should be relative to.
  36100. */
  36101. SourceNode.fromStringWithSourceMap =
  36102. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  36103. // The SourceNode we want to fill with the generated code
  36104. // and the SourceMap
  36105. var node = new SourceNode();
  36106. // All even indices of this array are one line of the generated code,
  36107. // while all odd indices are the newlines between two adjacent lines
  36108. // (since `REGEX_NEWLINE` captures its match).
  36109. // Processed fragments are accessed by calling `shiftNextLine`.
  36110. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  36111. var remainingLinesIndex = 0;
  36112. var shiftNextLine = function() {
  36113. var lineContents = getNextLine();
  36114. // The last line of a file might not have a newline.
  36115. var newLine = getNextLine() || "";
  36116. return lineContents + newLine;
  36117. function getNextLine() {
  36118. return remainingLinesIndex < remainingLines.length ?
  36119. remainingLines[remainingLinesIndex++] : undefined;
  36120. }
  36121. };
  36122. // We need to remember the position of "remainingLines"
  36123. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  36124. // The generate SourceNodes we need a code range.
  36125. // To extract it current and last mapping is used.
  36126. // Here we store the last mapping.
  36127. var lastMapping = null;
  36128. aSourceMapConsumer.eachMapping(function (mapping) {
  36129. if (lastMapping !== null) {
  36130. // We add the code from "lastMapping" to "mapping":
  36131. // First check if there is a new line in between.
  36132. if (lastGeneratedLine < mapping.generatedLine) {
  36133. // Associate first line with "lastMapping"
  36134. addMappingWithCode(lastMapping, shiftNextLine());
  36135. lastGeneratedLine++;
  36136. lastGeneratedColumn = 0;
  36137. // The remaining code is added without mapping
  36138. } else {
  36139. // There is no new line in between.
  36140. // Associate the code between "lastGeneratedColumn" and
  36141. // "mapping.generatedColumn" with "lastMapping"
  36142. var nextLine = remainingLines[remainingLinesIndex] || '';
  36143. var code = nextLine.substr(0, mapping.generatedColumn -
  36144. lastGeneratedColumn);
  36145. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  36146. lastGeneratedColumn);
  36147. lastGeneratedColumn = mapping.generatedColumn;
  36148. addMappingWithCode(lastMapping, code);
  36149. // No more remaining code, continue
  36150. lastMapping = mapping;
  36151. return;
  36152. }
  36153. }
  36154. // We add the generated code until the first mapping
  36155. // to the SourceNode without any mapping.
  36156. // Each line is added as separate string.
  36157. while (lastGeneratedLine < mapping.generatedLine) {
  36158. node.add(shiftNextLine());
  36159. lastGeneratedLine++;
  36160. }
  36161. if (lastGeneratedColumn < mapping.generatedColumn) {
  36162. var nextLine = remainingLines[remainingLinesIndex] || '';
  36163. node.add(nextLine.substr(0, mapping.generatedColumn));
  36164. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  36165. lastGeneratedColumn = mapping.generatedColumn;
  36166. }
  36167. lastMapping = mapping;
  36168. }, this);
  36169. // We have processed all mappings.
  36170. if (remainingLinesIndex < remainingLines.length) {
  36171. if (lastMapping) {
  36172. // Associate the remaining code in the current line with "lastMapping"
  36173. addMappingWithCode(lastMapping, shiftNextLine());
  36174. }
  36175. // and add the remaining lines without any mapping
  36176. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  36177. }
  36178. // Copy sourcesContent into SourceNode
  36179. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  36180. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  36181. if (content != null) {
  36182. if (aRelativePath != null) {
  36183. sourceFile = util.join(aRelativePath, sourceFile);
  36184. }
  36185. node.setSourceContent(sourceFile, content);
  36186. }
  36187. });
  36188. return node;
  36189. function addMappingWithCode(mapping, code) {
  36190. if (mapping === null || mapping.source === undefined) {
  36191. node.add(code);
  36192. } else {
  36193. var source = aRelativePath
  36194. ? util.join(aRelativePath, mapping.source)
  36195. : mapping.source;
  36196. node.add(new SourceNode(mapping.originalLine,
  36197. mapping.originalColumn,
  36198. source,
  36199. code,
  36200. mapping.name));
  36201. }
  36202. }
  36203. };
  36204. /**
  36205. * Add a chunk of generated JS to this source node.
  36206. *
  36207. * @param aChunk A string snippet of generated JS code, another instance of
  36208. * SourceNode, or an array where each member is one of those things.
  36209. */
  36210. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  36211. if (Array.isArray(aChunk)) {
  36212. aChunk.forEach(function (chunk) {
  36213. this.add(chunk);
  36214. }, this);
  36215. }
  36216. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  36217. if (aChunk) {
  36218. this.children.push(aChunk);
  36219. }
  36220. }
  36221. else {
  36222. throw new TypeError(
  36223. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  36224. );
  36225. }
  36226. return this;
  36227. };
  36228. /**
  36229. * Add a chunk of generated JS to the beginning of this source node.
  36230. *
  36231. * @param aChunk A string snippet of generated JS code, another instance of
  36232. * SourceNode, or an array where each member is one of those things.
  36233. */
  36234. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  36235. if (Array.isArray(aChunk)) {
  36236. for (var i = aChunk.length-1; i >= 0; i--) {
  36237. this.prepend(aChunk[i]);
  36238. }
  36239. }
  36240. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  36241. this.children.unshift(aChunk);
  36242. }
  36243. else {
  36244. throw new TypeError(
  36245. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  36246. );
  36247. }
  36248. return this;
  36249. };
  36250. /**
  36251. * Walk over the tree of JS snippets in this node and its children. The
  36252. * walking function is called once for each snippet of JS and is passed that
  36253. * snippet and the its original associated source's line/column location.
  36254. *
  36255. * @param aFn The traversal function.
  36256. */
  36257. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  36258. var chunk;
  36259. for (var i = 0, len = this.children.length; i < len; i++) {
  36260. chunk = this.children[i];
  36261. if (chunk[isSourceNode]) {
  36262. chunk.walk(aFn);
  36263. }
  36264. else {
  36265. if (chunk !== '') {
  36266. aFn(chunk, { source: this.source,
  36267. line: this.line,
  36268. column: this.column,
  36269. name: this.name });
  36270. }
  36271. }
  36272. }
  36273. };
  36274. /**
  36275. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  36276. * each of `this.children`.
  36277. *
  36278. * @param aSep The separator.
  36279. */
  36280. SourceNode.prototype.join = function SourceNode_join(aSep) {
  36281. var newChildren;
  36282. var i;
  36283. var len = this.children.length;
  36284. if (len > 0) {
  36285. newChildren = [];
  36286. for (i = 0; i < len-1; i++) {
  36287. newChildren.push(this.children[i]);
  36288. newChildren.push(aSep);
  36289. }
  36290. newChildren.push(this.children[i]);
  36291. this.children = newChildren;
  36292. }
  36293. return this;
  36294. };
  36295. /**
  36296. * Call String.prototype.replace on the very right-most source snippet. Useful
  36297. * for trimming whitespace from the end of a source node, etc.
  36298. *
  36299. * @param aPattern The pattern to replace.
  36300. * @param aReplacement The thing to replace the pattern with.
  36301. */
  36302. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  36303. var lastChild = this.children[this.children.length - 1];
  36304. if (lastChild[isSourceNode]) {
  36305. lastChild.replaceRight(aPattern, aReplacement);
  36306. }
  36307. else if (typeof lastChild === 'string') {
  36308. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  36309. }
  36310. else {
  36311. this.children.push(''.replace(aPattern, aReplacement));
  36312. }
  36313. return this;
  36314. };
  36315. /**
  36316. * Set the source content for a source file. This will be added to the SourceMapGenerator
  36317. * in the sourcesContent field.
  36318. *
  36319. * @param aSourceFile The filename of the source file
  36320. * @param aSourceContent The content of the source file
  36321. */
  36322. SourceNode.prototype.setSourceContent =
  36323. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  36324. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  36325. };
  36326. /**
  36327. * Walk over the tree of SourceNodes. The walking function is called for each
  36328. * source file content and is passed the filename and source content.
  36329. *
  36330. * @param aFn The traversal function.
  36331. */
  36332. SourceNode.prototype.walkSourceContents =
  36333. function SourceNode_walkSourceContents(aFn) {
  36334. for (var i = 0, len = this.children.length; i < len; i++) {
  36335. if (this.children[i][isSourceNode]) {
  36336. this.children[i].walkSourceContents(aFn);
  36337. }
  36338. }
  36339. var sources = Object.keys(this.sourceContents);
  36340. for (var i = 0, len = sources.length; i < len; i++) {
  36341. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  36342. }
  36343. };
  36344. /**
  36345. * Return the string representation of this source node. Walks over the tree
  36346. * and concatenates all the various snippets together to one string.
  36347. */
  36348. SourceNode.prototype.toString = function SourceNode_toString() {
  36349. var str = "";
  36350. this.walk(function (chunk) {
  36351. str += chunk;
  36352. });
  36353. return str;
  36354. };
  36355. /**
  36356. * Returns the string representation of this source node along with a source
  36357. * map.
  36358. */
  36359. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  36360. var generated = {
  36361. code: "",
  36362. line: 1,
  36363. column: 0
  36364. };
  36365. var map = new SourceMapGenerator(aArgs);
  36366. var sourceMappingActive = false;
  36367. var lastOriginalSource = null;
  36368. var lastOriginalLine = null;
  36369. var lastOriginalColumn = null;
  36370. var lastOriginalName = null;
  36371. this.walk(function (chunk, original) {
  36372. generated.code += chunk;
  36373. if (original.source !== null
  36374. && original.line !== null
  36375. && original.column !== null) {
  36376. if(lastOriginalSource !== original.source
  36377. || lastOriginalLine !== original.line
  36378. || lastOriginalColumn !== original.column
  36379. || lastOriginalName !== original.name) {
  36380. map.addMapping({
  36381. source: original.source,
  36382. original: {
  36383. line: original.line,
  36384. column: original.column
  36385. },
  36386. generated: {
  36387. line: generated.line,
  36388. column: generated.column
  36389. },
  36390. name: original.name
  36391. });
  36392. }
  36393. lastOriginalSource = original.source;
  36394. lastOriginalLine = original.line;
  36395. lastOriginalColumn = original.column;
  36396. lastOriginalName = original.name;
  36397. sourceMappingActive = true;
  36398. } else if (sourceMappingActive) {
  36399. map.addMapping({
  36400. generated: {
  36401. line: generated.line,
  36402. column: generated.column
  36403. }
  36404. });
  36405. lastOriginalSource = null;
  36406. sourceMappingActive = false;
  36407. }
  36408. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  36409. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  36410. generated.line++;
  36411. generated.column = 0;
  36412. // Mappings end at eol
  36413. if (idx + 1 === length) {
  36414. lastOriginalSource = null;
  36415. sourceMappingActive = false;
  36416. } else if (sourceMappingActive) {
  36417. map.addMapping({
  36418. source: original.source,
  36419. original: {
  36420. line: original.line,
  36421. column: original.column
  36422. },
  36423. generated: {
  36424. line: generated.line,
  36425. column: generated.column
  36426. },
  36427. name: original.name
  36428. });
  36429. }
  36430. } else {
  36431. generated.column++;
  36432. }
  36433. }
  36434. });
  36435. this.walkSourceContents(function (sourceFile, sourceContent) {
  36436. map.setSourceContent(sourceFile, sourceContent);
  36437. });
  36438. return { code: generated.code, map: map };
  36439. };
  36440. sourceNode$1.SourceNode = SourceNode;
  36441. return sourceNode$1;
  36442. }
  36443. /*
  36444. * Copyright 2009-2011 Mozilla Foundation and contributors
  36445. * Licensed under the New BSD license. See LICENSE.txt or:
  36446. * http://opensource.org/licenses/BSD-3-Clause
  36447. */
  36448. var hasRequiredSourceMap$1;
  36449. function requireSourceMap$1 () {
  36450. if (hasRequiredSourceMap$1) return sourceMap$1;
  36451. hasRequiredSourceMap$1 = 1;
  36452. sourceMap$1.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  36453. sourceMap$1.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer$1().SourceMapConsumer;
  36454. sourceMap$1.SourceNode = /*@__PURE__*/ requireSourceNode$1().SourceNode;
  36455. return sourceMap$1;
  36456. }
  36457. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  36458. var previousMap;
  36459. var hasRequiredPreviousMap;
  36460. function requirePreviousMap () {
  36461. if (hasRequiredPreviousMap) return previousMap;
  36462. hasRequiredPreviousMap = 1;
  36463. let { existsSync, readFileSync } = require$$0$1;
  36464. let { dirname, join } = require$$1;
  36465. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  36466. function fromBase64(str) {
  36467. if (Buffer$1) {
  36468. return Buffer$1.from(str, 'base64').toString()
  36469. } else {
  36470. /* c8 ignore next 2 */
  36471. return window.atob(str)
  36472. }
  36473. }
  36474. class PreviousMap {
  36475. constructor(css, opts) {
  36476. if (opts.map === false) return
  36477. this.loadAnnotation(css);
  36478. this.inline = this.startWith(this.annotation, 'data:');
  36479. let prev = opts.map ? opts.map.prev : undefined;
  36480. let text = this.loadMap(opts.from, prev);
  36481. if (!this.mapFile && opts.from) {
  36482. this.mapFile = opts.from;
  36483. }
  36484. if (this.mapFile) this.root = dirname(this.mapFile);
  36485. if (text) this.text = text;
  36486. }
  36487. consumer() {
  36488. if (!this.consumerCache) {
  36489. this.consumerCache = new SourceMapConsumer(this.text);
  36490. }
  36491. return this.consumerCache
  36492. }
  36493. decodeInline(text) {
  36494. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  36495. let baseUri = /^data:application\/json;base64,/;
  36496. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  36497. let uri = /^data:application\/json,/;
  36498. let uriMatch = text.match(charsetUri) || text.match(uri);
  36499. if (uriMatch) {
  36500. return decodeURIComponent(text.substr(uriMatch[0].length))
  36501. }
  36502. let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
  36503. if (baseUriMatch) {
  36504. return fromBase64(text.substr(baseUriMatch[0].length))
  36505. }
  36506. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  36507. throw new Error('Unsupported source map encoding ' + encoding)
  36508. }
  36509. getAnnotationURL(sourceMapString) {
  36510. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  36511. }
  36512. isMap(map) {
  36513. if (typeof map !== 'object') return false
  36514. return (
  36515. typeof map.mappings === 'string' ||
  36516. typeof map._mappings === 'string' ||
  36517. Array.isArray(map.sections)
  36518. )
  36519. }
  36520. loadAnnotation(css) {
  36521. let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
  36522. if (!comments) return
  36523. // sourceMappingURLs from comments, strings, etc.
  36524. let start = css.lastIndexOf(comments.pop());
  36525. let end = css.indexOf('*/', start);
  36526. if (start > -1 && end > -1) {
  36527. // Locate the last sourceMappingURL to avoid pickin
  36528. this.annotation = this.getAnnotationURL(css.substring(start, end));
  36529. }
  36530. }
  36531. loadFile(path) {
  36532. this.root = dirname(path);
  36533. if (existsSync(path)) {
  36534. this.mapFile = path;
  36535. return readFileSync(path, 'utf-8').toString().trim()
  36536. }
  36537. }
  36538. loadMap(file, prev) {
  36539. if (prev === false) return false
  36540. if (prev) {
  36541. if (typeof prev === 'string') {
  36542. return prev
  36543. } else if (typeof prev === 'function') {
  36544. let prevPath = prev(file);
  36545. if (prevPath) {
  36546. let map = this.loadFile(prevPath);
  36547. if (!map) {
  36548. throw new Error(
  36549. 'Unable to load previous source map: ' + prevPath.toString()
  36550. )
  36551. }
  36552. return map
  36553. }
  36554. } else if (prev instanceof SourceMapConsumer) {
  36555. return SourceMapGenerator.fromSourceMap(prev).toString()
  36556. } else if (prev instanceof SourceMapGenerator) {
  36557. return prev.toString()
  36558. } else if (this.isMap(prev)) {
  36559. return JSON.stringify(prev)
  36560. } else {
  36561. throw new Error(
  36562. 'Unsupported previous source map format: ' + prev.toString()
  36563. )
  36564. }
  36565. } else if (this.inline) {
  36566. return this.decodeInline(this.annotation)
  36567. } else if (this.annotation) {
  36568. let map = this.annotation;
  36569. if (file) map = join(dirname(file), map);
  36570. return this.loadFile(map)
  36571. }
  36572. }
  36573. startWith(string, start) {
  36574. if (!string) return false
  36575. return string.substr(0, start.length) === start
  36576. }
  36577. withContent() {
  36578. return !!(
  36579. this.consumer().sourcesContent &&
  36580. this.consumer().sourcesContent.length > 0
  36581. )
  36582. }
  36583. }
  36584. previousMap = PreviousMap;
  36585. PreviousMap.default = PreviousMap;
  36586. return previousMap;
  36587. }
  36588. var input;
  36589. var hasRequiredInput;
  36590. function requireInput () {
  36591. if (hasRequiredInput) return input;
  36592. hasRequiredInput = 1;
  36593. let { nanoid } = /*@__PURE__*/ requireNonSecure();
  36594. let { isAbsolute, resolve } = require$$1;
  36595. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  36596. let { fileURLToPath, pathToFileURL } = require$$2;
  36597. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  36598. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  36599. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  36600. let fromOffsetCache = Symbol('fromOffsetCache');
  36601. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  36602. let pathAvailable = Boolean(resolve && isAbsolute);
  36603. class Input {
  36604. constructor(css, opts = {}) {
  36605. if (
  36606. css === null ||
  36607. typeof css === 'undefined' ||
  36608. (typeof css === 'object' && !css.toString)
  36609. ) {
  36610. throw new Error(`PostCSS received ${css} instead of CSS string`)
  36611. }
  36612. this.css = css.toString();
  36613. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  36614. this.hasBOM = true;
  36615. this.css = this.css.slice(1);
  36616. } else {
  36617. this.hasBOM = false;
  36618. }
  36619. if (opts.from) {
  36620. if (
  36621. !pathAvailable ||
  36622. /^\w+:\/\//.test(opts.from) ||
  36623. isAbsolute(opts.from)
  36624. ) {
  36625. this.file = opts.from;
  36626. } else {
  36627. this.file = resolve(opts.from);
  36628. }
  36629. }
  36630. if (pathAvailable && sourceMapAvailable) {
  36631. let map = new PreviousMap(this.css, opts);
  36632. if (map.text) {
  36633. this.map = map;
  36634. let file = map.consumer().file;
  36635. if (!this.file && file) this.file = this.mapResolve(file);
  36636. }
  36637. }
  36638. if (!this.file) {
  36639. this.id = '<input css ' + nanoid(6) + '>';
  36640. }
  36641. if (this.map) this.map.file = this.from;
  36642. }
  36643. error(message, line, column, opts = {}) {
  36644. let endColumn, endLine, result;
  36645. if (line && typeof line === 'object') {
  36646. let start = line;
  36647. let end = column;
  36648. if (typeof start.offset === 'number') {
  36649. let pos = this.fromOffset(start.offset);
  36650. line = pos.line;
  36651. column = pos.col;
  36652. } else {
  36653. line = start.line;
  36654. column = start.column;
  36655. }
  36656. if (typeof end.offset === 'number') {
  36657. let pos = this.fromOffset(end.offset);
  36658. endLine = pos.line;
  36659. endColumn = pos.col;
  36660. } else {
  36661. endLine = end.line;
  36662. endColumn = end.column;
  36663. }
  36664. } else if (!column) {
  36665. let pos = this.fromOffset(line);
  36666. line = pos.line;
  36667. column = pos.col;
  36668. }
  36669. let origin = this.origin(line, column, endLine, endColumn);
  36670. if (origin) {
  36671. result = new CssSyntaxError(
  36672. message,
  36673. origin.endLine === undefined
  36674. ? origin.line
  36675. : { column: origin.column, line: origin.line },
  36676. origin.endLine === undefined
  36677. ? origin.column
  36678. : { column: origin.endColumn, line: origin.endLine },
  36679. origin.source,
  36680. origin.file,
  36681. opts.plugin
  36682. );
  36683. } else {
  36684. result = new CssSyntaxError(
  36685. message,
  36686. endLine === undefined ? line : { column, line },
  36687. endLine === undefined ? column : { column: endColumn, line: endLine },
  36688. this.css,
  36689. this.file,
  36690. opts.plugin
  36691. );
  36692. }
  36693. result.input = { column, endColumn, endLine, line, source: this.css };
  36694. if (this.file) {
  36695. if (pathToFileURL) {
  36696. result.input.url = pathToFileURL(this.file).toString();
  36697. }
  36698. result.input.file = this.file;
  36699. }
  36700. return result
  36701. }
  36702. fromOffset(offset) {
  36703. let lastLine, lineToIndex;
  36704. if (!this[fromOffsetCache]) {
  36705. let lines = this.css.split('\n');
  36706. lineToIndex = new Array(lines.length);
  36707. let prevIndex = 0;
  36708. for (let i = 0, l = lines.length; i < l; i++) {
  36709. lineToIndex[i] = prevIndex;
  36710. prevIndex += lines[i].length + 1;
  36711. }
  36712. this[fromOffsetCache] = lineToIndex;
  36713. } else {
  36714. lineToIndex = this[fromOffsetCache];
  36715. }
  36716. lastLine = lineToIndex[lineToIndex.length - 1];
  36717. let min = 0;
  36718. if (offset >= lastLine) {
  36719. min = lineToIndex.length - 1;
  36720. } else {
  36721. let max = lineToIndex.length - 2;
  36722. let mid;
  36723. while (min < max) {
  36724. mid = min + ((max - min) >> 1);
  36725. if (offset < lineToIndex[mid]) {
  36726. max = mid - 1;
  36727. } else if (offset >= lineToIndex[mid + 1]) {
  36728. min = mid + 1;
  36729. } else {
  36730. min = mid;
  36731. break
  36732. }
  36733. }
  36734. }
  36735. return {
  36736. col: offset - lineToIndex[min] + 1,
  36737. line: min + 1
  36738. }
  36739. }
  36740. mapResolve(file) {
  36741. if (/^\w+:\/\//.test(file)) {
  36742. return file
  36743. }
  36744. return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
  36745. }
  36746. origin(line, column, endLine, endColumn) {
  36747. if (!this.map) return false
  36748. let consumer = this.map.consumer();
  36749. let from = consumer.originalPositionFor({ column, line });
  36750. if (!from.source) return false
  36751. let to;
  36752. if (typeof endLine === 'number') {
  36753. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  36754. }
  36755. let fromUrl;
  36756. if (isAbsolute(from.source)) {
  36757. fromUrl = pathToFileURL(from.source);
  36758. } else {
  36759. fromUrl = new URL(
  36760. from.source,
  36761. this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
  36762. );
  36763. }
  36764. let result = {
  36765. column: from.column,
  36766. endColumn: to && to.column,
  36767. endLine: to && to.line,
  36768. line: from.line,
  36769. url: fromUrl.toString()
  36770. };
  36771. if (fromUrl.protocol === 'file:') {
  36772. if (fileURLToPath) {
  36773. result.file = fileURLToPath(fromUrl);
  36774. } else {
  36775. /* c8 ignore next 2 */
  36776. throw new Error(`file: protocol is not available in this PostCSS build`)
  36777. }
  36778. }
  36779. let source = consumer.sourceContentFor(from.source);
  36780. if (source) result.source = source;
  36781. return result
  36782. }
  36783. toJSON() {
  36784. let json = {};
  36785. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  36786. if (this[name] != null) {
  36787. json[name] = this[name];
  36788. }
  36789. }
  36790. if (this.map) {
  36791. json.map = { ...this.map };
  36792. if (json.map.consumerCache) {
  36793. json.map.consumerCache = undefined;
  36794. }
  36795. }
  36796. return json
  36797. }
  36798. get from() {
  36799. return this.file || this.id
  36800. }
  36801. }
  36802. input = Input;
  36803. Input.default = Input;
  36804. if (terminalHighlight && terminalHighlight.registerInput) {
  36805. terminalHighlight.registerInput(Input);
  36806. }
  36807. return input;
  36808. }
  36809. var root$1;
  36810. var hasRequiredRoot$1;
  36811. function requireRoot$1 () {
  36812. if (hasRequiredRoot$1) return root$1;
  36813. hasRequiredRoot$1 = 1;
  36814. let Container = /*@__PURE__*/ requireContainer$1();
  36815. let LazyResult, Processor;
  36816. class Root extends Container {
  36817. constructor(defaults) {
  36818. super(defaults);
  36819. this.type = 'root';
  36820. if (!this.nodes) this.nodes = [];
  36821. }
  36822. normalize(child, sample, type) {
  36823. let nodes = super.normalize(child);
  36824. if (sample) {
  36825. if (type === 'prepend') {
  36826. if (this.nodes.length > 1) {
  36827. sample.raws.before = this.nodes[1].raws.before;
  36828. } else {
  36829. delete sample.raws.before;
  36830. }
  36831. } else if (this.first !== sample) {
  36832. for (let node of nodes) {
  36833. node.raws.before = sample.raws.before;
  36834. }
  36835. }
  36836. }
  36837. return nodes
  36838. }
  36839. removeChild(child, ignore) {
  36840. let index = this.index(child);
  36841. if (!ignore && index === 0 && this.nodes.length > 1) {
  36842. this.nodes[1].raws.before = this.nodes[index].raws.before;
  36843. }
  36844. return super.removeChild(child)
  36845. }
  36846. toResult(opts = {}) {
  36847. let lazy = new LazyResult(new Processor(), this, opts);
  36848. return lazy.stringify()
  36849. }
  36850. }
  36851. Root.registerLazyResult = dependant => {
  36852. LazyResult = dependant;
  36853. };
  36854. Root.registerProcessor = dependant => {
  36855. Processor = dependant;
  36856. };
  36857. root$1 = Root;
  36858. Root.default = Root;
  36859. Container.registerRoot(Root);
  36860. return root$1;
  36861. }
  36862. var list_1;
  36863. var hasRequiredList;
  36864. function requireList () {
  36865. if (hasRequiredList) return list_1;
  36866. hasRequiredList = 1;
  36867. let list = {
  36868. comma(string) {
  36869. return list.split(string, [','], true)
  36870. },
  36871. space(string) {
  36872. let spaces = [' ', '\n', '\t'];
  36873. return list.split(string, spaces)
  36874. },
  36875. split(string, separators, last) {
  36876. let array = [];
  36877. let current = '';
  36878. let split = false;
  36879. let func = 0;
  36880. let inQuote = false;
  36881. let prevQuote = '';
  36882. let escape = false;
  36883. for (let letter of string) {
  36884. if (escape) {
  36885. escape = false;
  36886. } else if (letter === '\\') {
  36887. escape = true;
  36888. } else if (inQuote) {
  36889. if (letter === prevQuote) {
  36890. inQuote = false;
  36891. }
  36892. } else if (letter === '"' || letter === "'") {
  36893. inQuote = true;
  36894. prevQuote = letter;
  36895. } else if (letter === '(') {
  36896. func += 1;
  36897. } else if (letter === ')') {
  36898. if (func > 0) func -= 1;
  36899. } else if (func === 0) {
  36900. if (separators.includes(letter)) split = true;
  36901. }
  36902. if (split) {
  36903. if (current !== '') array.push(current.trim());
  36904. current = '';
  36905. split = false;
  36906. } else {
  36907. current += letter;
  36908. }
  36909. }
  36910. if (last || current !== '') array.push(current.trim());
  36911. return array
  36912. }
  36913. };
  36914. list_1 = list;
  36915. list.default = list;
  36916. return list_1;
  36917. }
  36918. var rule;
  36919. var hasRequiredRule;
  36920. function requireRule () {
  36921. if (hasRequiredRule) return rule;
  36922. hasRequiredRule = 1;
  36923. let Container = /*@__PURE__*/ requireContainer$1();
  36924. let list = /*@__PURE__*/ requireList();
  36925. class Rule extends Container {
  36926. constructor(defaults) {
  36927. super(defaults);
  36928. this.type = 'rule';
  36929. if (!this.nodes) this.nodes = [];
  36930. }
  36931. get selectors() {
  36932. return list.comma(this.selector)
  36933. }
  36934. set selectors(values) {
  36935. let match = this.selector ? this.selector.match(/,\s*/) : null;
  36936. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  36937. this.selector = values.join(sep);
  36938. }
  36939. }
  36940. rule = Rule;
  36941. Rule.default = Rule;
  36942. Container.registerRule(Rule);
  36943. return rule;
  36944. }
  36945. var fromJSON_1;
  36946. var hasRequiredFromJSON;
  36947. function requireFromJSON () {
  36948. if (hasRequiredFromJSON) return fromJSON_1;
  36949. hasRequiredFromJSON = 1;
  36950. let AtRule = /*@__PURE__*/ requireAtRule();
  36951. let Comment = /*@__PURE__*/ requireComment$1();
  36952. let Declaration = /*@__PURE__*/ requireDeclaration();
  36953. let Input = /*@__PURE__*/ requireInput();
  36954. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  36955. let Root = /*@__PURE__*/ requireRoot$1();
  36956. let Rule = /*@__PURE__*/ requireRule();
  36957. function fromJSON(json, inputs) {
  36958. if (Array.isArray(json)) return json.map(n => fromJSON(n))
  36959. let { inputs: ownInputs, ...defaults } = json;
  36960. if (ownInputs) {
  36961. inputs = [];
  36962. for (let input of ownInputs) {
  36963. let inputHydrated = { ...input, __proto__: Input.prototype };
  36964. if (inputHydrated.map) {
  36965. inputHydrated.map = {
  36966. ...inputHydrated.map,
  36967. __proto__: PreviousMap.prototype
  36968. };
  36969. }
  36970. inputs.push(inputHydrated);
  36971. }
  36972. }
  36973. if (defaults.nodes) {
  36974. defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
  36975. }
  36976. if (defaults.source) {
  36977. let { inputId, ...source } = defaults.source;
  36978. defaults.source = source;
  36979. if (inputId != null) {
  36980. defaults.source.input = inputs[inputId];
  36981. }
  36982. }
  36983. if (defaults.type === 'root') {
  36984. return new Root(defaults)
  36985. } else if (defaults.type === 'decl') {
  36986. return new Declaration(defaults)
  36987. } else if (defaults.type === 'rule') {
  36988. return new Rule(defaults)
  36989. } else if (defaults.type === 'comment') {
  36990. return new Comment(defaults)
  36991. } else if (defaults.type === 'atrule') {
  36992. return new AtRule(defaults)
  36993. } else {
  36994. throw new Error('Unknown node type: ' + json.type)
  36995. }
  36996. }
  36997. fromJSON_1 = fromJSON;
  36998. fromJSON.default = fromJSON;
  36999. return fromJSON_1;
  37000. }
  37001. var mapGenerator;
  37002. var hasRequiredMapGenerator;
  37003. function requireMapGenerator () {
  37004. if (hasRequiredMapGenerator) return mapGenerator;
  37005. hasRequiredMapGenerator = 1;
  37006. let { dirname, relative, resolve, sep } = require$$1;
  37007. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  37008. let { pathToFileURL } = require$$2;
  37009. let Input = /*@__PURE__*/ requireInput();
  37010. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  37011. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  37012. class MapGenerator {
  37013. constructor(stringify, root, opts, cssString) {
  37014. this.stringify = stringify;
  37015. this.mapOpts = opts.map || {};
  37016. this.root = root;
  37017. this.opts = opts;
  37018. this.css = cssString;
  37019. this.originalCSS = cssString;
  37020. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  37021. this.memoizedFileURLs = new Map();
  37022. this.memoizedPaths = new Map();
  37023. this.memoizedURLs = new Map();
  37024. }
  37025. addAnnotation() {
  37026. let content;
  37027. if (this.isInline()) {
  37028. content =
  37029. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  37030. } else if (typeof this.mapOpts.annotation === 'string') {
  37031. content = this.mapOpts.annotation;
  37032. } else if (typeof this.mapOpts.annotation === 'function') {
  37033. content = this.mapOpts.annotation(this.opts.to, this.root);
  37034. } else {
  37035. content = this.outputFile() + '.map';
  37036. }
  37037. let eol = '\n';
  37038. if (this.css.includes('\r\n')) eol = '\r\n';
  37039. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  37040. }
  37041. applyPrevMaps() {
  37042. for (let prev of this.previous()) {
  37043. let from = this.toUrl(this.path(prev.file));
  37044. let root = prev.root || dirname(prev.file);
  37045. let map;
  37046. if (this.mapOpts.sourcesContent === false) {
  37047. map = new SourceMapConsumer(prev.text);
  37048. if (map.sourcesContent) {
  37049. map.sourcesContent = null;
  37050. }
  37051. } else {
  37052. map = prev.consumer();
  37053. }
  37054. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  37055. }
  37056. }
  37057. clearAnnotation() {
  37058. if (this.mapOpts.annotation === false) return
  37059. if (this.root) {
  37060. let node;
  37061. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  37062. node = this.root.nodes[i];
  37063. if (node.type !== 'comment') continue
  37064. if (node.text.startsWith('# sourceMappingURL=')) {
  37065. this.root.removeChild(i);
  37066. }
  37067. }
  37068. } else if (this.css) {
  37069. this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
  37070. }
  37071. }
  37072. generate() {
  37073. this.clearAnnotation();
  37074. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  37075. return this.generateMap()
  37076. } else {
  37077. let result = '';
  37078. this.stringify(this.root, i => {
  37079. result += i;
  37080. });
  37081. return [result]
  37082. }
  37083. }
  37084. generateMap() {
  37085. if (this.root) {
  37086. this.generateString();
  37087. } else if (this.previous().length === 1) {
  37088. let prev = this.previous()[0].consumer();
  37089. prev.file = this.outputFile();
  37090. this.map = SourceMapGenerator.fromSourceMap(prev, {
  37091. ignoreInvalidMapping: true
  37092. });
  37093. } else {
  37094. this.map = new SourceMapGenerator({
  37095. file: this.outputFile(),
  37096. ignoreInvalidMapping: true
  37097. });
  37098. this.map.addMapping({
  37099. generated: { column: 0, line: 1 },
  37100. original: { column: 0, line: 1 },
  37101. source: this.opts.from
  37102. ? this.toUrl(this.path(this.opts.from))
  37103. : '<no source>'
  37104. });
  37105. }
  37106. if (this.isSourcesContent()) this.setSourcesContent();
  37107. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  37108. if (this.isAnnotation()) this.addAnnotation();
  37109. if (this.isInline()) {
  37110. return [this.css]
  37111. } else {
  37112. return [this.css, this.map]
  37113. }
  37114. }
  37115. generateString() {
  37116. this.css = '';
  37117. this.map = new SourceMapGenerator({
  37118. file: this.outputFile(),
  37119. ignoreInvalidMapping: true
  37120. });
  37121. let line = 1;
  37122. let column = 1;
  37123. let noSource = '<no source>';
  37124. let mapping = {
  37125. generated: { column: 0, line: 0 },
  37126. original: { column: 0, line: 0 },
  37127. source: ''
  37128. };
  37129. let last, lines;
  37130. this.stringify(this.root, (str, node, type) => {
  37131. this.css += str;
  37132. if (node && type !== 'end') {
  37133. mapping.generated.line = line;
  37134. mapping.generated.column = column - 1;
  37135. if (node.source && node.source.start) {
  37136. mapping.source = this.sourcePath(node);
  37137. mapping.original.line = node.source.start.line;
  37138. mapping.original.column = node.source.start.column - 1;
  37139. this.map.addMapping(mapping);
  37140. } else {
  37141. mapping.source = noSource;
  37142. mapping.original.line = 1;
  37143. mapping.original.column = 0;
  37144. this.map.addMapping(mapping);
  37145. }
  37146. }
  37147. lines = str.match(/\n/g);
  37148. if (lines) {
  37149. line += lines.length;
  37150. last = str.lastIndexOf('\n');
  37151. column = str.length - last;
  37152. } else {
  37153. column += str.length;
  37154. }
  37155. if (node && type !== 'start') {
  37156. let p = node.parent || { raws: {} };
  37157. let childless =
  37158. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  37159. if (!childless || node !== p.last || p.raws.semicolon) {
  37160. if (node.source && node.source.end) {
  37161. mapping.source = this.sourcePath(node);
  37162. mapping.original.line = node.source.end.line;
  37163. mapping.original.column = node.source.end.column - 1;
  37164. mapping.generated.line = line;
  37165. mapping.generated.column = column - 2;
  37166. this.map.addMapping(mapping);
  37167. } else {
  37168. mapping.source = noSource;
  37169. mapping.original.line = 1;
  37170. mapping.original.column = 0;
  37171. mapping.generated.line = line;
  37172. mapping.generated.column = column - 1;
  37173. this.map.addMapping(mapping);
  37174. }
  37175. }
  37176. }
  37177. });
  37178. }
  37179. isAnnotation() {
  37180. if (this.isInline()) {
  37181. return true
  37182. }
  37183. if (typeof this.mapOpts.annotation !== 'undefined') {
  37184. return this.mapOpts.annotation
  37185. }
  37186. if (this.previous().length) {
  37187. return this.previous().some(i => i.annotation)
  37188. }
  37189. return true
  37190. }
  37191. isInline() {
  37192. if (typeof this.mapOpts.inline !== 'undefined') {
  37193. return this.mapOpts.inline
  37194. }
  37195. let annotation = this.mapOpts.annotation;
  37196. if (typeof annotation !== 'undefined' && annotation !== true) {
  37197. return false
  37198. }
  37199. if (this.previous().length) {
  37200. return this.previous().some(i => i.inline)
  37201. }
  37202. return true
  37203. }
  37204. isMap() {
  37205. if (typeof this.opts.map !== 'undefined') {
  37206. return !!this.opts.map
  37207. }
  37208. return this.previous().length > 0
  37209. }
  37210. isSourcesContent() {
  37211. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  37212. return this.mapOpts.sourcesContent
  37213. }
  37214. if (this.previous().length) {
  37215. return this.previous().some(i => i.withContent())
  37216. }
  37217. return true
  37218. }
  37219. outputFile() {
  37220. if (this.opts.to) {
  37221. return this.path(this.opts.to)
  37222. } else if (this.opts.from) {
  37223. return this.path(this.opts.from)
  37224. } else {
  37225. return 'to.css'
  37226. }
  37227. }
  37228. path(file) {
  37229. if (this.mapOpts.absolute) return file
  37230. if (file.charCodeAt(0) === 60 /* `<` */) return file
  37231. if (/^\w+:\/\//.test(file)) return file
  37232. let cached = this.memoizedPaths.get(file);
  37233. if (cached) return cached
  37234. let from = this.opts.to ? dirname(this.opts.to) : '.';
  37235. if (typeof this.mapOpts.annotation === 'string') {
  37236. from = dirname(resolve(from, this.mapOpts.annotation));
  37237. }
  37238. let path = relative(from, file);
  37239. this.memoizedPaths.set(file, path);
  37240. return path
  37241. }
  37242. previous() {
  37243. if (!this.previousMaps) {
  37244. this.previousMaps = [];
  37245. if (this.root) {
  37246. this.root.walk(node => {
  37247. if (node.source && node.source.input.map) {
  37248. let map = node.source.input.map;
  37249. if (!this.previousMaps.includes(map)) {
  37250. this.previousMaps.push(map);
  37251. }
  37252. }
  37253. });
  37254. } else {
  37255. let input = new Input(this.originalCSS, this.opts);
  37256. if (input.map) this.previousMaps.push(input.map);
  37257. }
  37258. }
  37259. return this.previousMaps
  37260. }
  37261. setSourcesContent() {
  37262. let already = {};
  37263. if (this.root) {
  37264. this.root.walk(node => {
  37265. if (node.source) {
  37266. let from = node.source.input.from;
  37267. if (from && !already[from]) {
  37268. already[from] = true;
  37269. let fromUrl = this.usesFileUrls
  37270. ? this.toFileUrl(from)
  37271. : this.toUrl(this.path(from));
  37272. this.map.setSourceContent(fromUrl, node.source.input.css);
  37273. }
  37274. }
  37275. });
  37276. } else if (this.css) {
  37277. let from = this.opts.from
  37278. ? this.toUrl(this.path(this.opts.from))
  37279. : '<no source>';
  37280. this.map.setSourceContent(from, this.css);
  37281. }
  37282. }
  37283. sourcePath(node) {
  37284. if (this.mapOpts.from) {
  37285. return this.toUrl(this.mapOpts.from)
  37286. } else if (this.usesFileUrls) {
  37287. return this.toFileUrl(node.source.input.from)
  37288. } else {
  37289. return this.toUrl(this.path(node.source.input.from))
  37290. }
  37291. }
  37292. toBase64(str) {
  37293. if (Buffer$1) {
  37294. return Buffer$1.from(str).toString('base64')
  37295. } else {
  37296. return window.btoa(unescape(encodeURIComponent(str)))
  37297. }
  37298. }
  37299. toFileUrl(path) {
  37300. let cached = this.memoizedFileURLs.get(path);
  37301. if (cached) return cached
  37302. if (pathToFileURL) {
  37303. let fileURL = pathToFileURL(path).toString();
  37304. this.memoizedFileURLs.set(path, fileURL);
  37305. return fileURL
  37306. } else {
  37307. throw new Error(
  37308. '`map.absolute` option is not available in this PostCSS build'
  37309. )
  37310. }
  37311. }
  37312. toUrl(path) {
  37313. let cached = this.memoizedURLs.get(path);
  37314. if (cached) return cached
  37315. if (sep === '\\') {
  37316. path = path.replace(/\\/g, '/');
  37317. }
  37318. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  37319. this.memoizedURLs.set(path, url);
  37320. return url
  37321. }
  37322. }
  37323. mapGenerator = MapGenerator;
  37324. return mapGenerator;
  37325. }
  37326. var parser$1;
  37327. var hasRequiredParser$1;
  37328. function requireParser$1 () {
  37329. if (hasRequiredParser$1) return parser$1;
  37330. hasRequiredParser$1 = 1;
  37331. let AtRule = /*@__PURE__*/ requireAtRule();
  37332. let Comment = /*@__PURE__*/ requireComment$1();
  37333. let Declaration = /*@__PURE__*/ requireDeclaration();
  37334. let Root = /*@__PURE__*/ requireRoot$1();
  37335. let Rule = /*@__PURE__*/ requireRule();
  37336. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  37337. const SAFE_COMMENT_NEIGHBOR = {
  37338. empty: true,
  37339. space: true
  37340. };
  37341. function findLastWithPosition(tokens) {
  37342. for (let i = tokens.length - 1; i >= 0; i--) {
  37343. let token = tokens[i];
  37344. let pos = token[3] || token[2];
  37345. if (pos) return pos
  37346. }
  37347. }
  37348. class Parser {
  37349. constructor(input) {
  37350. this.input = input;
  37351. this.root = new Root();
  37352. this.current = this.root;
  37353. this.spaces = '';
  37354. this.semicolon = false;
  37355. this.createTokenizer();
  37356. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  37357. }
  37358. atrule(token) {
  37359. let node = new AtRule();
  37360. node.name = token[1].slice(1);
  37361. if (node.name === '') {
  37362. this.unnamedAtrule(node, token);
  37363. }
  37364. this.init(node, token[2]);
  37365. let type;
  37366. let prev;
  37367. let shift;
  37368. let last = false;
  37369. let open = false;
  37370. let params = [];
  37371. let brackets = [];
  37372. while (!this.tokenizer.endOfFile()) {
  37373. token = this.tokenizer.nextToken();
  37374. type = token[0];
  37375. if (type === '(' || type === '[') {
  37376. brackets.push(type === '(' ? ')' : ']');
  37377. } else if (type === '{' && brackets.length > 0) {
  37378. brackets.push('}');
  37379. } else if (type === brackets[brackets.length - 1]) {
  37380. brackets.pop();
  37381. }
  37382. if (brackets.length === 0) {
  37383. if (type === ';') {
  37384. node.source.end = this.getPosition(token[2]);
  37385. node.source.end.offset++;
  37386. this.semicolon = true;
  37387. break
  37388. } else if (type === '{') {
  37389. open = true;
  37390. break
  37391. } else if (type === '}') {
  37392. if (params.length > 0) {
  37393. shift = params.length - 1;
  37394. prev = params[shift];
  37395. while (prev && prev[0] === 'space') {
  37396. prev = params[--shift];
  37397. }
  37398. if (prev) {
  37399. node.source.end = this.getPosition(prev[3] || prev[2]);
  37400. node.source.end.offset++;
  37401. }
  37402. }
  37403. this.end(token);
  37404. break
  37405. } else {
  37406. params.push(token);
  37407. }
  37408. } else {
  37409. params.push(token);
  37410. }
  37411. if (this.tokenizer.endOfFile()) {
  37412. last = true;
  37413. break
  37414. }
  37415. }
  37416. node.raws.between = this.spacesAndCommentsFromEnd(params);
  37417. if (params.length) {
  37418. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  37419. this.raw(node, 'params', params);
  37420. if (last) {
  37421. token = params[params.length - 1];
  37422. node.source.end = this.getPosition(token[3] || token[2]);
  37423. node.source.end.offset++;
  37424. this.spaces = node.raws.between;
  37425. node.raws.between = '';
  37426. }
  37427. } else {
  37428. node.raws.afterName = '';
  37429. node.params = '';
  37430. }
  37431. if (open) {
  37432. node.nodes = [];
  37433. this.current = node;
  37434. }
  37435. }
  37436. checkMissedSemicolon(tokens) {
  37437. let colon = this.colon(tokens);
  37438. if (colon === false) return
  37439. let founded = 0;
  37440. let token;
  37441. for (let j = colon - 1; j >= 0; j--) {
  37442. token = tokens[j];
  37443. if (token[0] !== 'space') {
  37444. founded += 1;
  37445. if (founded === 2) break
  37446. }
  37447. }
  37448. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  37449. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  37450. // And because we need it after that one we do +1 to get the next one.
  37451. throw this.input.error(
  37452. 'Missed semicolon',
  37453. token[0] === 'word' ? token[3] + 1 : token[2]
  37454. )
  37455. }
  37456. colon(tokens) {
  37457. let brackets = 0;
  37458. let prev, token, type;
  37459. for (let [i, element] of tokens.entries()) {
  37460. token = element;
  37461. type = token[0];
  37462. if (type === '(') {
  37463. brackets += 1;
  37464. }
  37465. if (type === ')') {
  37466. brackets -= 1;
  37467. }
  37468. if (brackets === 0 && type === ':') {
  37469. if (!prev) {
  37470. this.doubleColon(token);
  37471. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  37472. continue
  37473. } else {
  37474. return i
  37475. }
  37476. }
  37477. prev = token;
  37478. }
  37479. return false
  37480. }
  37481. comment(token) {
  37482. let node = new Comment();
  37483. this.init(node, token[2]);
  37484. node.source.end = this.getPosition(token[3] || token[2]);
  37485. node.source.end.offset++;
  37486. let text = token[1].slice(2, -2);
  37487. if (/^\s*$/.test(text)) {
  37488. node.text = '';
  37489. node.raws.left = text;
  37490. node.raws.right = '';
  37491. } else {
  37492. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  37493. node.text = match[2];
  37494. node.raws.left = match[1];
  37495. node.raws.right = match[3];
  37496. }
  37497. }
  37498. createTokenizer() {
  37499. this.tokenizer = tokenizer(this.input);
  37500. }
  37501. decl(tokens, customProperty) {
  37502. let node = new Declaration();
  37503. this.init(node, tokens[0][2]);
  37504. let last = tokens[tokens.length - 1];
  37505. if (last[0] === ';') {
  37506. this.semicolon = true;
  37507. tokens.pop();
  37508. }
  37509. node.source.end = this.getPosition(
  37510. last[3] || last[2] || findLastWithPosition(tokens)
  37511. );
  37512. node.source.end.offset++;
  37513. while (tokens[0][0] !== 'word') {
  37514. if (tokens.length === 1) this.unknownWord(tokens);
  37515. node.raws.before += tokens.shift()[1];
  37516. }
  37517. node.source.start = this.getPosition(tokens[0][2]);
  37518. node.prop = '';
  37519. while (tokens.length) {
  37520. let type = tokens[0][0];
  37521. if (type === ':' || type === 'space' || type === 'comment') {
  37522. break
  37523. }
  37524. node.prop += tokens.shift()[1];
  37525. }
  37526. node.raws.between = '';
  37527. let token;
  37528. while (tokens.length) {
  37529. token = tokens.shift();
  37530. if (token[0] === ':') {
  37531. node.raws.between += token[1];
  37532. break
  37533. } else {
  37534. if (token[0] === 'word' && /\w/.test(token[1])) {
  37535. this.unknownWord([token]);
  37536. }
  37537. node.raws.between += token[1];
  37538. }
  37539. }
  37540. if (node.prop[0] === '_' || node.prop[0] === '*') {
  37541. node.raws.before += node.prop[0];
  37542. node.prop = node.prop.slice(1);
  37543. }
  37544. let firstSpaces = [];
  37545. let next;
  37546. while (tokens.length) {
  37547. next = tokens[0][0];
  37548. if (next !== 'space' && next !== 'comment') break
  37549. firstSpaces.push(tokens.shift());
  37550. }
  37551. this.precheckMissedSemicolon(tokens);
  37552. for (let i = tokens.length - 1; i >= 0; i--) {
  37553. token = tokens[i];
  37554. if (token[1].toLowerCase() === '!important') {
  37555. node.important = true;
  37556. let string = this.stringFrom(tokens, i);
  37557. string = this.spacesFromEnd(tokens) + string;
  37558. if (string !== ' !important') node.raws.important = string;
  37559. break
  37560. } else if (token[1].toLowerCase() === 'important') {
  37561. let cache = tokens.slice(0);
  37562. let str = '';
  37563. for (let j = i; j > 0; j--) {
  37564. let type = cache[j][0];
  37565. if (str.trim().startsWith('!') && type !== 'space') {
  37566. break
  37567. }
  37568. str = cache.pop()[1] + str;
  37569. }
  37570. if (str.trim().startsWith('!')) {
  37571. node.important = true;
  37572. node.raws.important = str;
  37573. tokens = cache;
  37574. }
  37575. }
  37576. if (token[0] !== 'space' && token[0] !== 'comment') {
  37577. break
  37578. }
  37579. }
  37580. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  37581. if (hasWord) {
  37582. node.raws.between += firstSpaces.map(i => i[1]).join('');
  37583. firstSpaces = [];
  37584. }
  37585. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  37586. if (node.value.includes(':') && !customProperty) {
  37587. this.checkMissedSemicolon(tokens);
  37588. }
  37589. }
  37590. doubleColon(token) {
  37591. throw this.input.error(
  37592. 'Double colon',
  37593. { offset: token[2] },
  37594. { offset: token[2] + token[1].length }
  37595. )
  37596. }
  37597. emptyRule(token) {
  37598. let node = new Rule();
  37599. this.init(node, token[2]);
  37600. node.selector = '';
  37601. node.raws.between = '';
  37602. this.current = node;
  37603. }
  37604. end(token) {
  37605. if (this.current.nodes && this.current.nodes.length) {
  37606. this.current.raws.semicolon = this.semicolon;
  37607. }
  37608. this.semicolon = false;
  37609. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  37610. this.spaces = '';
  37611. if (this.current.parent) {
  37612. this.current.source.end = this.getPosition(token[2]);
  37613. this.current.source.end.offset++;
  37614. this.current = this.current.parent;
  37615. } else {
  37616. this.unexpectedClose(token);
  37617. }
  37618. }
  37619. endFile() {
  37620. if (this.current.parent) this.unclosedBlock();
  37621. if (this.current.nodes && this.current.nodes.length) {
  37622. this.current.raws.semicolon = this.semicolon;
  37623. }
  37624. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  37625. this.root.source.end = this.getPosition(this.tokenizer.position());
  37626. }
  37627. freeSemicolon(token) {
  37628. this.spaces += token[1];
  37629. if (this.current.nodes) {
  37630. let prev = this.current.nodes[this.current.nodes.length - 1];
  37631. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  37632. prev.raws.ownSemicolon = this.spaces;
  37633. this.spaces = '';
  37634. }
  37635. }
  37636. }
  37637. // Helpers
  37638. getPosition(offset) {
  37639. let pos = this.input.fromOffset(offset);
  37640. return {
  37641. column: pos.col,
  37642. line: pos.line,
  37643. offset
  37644. }
  37645. }
  37646. init(node, offset) {
  37647. this.current.push(node);
  37648. node.source = {
  37649. input: this.input,
  37650. start: this.getPosition(offset)
  37651. };
  37652. node.raws.before = this.spaces;
  37653. this.spaces = '';
  37654. if (node.type !== 'comment') this.semicolon = false;
  37655. }
  37656. other(start) {
  37657. let end = false;
  37658. let type = null;
  37659. let colon = false;
  37660. let bracket = null;
  37661. let brackets = [];
  37662. let customProperty = start[1].startsWith('--');
  37663. let tokens = [];
  37664. let token = start;
  37665. while (token) {
  37666. type = token[0];
  37667. tokens.push(token);
  37668. if (type === '(' || type === '[') {
  37669. if (!bracket) bracket = token;
  37670. brackets.push(type === '(' ? ')' : ']');
  37671. } else if (customProperty && colon && type === '{') {
  37672. if (!bracket) bracket = token;
  37673. brackets.push('}');
  37674. } else if (brackets.length === 0) {
  37675. if (type === ';') {
  37676. if (colon) {
  37677. this.decl(tokens, customProperty);
  37678. return
  37679. } else {
  37680. break
  37681. }
  37682. } else if (type === '{') {
  37683. this.rule(tokens);
  37684. return
  37685. } else if (type === '}') {
  37686. this.tokenizer.back(tokens.pop());
  37687. end = true;
  37688. break
  37689. } else if (type === ':') {
  37690. colon = true;
  37691. }
  37692. } else if (type === brackets[brackets.length - 1]) {
  37693. brackets.pop();
  37694. if (brackets.length === 0) bracket = null;
  37695. }
  37696. token = this.tokenizer.nextToken();
  37697. }
  37698. if (this.tokenizer.endOfFile()) end = true;
  37699. if (brackets.length > 0) this.unclosedBracket(bracket);
  37700. if (end && colon) {
  37701. if (!customProperty) {
  37702. while (tokens.length) {
  37703. token = tokens[tokens.length - 1][0];
  37704. if (token !== 'space' && token !== 'comment') break
  37705. this.tokenizer.back(tokens.pop());
  37706. }
  37707. }
  37708. this.decl(tokens, customProperty);
  37709. } else {
  37710. this.unknownWord(tokens);
  37711. }
  37712. }
  37713. parse() {
  37714. let token;
  37715. while (!this.tokenizer.endOfFile()) {
  37716. token = this.tokenizer.nextToken();
  37717. switch (token[0]) {
  37718. case 'space':
  37719. this.spaces += token[1];
  37720. break
  37721. case ';':
  37722. this.freeSemicolon(token);
  37723. break
  37724. case '}':
  37725. this.end(token);
  37726. break
  37727. case 'comment':
  37728. this.comment(token);
  37729. break
  37730. case 'at-word':
  37731. this.atrule(token);
  37732. break
  37733. case '{':
  37734. this.emptyRule(token);
  37735. break
  37736. default:
  37737. this.other(token);
  37738. break
  37739. }
  37740. }
  37741. this.endFile();
  37742. }
  37743. precheckMissedSemicolon(/* tokens */) {
  37744. // Hook for Safe Parser
  37745. }
  37746. raw(node, prop, tokens, customProperty) {
  37747. let token, type;
  37748. let length = tokens.length;
  37749. let value = '';
  37750. let clean = true;
  37751. let next, prev;
  37752. for (let i = 0; i < length; i += 1) {
  37753. token = tokens[i];
  37754. type = token[0];
  37755. if (type === 'space' && i === length - 1 && !customProperty) {
  37756. clean = false;
  37757. } else if (type === 'comment') {
  37758. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  37759. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  37760. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  37761. if (value.slice(-1) === ',') {
  37762. clean = false;
  37763. } else {
  37764. value += token[1];
  37765. }
  37766. } else {
  37767. clean = false;
  37768. }
  37769. } else {
  37770. value += token[1];
  37771. }
  37772. }
  37773. if (!clean) {
  37774. let raw = tokens.reduce((all, i) => all + i[1], '');
  37775. node.raws[prop] = { raw, value };
  37776. }
  37777. node[prop] = value;
  37778. }
  37779. rule(tokens) {
  37780. tokens.pop();
  37781. let node = new Rule();
  37782. this.init(node, tokens[0][2]);
  37783. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  37784. this.raw(node, 'selector', tokens);
  37785. this.current = node;
  37786. }
  37787. spacesAndCommentsFromEnd(tokens) {
  37788. let lastTokenType;
  37789. let spaces = '';
  37790. while (tokens.length) {
  37791. lastTokenType = tokens[tokens.length - 1][0];
  37792. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  37793. spaces = tokens.pop()[1] + spaces;
  37794. }
  37795. return spaces
  37796. }
  37797. // Errors
  37798. spacesAndCommentsFromStart(tokens) {
  37799. let next;
  37800. let spaces = '';
  37801. while (tokens.length) {
  37802. next = tokens[0][0];
  37803. if (next !== 'space' && next !== 'comment') break
  37804. spaces += tokens.shift()[1];
  37805. }
  37806. return spaces
  37807. }
  37808. spacesFromEnd(tokens) {
  37809. let lastTokenType;
  37810. let spaces = '';
  37811. while (tokens.length) {
  37812. lastTokenType = tokens[tokens.length - 1][0];
  37813. if (lastTokenType !== 'space') break
  37814. spaces = tokens.pop()[1] + spaces;
  37815. }
  37816. return spaces
  37817. }
  37818. stringFrom(tokens, from) {
  37819. let result = '';
  37820. for (let i = from; i < tokens.length; i++) {
  37821. result += tokens[i][1];
  37822. }
  37823. tokens.splice(from, tokens.length - from);
  37824. return result
  37825. }
  37826. unclosedBlock() {
  37827. let pos = this.current.source.start;
  37828. throw this.input.error('Unclosed block', pos.line, pos.column)
  37829. }
  37830. unclosedBracket(bracket) {
  37831. throw this.input.error(
  37832. 'Unclosed bracket',
  37833. { offset: bracket[2] },
  37834. { offset: bracket[2] + 1 }
  37835. )
  37836. }
  37837. unexpectedClose(token) {
  37838. throw this.input.error(
  37839. 'Unexpected }',
  37840. { offset: token[2] },
  37841. { offset: token[2] + 1 }
  37842. )
  37843. }
  37844. unknownWord(tokens) {
  37845. throw this.input.error(
  37846. 'Unknown word',
  37847. { offset: tokens[0][2] },
  37848. { offset: tokens[0][2] + tokens[0][1].length }
  37849. )
  37850. }
  37851. unnamedAtrule(node, token) {
  37852. throw this.input.error(
  37853. 'At-rule without name',
  37854. { offset: token[2] },
  37855. { offset: token[2] + token[1].length }
  37856. )
  37857. }
  37858. }
  37859. parser$1 = Parser;
  37860. return parser$1;
  37861. }
  37862. var parse_1;
  37863. var hasRequiredParse;
  37864. function requireParse () {
  37865. if (hasRequiredParse) return parse_1;
  37866. hasRequiredParse = 1;
  37867. let Container = /*@__PURE__*/ requireContainer$1();
  37868. let Input = /*@__PURE__*/ requireInput();
  37869. let Parser = /*@__PURE__*/ requireParser$1();
  37870. function parse(css, opts) {
  37871. let input = new Input(css, opts);
  37872. let parser = new Parser(input);
  37873. try {
  37874. parser.parse();
  37875. } catch (e) {
  37876. if (browser$1.env.NODE_ENV !== 'production') {
  37877. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  37878. if (/\.scss$/i.test(opts.from)) {
  37879. e.message +=
  37880. '\nYou tried to parse SCSS with ' +
  37881. 'the standard CSS parser; ' +
  37882. 'try again with the postcss-scss parser';
  37883. } else if (/\.sass/i.test(opts.from)) {
  37884. e.message +=
  37885. '\nYou tried to parse Sass with ' +
  37886. 'the standard CSS parser; ' +
  37887. 'try again with the postcss-sass parser';
  37888. } else if (/\.less$/i.test(opts.from)) {
  37889. e.message +=
  37890. '\nYou tried to parse Less with ' +
  37891. 'the standard CSS parser; ' +
  37892. 'try again with the postcss-less parser';
  37893. }
  37894. }
  37895. }
  37896. throw e
  37897. }
  37898. return parser.root
  37899. }
  37900. parse_1 = parse;
  37901. parse.default = parse;
  37902. Container.registerParse(parse);
  37903. return parse_1;
  37904. }
  37905. var warning;
  37906. var hasRequiredWarning;
  37907. function requireWarning () {
  37908. if (hasRequiredWarning) return warning;
  37909. hasRequiredWarning = 1;
  37910. class Warning {
  37911. constructor(text, opts = {}) {
  37912. this.type = 'warning';
  37913. this.text = text;
  37914. if (opts.node && opts.node.source) {
  37915. let range = opts.node.rangeBy(opts);
  37916. this.line = range.start.line;
  37917. this.column = range.start.column;
  37918. this.endLine = range.end.line;
  37919. this.endColumn = range.end.column;
  37920. }
  37921. for (let opt in opts) this[opt] = opts[opt];
  37922. }
  37923. toString() {
  37924. if (this.node) {
  37925. return this.node.error(this.text, {
  37926. index: this.index,
  37927. plugin: this.plugin,
  37928. word: this.word
  37929. }).message
  37930. }
  37931. if (this.plugin) {
  37932. return this.plugin + ': ' + this.text
  37933. }
  37934. return this.text
  37935. }
  37936. }
  37937. warning = Warning;
  37938. Warning.default = Warning;
  37939. return warning;
  37940. }
  37941. var result;
  37942. var hasRequiredResult;
  37943. function requireResult () {
  37944. if (hasRequiredResult) return result;
  37945. hasRequiredResult = 1;
  37946. let Warning = /*@__PURE__*/ requireWarning();
  37947. class Result {
  37948. constructor(processor, root, opts) {
  37949. this.processor = processor;
  37950. this.messages = [];
  37951. this.root = root;
  37952. this.opts = opts;
  37953. this.css = undefined;
  37954. this.map = undefined;
  37955. }
  37956. toString() {
  37957. return this.css
  37958. }
  37959. warn(text, opts = {}) {
  37960. if (!opts.plugin) {
  37961. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  37962. opts.plugin = this.lastPlugin.postcssPlugin;
  37963. }
  37964. }
  37965. let warning = new Warning(text, opts);
  37966. this.messages.push(warning);
  37967. return warning
  37968. }
  37969. warnings() {
  37970. return this.messages.filter(i => i.type === 'warning')
  37971. }
  37972. get content() {
  37973. return this.css
  37974. }
  37975. }
  37976. result = Result;
  37977. Result.default = Result;
  37978. return result;
  37979. }
  37980. /* eslint-disable no-console */
  37981. var warnOnce;
  37982. var hasRequiredWarnOnce;
  37983. function requireWarnOnce () {
  37984. if (hasRequiredWarnOnce) return warnOnce;
  37985. hasRequiredWarnOnce = 1;
  37986. let printed = {};
  37987. warnOnce = function warnOnce(message) {
  37988. if (printed[message]) return
  37989. printed[message] = true;
  37990. if (typeof console !== 'undefined' && console.warn) {
  37991. console.warn(message);
  37992. }
  37993. };
  37994. return warnOnce;
  37995. }
  37996. var lazyResult;
  37997. var hasRequiredLazyResult;
  37998. function requireLazyResult () {
  37999. if (hasRequiredLazyResult) return lazyResult;
  38000. hasRequiredLazyResult = 1;
  38001. let Container = /*@__PURE__*/ requireContainer$1();
  38002. let Document = /*@__PURE__*/ requireDocument();
  38003. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  38004. let parse = /*@__PURE__*/ requireParse();
  38005. let Result = /*@__PURE__*/ requireResult();
  38006. let Root = /*@__PURE__*/ requireRoot$1();
  38007. let stringify = /*@__PURE__*/ requireStringify();
  38008. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  38009. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  38010. const TYPE_TO_CLASS_NAME = {
  38011. atrule: 'AtRule',
  38012. comment: 'Comment',
  38013. decl: 'Declaration',
  38014. document: 'Document',
  38015. root: 'Root',
  38016. rule: 'Rule'
  38017. };
  38018. const PLUGIN_PROPS = {
  38019. AtRule: true,
  38020. AtRuleExit: true,
  38021. Comment: true,
  38022. CommentExit: true,
  38023. Declaration: true,
  38024. DeclarationExit: true,
  38025. Document: true,
  38026. DocumentExit: true,
  38027. Once: true,
  38028. OnceExit: true,
  38029. postcssPlugin: true,
  38030. prepare: true,
  38031. Root: true,
  38032. RootExit: true,
  38033. Rule: true,
  38034. RuleExit: true
  38035. };
  38036. const NOT_VISITORS = {
  38037. Once: true,
  38038. postcssPlugin: true,
  38039. prepare: true
  38040. };
  38041. const CHILDREN = 0;
  38042. function isPromise(obj) {
  38043. return typeof obj === 'object' && typeof obj.then === 'function'
  38044. }
  38045. function getEvents(node) {
  38046. let key = false;
  38047. let type = TYPE_TO_CLASS_NAME[node.type];
  38048. if (node.type === 'decl') {
  38049. key = node.prop.toLowerCase();
  38050. } else if (node.type === 'atrule') {
  38051. key = node.name.toLowerCase();
  38052. }
  38053. if (key && node.append) {
  38054. return [
  38055. type,
  38056. type + '-' + key,
  38057. CHILDREN,
  38058. type + 'Exit',
  38059. type + 'Exit-' + key
  38060. ]
  38061. } else if (key) {
  38062. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  38063. } else if (node.append) {
  38064. return [type, CHILDREN, type + 'Exit']
  38065. } else {
  38066. return [type, type + 'Exit']
  38067. }
  38068. }
  38069. function toStack(node) {
  38070. let events;
  38071. if (node.type === 'document') {
  38072. events = ['Document', CHILDREN, 'DocumentExit'];
  38073. } else if (node.type === 'root') {
  38074. events = ['Root', CHILDREN, 'RootExit'];
  38075. } else {
  38076. events = getEvents(node);
  38077. }
  38078. return {
  38079. eventIndex: 0,
  38080. events,
  38081. iterator: 0,
  38082. node,
  38083. visitorIndex: 0,
  38084. visitors: []
  38085. }
  38086. }
  38087. function cleanMarks(node) {
  38088. node[isClean] = false;
  38089. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  38090. return node
  38091. }
  38092. let postcss = {};
  38093. class LazyResult {
  38094. constructor(processor, css, opts) {
  38095. this.stringified = false;
  38096. this.processed = false;
  38097. let root;
  38098. if (
  38099. typeof css === 'object' &&
  38100. css !== null &&
  38101. (css.type === 'root' || css.type === 'document')
  38102. ) {
  38103. root = cleanMarks(css);
  38104. } else if (css instanceof LazyResult || css instanceof Result) {
  38105. root = cleanMarks(css.root);
  38106. if (css.map) {
  38107. if (typeof opts.map === 'undefined') opts.map = {};
  38108. if (!opts.map.inline) opts.map.inline = false;
  38109. opts.map.prev = css.map;
  38110. }
  38111. } else {
  38112. let parser = parse;
  38113. if (opts.syntax) parser = opts.syntax.parse;
  38114. if (opts.parser) parser = opts.parser;
  38115. if (parser.parse) parser = parser.parse;
  38116. try {
  38117. root = parser(css, opts);
  38118. } catch (error) {
  38119. this.processed = true;
  38120. this.error = error;
  38121. }
  38122. if (root && !root[my]) {
  38123. /* c8 ignore next 2 */
  38124. Container.rebuild(root);
  38125. }
  38126. }
  38127. this.result = new Result(processor, root, opts);
  38128. this.helpers = { ...postcss, postcss, result: this.result };
  38129. this.plugins = this.processor.plugins.map(plugin => {
  38130. if (typeof plugin === 'object' && plugin.prepare) {
  38131. return { ...plugin, ...plugin.prepare(this.result) }
  38132. } else {
  38133. return plugin
  38134. }
  38135. });
  38136. }
  38137. async() {
  38138. if (this.error) return Promise.reject(this.error)
  38139. if (this.processed) return Promise.resolve(this.result)
  38140. if (!this.processing) {
  38141. this.processing = this.runAsync();
  38142. }
  38143. return this.processing
  38144. }
  38145. catch(onRejected) {
  38146. return this.async().catch(onRejected)
  38147. }
  38148. finally(onFinally) {
  38149. return this.async().then(onFinally, onFinally)
  38150. }
  38151. getAsyncError() {
  38152. throw new Error('Use process(css).then(cb) to work with async plugins')
  38153. }
  38154. handleError(error, node) {
  38155. let plugin = this.result.lastPlugin;
  38156. try {
  38157. if (node) node.addToError(error);
  38158. this.error = error;
  38159. if (error.name === 'CssSyntaxError' && !error.plugin) {
  38160. error.plugin = plugin.postcssPlugin;
  38161. error.setMessage();
  38162. } else if (plugin.postcssVersion) {
  38163. if (browser$1.env.NODE_ENV !== 'production') {
  38164. let pluginName = plugin.postcssPlugin;
  38165. let pluginVer = plugin.postcssVersion;
  38166. let runtimeVer = this.result.processor.version;
  38167. let a = pluginVer.split('.');
  38168. let b = runtimeVer.split('.');
  38169. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  38170. // eslint-disable-next-line no-console
  38171. console.error(
  38172. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  38173. 'version is ' +
  38174. runtimeVer +
  38175. ', but ' +
  38176. pluginName +
  38177. ' uses ' +
  38178. pluginVer +
  38179. '. Perhaps this is the source of the error below.'
  38180. );
  38181. }
  38182. }
  38183. }
  38184. } catch (err) {
  38185. /* c8 ignore next 3 */
  38186. // eslint-disable-next-line no-console
  38187. if (console && console.error) console.error(err);
  38188. }
  38189. return error
  38190. }
  38191. prepareVisitors() {
  38192. this.listeners = {};
  38193. let add = (plugin, type, cb) => {
  38194. if (!this.listeners[type]) this.listeners[type] = [];
  38195. this.listeners[type].push([plugin, cb]);
  38196. };
  38197. for (let plugin of this.plugins) {
  38198. if (typeof plugin === 'object') {
  38199. for (let event in plugin) {
  38200. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  38201. throw new Error(
  38202. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  38203. `Try to update PostCSS (${this.processor.version} now).`
  38204. )
  38205. }
  38206. if (!NOT_VISITORS[event]) {
  38207. if (typeof plugin[event] === 'object') {
  38208. for (let filter in plugin[event]) {
  38209. if (filter === '*') {
  38210. add(plugin, event, plugin[event][filter]);
  38211. } else {
  38212. add(
  38213. plugin,
  38214. event + '-' + filter.toLowerCase(),
  38215. plugin[event][filter]
  38216. );
  38217. }
  38218. }
  38219. } else if (typeof plugin[event] === 'function') {
  38220. add(plugin, event, plugin[event]);
  38221. }
  38222. }
  38223. }
  38224. }
  38225. }
  38226. this.hasListener = Object.keys(this.listeners).length > 0;
  38227. }
  38228. async runAsync() {
  38229. this.plugin = 0;
  38230. for (let i = 0; i < this.plugins.length; i++) {
  38231. let plugin = this.plugins[i];
  38232. let promise = this.runOnRoot(plugin);
  38233. if (isPromise(promise)) {
  38234. try {
  38235. await promise;
  38236. } catch (error) {
  38237. throw this.handleError(error)
  38238. }
  38239. }
  38240. }
  38241. this.prepareVisitors();
  38242. if (this.hasListener) {
  38243. let root = this.result.root;
  38244. while (!root[isClean]) {
  38245. root[isClean] = true;
  38246. let stack = [toStack(root)];
  38247. while (stack.length > 0) {
  38248. let promise = this.visitTick(stack);
  38249. if (isPromise(promise)) {
  38250. try {
  38251. await promise;
  38252. } catch (e) {
  38253. let node = stack[stack.length - 1].node;
  38254. throw this.handleError(e, node)
  38255. }
  38256. }
  38257. }
  38258. }
  38259. if (this.listeners.OnceExit) {
  38260. for (let [plugin, visitor] of this.listeners.OnceExit) {
  38261. this.result.lastPlugin = plugin;
  38262. try {
  38263. if (root.type === 'document') {
  38264. let roots = root.nodes.map(subRoot =>
  38265. visitor(subRoot, this.helpers)
  38266. );
  38267. await Promise.all(roots);
  38268. } else {
  38269. await visitor(root, this.helpers);
  38270. }
  38271. } catch (e) {
  38272. throw this.handleError(e)
  38273. }
  38274. }
  38275. }
  38276. }
  38277. this.processed = true;
  38278. return this.stringify()
  38279. }
  38280. runOnRoot(plugin) {
  38281. this.result.lastPlugin = plugin;
  38282. try {
  38283. if (typeof plugin === 'object' && plugin.Once) {
  38284. if (this.result.root.type === 'document') {
  38285. let roots = this.result.root.nodes.map(root =>
  38286. plugin.Once(root, this.helpers)
  38287. );
  38288. if (isPromise(roots[0])) {
  38289. return Promise.all(roots)
  38290. }
  38291. return roots
  38292. }
  38293. return plugin.Once(this.result.root, this.helpers)
  38294. } else if (typeof plugin === 'function') {
  38295. return plugin(this.result.root, this.result)
  38296. }
  38297. } catch (error) {
  38298. throw this.handleError(error)
  38299. }
  38300. }
  38301. stringify() {
  38302. if (this.error) throw this.error
  38303. if (this.stringified) return this.result
  38304. this.stringified = true;
  38305. this.sync();
  38306. let opts = this.result.opts;
  38307. let str = stringify;
  38308. if (opts.syntax) str = opts.syntax.stringify;
  38309. if (opts.stringifier) str = opts.stringifier;
  38310. if (str.stringify) str = str.stringify;
  38311. let map = new MapGenerator(str, this.result.root, this.result.opts);
  38312. let data = map.generate();
  38313. this.result.css = data[0];
  38314. this.result.map = data[1];
  38315. return this.result
  38316. }
  38317. sync() {
  38318. if (this.error) throw this.error
  38319. if (this.processed) return this.result
  38320. this.processed = true;
  38321. if (this.processing) {
  38322. throw this.getAsyncError()
  38323. }
  38324. for (let plugin of this.plugins) {
  38325. let promise = this.runOnRoot(plugin);
  38326. if (isPromise(promise)) {
  38327. throw this.getAsyncError()
  38328. }
  38329. }
  38330. this.prepareVisitors();
  38331. if (this.hasListener) {
  38332. let root = this.result.root;
  38333. while (!root[isClean]) {
  38334. root[isClean] = true;
  38335. this.walkSync(root);
  38336. }
  38337. if (this.listeners.OnceExit) {
  38338. if (root.type === 'document') {
  38339. for (let subRoot of root.nodes) {
  38340. this.visitSync(this.listeners.OnceExit, subRoot);
  38341. }
  38342. } else {
  38343. this.visitSync(this.listeners.OnceExit, root);
  38344. }
  38345. }
  38346. }
  38347. return this.result
  38348. }
  38349. then(onFulfilled, onRejected) {
  38350. if (browser$1.env.NODE_ENV !== 'production') {
  38351. if (!('from' in this.opts)) {
  38352. warnOnce(
  38353. 'Without `from` option PostCSS could generate wrong source map ' +
  38354. 'and will not find Browserslist config. Set it to CSS file path ' +
  38355. 'or to `undefined` to prevent this warning.'
  38356. );
  38357. }
  38358. }
  38359. return this.async().then(onFulfilled, onRejected)
  38360. }
  38361. toString() {
  38362. return this.css
  38363. }
  38364. visitSync(visitors, node) {
  38365. for (let [plugin, visitor] of visitors) {
  38366. this.result.lastPlugin = plugin;
  38367. let promise;
  38368. try {
  38369. promise = visitor(node, this.helpers);
  38370. } catch (e) {
  38371. throw this.handleError(e, node.proxyOf)
  38372. }
  38373. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  38374. return true
  38375. }
  38376. if (isPromise(promise)) {
  38377. throw this.getAsyncError()
  38378. }
  38379. }
  38380. }
  38381. visitTick(stack) {
  38382. let visit = stack[stack.length - 1];
  38383. let { node, visitors } = visit;
  38384. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  38385. stack.pop();
  38386. return
  38387. }
  38388. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  38389. let [plugin, visitor] = visitors[visit.visitorIndex];
  38390. visit.visitorIndex += 1;
  38391. if (visit.visitorIndex === visitors.length) {
  38392. visit.visitors = [];
  38393. visit.visitorIndex = 0;
  38394. }
  38395. this.result.lastPlugin = plugin;
  38396. try {
  38397. return visitor(node.toProxy(), this.helpers)
  38398. } catch (e) {
  38399. throw this.handleError(e, node)
  38400. }
  38401. }
  38402. if (visit.iterator !== 0) {
  38403. let iterator = visit.iterator;
  38404. let child;
  38405. while ((child = node.nodes[node.indexes[iterator]])) {
  38406. node.indexes[iterator] += 1;
  38407. if (!child[isClean]) {
  38408. child[isClean] = true;
  38409. stack.push(toStack(child));
  38410. return
  38411. }
  38412. }
  38413. visit.iterator = 0;
  38414. delete node.indexes[iterator];
  38415. }
  38416. let events = visit.events;
  38417. while (visit.eventIndex < events.length) {
  38418. let event = events[visit.eventIndex];
  38419. visit.eventIndex += 1;
  38420. if (event === CHILDREN) {
  38421. if (node.nodes && node.nodes.length) {
  38422. node[isClean] = true;
  38423. visit.iterator = node.getIterator();
  38424. }
  38425. return
  38426. } else if (this.listeners[event]) {
  38427. visit.visitors = this.listeners[event];
  38428. return
  38429. }
  38430. }
  38431. stack.pop();
  38432. }
  38433. walkSync(node) {
  38434. node[isClean] = true;
  38435. let events = getEvents(node);
  38436. for (let event of events) {
  38437. if (event === CHILDREN) {
  38438. if (node.nodes) {
  38439. node.each(child => {
  38440. if (!child[isClean]) this.walkSync(child);
  38441. });
  38442. }
  38443. } else {
  38444. let visitors = this.listeners[event];
  38445. if (visitors) {
  38446. if (this.visitSync(visitors, node.toProxy())) return
  38447. }
  38448. }
  38449. }
  38450. }
  38451. warnings() {
  38452. return this.sync().warnings()
  38453. }
  38454. get content() {
  38455. return this.stringify().content
  38456. }
  38457. get css() {
  38458. return this.stringify().css
  38459. }
  38460. get map() {
  38461. return this.stringify().map
  38462. }
  38463. get messages() {
  38464. return this.sync().messages
  38465. }
  38466. get opts() {
  38467. return this.result.opts
  38468. }
  38469. get processor() {
  38470. return this.result.processor
  38471. }
  38472. get root() {
  38473. return this.sync().root
  38474. }
  38475. get [Symbol.toStringTag]() {
  38476. return 'LazyResult'
  38477. }
  38478. }
  38479. LazyResult.registerPostcss = dependant => {
  38480. postcss = dependant;
  38481. };
  38482. lazyResult = LazyResult;
  38483. LazyResult.default = LazyResult;
  38484. Root.registerLazyResult(LazyResult);
  38485. Document.registerLazyResult(LazyResult);
  38486. return lazyResult;
  38487. }
  38488. var noWorkResult;
  38489. var hasRequiredNoWorkResult;
  38490. function requireNoWorkResult () {
  38491. if (hasRequiredNoWorkResult) return noWorkResult;
  38492. hasRequiredNoWorkResult = 1;
  38493. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  38494. let parse = /*@__PURE__*/ requireParse();
  38495. const Result = /*@__PURE__*/ requireResult();
  38496. let stringify = /*@__PURE__*/ requireStringify();
  38497. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  38498. class NoWorkResult {
  38499. constructor(processor, css, opts) {
  38500. css = css.toString();
  38501. this.stringified = false;
  38502. this._processor = processor;
  38503. this._css = css;
  38504. this._opts = opts;
  38505. this._map = undefined;
  38506. let root;
  38507. let str = stringify;
  38508. this.result = new Result(this._processor, root, this._opts);
  38509. this.result.css = css;
  38510. let self = this;
  38511. Object.defineProperty(this.result, 'root', {
  38512. get() {
  38513. return self.root
  38514. }
  38515. });
  38516. let map = new MapGenerator(str, root, this._opts, css);
  38517. if (map.isMap()) {
  38518. let [generatedCSS, generatedMap] = map.generate();
  38519. if (generatedCSS) {
  38520. this.result.css = generatedCSS;
  38521. }
  38522. if (generatedMap) {
  38523. this.result.map = generatedMap;
  38524. }
  38525. } else {
  38526. map.clearAnnotation();
  38527. this.result.css = map.css;
  38528. }
  38529. }
  38530. async() {
  38531. if (this.error) return Promise.reject(this.error)
  38532. return Promise.resolve(this.result)
  38533. }
  38534. catch(onRejected) {
  38535. return this.async().catch(onRejected)
  38536. }
  38537. finally(onFinally) {
  38538. return this.async().then(onFinally, onFinally)
  38539. }
  38540. sync() {
  38541. if (this.error) throw this.error
  38542. return this.result
  38543. }
  38544. then(onFulfilled, onRejected) {
  38545. if (browser$1.env.NODE_ENV !== 'production') {
  38546. if (!('from' in this._opts)) {
  38547. warnOnce(
  38548. 'Without `from` option PostCSS could generate wrong source map ' +
  38549. 'and will not find Browserslist config. Set it to CSS file path ' +
  38550. 'or to `undefined` to prevent this warning.'
  38551. );
  38552. }
  38553. }
  38554. return this.async().then(onFulfilled, onRejected)
  38555. }
  38556. toString() {
  38557. return this._css
  38558. }
  38559. warnings() {
  38560. return []
  38561. }
  38562. get content() {
  38563. return this.result.css
  38564. }
  38565. get css() {
  38566. return this.result.css
  38567. }
  38568. get map() {
  38569. return this.result.map
  38570. }
  38571. get messages() {
  38572. return []
  38573. }
  38574. get opts() {
  38575. return this.result.opts
  38576. }
  38577. get processor() {
  38578. return this.result.processor
  38579. }
  38580. get root() {
  38581. if (this._root) {
  38582. return this._root
  38583. }
  38584. let root;
  38585. let parser = parse;
  38586. try {
  38587. root = parser(this._css, this._opts);
  38588. } catch (error) {
  38589. this.error = error;
  38590. }
  38591. if (this.error) {
  38592. throw this.error
  38593. } else {
  38594. this._root = root;
  38595. return root
  38596. }
  38597. }
  38598. get [Symbol.toStringTag]() {
  38599. return 'NoWorkResult'
  38600. }
  38601. }
  38602. noWorkResult = NoWorkResult;
  38603. NoWorkResult.default = NoWorkResult;
  38604. return noWorkResult;
  38605. }
  38606. var processor$1;
  38607. var hasRequiredProcessor$1;
  38608. function requireProcessor$1 () {
  38609. if (hasRequiredProcessor$1) return processor$1;
  38610. hasRequiredProcessor$1 = 1;
  38611. let Document = /*@__PURE__*/ requireDocument();
  38612. let LazyResult = /*@__PURE__*/ requireLazyResult();
  38613. let NoWorkResult = /*@__PURE__*/ requireNoWorkResult();
  38614. let Root = /*@__PURE__*/ requireRoot$1();
  38615. class Processor {
  38616. constructor(plugins = []) {
  38617. this.version = '8.4.48';
  38618. this.plugins = this.normalize(plugins);
  38619. }
  38620. normalize(plugins) {
  38621. let normalized = [];
  38622. for (let i of plugins) {
  38623. if (i.postcss === true) {
  38624. i = i();
  38625. } else if (i.postcss) {
  38626. i = i.postcss;
  38627. }
  38628. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  38629. normalized = normalized.concat(i.plugins);
  38630. } else if (typeof i === 'object' && i.postcssPlugin) {
  38631. normalized.push(i);
  38632. } else if (typeof i === 'function') {
  38633. normalized.push(i);
  38634. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  38635. if (browser$1.env.NODE_ENV !== 'production') {
  38636. throw new Error(
  38637. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  38638. 'one of the syntax/parser/stringifier options as outlined ' +
  38639. 'in your PostCSS runner documentation.'
  38640. )
  38641. }
  38642. } else {
  38643. throw new Error(i + ' is not a PostCSS plugin')
  38644. }
  38645. }
  38646. return normalized
  38647. }
  38648. process(css, opts = {}) {
  38649. if (
  38650. !this.plugins.length &&
  38651. !opts.parser &&
  38652. !opts.stringifier &&
  38653. !opts.syntax
  38654. ) {
  38655. return new NoWorkResult(this, css, opts)
  38656. } else {
  38657. return new LazyResult(this, css, opts)
  38658. }
  38659. }
  38660. use(plugin) {
  38661. this.plugins = this.plugins.concat(this.normalize([plugin]));
  38662. return this
  38663. }
  38664. }
  38665. processor$1 = Processor;
  38666. Processor.default = Processor;
  38667. Root.registerProcessor(Processor);
  38668. Document.registerProcessor(Processor);
  38669. return processor$1;
  38670. }
  38671. var postcss_1;
  38672. var hasRequiredPostcss;
  38673. function requirePostcss () {
  38674. if (hasRequiredPostcss) return postcss_1;
  38675. hasRequiredPostcss = 1;
  38676. let AtRule = /*@__PURE__*/ requireAtRule();
  38677. let Comment = /*@__PURE__*/ requireComment$1();
  38678. let Container = /*@__PURE__*/ requireContainer$1();
  38679. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  38680. let Declaration = /*@__PURE__*/ requireDeclaration();
  38681. let Document = /*@__PURE__*/ requireDocument();
  38682. let fromJSON = /*@__PURE__*/ requireFromJSON();
  38683. let Input = /*@__PURE__*/ requireInput();
  38684. let LazyResult = /*@__PURE__*/ requireLazyResult();
  38685. let list = /*@__PURE__*/ requireList();
  38686. let Node = /*@__PURE__*/ requireNode$2();
  38687. let parse = /*@__PURE__*/ requireParse();
  38688. let Processor = /*@__PURE__*/ requireProcessor$1();
  38689. let Result = /*@__PURE__*/ requireResult();
  38690. let Root = /*@__PURE__*/ requireRoot$1();
  38691. let Rule = /*@__PURE__*/ requireRule();
  38692. let stringify = /*@__PURE__*/ requireStringify();
  38693. let Warning = /*@__PURE__*/ requireWarning();
  38694. function postcss(...plugins) {
  38695. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  38696. plugins = plugins[0];
  38697. }
  38698. return new Processor(plugins)
  38699. }
  38700. postcss.plugin = function plugin(name, initializer) {
  38701. let warningPrinted = false;
  38702. function creator(...args) {
  38703. // eslint-disable-next-line no-console
  38704. if (console && console.warn && !warningPrinted) {
  38705. warningPrinted = true;
  38706. // eslint-disable-next-line no-console
  38707. console.warn(
  38708. name +
  38709. ': postcss.plugin was deprecated. Migration guide:\n' +
  38710. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  38711. );
  38712. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  38713. /* c8 ignore next 7 */
  38714. // eslint-disable-next-line no-console
  38715. console.warn(
  38716. name +
  38717. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  38718. 'https://www.w3ctech.com/topic/2226'
  38719. );
  38720. }
  38721. }
  38722. let transformer = initializer(...args);
  38723. transformer.postcssPlugin = name;
  38724. transformer.postcssVersion = new Processor().version;
  38725. return transformer
  38726. }
  38727. let cache;
  38728. Object.defineProperty(creator, 'postcss', {
  38729. get() {
  38730. if (!cache) cache = creator();
  38731. return cache
  38732. }
  38733. });
  38734. creator.process = function (css, processOpts, pluginOpts) {
  38735. return postcss([creator(pluginOpts)]).process(css, processOpts)
  38736. };
  38737. return creator
  38738. };
  38739. postcss.stringify = stringify;
  38740. postcss.parse = parse;
  38741. postcss.fromJSON = fromJSON;
  38742. postcss.list = list;
  38743. postcss.comment = defaults => new Comment(defaults);
  38744. postcss.atRule = defaults => new AtRule(defaults);
  38745. postcss.decl = defaults => new Declaration(defaults);
  38746. postcss.rule = defaults => new Rule(defaults);
  38747. postcss.root = defaults => new Root(defaults);
  38748. postcss.document = defaults => new Document(defaults);
  38749. postcss.CssSyntaxError = CssSyntaxError;
  38750. postcss.Declaration = Declaration;
  38751. postcss.Container = Container;
  38752. postcss.Processor = Processor;
  38753. postcss.Document = Document;
  38754. postcss.Comment = Comment;
  38755. postcss.Warning = Warning;
  38756. postcss.AtRule = AtRule;
  38757. postcss.Result = Result;
  38758. postcss.Input = Input;
  38759. postcss.Rule = Rule;
  38760. postcss.Root = Root;
  38761. postcss.Node = Node;
  38762. LazyResult.registerPostcss(postcss);
  38763. postcss_1 = postcss;
  38764. postcss.default = postcss;
  38765. return postcss_1;
  38766. }
  38767. var postcssExports = /*@__PURE__*/ requirePostcss();
  38768. var postcss = /*@__PURE__*/getDefaultExportFromCjs(postcssExports);
  38769. postcss.stringify;
  38770. postcss.fromJSON;
  38771. postcss.plugin;
  38772. postcss.parse;
  38773. postcss.list;
  38774. postcss.document;
  38775. postcss.comment;
  38776. postcss.atRule;
  38777. postcss.rule;
  38778. postcss.decl;
  38779. postcss.root;
  38780. postcss.CssSyntaxError;
  38781. postcss.Declaration;
  38782. postcss.Container;
  38783. postcss.Processor;
  38784. postcss.Document;
  38785. postcss.Comment;
  38786. postcss.Warning;
  38787. postcss.AtRule;
  38788. postcss.Result;
  38789. postcss.Input;
  38790. const Rule = postcss.Rule;
  38791. postcss.Root;
  38792. postcss.Node;
  38793. const trimPlugin = () => {
  38794. return {
  38795. postcssPlugin: "vue-sfc-trim",
  38796. Once(root) {
  38797. root.walk(({ type, raws }) => {
  38798. if (type === "rule" || type === "atrule") {
  38799. if (raws.before) raws.before = "\n";
  38800. if ("after" in raws && raws.after) raws.after = "\n";
  38801. }
  38802. });
  38803. }
  38804. };
  38805. };
  38806. trimPlugin.postcss = true;
  38807. var dist = {exports: {}};
  38808. var processor = {exports: {}};
  38809. var parser = {exports: {}};
  38810. var root = {exports: {}};
  38811. var container = {exports: {}};
  38812. var node$1 = {exports: {}};
  38813. var util$1 = {};
  38814. var unesc = {exports: {}};
  38815. var hasRequiredUnesc;
  38816. function requireUnesc () {
  38817. if (hasRequiredUnesc) return unesc.exports;
  38818. hasRequiredUnesc = 1;
  38819. (function (module, exports) {
  38820. exports.__esModule = true;
  38821. exports["default"] = unesc;
  38822. // Many thanks for this post which made this migration much easier.
  38823. // https://mathiasbynens.be/notes/css-escapes
  38824. /**
  38825. *
  38826. * @param {string} str
  38827. * @returns {[string, number]|undefined}
  38828. */
  38829. function gobbleHex(str) {
  38830. var lower = str.toLowerCase();
  38831. var hex = '';
  38832. var spaceTerminated = false;
  38833. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  38834. var code = lower.charCodeAt(i);
  38835. // check to see if we are dealing with a valid hex char [a-f|0-9]
  38836. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  38837. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  38838. spaceTerminated = code === 32;
  38839. if (!valid) {
  38840. break;
  38841. }
  38842. hex += lower[i];
  38843. }
  38844. if (hex.length === 0) {
  38845. return undefined;
  38846. }
  38847. var codePoint = parseInt(hex, 16);
  38848. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  38849. // Add special case for
  38850. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  38851. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  38852. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  38853. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  38854. }
  38855. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  38856. }
  38857. var CONTAINS_ESCAPE = /\\/;
  38858. function unesc(str) {
  38859. var needToProcess = CONTAINS_ESCAPE.test(str);
  38860. if (!needToProcess) {
  38861. return str;
  38862. }
  38863. var ret = "";
  38864. for (var i = 0; i < str.length; i++) {
  38865. if (str[i] === "\\") {
  38866. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  38867. if (gobbled !== undefined) {
  38868. ret += gobbled[0];
  38869. i += gobbled[1];
  38870. continue;
  38871. }
  38872. // Retain a pair of \\ if double escaped `\\\\`
  38873. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  38874. if (str[i + 1] === "\\") {
  38875. ret += "\\";
  38876. i++;
  38877. continue;
  38878. }
  38879. // if \\ is at the end of the string retain it
  38880. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  38881. if (str.length === i + 1) {
  38882. ret += str[i];
  38883. }
  38884. continue;
  38885. }
  38886. ret += str[i];
  38887. }
  38888. return ret;
  38889. }
  38890. module.exports = exports.default;
  38891. } (unesc, unesc.exports));
  38892. return unesc.exports;
  38893. }
  38894. var getProp = {exports: {}};
  38895. var hasRequiredGetProp;
  38896. function requireGetProp () {
  38897. if (hasRequiredGetProp) return getProp.exports;
  38898. hasRequiredGetProp = 1;
  38899. (function (module, exports) {
  38900. exports.__esModule = true;
  38901. exports["default"] = getProp;
  38902. function getProp(obj) {
  38903. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  38904. props[_key - 1] = arguments[_key];
  38905. }
  38906. while (props.length > 0) {
  38907. var prop = props.shift();
  38908. if (!obj[prop]) {
  38909. return undefined;
  38910. }
  38911. obj = obj[prop];
  38912. }
  38913. return obj;
  38914. }
  38915. module.exports = exports.default;
  38916. } (getProp, getProp.exports));
  38917. return getProp.exports;
  38918. }
  38919. var ensureObject = {exports: {}};
  38920. var hasRequiredEnsureObject;
  38921. function requireEnsureObject () {
  38922. if (hasRequiredEnsureObject) return ensureObject.exports;
  38923. hasRequiredEnsureObject = 1;
  38924. (function (module, exports) {
  38925. exports.__esModule = true;
  38926. exports["default"] = ensureObject;
  38927. function ensureObject(obj) {
  38928. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  38929. props[_key - 1] = arguments[_key];
  38930. }
  38931. while (props.length > 0) {
  38932. var prop = props.shift();
  38933. if (!obj[prop]) {
  38934. obj[prop] = {};
  38935. }
  38936. obj = obj[prop];
  38937. }
  38938. }
  38939. module.exports = exports.default;
  38940. } (ensureObject, ensureObject.exports));
  38941. return ensureObject.exports;
  38942. }
  38943. var stripComments = {exports: {}};
  38944. var hasRequiredStripComments;
  38945. function requireStripComments () {
  38946. if (hasRequiredStripComments) return stripComments.exports;
  38947. hasRequiredStripComments = 1;
  38948. (function (module, exports) {
  38949. exports.__esModule = true;
  38950. exports["default"] = stripComments;
  38951. function stripComments(str) {
  38952. var s = "";
  38953. var commentStart = str.indexOf("/*");
  38954. var lastEnd = 0;
  38955. while (commentStart >= 0) {
  38956. s = s + str.slice(lastEnd, commentStart);
  38957. var commentEnd = str.indexOf("*/", commentStart + 2);
  38958. if (commentEnd < 0) {
  38959. return s;
  38960. }
  38961. lastEnd = commentEnd + 2;
  38962. commentStart = str.indexOf("/*", lastEnd);
  38963. }
  38964. s = s + str.slice(lastEnd);
  38965. return s;
  38966. }
  38967. module.exports = exports.default;
  38968. } (stripComments, stripComments.exports));
  38969. return stripComments.exports;
  38970. }
  38971. var hasRequiredUtil$1;
  38972. function requireUtil$1 () {
  38973. if (hasRequiredUtil$1) return util$1;
  38974. hasRequiredUtil$1 = 1;
  38975. util$1.__esModule = true;
  38976. util$1.unesc = util$1.stripComments = util$1.getProp = util$1.ensureObject = void 0;
  38977. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  38978. util$1.unesc = _unesc["default"];
  38979. var _getProp = _interopRequireDefault(/*@__PURE__*/ requireGetProp());
  38980. util$1.getProp = _getProp["default"];
  38981. var _ensureObject = _interopRequireDefault(/*@__PURE__*/ requireEnsureObject());
  38982. util$1.ensureObject = _ensureObject["default"];
  38983. var _stripComments = _interopRequireDefault(/*@__PURE__*/ requireStripComments());
  38984. util$1.stripComments = _stripComments["default"];
  38985. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38986. return util$1;
  38987. }
  38988. var hasRequiredNode$1;
  38989. function requireNode$1 () {
  38990. if (hasRequiredNode$1) return node$1.exports;
  38991. hasRequiredNode$1 = 1;
  38992. (function (module, exports) {
  38993. exports.__esModule = true;
  38994. exports["default"] = void 0;
  38995. var _util = /*@__PURE__*/ requireUtil$1();
  38996. 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); } }
  38997. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  38998. var cloneNode = function cloneNode(obj, parent) {
  38999. if (typeof obj !== 'object' || obj === null) {
  39000. return obj;
  39001. }
  39002. var cloned = new obj.constructor();
  39003. for (var i in obj) {
  39004. if (!obj.hasOwnProperty(i)) {
  39005. continue;
  39006. }
  39007. var value = obj[i];
  39008. var type = typeof value;
  39009. if (i === 'parent' && type === 'object') {
  39010. if (parent) {
  39011. cloned[i] = parent;
  39012. }
  39013. } else if (value instanceof Array) {
  39014. cloned[i] = value.map(function (j) {
  39015. return cloneNode(j, cloned);
  39016. });
  39017. } else {
  39018. cloned[i] = cloneNode(value, cloned);
  39019. }
  39020. }
  39021. return cloned;
  39022. };
  39023. var Node = /*#__PURE__*/function () {
  39024. function Node(opts) {
  39025. if (opts === void 0) {
  39026. opts = {};
  39027. }
  39028. Object.assign(this, opts);
  39029. this.spaces = this.spaces || {};
  39030. this.spaces.before = this.spaces.before || '';
  39031. this.spaces.after = this.spaces.after || '';
  39032. }
  39033. var _proto = Node.prototype;
  39034. _proto.remove = function remove() {
  39035. if (this.parent) {
  39036. this.parent.removeChild(this);
  39037. }
  39038. this.parent = undefined;
  39039. return this;
  39040. };
  39041. _proto.replaceWith = function replaceWith() {
  39042. if (this.parent) {
  39043. for (var index in arguments) {
  39044. this.parent.insertBefore(this, arguments[index]);
  39045. }
  39046. this.remove();
  39047. }
  39048. return this;
  39049. };
  39050. _proto.next = function next() {
  39051. return this.parent.at(this.parent.index(this) + 1);
  39052. };
  39053. _proto.prev = function prev() {
  39054. return this.parent.at(this.parent.index(this) - 1);
  39055. };
  39056. _proto.clone = function clone(overrides) {
  39057. if (overrides === void 0) {
  39058. overrides = {};
  39059. }
  39060. var cloned = cloneNode(this);
  39061. for (var name in overrides) {
  39062. cloned[name] = overrides[name];
  39063. }
  39064. return cloned;
  39065. }
  39066. /**
  39067. * Some non-standard syntax doesn't follow normal escaping rules for css.
  39068. * This allows non standard syntax to be appended to an existing property
  39069. * by specifying the escaped value. By specifying the escaped value,
  39070. * illegal characters are allowed to be directly inserted into css output.
  39071. * @param {string} name the property to set
  39072. * @param {any} value the unescaped value of the property
  39073. * @param {string} valueEscaped optional. the escaped value of the property.
  39074. */;
  39075. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  39076. if (!this.raws) {
  39077. this.raws = {};
  39078. }
  39079. var originalValue = this[name];
  39080. var originalEscaped = this.raws[name];
  39081. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  39082. if (originalEscaped || valueEscaped !== value) {
  39083. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  39084. } else {
  39085. delete this.raws[name]; // delete any escaped value that was created by the setter.
  39086. }
  39087. }
  39088. /**
  39089. * Some non-standard syntax doesn't follow normal escaping rules for css.
  39090. * This allows the escaped value to be specified directly, allowing illegal
  39091. * characters to be directly inserted into css output.
  39092. * @param {string} name the property to set
  39093. * @param {any} value the unescaped value of the property
  39094. * @param {string} valueEscaped the escaped value of the property.
  39095. */;
  39096. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  39097. if (!this.raws) {
  39098. this.raws = {};
  39099. }
  39100. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  39101. this.raws[name] = valueEscaped;
  39102. }
  39103. /**
  39104. * When you want a value to passed through to CSS directly. This method
  39105. * deletes the corresponding raw value causing the stringifier to fallback
  39106. * to the unescaped value.
  39107. * @param {string} name the property to set.
  39108. * @param {any} value The value that is both escaped and unescaped.
  39109. */;
  39110. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  39111. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  39112. if (this.raws) {
  39113. delete this.raws[name];
  39114. }
  39115. }
  39116. /**
  39117. *
  39118. * @param {number} line The number (starting with 1)
  39119. * @param {number} column The column number (starting with 1)
  39120. */;
  39121. _proto.isAtPosition = function isAtPosition(line, column) {
  39122. if (this.source && this.source.start && this.source.end) {
  39123. if (this.source.start.line > line) {
  39124. return false;
  39125. }
  39126. if (this.source.end.line < line) {
  39127. return false;
  39128. }
  39129. if (this.source.start.line === line && this.source.start.column > column) {
  39130. return false;
  39131. }
  39132. if (this.source.end.line === line && this.source.end.column < column) {
  39133. return false;
  39134. }
  39135. return true;
  39136. }
  39137. return undefined;
  39138. };
  39139. _proto.stringifyProperty = function stringifyProperty(name) {
  39140. return this.raws && this.raws[name] || this[name];
  39141. };
  39142. _proto.valueToString = function valueToString() {
  39143. return String(this.stringifyProperty("value"));
  39144. };
  39145. _proto.toString = function toString() {
  39146. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  39147. };
  39148. _createClass(Node, [{
  39149. key: "rawSpaceBefore",
  39150. get: function get() {
  39151. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  39152. if (rawSpace === undefined) {
  39153. rawSpace = this.spaces && this.spaces.before;
  39154. }
  39155. return rawSpace || "";
  39156. },
  39157. set: function set(raw) {
  39158. (0, _util.ensureObject)(this, "raws", "spaces");
  39159. this.raws.spaces.before = raw;
  39160. }
  39161. }, {
  39162. key: "rawSpaceAfter",
  39163. get: function get() {
  39164. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  39165. if (rawSpace === undefined) {
  39166. rawSpace = this.spaces.after;
  39167. }
  39168. return rawSpace || "";
  39169. },
  39170. set: function set(raw) {
  39171. (0, _util.ensureObject)(this, "raws", "spaces");
  39172. this.raws.spaces.after = raw;
  39173. }
  39174. }]);
  39175. return Node;
  39176. }();
  39177. exports["default"] = Node;
  39178. module.exports = exports.default;
  39179. } (node$1, node$1.exports));
  39180. return node$1.exports;
  39181. }
  39182. var types = {};
  39183. var hasRequiredTypes;
  39184. function requireTypes () {
  39185. if (hasRequiredTypes) return types;
  39186. hasRequiredTypes = 1;
  39187. types.__esModule = true;
  39188. 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;
  39189. var TAG = 'tag';
  39190. types.TAG = TAG;
  39191. var STRING = 'string';
  39192. types.STRING = STRING;
  39193. var SELECTOR = 'selector';
  39194. types.SELECTOR = SELECTOR;
  39195. var ROOT = 'root';
  39196. types.ROOT = ROOT;
  39197. var PSEUDO = 'pseudo';
  39198. types.PSEUDO = PSEUDO;
  39199. var NESTING = 'nesting';
  39200. types.NESTING = NESTING;
  39201. var ID = 'id';
  39202. types.ID = ID;
  39203. var COMMENT = 'comment';
  39204. types.COMMENT = COMMENT;
  39205. var COMBINATOR = 'combinator';
  39206. types.COMBINATOR = COMBINATOR;
  39207. var CLASS = 'class';
  39208. types.CLASS = CLASS;
  39209. var ATTRIBUTE = 'attribute';
  39210. types.ATTRIBUTE = ATTRIBUTE;
  39211. var UNIVERSAL = 'universal';
  39212. types.UNIVERSAL = UNIVERSAL;
  39213. return types;
  39214. }
  39215. var hasRequiredContainer;
  39216. function requireContainer () {
  39217. if (hasRequiredContainer) return container.exports;
  39218. hasRequiredContainer = 1;
  39219. (function (module, exports) {
  39220. exports.__esModule = true;
  39221. exports["default"] = void 0;
  39222. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39223. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  39224. 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); }
  39225. function _interopRequireWildcard(obj, nodeInterop) { if (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; }
  39226. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39227. 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) { 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."); }
  39228. 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); }
  39229. 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; }
  39230. 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); } }
  39231. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39232. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39233. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39234. var Container = /*#__PURE__*/function (_Node) {
  39235. _inheritsLoose(Container, _Node);
  39236. function Container(opts) {
  39237. var _this;
  39238. _this = _Node.call(this, opts) || this;
  39239. if (!_this.nodes) {
  39240. _this.nodes = [];
  39241. }
  39242. return _this;
  39243. }
  39244. var _proto = Container.prototype;
  39245. _proto.append = function append(selector) {
  39246. selector.parent = this;
  39247. this.nodes.push(selector);
  39248. return this;
  39249. };
  39250. _proto.prepend = function prepend(selector) {
  39251. selector.parent = this;
  39252. this.nodes.unshift(selector);
  39253. for (var id in this.indexes) {
  39254. this.indexes[id]++;
  39255. }
  39256. return this;
  39257. };
  39258. _proto.at = function at(index) {
  39259. return this.nodes[index];
  39260. };
  39261. _proto.index = function index(child) {
  39262. if (typeof child === 'number') {
  39263. return child;
  39264. }
  39265. return this.nodes.indexOf(child);
  39266. };
  39267. _proto.removeChild = function removeChild(child) {
  39268. child = this.index(child);
  39269. this.at(child).parent = undefined;
  39270. this.nodes.splice(child, 1);
  39271. var index;
  39272. for (var id in this.indexes) {
  39273. index = this.indexes[id];
  39274. if (index >= child) {
  39275. this.indexes[id] = index - 1;
  39276. }
  39277. }
  39278. return this;
  39279. };
  39280. _proto.removeAll = function removeAll() {
  39281. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  39282. var node = _step.value;
  39283. node.parent = undefined;
  39284. }
  39285. this.nodes = [];
  39286. return this;
  39287. };
  39288. _proto.empty = function empty() {
  39289. return this.removeAll();
  39290. };
  39291. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  39292. newNode.parent = this;
  39293. var oldIndex = this.index(oldNode);
  39294. this.nodes.splice(oldIndex + 1, 0, newNode);
  39295. newNode.parent = this;
  39296. var index;
  39297. for (var id in this.indexes) {
  39298. index = this.indexes[id];
  39299. if (oldIndex < index) {
  39300. this.indexes[id] = index + 1;
  39301. }
  39302. }
  39303. return this;
  39304. };
  39305. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  39306. newNode.parent = this;
  39307. var oldIndex = this.index(oldNode);
  39308. this.nodes.splice(oldIndex, 0, newNode);
  39309. newNode.parent = this;
  39310. var index;
  39311. for (var id in this.indexes) {
  39312. index = this.indexes[id];
  39313. if (index >= oldIndex) {
  39314. this.indexes[id] = index + 1;
  39315. }
  39316. }
  39317. return this;
  39318. };
  39319. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  39320. var found = undefined;
  39321. this.each(function (node) {
  39322. if (node.atPosition) {
  39323. var foundChild = node.atPosition(line, col);
  39324. if (foundChild) {
  39325. found = foundChild;
  39326. return false;
  39327. }
  39328. } else if (node.isAtPosition(line, col)) {
  39329. found = node;
  39330. return false;
  39331. }
  39332. });
  39333. return found;
  39334. }
  39335. /**
  39336. * Return the most specific node at the line and column number given.
  39337. * The source location is based on the original parsed location, locations aren't
  39338. * updated as selector nodes are mutated.
  39339. *
  39340. * Note that this location is relative to the location of the first character
  39341. * of the selector, and not the location of the selector in the overall document
  39342. * when used in conjunction with postcss.
  39343. *
  39344. * If not found, returns undefined.
  39345. * @param {number} line The line number of the node to find. (1-based index)
  39346. * @param {number} col The column number of the node to find. (1-based index)
  39347. */;
  39348. _proto.atPosition = function atPosition(line, col) {
  39349. if (this.isAtPosition(line, col)) {
  39350. return this._findChildAtPosition(line, col) || this;
  39351. } else {
  39352. return undefined;
  39353. }
  39354. };
  39355. _proto._inferEndPosition = function _inferEndPosition() {
  39356. if (this.last && this.last.source && this.last.source.end) {
  39357. this.source = this.source || {};
  39358. this.source.end = this.source.end || {};
  39359. Object.assign(this.source.end, this.last.source.end);
  39360. }
  39361. };
  39362. _proto.each = function each(callback) {
  39363. if (!this.lastEach) {
  39364. this.lastEach = 0;
  39365. }
  39366. if (!this.indexes) {
  39367. this.indexes = {};
  39368. }
  39369. this.lastEach++;
  39370. var id = this.lastEach;
  39371. this.indexes[id] = 0;
  39372. if (!this.length) {
  39373. return undefined;
  39374. }
  39375. var index, result;
  39376. while (this.indexes[id] < this.length) {
  39377. index = this.indexes[id];
  39378. result = callback(this.at(index), index);
  39379. if (result === false) {
  39380. break;
  39381. }
  39382. this.indexes[id] += 1;
  39383. }
  39384. delete this.indexes[id];
  39385. if (result === false) {
  39386. return false;
  39387. }
  39388. };
  39389. _proto.walk = function walk(callback) {
  39390. return this.each(function (node, i) {
  39391. var result = callback(node, i);
  39392. if (result !== false && node.length) {
  39393. result = node.walk(callback);
  39394. }
  39395. if (result === false) {
  39396. return false;
  39397. }
  39398. });
  39399. };
  39400. _proto.walkAttributes = function walkAttributes(callback) {
  39401. var _this2 = this;
  39402. return this.walk(function (selector) {
  39403. if (selector.type === types.ATTRIBUTE) {
  39404. return callback.call(_this2, selector);
  39405. }
  39406. });
  39407. };
  39408. _proto.walkClasses = function walkClasses(callback) {
  39409. var _this3 = this;
  39410. return this.walk(function (selector) {
  39411. if (selector.type === types.CLASS) {
  39412. return callback.call(_this3, selector);
  39413. }
  39414. });
  39415. };
  39416. _proto.walkCombinators = function walkCombinators(callback) {
  39417. var _this4 = this;
  39418. return this.walk(function (selector) {
  39419. if (selector.type === types.COMBINATOR) {
  39420. return callback.call(_this4, selector);
  39421. }
  39422. });
  39423. };
  39424. _proto.walkComments = function walkComments(callback) {
  39425. var _this5 = this;
  39426. return this.walk(function (selector) {
  39427. if (selector.type === types.COMMENT) {
  39428. return callback.call(_this5, selector);
  39429. }
  39430. });
  39431. };
  39432. _proto.walkIds = function walkIds(callback) {
  39433. var _this6 = this;
  39434. return this.walk(function (selector) {
  39435. if (selector.type === types.ID) {
  39436. return callback.call(_this6, selector);
  39437. }
  39438. });
  39439. };
  39440. _proto.walkNesting = function walkNesting(callback) {
  39441. var _this7 = this;
  39442. return this.walk(function (selector) {
  39443. if (selector.type === types.NESTING) {
  39444. return callback.call(_this7, selector);
  39445. }
  39446. });
  39447. };
  39448. _proto.walkPseudos = function walkPseudos(callback) {
  39449. var _this8 = this;
  39450. return this.walk(function (selector) {
  39451. if (selector.type === types.PSEUDO) {
  39452. return callback.call(_this8, selector);
  39453. }
  39454. });
  39455. };
  39456. _proto.walkTags = function walkTags(callback) {
  39457. var _this9 = this;
  39458. return this.walk(function (selector) {
  39459. if (selector.type === types.TAG) {
  39460. return callback.call(_this9, selector);
  39461. }
  39462. });
  39463. };
  39464. _proto.walkUniversals = function walkUniversals(callback) {
  39465. var _this10 = this;
  39466. return this.walk(function (selector) {
  39467. if (selector.type === types.UNIVERSAL) {
  39468. return callback.call(_this10, selector);
  39469. }
  39470. });
  39471. };
  39472. _proto.split = function split(callback) {
  39473. var _this11 = this;
  39474. var current = [];
  39475. return this.reduce(function (memo, node, index) {
  39476. var split = callback.call(_this11, node);
  39477. current.push(node);
  39478. if (split) {
  39479. memo.push(current);
  39480. current = [];
  39481. } else if (index === _this11.length - 1) {
  39482. memo.push(current);
  39483. }
  39484. return memo;
  39485. }, []);
  39486. };
  39487. _proto.map = function map(callback) {
  39488. return this.nodes.map(callback);
  39489. };
  39490. _proto.reduce = function reduce(callback, memo) {
  39491. return this.nodes.reduce(callback, memo);
  39492. };
  39493. _proto.every = function every(callback) {
  39494. return this.nodes.every(callback);
  39495. };
  39496. _proto.some = function some(callback) {
  39497. return this.nodes.some(callback);
  39498. };
  39499. _proto.filter = function filter(callback) {
  39500. return this.nodes.filter(callback);
  39501. };
  39502. _proto.sort = function sort(callback) {
  39503. return this.nodes.sort(callback);
  39504. };
  39505. _proto.toString = function toString() {
  39506. return this.map(String).join('');
  39507. };
  39508. _createClass(Container, [{
  39509. key: "first",
  39510. get: function get() {
  39511. return this.at(0);
  39512. }
  39513. }, {
  39514. key: "last",
  39515. get: function get() {
  39516. return this.at(this.length - 1);
  39517. }
  39518. }, {
  39519. key: "length",
  39520. get: function get() {
  39521. return this.nodes.length;
  39522. }
  39523. }]);
  39524. return Container;
  39525. }(_node["default"]);
  39526. exports["default"] = Container;
  39527. module.exports = exports.default;
  39528. } (container, container.exports));
  39529. return container.exports;
  39530. }
  39531. var hasRequiredRoot;
  39532. function requireRoot () {
  39533. if (hasRequiredRoot) return root.exports;
  39534. hasRequiredRoot = 1;
  39535. (function (module, exports) {
  39536. exports.__esModule = true;
  39537. exports["default"] = void 0;
  39538. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39539. var _types = /*@__PURE__*/ requireTypes();
  39540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39541. 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); } }
  39542. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39543. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39544. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39545. var Root = /*#__PURE__*/function (_Container) {
  39546. _inheritsLoose(Root, _Container);
  39547. function Root(opts) {
  39548. var _this;
  39549. _this = _Container.call(this, opts) || this;
  39550. _this.type = _types.ROOT;
  39551. return _this;
  39552. }
  39553. var _proto = Root.prototype;
  39554. _proto.toString = function toString() {
  39555. var str = this.reduce(function (memo, selector) {
  39556. memo.push(String(selector));
  39557. return memo;
  39558. }, []).join(',');
  39559. return this.trailingComma ? str + ',' : str;
  39560. };
  39561. _proto.error = function error(message, options) {
  39562. if (this._error) {
  39563. return this._error(message, options);
  39564. } else {
  39565. return new Error(message);
  39566. }
  39567. };
  39568. _createClass(Root, [{
  39569. key: "errorGenerator",
  39570. set: function set(handler) {
  39571. this._error = handler;
  39572. }
  39573. }]);
  39574. return Root;
  39575. }(_container["default"]);
  39576. exports["default"] = Root;
  39577. module.exports = exports.default;
  39578. } (root, root.exports));
  39579. return root.exports;
  39580. }
  39581. var selector = {exports: {}};
  39582. var hasRequiredSelector;
  39583. function requireSelector () {
  39584. if (hasRequiredSelector) return selector.exports;
  39585. hasRequiredSelector = 1;
  39586. (function (module, exports) {
  39587. exports.__esModule = true;
  39588. exports["default"] = void 0;
  39589. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39590. var _types = /*@__PURE__*/ requireTypes();
  39591. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39592. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39593. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39594. var Selector = /*#__PURE__*/function (_Container) {
  39595. _inheritsLoose(Selector, _Container);
  39596. function Selector(opts) {
  39597. var _this;
  39598. _this = _Container.call(this, opts) || this;
  39599. _this.type = _types.SELECTOR;
  39600. return _this;
  39601. }
  39602. return Selector;
  39603. }(_container["default"]);
  39604. exports["default"] = Selector;
  39605. module.exports = exports.default;
  39606. } (selector, selector.exports));
  39607. return selector.exports;
  39608. }
  39609. var className = {exports: {}};
  39610. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  39611. var cssesc_1;
  39612. var hasRequiredCssesc;
  39613. function requireCssesc () {
  39614. if (hasRequiredCssesc) return cssesc_1;
  39615. hasRequiredCssesc = 1;
  39616. var object = {};
  39617. var hasOwnProperty = object.hasOwnProperty;
  39618. var merge = function merge(options, defaults) {
  39619. if (!options) {
  39620. return defaults;
  39621. }
  39622. var result = {};
  39623. for (var key in defaults) {
  39624. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  39625. // only recognized option names are used.
  39626. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  39627. }
  39628. return result;
  39629. };
  39630. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  39631. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  39632. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  39633. // https://mathiasbynens.be/notes/css-escapes#css
  39634. var cssesc = function cssesc(string, options) {
  39635. options = merge(options, cssesc.options);
  39636. if (options.quotes != 'single' && options.quotes != 'double') {
  39637. options.quotes = 'single';
  39638. }
  39639. var quote = options.quotes == 'double' ? '"' : '\'';
  39640. var isIdentifier = options.isIdentifier;
  39641. var firstChar = string.charAt(0);
  39642. var output = '';
  39643. var counter = 0;
  39644. var length = string.length;
  39645. while (counter < length) {
  39646. var character = string.charAt(counter++);
  39647. var codePoint = character.charCodeAt();
  39648. var value = void 0;
  39649. // If it’s not a printable ASCII character…
  39650. if (codePoint < 0x20 || codePoint > 0x7E) {
  39651. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  39652. // It’s a high surrogate, and there is a next character.
  39653. var extra = string.charCodeAt(counter++);
  39654. if ((extra & 0xFC00) == 0xDC00) {
  39655. // next character is low surrogate
  39656. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  39657. } else {
  39658. // It’s an unmatched surrogate; only append this code unit, in case
  39659. // the next code unit is the high surrogate of a surrogate pair.
  39660. counter--;
  39661. }
  39662. }
  39663. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39664. } else {
  39665. if (options.escapeEverything) {
  39666. if (regexAnySingleEscape.test(character)) {
  39667. value = '\\' + character;
  39668. } else {
  39669. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39670. }
  39671. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  39672. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39673. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  39674. value = '\\' + character;
  39675. } else {
  39676. value = character;
  39677. }
  39678. }
  39679. output += value;
  39680. }
  39681. if (isIdentifier) {
  39682. if (/^-[-\d]/.test(output)) {
  39683. output = '\\-' + output.slice(1);
  39684. } else if (/\d/.test(firstChar)) {
  39685. output = '\\3' + firstChar + ' ' + output.slice(1);
  39686. }
  39687. }
  39688. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  39689. // since they’re redundant. Note that this is only possible if the escape
  39690. // sequence isn’t preceded by an odd number of backslashes.
  39691. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  39692. if ($1 && $1.length % 2) {
  39693. // It’s not safe to remove the space, so don’t.
  39694. return $0;
  39695. }
  39696. // Strip the space.
  39697. return ($1 || '') + $2;
  39698. });
  39699. if (!isIdentifier && options.wrap) {
  39700. return quote + output + quote;
  39701. }
  39702. return output;
  39703. };
  39704. // Expose default options (so they can be overridden globally).
  39705. cssesc.options = {
  39706. 'escapeEverything': false,
  39707. 'isIdentifier': false,
  39708. 'quotes': 'single',
  39709. 'wrap': false
  39710. };
  39711. cssesc.version = '3.0.0';
  39712. cssesc_1 = cssesc;
  39713. return cssesc_1;
  39714. }
  39715. var hasRequiredClassName;
  39716. function requireClassName () {
  39717. if (hasRequiredClassName) return className.exports;
  39718. hasRequiredClassName = 1;
  39719. (function (module, exports) {
  39720. exports.__esModule = true;
  39721. exports["default"] = void 0;
  39722. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  39723. var _util = /*@__PURE__*/ requireUtil$1();
  39724. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39725. var _types = /*@__PURE__*/ requireTypes();
  39726. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39727. 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); } }
  39728. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39729. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39730. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39731. var ClassName = /*#__PURE__*/function (_Node) {
  39732. _inheritsLoose(ClassName, _Node);
  39733. function ClassName(opts) {
  39734. var _this;
  39735. _this = _Node.call(this, opts) || this;
  39736. _this.type = _types.CLASS;
  39737. _this._constructed = true;
  39738. return _this;
  39739. }
  39740. var _proto = ClassName.prototype;
  39741. _proto.valueToString = function valueToString() {
  39742. return '.' + _Node.prototype.valueToString.call(this);
  39743. };
  39744. _createClass(ClassName, [{
  39745. key: "value",
  39746. get: function get() {
  39747. return this._value;
  39748. },
  39749. set: function set(v) {
  39750. if (this._constructed) {
  39751. var escaped = (0, _cssesc["default"])(v, {
  39752. isIdentifier: true
  39753. });
  39754. if (escaped !== v) {
  39755. (0, _util.ensureObject)(this, "raws");
  39756. this.raws.value = escaped;
  39757. } else if (this.raws) {
  39758. delete this.raws.value;
  39759. }
  39760. }
  39761. this._value = v;
  39762. }
  39763. }]);
  39764. return ClassName;
  39765. }(_node["default"]);
  39766. exports["default"] = ClassName;
  39767. module.exports = exports.default;
  39768. } (className, className.exports));
  39769. return className.exports;
  39770. }
  39771. var comment = {exports: {}};
  39772. var hasRequiredComment;
  39773. function requireComment () {
  39774. if (hasRequiredComment) return comment.exports;
  39775. hasRequiredComment = 1;
  39776. (function (module, exports) {
  39777. exports.__esModule = true;
  39778. exports["default"] = void 0;
  39779. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39780. var _types = /*@__PURE__*/ requireTypes();
  39781. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39782. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39783. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39784. var Comment = /*#__PURE__*/function (_Node) {
  39785. _inheritsLoose(Comment, _Node);
  39786. function Comment(opts) {
  39787. var _this;
  39788. _this = _Node.call(this, opts) || this;
  39789. _this.type = _types.COMMENT;
  39790. return _this;
  39791. }
  39792. return Comment;
  39793. }(_node["default"]);
  39794. exports["default"] = Comment;
  39795. module.exports = exports.default;
  39796. } (comment, comment.exports));
  39797. return comment.exports;
  39798. }
  39799. var id = {exports: {}};
  39800. var hasRequiredId;
  39801. function requireId () {
  39802. if (hasRequiredId) return id.exports;
  39803. hasRequiredId = 1;
  39804. (function (module, exports) {
  39805. exports.__esModule = true;
  39806. exports["default"] = void 0;
  39807. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39808. var _types = /*@__PURE__*/ requireTypes();
  39809. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39810. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39811. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39812. var ID = /*#__PURE__*/function (_Node) {
  39813. _inheritsLoose(ID, _Node);
  39814. function ID(opts) {
  39815. var _this;
  39816. _this = _Node.call(this, opts) || this;
  39817. _this.type = _types.ID;
  39818. return _this;
  39819. }
  39820. var _proto = ID.prototype;
  39821. _proto.valueToString = function valueToString() {
  39822. return '#' + _Node.prototype.valueToString.call(this);
  39823. };
  39824. return ID;
  39825. }(_node["default"]);
  39826. exports["default"] = ID;
  39827. module.exports = exports.default;
  39828. } (id, id.exports));
  39829. return id.exports;
  39830. }
  39831. var tag = {exports: {}};
  39832. var namespace = {exports: {}};
  39833. var hasRequiredNamespace;
  39834. function requireNamespace () {
  39835. if (hasRequiredNamespace) return namespace.exports;
  39836. hasRequiredNamespace = 1;
  39837. (function (module, exports) {
  39838. exports.__esModule = true;
  39839. exports["default"] = void 0;
  39840. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  39841. var _util = /*@__PURE__*/ requireUtil$1();
  39842. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39843. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39844. 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); } }
  39845. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39846. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39847. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39848. var Namespace = /*#__PURE__*/function (_Node) {
  39849. _inheritsLoose(Namespace, _Node);
  39850. function Namespace() {
  39851. return _Node.apply(this, arguments) || this;
  39852. }
  39853. var _proto = Namespace.prototype;
  39854. _proto.qualifiedName = function qualifiedName(value) {
  39855. if (this.namespace) {
  39856. return this.namespaceString + "|" + value;
  39857. } else {
  39858. return value;
  39859. }
  39860. };
  39861. _proto.valueToString = function valueToString() {
  39862. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  39863. };
  39864. _createClass(Namespace, [{
  39865. key: "namespace",
  39866. get: function get() {
  39867. return this._namespace;
  39868. },
  39869. set: function set(namespace) {
  39870. if (namespace === true || namespace === "*" || namespace === "&") {
  39871. this._namespace = namespace;
  39872. if (this.raws) {
  39873. delete this.raws.namespace;
  39874. }
  39875. return;
  39876. }
  39877. var escaped = (0, _cssesc["default"])(namespace, {
  39878. isIdentifier: true
  39879. });
  39880. this._namespace = namespace;
  39881. if (escaped !== namespace) {
  39882. (0, _util.ensureObject)(this, "raws");
  39883. this.raws.namespace = escaped;
  39884. } else if (this.raws) {
  39885. delete this.raws.namespace;
  39886. }
  39887. }
  39888. }, {
  39889. key: "ns",
  39890. get: function get() {
  39891. return this._namespace;
  39892. },
  39893. set: function set(namespace) {
  39894. this.namespace = namespace;
  39895. }
  39896. }, {
  39897. key: "namespaceString",
  39898. get: function get() {
  39899. if (this.namespace) {
  39900. var ns = this.stringifyProperty("namespace");
  39901. if (ns === true) {
  39902. return '';
  39903. } else {
  39904. return ns;
  39905. }
  39906. } else {
  39907. return '';
  39908. }
  39909. }
  39910. }]);
  39911. return Namespace;
  39912. }(_node["default"]);
  39913. exports["default"] = Namespace;
  39914. module.exports = exports.default;
  39915. } (namespace, namespace.exports));
  39916. return namespace.exports;
  39917. }
  39918. var hasRequiredTag;
  39919. function requireTag () {
  39920. if (hasRequiredTag) return tag.exports;
  39921. hasRequiredTag = 1;
  39922. (function (module, exports) {
  39923. exports.__esModule = true;
  39924. exports["default"] = void 0;
  39925. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  39926. var _types = /*@__PURE__*/ requireTypes();
  39927. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39928. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39929. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39930. var Tag = /*#__PURE__*/function (_Namespace) {
  39931. _inheritsLoose(Tag, _Namespace);
  39932. function Tag(opts) {
  39933. var _this;
  39934. _this = _Namespace.call(this, opts) || this;
  39935. _this.type = _types.TAG;
  39936. return _this;
  39937. }
  39938. return Tag;
  39939. }(_namespace["default"]);
  39940. exports["default"] = Tag;
  39941. module.exports = exports.default;
  39942. } (tag, tag.exports));
  39943. return tag.exports;
  39944. }
  39945. var string = {exports: {}};
  39946. var hasRequiredString;
  39947. function requireString () {
  39948. if (hasRequiredString) return string.exports;
  39949. hasRequiredString = 1;
  39950. (function (module, exports) {
  39951. exports.__esModule = true;
  39952. exports["default"] = void 0;
  39953. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39954. var _types = /*@__PURE__*/ requireTypes();
  39955. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39956. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39957. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39958. var String = /*#__PURE__*/function (_Node) {
  39959. _inheritsLoose(String, _Node);
  39960. function String(opts) {
  39961. var _this;
  39962. _this = _Node.call(this, opts) || this;
  39963. _this.type = _types.STRING;
  39964. return _this;
  39965. }
  39966. return String;
  39967. }(_node["default"]);
  39968. exports["default"] = String;
  39969. module.exports = exports.default;
  39970. } (string, string.exports));
  39971. return string.exports;
  39972. }
  39973. var pseudo = {exports: {}};
  39974. var hasRequiredPseudo;
  39975. function requirePseudo () {
  39976. if (hasRequiredPseudo) return pseudo.exports;
  39977. hasRequiredPseudo = 1;
  39978. (function (module, exports) {
  39979. exports.__esModule = true;
  39980. exports["default"] = void 0;
  39981. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39982. var _types = /*@__PURE__*/ requireTypes();
  39983. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39984. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39985. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39986. var Pseudo = /*#__PURE__*/function (_Container) {
  39987. _inheritsLoose(Pseudo, _Container);
  39988. function Pseudo(opts) {
  39989. var _this;
  39990. _this = _Container.call(this, opts) || this;
  39991. _this.type = _types.PSEUDO;
  39992. return _this;
  39993. }
  39994. var _proto = Pseudo.prototype;
  39995. _proto.toString = function toString() {
  39996. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  39997. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  39998. };
  39999. return Pseudo;
  40000. }(_container["default"]);
  40001. exports["default"] = Pseudo;
  40002. module.exports = exports.default;
  40003. } (pseudo, pseudo.exports));
  40004. return pseudo.exports;
  40005. }
  40006. var attribute = {};
  40007. var node;
  40008. var hasRequiredNode;
  40009. function requireNode () {
  40010. if (hasRequiredNode) return node;
  40011. hasRequiredNode = 1;
  40012. /**
  40013. * For Node.js, simply re-export the core `util.deprecate` function.
  40014. */
  40015. node = require$$0.deprecate;
  40016. return node;
  40017. }
  40018. var hasRequiredAttribute;
  40019. function requireAttribute () {
  40020. if (hasRequiredAttribute) return attribute;
  40021. hasRequiredAttribute = 1;
  40022. (function (exports) {
  40023. exports.__esModule = true;
  40024. exports["default"] = void 0;
  40025. exports.unescapeValue = unescapeValue;
  40026. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  40027. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  40028. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  40029. var _types = /*@__PURE__*/ requireTypes();
  40030. var _CSSESC_QUOTE_OPTIONS;
  40031. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40032. 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); } }
  40033. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  40034. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40035. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40036. var deprecate = /*@__PURE__*/ requireNode();
  40037. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  40038. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  40039. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  40040. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  40041. function unescapeValue(value) {
  40042. var deprecatedUsage = false;
  40043. var quoteMark = null;
  40044. var unescaped = value;
  40045. var m = unescaped.match(WRAPPED_IN_QUOTES);
  40046. if (m) {
  40047. quoteMark = m[1];
  40048. unescaped = m[2];
  40049. }
  40050. unescaped = (0, _unesc["default"])(unescaped);
  40051. if (unescaped !== value) {
  40052. deprecatedUsage = true;
  40053. }
  40054. return {
  40055. deprecatedUsage: deprecatedUsage,
  40056. unescaped: unescaped,
  40057. quoteMark: quoteMark
  40058. };
  40059. }
  40060. function handleDeprecatedContructorOpts(opts) {
  40061. if (opts.quoteMark !== undefined) {
  40062. return opts;
  40063. }
  40064. if (opts.value === undefined) {
  40065. return opts;
  40066. }
  40067. warnOfDeprecatedConstructor();
  40068. var _unescapeValue = unescapeValue(opts.value),
  40069. quoteMark = _unescapeValue.quoteMark,
  40070. unescaped = _unescapeValue.unescaped;
  40071. if (!opts.raws) {
  40072. opts.raws = {};
  40073. }
  40074. if (opts.raws.value === undefined) {
  40075. opts.raws.value = opts.value;
  40076. }
  40077. opts.value = unescaped;
  40078. opts.quoteMark = quoteMark;
  40079. return opts;
  40080. }
  40081. var Attribute = /*#__PURE__*/function (_Namespace) {
  40082. _inheritsLoose(Attribute, _Namespace);
  40083. function Attribute(opts) {
  40084. var _this;
  40085. if (opts === void 0) {
  40086. opts = {};
  40087. }
  40088. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  40089. _this.type = _types.ATTRIBUTE;
  40090. _this.raws = _this.raws || {};
  40091. Object.defineProperty(_this.raws, 'unquoted', {
  40092. get: deprecate(function () {
  40093. return _this.value;
  40094. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  40095. set: deprecate(function () {
  40096. return _this.value;
  40097. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  40098. });
  40099. _this._constructed = true;
  40100. return _this;
  40101. }
  40102. /**
  40103. * Returns the Attribute's value quoted such that it would be legal to use
  40104. * in the value of a css file. The original value's quotation setting
  40105. * used for stringification is left unchanged. See `setValue(value, options)`
  40106. * if you want to control the quote settings of a new value for the attribute.
  40107. *
  40108. * You can also change the quotation used for the current value by setting quoteMark.
  40109. *
  40110. * Options:
  40111. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  40112. * option is not set, the original value for quoteMark will be used. If
  40113. * indeterminate, a double quote is used. The legal values are:
  40114. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  40115. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  40116. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  40117. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  40118. * over the quoteMark option value.
  40119. * * smart {boolean} - if true, will select a quote mark based on the value
  40120. * and the other options specified here. See the `smartQuoteMark()`
  40121. * method.
  40122. **/
  40123. var _proto = Attribute.prototype;
  40124. _proto.getQuotedValue = function getQuotedValue(options) {
  40125. if (options === void 0) {
  40126. options = {};
  40127. }
  40128. var quoteMark = this._determineQuoteMark(options);
  40129. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  40130. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  40131. return escaped;
  40132. };
  40133. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  40134. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  40135. }
  40136. /**
  40137. * Set the unescaped value with the specified quotation options. The value
  40138. * provided must not include any wrapping quote marks -- those quotes will
  40139. * be interpreted as part of the value and escaped accordingly.
  40140. */;
  40141. _proto.setValue = function setValue(value, options) {
  40142. if (options === void 0) {
  40143. options = {};
  40144. }
  40145. this._value = value;
  40146. this._quoteMark = this._determineQuoteMark(options);
  40147. this._syncRawValue();
  40148. }
  40149. /**
  40150. * Intelligently select a quoteMark value based on the value's contents. If
  40151. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  40152. * mark will be picked that minimizes the number of escapes.
  40153. *
  40154. * If there's no clear winner, the quote mark from these options is used,
  40155. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  40156. * true). If the quoteMark is unspecified, a double quote is used.
  40157. *
  40158. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  40159. * from the quoteValue method.
  40160. */;
  40161. _proto.smartQuoteMark = function smartQuoteMark(options) {
  40162. var v = this.value;
  40163. var numSingleQuotes = v.replace(/[^']/g, '').length;
  40164. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  40165. if (numSingleQuotes + numDoubleQuotes === 0) {
  40166. var escaped = (0, _cssesc["default"])(v, {
  40167. isIdentifier: true
  40168. });
  40169. if (escaped === v) {
  40170. return Attribute.NO_QUOTE;
  40171. } else {
  40172. var pref = this.preferredQuoteMark(options);
  40173. if (pref === Attribute.NO_QUOTE) {
  40174. // pick a quote mark that isn't none and see if it's smaller
  40175. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  40176. var opts = CSSESC_QUOTE_OPTIONS[quote];
  40177. var quoteValue = (0, _cssesc["default"])(v, opts);
  40178. if (quoteValue.length < escaped.length) {
  40179. return quote;
  40180. }
  40181. }
  40182. return pref;
  40183. }
  40184. } else if (numDoubleQuotes === numSingleQuotes) {
  40185. return this.preferredQuoteMark(options);
  40186. } else if (numDoubleQuotes < numSingleQuotes) {
  40187. return Attribute.DOUBLE_QUOTE;
  40188. } else {
  40189. return Attribute.SINGLE_QUOTE;
  40190. }
  40191. }
  40192. /**
  40193. * Selects the preferred quote mark based on the options and the current quote mark value.
  40194. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  40195. * instead.
  40196. */;
  40197. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  40198. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  40199. if (quoteMark === undefined) {
  40200. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  40201. }
  40202. if (quoteMark === undefined) {
  40203. quoteMark = Attribute.DOUBLE_QUOTE;
  40204. }
  40205. return quoteMark;
  40206. };
  40207. _proto._syncRawValue = function _syncRawValue() {
  40208. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  40209. if (rawValue === this._value) {
  40210. if (this.raws) {
  40211. delete this.raws.value;
  40212. }
  40213. } else {
  40214. this.raws.value = rawValue;
  40215. }
  40216. };
  40217. _proto._handleEscapes = function _handleEscapes(prop, value) {
  40218. if (this._constructed) {
  40219. var escaped = (0, _cssesc["default"])(value, {
  40220. isIdentifier: true
  40221. });
  40222. if (escaped !== value) {
  40223. this.raws[prop] = escaped;
  40224. } else {
  40225. delete this.raws[prop];
  40226. }
  40227. }
  40228. };
  40229. _proto._spacesFor = function _spacesFor(name) {
  40230. var attrSpaces = {
  40231. before: '',
  40232. after: ''
  40233. };
  40234. var spaces = this.spaces[name] || {};
  40235. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  40236. return Object.assign(attrSpaces, spaces, rawSpaces);
  40237. };
  40238. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  40239. if (spaceName === void 0) {
  40240. spaceName = name;
  40241. }
  40242. if (concat === void 0) {
  40243. concat = defaultAttrConcat;
  40244. }
  40245. var attrSpaces = this._spacesFor(spaceName);
  40246. return concat(this.stringifyProperty(name), attrSpaces);
  40247. }
  40248. /**
  40249. * returns the offset of the attribute part specified relative to the
  40250. * start of the node of the output string.
  40251. *
  40252. * * "ns" - alias for "namespace"
  40253. * * "namespace" - the namespace if it exists.
  40254. * * "attribute" - the attribute name
  40255. * * "attributeNS" - the start of the attribute or its namespace
  40256. * * "operator" - the match operator of the attribute
  40257. * * "value" - The value (string or identifier)
  40258. * * "insensitive" - the case insensitivity flag;
  40259. * @param part One of the possible values inside an attribute.
  40260. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  40261. */;
  40262. _proto.offsetOf = function offsetOf(name) {
  40263. var count = 1;
  40264. var attributeSpaces = this._spacesFor("attribute");
  40265. count += attributeSpaces.before.length;
  40266. if (name === "namespace" || name === "ns") {
  40267. return this.namespace ? count : -1;
  40268. }
  40269. if (name === "attributeNS") {
  40270. return count;
  40271. }
  40272. count += this.namespaceString.length;
  40273. if (this.namespace) {
  40274. count += 1;
  40275. }
  40276. if (name === "attribute") {
  40277. return count;
  40278. }
  40279. count += this.stringifyProperty("attribute").length;
  40280. count += attributeSpaces.after.length;
  40281. var operatorSpaces = this._spacesFor("operator");
  40282. count += operatorSpaces.before.length;
  40283. var operator = this.stringifyProperty("operator");
  40284. if (name === "operator") {
  40285. return operator ? count : -1;
  40286. }
  40287. count += operator.length;
  40288. count += operatorSpaces.after.length;
  40289. var valueSpaces = this._spacesFor("value");
  40290. count += valueSpaces.before.length;
  40291. var value = this.stringifyProperty("value");
  40292. if (name === "value") {
  40293. return value ? count : -1;
  40294. }
  40295. count += value.length;
  40296. count += valueSpaces.after.length;
  40297. var insensitiveSpaces = this._spacesFor("insensitive");
  40298. count += insensitiveSpaces.before.length;
  40299. if (name === "insensitive") {
  40300. return this.insensitive ? count : -1;
  40301. }
  40302. return -1;
  40303. };
  40304. _proto.toString = function toString() {
  40305. var _this2 = this;
  40306. var selector = [this.rawSpaceBefore, '['];
  40307. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  40308. if (this.operator && (this.value || this.value === '')) {
  40309. selector.push(this._stringFor('operator'));
  40310. selector.push(this._stringFor('value'));
  40311. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  40312. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  40313. attrSpaces.before = " ";
  40314. }
  40315. return defaultAttrConcat(attrValue, attrSpaces);
  40316. }));
  40317. }
  40318. selector.push(']');
  40319. selector.push(this.rawSpaceAfter);
  40320. return selector.join('');
  40321. };
  40322. _createClass(Attribute, [{
  40323. key: "quoted",
  40324. get: function get() {
  40325. var qm = this.quoteMark;
  40326. return qm === "'" || qm === '"';
  40327. },
  40328. set: function set(value) {
  40329. warnOfDeprecatedQuotedAssignment();
  40330. }
  40331. /**
  40332. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  40333. * returns `null` if the value is not quoted.
  40334. * returns `undefined` if the quotation state is unknown (this can happen when
  40335. * the attribute is constructed without specifying a quote mark.)
  40336. */
  40337. }, {
  40338. key: "quoteMark",
  40339. get: function get() {
  40340. return this._quoteMark;
  40341. }
  40342. /**
  40343. * Set the quote mark to be used by this attribute's value.
  40344. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  40345. * value is updated accordingly.
  40346. *
  40347. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  40348. */,
  40349. set: function set(quoteMark) {
  40350. if (!this._constructed) {
  40351. this._quoteMark = quoteMark;
  40352. return;
  40353. }
  40354. if (this._quoteMark !== quoteMark) {
  40355. this._quoteMark = quoteMark;
  40356. this._syncRawValue();
  40357. }
  40358. }
  40359. }, {
  40360. key: "qualifiedAttribute",
  40361. get: function get() {
  40362. return this.qualifiedName(this.raws.attribute || this.attribute);
  40363. }
  40364. }, {
  40365. key: "insensitiveFlag",
  40366. get: function get() {
  40367. return this.insensitive ? 'i' : '';
  40368. }
  40369. }, {
  40370. key: "value",
  40371. get: function get() {
  40372. return this._value;
  40373. },
  40374. set:
  40375. /**
  40376. * Before 3.0, the value had to be set to an escaped value including any wrapped
  40377. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  40378. * is unescaped during parsing and any quote marks are removed.
  40379. *
  40380. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  40381. * a deprecation warning is raised when the new value contains any characters that would
  40382. * require escaping (including if it contains wrapped quotes).
  40383. *
  40384. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  40385. * how the new value is quoted.
  40386. */
  40387. function set(v) {
  40388. if (this._constructed) {
  40389. var _unescapeValue2 = unescapeValue(v),
  40390. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  40391. unescaped = _unescapeValue2.unescaped,
  40392. quoteMark = _unescapeValue2.quoteMark;
  40393. if (deprecatedUsage) {
  40394. warnOfDeprecatedValueAssignment();
  40395. }
  40396. if (unescaped === this._value && quoteMark === this._quoteMark) {
  40397. return;
  40398. }
  40399. this._value = unescaped;
  40400. this._quoteMark = quoteMark;
  40401. this._syncRawValue();
  40402. } else {
  40403. this._value = v;
  40404. }
  40405. }
  40406. }, {
  40407. key: "insensitive",
  40408. get: function get() {
  40409. return this._insensitive;
  40410. }
  40411. /**
  40412. * Set the case insensitive flag.
  40413. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  40414. * of the attribute is updated accordingly.
  40415. *
  40416. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  40417. */,
  40418. set: function set(insensitive) {
  40419. if (!insensitive) {
  40420. this._insensitive = false;
  40421. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  40422. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  40423. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  40424. this.raws.insensitiveFlag = undefined;
  40425. }
  40426. }
  40427. this._insensitive = insensitive;
  40428. }
  40429. }, {
  40430. key: "attribute",
  40431. get: function get() {
  40432. return this._attribute;
  40433. },
  40434. set: function set(name) {
  40435. this._handleEscapes("attribute", name);
  40436. this._attribute = name;
  40437. }
  40438. }]);
  40439. return Attribute;
  40440. }(_namespace["default"]);
  40441. exports["default"] = Attribute;
  40442. Attribute.NO_QUOTE = null;
  40443. Attribute.SINGLE_QUOTE = "'";
  40444. Attribute.DOUBLE_QUOTE = '"';
  40445. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  40446. "'": {
  40447. quotes: 'single',
  40448. wrap: true
  40449. },
  40450. '"': {
  40451. quotes: 'double',
  40452. wrap: true
  40453. }
  40454. }, _CSSESC_QUOTE_OPTIONS[null] = {
  40455. isIdentifier: true
  40456. }, _CSSESC_QUOTE_OPTIONS);
  40457. function defaultAttrConcat(attrValue, attrSpaces) {
  40458. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  40459. }
  40460. } (attribute));
  40461. return attribute;
  40462. }
  40463. var universal = {exports: {}};
  40464. var hasRequiredUniversal;
  40465. function requireUniversal () {
  40466. if (hasRequiredUniversal) return universal.exports;
  40467. hasRequiredUniversal = 1;
  40468. (function (module, exports) {
  40469. exports.__esModule = true;
  40470. exports["default"] = void 0;
  40471. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  40472. var _types = /*@__PURE__*/ requireTypes();
  40473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40474. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40475. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40476. var Universal = /*#__PURE__*/function (_Namespace) {
  40477. _inheritsLoose(Universal, _Namespace);
  40478. function Universal(opts) {
  40479. var _this;
  40480. _this = _Namespace.call(this, opts) || this;
  40481. _this.type = _types.UNIVERSAL;
  40482. _this.value = '*';
  40483. return _this;
  40484. }
  40485. return Universal;
  40486. }(_namespace["default"]);
  40487. exports["default"] = Universal;
  40488. module.exports = exports.default;
  40489. } (universal, universal.exports));
  40490. return universal.exports;
  40491. }
  40492. var combinator = {exports: {}};
  40493. var hasRequiredCombinator;
  40494. function requireCombinator () {
  40495. if (hasRequiredCombinator) return combinator.exports;
  40496. hasRequiredCombinator = 1;
  40497. (function (module, exports) {
  40498. exports.__esModule = true;
  40499. exports["default"] = void 0;
  40500. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  40501. var _types = /*@__PURE__*/ requireTypes();
  40502. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40503. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40504. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40505. var Combinator = /*#__PURE__*/function (_Node) {
  40506. _inheritsLoose(Combinator, _Node);
  40507. function Combinator(opts) {
  40508. var _this;
  40509. _this = _Node.call(this, opts) || this;
  40510. _this.type = _types.COMBINATOR;
  40511. return _this;
  40512. }
  40513. return Combinator;
  40514. }(_node["default"]);
  40515. exports["default"] = Combinator;
  40516. module.exports = exports.default;
  40517. } (combinator, combinator.exports));
  40518. return combinator.exports;
  40519. }
  40520. var nesting = {exports: {}};
  40521. var hasRequiredNesting;
  40522. function requireNesting () {
  40523. if (hasRequiredNesting) return nesting.exports;
  40524. hasRequiredNesting = 1;
  40525. (function (module, exports) {
  40526. exports.__esModule = true;
  40527. exports["default"] = void 0;
  40528. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  40529. var _types = /*@__PURE__*/ requireTypes();
  40530. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40531. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40532. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40533. var Nesting = /*#__PURE__*/function (_Node) {
  40534. _inheritsLoose(Nesting, _Node);
  40535. function Nesting(opts) {
  40536. var _this;
  40537. _this = _Node.call(this, opts) || this;
  40538. _this.type = _types.NESTING;
  40539. _this.value = '&';
  40540. return _this;
  40541. }
  40542. return Nesting;
  40543. }(_node["default"]);
  40544. exports["default"] = Nesting;
  40545. module.exports = exports.default;
  40546. } (nesting, nesting.exports));
  40547. return nesting.exports;
  40548. }
  40549. var sortAscending = {exports: {}};
  40550. var hasRequiredSortAscending;
  40551. function requireSortAscending () {
  40552. if (hasRequiredSortAscending) return sortAscending.exports;
  40553. hasRequiredSortAscending = 1;
  40554. (function (module, exports) {
  40555. exports.__esModule = true;
  40556. exports["default"] = sortAscending;
  40557. function sortAscending(list) {
  40558. return list.sort(function (a, b) {
  40559. return a - b;
  40560. });
  40561. }
  40562. module.exports = exports.default;
  40563. } (sortAscending, sortAscending.exports));
  40564. return sortAscending.exports;
  40565. }
  40566. var tokenize = {};
  40567. var tokenTypes = {};
  40568. var hasRequiredTokenTypes;
  40569. function requireTokenTypes () {
  40570. if (hasRequiredTokenTypes) return tokenTypes;
  40571. hasRequiredTokenTypes = 1;
  40572. tokenTypes.__esModule = true;
  40573. 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;
  40574. var ampersand = 38; // `&`.charCodeAt(0);
  40575. tokenTypes.ampersand = ampersand;
  40576. var asterisk = 42; // `*`.charCodeAt(0);
  40577. tokenTypes.asterisk = asterisk;
  40578. var at = 64; // `@`.charCodeAt(0);
  40579. tokenTypes.at = at;
  40580. var comma = 44; // `,`.charCodeAt(0);
  40581. tokenTypes.comma = comma;
  40582. var colon = 58; // `:`.charCodeAt(0);
  40583. tokenTypes.colon = colon;
  40584. var semicolon = 59; // `;`.charCodeAt(0);
  40585. tokenTypes.semicolon = semicolon;
  40586. var openParenthesis = 40; // `(`.charCodeAt(0);
  40587. tokenTypes.openParenthesis = openParenthesis;
  40588. var closeParenthesis = 41; // `)`.charCodeAt(0);
  40589. tokenTypes.closeParenthesis = closeParenthesis;
  40590. var openSquare = 91; // `[`.charCodeAt(0);
  40591. tokenTypes.openSquare = openSquare;
  40592. var closeSquare = 93; // `]`.charCodeAt(0);
  40593. tokenTypes.closeSquare = closeSquare;
  40594. var dollar = 36; // `$`.charCodeAt(0);
  40595. tokenTypes.dollar = dollar;
  40596. var tilde = 126; // `~`.charCodeAt(0);
  40597. tokenTypes.tilde = tilde;
  40598. var caret = 94; // `^`.charCodeAt(0);
  40599. tokenTypes.caret = caret;
  40600. var plus = 43; // `+`.charCodeAt(0);
  40601. tokenTypes.plus = plus;
  40602. var equals = 61; // `=`.charCodeAt(0);
  40603. tokenTypes.equals = equals;
  40604. var pipe = 124; // `|`.charCodeAt(0);
  40605. tokenTypes.pipe = pipe;
  40606. var greaterThan = 62; // `>`.charCodeAt(0);
  40607. tokenTypes.greaterThan = greaterThan;
  40608. var space = 32; // ` `.charCodeAt(0);
  40609. tokenTypes.space = space;
  40610. var singleQuote = 39; // `'`.charCodeAt(0);
  40611. tokenTypes.singleQuote = singleQuote;
  40612. var doubleQuote = 34; // `"`.charCodeAt(0);
  40613. tokenTypes.doubleQuote = doubleQuote;
  40614. var slash = 47; // `/`.charCodeAt(0);
  40615. tokenTypes.slash = slash;
  40616. var bang = 33; // `!`.charCodeAt(0);
  40617. tokenTypes.bang = bang;
  40618. var backslash = 92; // '\\'.charCodeAt(0);
  40619. tokenTypes.backslash = backslash;
  40620. var cr = 13; // '\r'.charCodeAt(0);
  40621. tokenTypes.cr = cr;
  40622. var feed = 12; // '\f'.charCodeAt(0);
  40623. tokenTypes.feed = feed;
  40624. var newline = 10; // '\n'.charCodeAt(0);
  40625. tokenTypes.newline = newline;
  40626. var tab = 9; // '\t'.charCodeAt(0);
  40627. // Expose aliases primarily for readability.
  40628. tokenTypes.tab = tab;
  40629. var str = singleQuote;
  40630. // No good single character representation!
  40631. tokenTypes.str = str;
  40632. var comment = -1;
  40633. tokenTypes.comment = comment;
  40634. var word = -2;
  40635. tokenTypes.word = word;
  40636. var combinator = -3;
  40637. tokenTypes.combinator = combinator;
  40638. return tokenTypes;
  40639. }
  40640. var hasRequiredTokenize;
  40641. function requireTokenize () {
  40642. if (hasRequiredTokenize) return tokenize;
  40643. hasRequiredTokenize = 1;
  40644. (function (exports) {
  40645. exports.__esModule = true;
  40646. exports.FIELDS = void 0;
  40647. exports["default"] = tokenize;
  40648. var t = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  40649. var _unescapable, _wordDelimiters;
  40650. 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); }
  40651. function _interopRequireWildcard(obj, nodeInterop) { if (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; }
  40652. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  40653. 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);
  40654. var hex = {};
  40655. var hexChars = "0123456789abcdefABCDEF";
  40656. for (var i = 0; i < hexChars.length; i++) {
  40657. hex[hexChars.charCodeAt(i)] = true;
  40658. }
  40659. /**
  40660. * Returns the last index of the bar css word
  40661. * @param {string} css The string in which the word begins
  40662. * @param {number} start The index into the string where word's first letter occurs
  40663. */
  40664. function consumeWord(css, start) {
  40665. var next = start;
  40666. var code;
  40667. do {
  40668. code = css.charCodeAt(next);
  40669. if (wordDelimiters[code]) {
  40670. return next - 1;
  40671. } else if (code === t.backslash) {
  40672. next = consumeEscape(css, next) + 1;
  40673. } else {
  40674. // All other characters are part of the word
  40675. next++;
  40676. }
  40677. } while (next < css.length);
  40678. return next - 1;
  40679. }
  40680. /**
  40681. * Returns the last index of the escape sequence
  40682. * @param {string} css The string in which the sequence begins
  40683. * @param {number} start The index into the string where escape character (`\`) occurs.
  40684. */
  40685. function consumeEscape(css, start) {
  40686. var next = start;
  40687. var code = css.charCodeAt(next + 1);
  40688. if (unescapable[code]) ; else if (hex[code]) {
  40689. var hexDigits = 0;
  40690. // consume up to 6 hex chars
  40691. do {
  40692. next++;
  40693. hexDigits++;
  40694. code = css.charCodeAt(next + 1);
  40695. } while (hex[code] && hexDigits < 6);
  40696. // if fewer than 6 hex chars, a trailing space ends the escape
  40697. if (hexDigits < 6 && code === t.space) {
  40698. next++;
  40699. }
  40700. } else {
  40701. // the next char is part of the current word
  40702. next++;
  40703. }
  40704. return next;
  40705. }
  40706. var FIELDS = {
  40707. TYPE: 0,
  40708. START_LINE: 1,
  40709. START_COL: 2,
  40710. END_LINE: 3,
  40711. END_COL: 4,
  40712. START_POS: 5,
  40713. END_POS: 6
  40714. };
  40715. exports.FIELDS = FIELDS;
  40716. function tokenize(input) {
  40717. var tokens = [];
  40718. var css = input.css.valueOf();
  40719. var _css = css,
  40720. length = _css.length;
  40721. var offset = -1;
  40722. var line = 1;
  40723. var start = 0;
  40724. var end = 0;
  40725. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  40726. function unclosed(what, fix) {
  40727. if (input.safe) {
  40728. // fyi: this is never set to true.
  40729. css += fix;
  40730. next = css.length - 1;
  40731. } else {
  40732. throw input.error('Unclosed ' + what, line, start - offset, start);
  40733. }
  40734. }
  40735. while (start < length) {
  40736. code = css.charCodeAt(start);
  40737. if (code === t.newline) {
  40738. offset = start;
  40739. line += 1;
  40740. }
  40741. switch (code) {
  40742. case t.space:
  40743. case t.tab:
  40744. case t.newline:
  40745. case t.cr:
  40746. case t.feed:
  40747. next = start;
  40748. do {
  40749. next += 1;
  40750. code = css.charCodeAt(next);
  40751. if (code === t.newline) {
  40752. offset = next;
  40753. line += 1;
  40754. }
  40755. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  40756. tokenType = t.space;
  40757. endLine = line;
  40758. endColumn = next - offset - 1;
  40759. end = next;
  40760. break;
  40761. case t.plus:
  40762. case t.greaterThan:
  40763. case t.tilde:
  40764. case t.pipe:
  40765. next = start;
  40766. do {
  40767. next += 1;
  40768. code = css.charCodeAt(next);
  40769. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  40770. tokenType = t.combinator;
  40771. endLine = line;
  40772. endColumn = start - offset;
  40773. end = next;
  40774. break;
  40775. // Consume these characters as single tokens.
  40776. case t.asterisk:
  40777. case t.ampersand:
  40778. case t.bang:
  40779. case t.comma:
  40780. case t.equals:
  40781. case t.dollar:
  40782. case t.caret:
  40783. case t.openSquare:
  40784. case t.closeSquare:
  40785. case t.colon:
  40786. case t.semicolon:
  40787. case t.openParenthesis:
  40788. case t.closeParenthesis:
  40789. next = start;
  40790. tokenType = code;
  40791. endLine = line;
  40792. endColumn = start - offset;
  40793. end = next + 1;
  40794. break;
  40795. case t.singleQuote:
  40796. case t.doubleQuote:
  40797. quote = code === t.singleQuote ? "'" : '"';
  40798. next = start;
  40799. do {
  40800. escaped = false;
  40801. next = css.indexOf(quote, next + 1);
  40802. if (next === -1) {
  40803. unclosed('quote', quote);
  40804. }
  40805. escapePos = next;
  40806. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  40807. escapePos -= 1;
  40808. escaped = !escaped;
  40809. }
  40810. } while (escaped);
  40811. tokenType = t.str;
  40812. endLine = line;
  40813. endColumn = start - offset;
  40814. end = next + 1;
  40815. break;
  40816. default:
  40817. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  40818. next = css.indexOf('*/', start + 2) + 1;
  40819. if (next === 0) {
  40820. unclosed('comment', '*/');
  40821. }
  40822. content = css.slice(start, next + 1);
  40823. lines = content.split('\n');
  40824. last = lines.length - 1;
  40825. if (last > 0) {
  40826. nextLine = line + last;
  40827. nextOffset = next - lines[last].length;
  40828. } else {
  40829. nextLine = line;
  40830. nextOffset = offset;
  40831. }
  40832. tokenType = t.comment;
  40833. line = nextLine;
  40834. endLine = nextLine;
  40835. endColumn = next - nextOffset;
  40836. } else if (code === t.slash) {
  40837. next = start;
  40838. tokenType = code;
  40839. endLine = line;
  40840. endColumn = start - offset;
  40841. end = next + 1;
  40842. } else {
  40843. next = consumeWord(css, start);
  40844. tokenType = t.word;
  40845. endLine = line;
  40846. endColumn = next - offset;
  40847. }
  40848. end = next + 1;
  40849. break;
  40850. }
  40851. // Ensure that the token structure remains consistent
  40852. tokens.push([tokenType,
  40853. // [0] Token type
  40854. line,
  40855. // [1] Starting line
  40856. start - offset,
  40857. // [2] Starting column
  40858. endLine,
  40859. // [3] Ending line
  40860. endColumn,
  40861. // [4] Ending column
  40862. start,
  40863. // [5] Start position / Source index
  40864. end // [6] End position
  40865. ]);
  40866. // Reset offset for the next token
  40867. if (nextOffset) {
  40868. offset = nextOffset;
  40869. nextOffset = null;
  40870. }
  40871. start = end;
  40872. }
  40873. return tokens;
  40874. }
  40875. } (tokenize));
  40876. return tokenize;
  40877. }
  40878. var hasRequiredParser;
  40879. function requireParser () {
  40880. if (hasRequiredParser) return parser.exports;
  40881. hasRequiredParser = 1;
  40882. (function (module, exports) {
  40883. exports.__esModule = true;
  40884. exports["default"] = void 0;
  40885. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  40886. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  40887. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  40888. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  40889. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  40890. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  40891. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  40892. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  40893. var _attribute = _interopRequireWildcard(/*@__PURE__*/ requireAttribute());
  40894. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  40895. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  40896. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  40897. var _sortAscending = _interopRequireDefault(/*@__PURE__*/ requireSortAscending());
  40898. var _tokenize = _interopRequireWildcard(/*@__PURE__*/ requireTokenize());
  40899. var tokens = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  40900. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  40901. var _util = /*@__PURE__*/ requireUtil$1();
  40902. var _WHITESPACE_TOKENS, _Object$assign;
  40903. 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); }
  40904. function _interopRequireWildcard(obj, nodeInterop) { if (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; }
  40905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40906. 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); } }
  40907. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  40908. 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);
  40909. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  40910. function tokenStart(token) {
  40911. return {
  40912. line: token[_tokenize.FIELDS.START_LINE],
  40913. column: token[_tokenize.FIELDS.START_COL]
  40914. };
  40915. }
  40916. function tokenEnd(token) {
  40917. return {
  40918. line: token[_tokenize.FIELDS.END_LINE],
  40919. column: token[_tokenize.FIELDS.END_COL]
  40920. };
  40921. }
  40922. function getSource(startLine, startColumn, endLine, endColumn) {
  40923. return {
  40924. start: {
  40925. line: startLine,
  40926. column: startColumn
  40927. },
  40928. end: {
  40929. line: endLine,
  40930. column: endColumn
  40931. }
  40932. };
  40933. }
  40934. function getTokenSource(token) {
  40935. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  40936. }
  40937. function getTokenSourceSpan(startToken, endToken) {
  40938. if (!startToken) {
  40939. return undefined;
  40940. }
  40941. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  40942. }
  40943. function unescapeProp(node, prop) {
  40944. var value = node[prop];
  40945. if (typeof value !== "string") {
  40946. return;
  40947. }
  40948. if (value.indexOf("\\") !== -1) {
  40949. (0, _util.ensureObject)(node, 'raws');
  40950. node[prop] = (0, _util.unesc)(value);
  40951. if (node.raws[prop] === undefined) {
  40952. node.raws[prop] = value;
  40953. }
  40954. }
  40955. return node;
  40956. }
  40957. function indexesOf(array, item) {
  40958. var i = -1;
  40959. var indexes = [];
  40960. while ((i = array.indexOf(item, i + 1)) !== -1) {
  40961. indexes.push(i);
  40962. }
  40963. return indexes;
  40964. }
  40965. function uniqs() {
  40966. var list = Array.prototype.concat.apply([], arguments);
  40967. return list.filter(function (item, i) {
  40968. return i === list.indexOf(item);
  40969. });
  40970. }
  40971. var Parser = /*#__PURE__*/function () {
  40972. function Parser(rule, options) {
  40973. if (options === void 0) {
  40974. options = {};
  40975. }
  40976. this.rule = rule;
  40977. this.options = Object.assign({
  40978. lossy: false,
  40979. safe: false
  40980. }, options);
  40981. this.position = 0;
  40982. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  40983. this.tokens = (0, _tokenize["default"])({
  40984. css: this.css,
  40985. error: this._errorGenerator(),
  40986. safe: this.options.safe
  40987. });
  40988. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  40989. this.root = new _root["default"]({
  40990. source: rootSource
  40991. });
  40992. this.root.errorGenerator = this._errorGenerator();
  40993. var selector = new _selector["default"]({
  40994. source: {
  40995. start: {
  40996. line: 1,
  40997. column: 1
  40998. }
  40999. },
  41000. sourceIndex: 0
  41001. });
  41002. this.root.append(selector);
  41003. this.current = selector;
  41004. this.loop();
  41005. }
  41006. var _proto = Parser.prototype;
  41007. _proto._errorGenerator = function _errorGenerator() {
  41008. var _this = this;
  41009. return function (message, errorOptions) {
  41010. if (typeof _this.rule === 'string') {
  41011. return new Error(message);
  41012. }
  41013. return _this.rule.error(message, errorOptions);
  41014. };
  41015. };
  41016. _proto.attribute = function attribute() {
  41017. var attr = [];
  41018. var startingToken = this.currToken;
  41019. this.position++;
  41020. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  41021. attr.push(this.currToken);
  41022. this.position++;
  41023. }
  41024. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  41025. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  41026. }
  41027. var len = attr.length;
  41028. var node = {
  41029. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  41030. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  41031. };
  41032. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  41033. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  41034. }
  41035. var pos = 0;
  41036. var spaceBefore = '';
  41037. var commentBefore = '';
  41038. var lastAdded = null;
  41039. var spaceAfterMeaningfulToken = false;
  41040. while (pos < len) {
  41041. var token = attr[pos];
  41042. var content = this.content(token);
  41043. var next = attr[pos + 1];
  41044. switch (token[_tokenize.FIELDS.TYPE]) {
  41045. case tokens.space:
  41046. // if (
  41047. // len === 1 ||
  41048. // pos === 0 && this.content(next) === '|'
  41049. // ) {
  41050. // return this.expected('attribute', token[TOKEN.START_POS], content);
  41051. // }
  41052. spaceAfterMeaningfulToken = true;
  41053. if (this.options.lossy) {
  41054. break;
  41055. }
  41056. if (lastAdded) {
  41057. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  41058. var prevContent = node.spaces[lastAdded].after || '';
  41059. node.spaces[lastAdded].after = prevContent + content;
  41060. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  41061. if (existingComment) {
  41062. node.raws.spaces[lastAdded].after = existingComment + content;
  41063. }
  41064. } else {
  41065. spaceBefore = spaceBefore + content;
  41066. commentBefore = commentBefore + content;
  41067. }
  41068. break;
  41069. case tokens.asterisk:
  41070. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41071. node.operator = content;
  41072. lastAdded = 'operator';
  41073. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  41074. if (spaceBefore) {
  41075. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  41076. node.spaces.attribute.before = spaceBefore;
  41077. spaceBefore = '';
  41078. }
  41079. if (commentBefore) {
  41080. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  41081. node.raws.spaces.attribute.before = spaceBefore;
  41082. commentBefore = '';
  41083. }
  41084. node.namespace = (node.namespace || "") + content;
  41085. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  41086. if (rawValue) {
  41087. node.raws.namespace += content;
  41088. }
  41089. lastAdded = 'namespace';
  41090. }
  41091. spaceAfterMeaningfulToken = false;
  41092. break;
  41093. case tokens.dollar:
  41094. if (lastAdded === "value") {
  41095. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  41096. node.value += "$";
  41097. if (oldRawValue) {
  41098. node.raws.value = oldRawValue + "$";
  41099. }
  41100. break;
  41101. }
  41102. // Falls through
  41103. case tokens.caret:
  41104. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41105. node.operator = content;
  41106. lastAdded = 'operator';
  41107. }
  41108. spaceAfterMeaningfulToken = false;
  41109. break;
  41110. case tokens.combinator:
  41111. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41112. node.operator = content;
  41113. lastAdded = 'operator';
  41114. }
  41115. if (content !== '|') {
  41116. spaceAfterMeaningfulToken = false;
  41117. break;
  41118. }
  41119. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41120. node.operator = content;
  41121. lastAdded = 'operator';
  41122. } else if (!node.namespace && !node.attribute) {
  41123. node.namespace = true;
  41124. }
  41125. spaceAfterMeaningfulToken = false;
  41126. break;
  41127. case tokens.word:
  41128. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  41129. // this look-ahead probably fails with comment nodes involved.
  41130. !node.operator && !node.namespace) {
  41131. node.namespace = content;
  41132. lastAdded = 'namespace';
  41133. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  41134. if (spaceBefore) {
  41135. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  41136. node.spaces.attribute.before = spaceBefore;
  41137. spaceBefore = '';
  41138. }
  41139. if (commentBefore) {
  41140. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  41141. node.raws.spaces.attribute.before = commentBefore;
  41142. commentBefore = '';
  41143. }
  41144. node.attribute = (node.attribute || "") + content;
  41145. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  41146. if (_rawValue) {
  41147. node.raws.attribute += content;
  41148. }
  41149. lastAdded = 'attribute';
  41150. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  41151. var _unescaped = (0, _util.unesc)(content);
  41152. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  41153. var oldValue = node.value || '';
  41154. node.value = oldValue + _unescaped;
  41155. node.quoteMark = null;
  41156. if (_unescaped !== content || _oldRawValue) {
  41157. (0, _util.ensureObject)(node, 'raws');
  41158. node.raws.value = (_oldRawValue || oldValue) + content;
  41159. }
  41160. lastAdded = 'value';
  41161. } else {
  41162. var insensitive = content === 'i' || content === "I";
  41163. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  41164. node.insensitive = insensitive;
  41165. if (!insensitive || content === "I") {
  41166. (0, _util.ensureObject)(node, 'raws');
  41167. node.raws.insensitiveFlag = content;
  41168. }
  41169. lastAdded = 'insensitive';
  41170. if (spaceBefore) {
  41171. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  41172. node.spaces.insensitive.before = spaceBefore;
  41173. spaceBefore = '';
  41174. }
  41175. if (commentBefore) {
  41176. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  41177. node.raws.spaces.insensitive.before = commentBefore;
  41178. commentBefore = '';
  41179. }
  41180. } else if (node.value || node.value === '') {
  41181. lastAdded = 'value';
  41182. node.value += content;
  41183. if (node.raws.value) {
  41184. node.raws.value += content;
  41185. }
  41186. }
  41187. }
  41188. spaceAfterMeaningfulToken = false;
  41189. break;
  41190. case tokens.str:
  41191. if (!node.attribute || !node.operator) {
  41192. return this.error("Expected an attribute followed by an operator preceding the string.", {
  41193. index: token[_tokenize.FIELDS.START_POS]
  41194. });
  41195. }
  41196. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  41197. unescaped = _unescapeValue.unescaped,
  41198. quoteMark = _unescapeValue.quoteMark;
  41199. node.value = unescaped;
  41200. node.quoteMark = quoteMark;
  41201. lastAdded = 'value';
  41202. (0, _util.ensureObject)(node, 'raws');
  41203. node.raws.value = content;
  41204. spaceAfterMeaningfulToken = false;
  41205. break;
  41206. case tokens.equals:
  41207. if (!node.attribute) {
  41208. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  41209. }
  41210. if (node.value) {
  41211. return this.error('Unexpected "=" found; an operator was already defined.', {
  41212. index: token[_tokenize.FIELDS.START_POS]
  41213. });
  41214. }
  41215. node.operator = node.operator ? node.operator + content : content;
  41216. lastAdded = 'operator';
  41217. spaceAfterMeaningfulToken = false;
  41218. break;
  41219. case tokens.comment:
  41220. if (lastAdded) {
  41221. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  41222. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  41223. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  41224. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  41225. node.raws.spaces[lastAdded].after = rawLastComment + content;
  41226. } else {
  41227. var lastValue = node[lastAdded] || '';
  41228. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  41229. (0, _util.ensureObject)(node, 'raws');
  41230. node.raws[lastAdded] = rawLastValue + content;
  41231. }
  41232. } else {
  41233. commentBefore = commentBefore + content;
  41234. }
  41235. break;
  41236. default:
  41237. return this.error("Unexpected \"" + content + "\" found.", {
  41238. index: token[_tokenize.FIELDS.START_POS]
  41239. });
  41240. }
  41241. pos++;
  41242. }
  41243. unescapeProp(node, "attribute");
  41244. unescapeProp(node, "namespace");
  41245. this.newNode(new _attribute["default"](node));
  41246. this.position++;
  41247. }
  41248. /**
  41249. * return a node containing meaningless garbage up to (but not including) the specified token position.
  41250. * if the token position is negative, all remaining tokens are consumed.
  41251. *
  41252. * This returns an array containing a single string node if all whitespace,
  41253. * otherwise an array of comment nodes with space before and after.
  41254. *
  41255. * These tokens are not added to the current selector, the caller can add them or use them to amend
  41256. * a previous node's space metadata.
  41257. *
  41258. * In lossy mode, this returns only comments.
  41259. */;
  41260. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  41261. if (stopPosition < 0) {
  41262. stopPosition = this.tokens.length;
  41263. }
  41264. var startPosition = this.position;
  41265. var nodes = [];
  41266. var space = "";
  41267. var lastComment = undefined;
  41268. do {
  41269. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  41270. if (!this.options.lossy) {
  41271. space += this.content();
  41272. }
  41273. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  41274. var spaces = {};
  41275. if (space) {
  41276. spaces.before = space;
  41277. space = "";
  41278. }
  41279. lastComment = new _comment["default"]({
  41280. value: this.content(),
  41281. source: getTokenSource(this.currToken),
  41282. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  41283. spaces: spaces
  41284. });
  41285. nodes.push(lastComment);
  41286. }
  41287. } while (++this.position < stopPosition);
  41288. if (space) {
  41289. if (lastComment) {
  41290. lastComment.spaces.after = space;
  41291. } else if (!this.options.lossy) {
  41292. var firstToken = this.tokens[startPosition];
  41293. var lastToken = this.tokens[this.position - 1];
  41294. nodes.push(new _string["default"]({
  41295. value: '',
  41296. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  41297. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  41298. spaces: {
  41299. before: space,
  41300. after: ''
  41301. }
  41302. }));
  41303. }
  41304. }
  41305. return nodes;
  41306. }
  41307. /**
  41308. *
  41309. * @param {*} nodes
  41310. */;
  41311. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  41312. var _this2 = this;
  41313. if (requiredSpace === void 0) {
  41314. requiredSpace = false;
  41315. }
  41316. var space = "";
  41317. var rawSpace = "";
  41318. nodes.forEach(function (n) {
  41319. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  41320. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  41321. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  41322. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  41323. });
  41324. if (rawSpace === space) {
  41325. rawSpace = undefined;
  41326. }
  41327. var result = {
  41328. space: space,
  41329. rawSpace: rawSpace
  41330. };
  41331. return result;
  41332. };
  41333. _proto.isNamedCombinator = function isNamedCombinator(position) {
  41334. if (position === void 0) {
  41335. position = this.position;
  41336. }
  41337. 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;
  41338. };
  41339. _proto.namedCombinator = function namedCombinator() {
  41340. if (this.isNamedCombinator()) {
  41341. var nameRaw = this.content(this.tokens[this.position + 1]);
  41342. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  41343. var raws = {};
  41344. if (name !== nameRaw) {
  41345. raws.value = "/" + nameRaw + "/";
  41346. }
  41347. var node = new _combinator["default"]({
  41348. value: "/" + name + "/",
  41349. 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]),
  41350. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  41351. raws: raws
  41352. });
  41353. this.position = this.position + 3;
  41354. return node;
  41355. } else {
  41356. this.unexpected();
  41357. }
  41358. };
  41359. _proto.combinator = function combinator() {
  41360. var _this3 = this;
  41361. if (this.content() === '|') {
  41362. return this.namespace();
  41363. }
  41364. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  41365. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  41366. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41367. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  41368. if (nodes.length > 0) {
  41369. var last = this.current.last;
  41370. if (last) {
  41371. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  41372. space = _this$convertWhitespa.space,
  41373. rawSpace = _this$convertWhitespa.rawSpace;
  41374. if (rawSpace !== undefined) {
  41375. last.rawSpaceAfter += rawSpace;
  41376. }
  41377. last.spaces.after += space;
  41378. } else {
  41379. nodes.forEach(function (n) {
  41380. return _this3.newNode(n);
  41381. });
  41382. }
  41383. }
  41384. return;
  41385. }
  41386. var firstToken = this.currToken;
  41387. var spaceOrDescendantSelectorNodes = undefined;
  41388. if (nextSigTokenPos > this.position) {
  41389. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  41390. }
  41391. var node;
  41392. if (this.isNamedCombinator()) {
  41393. node = this.namedCombinator();
  41394. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  41395. node = new _combinator["default"]({
  41396. value: this.content(),
  41397. source: getTokenSource(this.currToken),
  41398. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  41399. });
  41400. this.position++;
  41401. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  41402. this.unexpected();
  41403. }
  41404. if (node) {
  41405. if (spaceOrDescendantSelectorNodes) {
  41406. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  41407. _space = _this$convertWhitespa2.space,
  41408. _rawSpace = _this$convertWhitespa2.rawSpace;
  41409. node.spaces.before = _space;
  41410. node.rawSpaceBefore = _rawSpace;
  41411. }
  41412. } else {
  41413. // descendant combinator
  41414. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  41415. _space2 = _this$convertWhitespa3.space,
  41416. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  41417. if (!_rawSpace2) {
  41418. _rawSpace2 = _space2;
  41419. }
  41420. var spaces = {};
  41421. var raws = {
  41422. spaces: {}
  41423. };
  41424. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  41425. spaces.before = _space2.slice(0, _space2.length - 1);
  41426. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  41427. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  41428. spaces.after = _space2.slice(1);
  41429. raws.spaces.after = _rawSpace2.slice(1);
  41430. } else {
  41431. raws.value = _rawSpace2;
  41432. }
  41433. node = new _combinator["default"]({
  41434. value: ' ',
  41435. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  41436. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  41437. spaces: spaces,
  41438. raws: raws
  41439. });
  41440. }
  41441. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  41442. node.spaces.after = this.optionalSpace(this.content());
  41443. this.position++;
  41444. }
  41445. return this.newNode(node);
  41446. };
  41447. _proto.comma = function comma() {
  41448. if (this.position === this.tokens.length - 1) {
  41449. this.root.trailingComma = true;
  41450. this.position++;
  41451. return;
  41452. }
  41453. this.current._inferEndPosition();
  41454. var selector = new _selector["default"]({
  41455. source: {
  41456. start: tokenStart(this.tokens[this.position + 1])
  41457. },
  41458. sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
  41459. });
  41460. this.current.parent.append(selector);
  41461. this.current = selector;
  41462. this.position++;
  41463. };
  41464. _proto.comment = function comment() {
  41465. var current = this.currToken;
  41466. this.newNode(new _comment["default"]({
  41467. value: this.content(),
  41468. source: getTokenSource(current),
  41469. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41470. }));
  41471. this.position++;
  41472. };
  41473. _proto.error = function error(message, opts) {
  41474. throw this.root.error(message, opts);
  41475. };
  41476. _proto.missingBackslash = function missingBackslash() {
  41477. return this.error('Expected a backslash preceding the semicolon.', {
  41478. index: this.currToken[_tokenize.FIELDS.START_POS]
  41479. });
  41480. };
  41481. _proto.missingParenthesis = function missingParenthesis() {
  41482. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  41483. };
  41484. _proto.missingSquareBracket = function missingSquareBracket() {
  41485. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  41486. };
  41487. _proto.unexpected = function unexpected() {
  41488. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  41489. };
  41490. _proto.unexpectedPipe = function unexpectedPipe() {
  41491. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  41492. };
  41493. _proto.namespace = function namespace() {
  41494. var before = this.prevToken && this.content(this.prevToken) || true;
  41495. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  41496. this.position++;
  41497. return this.word(before);
  41498. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  41499. this.position++;
  41500. return this.universal(before);
  41501. }
  41502. this.unexpectedPipe();
  41503. };
  41504. _proto.nesting = function nesting() {
  41505. if (this.nextToken) {
  41506. var nextContent = this.content(this.nextToken);
  41507. if (nextContent === "|") {
  41508. this.position++;
  41509. return;
  41510. }
  41511. }
  41512. var current = this.currToken;
  41513. this.newNode(new _nesting["default"]({
  41514. value: this.content(),
  41515. source: getTokenSource(current),
  41516. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41517. }));
  41518. this.position++;
  41519. };
  41520. _proto.parentheses = function parentheses() {
  41521. var last = this.current.last;
  41522. var unbalanced = 1;
  41523. this.position++;
  41524. if (last && last.type === types.PSEUDO) {
  41525. var selector = new _selector["default"]({
  41526. source: {
  41527. start: tokenStart(this.tokens[this.position])
  41528. },
  41529. sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
  41530. });
  41531. var cache = this.current;
  41532. last.append(selector);
  41533. this.current = selector;
  41534. while (this.position < this.tokens.length && unbalanced) {
  41535. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41536. unbalanced++;
  41537. }
  41538. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41539. unbalanced--;
  41540. }
  41541. if (unbalanced) {
  41542. this.parse();
  41543. } else {
  41544. this.current.source.end = tokenEnd(this.currToken);
  41545. this.current.parent.source.end = tokenEnd(this.currToken);
  41546. this.position++;
  41547. }
  41548. }
  41549. this.current = cache;
  41550. } else {
  41551. // I think this case should be an error. It's used to implement a basic parse of media queries
  41552. // but I don't think it's a good idea.
  41553. var parenStart = this.currToken;
  41554. var parenValue = "(";
  41555. var parenEnd;
  41556. while (this.position < this.tokens.length && unbalanced) {
  41557. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41558. unbalanced++;
  41559. }
  41560. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41561. unbalanced--;
  41562. }
  41563. parenEnd = this.currToken;
  41564. parenValue += this.parseParenthesisToken(this.currToken);
  41565. this.position++;
  41566. }
  41567. if (last) {
  41568. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  41569. } else {
  41570. this.newNode(new _string["default"]({
  41571. value: parenValue,
  41572. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  41573. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  41574. }));
  41575. }
  41576. }
  41577. if (unbalanced) {
  41578. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  41579. }
  41580. };
  41581. _proto.pseudo = function pseudo() {
  41582. var _this4 = this;
  41583. var pseudoStr = '';
  41584. var startingToken = this.currToken;
  41585. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  41586. pseudoStr += this.content();
  41587. this.position++;
  41588. }
  41589. if (!this.currToken) {
  41590. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  41591. }
  41592. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  41593. this.splitWord(false, function (first, length) {
  41594. pseudoStr += first;
  41595. _this4.newNode(new _pseudo["default"]({
  41596. value: pseudoStr,
  41597. source: getTokenSourceSpan(startingToken, _this4.currToken),
  41598. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  41599. }));
  41600. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41601. _this4.error('Misplaced parenthesis.', {
  41602. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  41603. });
  41604. }
  41605. });
  41606. } else {
  41607. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  41608. }
  41609. };
  41610. _proto.space = function space() {
  41611. var content = this.content();
  41612. // Handle space before and after the selector
  41613. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  41614. return node.type === 'comment';
  41615. })) {
  41616. this.spaces = this.optionalSpace(content);
  41617. this.position++;
  41618. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41619. this.current.last.spaces.after = this.optionalSpace(content);
  41620. this.position++;
  41621. } else {
  41622. this.combinator();
  41623. }
  41624. };
  41625. _proto.string = function string() {
  41626. var current = this.currToken;
  41627. this.newNode(new _string["default"]({
  41628. value: this.content(),
  41629. source: getTokenSource(current),
  41630. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41631. }));
  41632. this.position++;
  41633. };
  41634. _proto.universal = function universal(namespace) {
  41635. var nextToken = this.nextToken;
  41636. if (nextToken && this.content(nextToken) === '|') {
  41637. this.position++;
  41638. return this.namespace();
  41639. }
  41640. var current = this.currToken;
  41641. this.newNode(new _universal["default"]({
  41642. value: this.content(),
  41643. source: getTokenSource(current),
  41644. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41645. }), namespace);
  41646. this.position++;
  41647. };
  41648. _proto.splitWord = function splitWord(namespace, firstCallback) {
  41649. var _this5 = this;
  41650. var nextToken = this.nextToken;
  41651. var word = this.content();
  41652. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  41653. this.position++;
  41654. var current = this.content();
  41655. word += current;
  41656. if (current.lastIndexOf('\\') === current.length - 1) {
  41657. var next = this.nextToken;
  41658. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  41659. word += this.requiredSpace(this.content(next));
  41660. this.position++;
  41661. }
  41662. }
  41663. nextToken = this.nextToken;
  41664. }
  41665. var hasClass = indexesOf(word, '.').filter(function (i) {
  41666. // Allow escaped dot within class name
  41667. var escapedDot = word[i - 1] === '\\';
  41668. // Allow decimal numbers percent in @keyframes
  41669. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  41670. return !escapedDot && !isKeyframesPercent;
  41671. });
  41672. var hasId = indexesOf(word, '#').filter(function (i) {
  41673. return word[i - 1] !== '\\';
  41674. });
  41675. // Eliminate Sass interpolations from the list of id indexes
  41676. var interpolations = indexesOf(word, '#{');
  41677. if (interpolations.length) {
  41678. hasId = hasId.filter(function (hashIndex) {
  41679. return !~interpolations.indexOf(hashIndex);
  41680. });
  41681. }
  41682. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  41683. indices.forEach(function (ind, i) {
  41684. var index = indices[i + 1] || word.length;
  41685. var value = word.slice(ind, index);
  41686. if (i === 0 && firstCallback) {
  41687. return firstCallback.call(_this5, value, indices.length);
  41688. }
  41689. var node;
  41690. var current = _this5.currToken;
  41691. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  41692. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  41693. if (~hasClass.indexOf(ind)) {
  41694. var classNameOpts = {
  41695. value: value.slice(1),
  41696. source: source,
  41697. sourceIndex: sourceIndex
  41698. };
  41699. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  41700. } else if (~hasId.indexOf(ind)) {
  41701. var idOpts = {
  41702. value: value.slice(1),
  41703. source: source,
  41704. sourceIndex: sourceIndex
  41705. };
  41706. node = new _id["default"](unescapeProp(idOpts, "value"));
  41707. } else {
  41708. var tagOpts = {
  41709. value: value,
  41710. source: source,
  41711. sourceIndex: sourceIndex
  41712. };
  41713. unescapeProp(tagOpts, "value");
  41714. node = new _tag["default"](tagOpts);
  41715. }
  41716. _this5.newNode(node, namespace);
  41717. // Ensure that the namespace is used only once
  41718. namespace = null;
  41719. });
  41720. this.position++;
  41721. };
  41722. _proto.word = function word(namespace) {
  41723. var nextToken = this.nextToken;
  41724. if (nextToken && this.content(nextToken) === '|') {
  41725. this.position++;
  41726. return this.namespace();
  41727. }
  41728. return this.splitWord(namespace);
  41729. };
  41730. _proto.loop = function loop() {
  41731. while (this.position < this.tokens.length) {
  41732. this.parse(true);
  41733. }
  41734. this.current._inferEndPosition();
  41735. return this.root;
  41736. };
  41737. _proto.parse = function parse(throwOnParenthesis) {
  41738. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  41739. case tokens.space:
  41740. this.space();
  41741. break;
  41742. case tokens.comment:
  41743. this.comment();
  41744. break;
  41745. case tokens.openParenthesis:
  41746. this.parentheses();
  41747. break;
  41748. case tokens.closeParenthesis:
  41749. if (throwOnParenthesis) {
  41750. this.missingParenthesis();
  41751. }
  41752. break;
  41753. case tokens.openSquare:
  41754. this.attribute();
  41755. break;
  41756. case tokens.dollar:
  41757. case tokens.caret:
  41758. case tokens.equals:
  41759. case tokens.word:
  41760. this.word();
  41761. break;
  41762. case tokens.colon:
  41763. this.pseudo();
  41764. break;
  41765. case tokens.comma:
  41766. this.comma();
  41767. break;
  41768. case tokens.asterisk:
  41769. this.universal();
  41770. break;
  41771. case tokens.ampersand:
  41772. this.nesting();
  41773. break;
  41774. case tokens.slash:
  41775. case tokens.combinator:
  41776. this.combinator();
  41777. break;
  41778. case tokens.str:
  41779. this.string();
  41780. break;
  41781. // These cases throw; no break needed.
  41782. case tokens.closeSquare:
  41783. this.missingSquareBracket();
  41784. case tokens.semicolon:
  41785. this.missingBackslash();
  41786. default:
  41787. this.unexpected();
  41788. }
  41789. }
  41790. /**
  41791. * Helpers
  41792. */;
  41793. _proto.expected = function expected(description, index, found) {
  41794. if (Array.isArray(description)) {
  41795. var last = description.pop();
  41796. description = description.join(', ') + " or " + last;
  41797. }
  41798. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  41799. if (!found) {
  41800. return this.error("Expected " + an + " " + description + ".", {
  41801. index: index
  41802. });
  41803. }
  41804. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  41805. index: index
  41806. });
  41807. };
  41808. _proto.requiredSpace = function requiredSpace(space) {
  41809. return this.options.lossy ? ' ' : space;
  41810. };
  41811. _proto.optionalSpace = function optionalSpace(space) {
  41812. return this.options.lossy ? '' : space;
  41813. };
  41814. _proto.lossySpace = function lossySpace(space, required) {
  41815. if (this.options.lossy) {
  41816. return required ? ' ' : '';
  41817. } else {
  41818. return space;
  41819. }
  41820. };
  41821. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  41822. var content = this.content(token);
  41823. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  41824. return this.requiredSpace(content);
  41825. } else {
  41826. return content;
  41827. }
  41828. };
  41829. _proto.newNode = function newNode(node, namespace) {
  41830. if (namespace) {
  41831. if (/^ +$/.test(namespace)) {
  41832. if (!this.options.lossy) {
  41833. this.spaces = (this.spaces || '') + namespace;
  41834. }
  41835. namespace = true;
  41836. }
  41837. node.namespace = namespace;
  41838. unescapeProp(node, "namespace");
  41839. }
  41840. if (this.spaces) {
  41841. node.spaces.before = this.spaces;
  41842. this.spaces = '';
  41843. }
  41844. return this.current.append(node);
  41845. };
  41846. _proto.content = function content(token) {
  41847. if (token === void 0) {
  41848. token = this.currToken;
  41849. }
  41850. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  41851. };
  41852. /**
  41853. * returns the index of the next non-whitespace, non-comment token.
  41854. * returns -1 if no meaningful token is found.
  41855. */
  41856. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  41857. if (startPosition === void 0) {
  41858. startPosition = this.position + 1;
  41859. }
  41860. var searchPosition = startPosition;
  41861. while (searchPosition < this.tokens.length) {
  41862. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  41863. searchPosition++;
  41864. continue;
  41865. } else {
  41866. return searchPosition;
  41867. }
  41868. }
  41869. return -1;
  41870. };
  41871. _createClass(Parser, [{
  41872. key: "currToken",
  41873. get: function get() {
  41874. return this.tokens[this.position];
  41875. }
  41876. }, {
  41877. key: "nextToken",
  41878. get: function get() {
  41879. return this.tokens[this.position + 1];
  41880. }
  41881. }, {
  41882. key: "prevToken",
  41883. get: function get() {
  41884. return this.tokens[this.position - 1];
  41885. }
  41886. }]);
  41887. return Parser;
  41888. }();
  41889. exports["default"] = Parser;
  41890. module.exports = exports.default;
  41891. } (parser, parser.exports));
  41892. return parser.exports;
  41893. }
  41894. var hasRequiredProcessor;
  41895. function requireProcessor () {
  41896. if (hasRequiredProcessor) return processor.exports;
  41897. hasRequiredProcessor = 1;
  41898. (function (module, exports) {
  41899. exports.__esModule = true;
  41900. exports["default"] = void 0;
  41901. var _parser = _interopRequireDefault(/*@__PURE__*/ requireParser());
  41902. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  41903. var Processor = /*#__PURE__*/function () {
  41904. function Processor(func, options) {
  41905. this.func = func || function noop() {};
  41906. this.funcRes = null;
  41907. this.options = options;
  41908. }
  41909. var _proto = Processor.prototype;
  41910. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  41911. if (options === void 0) {
  41912. options = {};
  41913. }
  41914. var merged = Object.assign({}, this.options, options);
  41915. if (merged.updateSelector === false) {
  41916. return false;
  41917. } else {
  41918. return typeof rule !== "string";
  41919. }
  41920. };
  41921. _proto._isLossy = function _isLossy(options) {
  41922. if (options === void 0) {
  41923. options = {};
  41924. }
  41925. var merged = Object.assign({}, this.options, options);
  41926. if (merged.lossless === false) {
  41927. return true;
  41928. } else {
  41929. return false;
  41930. }
  41931. };
  41932. _proto._root = function _root(rule, options) {
  41933. if (options === void 0) {
  41934. options = {};
  41935. }
  41936. var parser = new _parser["default"](rule, this._parseOptions(options));
  41937. return parser.root;
  41938. };
  41939. _proto._parseOptions = function _parseOptions(options) {
  41940. return {
  41941. lossy: this._isLossy(options)
  41942. };
  41943. };
  41944. _proto._run = function _run(rule, options) {
  41945. var _this = this;
  41946. if (options === void 0) {
  41947. options = {};
  41948. }
  41949. return new Promise(function (resolve, reject) {
  41950. try {
  41951. var root = _this._root(rule, options);
  41952. Promise.resolve(_this.func(root)).then(function (transform) {
  41953. var string = undefined;
  41954. if (_this._shouldUpdateSelector(rule, options)) {
  41955. string = root.toString();
  41956. rule.selector = string;
  41957. }
  41958. return {
  41959. transform: transform,
  41960. root: root,
  41961. string: string
  41962. };
  41963. }).then(resolve, reject);
  41964. } catch (e) {
  41965. reject(e);
  41966. return;
  41967. }
  41968. });
  41969. };
  41970. _proto._runSync = function _runSync(rule, options) {
  41971. if (options === void 0) {
  41972. options = {};
  41973. }
  41974. var root = this._root(rule, options);
  41975. var transform = this.func(root);
  41976. if (transform && typeof transform.then === "function") {
  41977. throw new Error("Selector processor returned a promise to a synchronous call.");
  41978. }
  41979. var string = undefined;
  41980. if (options.updateSelector && typeof rule !== "string") {
  41981. string = root.toString();
  41982. rule.selector = string;
  41983. }
  41984. return {
  41985. transform: transform,
  41986. root: root,
  41987. string: string
  41988. };
  41989. }
  41990. /**
  41991. * Process rule into a selector AST.
  41992. *
  41993. * @param rule {postcss.Rule | string} The css selector to be processed
  41994. * @param options The options for processing
  41995. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  41996. */;
  41997. _proto.ast = function ast(rule, options) {
  41998. return this._run(rule, options).then(function (result) {
  41999. return result.root;
  42000. });
  42001. }
  42002. /**
  42003. * Process rule into a selector AST synchronously.
  42004. *
  42005. * @param rule {postcss.Rule | string} The css selector to be processed
  42006. * @param options The options for processing
  42007. * @returns {parser.Root} The AST of the selector after processing it.
  42008. */;
  42009. _proto.astSync = function astSync(rule, options) {
  42010. return this._runSync(rule, options).root;
  42011. }
  42012. /**
  42013. * Process a selector into a transformed value asynchronously
  42014. *
  42015. * @param rule {postcss.Rule | string} The css selector to be processed
  42016. * @param options The options for processing
  42017. * @returns {Promise<any>} The value returned by the processor.
  42018. */;
  42019. _proto.transform = function transform(rule, options) {
  42020. return this._run(rule, options).then(function (result) {
  42021. return result.transform;
  42022. });
  42023. }
  42024. /**
  42025. * Process a selector into a transformed value synchronously.
  42026. *
  42027. * @param rule {postcss.Rule | string} The css selector to be processed
  42028. * @param options The options for processing
  42029. * @returns {any} The value returned by the processor.
  42030. */;
  42031. _proto.transformSync = function transformSync(rule, options) {
  42032. return this._runSync(rule, options).transform;
  42033. }
  42034. /**
  42035. * Process a selector into a new selector string asynchronously.
  42036. *
  42037. * @param rule {postcss.Rule | string} The css selector to be processed
  42038. * @param options The options for processing
  42039. * @returns {string} the selector after processing.
  42040. */;
  42041. _proto.process = function process(rule, options) {
  42042. return this._run(rule, options).then(function (result) {
  42043. return result.string || result.root.toString();
  42044. });
  42045. }
  42046. /**
  42047. * Process a selector into a new selector string synchronously.
  42048. *
  42049. * @param rule {postcss.Rule | string} The css selector to be processed
  42050. * @param options The options for processing
  42051. * @returns {string} the selector after processing.
  42052. */;
  42053. _proto.processSync = function processSync(rule, options) {
  42054. var result = this._runSync(rule, options);
  42055. return result.string || result.root.toString();
  42056. };
  42057. return Processor;
  42058. }();
  42059. exports["default"] = Processor;
  42060. module.exports = exports.default;
  42061. } (processor, processor.exports));
  42062. return processor.exports;
  42063. }
  42064. var selectors = {};
  42065. var constructors = {};
  42066. var hasRequiredConstructors;
  42067. function requireConstructors () {
  42068. if (hasRequiredConstructors) return constructors;
  42069. hasRequiredConstructors = 1;
  42070. constructors.__esModule = true;
  42071. 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;
  42072. var _attribute = _interopRequireDefault(/*@__PURE__*/ requireAttribute());
  42073. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  42074. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  42075. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  42076. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  42077. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  42078. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  42079. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  42080. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  42081. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  42082. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  42083. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  42084. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  42085. var attribute = function attribute(opts) {
  42086. return new _attribute["default"](opts);
  42087. };
  42088. constructors.attribute = attribute;
  42089. var className = function className(opts) {
  42090. return new _className["default"](opts);
  42091. };
  42092. constructors.className = className;
  42093. var combinator = function combinator(opts) {
  42094. return new _combinator["default"](opts);
  42095. };
  42096. constructors.combinator = combinator;
  42097. var comment = function comment(opts) {
  42098. return new _comment["default"](opts);
  42099. };
  42100. constructors.comment = comment;
  42101. var id = function id(opts) {
  42102. return new _id["default"](opts);
  42103. };
  42104. constructors.id = id;
  42105. var nesting = function nesting(opts) {
  42106. return new _nesting["default"](opts);
  42107. };
  42108. constructors.nesting = nesting;
  42109. var pseudo = function pseudo(opts) {
  42110. return new _pseudo["default"](opts);
  42111. };
  42112. constructors.pseudo = pseudo;
  42113. var root = function root(opts) {
  42114. return new _root["default"](opts);
  42115. };
  42116. constructors.root = root;
  42117. var selector = function selector(opts) {
  42118. return new _selector["default"](opts);
  42119. };
  42120. constructors.selector = selector;
  42121. var string = function string(opts) {
  42122. return new _string["default"](opts);
  42123. };
  42124. constructors.string = string;
  42125. var tag = function tag(opts) {
  42126. return new _tag["default"](opts);
  42127. };
  42128. constructors.tag = tag;
  42129. var universal = function universal(opts) {
  42130. return new _universal["default"](opts);
  42131. };
  42132. constructors.universal = universal;
  42133. return constructors;
  42134. }
  42135. var guards = {};
  42136. var hasRequiredGuards;
  42137. function requireGuards () {
  42138. if (hasRequiredGuards) return guards;
  42139. hasRequiredGuards = 1;
  42140. guards.__esModule = true;
  42141. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  42142. guards.isContainer = isContainer;
  42143. guards.isIdentifier = void 0;
  42144. guards.isNamespace = isNamespace;
  42145. guards.isNesting = void 0;
  42146. guards.isNode = isNode;
  42147. guards.isPseudo = void 0;
  42148. guards.isPseudoClass = isPseudoClass;
  42149. guards.isPseudoElement = isPseudoElement;
  42150. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  42151. var _types = /*@__PURE__*/ requireTypes();
  42152. var _IS_TYPE;
  42153. 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);
  42154. function isNode(node) {
  42155. return typeof node === "object" && IS_TYPE[node.type];
  42156. }
  42157. function isNodeType(type, node) {
  42158. return isNode(node) && node.type === type;
  42159. }
  42160. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  42161. guards.isAttribute = isAttribute;
  42162. var isClassName = isNodeType.bind(null, _types.CLASS);
  42163. guards.isClassName = isClassName;
  42164. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  42165. guards.isCombinator = isCombinator;
  42166. var isComment = isNodeType.bind(null, _types.COMMENT);
  42167. guards.isComment = isComment;
  42168. var isIdentifier = isNodeType.bind(null, _types.ID);
  42169. guards.isIdentifier = isIdentifier;
  42170. var isNesting = isNodeType.bind(null, _types.NESTING);
  42171. guards.isNesting = isNesting;
  42172. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  42173. guards.isPseudo = isPseudo;
  42174. var isRoot = isNodeType.bind(null, _types.ROOT);
  42175. guards.isRoot = isRoot;
  42176. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  42177. guards.isSelector = isSelector;
  42178. var isString = isNodeType.bind(null, _types.STRING);
  42179. guards.isString = isString;
  42180. var isTag = isNodeType.bind(null, _types.TAG);
  42181. guards.isTag = isTag;
  42182. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  42183. guards.isUniversal = isUniversal;
  42184. function isPseudoElement(node) {
  42185. 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");
  42186. }
  42187. function isPseudoClass(node) {
  42188. return isPseudo(node) && !isPseudoElement(node);
  42189. }
  42190. function isContainer(node) {
  42191. return !!(isNode(node) && node.walk);
  42192. }
  42193. function isNamespace(node) {
  42194. return isAttribute(node) || isTag(node);
  42195. }
  42196. return guards;
  42197. }
  42198. var hasRequiredSelectors;
  42199. function requireSelectors () {
  42200. if (hasRequiredSelectors) return selectors;
  42201. hasRequiredSelectors = 1;
  42202. (function (exports) {
  42203. exports.__esModule = true;
  42204. var _types = /*@__PURE__*/ requireTypes();
  42205. Object.keys(_types).forEach(function (key) {
  42206. if (key === "default" || key === "__esModule") return;
  42207. if (key in exports && exports[key] === _types[key]) return;
  42208. exports[key] = _types[key];
  42209. });
  42210. var _constructors = /*@__PURE__*/ requireConstructors();
  42211. Object.keys(_constructors).forEach(function (key) {
  42212. if (key === "default" || key === "__esModule") return;
  42213. if (key in exports && exports[key] === _constructors[key]) return;
  42214. exports[key] = _constructors[key];
  42215. });
  42216. var _guards = /*@__PURE__*/ requireGuards();
  42217. Object.keys(_guards).forEach(function (key) {
  42218. if (key === "default" || key === "__esModule") return;
  42219. if (key in exports && exports[key] === _guards[key]) return;
  42220. exports[key] = _guards[key];
  42221. });
  42222. } (selectors));
  42223. return selectors;
  42224. }
  42225. var hasRequiredDist;
  42226. function requireDist () {
  42227. if (hasRequiredDist) return dist.exports;
  42228. hasRequiredDist = 1;
  42229. (function (module, exports) {
  42230. exports.__esModule = true;
  42231. exports["default"] = void 0;
  42232. var _processor = _interopRequireDefault(/*@__PURE__*/ requireProcessor());
  42233. var selectors = _interopRequireWildcard(/*@__PURE__*/ requireSelectors());
  42234. 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); }
  42235. function _interopRequireWildcard(obj, nodeInterop) { if (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; }
  42236. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  42237. var parser = function parser(processor) {
  42238. return new _processor["default"](processor);
  42239. };
  42240. Object.assign(parser, selectors);
  42241. delete parser.__esModule;
  42242. var _default = parser;
  42243. exports["default"] = _default;
  42244. module.exports = exports.default;
  42245. } (dist, dist.exports));
  42246. return dist.exports;
  42247. }
  42248. var distExports = /*@__PURE__*/ requireDist();
  42249. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  42250. const animationNameRE = /^(-\w+-)?animation-name$/;
  42251. const animationRE = /^(-\w+-)?animation$/;
  42252. const scopedPlugin = (id = "") => {
  42253. const keyframes = /* @__PURE__ */ Object.create(null);
  42254. const shortId = id.replace(/^data-v-/, "");
  42255. return {
  42256. postcssPlugin: "vue-sfc-scoped",
  42257. Rule(rule) {
  42258. processRule(id, rule);
  42259. },
  42260. AtRule(node) {
  42261. if (/-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  42262. keyframes[node.params] = node.params = node.params + "-" + shortId;
  42263. }
  42264. },
  42265. OnceExit(root) {
  42266. if (Object.keys(keyframes).length) {
  42267. root.walkDecls((decl) => {
  42268. if (animationNameRE.test(decl.prop)) {
  42269. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  42270. }
  42271. if (animationRE.test(decl.prop)) {
  42272. decl.value = decl.value.split(",").map((v) => {
  42273. const vals = v.trim().split(/\s+/);
  42274. const i = vals.findIndex((val) => keyframes[val]);
  42275. if (i !== -1) {
  42276. vals.splice(i, 1, keyframes[vals[i]]);
  42277. return vals.join(" ");
  42278. } else {
  42279. return v;
  42280. }
  42281. }).join(",");
  42282. }
  42283. });
  42284. }
  42285. }
  42286. };
  42287. };
  42288. const processedRules = /* @__PURE__ */ new WeakSet();
  42289. function processRule(id, rule) {
  42290. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && /-?keyframes$/.test(rule.parent.name)) {
  42291. return;
  42292. }
  42293. processedRules.add(rule);
  42294. let deep = false;
  42295. let parent = rule.parent;
  42296. while (parent && parent.type !== "root") {
  42297. if (parent.__deep) {
  42298. deep = true;
  42299. break;
  42300. }
  42301. parent = parent.parent;
  42302. }
  42303. rule.selector = selectorParser((selectorRoot) => {
  42304. selectorRoot.each((selector) => {
  42305. rewriteSelector(id, rule, selector, selectorRoot, deep);
  42306. });
  42307. }).processSync(rule.selector);
  42308. }
  42309. function rewriteSelector(id, rule, selector, selectorRoot, deep, slotted = false) {
  42310. let node = null;
  42311. let shouldInject = !deep;
  42312. selector.each((n) => {
  42313. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  42314. n.value = " ";
  42315. n.spaces.before = n.spaces.after = "";
  42316. warn(
  42317. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  42318. );
  42319. return false;
  42320. }
  42321. if (n.type === "pseudo") {
  42322. const { value } = n;
  42323. if (value === ":deep" || value === "::v-deep") {
  42324. rule.__deep = true;
  42325. if (n.nodes.length) {
  42326. let last = n;
  42327. n.nodes[0].each((ss) => {
  42328. selector.insertAfter(last, ss);
  42329. last = ss;
  42330. });
  42331. const prev = selector.at(selector.index(n) - 1);
  42332. if (!prev || !isSpaceCombinator(prev)) {
  42333. selector.insertAfter(
  42334. n,
  42335. selectorParser.combinator({
  42336. value: " "
  42337. })
  42338. );
  42339. }
  42340. selector.removeChild(n);
  42341. } else {
  42342. warn(
  42343. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  42344. );
  42345. const prev = selector.at(selector.index(n) - 1);
  42346. if (prev && isSpaceCombinator(prev)) {
  42347. selector.removeChild(prev);
  42348. }
  42349. selector.removeChild(n);
  42350. }
  42351. return false;
  42352. }
  42353. if (value === ":slotted" || value === "::v-slotted") {
  42354. rewriteSelector(
  42355. id,
  42356. rule,
  42357. n.nodes[0],
  42358. selectorRoot,
  42359. deep,
  42360. true
  42361. );
  42362. let last = n;
  42363. n.nodes[0].each((ss) => {
  42364. selector.insertAfter(last, ss);
  42365. last = ss;
  42366. });
  42367. selector.removeChild(n);
  42368. shouldInject = false;
  42369. return false;
  42370. }
  42371. if (value === ":global" || value === "::v-global") {
  42372. selector.replaceWith(n.nodes[0]);
  42373. return false;
  42374. }
  42375. }
  42376. if (n.type === "universal") {
  42377. const prev = selector.at(selector.index(n) - 1);
  42378. const next = selector.at(selector.index(n) + 1);
  42379. if (!prev) {
  42380. if (next) {
  42381. if (next.type === "combinator" && next.value === " ") {
  42382. selector.removeChild(next);
  42383. }
  42384. selector.removeChild(n);
  42385. return;
  42386. } else {
  42387. node = selectorParser.combinator({
  42388. value: ""
  42389. });
  42390. selector.insertBefore(n, node);
  42391. selector.removeChild(n);
  42392. return false;
  42393. }
  42394. }
  42395. if (node) return;
  42396. }
  42397. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
  42398. node = n;
  42399. }
  42400. });
  42401. if (rule.nodes.some((node2) => node2.type === "rule")) {
  42402. const deep2 = rule.__deep;
  42403. if (!deep2) {
  42404. extractAndWrapNodes(rule);
  42405. const atruleNodes = rule.nodes.filter((node2) => node2.type === "atrule");
  42406. for (const atnode of atruleNodes) {
  42407. extractAndWrapNodes(atnode);
  42408. }
  42409. }
  42410. shouldInject = deep2;
  42411. }
  42412. if (node) {
  42413. const { type, value } = node;
  42414. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  42415. node.nodes.forEach(
  42416. (value2) => rewriteSelector(id, rule, value2, selectorRoot, deep, slotted)
  42417. );
  42418. shouldInject = false;
  42419. }
  42420. }
  42421. if (node) {
  42422. node.spaces.after = "";
  42423. } else {
  42424. selector.first.spaces.before = "";
  42425. }
  42426. if (shouldInject) {
  42427. const idToAdd = slotted ? id + "-s" : id;
  42428. selector.insertAfter(
  42429. // If node is null it means we need to inject [id] at the start
  42430. // insertAfter can handle `null` here
  42431. node,
  42432. selectorParser.attribute({
  42433. attribute: idToAdd,
  42434. value: idToAdd,
  42435. raws: {},
  42436. quoteMark: `"`
  42437. })
  42438. );
  42439. }
  42440. }
  42441. function isSpaceCombinator(node) {
  42442. return node.type === "combinator" && /^\s+$/.test(node.value);
  42443. }
  42444. function extractAndWrapNodes(parentNode) {
  42445. if (!parentNode.nodes) return;
  42446. const nodes = parentNode.nodes.filter(
  42447. (node) => node.type === "decl" || node.type === "comment"
  42448. );
  42449. if (nodes.length) {
  42450. for (const node of nodes) {
  42451. parentNode.removeChild(node);
  42452. }
  42453. const wrappedRule = new Rule({
  42454. nodes,
  42455. selector: "&"
  42456. });
  42457. parentNode.prepend(wrappedRule);
  42458. }
  42459. }
  42460. scopedPlugin.postcss = true;
  42461. var sourceMap = {};
  42462. var sourceMapGenerator = {};
  42463. var base64Vlq = {};
  42464. var base64 = {};
  42465. /* -*- Mode: js; js-indent-level: 2; -*- */
  42466. var hasRequiredBase64;
  42467. function requireBase64 () {
  42468. if (hasRequiredBase64) return base64;
  42469. hasRequiredBase64 = 1;
  42470. /*
  42471. * Copyright 2011 Mozilla Foundation and contributors
  42472. * Licensed under the New BSD license. See LICENSE or:
  42473. * http://opensource.org/licenses/BSD-3-Clause
  42474. */
  42475. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  42476. /**
  42477. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  42478. */
  42479. base64.encode = function (number) {
  42480. if (0 <= number && number < intToCharMap.length) {
  42481. return intToCharMap[number];
  42482. }
  42483. throw new TypeError("Must be between 0 and 63: " + number);
  42484. };
  42485. /**
  42486. * Decode a single base 64 character code digit to an integer. Returns -1 on
  42487. * failure.
  42488. */
  42489. base64.decode = function (charCode) {
  42490. var bigA = 65; // 'A'
  42491. var bigZ = 90; // 'Z'
  42492. var littleA = 97; // 'a'
  42493. var littleZ = 122; // 'z'
  42494. var zero = 48; // '0'
  42495. var nine = 57; // '9'
  42496. var plus = 43; // '+'
  42497. var slash = 47; // '/'
  42498. var littleOffset = 26;
  42499. var numberOffset = 52;
  42500. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  42501. if (bigA <= charCode && charCode <= bigZ) {
  42502. return (charCode - bigA);
  42503. }
  42504. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  42505. if (littleA <= charCode && charCode <= littleZ) {
  42506. return (charCode - littleA + littleOffset);
  42507. }
  42508. // 52 - 61: 0123456789
  42509. if (zero <= charCode && charCode <= nine) {
  42510. return (charCode - zero + numberOffset);
  42511. }
  42512. // 62: +
  42513. if (charCode == plus) {
  42514. return 62;
  42515. }
  42516. // 63: /
  42517. if (charCode == slash) {
  42518. return 63;
  42519. }
  42520. // Invalid base64 digit.
  42521. return -1;
  42522. };
  42523. return base64;
  42524. }
  42525. /* -*- Mode: js; js-indent-level: 2; -*- */
  42526. var hasRequiredBase64Vlq;
  42527. function requireBase64Vlq () {
  42528. if (hasRequiredBase64Vlq) return base64Vlq;
  42529. hasRequiredBase64Vlq = 1;
  42530. /*
  42531. * Copyright 2011 Mozilla Foundation and contributors
  42532. * Licensed under the New BSD license. See LICENSE or:
  42533. * http://opensource.org/licenses/BSD-3-Clause
  42534. *
  42535. * Based on the Base 64 VLQ implementation in Closure Compiler:
  42536. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  42537. *
  42538. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  42539. * Redistribution and use in source and binary forms, with or without
  42540. * modification, are permitted provided that the following conditions are
  42541. * met:
  42542. *
  42543. * * Redistributions of source code must retain the above copyright
  42544. * notice, this list of conditions and the following disclaimer.
  42545. * * Redistributions in binary form must reproduce the above
  42546. * copyright notice, this list of conditions and the following
  42547. * disclaimer in the documentation and/or other materials provided
  42548. * with the distribution.
  42549. * * Neither the name of Google Inc. nor the names of its
  42550. * contributors may be used to endorse or promote products derived
  42551. * from this software without specific prior written permission.
  42552. *
  42553. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  42554. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  42555. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  42556. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  42557. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42558. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42559. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  42560. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42561. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42562. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  42563. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42564. */
  42565. var base64 = /*@__PURE__*/ requireBase64();
  42566. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  42567. // length quantities we use in the source map spec, the first bit is the sign,
  42568. // the next four bits are the actual value, and the 6th bit is the
  42569. // continuation bit. The continuation bit tells us whether there are more
  42570. // digits in this value following this digit.
  42571. //
  42572. // Continuation
  42573. // | Sign
  42574. // | |
  42575. // V V
  42576. // 101011
  42577. var VLQ_BASE_SHIFT = 5;
  42578. // binary: 100000
  42579. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  42580. // binary: 011111
  42581. var VLQ_BASE_MASK = VLQ_BASE - 1;
  42582. // binary: 100000
  42583. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  42584. /**
  42585. * Converts from a two-complement value to a value where the sign bit is
  42586. * placed in the least significant bit. For example, as decimals:
  42587. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  42588. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  42589. */
  42590. function toVLQSigned(aValue) {
  42591. return aValue < 0
  42592. ? ((-aValue) << 1) + 1
  42593. : (aValue << 1) + 0;
  42594. }
  42595. /**
  42596. * Converts to a two-complement value from a value where the sign bit is
  42597. * placed in the least significant bit. For example, as decimals:
  42598. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  42599. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  42600. */
  42601. function fromVLQSigned(aValue) {
  42602. var isNegative = (aValue & 1) === 1;
  42603. var shifted = aValue >> 1;
  42604. return isNegative
  42605. ? -shifted
  42606. : shifted;
  42607. }
  42608. /**
  42609. * Returns the base 64 VLQ encoded value.
  42610. */
  42611. base64Vlq.encode = function base64VLQ_encode(aValue) {
  42612. var encoded = "";
  42613. var digit;
  42614. var vlq = toVLQSigned(aValue);
  42615. do {
  42616. digit = vlq & VLQ_BASE_MASK;
  42617. vlq >>>= VLQ_BASE_SHIFT;
  42618. if (vlq > 0) {
  42619. // There are still more digits in this value, so we must make sure the
  42620. // continuation bit is marked.
  42621. digit |= VLQ_CONTINUATION_BIT;
  42622. }
  42623. encoded += base64.encode(digit);
  42624. } while (vlq > 0);
  42625. return encoded;
  42626. };
  42627. /**
  42628. * Decodes the next base 64 VLQ value from the given string and returns the
  42629. * value and the rest of the string via the out parameter.
  42630. */
  42631. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  42632. var strLen = aStr.length;
  42633. var result = 0;
  42634. var shift = 0;
  42635. var continuation, digit;
  42636. do {
  42637. if (aIndex >= strLen) {
  42638. throw new Error("Expected more digits in base 64 VLQ value.");
  42639. }
  42640. digit = base64.decode(aStr.charCodeAt(aIndex++));
  42641. if (digit === -1) {
  42642. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  42643. }
  42644. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  42645. digit &= VLQ_BASE_MASK;
  42646. result = result + (digit << shift);
  42647. shift += VLQ_BASE_SHIFT;
  42648. } while (continuation);
  42649. aOutParam.value = fromVLQSigned(result);
  42650. aOutParam.rest = aIndex;
  42651. };
  42652. return base64Vlq;
  42653. }
  42654. var util = {};
  42655. /* -*- Mode: js; js-indent-level: 2; -*- */
  42656. var hasRequiredUtil;
  42657. function requireUtil () {
  42658. if (hasRequiredUtil) return util;
  42659. hasRequiredUtil = 1;
  42660. (function (exports) {
  42661. /*
  42662. * Copyright 2011 Mozilla Foundation and contributors
  42663. * Licensed under the New BSD license. See LICENSE or:
  42664. * http://opensource.org/licenses/BSD-3-Clause
  42665. */
  42666. /**
  42667. * This is a helper function for getting values from parameter/options
  42668. * objects.
  42669. *
  42670. * @param args The object we are extracting values from
  42671. * @param name The name of the property we are getting.
  42672. * @param defaultValue An optional value to return if the property is missing
  42673. * from the object. If this is not specified and the property is missing, an
  42674. * error will be thrown.
  42675. */
  42676. function getArg(aArgs, aName, aDefaultValue) {
  42677. if (aName in aArgs) {
  42678. return aArgs[aName];
  42679. } else if (arguments.length === 3) {
  42680. return aDefaultValue;
  42681. } else {
  42682. throw new Error('"' + aName + '" is a required argument.');
  42683. }
  42684. }
  42685. exports.getArg = getArg;
  42686. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  42687. var dataUrlRegexp = /^data:.+\,.+$/;
  42688. function urlParse(aUrl) {
  42689. var match = aUrl.match(urlRegexp);
  42690. if (!match) {
  42691. return null;
  42692. }
  42693. return {
  42694. scheme: match[1],
  42695. auth: match[2],
  42696. host: match[3],
  42697. port: match[4],
  42698. path: match[5]
  42699. };
  42700. }
  42701. exports.urlParse = urlParse;
  42702. function urlGenerate(aParsedUrl) {
  42703. var url = '';
  42704. if (aParsedUrl.scheme) {
  42705. url += aParsedUrl.scheme + ':';
  42706. }
  42707. url += '//';
  42708. if (aParsedUrl.auth) {
  42709. url += aParsedUrl.auth + '@';
  42710. }
  42711. if (aParsedUrl.host) {
  42712. url += aParsedUrl.host;
  42713. }
  42714. if (aParsedUrl.port) {
  42715. url += ":" + aParsedUrl.port;
  42716. }
  42717. if (aParsedUrl.path) {
  42718. url += aParsedUrl.path;
  42719. }
  42720. return url;
  42721. }
  42722. exports.urlGenerate = urlGenerate;
  42723. /**
  42724. * Normalizes a path, or the path portion of a URL:
  42725. *
  42726. * - Replaces consecutive slashes with one slash.
  42727. * - Removes unnecessary '.' parts.
  42728. * - Removes unnecessary '<dir>/..' parts.
  42729. *
  42730. * Based on code in the Node.js 'path' core module.
  42731. *
  42732. * @param aPath The path or url to normalize.
  42733. */
  42734. function normalize(aPath) {
  42735. var path = aPath;
  42736. var url = urlParse(aPath);
  42737. if (url) {
  42738. if (!url.path) {
  42739. return aPath;
  42740. }
  42741. path = url.path;
  42742. }
  42743. var isAbsolute = exports.isAbsolute(path);
  42744. var parts = path.split(/\/+/);
  42745. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  42746. part = parts[i];
  42747. if (part === '.') {
  42748. parts.splice(i, 1);
  42749. } else if (part === '..') {
  42750. up++;
  42751. } else if (up > 0) {
  42752. if (part === '') {
  42753. // The first part is blank if the path is absolute. Trying to go
  42754. // above the root is a no-op. Therefore we can remove all '..' parts
  42755. // directly after the root.
  42756. parts.splice(i + 1, up);
  42757. up = 0;
  42758. } else {
  42759. parts.splice(i, 2);
  42760. up--;
  42761. }
  42762. }
  42763. }
  42764. path = parts.join('/');
  42765. if (path === '') {
  42766. path = isAbsolute ? '/' : '.';
  42767. }
  42768. if (url) {
  42769. url.path = path;
  42770. return urlGenerate(url);
  42771. }
  42772. return path;
  42773. }
  42774. exports.normalize = normalize;
  42775. /**
  42776. * Joins two paths/URLs.
  42777. *
  42778. * @param aRoot The root path or URL.
  42779. * @param aPath The path or URL to be joined with the root.
  42780. *
  42781. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  42782. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  42783. * first.
  42784. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  42785. * is updated with the result and aRoot is returned. Otherwise the result
  42786. * is returned.
  42787. * - If aPath is absolute, the result is aPath.
  42788. * - Otherwise the two paths are joined with a slash.
  42789. * - Joining for example 'http://' and 'www.example.com' is also supported.
  42790. */
  42791. function join(aRoot, aPath) {
  42792. if (aRoot === "") {
  42793. aRoot = ".";
  42794. }
  42795. if (aPath === "") {
  42796. aPath = ".";
  42797. }
  42798. var aPathUrl = urlParse(aPath);
  42799. var aRootUrl = urlParse(aRoot);
  42800. if (aRootUrl) {
  42801. aRoot = aRootUrl.path || '/';
  42802. }
  42803. // `join(foo, '//www.example.org')`
  42804. if (aPathUrl && !aPathUrl.scheme) {
  42805. if (aRootUrl) {
  42806. aPathUrl.scheme = aRootUrl.scheme;
  42807. }
  42808. return urlGenerate(aPathUrl);
  42809. }
  42810. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  42811. return aPath;
  42812. }
  42813. // `join('http://', 'www.example.com')`
  42814. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  42815. aRootUrl.host = aPath;
  42816. return urlGenerate(aRootUrl);
  42817. }
  42818. var joined = aPath.charAt(0) === '/'
  42819. ? aPath
  42820. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  42821. if (aRootUrl) {
  42822. aRootUrl.path = joined;
  42823. return urlGenerate(aRootUrl);
  42824. }
  42825. return joined;
  42826. }
  42827. exports.join = join;
  42828. exports.isAbsolute = function (aPath) {
  42829. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  42830. };
  42831. /**
  42832. * Make a path relative to a URL or another path.
  42833. *
  42834. * @param aRoot The root path or URL.
  42835. * @param aPath The path or URL to be made relative to aRoot.
  42836. */
  42837. function relative(aRoot, aPath) {
  42838. if (aRoot === "") {
  42839. aRoot = ".";
  42840. }
  42841. aRoot = aRoot.replace(/\/$/, '');
  42842. // It is possible for the path to be above the root. In this case, simply
  42843. // checking whether the root is a prefix of the path won't work. Instead, we
  42844. // need to remove components from the root one by one, until either we find
  42845. // a prefix that fits, or we run out of components to remove.
  42846. var level = 0;
  42847. while (aPath.indexOf(aRoot + '/') !== 0) {
  42848. var index = aRoot.lastIndexOf("/");
  42849. if (index < 0) {
  42850. return aPath;
  42851. }
  42852. // If the only part of the root that is left is the scheme (i.e. http://,
  42853. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  42854. // have exhausted all components, so the path is not relative to the root.
  42855. aRoot = aRoot.slice(0, index);
  42856. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  42857. return aPath;
  42858. }
  42859. ++level;
  42860. }
  42861. // Make sure we add a "../" for each component we removed from the root.
  42862. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  42863. }
  42864. exports.relative = relative;
  42865. var supportsNullProto = (function () {
  42866. var obj = Object.create(null);
  42867. return !('__proto__' in obj);
  42868. }());
  42869. function identity (s) {
  42870. return s;
  42871. }
  42872. /**
  42873. * Because behavior goes wacky when you set `__proto__` on objects, we
  42874. * have to prefix all the strings in our set with an arbitrary character.
  42875. *
  42876. * See https://github.com/mozilla/source-map/pull/31 and
  42877. * https://github.com/mozilla/source-map/issues/30
  42878. *
  42879. * @param String aStr
  42880. */
  42881. function toSetString(aStr) {
  42882. if (isProtoString(aStr)) {
  42883. return '$' + aStr;
  42884. }
  42885. return aStr;
  42886. }
  42887. exports.toSetString = supportsNullProto ? identity : toSetString;
  42888. function fromSetString(aStr) {
  42889. if (isProtoString(aStr)) {
  42890. return aStr.slice(1);
  42891. }
  42892. return aStr;
  42893. }
  42894. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  42895. function isProtoString(s) {
  42896. if (!s) {
  42897. return false;
  42898. }
  42899. var length = s.length;
  42900. if (length < 9 /* "__proto__".length */) {
  42901. return false;
  42902. }
  42903. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  42904. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  42905. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  42906. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  42907. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  42908. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  42909. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  42910. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  42911. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  42912. return false;
  42913. }
  42914. for (var i = length - 10; i >= 0; i--) {
  42915. if (s.charCodeAt(i) !== 36 /* '$' */) {
  42916. return false;
  42917. }
  42918. }
  42919. return true;
  42920. }
  42921. /**
  42922. * Comparator between two mappings where the original positions are compared.
  42923. *
  42924. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  42925. * mappings with the same original source/line/column, but different generated
  42926. * line and column the same. Useful when searching for a mapping with a
  42927. * stubbed out mapping.
  42928. */
  42929. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  42930. var cmp = strcmp(mappingA.source, mappingB.source);
  42931. if (cmp !== 0) {
  42932. return cmp;
  42933. }
  42934. cmp = mappingA.originalLine - mappingB.originalLine;
  42935. if (cmp !== 0) {
  42936. return cmp;
  42937. }
  42938. cmp = mappingA.originalColumn - mappingB.originalColumn;
  42939. if (cmp !== 0 || onlyCompareOriginal) {
  42940. return cmp;
  42941. }
  42942. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  42943. if (cmp !== 0) {
  42944. return cmp;
  42945. }
  42946. cmp = mappingA.generatedLine - mappingB.generatedLine;
  42947. if (cmp !== 0) {
  42948. return cmp;
  42949. }
  42950. return strcmp(mappingA.name, mappingB.name);
  42951. }
  42952. exports.compareByOriginalPositions = compareByOriginalPositions;
  42953. /**
  42954. * Comparator between two mappings with deflated source and name indices where
  42955. * the generated positions are compared.
  42956. *
  42957. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  42958. * mappings with the same generated line and column, but different
  42959. * source/name/original line and column the same. Useful when searching for a
  42960. * mapping with a stubbed out mapping.
  42961. */
  42962. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  42963. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  42964. if (cmp !== 0) {
  42965. return cmp;
  42966. }
  42967. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  42968. if (cmp !== 0 || onlyCompareGenerated) {
  42969. return cmp;
  42970. }
  42971. cmp = strcmp(mappingA.source, mappingB.source);
  42972. if (cmp !== 0) {
  42973. return cmp;
  42974. }
  42975. cmp = mappingA.originalLine - mappingB.originalLine;
  42976. if (cmp !== 0) {
  42977. return cmp;
  42978. }
  42979. cmp = mappingA.originalColumn - mappingB.originalColumn;
  42980. if (cmp !== 0) {
  42981. return cmp;
  42982. }
  42983. return strcmp(mappingA.name, mappingB.name);
  42984. }
  42985. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  42986. function strcmp(aStr1, aStr2) {
  42987. if (aStr1 === aStr2) {
  42988. return 0;
  42989. }
  42990. if (aStr1 === null) {
  42991. return 1; // aStr2 !== null
  42992. }
  42993. if (aStr2 === null) {
  42994. return -1; // aStr1 !== null
  42995. }
  42996. if (aStr1 > aStr2) {
  42997. return 1;
  42998. }
  42999. return -1;
  43000. }
  43001. /**
  43002. * Comparator between two mappings with inflated source and name strings where
  43003. * the generated positions are compared.
  43004. */
  43005. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  43006. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  43007. if (cmp !== 0) {
  43008. return cmp;
  43009. }
  43010. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  43011. if (cmp !== 0) {
  43012. return cmp;
  43013. }
  43014. cmp = strcmp(mappingA.source, mappingB.source);
  43015. if (cmp !== 0) {
  43016. return cmp;
  43017. }
  43018. cmp = mappingA.originalLine - mappingB.originalLine;
  43019. if (cmp !== 0) {
  43020. return cmp;
  43021. }
  43022. cmp = mappingA.originalColumn - mappingB.originalColumn;
  43023. if (cmp !== 0) {
  43024. return cmp;
  43025. }
  43026. return strcmp(mappingA.name, mappingB.name);
  43027. }
  43028. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  43029. /**
  43030. * Strip any JSON XSSI avoidance prefix from the string (as documented
  43031. * in the source maps specification), and then parse the string as
  43032. * JSON.
  43033. */
  43034. function parseSourceMapInput(str) {
  43035. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  43036. }
  43037. exports.parseSourceMapInput = parseSourceMapInput;
  43038. /**
  43039. * Compute the URL of a source given the the source root, the source's
  43040. * URL, and the source map's URL.
  43041. */
  43042. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  43043. sourceURL = sourceURL || '';
  43044. if (sourceRoot) {
  43045. // This follows what Chrome does.
  43046. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  43047. sourceRoot += '/';
  43048. }
  43049. // The spec says:
  43050. // Line 4: An optional source root, useful for relocating source
  43051. // files on a server or removing repeated values in the
  43052. // “sources” entry. This value is prepended to the individual
  43053. // entries in the “source” field.
  43054. sourceURL = sourceRoot + sourceURL;
  43055. }
  43056. // Historically, SourceMapConsumer did not take the sourceMapURL as
  43057. // a parameter. This mode is still somewhat supported, which is why
  43058. // this code block is conditional. However, it's preferable to pass
  43059. // the source map URL to SourceMapConsumer, so that this function
  43060. // can implement the source URL resolution algorithm as outlined in
  43061. // the spec. This block is basically the equivalent of:
  43062. // new URL(sourceURL, sourceMapURL).toString()
  43063. // ... except it avoids using URL, which wasn't available in the
  43064. // older releases of node still supported by this library.
  43065. //
  43066. // The spec says:
  43067. // If the sources are not absolute URLs after prepending of the
  43068. // “sourceRoot”, the sources are resolved relative to the
  43069. // SourceMap (like resolving script src in a html document).
  43070. if (sourceMapURL) {
  43071. var parsed = urlParse(sourceMapURL);
  43072. if (!parsed) {
  43073. throw new Error("sourceMapURL could not be parsed");
  43074. }
  43075. if (parsed.path) {
  43076. // Strip the last path component, but keep the "/".
  43077. var index = parsed.path.lastIndexOf('/');
  43078. if (index >= 0) {
  43079. parsed.path = parsed.path.substring(0, index + 1);
  43080. }
  43081. }
  43082. sourceURL = join(urlGenerate(parsed), sourceURL);
  43083. }
  43084. return normalize(sourceURL);
  43085. }
  43086. exports.computeSourceURL = computeSourceURL;
  43087. } (util));
  43088. return util;
  43089. }
  43090. var arraySet = {};
  43091. /* -*- Mode: js; js-indent-level: 2; -*- */
  43092. var hasRequiredArraySet;
  43093. function requireArraySet () {
  43094. if (hasRequiredArraySet) return arraySet;
  43095. hasRequiredArraySet = 1;
  43096. /*
  43097. * Copyright 2011 Mozilla Foundation and contributors
  43098. * Licensed under the New BSD license. See LICENSE or:
  43099. * http://opensource.org/licenses/BSD-3-Clause
  43100. */
  43101. var util = /*@__PURE__*/ requireUtil();
  43102. var has = Object.prototype.hasOwnProperty;
  43103. var hasNativeMap = typeof Map !== "undefined";
  43104. /**
  43105. * A data structure which is a combination of an array and a set. Adding a new
  43106. * member is O(1), testing for membership is O(1), and finding the index of an
  43107. * element is O(1). Removing elements from the set is not supported. Only
  43108. * strings are supported for membership.
  43109. */
  43110. function ArraySet() {
  43111. this._array = [];
  43112. this._set = hasNativeMap ? new Map() : Object.create(null);
  43113. }
  43114. /**
  43115. * Static method for creating ArraySet instances from an existing array.
  43116. */
  43117. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  43118. var set = new ArraySet();
  43119. for (var i = 0, len = aArray.length; i < len; i++) {
  43120. set.add(aArray[i], aAllowDuplicates);
  43121. }
  43122. return set;
  43123. };
  43124. /**
  43125. * Return how many unique items are in this ArraySet. If duplicates have been
  43126. * added, than those do not count towards the size.
  43127. *
  43128. * @returns Number
  43129. */
  43130. ArraySet.prototype.size = function ArraySet_size() {
  43131. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  43132. };
  43133. /**
  43134. * Add the given string to this set.
  43135. *
  43136. * @param String aStr
  43137. */
  43138. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  43139. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  43140. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  43141. var idx = this._array.length;
  43142. if (!isDuplicate || aAllowDuplicates) {
  43143. this._array.push(aStr);
  43144. }
  43145. if (!isDuplicate) {
  43146. if (hasNativeMap) {
  43147. this._set.set(aStr, idx);
  43148. } else {
  43149. this._set[sStr] = idx;
  43150. }
  43151. }
  43152. };
  43153. /**
  43154. * Is the given string a member of this set?
  43155. *
  43156. * @param String aStr
  43157. */
  43158. ArraySet.prototype.has = function ArraySet_has(aStr) {
  43159. if (hasNativeMap) {
  43160. return this._set.has(aStr);
  43161. } else {
  43162. var sStr = util.toSetString(aStr);
  43163. return has.call(this._set, sStr);
  43164. }
  43165. };
  43166. /**
  43167. * What is the index of the given string in the array?
  43168. *
  43169. * @param String aStr
  43170. */
  43171. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  43172. if (hasNativeMap) {
  43173. var idx = this._set.get(aStr);
  43174. if (idx >= 0) {
  43175. return idx;
  43176. }
  43177. } else {
  43178. var sStr = util.toSetString(aStr);
  43179. if (has.call(this._set, sStr)) {
  43180. return this._set[sStr];
  43181. }
  43182. }
  43183. throw new Error('"' + aStr + '" is not in the set.');
  43184. };
  43185. /**
  43186. * What is the element at the given index?
  43187. *
  43188. * @param Number aIdx
  43189. */
  43190. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  43191. if (aIdx >= 0 && aIdx < this._array.length) {
  43192. return this._array[aIdx];
  43193. }
  43194. throw new Error('No element indexed by ' + aIdx);
  43195. };
  43196. /**
  43197. * Returns the array representation of this set (which has the proper indices
  43198. * indicated by indexOf). Note that this is a copy of the internal array used
  43199. * for storing the members so that no one can mess with internal state.
  43200. */
  43201. ArraySet.prototype.toArray = function ArraySet_toArray() {
  43202. return this._array.slice();
  43203. };
  43204. arraySet.ArraySet = ArraySet;
  43205. return arraySet;
  43206. }
  43207. var mappingList = {};
  43208. /* -*- Mode: js; js-indent-level: 2; -*- */
  43209. var hasRequiredMappingList;
  43210. function requireMappingList () {
  43211. if (hasRequiredMappingList) return mappingList;
  43212. hasRequiredMappingList = 1;
  43213. /*
  43214. * Copyright 2014 Mozilla Foundation and contributors
  43215. * Licensed under the New BSD license. See LICENSE or:
  43216. * http://opensource.org/licenses/BSD-3-Clause
  43217. */
  43218. var util = /*@__PURE__*/ requireUtil();
  43219. /**
  43220. * Determine whether mappingB is after mappingA with respect to generated
  43221. * position.
  43222. */
  43223. function generatedPositionAfter(mappingA, mappingB) {
  43224. // Optimized for most common case
  43225. var lineA = mappingA.generatedLine;
  43226. var lineB = mappingB.generatedLine;
  43227. var columnA = mappingA.generatedColumn;
  43228. var columnB = mappingB.generatedColumn;
  43229. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  43230. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  43231. }
  43232. /**
  43233. * A data structure to provide a sorted view of accumulated mappings in a
  43234. * performance conscious manner. It trades a neglibable overhead in general
  43235. * case for a large speedup in case of mappings being added in order.
  43236. */
  43237. function MappingList() {
  43238. this._array = [];
  43239. this._sorted = true;
  43240. // Serves as infimum
  43241. this._last = {generatedLine: -1, generatedColumn: 0};
  43242. }
  43243. /**
  43244. * Iterate through internal items. This method takes the same arguments that
  43245. * `Array.prototype.forEach` takes.
  43246. *
  43247. * NOTE: The order of the mappings is NOT guaranteed.
  43248. */
  43249. MappingList.prototype.unsortedForEach =
  43250. function MappingList_forEach(aCallback, aThisArg) {
  43251. this._array.forEach(aCallback, aThisArg);
  43252. };
  43253. /**
  43254. * Add the given source mapping.
  43255. *
  43256. * @param Object aMapping
  43257. */
  43258. MappingList.prototype.add = function MappingList_add(aMapping) {
  43259. if (generatedPositionAfter(this._last, aMapping)) {
  43260. this._last = aMapping;
  43261. this._array.push(aMapping);
  43262. } else {
  43263. this._sorted = false;
  43264. this._array.push(aMapping);
  43265. }
  43266. };
  43267. /**
  43268. * Returns the flat, sorted array of mappings. The mappings are sorted by
  43269. * generated position.
  43270. *
  43271. * WARNING: This method returns internal data without copying, for
  43272. * performance. The return value must NOT be mutated, and should be treated as
  43273. * an immutable borrow. If you want to take ownership, you must make your own
  43274. * copy.
  43275. */
  43276. MappingList.prototype.toArray = function MappingList_toArray() {
  43277. if (!this._sorted) {
  43278. this._array.sort(util.compareByGeneratedPositionsInflated);
  43279. this._sorted = true;
  43280. }
  43281. return this._array;
  43282. };
  43283. mappingList.MappingList = MappingList;
  43284. return mappingList;
  43285. }
  43286. /* -*- Mode: js; js-indent-level: 2; -*- */
  43287. var hasRequiredSourceMapGenerator;
  43288. function requireSourceMapGenerator () {
  43289. if (hasRequiredSourceMapGenerator) return sourceMapGenerator;
  43290. hasRequiredSourceMapGenerator = 1;
  43291. /*
  43292. * Copyright 2011 Mozilla Foundation and contributors
  43293. * Licensed under the New BSD license. See LICENSE or:
  43294. * http://opensource.org/licenses/BSD-3-Clause
  43295. */
  43296. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  43297. var util = /*@__PURE__*/ requireUtil();
  43298. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  43299. var MappingList = /*@__PURE__*/ requireMappingList().MappingList;
  43300. /**
  43301. * An instance of the SourceMapGenerator represents a source map which is
  43302. * being built incrementally. You may pass an object with the following
  43303. * properties:
  43304. *
  43305. * - file: The filename of the generated source.
  43306. * - sourceRoot: A root for all relative URLs in this source map.
  43307. */
  43308. function SourceMapGenerator(aArgs) {
  43309. if (!aArgs) {
  43310. aArgs = {};
  43311. }
  43312. this._file = util.getArg(aArgs, 'file', null);
  43313. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  43314. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  43315. this._sources = new ArraySet();
  43316. this._names = new ArraySet();
  43317. this._mappings = new MappingList();
  43318. this._sourcesContents = null;
  43319. }
  43320. SourceMapGenerator.prototype._version = 3;
  43321. /**
  43322. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  43323. *
  43324. * @param aSourceMapConsumer The SourceMap.
  43325. */
  43326. SourceMapGenerator.fromSourceMap =
  43327. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  43328. var sourceRoot = aSourceMapConsumer.sourceRoot;
  43329. var generator = new SourceMapGenerator({
  43330. file: aSourceMapConsumer.file,
  43331. sourceRoot: sourceRoot
  43332. });
  43333. aSourceMapConsumer.eachMapping(function (mapping) {
  43334. var newMapping = {
  43335. generated: {
  43336. line: mapping.generatedLine,
  43337. column: mapping.generatedColumn
  43338. }
  43339. };
  43340. if (mapping.source != null) {
  43341. newMapping.source = mapping.source;
  43342. if (sourceRoot != null) {
  43343. newMapping.source = util.relative(sourceRoot, newMapping.source);
  43344. }
  43345. newMapping.original = {
  43346. line: mapping.originalLine,
  43347. column: mapping.originalColumn
  43348. };
  43349. if (mapping.name != null) {
  43350. newMapping.name = mapping.name;
  43351. }
  43352. }
  43353. generator.addMapping(newMapping);
  43354. });
  43355. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  43356. var sourceRelative = sourceFile;
  43357. if (sourceRoot !== null) {
  43358. sourceRelative = util.relative(sourceRoot, sourceFile);
  43359. }
  43360. if (!generator._sources.has(sourceRelative)) {
  43361. generator._sources.add(sourceRelative);
  43362. }
  43363. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  43364. if (content != null) {
  43365. generator.setSourceContent(sourceFile, content);
  43366. }
  43367. });
  43368. return generator;
  43369. };
  43370. /**
  43371. * Add a single mapping from original source line and column to the generated
  43372. * source's line and column for this source map being created. The mapping
  43373. * object should have the following properties:
  43374. *
  43375. * - generated: An object with the generated line and column positions.
  43376. * - original: An object with the original line and column positions.
  43377. * - source: The original source file (relative to the sourceRoot).
  43378. * - name: An optional original token name for this mapping.
  43379. */
  43380. SourceMapGenerator.prototype.addMapping =
  43381. function SourceMapGenerator_addMapping(aArgs) {
  43382. var generated = util.getArg(aArgs, 'generated');
  43383. var original = util.getArg(aArgs, 'original', null);
  43384. var source = util.getArg(aArgs, 'source', null);
  43385. var name = util.getArg(aArgs, 'name', null);
  43386. if (!this._skipValidation) {
  43387. this._validateMapping(generated, original, source, name);
  43388. }
  43389. if (source != null) {
  43390. source = String(source);
  43391. if (!this._sources.has(source)) {
  43392. this._sources.add(source);
  43393. }
  43394. }
  43395. if (name != null) {
  43396. name = String(name);
  43397. if (!this._names.has(name)) {
  43398. this._names.add(name);
  43399. }
  43400. }
  43401. this._mappings.add({
  43402. generatedLine: generated.line,
  43403. generatedColumn: generated.column,
  43404. originalLine: original != null && original.line,
  43405. originalColumn: original != null && original.column,
  43406. source: source,
  43407. name: name
  43408. });
  43409. };
  43410. /**
  43411. * Set the source content for a source file.
  43412. */
  43413. SourceMapGenerator.prototype.setSourceContent =
  43414. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  43415. var source = aSourceFile;
  43416. if (this._sourceRoot != null) {
  43417. source = util.relative(this._sourceRoot, source);
  43418. }
  43419. if (aSourceContent != null) {
  43420. // Add the source content to the _sourcesContents map.
  43421. // Create a new _sourcesContents map if the property is null.
  43422. if (!this._sourcesContents) {
  43423. this._sourcesContents = Object.create(null);
  43424. }
  43425. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  43426. } else if (this._sourcesContents) {
  43427. // Remove the source file from the _sourcesContents map.
  43428. // If the _sourcesContents map is empty, set the property to null.
  43429. delete this._sourcesContents[util.toSetString(source)];
  43430. if (Object.keys(this._sourcesContents).length === 0) {
  43431. this._sourcesContents = null;
  43432. }
  43433. }
  43434. };
  43435. /**
  43436. * Applies the mappings of a sub-source-map for a specific source file to the
  43437. * source map being generated. Each mapping to the supplied source file is
  43438. * rewritten using the supplied source map. Note: The resolution for the
  43439. * resulting mappings is the minimium of this map and the supplied map.
  43440. *
  43441. * @param aSourceMapConsumer The source map to be applied.
  43442. * @param aSourceFile Optional. The filename of the source file.
  43443. * If omitted, SourceMapConsumer's file property will be used.
  43444. * @param aSourceMapPath Optional. The dirname of the path to the source map
  43445. * to be applied. If relative, it is relative to the SourceMapConsumer.
  43446. * This parameter is needed when the two source maps aren't in the same
  43447. * directory, and the source map to be applied contains relative source
  43448. * paths. If so, those relative source paths need to be rewritten
  43449. * relative to the SourceMapGenerator.
  43450. */
  43451. SourceMapGenerator.prototype.applySourceMap =
  43452. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  43453. var sourceFile = aSourceFile;
  43454. // If aSourceFile is omitted, we will use the file property of the SourceMap
  43455. if (aSourceFile == null) {
  43456. if (aSourceMapConsumer.file == null) {
  43457. throw new Error(
  43458. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  43459. 'or the source map\'s "file" property. Both were omitted.'
  43460. );
  43461. }
  43462. sourceFile = aSourceMapConsumer.file;
  43463. }
  43464. var sourceRoot = this._sourceRoot;
  43465. // Make "sourceFile" relative if an absolute Url is passed.
  43466. if (sourceRoot != null) {
  43467. sourceFile = util.relative(sourceRoot, sourceFile);
  43468. }
  43469. // Applying the SourceMap can add and remove items from the sources and
  43470. // the names array.
  43471. var newSources = new ArraySet();
  43472. var newNames = new ArraySet();
  43473. // Find mappings for the "sourceFile"
  43474. this._mappings.unsortedForEach(function (mapping) {
  43475. if (mapping.source === sourceFile && mapping.originalLine != null) {
  43476. // Check if it can be mapped by the source map, then update the mapping.
  43477. var original = aSourceMapConsumer.originalPositionFor({
  43478. line: mapping.originalLine,
  43479. column: mapping.originalColumn
  43480. });
  43481. if (original.source != null) {
  43482. // Copy mapping
  43483. mapping.source = original.source;
  43484. if (aSourceMapPath != null) {
  43485. mapping.source = util.join(aSourceMapPath, mapping.source);
  43486. }
  43487. if (sourceRoot != null) {
  43488. mapping.source = util.relative(sourceRoot, mapping.source);
  43489. }
  43490. mapping.originalLine = original.line;
  43491. mapping.originalColumn = original.column;
  43492. if (original.name != null) {
  43493. mapping.name = original.name;
  43494. }
  43495. }
  43496. }
  43497. var source = mapping.source;
  43498. if (source != null && !newSources.has(source)) {
  43499. newSources.add(source);
  43500. }
  43501. var name = mapping.name;
  43502. if (name != null && !newNames.has(name)) {
  43503. newNames.add(name);
  43504. }
  43505. }, this);
  43506. this._sources = newSources;
  43507. this._names = newNames;
  43508. // Copy sourcesContents of applied map.
  43509. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  43510. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  43511. if (content != null) {
  43512. if (aSourceMapPath != null) {
  43513. sourceFile = util.join(aSourceMapPath, sourceFile);
  43514. }
  43515. if (sourceRoot != null) {
  43516. sourceFile = util.relative(sourceRoot, sourceFile);
  43517. }
  43518. this.setSourceContent(sourceFile, content);
  43519. }
  43520. }, this);
  43521. };
  43522. /**
  43523. * A mapping can have one of the three levels of data:
  43524. *
  43525. * 1. Just the generated position.
  43526. * 2. The Generated position, original position, and original source.
  43527. * 3. Generated and original position, original source, as well as a name
  43528. * token.
  43529. *
  43530. * To maintain consistency, we validate that any new mapping being added falls
  43531. * in to one of these categories.
  43532. */
  43533. SourceMapGenerator.prototype._validateMapping =
  43534. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  43535. aName) {
  43536. // When aOriginal is truthy but has empty values for .line and .column,
  43537. // it is most likely a programmer error. In this case we throw a very
  43538. // specific error message to try to guide them the right way.
  43539. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  43540. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  43541. throw new Error(
  43542. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  43543. 'the original mapping entirely and only map the generated position. If so, pass ' +
  43544. 'null for the original mapping instead of an object with empty or null values.'
  43545. );
  43546. }
  43547. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  43548. && aGenerated.line > 0 && aGenerated.column >= 0
  43549. && !aOriginal && !aSource && !aName) {
  43550. // Case 1.
  43551. return;
  43552. }
  43553. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  43554. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  43555. && aGenerated.line > 0 && aGenerated.column >= 0
  43556. && aOriginal.line > 0 && aOriginal.column >= 0
  43557. && aSource) {
  43558. // Cases 2 and 3.
  43559. return;
  43560. }
  43561. else {
  43562. throw new Error('Invalid mapping: ' + JSON.stringify({
  43563. generated: aGenerated,
  43564. source: aSource,
  43565. original: aOriginal,
  43566. name: aName
  43567. }));
  43568. }
  43569. };
  43570. /**
  43571. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  43572. * specified by the source map format.
  43573. */
  43574. SourceMapGenerator.prototype._serializeMappings =
  43575. function SourceMapGenerator_serializeMappings() {
  43576. var previousGeneratedColumn = 0;
  43577. var previousGeneratedLine = 1;
  43578. var previousOriginalColumn = 0;
  43579. var previousOriginalLine = 0;
  43580. var previousName = 0;
  43581. var previousSource = 0;
  43582. var result = '';
  43583. var next;
  43584. var mapping;
  43585. var nameIdx;
  43586. var sourceIdx;
  43587. var mappings = this._mappings.toArray();
  43588. for (var i = 0, len = mappings.length; i < len; i++) {
  43589. mapping = mappings[i];
  43590. next = '';
  43591. if (mapping.generatedLine !== previousGeneratedLine) {
  43592. previousGeneratedColumn = 0;
  43593. while (mapping.generatedLine !== previousGeneratedLine) {
  43594. next += ';';
  43595. previousGeneratedLine++;
  43596. }
  43597. }
  43598. else {
  43599. if (i > 0) {
  43600. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  43601. continue;
  43602. }
  43603. next += ',';
  43604. }
  43605. }
  43606. next += base64VLQ.encode(mapping.generatedColumn
  43607. - previousGeneratedColumn);
  43608. previousGeneratedColumn = mapping.generatedColumn;
  43609. if (mapping.source != null) {
  43610. sourceIdx = this._sources.indexOf(mapping.source);
  43611. next += base64VLQ.encode(sourceIdx - previousSource);
  43612. previousSource = sourceIdx;
  43613. // lines are stored 0-based in SourceMap spec version 3
  43614. next += base64VLQ.encode(mapping.originalLine - 1
  43615. - previousOriginalLine);
  43616. previousOriginalLine = mapping.originalLine - 1;
  43617. next += base64VLQ.encode(mapping.originalColumn
  43618. - previousOriginalColumn);
  43619. previousOriginalColumn = mapping.originalColumn;
  43620. if (mapping.name != null) {
  43621. nameIdx = this._names.indexOf(mapping.name);
  43622. next += base64VLQ.encode(nameIdx - previousName);
  43623. previousName = nameIdx;
  43624. }
  43625. }
  43626. result += next;
  43627. }
  43628. return result;
  43629. };
  43630. SourceMapGenerator.prototype._generateSourcesContent =
  43631. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  43632. return aSources.map(function (source) {
  43633. if (!this._sourcesContents) {
  43634. return null;
  43635. }
  43636. if (aSourceRoot != null) {
  43637. source = util.relative(aSourceRoot, source);
  43638. }
  43639. var key = util.toSetString(source);
  43640. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  43641. ? this._sourcesContents[key]
  43642. : null;
  43643. }, this);
  43644. };
  43645. /**
  43646. * Externalize the source map.
  43647. */
  43648. SourceMapGenerator.prototype.toJSON =
  43649. function SourceMapGenerator_toJSON() {
  43650. var map = {
  43651. version: this._version,
  43652. sources: this._sources.toArray(),
  43653. names: this._names.toArray(),
  43654. mappings: this._serializeMappings()
  43655. };
  43656. if (this._file != null) {
  43657. map.file = this._file;
  43658. }
  43659. if (this._sourceRoot != null) {
  43660. map.sourceRoot = this._sourceRoot;
  43661. }
  43662. if (this._sourcesContents) {
  43663. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  43664. }
  43665. return map;
  43666. };
  43667. /**
  43668. * Render the source map being generated to a string.
  43669. */
  43670. SourceMapGenerator.prototype.toString =
  43671. function SourceMapGenerator_toString() {
  43672. return JSON.stringify(this.toJSON());
  43673. };
  43674. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator;
  43675. return sourceMapGenerator;
  43676. }
  43677. var sourceMapConsumer = {};
  43678. var binarySearch = {};
  43679. /* -*- Mode: js; js-indent-level: 2; -*- */
  43680. var hasRequiredBinarySearch;
  43681. function requireBinarySearch () {
  43682. if (hasRequiredBinarySearch) return binarySearch;
  43683. hasRequiredBinarySearch = 1;
  43684. (function (exports) {
  43685. /*
  43686. * Copyright 2011 Mozilla Foundation and contributors
  43687. * Licensed under the New BSD license. See LICENSE or:
  43688. * http://opensource.org/licenses/BSD-3-Clause
  43689. */
  43690. exports.GREATEST_LOWER_BOUND = 1;
  43691. exports.LEAST_UPPER_BOUND = 2;
  43692. /**
  43693. * Recursive implementation of binary search.
  43694. *
  43695. * @param aLow Indices here and lower do not contain the needle.
  43696. * @param aHigh Indices here and higher do not contain the needle.
  43697. * @param aNeedle The element being searched for.
  43698. * @param aHaystack The non-empty array being searched.
  43699. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  43700. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  43701. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  43702. * closest element that is smaller than or greater than the one we are
  43703. * searching for, respectively, if the exact element cannot be found.
  43704. */
  43705. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  43706. // This function terminates when one of the following is true:
  43707. //
  43708. // 1. We find the exact element we are looking for.
  43709. //
  43710. // 2. We did not find the exact element, but we can return the index of
  43711. // the next-closest element.
  43712. //
  43713. // 3. We did not find the exact element, and there is no next-closest
  43714. // element than the one we are searching for, so we return -1.
  43715. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  43716. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  43717. if (cmp === 0) {
  43718. // Found the element we are looking for.
  43719. return mid;
  43720. }
  43721. else if (cmp > 0) {
  43722. // Our needle is greater than aHaystack[mid].
  43723. if (aHigh - mid > 1) {
  43724. // The element is in the upper half.
  43725. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  43726. }
  43727. // The exact needle element was not found in this haystack. Determine if
  43728. // we are in termination case (3) or (2) and return the appropriate thing.
  43729. if (aBias == exports.LEAST_UPPER_BOUND) {
  43730. return aHigh < aHaystack.length ? aHigh : -1;
  43731. } else {
  43732. return mid;
  43733. }
  43734. }
  43735. else {
  43736. // Our needle is less than aHaystack[mid].
  43737. if (mid - aLow > 1) {
  43738. // The element is in the lower half.
  43739. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  43740. }
  43741. // we are in termination case (3) or (2) and return the appropriate thing.
  43742. if (aBias == exports.LEAST_UPPER_BOUND) {
  43743. return mid;
  43744. } else {
  43745. return aLow < 0 ? -1 : aLow;
  43746. }
  43747. }
  43748. }
  43749. /**
  43750. * This is an implementation of binary search which will always try and return
  43751. * the index of the closest element if there is no exact hit. This is because
  43752. * mappings between original and generated line/col pairs are single points,
  43753. * and there is an implicit region between each of them, so a miss just means
  43754. * that you aren't on the very start of a region.
  43755. *
  43756. * @param aNeedle The element you are looking for.
  43757. * @param aHaystack The array that is being searched.
  43758. * @param aCompare A function which takes the needle and an element in the
  43759. * array and returns -1, 0, or 1 depending on whether the needle is less
  43760. * than, equal to, or greater than the element, respectively.
  43761. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  43762. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  43763. * closest element that is smaller than or greater than the one we are
  43764. * searching for, respectively, if the exact element cannot be found.
  43765. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  43766. */
  43767. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  43768. if (aHaystack.length === 0) {
  43769. return -1;
  43770. }
  43771. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  43772. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  43773. if (index < 0) {
  43774. return -1;
  43775. }
  43776. // We have found either the exact element, or the next-closest element than
  43777. // the one we are searching for. However, there may be more than one such
  43778. // element. Make sure we always return the smallest of these.
  43779. while (index - 1 >= 0) {
  43780. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  43781. break;
  43782. }
  43783. --index;
  43784. }
  43785. return index;
  43786. };
  43787. } (binarySearch));
  43788. return binarySearch;
  43789. }
  43790. var quickSort = {};
  43791. /* -*- Mode: js; js-indent-level: 2; -*- */
  43792. var hasRequiredQuickSort;
  43793. function requireQuickSort () {
  43794. if (hasRequiredQuickSort) return quickSort;
  43795. hasRequiredQuickSort = 1;
  43796. /*
  43797. * Copyright 2011 Mozilla Foundation and contributors
  43798. * Licensed under the New BSD license. See LICENSE or:
  43799. * http://opensource.org/licenses/BSD-3-Clause
  43800. */
  43801. // It turns out that some (most?) JavaScript engines don't self-host
  43802. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  43803. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  43804. // custom comparator function, calling back and forth between the VM's C++ and
  43805. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  43806. // worse generated code for the comparator function than would be optimal. In
  43807. // fact, when sorting with a comparator, these costs outweigh the benefits of
  43808. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  43809. // a ~3500ms mean speed-up in `bench/bench.html`.
  43810. /**
  43811. * Swap the elements indexed by `x` and `y` in the array `ary`.
  43812. *
  43813. * @param {Array} ary
  43814. * The array.
  43815. * @param {Number} x
  43816. * The index of the first item.
  43817. * @param {Number} y
  43818. * The index of the second item.
  43819. */
  43820. function swap(ary, x, y) {
  43821. var temp = ary[x];
  43822. ary[x] = ary[y];
  43823. ary[y] = temp;
  43824. }
  43825. /**
  43826. * Returns a random integer within the range `low .. high` inclusive.
  43827. *
  43828. * @param {Number} low
  43829. * The lower bound on the range.
  43830. * @param {Number} high
  43831. * The upper bound on the range.
  43832. */
  43833. function randomIntInRange(low, high) {
  43834. return Math.round(low + (Math.random() * (high - low)));
  43835. }
  43836. /**
  43837. * The Quick Sort algorithm.
  43838. *
  43839. * @param {Array} ary
  43840. * An array to sort.
  43841. * @param {function} comparator
  43842. * Function to use to compare two items.
  43843. * @param {Number} p
  43844. * Start index of the array
  43845. * @param {Number} r
  43846. * End index of the array
  43847. */
  43848. function doQuickSort(ary, comparator, p, r) {
  43849. // If our lower bound is less than our upper bound, we (1) partition the
  43850. // array into two pieces and (2) recurse on each half. If it is not, this is
  43851. // the empty array and our base case.
  43852. if (p < r) {
  43853. // (1) Partitioning.
  43854. //
  43855. // The partitioning chooses a pivot between `p` and `r` and moves all
  43856. // elements that are less than or equal to the pivot to the before it, and
  43857. // all the elements that are greater than it after it. The effect is that
  43858. // once partition is done, the pivot is in the exact place it will be when
  43859. // the array is put in sorted order, and it will not need to be moved
  43860. // again. This runs in O(n) time.
  43861. // Always choose a random pivot so that an input array which is reverse
  43862. // sorted does not cause O(n^2) running time.
  43863. var pivotIndex = randomIntInRange(p, r);
  43864. var i = p - 1;
  43865. swap(ary, pivotIndex, r);
  43866. var pivot = ary[r];
  43867. // Immediately after `j` is incremented in this loop, the following hold
  43868. // true:
  43869. //
  43870. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  43871. //
  43872. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  43873. for (var j = p; j < r; j++) {
  43874. if (comparator(ary[j], pivot) <= 0) {
  43875. i += 1;
  43876. swap(ary, i, j);
  43877. }
  43878. }
  43879. swap(ary, i + 1, j);
  43880. var q = i + 1;
  43881. // (2) Recurse on each half.
  43882. doQuickSort(ary, comparator, p, q - 1);
  43883. doQuickSort(ary, comparator, q + 1, r);
  43884. }
  43885. }
  43886. /**
  43887. * Sort the given array in-place with the given comparator function.
  43888. *
  43889. * @param {Array} ary
  43890. * An array to sort.
  43891. * @param {function} comparator
  43892. * Function to use to compare two items.
  43893. */
  43894. quickSort.quickSort = function (ary, comparator) {
  43895. doQuickSort(ary, comparator, 0, ary.length - 1);
  43896. };
  43897. return quickSort;
  43898. }
  43899. /* -*- Mode: js; js-indent-level: 2; -*- */
  43900. var hasRequiredSourceMapConsumer;
  43901. function requireSourceMapConsumer () {
  43902. if (hasRequiredSourceMapConsumer) return sourceMapConsumer;
  43903. hasRequiredSourceMapConsumer = 1;
  43904. /*
  43905. * Copyright 2011 Mozilla Foundation and contributors
  43906. * Licensed under the New BSD license. See LICENSE or:
  43907. * http://opensource.org/licenses/BSD-3-Clause
  43908. */
  43909. var util = /*@__PURE__*/ requireUtil();
  43910. var binarySearch = /*@__PURE__*/ requireBinarySearch();
  43911. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  43912. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  43913. var quickSort = /*@__PURE__*/ requireQuickSort().quickSort;
  43914. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  43915. var sourceMap = aSourceMap;
  43916. if (typeof aSourceMap === 'string') {
  43917. sourceMap = util.parseSourceMapInput(aSourceMap);
  43918. }
  43919. return sourceMap.sections != null
  43920. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  43921. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  43922. }
  43923. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  43924. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  43925. };
  43926. /**
  43927. * The version of the source mapping spec that we are consuming.
  43928. */
  43929. SourceMapConsumer.prototype._version = 3;
  43930. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  43931. // parsed mapping coordinates from the source map's "mappings" attribute. They
  43932. // are lazily instantiated, accessed via the `_generatedMappings` and
  43933. // `_originalMappings` getters respectively, and we only parse the mappings
  43934. // and create these arrays once queried for a source location. We jump through
  43935. // these hoops because there can be many thousands of mappings, and parsing
  43936. // them is expensive, so we only want to do it if we must.
  43937. //
  43938. // Each object in the arrays is of the form:
  43939. //
  43940. // {
  43941. // generatedLine: The line number in the generated code,
  43942. // generatedColumn: The column number in the generated code,
  43943. // source: The path to the original source file that generated this
  43944. // chunk of code,
  43945. // originalLine: The line number in the original source that
  43946. // corresponds to this chunk of generated code,
  43947. // originalColumn: The column number in the original source that
  43948. // corresponds to this chunk of generated code,
  43949. // name: The name of the original symbol which generated this chunk of
  43950. // code.
  43951. // }
  43952. //
  43953. // All properties except for `generatedLine` and `generatedColumn` can be
  43954. // `null`.
  43955. //
  43956. // `_generatedMappings` is ordered by the generated positions.
  43957. //
  43958. // `_originalMappings` is ordered by the original positions.
  43959. SourceMapConsumer.prototype.__generatedMappings = null;
  43960. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  43961. configurable: true,
  43962. enumerable: true,
  43963. get: function () {
  43964. if (!this.__generatedMappings) {
  43965. this._parseMappings(this._mappings, this.sourceRoot);
  43966. }
  43967. return this.__generatedMappings;
  43968. }
  43969. });
  43970. SourceMapConsumer.prototype.__originalMappings = null;
  43971. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  43972. configurable: true,
  43973. enumerable: true,
  43974. get: function () {
  43975. if (!this.__originalMappings) {
  43976. this._parseMappings(this._mappings, this.sourceRoot);
  43977. }
  43978. return this.__originalMappings;
  43979. }
  43980. });
  43981. SourceMapConsumer.prototype._charIsMappingSeparator =
  43982. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  43983. var c = aStr.charAt(index);
  43984. return c === ";" || c === ",";
  43985. };
  43986. /**
  43987. * Parse the mappings in a string in to a data structure which we can easily
  43988. * query (the ordered arrays in the `this.__generatedMappings` and
  43989. * `this.__originalMappings` properties).
  43990. */
  43991. SourceMapConsumer.prototype._parseMappings =
  43992. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  43993. throw new Error("Subclasses must implement _parseMappings");
  43994. };
  43995. SourceMapConsumer.GENERATED_ORDER = 1;
  43996. SourceMapConsumer.ORIGINAL_ORDER = 2;
  43997. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  43998. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  43999. /**
  44000. * Iterate over each mapping between an original source/line/column and a
  44001. * generated line/column in this source map.
  44002. *
  44003. * @param Function aCallback
  44004. * The function that is called with each mapping.
  44005. * @param Object aContext
  44006. * Optional. If specified, this object will be the value of `this` every
  44007. * time that `aCallback` is called.
  44008. * @param aOrder
  44009. * Either `SourceMapConsumer.GENERATED_ORDER` or
  44010. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  44011. * iterate over the mappings sorted by the generated file's line/column
  44012. * order or the original's source/line/column order, respectively. Defaults to
  44013. * `SourceMapConsumer.GENERATED_ORDER`.
  44014. */
  44015. SourceMapConsumer.prototype.eachMapping =
  44016. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  44017. var context = aContext || null;
  44018. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  44019. var mappings;
  44020. switch (order) {
  44021. case SourceMapConsumer.GENERATED_ORDER:
  44022. mappings = this._generatedMappings;
  44023. break;
  44024. case SourceMapConsumer.ORIGINAL_ORDER:
  44025. mappings = this._originalMappings;
  44026. break;
  44027. default:
  44028. throw new Error("Unknown order of iteration.");
  44029. }
  44030. var sourceRoot = this.sourceRoot;
  44031. mappings.map(function (mapping) {
  44032. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  44033. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  44034. return {
  44035. source: source,
  44036. generatedLine: mapping.generatedLine,
  44037. generatedColumn: mapping.generatedColumn,
  44038. originalLine: mapping.originalLine,
  44039. originalColumn: mapping.originalColumn,
  44040. name: mapping.name === null ? null : this._names.at(mapping.name)
  44041. };
  44042. }, this).forEach(aCallback, context);
  44043. };
  44044. /**
  44045. * Returns all generated line and column information for the original source,
  44046. * line, and column provided. If no column is provided, returns all mappings
  44047. * corresponding to a either the line we are searching for or the next
  44048. * closest line that has any mappings. Otherwise, returns all mappings
  44049. * corresponding to the given line and either the column we are searching for
  44050. * or the next closest column that has any offsets.
  44051. *
  44052. * The only argument is an object with the following properties:
  44053. *
  44054. * - source: The filename of the original source.
  44055. * - line: The line number in the original source. The line number is 1-based.
  44056. * - column: Optional. the column number in the original source.
  44057. * The column number is 0-based.
  44058. *
  44059. * and an array of objects is returned, each with the following properties:
  44060. *
  44061. * - line: The line number in the generated source, or null. The
  44062. * line number is 1-based.
  44063. * - column: The column number in the generated source, or null.
  44064. * The column number is 0-based.
  44065. */
  44066. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  44067. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  44068. var line = util.getArg(aArgs, 'line');
  44069. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  44070. // returns the index of the closest mapping less than the needle. By
  44071. // setting needle.originalColumn to 0, we thus find the last mapping for
  44072. // the given line, provided such a mapping exists.
  44073. var needle = {
  44074. source: util.getArg(aArgs, 'source'),
  44075. originalLine: line,
  44076. originalColumn: util.getArg(aArgs, 'column', 0)
  44077. };
  44078. needle.source = this._findSourceIndex(needle.source);
  44079. if (needle.source < 0) {
  44080. return [];
  44081. }
  44082. var mappings = [];
  44083. var index = this._findMapping(needle,
  44084. this._originalMappings,
  44085. "originalLine",
  44086. "originalColumn",
  44087. util.compareByOriginalPositions,
  44088. binarySearch.LEAST_UPPER_BOUND);
  44089. if (index >= 0) {
  44090. var mapping = this._originalMappings[index];
  44091. if (aArgs.column === undefined) {
  44092. var originalLine = mapping.originalLine;
  44093. // Iterate until either we run out of mappings, or we run into
  44094. // a mapping for a different line than the one we found. Since
  44095. // mappings are sorted, this is guaranteed to find all mappings for
  44096. // the line we found.
  44097. while (mapping && mapping.originalLine === originalLine) {
  44098. mappings.push({
  44099. line: util.getArg(mapping, 'generatedLine', null),
  44100. column: util.getArg(mapping, 'generatedColumn', null),
  44101. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44102. });
  44103. mapping = this._originalMappings[++index];
  44104. }
  44105. } else {
  44106. var originalColumn = mapping.originalColumn;
  44107. // Iterate until either we run out of mappings, or we run into
  44108. // a mapping for a different line than the one we were searching for.
  44109. // Since mappings are sorted, this is guaranteed to find all mappings for
  44110. // the line we are searching for.
  44111. while (mapping &&
  44112. mapping.originalLine === line &&
  44113. mapping.originalColumn == originalColumn) {
  44114. mappings.push({
  44115. line: util.getArg(mapping, 'generatedLine', null),
  44116. column: util.getArg(mapping, 'generatedColumn', null),
  44117. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44118. });
  44119. mapping = this._originalMappings[++index];
  44120. }
  44121. }
  44122. }
  44123. return mappings;
  44124. };
  44125. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer;
  44126. /**
  44127. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  44128. * query for information about the original file positions by giving it a file
  44129. * position in the generated source.
  44130. *
  44131. * The first parameter is the raw source map (either as a JSON string, or
  44132. * already parsed to an object). According to the spec, source maps have the
  44133. * following attributes:
  44134. *
  44135. * - version: Which version of the source map spec this map is following.
  44136. * - sources: An array of URLs to the original source files.
  44137. * - names: An array of identifiers which can be referrenced by individual mappings.
  44138. * - sourceRoot: Optional. The URL root from which all sources are relative.
  44139. * - sourcesContent: Optional. An array of contents of the original source files.
  44140. * - mappings: A string of base64 VLQs which contain the actual mappings.
  44141. * - file: Optional. The generated file this source map is associated with.
  44142. *
  44143. * Here is an example source map, taken from the source map spec[0]:
  44144. *
  44145. * {
  44146. * version : 3,
  44147. * file: "out.js",
  44148. * sourceRoot : "",
  44149. * sources: ["foo.js", "bar.js"],
  44150. * names: ["src", "maps", "are", "fun"],
  44151. * mappings: "AA,AB;;ABCDE;"
  44152. * }
  44153. *
  44154. * The second parameter, if given, is a string whose value is the URL
  44155. * at which the source map was found. This URL is used to compute the
  44156. * sources array.
  44157. *
  44158. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  44159. */
  44160. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  44161. var sourceMap = aSourceMap;
  44162. if (typeof aSourceMap === 'string') {
  44163. sourceMap = util.parseSourceMapInput(aSourceMap);
  44164. }
  44165. var version = util.getArg(sourceMap, 'version');
  44166. var sources = util.getArg(sourceMap, 'sources');
  44167. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  44168. // requires the array) to play nice here.
  44169. var names = util.getArg(sourceMap, 'names', []);
  44170. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  44171. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  44172. var mappings = util.getArg(sourceMap, 'mappings');
  44173. var file = util.getArg(sourceMap, 'file', null);
  44174. // Once again, Sass deviates from the spec and supplies the version as a
  44175. // string rather than a number, so we use loose equality checking here.
  44176. if (version != this._version) {
  44177. throw new Error('Unsupported version: ' + version);
  44178. }
  44179. if (sourceRoot) {
  44180. sourceRoot = util.normalize(sourceRoot);
  44181. }
  44182. sources = sources
  44183. .map(String)
  44184. // Some source maps produce relative source paths like "./foo.js" instead of
  44185. // "foo.js". Normalize these first so that future comparisons will succeed.
  44186. // See bugzil.la/1090768.
  44187. .map(util.normalize)
  44188. // Always ensure that absolute sources are internally stored relative to
  44189. // the source root, if the source root is absolute. Not doing this would
  44190. // be particularly problematic when the source root is a prefix of the
  44191. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  44192. .map(function (source) {
  44193. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  44194. ? util.relative(sourceRoot, source)
  44195. : source;
  44196. });
  44197. // Pass `true` below to allow duplicate names and sources. While source maps
  44198. // are intended to be compressed and deduplicated, the TypeScript compiler
  44199. // sometimes generates source maps with duplicates in them. See Github issue
  44200. // #72 and bugzil.la/889492.
  44201. this._names = ArraySet.fromArray(names.map(String), true);
  44202. this._sources = ArraySet.fromArray(sources, true);
  44203. this._absoluteSources = this._sources.toArray().map(function (s) {
  44204. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  44205. });
  44206. this.sourceRoot = sourceRoot;
  44207. this.sourcesContent = sourcesContent;
  44208. this._mappings = mappings;
  44209. this._sourceMapURL = aSourceMapURL;
  44210. this.file = file;
  44211. }
  44212. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  44213. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  44214. /**
  44215. * Utility function to find the index of a source. Returns -1 if not
  44216. * found.
  44217. */
  44218. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  44219. var relativeSource = aSource;
  44220. if (this.sourceRoot != null) {
  44221. relativeSource = util.relative(this.sourceRoot, relativeSource);
  44222. }
  44223. if (this._sources.has(relativeSource)) {
  44224. return this._sources.indexOf(relativeSource);
  44225. }
  44226. // Maybe aSource is an absolute URL as returned by |sources|. In
  44227. // this case we can't simply undo the transform.
  44228. var i;
  44229. for (i = 0; i < this._absoluteSources.length; ++i) {
  44230. if (this._absoluteSources[i] == aSource) {
  44231. return i;
  44232. }
  44233. }
  44234. return -1;
  44235. };
  44236. /**
  44237. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  44238. *
  44239. * @param SourceMapGenerator aSourceMap
  44240. * The source map that will be consumed.
  44241. * @param String aSourceMapURL
  44242. * The URL at which the source map can be found (optional)
  44243. * @returns BasicSourceMapConsumer
  44244. */
  44245. BasicSourceMapConsumer.fromSourceMap =
  44246. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  44247. var smc = Object.create(BasicSourceMapConsumer.prototype);
  44248. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  44249. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  44250. smc.sourceRoot = aSourceMap._sourceRoot;
  44251. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  44252. smc.sourceRoot);
  44253. smc.file = aSourceMap._file;
  44254. smc._sourceMapURL = aSourceMapURL;
  44255. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  44256. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  44257. });
  44258. // Because we are modifying the entries (by converting string sources and
  44259. // names to indices into the sources and names ArraySets), we have to make
  44260. // a copy of the entry or else bad things happen. Shared mutable state
  44261. // strikes again! See github issue #191.
  44262. var generatedMappings = aSourceMap._mappings.toArray().slice();
  44263. var destGeneratedMappings = smc.__generatedMappings = [];
  44264. var destOriginalMappings = smc.__originalMappings = [];
  44265. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  44266. var srcMapping = generatedMappings[i];
  44267. var destMapping = new Mapping;
  44268. destMapping.generatedLine = srcMapping.generatedLine;
  44269. destMapping.generatedColumn = srcMapping.generatedColumn;
  44270. if (srcMapping.source) {
  44271. destMapping.source = sources.indexOf(srcMapping.source);
  44272. destMapping.originalLine = srcMapping.originalLine;
  44273. destMapping.originalColumn = srcMapping.originalColumn;
  44274. if (srcMapping.name) {
  44275. destMapping.name = names.indexOf(srcMapping.name);
  44276. }
  44277. destOriginalMappings.push(destMapping);
  44278. }
  44279. destGeneratedMappings.push(destMapping);
  44280. }
  44281. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  44282. return smc;
  44283. };
  44284. /**
  44285. * The version of the source mapping spec that we are consuming.
  44286. */
  44287. BasicSourceMapConsumer.prototype._version = 3;
  44288. /**
  44289. * The list of original sources.
  44290. */
  44291. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  44292. get: function () {
  44293. return this._absoluteSources.slice();
  44294. }
  44295. });
  44296. /**
  44297. * Provide the JIT with a nice shape / hidden class.
  44298. */
  44299. function Mapping() {
  44300. this.generatedLine = 0;
  44301. this.generatedColumn = 0;
  44302. this.source = null;
  44303. this.originalLine = null;
  44304. this.originalColumn = null;
  44305. this.name = null;
  44306. }
  44307. /**
  44308. * Parse the mappings in a string in to a data structure which we can easily
  44309. * query (the ordered arrays in the `this.__generatedMappings` and
  44310. * `this.__originalMappings` properties).
  44311. */
  44312. BasicSourceMapConsumer.prototype._parseMappings =
  44313. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  44314. var generatedLine = 1;
  44315. var previousGeneratedColumn = 0;
  44316. var previousOriginalLine = 0;
  44317. var previousOriginalColumn = 0;
  44318. var previousSource = 0;
  44319. var previousName = 0;
  44320. var length = aStr.length;
  44321. var index = 0;
  44322. var cachedSegments = {};
  44323. var temp = {};
  44324. var originalMappings = [];
  44325. var generatedMappings = [];
  44326. var mapping, str, segment, end, value;
  44327. while (index < length) {
  44328. if (aStr.charAt(index) === ';') {
  44329. generatedLine++;
  44330. index++;
  44331. previousGeneratedColumn = 0;
  44332. }
  44333. else if (aStr.charAt(index) === ',') {
  44334. index++;
  44335. }
  44336. else {
  44337. mapping = new Mapping();
  44338. mapping.generatedLine = generatedLine;
  44339. // Because each offset is encoded relative to the previous one,
  44340. // many segments often have the same encoding. We can exploit this
  44341. // fact by caching the parsed variable length fields of each segment,
  44342. // allowing us to avoid a second parse if we encounter the same
  44343. // segment again.
  44344. for (end = index; end < length; end++) {
  44345. if (this._charIsMappingSeparator(aStr, end)) {
  44346. break;
  44347. }
  44348. }
  44349. str = aStr.slice(index, end);
  44350. segment = cachedSegments[str];
  44351. if (segment) {
  44352. index += str.length;
  44353. } else {
  44354. segment = [];
  44355. while (index < end) {
  44356. base64VLQ.decode(aStr, index, temp);
  44357. value = temp.value;
  44358. index = temp.rest;
  44359. segment.push(value);
  44360. }
  44361. if (segment.length === 2) {
  44362. throw new Error('Found a source, but no line and column');
  44363. }
  44364. if (segment.length === 3) {
  44365. throw new Error('Found a source and line, but no column');
  44366. }
  44367. cachedSegments[str] = segment;
  44368. }
  44369. // Generated column.
  44370. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  44371. previousGeneratedColumn = mapping.generatedColumn;
  44372. if (segment.length > 1) {
  44373. // Original source.
  44374. mapping.source = previousSource + segment[1];
  44375. previousSource += segment[1];
  44376. // Original line.
  44377. mapping.originalLine = previousOriginalLine + segment[2];
  44378. previousOriginalLine = mapping.originalLine;
  44379. // Lines are stored 0-based
  44380. mapping.originalLine += 1;
  44381. // Original column.
  44382. mapping.originalColumn = previousOriginalColumn + segment[3];
  44383. previousOriginalColumn = mapping.originalColumn;
  44384. if (segment.length > 4) {
  44385. // Original name.
  44386. mapping.name = previousName + segment[4];
  44387. previousName += segment[4];
  44388. }
  44389. }
  44390. generatedMappings.push(mapping);
  44391. if (typeof mapping.originalLine === 'number') {
  44392. originalMappings.push(mapping);
  44393. }
  44394. }
  44395. }
  44396. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  44397. this.__generatedMappings = generatedMappings;
  44398. quickSort(originalMappings, util.compareByOriginalPositions);
  44399. this.__originalMappings = originalMappings;
  44400. };
  44401. /**
  44402. * Find the mapping that best matches the hypothetical "needle" mapping that
  44403. * we are searching for in the given "haystack" of mappings.
  44404. */
  44405. BasicSourceMapConsumer.prototype._findMapping =
  44406. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  44407. aColumnName, aComparator, aBias) {
  44408. // To return the position we are searching for, we must first find the
  44409. // mapping for the given position and then return the opposite position it
  44410. // points to. Because the mappings are sorted, we can use binary search to
  44411. // find the best mapping.
  44412. if (aNeedle[aLineName] <= 0) {
  44413. throw new TypeError('Line must be greater than or equal to 1, got '
  44414. + aNeedle[aLineName]);
  44415. }
  44416. if (aNeedle[aColumnName] < 0) {
  44417. throw new TypeError('Column must be greater than or equal to 0, got '
  44418. + aNeedle[aColumnName]);
  44419. }
  44420. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  44421. };
  44422. /**
  44423. * Compute the last column for each generated mapping. The last column is
  44424. * inclusive.
  44425. */
  44426. BasicSourceMapConsumer.prototype.computeColumnSpans =
  44427. function SourceMapConsumer_computeColumnSpans() {
  44428. for (var index = 0; index < this._generatedMappings.length; ++index) {
  44429. var mapping = this._generatedMappings[index];
  44430. // Mappings do not contain a field for the last generated columnt. We
  44431. // can come up with an optimistic estimate, however, by assuming that
  44432. // mappings are contiguous (i.e. given two consecutive mappings, the
  44433. // first mapping ends where the second one starts).
  44434. if (index + 1 < this._generatedMappings.length) {
  44435. var nextMapping = this._generatedMappings[index + 1];
  44436. if (mapping.generatedLine === nextMapping.generatedLine) {
  44437. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  44438. continue;
  44439. }
  44440. }
  44441. // The last mapping for each line spans the entire line.
  44442. mapping.lastGeneratedColumn = Infinity;
  44443. }
  44444. };
  44445. /**
  44446. * Returns the original source, line, and column information for the generated
  44447. * source's line and column positions provided. The only argument is an object
  44448. * with the following properties:
  44449. *
  44450. * - line: The line number in the generated source. The line number
  44451. * is 1-based.
  44452. * - column: The column number in the generated source. The column
  44453. * number is 0-based.
  44454. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  44455. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  44456. * closest element that is smaller than or greater than the one we are
  44457. * searching for, respectively, if the exact element cannot be found.
  44458. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  44459. *
  44460. * and an object is returned with the following properties:
  44461. *
  44462. * - source: The original source file, or null.
  44463. * - line: The line number in the original source, or null. The
  44464. * line number is 1-based.
  44465. * - column: The column number in the original source, or null. The
  44466. * column number is 0-based.
  44467. * - name: The original identifier, or null.
  44468. */
  44469. BasicSourceMapConsumer.prototype.originalPositionFor =
  44470. function SourceMapConsumer_originalPositionFor(aArgs) {
  44471. var needle = {
  44472. generatedLine: util.getArg(aArgs, 'line'),
  44473. generatedColumn: util.getArg(aArgs, 'column')
  44474. };
  44475. var index = this._findMapping(
  44476. needle,
  44477. this._generatedMappings,
  44478. "generatedLine",
  44479. "generatedColumn",
  44480. util.compareByGeneratedPositionsDeflated,
  44481. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  44482. );
  44483. if (index >= 0) {
  44484. var mapping = this._generatedMappings[index];
  44485. if (mapping.generatedLine === needle.generatedLine) {
  44486. var source = util.getArg(mapping, 'source', null);
  44487. if (source !== null) {
  44488. source = this._sources.at(source);
  44489. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  44490. }
  44491. var name = util.getArg(mapping, 'name', null);
  44492. if (name !== null) {
  44493. name = this._names.at(name);
  44494. }
  44495. return {
  44496. source: source,
  44497. line: util.getArg(mapping, 'originalLine', null),
  44498. column: util.getArg(mapping, 'originalColumn', null),
  44499. name: name
  44500. };
  44501. }
  44502. }
  44503. return {
  44504. source: null,
  44505. line: null,
  44506. column: null,
  44507. name: null
  44508. };
  44509. };
  44510. /**
  44511. * Return true if we have the source content for every source in the source
  44512. * map, false otherwise.
  44513. */
  44514. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  44515. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  44516. if (!this.sourcesContent) {
  44517. return false;
  44518. }
  44519. return this.sourcesContent.length >= this._sources.size() &&
  44520. !this.sourcesContent.some(function (sc) { return sc == null; });
  44521. };
  44522. /**
  44523. * Returns the original source content. The only argument is the url of the
  44524. * original source file. Returns null if no original source content is
  44525. * available.
  44526. */
  44527. BasicSourceMapConsumer.prototype.sourceContentFor =
  44528. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  44529. if (!this.sourcesContent) {
  44530. return null;
  44531. }
  44532. var index = this._findSourceIndex(aSource);
  44533. if (index >= 0) {
  44534. return this.sourcesContent[index];
  44535. }
  44536. var relativeSource = aSource;
  44537. if (this.sourceRoot != null) {
  44538. relativeSource = util.relative(this.sourceRoot, relativeSource);
  44539. }
  44540. var url;
  44541. if (this.sourceRoot != null
  44542. && (url = util.urlParse(this.sourceRoot))) {
  44543. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  44544. // many users. We can help them out when they expect file:// URIs to
  44545. // behave like it would if they were running a local HTTP server. See
  44546. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  44547. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  44548. if (url.scheme == "file"
  44549. && this._sources.has(fileUriAbsPath)) {
  44550. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  44551. }
  44552. if ((!url.path || url.path == "/")
  44553. && this._sources.has("/" + relativeSource)) {
  44554. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  44555. }
  44556. }
  44557. // This function is used recursively from
  44558. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  44559. // don't want to throw if we can't find the source - we just want to
  44560. // return null, so we provide a flag to exit gracefully.
  44561. if (nullOnMissing) {
  44562. return null;
  44563. }
  44564. else {
  44565. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  44566. }
  44567. };
  44568. /**
  44569. * Returns the generated line and column information for the original source,
  44570. * line, and column positions provided. The only argument is an object with
  44571. * the following properties:
  44572. *
  44573. * - source: The filename of the original source.
  44574. * - line: The line number in the original source. The line number
  44575. * is 1-based.
  44576. * - column: The column number in the original source. The column
  44577. * number is 0-based.
  44578. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  44579. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  44580. * closest element that is smaller than or greater than the one we are
  44581. * searching for, respectively, if the exact element cannot be found.
  44582. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  44583. *
  44584. * and an object is returned with the following properties:
  44585. *
  44586. * - line: The line number in the generated source, or null. The
  44587. * line number is 1-based.
  44588. * - column: The column number in the generated source, or null.
  44589. * The column number is 0-based.
  44590. */
  44591. BasicSourceMapConsumer.prototype.generatedPositionFor =
  44592. function SourceMapConsumer_generatedPositionFor(aArgs) {
  44593. var source = util.getArg(aArgs, 'source');
  44594. source = this._findSourceIndex(source);
  44595. if (source < 0) {
  44596. return {
  44597. line: null,
  44598. column: null,
  44599. lastColumn: null
  44600. };
  44601. }
  44602. var needle = {
  44603. source: source,
  44604. originalLine: util.getArg(aArgs, 'line'),
  44605. originalColumn: util.getArg(aArgs, 'column')
  44606. };
  44607. var index = this._findMapping(
  44608. needle,
  44609. this._originalMappings,
  44610. "originalLine",
  44611. "originalColumn",
  44612. util.compareByOriginalPositions,
  44613. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  44614. );
  44615. if (index >= 0) {
  44616. var mapping = this._originalMappings[index];
  44617. if (mapping.source === needle.source) {
  44618. return {
  44619. line: util.getArg(mapping, 'generatedLine', null),
  44620. column: util.getArg(mapping, 'generatedColumn', null),
  44621. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44622. };
  44623. }
  44624. }
  44625. return {
  44626. line: null,
  44627. column: null,
  44628. lastColumn: null
  44629. };
  44630. };
  44631. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  44632. /**
  44633. * An IndexedSourceMapConsumer instance represents a parsed source map which
  44634. * we can query for information. It differs from BasicSourceMapConsumer in
  44635. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  44636. * input.
  44637. *
  44638. * The first parameter is a raw source map (either as a JSON string, or already
  44639. * parsed to an object). According to the spec for indexed source maps, they
  44640. * have the following attributes:
  44641. *
  44642. * - version: Which version of the source map spec this map is following.
  44643. * - file: Optional. The generated file this source map is associated with.
  44644. * - sections: A list of section definitions.
  44645. *
  44646. * Each value under the "sections" field has two fields:
  44647. * - offset: The offset into the original specified at which this section
  44648. * begins to apply, defined as an object with a "line" and "column"
  44649. * field.
  44650. * - map: A source map definition. This source map could also be indexed,
  44651. * but doesn't have to be.
  44652. *
  44653. * Instead of the "map" field, it's also possible to have a "url" field
  44654. * specifying a URL to retrieve a source map from, but that's currently
  44655. * unsupported.
  44656. *
  44657. * Here's an example source map, taken from the source map spec[0], but
  44658. * modified to omit a section which uses the "url" field.
  44659. *
  44660. * {
  44661. * version : 3,
  44662. * file: "app.js",
  44663. * sections: [{
  44664. * offset: {line:100, column:10},
  44665. * map: {
  44666. * version : 3,
  44667. * file: "section.js",
  44668. * sources: ["foo.js", "bar.js"],
  44669. * names: ["src", "maps", "are", "fun"],
  44670. * mappings: "AAAA,E;;ABCDE;"
  44671. * }
  44672. * }],
  44673. * }
  44674. *
  44675. * The second parameter, if given, is a string whose value is the URL
  44676. * at which the source map was found. This URL is used to compute the
  44677. * sources array.
  44678. *
  44679. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  44680. */
  44681. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  44682. var sourceMap = aSourceMap;
  44683. if (typeof aSourceMap === 'string') {
  44684. sourceMap = util.parseSourceMapInput(aSourceMap);
  44685. }
  44686. var version = util.getArg(sourceMap, 'version');
  44687. var sections = util.getArg(sourceMap, 'sections');
  44688. if (version != this._version) {
  44689. throw new Error('Unsupported version: ' + version);
  44690. }
  44691. this._sources = new ArraySet();
  44692. this._names = new ArraySet();
  44693. var lastOffset = {
  44694. line: -1,
  44695. column: 0
  44696. };
  44697. this._sections = sections.map(function (s) {
  44698. if (s.url) {
  44699. // The url field will require support for asynchronicity.
  44700. // See https://github.com/mozilla/source-map/issues/16
  44701. throw new Error('Support for url field in sections not implemented.');
  44702. }
  44703. var offset = util.getArg(s, 'offset');
  44704. var offsetLine = util.getArg(offset, 'line');
  44705. var offsetColumn = util.getArg(offset, 'column');
  44706. if (offsetLine < lastOffset.line ||
  44707. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  44708. throw new Error('Section offsets must be ordered and non-overlapping.');
  44709. }
  44710. lastOffset = offset;
  44711. return {
  44712. generatedOffset: {
  44713. // The offset fields are 0-based, but we use 1-based indices when
  44714. // encoding/decoding from VLQ.
  44715. generatedLine: offsetLine + 1,
  44716. generatedColumn: offsetColumn + 1
  44717. },
  44718. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  44719. }
  44720. });
  44721. }
  44722. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  44723. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  44724. /**
  44725. * The version of the source mapping spec that we are consuming.
  44726. */
  44727. IndexedSourceMapConsumer.prototype._version = 3;
  44728. /**
  44729. * The list of original sources.
  44730. */
  44731. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  44732. get: function () {
  44733. var sources = [];
  44734. for (var i = 0; i < this._sections.length; i++) {
  44735. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  44736. sources.push(this._sections[i].consumer.sources[j]);
  44737. }
  44738. }
  44739. return sources;
  44740. }
  44741. });
  44742. /**
  44743. * Returns the original source, line, and column information for the generated
  44744. * source's line and column positions provided. The only argument is an object
  44745. * with the following properties:
  44746. *
  44747. * - line: The line number in the generated source. The line number
  44748. * is 1-based.
  44749. * - column: The column number in the generated source. The column
  44750. * number is 0-based.
  44751. *
  44752. * and an object is returned with the following properties:
  44753. *
  44754. * - source: The original source file, or null.
  44755. * - line: The line number in the original source, or null. The
  44756. * line number is 1-based.
  44757. * - column: The column number in the original source, or null. The
  44758. * column number is 0-based.
  44759. * - name: The original identifier, or null.
  44760. */
  44761. IndexedSourceMapConsumer.prototype.originalPositionFor =
  44762. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  44763. var needle = {
  44764. generatedLine: util.getArg(aArgs, 'line'),
  44765. generatedColumn: util.getArg(aArgs, 'column')
  44766. };
  44767. // Find the section containing the generated position we're trying to map
  44768. // to an original position.
  44769. var sectionIndex = binarySearch.search(needle, this._sections,
  44770. function(needle, section) {
  44771. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  44772. if (cmp) {
  44773. return cmp;
  44774. }
  44775. return (needle.generatedColumn -
  44776. section.generatedOffset.generatedColumn);
  44777. });
  44778. var section = this._sections[sectionIndex];
  44779. if (!section) {
  44780. return {
  44781. source: null,
  44782. line: null,
  44783. column: null,
  44784. name: null
  44785. };
  44786. }
  44787. return section.consumer.originalPositionFor({
  44788. line: needle.generatedLine -
  44789. (section.generatedOffset.generatedLine - 1),
  44790. column: needle.generatedColumn -
  44791. (section.generatedOffset.generatedLine === needle.generatedLine
  44792. ? section.generatedOffset.generatedColumn - 1
  44793. : 0),
  44794. bias: aArgs.bias
  44795. });
  44796. };
  44797. /**
  44798. * Return true if we have the source content for every source in the source
  44799. * map, false otherwise.
  44800. */
  44801. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  44802. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  44803. return this._sections.every(function (s) {
  44804. return s.consumer.hasContentsOfAllSources();
  44805. });
  44806. };
  44807. /**
  44808. * Returns the original source content. The only argument is the url of the
  44809. * original source file. Returns null if no original source content is
  44810. * available.
  44811. */
  44812. IndexedSourceMapConsumer.prototype.sourceContentFor =
  44813. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  44814. for (var i = 0; i < this._sections.length; i++) {
  44815. var section = this._sections[i];
  44816. var content = section.consumer.sourceContentFor(aSource, true);
  44817. if (content) {
  44818. return content;
  44819. }
  44820. }
  44821. if (nullOnMissing) {
  44822. return null;
  44823. }
  44824. else {
  44825. throw new Error('"' + aSource + '" is not in the SourceMap.');
  44826. }
  44827. };
  44828. /**
  44829. * Returns the generated line and column information for the original source,
  44830. * line, and column positions provided. The only argument is an object with
  44831. * the following properties:
  44832. *
  44833. * - source: The filename of the original source.
  44834. * - line: The line number in the original source. The line number
  44835. * is 1-based.
  44836. * - column: The column number in the original source. The column
  44837. * number is 0-based.
  44838. *
  44839. * and an object is returned with the following properties:
  44840. *
  44841. * - line: The line number in the generated source, or null. The
  44842. * line number is 1-based.
  44843. * - column: The column number in the generated source, or null.
  44844. * The column number is 0-based.
  44845. */
  44846. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  44847. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  44848. for (var i = 0; i < this._sections.length; i++) {
  44849. var section = this._sections[i];
  44850. // Only consider this section if the requested source is in the list of
  44851. // sources of the consumer.
  44852. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  44853. continue;
  44854. }
  44855. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  44856. if (generatedPosition) {
  44857. var ret = {
  44858. line: generatedPosition.line +
  44859. (section.generatedOffset.generatedLine - 1),
  44860. column: generatedPosition.column +
  44861. (section.generatedOffset.generatedLine === generatedPosition.line
  44862. ? section.generatedOffset.generatedColumn - 1
  44863. : 0)
  44864. };
  44865. return ret;
  44866. }
  44867. }
  44868. return {
  44869. line: null,
  44870. column: null
  44871. };
  44872. };
  44873. /**
  44874. * Parse the mappings in a string in to a data structure which we can easily
  44875. * query (the ordered arrays in the `this.__generatedMappings` and
  44876. * `this.__originalMappings` properties).
  44877. */
  44878. IndexedSourceMapConsumer.prototype._parseMappings =
  44879. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  44880. this.__generatedMappings = [];
  44881. this.__originalMappings = [];
  44882. for (var i = 0; i < this._sections.length; i++) {
  44883. var section = this._sections[i];
  44884. var sectionMappings = section.consumer._generatedMappings;
  44885. for (var j = 0; j < sectionMappings.length; j++) {
  44886. var mapping = sectionMappings[j];
  44887. var source = section.consumer._sources.at(mapping.source);
  44888. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  44889. this._sources.add(source);
  44890. source = this._sources.indexOf(source);
  44891. var name = null;
  44892. if (mapping.name) {
  44893. name = section.consumer._names.at(mapping.name);
  44894. this._names.add(name);
  44895. name = this._names.indexOf(name);
  44896. }
  44897. // The mappings coming from the consumer for the section have
  44898. // generated positions relative to the start of the section, so we
  44899. // need to offset them to be relative to the start of the concatenated
  44900. // generated file.
  44901. var adjustedMapping = {
  44902. source: source,
  44903. generatedLine: mapping.generatedLine +
  44904. (section.generatedOffset.generatedLine - 1),
  44905. generatedColumn: mapping.generatedColumn +
  44906. (section.generatedOffset.generatedLine === mapping.generatedLine
  44907. ? section.generatedOffset.generatedColumn - 1
  44908. : 0),
  44909. originalLine: mapping.originalLine,
  44910. originalColumn: mapping.originalColumn,
  44911. name: name
  44912. };
  44913. this.__generatedMappings.push(adjustedMapping);
  44914. if (typeof adjustedMapping.originalLine === 'number') {
  44915. this.__originalMappings.push(adjustedMapping);
  44916. }
  44917. }
  44918. }
  44919. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  44920. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  44921. };
  44922. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  44923. return sourceMapConsumer;
  44924. }
  44925. var sourceNode = {};
  44926. /* -*- Mode: js; js-indent-level: 2; -*- */
  44927. var hasRequiredSourceNode;
  44928. function requireSourceNode () {
  44929. if (hasRequiredSourceNode) return sourceNode;
  44930. hasRequiredSourceNode = 1;
  44931. /*
  44932. * Copyright 2011 Mozilla Foundation and contributors
  44933. * Licensed under the New BSD license. See LICENSE or:
  44934. * http://opensource.org/licenses/BSD-3-Clause
  44935. */
  44936. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  44937. var util = /*@__PURE__*/ requireUtil();
  44938. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  44939. // operating systems these days (capturing the result).
  44940. var REGEX_NEWLINE = /(\r?\n)/;
  44941. // Newline character code for charCodeAt() comparisons
  44942. var NEWLINE_CODE = 10;
  44943. // Private symbol for identifying `SourceNode`s when multiple versions of
  44944. // the source-map library are loaded. This MUST NOT CHANGE across
  44945. // versions!
  44946. var isSourceNode = "$$$isSourceNode$$$";
  44947. /**
  44948. * SourceNodes provide a way to abstract over interpolating/concatenating
  44949. * snippets of generated JavaScript source code while maintaining the line and
  44950. * column information associated with the original source code.
  44951. *
  44952. * @param aLine The original line number.
  44953. * @param aColumn The original column number.
  44954. * @param aSource The original source's filename.
  44955. * @param aChunks Optional. An array of strings which are snippets of
  44956. * generated JS, or other SourceNodes.
  44957. * @param aName The original identifier.
  44958. */
  44959. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  44960. this.children = [];
  44961. this.sourceContents = {};
  44962. this.line = aLine == null ? null : aLine;
  44963. this.column = aColumn == null ? null : aColumn;
  44964. this.source = aSource == null ? null : aSource;
  44965. this.name = aName == null ? null : aName;
  44966. this[isSourceNode] = true;
  44967. if (aChunks != null) this.add(aChunks);
  44968. }
  44969. /**
  44970. * Creates a SourceNode from generated code and a SourceMapConsumer.
  44971. *
  44972. * @param aGeneratedCode The generated code
  44973. * @param aSourceMapConsumer The SourceMap for the generated code
  44974. * @param aRelativePath Optional. The path that relative sources in the
  44975. * SourceMapConsumer should be relative to.
  44976. */
  44977. SourceNode.fromStringWithSourceMap =
  44978. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  44979. // The SourceNode we want to fill with the generated code
  44980. // and the SourceMap
  44981. var node = new SourceNode();
  44982. // All even indices of this array are one line of the generated code,
  44983. // while all odd indices are the newlines between two adjacent lines
  44984. // (since `REGEX_NEWLINE` captures its match).
  44985. // Processed fragments are accessed by calling `shiftNextLine`.
  44986. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  44987. var remainingLinesIndex = 0;
  44988. var shiftNextLine = function() {
  44989. var lineContents = getNextLine();
  44990. // The last line of a file might not have a newline.
  44991. var newLine = getNextLine() || "";
  44992. return lineContents + newLine;
  44993. function getNextLine() {
  44994. return remainingLinesIndex < remainingLines.length ?
  44995. remainingLines[remainingLinesIndex++] : undefined;
  44996. }
  44997. };
  44998. // We need to remember the position of "remainingLines"
  44999. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  45000. // The generate SourceNodes we need a code range.
  45001. // To extract it current and last mapping is used.
  45002. // Here we store the last mapping.
  45003. var lastMapping = null;
  45004. aSourceMapConsumer.eachMapping(function (mapping) {
  45005. if (lastMapping !== null) {
  45006. // We add the code from "lastMapping" to "mapping":
  45007. // First check if there is a new line in between.
  45008. if (lastGeneratedLine < mapping.generatedLine) {
  45009. // Associate first line with "lastMapping"
  45010. addMappingWithCode(lastMapping, shiftNextLine());
  45011. lastGeneratedLine++;
  45012. lastGeneratedColumn = 0;
  45013. // The remaining code is added without mapping
  45014. } else {
  45015. // There is no new line in between.
  45016. // Associate the code between "lastGeneratedColumn" and
  45017. // "mapping.generatedColumn" with "lastMapping"
  45018. var nextLine = remainingLines[remainingLinesIndex] || '';
  45019. var code = nextLine.substr(0, mapping.generatedColumn -
  45020. lastGeneratedColumn);
  45021. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  45022. lastGeneratedColumn);
  45023. lastGeneratedColumn = mapping.generatedColumn;
  45024. addMappingWithCode(lastMapping, code);
  45025. // No more remaining code, continue
  45026. lastMapping = mapping;
  45027. return;
  45028. }
  45029. }
  45030. // We add the generated code until the first mapping
  45031. // to the SourceNode without any mapping.
  45032. // Each line is added as separate string.
  45033. while (lastGeneratedLine < mapping.generatedLine) {
  45034. node.add(shiftNextLine());
  45035. lastGeneratedLine++;
  45036. }
  45037. if (lastGeneratedColumn < mapping.generatedColumn) {
  45038. var nextLine = remainingLines[remainingLinesIndex] || '';
  45039. node.add(nextLine.substr(0, mapping.generatedColumn));
  45040. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  45041. lastGeneratedColumn = mapping.generatedColumn;
  45042. }
  45043. lastMapping = mapping;
  45044. }, this);
  45045. // We have processed all mappings.
  45046. if (remainingLinesIndex < remainingLines.length) {
  45047. if (lastMapping) {
  45048. // Associate the remaining code in the current line with "lastMapping"
  45049. addMappingWithCode(lastMapping, shiftNextLine());
  45050. }
  45051. // and add the remaining lines without any mapping
  45052. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  45053. }
  45054. // Copy sourcesContent into SourceNode
  45055. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  45056. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  45057. if (content != null) {
  45058. if (aRelativePath != null) {
  45059. sourceFile = util.join(aRelativePath, sourceFile);
  45060. }
  45061. node.setSourceContent(sourceFile, content);
  45062. }
  45063. });
  45064. return node;
  45065. function addMappingWithCode(mapping, code) {
  45066. if (mapping === null || mapping.source === undefined) {
  45067. node.add(code);
  45068. } else {
  45069. var source = aRelativePath
  45070. ? util.join(aRelativePath, mapping.source)
  45071. : mapping.source;
  45072. node.add(new SourceNode(mapping.originalLine,
  45073. mapping.originalColumn,
  45074. source,
  45075. code,
  45076. mapping.name));
  45077. }
  45078. }
  45079. };
  45080. /**
  45081. * Add a chunk of generated JS to this source node.
  45082. *
  45083. * @param aChunk A string snippet of generated JS code, another instance of
  45084. * SourceNode, or an array where each member is one of those things.
  45085. */
  45086. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  45087. if (Array.isArray(aChunk)) {
  45088. aChunk.forEach(function (chunk) {
  45089. this.add(chunk);
  45090. }, this);
  45091. }
  45092. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  45093. if (aChunk) {
  45094. this.children.push(aChunk);
  45095. }
  45096. }
  45097. else {
  45098. throw new TypeError(
  45099. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  45100. );
  45101. }
  45102. return this;
  45103. };
  45104. /**
  45105. * Add a chunk of generated JS to the beginning of this source node.
  45106. *
  45107. * @param aChunk A string snippet of generated JS code, another instance of
  45108. * SourceNode, or an array where each member is one of those things.
  45109. */
  45110. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  45111. if (Array.isArray(aChunk)) {
  45112. for (var i = aChunk.length-1; i >= 0; i--) {
  45113. this.prepend(aChunk[i]);
  45114. }
  45115. }
  45116. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  45117. this.children.unshift(aChunk);
  45118. }
  45119. else {
  45120. throw new TypeError(
  45121. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  45122. );
  45123. }
  45124. return this;
  45125. };
  45126. /**
  45127. * Walk over the tree of JS snippets in this node and its children. The
  45128. * walking function is called once for each snippet of JS and is passed that
  45129. * snippet and the its original associated source's line/column location.
  45130. *
  45131. * @param aFn The traversal function.
  45132. */
  45133. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  45134. var chunk;
  45135. for (var i = 0, len = this.children.length; i < len; i++) {
  45136. chunk = this.children[i];
  45137. if (chunk[isSourceNode]) {
  45138. chunk.walk(aFn);
  45139. }
  45140. else {
  45141. if (chunk !== '') {
  45142. aFn(chunk, { source: this.source,
  45143. line: this.line,
  45144. column: this.column,
  45145. name: this.name });
  45146. }
  45147. }
  45148. }
  45149. };
  45150. /**
  45151. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  45152. * each of `this.children`.
  45153. *
  45154. * @param aSep The separator.
  45155. */
  45156. SourceNode.prototype.join = function SourceNode_join(aSep) {
  45157. var newChildren;
  45158. var i;
  45159. var len = this.children.length;
  45160. if (len > 0) {
  45161. newChildren = [];
  45162. for (i = 0; i < len-1; i++) {
  45163. newChildren.push(this.children[i]);
  45164. newChildren.push(aSep);
  45165. }
  45166. newChildren.push(this.children[i]);
  45167. this.children = newChildren;
  45168. }
  45169. return this;
  45170. };
  45171. /**
  45172. * Call String.prototype.replace on the very right-most source snippet. Useful
  45173. * for trimming whitespace from the end of a source node, etc.
  45174. *
  45175. * @param aPattern The pattern to replace.
  45176. * @param aReplacement The thing to replace the pattern with.
  45177. */
  45178. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  45179. var lastChild = this.children[this.children.length - 1];
  45180. if (lastChild[isSourceNode]) {
  45181. lastChild.replaceRight(aPattern, aReplacement);
  45182. }
  45183. else if (typeof lastChild === 'string') {
  45184. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  45185. }
  45186. else {
  45187. this.children.push(''.replace(aPattern, aReplacement));
  45188. }
  45189. return this;
  45190. };
  45191. /**
  45192. * Set the source content for a source file. This will be added to the SourceMapGenerator
  45193. * in the sourcesContent field.
  45194. *
  45195. * @param aSourceFile The filename of the source file
  45196. * @param aSourceContent The content of the source file
  45197. */
  45198. SourceNode.prototype.setSourceContent =
  45199. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  45200. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  45201. };
  45202. /**
  45203. * Walk over the tree of SourceNodes. The walking function is called for each
  45204. * source file content and is passed the filename and source content.
  45205. *
  45206. * @param aFn The traversal function.
  45207. */
  45208. SourceNode.prototype.walkSourceContents =
  45209. function SourceNode_walkSourceContents(aFn) {
  45210. for (var i = 0, len = this.children.length; i < len; i++) {
  45211. if (this.children[i][isSourceNode]) {
  45212. this.children[i].walkSourceContents(aFn);
  45213. }
  45214. }
  45215. var sources = Object.keys(this.sourceContents);
  45216. for (var i = 0, len = sources.length; i < len; i++) {
  45217. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  45218. }
  45219. };
  45220. /**
  45221. * Return the string representation of this source node. Walks over the tree
  45222. * and concatenates all the various snippets together to one string.
  45223. */
  45224. SourceNode.prototype.toString = function SourceNode_toString() {
  45225. var str = "";
  45226. this.walk(function (chunk) {
  45227. str += chunk;
  45228. });
  45229. return str;
  45230. };
  45231. /**
  45232. * Returns the string representation of this source node along with a source
  45233. * map.
  45234. */
  45235. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  45236. var generated = {
  45237. code: "",
  45238. line: 1,
  45239. column: 0
  45240. };
  45241. var map = new SourceMapGenerator(aArgs);
  45242. var sourceMappingActive = false;
  45243. var lastOriginalSource = null;
  45244. var lastOriginalLine = null;
  45245. var lastOriginalColumn = null;
  45246. var lastOriginalName = null;
  45247. this.walk(function (chunk, original) {
  45248. generated.code += chunk;
  45249. if (original.source !== null
  45250. && original.line !== null
  45251. && original.column !== null) {
  45252. if(lastOriginalSource !== original.source
  45253. || lastOriginalLine !== original.line
  45254. || lastOriginalColumn !== original.column
  45255. || lastOriginalName !== original.name) {
  45256. map.addMapping({
  45257. source: original.source,
  45258. original: {
  45259. line: original.line,
  45260. column: original.column
  45261. },
  45262. generated: {
  45263. line: generated.line,
  45264. column: generated.column
  45265. },
  45266. name: original.name
  45267. });
  45268. }
  45269. lastOriginalSource = original.source;
  45270. lastOriginalLine = original.line;
  45271. lastOriginalColumn = original.column;
  45272. lastOriginalName = original.name;
  45273. sourceMappingActive = true;
  45274. } else if (sourceMappingActive) {
  45275. map.addMapping({
  45276. generated: {
  45277. line: generated.line,
  45278. column: generated.column
  45279. }
  45280. });
  45281. lastOriginalSource = null;
  45282. sourceMappingActive = false;
  45283. }
  45284. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  45285. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  45286. generated.line++;
  45287. generated.column = 0;
  45288. // Mappings end at eol
  45289. if (idx + 1 === length) {
  45290. lastOriginalSource = null;
  45291. sourceMappingActive = false;
  45292. } else if (sourceMappingActive) {
  45293. map.addMapping({
  45294. source: original.source,
  45295. original: {
  45296. line: original.line,
  45297. column: original.column
  45298. },
  45299. generated: {
  45300. line: generated.line,
  45301. column: generated.column
  45302. },
  45303. name: original.name
  45304. });
  45305. }
  45306. } else {
  45307. generated.column++;
  45308. }
  45309. }
  45310. });
  45311. this.walkSourceContents(function (sourceFile, sourceContent) {
  45312. map.setSourceContent(sourceFile, sourceContent);
  45313. });
  45314. return { code: generated.code, map: map };
  45315. };
  45316. sourceNode.SourceNode = SourceNode;
  45317. return sourceNode;
  45318. }
  45319. /*
  45320. * Copyright 2009-2011 Mozilla Foundation and contributors
  45321. * Licensed under the New BSD license. See LICENSE.txt or:
  45322. * http://opensource.org/licenses/BSD-3-Clause
  45323. */
  45324. var hasRequiredSourceMap;
  45325. function requireSourceMap () {
  45326. if (hasRequiredSourceMap) return sourceMap;
  45327. hasRequiredSourceMap = 1;
  45328. sourceMap.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  45329. sourceMap.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer().SourceMapConsumer;
  45330. sourceMap.SourceNode = /*@__PURE__*/ requireSourceNode().SourceNode;
  45331. return sourceMap;
  45332. }
  45333. var mergeSourceMap;
  45334. var hasRequiredMergeSourceMap;
  45335. function requireMergeSourceMap () {
  45336. if (hasRequiredMergeSourceMap) return mergeSourceMap;
  45337. hasRequiredMergeSourceMap = 1;
  45338. var sourceMap = /*@__PURE__*/ requireSourceMap();
  45339. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  45340. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  45341. mergeSourceMap = merge;
  45342. /**
  45343. * Merge old source map and new source map and return merged.
  45344. * If old or new source map value is falsy, return another one as it is.
  45345. *
  45346. * @param {object|string} [oldMap] old source map object
  45347. * @param {object|string} [newmap] new source map object
  45348. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  45349. */
  45350. function merge(oldMap, newMap) {
  45351. if (!oldMap) return newMap
  45352. if (!newMap) return oldMap
  45353. var oldMapConsumer = new SourceMapConsumer(oldMap);
  45354. var newMapConsumer = new SourceMapConsumer(newMap);
  45355. var mergedMapGenerator = new SourceMapGenerator();
  45356. // iterate on new map and overwrite original position of new map with one of old map
  45357. newMapConsumer.eachMapping(function(m) {
  45358. // pass when `originalLine` is null.
  45359. // It occurs in case that the node does not have origin in original code.
  45360. if (m.originalLine == null) return
  45361. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  45362. line: m.originalLine,
  45363. column: m.originalColumn
  45364. });
  45365. if (origPosInOldMap.source == null) return
  45366. mergedMapGenerator.addMapping({
  45367. original: {
  45368. line: origPosInOldMap.line,
  45369. column: origPosInOldMap.column
  45370. },
  45371. generated: {
  45372. line: m.generatedLine,
  45373. column: m.generatedColumn
  45374. },
  45375. source: origPosInOldMap.source,
  45376. name: origPosInOldMap.name
  45377. });
  45378. });
  45379. var consumers = [oldMapConsumer, newMapConsumer];
  45380. consumers.forEach(function(consumer) {
  45381. consumer.sources.forEach(function(sourceFile) {
  45382. mergedMapGenerator._sources.add(sourceFile);
  45383. var sourceContent = consumer.sourceContentFor(sourceFile);
  45384. if (sourceContent != null) {
  45385. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  45386. }
  45387. });
  45388. });
  45389. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  45390. mergedMapGenerator._file = oldMap.file;
  45391. return JSON.parse(mergedMapGenerator.toString())
  45392. }
  45393. return mergeSourceMap;
  45394. }
  45395. var mergeSourceMapExports = /*@__PURE__*/ requireMergeSourceMap();
  45396. var merge = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMapExports);
  45397. var __defProp$5 = Object.defineProperty;
  45398. var __defProps$4 = Object.defineProperties;
  45399. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  45400. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  45401. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  45402. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  45403. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45404. var __spreadValues$5 = (a, b) => {
  45405. for (var prop in b || (b = {}))
  45406. if (__hasOwnProp$5.call(b, prop))
  45407. __defNormalProp$5(a, prop, b[prop]);
  45408. if (__getOwnPropSymbols$5)
  45409. for (var prop of __getOwnPropSymbols$5(b)) {
  45410. if (__propIsEnum$5.call(b, prop))
  45411. __defNormalProp$5(a, prop, b[prop]);
  45412. }
  45413. return a;
  45414. };
  45415. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  45416. const scss = (source, map, options, load = require) => {
  45417. const nodeSass = load("sass");
  45418. const { compileString, renderSync } = nodeSass;
  45419. const data = getSource(source, options.filename, options.additionalData);
  45420. let css;
  45421. let dependencies;
  45422. let sourceMap;
  45423. try {
  45424. if (compileString) {
  45425. const { pathToFileURL, fileURLToPath } = load("url");
  45426. const result = compileString(data, __spreadProps$4(__spreadValues$5({}, options), {
  45427. url: pathToFileURL(options.filename),
  45428. sourceMap: !!map
  45429. }));
  45430. css = result.css;
  45431. dependencies = result.loadedUrls.map((url) => fileURLToPath(url));
  45432. sourceMap = map ? result.sourceMap : void 0;
  45433. } else {
  45434. const result = renderSync(__spreadProps$4(__spreadValues$5({}, options), {
  45435. data,
  45436. file: options.filename,
  45437. outFile: options.filename,
  45438. sourceMap: !!map
  45439. }));
  45440. css = result.css.toString();
  45441. dependencies = result.stats.includedFiles;
  45442. sourceMap = map ? JSON.parse(result.map.toString()) : void 0;
  45443. }
  45444. if (map) {
  45445. return {
  45446. code: css,
  45447. errors: [],
  45448. dependencies,
  45449. map: merge(map, sourceMap)
  45450. };
  45451. }
  45452. return { code: css, errors: [], dependencies };
  45453. } catch (e) {
  45454. return { code: "", errors: [e], dependencies: [] };
  45455. }
  45456. };
  45457. const sass = (source, map, options, load) => scss(
  45458. source,
  45459. map,
  45460. __spreadProps$4(__spreadValues$5({}, options), {
  45461. indentedSyntax: true
  45462. }),
  45463. load
  45464. );
  45465. const less = (source, map, options, load = require) => {
  45466. const nodeLess = load("less");
  45467. let result;
  45468. let error = null;
  45469. nodeLess.render(
  45470. getSource(source, options.filename, options.additionalData),
  45471. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  45472. (err, output) => {
  45473. error = err;
  45474. result = output;
  45475. }
  45476. );
  45477. if (error) return { code: "", errors: [error], dependencies: [] };
  45478. const dependencies = result.imports;
  45479. if (map) {
  45480. return {
  45481. code: result.css.toString(),
  45482. map: merge(map, result.map),
  45483. errors: [],
  45484. dependencies
  45485. };
  45486. }
  45487. return {
  45488. code: result.css.toString(),
  45489. errors: [],
  45490. dependencies
  45491. };
  45492. };
  45493. const styl = (source, map, options, load = require) => {
  45494. const nodeStylus = load("stylus");
  45495. try {
  45496. const ref = nodeStylus(source, options);
  45497. if (map) ref.set("sourcemap", { inline: false, comment: false });
  45498. const result = ref.render();
  45499. const dependencies = ref.deps();
  45500. if (map) {
  45501. return {
  45502. code: result,
  45503. map: merge(map, ref.sourcemap),
  45504. errors: [],
  45505. dependencies
  45506. };
  45507. }
  45508. return { code: result, errors: [], dependencies };
  45509. } catch (e) {
  45510. return { code: "", errors: [e], dependencies: [] };
  45511. }
  45512. };
  45513. function getSource(source, filename, additionalData) {
  45514. if (!additionalData) return source;
  45515. if (isFunction$1(additionalData)) {
  45516. return additionalData(source, filename);
  45517. }
  45518. return additionalData + source;
  45519. }
  45520. const processors = {
  45521. less,
  45522. sass,
  45523. scss,
  45524. styl,
  45525. stylus: styl
  45526. };
  45527. var __defProp$4 = Object.defineProperty;
  45528. var __defProps$3 = Object.defineProperties;
  45529. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  45530. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  45531. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  45532. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  45533. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45534. var __spreadValues$4 = (a, b) => {
  45535. for (var prop in b || (b = {}))
  45536. if (__hasOwnProp$4.call(b, prop))
  45537. __defNormalProp$4(a, prop, b[prop]);
  45538. if (__getOwnPropSymbols$4)
  45539. for (var prop of __getOwnPropSymbols$4(b)) {
  45540. if (__propIsEnum$4.call(b, prop))
  45541. __defNormalProp$4(a, prop, b[prop]);
  45542. }
  45543. return a;
  45544. };
  45545. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  45546. function compileStyle(options) {
  45547. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  45548. isAsync: false
  45549. }));
  45550. }
  45551. function compileStyleAsync(options) {
  45552. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  45553. isAsync: true
  45554. }));
  45555. }
  45556. function doCompileStyle(options) {
  45557. const {
  45558. filename,
  45559. id,
  45560. scoped = false,
  45561. trim = true,
  45562. isProd = false,
  45563. modules = false,
  45564. modulesOptions = {},
  45565. preprocessLang,
  45566. postcssOptions,
  45567. postcssPlugins
  45568. } = options;
  45569. const preprocessor = preprocessLang && processors[preprocessLang];
  45570. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  45571. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  45572. const source = preProcessedSource ? preProcessedSource.code : options.source;
  45573. const shortId = id.replace(/^data-v-/, "");
  45574. const longId = `data-v-${shortId}`;
  45575. const plugins = (postcssPlugins || []).slice();
  45576. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  45577. if (trim) {
  45578. plugins.push(trimPlugin());
  45579. }
  45580. if (scoped) {
  45581. plugins.push(scopedPlugin(longId));
  45582. }
  45583. let cssModules;
  45584. if (modules) {
  45585. {
  45586. throw new Error(
  45587. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  45588. );
  45589. }
  45590. }
  45591. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  45592. to: filename,
  45593. from: filename
  45594. });
  45595. if (map) {
  45596. postCSSOptions.map = {
  45597. inline: false,
  45598. annotation: false,
  45599. prev: map
  45600. };
  45601. }
  45602. let result;
  45603. let code;
  45604. let outMap;
  45605. const dependencies = new Set(
  45606. preProcessedSource ? preProcessedSource.dependencies : []
  45607. );
  45608. dependencies.delete(filename);
  45609. const errors = [];
  45610. if (preProcessedSource && preProcessedSource.errors.length) {
  45611. errors.push(...preProcessedSource.errors);
  45612. }
  45613. const recordPlainCssDependencies = (messages) => {
  45614. messages.forEach((msg) => {
  45615. if (msg.type === "dependency") {
  45616. dependencies.add(msg.file);
  45617. }
  45618. });
  45619. return dependencies;
  45620. };
  45621. try {
  45622. result = postcss(plugins).process(source, postCSSOptions);
  45623. if (options.isAsync) {
  45624. return result.then((result2) => ({
  45625. code: result2.css || "",
  45626. map: result2.map && result2.map.toJSON(),
  45627. errors,
  45628. modules: cssModules,
  45629. rawResult: result2,
  45630. dependencies: recordPlainCssDependencies(result2.messages)
  45631. })).catch((error) => ({
  45632. code: "",
  45633. map: void 0,
  45634. errors: [...errors, error],
  45635. rawResult: void 0,
  45636. dependencies
  45637. }));
  45638. }
  45639. recordPlainCssDependencies(result.messages);
  45640. code = result.css;
  45641. outMap = result.map;
  45642. } catch (e) {
  45643. errors.push(e);
  45644. }
  45645. return {
  45646. code: code || ``,
  45647. map: outMap && outMap.toJSON(),
  45648. errors,
  45649. rawResult: result,
  45650. dependencies
  45651. };
  45652. }
  45653. function preprocess(options, preprocessor) {
  45654. if (!options.preprocessCustomRequire) {
  45655. throw new Error(
  45656. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  45657. );
  45658. }
  45659. return preprocessor(
  45660. options.source,
  45661. options.inMap || options.map,
  45662. __spreadValues$4({
  45663. filename: options.filename
  45664. }, options.preprocessOptions),
  45665. options.preprocessCustomRequire
  45666. );
  45667. }
  45668. const UNKNOWN_TYPE = "Unknown";
  45669. function resolveObjectKey(node, computed) {
  45670. switch (node.type) {
  45671. case "StringLiteral":
  45672. case "NumericLiteral":
  45673. return String(node.value);
  45674. case "Identifier":
  45675. if (!computed) return node.name;
  45676. }
  45677. return void 0;
  45678. }
  45679. function concatStrings(strs) {
  45680. return strs.filter((s) => !!s).join(", ");
  45681. }
  45682. function isLiteralNode(node) {
  45683. return node.type.endsWith("Literal");
  45684. }
  45685. function isCallOf(node, test) {
  45686. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  45687. }
  45688. function toRuntimeTypeString(types) {
  45689. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  45690. }
  45691. function getImportedName(specifier) {
  45692. if (specifier.type === "ImportSpecifier")
  45693. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  45694. else if (specifier.type === "ImportNamespaceSpecifier") return "*";
  45695. return "default";
  45696. }
  45697. function getId(node) {
  45698. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  45699. }
  45700. const normalize = (path.posix || path).normalize;
  45701. const windowsSlashRE = /\\/g;
  45702. function normalizePath(p) {
  45703. return normalize(p.replace(windowsSlashRE, "/"));
  45704. }
  45705. const joinPaths = (path.posix || path).join;
  45706. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  45707. function getEscapedPropName(key) {
  45708. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  45709. }
  45710. function analyzeScriptBindings(ast) {
  45711. for (const node of ast) {
  45712. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  45713. return analyzeBindingsFromOptions(node.declaration);
  45714. }
  45715. }
  45716. return {};
  45717. }
  45718. function analyzeBindingsFromOptions(node) {
  45719. const bindings = {};
  45720. Object.defineProperty(bindings, "__isScriptSetup", {
  45721. enumerable: false,
  45722. value: false
  45723. });
  45724. for (const property of node.properties) {
  45725. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  45726. if (property.key.name === "props") {
  45727. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  45728. bindings[key] = "props";
  45729. }
  45730. } else if (property.key.name === "inject") {
  45731. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  45732. bindings[key] = "options";
  45733. }
  45734. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  45735. for (const key of getObjectExpressionKeys(property.value)) {
  45736. bindings[key] = "options";
  45737. }
  45738. }
  45739. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  45740. for (const bodyItem of property.body.body) {
  45741. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  45742. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  45743. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  45744. }
  45745. }
  45746. }
  45747. }
  45748. }
  45749. return bindings;
  45750. }
  45751. function getObjectExpressionKeys(node) {
  45752. const keys = [];
  45753. for (const prop of node.properties) {
  45754. if (prop.type === "SpreadElement") continue;
  45755. const key = resolveObjectKey(prop.key, prop.computed);
  45756. if (key) keys.push(String(key));
  45757. }
  45758. return keys;
  45759. }
  45760. function getArrayExpressionKeys(node) {
  45761. const keys = [];
  45762. for (const element of node.elements) {
  45763. if (element && element.type === "StringLiteral") {
  45764. keys.push(element.value);
  45765. }
  45766. }
  45767. return keys;
  45768. }
  45769. function getObjectOrArrayExpressionKeys(value) {
  45770. if (value.type === "ArrayExpression") {
  45771. return getArrayExpressionKeys(value);
  45772. }
  45773. if (value.type === "ObjectExpression") {
  45774. return getObjectExpressionKeys(value);
  45775. }
  45776. return [];
  45777. }
  45778. const comma = ','.charCodeAt(0);
  45779. const semicolon = ';'.charCodeAt(0);
  45780. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  45781. const intToChar = new Uint8Array(64); // 64 possible chars.
  45782. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  45783. for (let i = 0; i < chars.length; i++) {
  45784. const c = chars.charCodeAt(i);
  45785. intToChar[i] = c;
  45786. charToInt[c] = i;
  45787. }
  45788. function encodeInteger(builder, num, relative) {
  45789. let delta = num - relative;
  45790. delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
  45791. do {
  45792. let clamped = delta & 0b011111;
  45793. delta >>>= 5;
  45794. if (delta > 0)
  45795. clamped |= 0b100000;
  45796. builder.write(intToChar[clamped]);
  45797. } while (delta > 0);
  45798. return num;
  45799. }
  45800. const bufLength = 1024 * 16;
  45801. // Provide a fallback for older environments.
  45802. const td = typeof TextDecoder !== 'undefined'
  45803. ? /* #__PURE__ */ new TextDecoder()
  45804. : typeof Buffer !== 'undefined'
  45805. ? {
  45806. decode(buf) {
  45807. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  45808. return out.toString();
  45809. },
  45810. }
  45811. : {
  45812. decode(buf) {
  45813. let out = '';
  45814. for (let i = 0; i < buf.length; i++) {
  45815. out += String.fromCharCode(buf[i]);
  45816. }
  45817. return out;
  45818. },
  45819. };
  45820. class StringWriter {
  45821. constructor() {
  45822. this.pos = 0;
  45823. this.out = '';
  45824. this.buffer = new Uint8Array(bufLength);
  45825. }
  45826. write(v) {
  45827. const { buffer } = this;
  45828. buffer[this.pos++] = v;
  45829. if (this.pos === bufLength) {
  45830. this.out += td.decode(buffer);
  45831. this.pos = 0;
  45832. }
  45833. }
  45834. flush() {
  45835. const { buffer, out, pos } = this;
  45836. return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
  45837. }
  45838. }
  45839. function encode(decoded) {
  45840. const writer = new StringWriter();
  45841. let sourcesIndex = 0;
  45842. let sourceLine = 0;
  45843. let sourceColumn = 0;
  45844. let namesIndex = 0;
  45845. for (let i = 0; i < decoded.length; i++) {
  45846. const line = decoded[i];
  45847. if (i > 0)
  45848. writer.write(semicolon);
  45849. if (line.length === 0)
  45850. continue;
  45851. let genColumn = 0;
  45852. for (let j = 0; j < line.length; j++) {
  45853. const segment = line[j];
  45854. if (j > 0)
  45855. writer.write(comma);
  45856. genColumn = encodeInteger(writer, segment[0], genColumn);
  45857. if (segment.length === 1)
  45858. continue;
  45859. sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
  45860. sourceLine = encodeInteger(writer, segment[2], sourceLine);
  45861. sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
  45862. if (segment.length === 4)
  45863. continue;
  45864. namesIndex = encodeInteger(writer, segment[4], namesIndex);
  45865. }
  45866. }
  45867. return writer.flush();
  45868. }
  45869. class BitSet {
  45870. constructor(arg) {
  45871. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  45872. }
  45873. add(n) {
  45874. this.bits[n >> 5] |= 1 << (n & 31);
  45875. }
  45876. has(n) {
  45877. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  45878. }
  45879. }
  45880. class Chunk {
  45881. constructor(start, end, content) {
  45882. this.start = start;
  45883. this.end = end;
  45884. this.original = content;
  45885. this.intro = '';
  45886. this.outro = '';
  45887. this.content = content;
  45888. this.storeName = false;
  45889. this.edited = false;
  45890. {
  45891. this.previous = null;
  45892. this.next = null;
  45893. }
  45894. }
  45895. appendLeft(content) {
  45896. this.outro += content;
  45897. }
  45898. appendRight(content) {
  45899. this.intro = this.intro + content;
  45900. }
  45901. clone() {
  45902. const chunk = new Chunk(this.start, this.end, this.original);
  45903. chunk.intro = this.intro;
  45904. chunk.outro = this.outro;
  45905. chunk.content = this.content;
  45906. chunk.storeName = this.storeName;
  45907. chunk.edited = this.edited;
  45908. return chunk;
  45909. }
  45910. contains(index) {
  45911. return this.start < index && index < this.end;
  45912. }
  45913. eachNext(fn) {
  45914. let chunk = this;
  45915. while (chunk) {
  45916. fn(chunk);
  45917. chunk = chunk.next;
  45918. }
  45919. }
  45920. eachPrevious(fn) {
  45921. let chunk = this;
  45922. while (chunk) {
  45923. fn(chunk);
  45924. chunk = chunk.previous;
  45925. }
  45926. }
  45927. edit(content, storeName, contentOnly) {
  45928. this.content = content;
  45929. if (!contentOnly) {
  45930. this.intro = '';
  45931. this.outro = '';
  45932. }
  45933. this.storeName = storeName;
  45934. this.edited = true;
  45935. return this;
  45936. }
  45937. prependLeft(content) {
  45938. this.outro = content + this.outro;
  45939. }
  45940. prependRight(content) {
  45941. this.intro = content + this.intro;
  45942. }
  45943. reset() {
  45944. this.intro = '';
  45945. this.outro = '';
  45946. if (this.edited) {
  45947. this.content = this.original;
  45948. this.storeName = false;
  45949. this.edited = false;
  45950. }
  45951. }
  45952. split(index) {
  45953. const sliceIndex = index - this.start;
  45954. const originalBefore = this.original.slice(0, sliceIndex);
  45955. const originalAfter = this.original.slice(sliceIndex);
  45956. this.original = originalBefore;
  45957. const newChunk = new Chunk(index, this.end, originalAfter);
  45958. newChunk.outro = this.outro;
  45959. this.outro = '';
  45960. this.end = index;
  45961. if (this.edited) {
  45962. // after split we should save the edit content record into the correct chunk
  45963. // to make sure sourcemap correct
  45964. // For example:
  45965. // ' test'.trim()
  45966. // split -> ' ' + 'test'
  45967. // ✔️ edit -> '' + 'test'
  45968. // ✖️ edit -> 'test' + ''
  45969. // TODO is this block necessary?...
  45970. newChunk.edit('', false);
  45971. this.content = '';
  45972. } else {
  45973. this.content = originalBefore;
  45974. }
  45975. newChunk.next = this.next;
  45976. if (newChunk.next) newChunk.next.previous = newChunk;
  45977. newChunk.previous = this;
  45978. this.next = newChunk;
  45979. return newChunk;
  45980. }
  45981. toString() {
  45982. return this.intro + this.content + this.outro;
  45983. }
  45984. trimEnd(rx) {
  45985. this.outro = this.outro.replace(rx, '');
  45986. if (this.outro.length) return true;
  45987. const trimmed = this.content.replace(rx, '');
  45988. if (trimmed.length) {
  45989. if (trimmed !== this.content) {
  45990. this.split(this.start + trimmed.length).edit('', undefined, true);
  45991. if (this.edited) {
  45992. // save the change, if it has been edited
  45993. this.edit(trimmed, this.storeName, true);
  45994. }
  45995. }
  45996. return true;
  45997. } else {
  45998. this.edit('', undefined, true);
  45999. this.intro = this.intro.replace(rx, '');
  46000. if (this.intro.length) return true;
  46001. }
  46002. }
  46003. trimStart(rx) {
  46004. this.intro = this.intro.replace(rx, '');
  46005. if (this.intro.length) return true;
  46006. const trimmed = this.content.replace(rx, '');
  46007. if (trimmed.length) {
  46008. if (trimmed !== this.content) {
  46009. const newChunk = this.split(this.end - trimmed.length);
  46010. if (this.edited) {
  46011. // save the change, if it has been edited
  46012. newChunk.edit(trimmed, this.storeName, true);
  46013. }
  46014. this.edit('', undefined, true);
  46015. }
  46016. return true;
  46017. } else {
  46018. this.edit('', undefined, true);
  46019. this.outro = this.outro.replace(rx, '');
  46020. if (this.outro.length) return true;
  46021. }
  46022. }
  46023. }
  46024. function getBtoa() {
  46025. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  46026. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  46027. } else if (typeof Buffer === 'function') {
  46028. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  46029. } else {
  46030. return () => {
  46031. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  46032. };
  46033. }
  46034. }
  46035. const btoa = /*#__PURE__*/ getBtoa();
  46036. class SourceMap {
  46037. constructor(properties) {
  46038. this.version = 3;
  46039. this.file = properties.file;
  46040. this.sources = properties.sources;
  46041. this.sourcesContent = properties.sourcesContent;
  46042. this.names = properties.names;
  46043. this.mappings = encode(properties.mappings);
  46044. if (typeof properties.x_google_ignoreList !== 'undefined') {
  46045. this.x_google_ignoreList = properties.x_google_ignoreList;
  46046. }
  46047. }
  46048. toString() {
  46049. return JSON.stringify(this);
  46050. }
  46051. toUrl() {
  46052. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  46053. }
  46054. }
  46055. function guessIndent(code) {
  46056. const lines = code.split('\n');
  46057. const tabbed = lines.filter((line) => /^\t+/.test(line));
  46058. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  46059. if (tabbed.length === 0 && spaced.length === 0) {
  46060. return null;
  46061. }
  46062. // More lines tabbed than spaced? Assume tabs, and
  46063. // default to tabs in the case of a tie (or nothing
  46064. // to go on)
  46065. if (tabbed.length >= spaced.length) {
  46066. return '\t';
  46067. }
  46068. // Otherwise, we need to guess the multiple
  46069. const min = spaced.reduce((previous, current) => {
  46070. const numSpaces = /^ +/.exec(current)[0].length;
  46071. return Math.min(numSpaces, previous);
  46072. }, Infinity);
  46073. return new Array(min + 1).join(' ');
  46074. }
  46075. function getRelativePath(from, to) {
  46076. const fromParts = from.split(/[/\\]/);
  46077. const toParts = to.split(/[/\\]/);
  46078. fromParts.pop(); // get dirname
  46079. while (fromParts[0] === toParts[0]) {
  46080. fromParts.shift();
  46081. toParts.shift();
  46082. }
  46083. if (fromParts.length) {
  46084. let i = fromParts.length;
  46085. while (i--) fromParts[i] = '..';
  46086. }
  46087. return fromParts.concat(toParts).join('/');
  46088. }
  46089. const toString = Object.prototype.toString;
  46090. function isObject(thing) {
  46091. return toString.call(thing) === '[object Object]';
  46092. }
  46093. function getLocator(source) {
  46094. const originalLines = source.split('\n');
  46095. const lineOffsets = [];
  46096. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  46097. lineOffsets.push(pos);
  46098. pos += originalLines[i].length + 1;
  46099. }
  46100. return function locate(index) {
  46101. let i = 0;
  46102. let j = lineOffsets.length;
  46103. while (i < j) {
  46104. const m = (i + j) >> 1;
  46105. if (index < lineOffsets[m]) {
  46106. j = m;
  46107. } else {
  46108. i = m + 1;
  46109. }
  46110. }
  46111. const line = i - 1;
  46112. const column = index - lineOffsets[line];
  46113. return { line, column };
  46114. };
  46115. }
  46116. const wordRegex = /\w/;
  46117. class Mappings {
  46118. constructor(hires) {
  46119. this.hires = hires;
  46120. this.generatedCodeLine = 0;
  46121. this.generatedCodeColumn = 0;
  46122. this.raw = [];
  46123. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  46124. this.pending = null;
  46125. }
  46126. addEdit(sourceIndex, content, loc, nameIndex) {
  46127. if (content.length) {
  46128. const contentLengthMinusOne = content.length - 1;
  46129. let contentLineEnd = content.indexOf('\n', 0);
  46130. let previousContentLineEnd = -1;
  46131. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  46132. // else code afterwards would fill one line too many
  46133. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  46134. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46135. if (nameIndex >= 0) {
  46136. segment.push(nameIndex);
  46137. }
  46138. this.rawSegments.push(segment);
  46139. this.generatedCodeLine += 1;
  46140. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46141. this.generatedCodeColumn = 0;
  46142. previousContentLineEnd = contentLineEnd;
  46143. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  46144. }
  46145. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46146. if (nameIndex >= 0) {
  46147. segment.push(nameIndex);
  46148. }
  46149. this.rawSegments.push(segment);
  46150. this.advance(content.slice(previousContentLineEnd + 1));
  46151. } else if (this.pending) {
  46152. this.rawSegments.push(this.pending);
  46153. this.advance(content);
  46154. }
  46155. this.pending = null;
  46156. }
  46157. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  46158. let originalCharIndex = chunk.start;
  46159. let first = true;
  46160. // when iterating each char, check if it's in a word boundary
  46161. let charInHiresBoundary = false;
  46162. while (originalCharIndex < chunk.end) {
  46163. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  46164. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46165. if (this.hires === 'boundary') {
  46166. // in hires "boundary", group segments per word boundary than per char
  46167. if (wordRegex.test(original[originalCharIndex])) {
  46168. // for first char in the boundary found, start the boundary by pushing a segment
  46169. if (!charInHiresBoundary) {
  46170. this.rawSegments.push(segment);
  46171. charInHiresBoundary = true;
  46172. }
  46173. } else {
  46174. // for non-word char, end the boundary by pushing a segment
  46175. this.rawSegments.push(segment);
  46176. charInHiresBoundary = false;
  46177. }
  46178. } else {
  46179. this.rawSegments.push(segment);
  46180. }
  46181. }
  46182. if (original[originalCharIndex] === '\n') {
  46183. loc.line += 1;
  46184. loc.column = 0;
  46185. this.generatedCodeLine += 1;
  46186. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46187. this.generatedCodeColumn = 0;
  46188. first = true;
  46189. } else {
  46190. loc.column += 1;
  46191. this.generatedCodeColumn += 1;
  46192. first = false;
  46193. }
  46194. originalCharIndex += 1;
  46195. }
  46196. this.pending = null;
  46197. }
  46198. advance(str) {
  46199. if (!str) return;
  46200. const lines = str.split('\n');
  46201. if (lines.length > 1) {
  46202. for (let i = 0; i < lines.length - 1; i++) {
  46203. this.generatedCodeLine++;
  46204. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46205. }
  46206. this.generatedCodeColumn = 0;
  46207. }
  46208. this.generatedCodeColumn += lines[lines.length - 1].length;
  46209. }
  46210. }
  46211. const n = '\n';
  46212. const warned = {
  46213. insertLeft: false,
  46214. insertRight: false,
  46215. storeName: false,
  46216. };
  46217. class MagicString {
  46218. constructor(string, options = {}) {
  46219. const chunk = new Chunk(0, string.length, string);
  46220. Object.defineProperties(this, {
  46221. original: { writable: true, value: string },
  46222. outro: { writable: true, value: '' },
  46223. intro: { writable: true, value: '' },
  46224. firstChunk: { writable: true, value: chunk },
  46225. lastChunk: { writable: true, value: chunk },
  46226. lastSearchedChunk: { writable: true, value: chunk },
  46227. byStart: { writable: true, value: {} },
  46228. byEnd: { writable: true, value: {} },
  46229. filename: { writable: true, value: options.filename },
  46230. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  46231. sourcemapLocations: { writable: true, value: new BitSet() },
  46232. storedNames: { writable: true, value: {} },
  46233. indentStr: { writable: true, value: undefined },
  46234. ignoreList: { writable: true, value: options.ignoreList },
  46235. });
  46236. this.byStart[0] = chunk;
  46237. this.byEnd[string.length] = chunk;
  46238. }
  46239. addSourcemapLocation(char) {
  46240. this.sourcemapLocations.add(char);
  46241. }
  46242. append(content) {
  46243. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  46244. this.outro += content;
  46245. return this;
  46246. }
  46247. appendLeft(index, content) {
  46248. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46249. this._split(index);
  46250. const chunk = this.byEnd[index];
  46251. if (chunk) {
  46252. chunk.appendLeft(content);
  46253. } else {
  46254. this.intro += content;
  46255. }
  46256. return this;
  46257. }
  46258. appendRight(index, content) {
  46259. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46260. this._split(index);
  46261. const chunk = this.byStart[index];
  46262. if (chunk) {
  46263. chunk.appendRight(content);
  46264. } else {
  46265. this.outro += content;
  46266. }
  46267. return this;
  46268. }
  46269. clone() {
  46270. const cloned = new MagicString(this.original, { filename: this.filename });
  46271. let originalChunk = this.firstChunk;
  46272. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  46273. while (originalChunk) {
  46274. cloned.byStart[clonedChunk.start] = clonedChunk;
  46275. cloned.byEnd[clonedChunk.end] = clonedChunk;
  46276. const nextOriginalChunk = originalChunk.next;
  46277. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  46278. if (nextClonedChunk) {
  46279. clonedChunk.next = nextClonedChunk;
  46280. nextClonedChunk.previous = clonedChunk;
  46281. clonedChunk = nextClonedChunk;
  46282. }
  46283. originalChunk = nextOriginalChunk;
  46284. }
  46285. cloned.lastChunk = clonedChunk;
  46286. if (this.indentExclusionRanges) {
  46287. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  46288. }
  46289. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  46290. cloned.intro = this.intro;
  46291. cloned.outro = this.outro;
  46292. return cloned;
  46293. }
  46294. generateDecodedMap(options) {
  46295. options = options || {};
  46296. const sourceIndex = 0;
  46297. const names = Object.keys(this.storedNames);
  46298. const mappings = new Mappings(options.hires);
  46299. const locate = getLocator(this.original);
  46300. if (this.intro) {
  46301. mappings.advance(this.intro);
  46302. }
  46303. this.firstChunk.eachNext((chunk) => {
  46304. const loc = locate(chunk.start);
  46305. if (chunk.intro.length) mappings.advance(chunk.intro);
  46306. if (chunk.edited) {
  46307. mappings.addEdit(
  46308. sourceIndex,
  46309. chunk.content,
  46310. loc,
  46311. chunk.storeName ? names.indexOf(chunk.original) : -1,
  46312. );
  46313. } else {
  46314. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  46315. }
  46316. if (chunk.outro.length) mappings.advance(chunk.outro);
  46317. });
  46318. return {
  46319. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  46320. sources: [
  46321. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  46322. ],
  46323. sourcesContent: options.includeContent ? [this.original] : undefined,
  46324. names,
  46325. mappings: mappings.raw,
  46326. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  46327. };
  46328. }
  46329. generateMap(options) {
  46330. return new SourceMap(this.generateDecodedMap(options));
  46331. }
  46332. _ensureindentStr() {
  46333. if (this.indentStr === undefined) {
  46334. this.indentStr = guessIndent(this.original);
  46335. }
  46336. }
  46337. _getRawIndentString() {
  46338. this._ensureindentStr();
  46339. return this.indentStr;
  46340. }
  46341. getIndentString() {
  46342. this._ensureindentStr();
  46343. return this.indentStr === null ? '\t' : this.indentStr;
  46344. }
  46345. indent(indentStr, options) {
  46346. const pattern = /^[^\r\n]/gm;
  46347. if (isObject(indentStr)) {
  46348. options = indentStr;
  46349. indentStr = undefined;
  46350. }
  46351. if (indentStr === undefined) {
  46352. this._ensureindentStr();
  46353. indentStr = this.indentStr || '\t';
  46354. }
  46355. if (indentStr === '') return this; // noop
  46356. options = options || {};
  46357. // Process exclusion ranges
  46358. const isExcluded = {};
  46359. if (options.exclude) {
  46360. const exclusions =
  46361. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  46362. exclusions.forEach((exclusion) => {
  46363. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  46364. isExcluded[i] = true;
  46365. }
  46366. });
  46367. }
  46368. let shouldIndentNextCharacter = options.indentStart !== false;
  46369. const replacer = (match) => {
  46370. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  46371. shouldIndentNextCharacter = true;
  46372. return match;
  46373. };
  46374. this.intro = this.intro.replace(pattern, replacer);
  46375. let charIndex = 0;
  46376. let chunk = this.firstChunk;
  46377. while (chunk) {
  46378. const end = chunk.end;
  46379. if (chunk.edited) {
  46380. if (!isExcluded[charIndex]) {
  46381. chunk.content = chunk.content.replace(pattern, replacer);
  46382. if (chunk.content.length) {
  46383. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  46384. }
  46385. }
  46386. } else {
  46387. charIndex = chunk.start;
  46388. while (charIndex < end) {
  46389. if (!isExcluded[charIndex]) {
  46390. const char = this.original[charIndex];
  46391. if (char === '\n') {
  46392. shouldIndentNextCharacter = true;
  46393. } else if (char !== '\r' && shouldIndentNextCharacter) {
  46394. shouldIndentNextCharacter = false;
  46395. if (charIndex === chunk.start) {
  46396. chunk.prependRight(indentStr);
  46397. } else {
  46398. this._splitChunk(chunk, charIndex);
  46399. chunk = chunk.next;
  46400. chunk.prependRight(indentStr);
  46401. }
  46402. }
  46403. }
  46404. charIndex += 1;
  46405. }
  46406. }
  46407. charIndex = chunk.end;
  46408. chunk = chunk.next;
  46409. }
  46410. this.outro = this.outro.replace(pattern, replacer);
  46411. return this;
  46412. }
  46413. insert() {
  46414. throw new Error(
  46415. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  46416. );
  46417. }
  46418. insertLeft(index, content) {
  46419. if (!warned.insertLeft) {
  46420. console.warn(
  46421. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  46422. ); // eslint-disable-line no-console
  46423. warned.insertLeft = true;
  46424. }
  46425. return this.appendLeft(index, content);
  46426. }
  46427. insertRight(index, content) {
  46428. if (!warned.insertRight) {
  46429. console.warn(
  46430. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  46431. ); // eslint-disable-line no-console
  46432. warned.insertRight = true;
  46433. }
  46434. return this.prependRight(index, content);
  46435. }
  46436. move(start, end, index) {
  46437. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  46438. this._split(start);
  46439. this._split(end);
  46440. this._split(index);
  46441. const first = this.byStart[start];
  46442. const last = this.byEnd[end];
  46443. const oldLeft = first.previous;
  46444. const oldRight = last.next;
  46445. const newRight = this.byStart[index];
  46446. if (!newRight && last === this.lastChunk) return this;
  46447. const newLeft = newRight ? newRight.previous : this.lastChunk;
  46448. if (oldLeft) oldLeft.next = oldRight;
  46449. if (oldRight) oldRight.previous = oldLeft;
  46450. if (newLeft) newLeft.next = first;
  46451. if (newRight) newRight.previous = last;
  46452. if (!first.previous) this.firstChunk = last.next;
  46453. if (!last.next) {
  46454. this.lastChunk = first.previous;
  46455. this.lastChunk.next = null;
  46456. }
  46457. first.previous = newLeft;
  46458. last.next = newRight || null;
  46459. if (!newLeft) this.firstChunk = first;
  46460. if (!newRight) this.lastChunk = last;
  46461. return this;
  46462. }
  46463. overwrite(start, end, content, options) {
  46464. options = options || {};
  46465. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  46466. }
  46467. update(start, end, content, options) {
  46468. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  46469. if (this.original.length !== 0) {
  46470. while (start < 0) start += this.original.length;
  46471. while (end < 0) end += this.original.length;
  46472. }
  46473. if (end > this.original.length) throw new Error('end is out of bounds');
  46474. if (start === end)
  46475. throw new Error(
  46476. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  46477. );
  46478. this._split(start);
  46479. this._split(end);
  46480. if (options === true) {
  46481. if (!warned.storeName) {
  46482. console.warn(
  46483. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  46484. ); // eslint-disable-line no-console
  46485. warned.storeName = true;
  46486. }
  46487. options = { storeName: true };
  46488. }
  46489. const storeName = options !== undefined ? options.storeName : false;
  46490. const overwrite = options !== undefined ? options.overwrite : false;
  46491. if (storeName) {
  46492. const original = this.original.slice(start, end);
  46493. Object.defineProperty(this.storedNames, original, {
  46494. writable: true,
  46495. value: true,
  46496. enumerable: true,
  46497. });
  46498. }
  46499. const first = this.byStart[start];
  46500. const last = this.byEnd[end];
  46501. if (first) {
  46502. let chunk = first;
  46503. while (chunk !== last) {
  46504. if (chunk.next !== this.byStart[chunk.end]) {
  46505. throw new Error('Cannot overwrite across a split point');
  46506. }
  46507. chunk = chunk.next;
  46508. chunk.edit('', false);
  46509. }
  46510. first.edit(content, storeName, !overwrite);
  46511. } else {
  46512. // must be inserting at the end
  46513. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  46514. // TODO last chunk in the array may not be the last chunk, if it's moved...
  46515. last.next = newChunk;
  46516. newChunk.previous = last;
  46517. }
  46518. return this;
  46519. }
  46520. prepend(content) {
  46521. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  46522. this.intro = content + this.intro;
  46523. return this;
  46524. }
  46525. prependLeft(index, content) {
  46526. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46527. this._split(index);
  46528. const chunk = this.byEnd[index];
  46529. if (chunk) {
  46530. chunk.prependLeft(content);
  46531. } else {
  46532. this.intro = content + this.intro;
  46533. }
  46534. return this;
  46535. }
  46536. prependRight(index, content) {
  46537. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46538. this._split(index);
  46539. const chunk = this.byStart[index];
  46540. if (chunk) {
  46541. chunk.prependRight(content);
  46542. } else {
  46543. this.outro = content + this.outro;
  46544. }
  46545. return this;
  46546. }
  46547. remove(start, end) {
  46548. if (this.original.length !== 0) {
  46549. while (start < 0) start += this.original.length;
  46550. while (end < 0) end += this.original.length;
  46551. }
  46552. if (start === end) return this;
  46553. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  46554. if (start > end) throw new Error('end must be greater than start');
  46555. this._split(start);
  46556. this._split(end);
  46557. let chunk = this.byStart[start];
  46558. while (chunk) {
  46559. chunk.intro = '';
  46560. chunk.outro = '';
  46561. chunk.edit('');
  46562. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  46563. }
  46564. return this;
  46565. }
  46566. reset(start, end) {
  46567. if (this.original.length !== 0) {
  46568. while (start < 0) start += this.original.length;
  46569. while (end < 0) end += this.original.length;
  46570. }
  46571. if (start === end) return this;
  46572. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  46573. if (start > end) throw new Error('end must be greater than start');
  46574. this._split(start);
  46575. this._split(end);
  46576. let chunk = this.byStart[start];
  46577. while (chunk) {
  46578. chunk.reset();
  46579. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  46580. }
  46581. return this;
  46582. }
  46583. lastChar() {
  46584. if (this.outro.length) return this.outro[this.outro.length - 1];
  46585. let chunk = this.lastChunk;
  46586. do {
  46587. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  46588. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  46589. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  46590. } while ((chunk = chunk.previous));
  46591. if (this.intro.length) return this.intro[this.intro.length - 1];
  46592. return '';
  46593. }
  46594. lastLine() {
  46595. let lineIndex = this.outro.lastIndexOf(n);
  46596. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  46597. let lineStr = this.outro;
  46598. let chunk = this.lastChunk;
  46599. do {
  46600. if (chunk.outro.length > 0) {
  46601. lineIndex = chunk.outro.lastIndexOf(n);
  46602. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  46603. lineStr = chunk.outro + lineStr;
  46604. }
  46605. if (chunk.content.length > 0) {
  46606. lineIndex = chunk.content.lastIndexOf(n);
  46607. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  46608. lineStr = chunk.content + lineStr;
  46609. }
  46610. if (chunk.intro.length > 0) {
  46611. lineIndex = chunk.intro.lastIndexOf(n);
  46612. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  46613. lineStr = chunk.intro + lineStr;
  46614. }
  46615. } while ((chunk = chunk.previous));
  46616. lineIndex = this.intro.lastIndexOf(n);
  46617. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  46618. return this.intro + lineStr;
  46619. }
  46620. slice(start = 0, end = this.original.length) {
  46621. if (this.original.length !== 0) {
  46622. while (start < 0) start += this.original.length;
  46623. while (end < 0) end += this.original.length;
  46624. }
  46625. let result = '';
  46626. // find start chunk
  46627. let chunk = this.firstChunk;
  46628. while (chunk && (chunk.start > start || chunk.end <= start)) {
  46629. // found end chunk before start
  46630. if (chunk.start < end && chunk.end >= end) {
  46631. return result;
  46632. }
  46633. chunk = chunk.next;
  46634. }
  46635. if (chunk && chunk.edited && chunk.start !== start)
  46636. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  46637. const startChunk = chunk;
  46638. while (chunk) {
  46639. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  46640. result += chunk.intro;
  46641. }
  46642. const containsEnd = chunk.start < end && chunk.end >= end;
  46643. if (containsEnd && chunk.edited && chunk.end !== end)
  46644. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  46645. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  46646. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  46647. result += chunk.content.slice(sliceStart, sliceEnd);
  46648. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  46649. result += chunk.outro;
  46650. }
  46651. if (containsEnd) {
  46652. break;
  46653. }
  46654. chunk = chunk.next;
  46655. }
  46656. return result;
  46657. }
  46658. // TODO deprecate this? not really very useful
  46659. snip(start, end) {
  46660. const clone = this.clone();
  46661. clone.remove(0, start);
  46662. clone.remove(end, clone.original.length);
  46663. return clone;
  46664. }
  46665. _split(index) {
  46666. if (this.byStart[index] || this.byEnd[index]) return;
  46667. let chunk = this.lastSearchedChunk;
  46668. const searchForward = index > chunk.end;
  46669. while (chunk) {
  46670. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  46671. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  46672. }
  46673. }
  46674. _splitChunk(chunk, index) {
  46675. if (chunk.edited && chunk.content.length) {
  46676. // zero-length edited chunks are a special case (overlapping replacements)
  46677. const loc = getLocator(this.original)(index);
  46678. throw new Error(
  46679. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  46680. );
  46681. }
  46682. const newChunk = chunk.split(index);
  46683. this.byEnd[index] = chunk;
  46684. this.byStart[index] = newChunk;
  46685. this.byEnd[newChunk.end] = newChunk;
  46686. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  46687. this.lastSearchedChunk = chunk;
  46688. return true;
  46689. }
  46690. toString() {
  46691. let str = this.intro;
  46692. let chunk = this.firstChunk;
  46693. while (chunk) {
  46694. str += chunk.toString();
  46695. chunk = chunk.next;
  46696. }
  46697. return str + this.outro;
  46698. }
  46699. isEmpty() {
  46700. let chunk = this.firstChunk;
  46701. do {
  46702. if (
  46703. (chunk.intro.length && chunk.intro.trim()) ||
  46704. (chunk.content.length && chunk.content.trim()) ||
  46705. (chunk.outro.length && chunk.outro.trim())
  46706. )
  46707. return false;
  46708. } while ((chunk = chunk.next));
  46709. return true;
  46710. }
  46711. length() {
  46712. let chunk = this.firstChunk;
  46713. let length = 0;
  46714. do {
  46715. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  46716. } while ((chunk = chunk.next));
  46717. return length;
  46718. }
  46719. trimLines() {
  46720. return this.trim('[\\r\\n]');
  46721. }
  46722. trim(charType) {
  46723. return this.trimStart(charType).trimEnd(charType);
  46724. }
  46725. trimEndAborted(charType) {
  46726. const rx = new RegExp((charType || '\\s') + '+$');
  46727. this.outro = this.outro.replace(rx, '');
  46728. if (this.outro.length) return true;
  46729. let chunk = this.lastChunk;
  46730. do {
  46731. const end = chunk.end;
  46732. const aborted = chunk.trimEnd(rx);
  46733. // if chunk was trimmed, we have a new lastChunk
  46734. if (chunk.end !== end) {
  46735. if (this.lastChunk === chunk) {
  46736. this.lastChunk = chunk.next;
  46737. }
  46738. this.byEnd[chunk.end] = chunk;
  46739. this.byStart[chunk.next.start] = chunk.next;
  46740. this.byEnd[chunk.next.end] = chunk.next;
  46741. }
  46742. if (aborted) return true;
  46743. chunk = chunk.previous;
  46744. } while (chunk);
  46745. return false;
  46746. }
  46747. trimEnd(charType) {
  46748. this.trimEndAborted(charType);
  46749. return this;
  46750. }
  46751. trimStartAborted(charType) {
  46752. const rx = new RegExp('^' + (charType || '\\s') + '+');
  46753. this.intro = this.intro.replace(rx, '');
  46754. if (this.intro.length) return true;
  46755. let chunk = this.firstChunk;
  46756. do {
  46757. const end = chunk.end;
  46758. const aborted = chunk.trimStart(rx);
  46759. if (chunk.end !== end) {
  46760. // special case...
  46761. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  46762. this.byEnd[chunk.end] = chunk;
  46763. this.byStart[chunk.next.start] = chunk.next;
  46764. this.byEnd[chunk.next.end] = chunk.next;
  46765. }
  46766. if (aborted) return true;
  46767. chunk = chunk.next;
  46768. } while (chunk);
  46769. return false;
  46770. }
  46771. trimStart(charType) {
  46772. this.trimStartAborted(charType);
  46773. return this;
  46774. }
  46775. hasChanged() {
  46776. return this.original !== this.toString();
  46777. }
  46778. _replaceRegexp(searchValue, replacement) {
  46779. function getReplacement(match, str) {
  46780. if (typeof replacement === 'string') {
  46781. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  46782. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  46783. if (i === '$') return '$';
  46784. if (i === '&') return match[0];
  46785. const num = +i;
  46786. if (num < match.length) return match[+i];
  46787. return `$${i}`;
  46788. });
  46789. } else {
  46790. return replacement(...match, match.index, str, match.groups);
  46791. }
  46792. }
  46793. function matchAll(re, str) {
  46794. let match;
  46795. const matches = [];
  46796. while ((match = re.exec(str))) {
  46797. matches.push(match);
  46798. }
  46799. return matches;
  46800. }
  46801. if (searchValue.global) {
  46802. const matches = matchAll(searchValue, this.original);
  46803. matches.forEach((match) => {
  46804. if (match.index != null) {
  46805. const replacement = getReplacement(match, this.original);
  46806. if (replacement !== match[0]) {
  46807. this.overwrite(
  46808. match.index,
  46809. match.index + match[0].length,
  46810. replacement
  46811. );
  46812. }
  46813. }
  46814. });
  46815. } else {
  46816. const match = this.original.match(searchValue);
  46817. if (match && match.index != null) {
  46818. const replacement = getReplacement(match, this.original);
  46819. if (replacement !== match[0]) {
  46820. this.overwrite(
  46821. match.index,
  46822. match.index + match[0].length,
  46823. replacement
  46824. );
  46825. }
  46826. }
  46827. }
  46828. return this;
  46829. }
  46830. _replaceString(string, replacement) {
  46831. const { original } = this;
  46832. const index = original.indexOf(string);
  46833. if (index !== -1) {
  46834. this.overwrite(index, index + string.length, replacement);
  46835. }
  46836. return this;
  46837. }
  46838. replace(searchValue, replacement) {
  46839. if (typeof searchValue === 'string') {
  46840. return this._replaceString(searchValue, replacement);
  46841. }
  46842. return this._replaceRegexp(searchValue, replacement);
  46843. }
  46844. _replaceAllString(string, replacement) {
  46845. const { original } = this;
  46846. const stringLength = string.length;
  46847. for (
  46848. let index = original.indexOf(string);
  46849. index !== -1;
  46850. index = original.indexOf(string, index + stringLength)
  46851. ) {
  46852. const previous = original.slice(index, index + stringLength);
  46853. if (previous !== replacement)
  46854. this.overwrite(index, index + stringLength, replacement);
  46855. }
  46856. return this;
  46857. }
  46858. replaceAll(searchValue, replacement) {
  46859. if (typeof searchValue === 'string') {
  46860. return this._replaceAllString(searchValue, replacement);
  46861. }
  46862. if (!searchValue.global) {
  46863. throw new TypeError(
  46864. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  46865. );
  46866. }
  46867. return this._replaceRegexp(searchValue, replacement);
  46868. }
  46869. }
  46870. var _a, _b;
  46871. class ScriptCompileContext {
  46872. constructor(descriptor, options) {
  46873. this.descriptor = descriptor;
  46874. this.options = options;
  46875. this.isCE = false;
  46876. this.source = this.descriptor.source;
  46877. this.filename = this.descriptor.filename;
  46878. this.s = new MagicString(this.source);
  46879. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  46880. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  46881. this.userImports = /* @__PURE__ */ Object.create(null);
  46882. // macros presence check
  46883. this.hasDefinePropsCall = false;
  46884. this.hasDefineEmitCall = false;
  46885. this.hasDefineExposeCall = false;
  46886. this.hasDefaultExportName = false;
  46887. this.hasDefaultExportRender = false;
  46888. this.hasDefineOptionsCall = false;
  46889. this.hasDefineSlotsCall = false;
  46890. this.hasDefineModelCall = false;
  46891. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  46892. // defineModel
  46893. this.modelDecls = /* @__PURE__ */ Object.create(null);
  46894. // codegen
  46895. this.bindingMetadata = {};
  46896. this.helperImports = /* @__PURE__ */ new Set();
  46897. const { script, scriptSetup } = descriptor;
  46898. const scriptLang = script && script.lang;
  46899. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  46900. this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
  46901. this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
  46902. const customElement = options.customElement;
  46903. const filename = this.descriptor.filename;
  46904. if (customElement) {
  46905. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  46906. }
  46907. const plugins = resolveParserPlugins(
  46908. scriptLang || scriptSetupLang,
  46909. options.babelParserPlugins
  46910. );
  46911. function parse(input, offset) {
  46912. try {
  46913. return libExports.parse(input, {
  46914. plugins,
  46915. sourceType: "module"
  46916. }).program;
  46917. } catch (e) {
  46918. e.message = `[vue/compiler-sfc] ${e.message}
  46919. ${descriptor.filename}
  46920. ${generateCodeFrame(
  46921. descriptor.source,
  46922. e.pos + offset,
  46923. e.pos + offset + 1
  46924. )}`;
  46925. throw e;
  46926. }
  46927. }
  46928. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  46929. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  46930. }
  46931. helper(key) {
  46932. this.helperImports.add(key);
  46933. return `_${key}`;
  46934. }
  46935. getString(node, scriptSetup = true) {
  46936. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  46937. return block.content.slice(node.start, node.end);
  46938. }
  46939. warn(msg, node, scope) {
  46940. warn(generateError(msg, node, this, scope));
  46941. }
  46942. error(msg, node, scope) {
  46943. throw new Error(
  46944. `[@vue/compiler-sfc] ${generateError(msg, node, this, scope)}`
  46945. );
  46946. }
  46947. }
  46948. function generateError(msg, node, ctx, scope) {
  46949. const offset = scope ? scope.offset : ctx.startOffset;
  46950. return `${msg}
  46951. ${(scope || ctx.descriptor).filename}
  46952. ${generateCodeFrame(
  46953. (scope || ctx.descriptor).source,
  46954. node.start + offset,
  46955. node.end + offset
  46956. )}`;
  46957. }
  46958. function resolveParserPlugins(lang, userPlugins, dts = false) {
  46959. const plugins = [];
  46960. if (!userPlugins || !userPlugins.some(
  46961. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  46962. )) {
  46963. plugins.push("importAttributes");
  46964. }
  46965. if (lang === "jsx" || lang === "tsx" || lang === "mtsx") {
  46966. plugins.push("jsx");
  46967. } else if (userPlugins) {
  46968. userPlugins = userPlugins.filter((p) => p !== "jsx");
  46969. }
  46970. if (lang === "ts" || lang === "mts" || lang === "tsx" || lang === "mtsx") {
  46971. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  46972. if (!userPlugins || !userPlugins.includes("decorators")) {
  46973. plugins.push("decorators-legacy");
  46974. }
  46975. }
  46976. if (userPlugins) {
  46977. plugins.push(...userPlugins);
  46978. }
  46979. return plugins;
  46980. }
  46981. function rewriteDefault(input, as, parserPlugins) {
  46982. const ast = libExports.parse(input, {
  46983. sourceType: "module",
  46984. plugins: resolveParserPlugins("js", parserPlugins)
  46985. }).program.body;
  46986. const s = new MagicString(input);
  46987. rewriteDefaultAST(ast, s, as);
  46988. return s.toString();
  46989. }
  46990. function rewriteDefaultAST(ast, s, as) {
  46991. if (!hasDefaultExport(ast)) {
  46992. s.append(`
  46993. const ${as} = {}`);
  46994. return;
  46995. }
  46996. ast.forEach((node) => {
  46997. if (node.type === "ExportDefaultDeclaration") {
  46998. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  46999. let start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  47000. s.overwrite(start, node.declaration.id.start, ` class `);
  47001. s.append(`
  47002. const ${as} = ${node.declaration.id.name}`);
  47003. } else {
  47004. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  47005. }
  47006. } else if (node.type === "ExportNamedDeclaration") {
  47007. for (const specifier of node.specifiers) {
  47008. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  47009. if (node.source) {
  47010. if (specifier.local.name === "default") {
  47011. s.prepend(
  47012. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  47013. `
  47014. );
  47015. const end2 = specifierEnd(s, specifier.local.end, node.end);
  47016. s.remove(specifier.start, end2);
  47017. s.append(`
  47018. const ${as} = __VUE_DEFAULT__`);
  47019. continue;
  47020. } else {
  47021. s.prepend(
  47022. `import { ${s.slice(
  47023. specifier.local.start,
  47024. specifier.local.end
  47025. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  47026. `
  47027. );
  47028. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  47029. s.remove(specifier.start, end2);
  47030. s.append(`
  47031. const ${as} = __VUE_DEFAULT__`);
  47032. continue;
  47033. }
  47034. }
  47035. const end = specifierEnd(s, specifier.end, node.end);
  47036. s.remove(specifier.start, end);
  47037. s.append(`
  47038. const ${as} = ${specifier.local.name}`);
  47039. }
  47040. }
  47041. }
  47042. });
  47043. }
  47044. function hasDefaultExport(ast) {
  47045. for (const stmt of ast) {
  47046. if (stmt.type === "ExportDefaultDeclaration") {
  47047. return true;
  47048. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  47049. (spec) => spec.exported.name === "default"
  47050. )) {
  47051. return true;
  47052. }
  47053. }
  47054. return false;
  47055. }
  47056. function specifierEnd(s, end, nodeEnd) {
  47057. let hasCommas = false;
  47058. let oldEnd = end;
  47059. while (end < nodeEnd) {
  47060. if (/\s/.test(s.slice(end, end + 1))) {
  47061. end++;
  47062. } else if (s.slice(end, end + 1) === ",") {
  47063. end++;
  47064. hasCommas = true;
  47065. break;
  47066. } else if (s.slice(end, end + 1) === "}") {
  47067. break;
  47068. }
  47069. }
  47070. return hasCommas ? end : oldEnd;
  47071. }
  47072. var __defProp$3 = Object.defineProperty;
  47073. var __defProps$2 = Object.defineProperties;
  47074. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  47075. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  47076. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  47077. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  47078. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47079. var __spreadValues$3 = (a, b) => {
  47080. for (var prop in b || (b = {}))
  47081. if (__hasOwnProp$3.call(b, prop))
  47082. __defNormalProp$3(a, prop, b[prop]);
  47083. if (__getOwnPropSymbols$3)
  47084. for (var prop of __getOwnPropSymbols$3(b)) {
  47085. if (__propIsEnum$3.call(b, prop))
  47086. __defNormalProp$3(a, prop, b[prop]);
  47087. }
  47088. return a;
  47089. };
  47090. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  47091. const normalScriptDefaultVar = `__default__`;
  47092. function processNormalScript(ctx, scopeId) {
  47093. var _a;
  47094. const script = ctx.descriptor.script;
  47095. if (script.lang && !ctx.isJS && !ctx.isTS) {
  47096. return script;
  47097. }
  47098. try {
  47099. let content = script.content;
  47100. let map = script.map;
  47101. const scriptAst = ctx.scriptAst;
  47102. const bindings = analyzeScriptBindings(scriptAst.body);
  47103. const { cssVars } = ctx.descriptor;
  47104. const { genDefaultAs, isProd } = ctx.options;
  47105. if (cssVars.length || genDefaultAs) {
  47106. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  47107. const s = new MagicString(content);
  47108. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  47109. content = s.toString();
  47110. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  47111. content += genNormalScriptCssVarsCode(
  47112. cssVars,
  47113. bindings,
  47114. scopeId,
  47115. !!isProd,
  47116. defaultVar
  47117. );
  47118. }
  47119. if (!genDefaultAs) {
  47120. content += `
  47121. export default ${defaultVar}`;
  47122. }
  47123. }
  47124. return __spreadProps$2(__spreadValues$3({}, script), {
  47125. content,
  47126. map,
  47127. bindings,
  47128. scriptAst: scriptAst.body
  47129. });
  47130. } catch (e) {
  47131. return script;
  47132. }
  47133. }
  47134. var __defProp$2 = Object.defineProperty;
  47135. var __defProps$1 = Object.defineProperties;
  47136. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  47137. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  47138. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  47139. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  47140. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47141. var __spreadValues$2 = (a, b) => {
  47142. for (var prop in b || (b = {}))
  47143. if (__hasOwnProp$2.call(b, prop))
  47144. __defNormalProp$2(a, prop, b[prop]);
  47145. if (__getOwnPropSymbols$2)
  47146. for (var prop of __getOwnPropSymbols$2(b)) {
  47147. if (__propIsEnum$2.call(b, prop))
  47148. __defNormalProp$2(a, prop, b[prop]);
  47149. }
  47150. return a;
  47151. };
  47152. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  47153. class TypeScope {
  47154. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  47155. this.filename = filename;
  47156. this.source = source;
  47157. this.offset = offset;
  47158. this.imports = imports;
  47159. this.types = types;
  47160. this.declares = declares;
  47161. this.isGenericScope = false;
  47162. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  47163. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  47164. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  47165. }
  47166. }
  47167. function resolveTypeElements(ctx, node, scope, typeParameters) {
  47168. const canCache = !typeParameters;
  47169. if (canCache && node._resolvedElements) {
  47170. return node._resolvedElements;
  47171. }
  47172. const resolved = innerResolveTypeElements(
  47173. ctx,
  47174. node,
  47175. node._ownerScope || scope || ctxToScope(ctx),
  47176. typeParameters
  47177. );
  47178. return canCache ? node._resolvedElements = resolved : resolved;
  47179. }
  47180. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  47181. var _a, _b;
  47182. if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  47183. return { props: {} };
  47184. }
  47185. switch (node.type) {
  47186. case "TSTypeLiteral":
  47187. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  47188. case "TSInterfaceDeclaration":
  47189. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  47190. case "TSTypeAliasDeclaration":
  47191. case "TSTypeAnnotation":
  47192. case "TSParenthesizedType":
  47193. return resolveTypeElements(
  47194. ctx,
  47195. node.typeAnnotation,
  47196. scope,
  47197. typeParameters
  47198. );
  47199. case "TSFunctionType": {
  47200. return { props: {}, calls: [node] };
  47201. }
  47202. case "TSUnionType":
  47203. case "TSIntersectionType":
  47204. return mergeElements(
  47205. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  47206. node.type
  47207. );
  47208. case "TSMappedType":
  47209. return resolveMappedType(ctx, node, scope, typeParameters);
  47210. case "TSIndexedAccessType": {
  47211. const types = resolveIndexType(ctx, node, scope);
  47212. return mergeElements(
  47213. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  47214. "TSUnionType"
  47215. );
  47216. }
  47217. case "TSExpressionWithTypeArguments":
  47218. // referenced by interface extends
  47219. case "TSTypeReference": {
  47220. const typeName = getReferenceName(node);
  47221. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  47222. return resolveExtractPropTypes(
  47223. resolveTypeElements(
  47224. ctx,
  47225. node.typeParameters.params[0],
  47226. scope,
  47227. typeParameters
  47228. ),
  47229. scope
  47230. );
  47231. }
  47232. const resolved = resolveTypeReference(ctx, node, scope);
  47233. if (resolved) {
  47234. let typeParams;
  47235. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  47236. typeParams = /* @__PURE__ */ Object.create(null);
  47237. resolved.typeParameters.params.forEach((p, i) => {
  47238. let param = typeParameters && typeParameters[p.name];
  47239. if (!param) param = node.typeParameters.params[i];
  47240. typeParams[p.name] = param;
  47241. });
  47242. }
  47243. return resolveTypeElements(
  47244. ctx,
  47245. resolved,
  47246. resolved._ownerScope,
  47247. typeParams
  47248. );
  47249. } else {
  47250. if (typeof typeName === "string") {
  47251. if (typeParameters && typeParameters[typeName]) {
  47252. return resolveTypeElements(
  47253. ctx,
  47254. typeParameters[typeName],
  47255. scope,
  47256. typeParameters
  47257. );
  47258. }
  47259. if (
  47260. // @ts-expect-error
  47261. SupportedBuiltinsSet.has(typeName)
  47262. ) {
  47263. return resolveBuiltin(
  47264. ctx,
  47265. node,
  47266. typeName,
  47267. scope,
  47268. typeParameters
  47269. );
  47270. } else if (typeName === "ReturnType" && node.typeParameters) {
  47271. const ret = resolveReturnType(
  47272. ctx,
  47273. node.typeParameters.params[0],
  47274. scope
  47275. );
  47276. if (ret) {
  47277. return resolveTypeElements(ctx, ret, scope);
  47278. }
  47279. }
  47280. }
  47281. return ctx.error(
  47282. `Unresolvable type reference or unsupported built-in utility type`,
  47283. node,
  47284. scope
  47285. );
  47286. }
  47287. }
  47288. case "TSImportType": {
  47289. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  47290. return resolveExtractPropTypes(
  47291. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  47292. scope
  47293. );
  47294. }
  47295. const sourceScope = importSourceToScope(
  47296. ctx,
  47297. node.argument,
  47298. scope,
  47299. node.argument.value
  47300. );
  47301. const resolved = resolveTypeReference(ctx, node, sourceScope);
  47302. if (resolved) {
  47303. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  47304. }
  47305. break;
  47306. }
  47307. case "TSTypeQuery":
  47308. {
  47309. const resolved = resolveTypeReference(ctx, node, scope);
  47310. if (resolved) {
  47311. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  47312. }
  47313. }
  47314. break;
  47315. }
  47316. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  47317. }
  47318. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  47319. const res = { props: {} };
  47320. for (const e of elements) {
  47321. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  47322. if (typeParameters) {
  47323. scope = createChildScope(scope);
  47324. scope.isGenericScope = true;
  47325. Object.assign(scope.types, typeParameters);
  47326. }
  47327. e._ownerScope = scope;
  47328. const name = getId(e.key);
  47329. if (name && !e.computed) {
  47330. res.props[name] = e;
  47331. } else if (e.key.type === "TemplateLiteral") {
  47332. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  47333. res.props[key] = e;
  47334. }
  47335. } else {
  47336. ctx.error(
  47337. `Unsupported computed key in type referenced by a macro`,
  47338. e.key,
  47339. scope
  47340. );
  47341. }
  47342. } else if (e.type === "TSCallSignatureDeclaration") {
  47343. (res.calls || (res.calls = [])).push(e);
  47344. }
  47345. }
  47346. return res;
  47347. }
  47348. function mergeElements(maps, type) {
  47349. if (maps.length === 1) return maps[0];
  47350. const res = { props: {} };
  47351. const { props: baseProps } = res;
  47352. for (const { props, calls } of maps) {
  47353. for (const key in props) {
  47354. if (!hasOwn(baseProps, key)) {
  47355. baseProps[key] = props[key];
  47356. } else {
  47357. baseProps[key] = createProperty(
  47358. baseProps[key].key,
  47359. {
  47360. type,
  47361. // @ts-expect-error
  47362. types: [baseProps[key], props[key]]
  47363. },
  47364. baseProps[key]._ownerScope,
  47365. baseProps[key].optional || props[key].optional
  47366. );
  47367. }
  47368. }
  47369. if (calls) {
  47370. (res.calls || (res.calls = [])).push(...calls);
  47371. }
  47372. }
  47373. return res;
  47374. }
  47375. function createProperty(key, typeAnnotation, scope, optional) {
  47376. return {
  47377. type: "TSPropertySignature",
  47378. key,
  47379. kind: "get",
  47380. optional,
  47381. typeAnnotation: {
  47382. type: "TSTypeAnnotation",
  47383. typeAnnotation
  47384. },
  47385. _ownerScope: scope
  47386. };
  47387. }
  47388. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  47389. const base = typeElementsToMap(
  47390. ctx,
  47391. node.body.body,
  47392. node._ownerScope,
  47393. typeParameters
  47394. );
  47395. if (node.extends) {
  47396. for (const ext of node.extends) {
  47397. try {
  47398. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  47399. for (const key in props) {
  47400. if (!hasOwn(base.props, key)) {
  47401. base.props[key] = props[key];
  47402. }
  47403. }
  47404. if (calls) {
  47405. ;
  47406. (base.calls || (base.calls = [])).push(...calls);
  47407. }
  47408. } catch (e) {
  47409. ctx.error(
  47410. `Failed to resolve extends base type.
  47411. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  47412. interface Props extends /* @vue-ignore */ Base {}
  47413. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  47414. ext,
  47415. scope
  47416. );
  47417. }
  47418. }
  47419. }
  47420. return base;
  47421. }
  47422. function resolveMappedType(ctx, node, scope, typeParameters) {
  47423. const res = { props: {} };
  47424. let keys;
  47425. if (node.nameType) {
  47426. const { name, constraint } = node.typeParameter;
  47427. scope = createChildScope(scope);
  47428. Object.assign(scope.types, __spreadProps$1(__spreadValues$2({}, typeParameters), { [name]: constraint }));
  47429. keys = resolveStringType(ctx, node.nameType, scope);
  47430. } else {
  47431. keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  47432. }
  47433. for (const key of keys) {
  47434. res.props[key] = createProperty(
  47435. {
  47436. type: "Identifier",
  47437. name: key
  47438. },
  47439. node.typeAnnotation,
  47440. scope,
  47441. !!node.optional
  47442. );
  47443. }
  47444. return res;
  47445. }
  47446. function resolveIndexType(ctx, node, scope) {
  47447. var _a, _b;
  47448. if (node.indexType.type === "TSNumberKeyword") {
  47449. return resolveArrayElementType(ctx, node.objectType, scope);
  47450. }
  47451. const { indexType, objectType } = node;
  47452. const types = [];
  47453. let keys;
  47454. let resolved;
  47455. if (indexType.type === "TSStringKeyword") {
  47456. resolved = resolveTypeElements(ctx, objectType, scope);
  47457. keys = Object.keys(resolved.props);
  47458. } else {
  47459. keys = resolveStringType(ctx, indexType, scope);
  47460. resolved = resolveTypeElements(ctx, objectType, scope);
  47461. }
  47462. for (const key of keys) {
  47463. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  47464. if (targetType) {
  47465. targetType._ownerScope = resolved.props[key]._ownerScope;
  47466. types.push(targetType);
  47467. }
  47468. }
  47469. return types;
  47470. }
  47471. function resolveArrayElementType(ctx, node, scope) {
  47472. if (node.type === "TSArrayType") {
  47473. return [node.elementType];
  47474. }
  47475. if (node.type === "TSTupleType") {
  47476. return node.elementTypes.map(
  47477. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  47478. );
  47479. }
  47480. if (node.type === "TSTypeReference") {
  47481. if (getReferenceName(node) === "Array" && node.typeParameters) {
  47482. return node.typeParameters.params;
  47483. } else {
  47484. const resolved = resolveTypeReference(ctx, node, scope);
  47485. if (resolved) {
  47486. return resolveArrayElementType(ctx, resolved, scope);
  47487. }
  47488. }
  47489. }
  47490. return ctx.error(
  47491. "Failed to resolve element type from target type",
  47492. node,
  47493. scope
  47494. );
  47495. }
  47496. function resolveStringType(ctx, node, scope) {
  47497. switch (node.type) {
  47498. case "StringLiteral":
  47499. return [node.value];
  47500. case "TSLiteralType":
  47501. return resolveStringType(ctx, node.literal, scope);
  47502. case "TSUnionType":
  47503. return node.types.map((t) => resolveStringType(ctx, t, scope)).flat();
  47504. case "TemplateLiteral": {
  47505. return resolveTemplateKeys(ctx, node, scope);
  47506. }
  47507. case "TSTypeReference": {
  47508. const resolved = resolveTypeReference(ctx, node, scope);
  47509. if (resolved) {
  47510. return resolveStringType(ctx, resolved, scope);
  47511. }
  47512. if (node.typeName.type === "Identifier") {
  47513. const getParam = (index = 0) => resolveStringType(ctx, node.typeParameters.params[index], scope);
  47514. switch (node.typeName.name) {
  47515. case "Extract":
  47516. return getParam(1);
  47517. case "Exclude": {
  47518. const excluded = getParam(1);
  47519. return getParam().filter((s) => !excluded.includes(s));
  47520. }
  47521. case "Uppercase":
  47522. return getParam().map((s) => s.toUpperCase());
  47523. case "Lowercase":
  47524. return getParam().map((s) => s.toLowerCase());
  47525. case "Capitalize":
  47526. return getParam().map(capitalize);
  47527. case "Uncapitalize":
  47528. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  47529. default:
  47530. ctx.error(
  47531. "Unsupported type when resolving index type",
  47532. node.typeName,
  47533. scope
  47534. );
  47535. }
  47536. }
  47537. }
  47538. }
  47539. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  47540. }
  47541. function resolveTemplateKeys(ctx, node, scope) {
  47542. if (!node.expressions.length) {
  47543. return [node.quasis[0].value.raw];
  47544. }
  47545. const res = [];
  47546. const e = node.expressions[0];
  47547. const q = node.quasis[0];
  47548. const leading = q ? q.value.raw : ``;
  47549. const resolved = resolveStringType(ctx, e, scope);
  47550. const restResolved = resolveTemplateKeys(
  47551. ctx,
  47552. __spreadProps$1(__spreadValues$2({}, node), {
  47553. expressions: node.expressions.slice(1),
  47554. quasis: q ? node.quasis.slice(1) : node.quasis
  47555. }),
  47556. scope
  47557. );
  47558. for (const r of resolved) {
  47559. for (const rr of restResolved) {
  47560. res.push(leading + r + rr);
  47561. }
  47562. }
  47563. return res;
  47564. }
  47565. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  47566. "Partial",
  47567. "Required",
  47568. "Readonly",
  47569. "Pick",
  47570. "Omit"
  47571. ]);
  47572. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  47573. const t = resolveTypeElements(
  47574. ctx,
  47575. node.typeParameters.params[0],
  47576. scope,
  47577. typeParameters
  47578. );
  47579. switch (name) {
  47580. case "Partial": {
  47581. const res2 = { props: {}, calls: t.calls };
  47582. Object.keys(t.props).forEach((key) => {
  47583. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  47584. });
  47585. return res2;
  47586. }
  47587. case "Required": {
  47588. const res2 = { props: {}, calls: t.calls };
  47589. Object.keys(t.props).forEach((key) => {
  47590. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  47591. });
  47592. return res2;
  47593. }
  47594. case "Readonly":
  47595. return t;
  47596. case "Pick": {
  47597. const picked = resolveStringType(
  47598. ctx,
  47599. node.typeParameters.params[1],
  47600. scope
  47601. );
  47602. const res2 = { props: {}, calls: t.calls };
  47603. for (const key of picked) {
  47604. res2.props[key] = t.props[key];
  47605. }
  47606. return res2;
  47607. }
  47608. case "Omit":
  47609. const omitted = resolveStringType(
  47610. ctx,
  47611. node.typeParameters.params[1],
  47612. scope
  47613. );
  47614. const res = { props: {}, calls: t.calls };
  47615. for (const key in t.props) {
  47616. if (!omitted.includes(key)) {
  47617. res.props[key] = t.props[key];
  47618. }
  47619. }
  47620. return res;
  47621. }
  47622. }
  47623. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  47624. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  47625. if (canCache && node._resolvedReference) {
  47626. return node._resolvedReference;
  47627. }
  47628. const resolved = innerResolveTypeReference(
  47629. ctx,
  47630. scope || ctxToScope(ctx),
  47631. name || getReferenceName(node),
  47632. node,
  47633. onlyExported
  47634. );
  47635. return canCache ? node._resolvedReference = resolved : resolved;
  47636. }
  47637. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  47638. if (typeof name === "string") {
  47639. if (scope.imports[name]) {
  47640. return resolveTypeFromImport(ctx, node, name, scope);
  47641. } else {
  47642. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  47643. if (lookupSource[name]) {
  47644. return lookupSource[name];
  47645. } else {
  47646. const globalScopes = resolveGlobalScope(ctx);
  47647. if (globalScopes) {
  47648. for (const s of globalScopes) {
  47649. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  47650. if (src[name]) {
  47651. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  47652. return src[name];
  47653. }
  47654. }
  47655. }
  47656. }
  47657. }
  47658. } else {
  47659. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  47660. if (ns) {
  47661. if (ns.type !== "TSModuleDeclaration") {
  47662. ns = ns._ns;
  47663. }
  47664. if (ns) {
  47665. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  47666. return innerResolveTypeReference(
  47667. ctx,
  47668. childScope,
  47669. name.length > 2 ? name.slice(1) : name[name.length - 1],
  47670. node,
  47671. !ns.declare
  47672. );
  47673. }
  47674. }
  47675. }
  47676. }
  47677. function getReferenceName(node) {
  47678. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  47679. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  47680. return ref.name;
  47681. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  47682. return qualifiedNameToPath(ref);
  47683. } else {
  47684. return "default";
  47685. }
  47686. }
  47687. function qualifiedNameToPath(node) {
  47688. if (node.type === "Identifier") {
  47689. return [node.name];
  47690. } else {
  47691. return [...qualifiedNameToPath(node.left), node.right.name];
  47692. }
  47693. }
  47694. function resolveGlobalScope(ctx) {
  47695. if (ctx.options.globalTypeFiles) {
  47696. const fs = resolveFS(ctx);
  47697. if (!fs) {
  47698. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  47699. }
  47700. return ctx.options.globalTypeFiles.map(
  47701. (file) => fileToScope(ctx, normalizePath(file), true)
  47702. );
  47703. }
  47704. }
  47705. let ts;
  47706. let loadTS;
  47707. function registerTS(_loadTS) {
  47708. loadTS = () => {
  47709. try {
  47710. return _loadTS();
  47711. } catch (err) {
  47712. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  47713. throw new Error(
  47714. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  47715. );
  47716. } else {
  47717. throw new Error(
  47718. "Failed to load TypeScript for resolving imported types."
  47719. );
  47720. }
  47721. }
  47722. };
  47723. }
  47724. function resolveFS(ctx) {
  47725. if (ctx.fs) {
  47726. return ctx.fs;
  47727. }
  47728. if (!ts && loadTS) {
  47729. ts = loadTS();
  47730. }
  47731. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  47732. if (!fs) {
  47733. return;
  47734. }
  47735. return ctx.fs = {
  47736. fileExists(file) {
  47737. if (file.endsWith(".vue.ts")) {
  47738. file = file.replace(/\.ts$/, "");
  47739. }
  47740. return fs.fileExists(file);
  47741. },
  47742. readFile(file) {
  47743. if (file.endsWith(".vue.ts")) {
  47744. file = file.replace(/\.ts$/, "");
  47745. }
  47746. return fs.readFile(file);
  47747. },
  47748. realpath: fs.realpath
  47749. };
  47750. }
  47751. function resolveTypeFromImport(ctx, node, name, scope) {
  47752. const { source, imported } = scope.imports[name];
  47753. const sourceScope = importSourceToScope(ctx, node, scope, source);
  47754. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  47755. }
  47756. function importSourceToScope(ctx, node, scope, source) {
  47757. let fs;
  47758. try {
  47759. fs = resolveFS(ctx);
  47760. } catch (err) {
  47761. return ctx.error(err.message, node, scope);
  47762. }
  47763. if (!fs) {
  47764. return ctx.error(
  47765. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  47766. node,
  47767. scope
  47768. );
  47769. }
  47770. let resolved = scope.resolvedImportSources[source];
  47771. if (!resolved) {
  47772. if (source.startsWith("..")) {
  47773. const osSpecificJoinFn = joinPaths;
  47774. const filename = osSpecificJoinFn(dirname(scope.filename), source);
  47775. resolved = resolveExt(filename, fs);
  47776. } else if (source[0] === ".") {
  47777. const filename = joinPaths(dirname(scope.filename), source);
  47778. resolved = resolveExt(filename, fs);
  47779. } else {
  47780. {
  47781. return ctx.error(
  47782. `Type import from non-relative sources is not supported in the browser build.`,
  47783. node,
  47784. scope
  47785. );
  47786. }
  47787. }
  47788. if (resolved) {
  47789. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  47790. }
  47791. }
  47792. if (resolved) {
  47793. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  47794. return fileToScope(ctx, resolved);
  47795. } else {
  47796. return ctx.error(
  47797. `Failed to resolve import source ${JSON.stringify(source)}.`,
  47798. node,
  47799. scope
  47800. );
  47801. }
  47802. }
  47803. function resolveExt(filename, fs) {
  47804. filename = filename.replace(/\.js$/, "");
  47805. const tryResolve = (filename2) => {
  47806. if (fs.fileExists(filename2)) return filename2;
  47807. };
  47808. return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
  47809. }
  47810. const tsConfigCache = createCache();
  47811. const tsConfigRefMap = /* @__PURE__ */ new Map();
  47812. const fileToScopeCache = createCache();
  47813. function invalidateTypeCache(filename) {
  47814. filename = normalizePath(filename);
  47815. fileToScopeCache.delete(filename);
  47816. tsConfigCache.delete(filename);
  47817. const affectedConfig = tsConfigRefMap.get(filename);
  47818. if (affectedConfig) tsConfigCache.delete(affectedConfig);
  47819. }
  47820. function fileToScope(ctx, filename, asGlobal = false) {
  47821. const cached = fileToScopeCache.get(filename);
  47822. if (cached) {
  47823. return cached;
  47824. }
  47825. const fs = resolveFS(ctx);
  47826. const source = fs.readFile(filename) || "";
  47827. const body = parseFile(filename, source, ctx.options.babelParserPlugins);
  47828. const scope = new TypeScope(filename, source, 0, recordImports(body));
  47829. recordTypes(ctx, body, scope, asGlobal);
  47830. fileToScopeCache.set(filename, scope);
  47831. return scope;
  47832. }
  47833. function parseFile(filename, content, parserPlugins) {
  47834. const ext = extname(filename);
  47835. if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
  47836. return libExports.parse(content, {
  47837. plugins: resolveParserPlugins(
  47838. ext.slice(1),
  47839. parserPlugins,
  47840. /\.d\.m?ts$/.test(filename)
  47841. ),
  47842. sourceType: "module"
  47843. }).program.body;
  47844. } else if (ext === ".vue") {
  47845. const {
  47846. descriptor: { script, scriptSetup }
  47847. } = parse$2(content);
  47848. if (!script && !scriptSetup) {
  47849. return [];
  47850. }
  47851. const scriptOffset = script ? script.loc.start.offset : Infinity;
  47852. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  47853. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  47854. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  47855. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  47856. if (secondBlock) {
  47857. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  47858. }
  47859. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  47860. return libExports.parse(scriptContent, {
  47861. plugins: resolveParserPlugins(lang, parserPlugins),
  47862. sourceType: "module"
  47863. }).program.body;
  47864. }
  47865. return [];
  47866. }
  47867. function ctxToScope(ctx) {
  47868. if (ctx.scope) {
  47869. return ctx.scope;
  47870. }
  47871. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  47872. const scope = new TypeScope(
  47873. ctx.filename,
  47874. ctx.source,
  47875. "startOffset" in ctx ? ctx.startOffset : 0,
  47876. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  47877. );
  47878. recordTypes(ctx, body, scope);
  47879. return ctx.scope = scope;
  47880. }
  47881. function moduleDeclToScope(ctx, node, parentScope) {
  47882. if (node._resolvedChildScope) {
  47883. return node._resolvedChildScope;
  47884. }
  47885. const scope = createChildScope(parentScope);
  47886. if (node.body.type === "TSModuleDeclaration") {
  47887. const decl = node.body;
  47888. decl._ownerScope = scope;
  47889. const id = getId(decl.id);
  47890. scope.types[id] = scope.exportedTypes[id] = decl;
  47891. } else {
  47892. recordTypes(ctx, node.body.body, scope);
  47893. }
  47894. return node._resolvedChildScope = scope;
  47895. }
  47896. function createChildScope(parentScope) {
  47897. return new TypeScope(
  47898. parentScope.filename,
  47899. parentScope.source,
  47900. parentScope.offset,
  47901. Object.create(parentScope.imports),
  47902. Object.create(parentScope.types),
  47903. Object.create(parentScope.declares)
  47904. );
  47905. }
  47906. const importExportRE = /^Import|^Export/;
  47907. function recordTypes(ctx, body, scope, asGlobal = false) {
  47908. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  47909. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  47910. for (const stmt of body) {
  47911. if (asGlobal) {
  47912. if (isAmbient) {
  47913. if (stmt.declare) {
  47914. recordType(stmt, types, declares);
  47915. }
  47916. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  47917. for (const s of stmt.body.body) {
  47918. recordType(s, types, declares);
  47919. }
  47920. }
  47921. } else {
  47922. recordType(stmt, types, declares);
  47923. }
  47924. }
  47925. if (!asGlobal) {
  47926. for (const stmt of body) {
  47927. if (stmt.type === "ExportNamedDeclaration") {
  47928. if (stmt.declaration) {
  47929. recordType(stmt.declaration, types, declares);
  47930. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  47931. } else {
  47932. for (const spec of stmt.specifiers) {
  47933. if (spec.type === "ExportSpecifier") {
  47934. const local = spec.local.name;
  47935. const exported = getId(spec.exported);
  47936. if (stmt.source) {
  47937. imports[exported] = {
  47938. source: stmt.source.value,
  47939. imported: local
  47940. };
  47941. exportedTypes[exported] = {
  47942. type: "TSTypeReference",
  47943. typeName: {
  47944. type: "Identifier",
  47945. name: local
  47946. },
  47947. _ownerScope: scope
  47948. };
  47949. } else if (types[local]) {
  47950. exportedTypes[exported] = types[local];
  47951. }
  47952. }
  47953. }
  47954. }
  47955. } else if (stmt.type === "ExportAllDeclaration") {
  47956. const sourceScope = importSourceToScope(
  47957. ctx,
  47958. stmt.source,
  47959. scope,
  47960. stmt.source.value
  47961. );
  47962. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  47963. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  47964. if (stmt.declaration.type !== "Identifier") {
  47965. recordType(stmt.declaration, types, declares, "default");
  47966. recordType(
  47967. stmt.declaration,
  47968. exportedTypes,
  47969. exportedDeclares,
  47970. "default"
  47971. );
  47972. } else if (types[stmt.declaration.name]) {
  47973. exportedTypes["default"] = types[stmt.declaration.name];
  47974. }
  47975. }
  47976. }
  47977. }
  47978. for (const key of Object.keys(types)) {
  47979. const node = types[key];
  47980. node._ownerScope = scope;
  47981. if (node._ns) node._ns._ownerScope = scope;
  47982. }
  47983. for (const key of Object.keys(declares)) {
  47984. declares[key]._ownerScope = scope;
  47985. }
  47986. }
  47987. function recordType(node, types, declares, overwriteId) {
  47988. switch (node.type) {
  47989. case "TSInterfaceDeclaration":
  47990. case "TSEnumDeclaration":
  47991. case "TSModuleDeclaration": {
  47992. const id = overwriteId || getId(node.id);
  47993. let existing = types[id];
  47994. if (existing) {
  47995. if (node.type === "TSModuleDeclaration") {
  47996. if (existing.type === "TSModuleDeclaration") {
  47997. mergeNamespaces(existing, node);
  47998. } else {
  47999. attachNamespace(existing, node);
  48000. }
  48001. break;
  48002. }
  48003. if (existing.type === "TSModuleDeclaration") {
  48004. types[id] = node;
  48005. attachNamespace(node, existing);
  48006. break;
  48007. }
  48008. if (existing.type !== node.type) {
  48009. break;
  48010. }
  48011. if (node.type === "TSInterfaceDeclaration") {
  48012. existing.body.body.push(...node.body.body);
  48013. } else {
  48014. existing.members.push(...node.members);
  48015. }
  48016. } else {
  48017. types[id] = node;
  48018. }
  48019. break;
  48020. }
  48021. case "ClassDeclaration":
  48022. if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
  48023. break;
  48024. case "TSTypeAliasDeclaration":
  48025. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  48026. break;
  48027. case "TSDeclareFunction":
  48028. if (node.id) declares[node.id.name] = node;
  48029. break;
  48030. case "VariableDeclaration": {
  48031. if (node.declare) {
  48032. for (const decl of node.declarations) {
  48033. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  48034. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  48035. }
  48036. }
  48037. }
  48038. break;
  48039. }
  48040. }
  48041. }
  48042. function mergeNamespaces(to, from) {
  48043. const toBody = to.body;
  48044. const fromBody = from.body;
  48045. if (toBody.type === "TSModuleDeclaration") {
  48046. if (fromBody.type === "TSModuleDeclaration") {
  48047. mergeNamespaces(toBody, fromBody);
  48048. } else {
  48049. fromBody.body.push({
  48050. type: "ExportNamedDeclaration",
  48051. declaration: toBody,
  48052. exportKind: "type",
  48053. specifiers: []
  48054. });
  48055. }
  48056. } else if (fromBody.type === "TSModuleDeclaration") {
  48057. toBody.body.push({
  48058. type: "ExportNamedDeclaration",
  48059. declaration: fromBody,
  48060. exportKind: "type",
  48061. specifiers: []
  48062. });
  48063. } else {
  48064. toBody.body.push(...fromBody.body);
  48065. }
  48066. }
  48067. function attachNamespace(to, ns) {
  48068. if (!to._ns) {
  48069. to._ns = ns;
  48070. } else {
  48071. mergeNamespaces(to._ns, ns);
  48072. }
  48073. }
  48074. function recordImports(body) {
  48075. const imports = /* @__PURE__ */ Object.create(null);
  48076. for (const s of body) {
  48077. recordImport(s, imports);
  48078. }
  48079. return imports;
  48080. }
  48081. function recordImport(node, imports) {
  48082. if (node.type !== "ImportDeclaration") {
  48083. return;
  48084. }
  48085. for (const s of node.specifiers) {
  48086. imports[s.local.name] = {
  48087. imported: getImportedName(s),
  48088. source: node.source.value
  48089. };
  48090. }
  48091. }
  48092. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
  48093. try {
  48094. switch (node.type) {
  48095. case "TSStringKeyword":
  48096. return ["String"];
  48097. case "TSNumberKeyword":
  48098. return ["Number"];
  48099. case "TSBooleanKeyword":
  48100. return ["Boolean"];
  48101. case "TSObjectKeyword":
  48102. return ["Object"];
  48103. case "TSNullKeyword":
  48104. return ["null"];
  48105. case "TSTypeLiteral":
  48106. case "TSInterfaceDeclaration": {
  48107. const types = /* @__PURE__ */ new Set();
  48108. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  48109. for (const m of members) {
  48110. if (isKeyOf) {
  48111. if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
  48112. types.add("Number");
  48113. } else if (m.type === "TSIndexSignature") {
  48114. const annotation = m.parameters[0].typeAnnotation;
  48115. if (annotation && annotation.type !== "Noop") {
  48116. const type = inferRuntimeType(
  48117. ctx,
  48118. annotation.typeAnnotation,
  48119. scope
  48120. )[0];
  48121. if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
  48122. types.add(type);
  48123. }
  48124. } else {
  48125. types.add("String");
  48126. }
  48127. } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  48128. types.add("Function");
  48129. } else {
  48130. types.add("Object");
  48131. }
  48132. }
  48133. return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
  48134. }
  48135. case "TSPropertySignature":
  48136. if (node.typeAnnotation) {
  48137. return inferRuntimeType(
  48138. ctx,
  48139. node.typeAnnotation.typeAnnotation,
  48140. scope
  48141. );
  48142. }
  48143. break;
  48144. case "TSMethodSignature":
  48145. case "TSFunctionType":
  48146. return ["Function"];
  48147. case "TSArrayType":
  48148. case "TSTupleType":
  48149. return ["Array"];
  48150. case "TSLiteralType":
  48151. switch (node.literal.type) {
  48152. case "StringLiteral":
  48153. return ["String"];
  48154. case "BooleanLiteral":
  48155. return ["Boolean"];
  48156. case "NumericLiteral":
  48157. case "BigIntLiteral":
  48158. return ["Number"];
  48159. default:
  48160. return [UNKNOWN_TYPE];
  48161. }
  48162. case "TSTypeReference": {
  48163. const resolved = resolveTypeReference(ctx, node, scope);
  48164. if (resolved) {
  48165. return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
  48166. }
  48167. if (node.typeName.type === "Identifier") {
  48168. if (isKeyOf) {
  48169. switch (node.typeName.name) {
  48170. case "String":
  48171. case "Array":
  48172. case "ArrayLike":
  48173. case "Parameters":
  48174. case "ConstructorParameters":
  48175. case "ReadonlyArray":
  48176. return ["String", "Number"];
  48177. // TS built-in utility types
  48178. case "Record":
  48179. case "Partial":
  48180. case "Required":
  48181. case "Readonly":
  48182. if (node.typeParameters && node.typeParameters.params[0]) {
  48183. return inferRuntimeType(
  48184. ctx,
  48185. node.typeParameters.params[0],
  48186. scope,
  48187. true
  48188. );
  48189. }
  48190. break;
  48191. case "Pick":
  48192. case "Extract":
  48193. if (node.typeParameters && node.typeParameters.params[1]) {
  48194. return inferRuntimeType(
  48195. ctx,
  48196. node.typeParameters.params[1],
  48197. scope
  48198. );
  48199. }
  48200. break;
  48201. case "Function":
  48202. case "Object":
  48203. case "Set":
  48204. case "Map":
  48205. case "WeakSet":
  48206. case "WeakMap":
  48207. case "Date":
  48208. case "Promise":
  48209. case "Error":
  48210. case "Uppercase":
  48211. case "Lowercase":
  48212. case "Capitalize":
  48213. case "Uncapitalize":
  48214. case "ReadonlyMap":
  48215. case "ReadonlySet":
  48216. return ["String"];
  48217. }
  48218. } else {
  48219. switch (node.typeName.name) {
  48220. case "Array":
  48221. case "Function":
  48222. case "Object":
  48223. case "Set":
  48224. case "Map":
  48225. case "WeakSet":
  48226. case "WeakMap":
  48227. case "Date":
  48228. case "Promise":
  48229. case "Error":
  48230. return [node.typeName.name];
  48231. // TS built-in utility types
  48232. // https://www.typescriptlang.org/docs/handbook/utility-types.html
  48233. case "Partial":
  48234. case "Required":
  48235. case "Readonly":
  48236. case "Record":
  48237. case "Pick":
  48238. case "Omit":
  48239. case "InstanceType":
  48240. return ["Object"];
  48241. case "Uppercase":
  48242. case "Lowercase":
  48243. case "Capitalize":
  48244. case "Uncapitalize":
  48245. return ["String"];
  48246. case "Parameters":
  48247. case "ConstructorParameters":
  48248. case "ReadonlyArray":
  48249. return ["Array"];
  48250. case "ReadonlyMap":
  48251. return ["Map"];
  48252. case "ReadonlySet":
  48253. return ["Set"];
  48254. case "NonNullable":
  48255. if (node.typeParameters && node.typeParameters.params[0]) {
  48256. return inferRuntimeType(
  48257. ctx,
  48258. node.typeParameters.params[0],
  48259. scope
  48260. ).filter((t) => t !== "null");
  48261. }
  48262. break;
  48263. case "Extract":
  48264. if (node.typeParameters && node.typeParameters.params[1]) {
  48265. return inferRuntimeType(
  48266. ctx,
  48267. node.typeParameters.params[1],
  48268. scope
  48269. );
  48270. }
  48271. break;
  48272. case "Exclude":
  48273. case "OmitThisParameter":
  48274. if (node.typeParameters && node.typeParameters.params[0]) {
  48275. return inferRuntimeType(
  48276. ctx,
  48277. node.typeParameters.params[0],
  48278. scope
  48279. );
  48280. }
  48281. break;
  48282. }
  48283. }
  48284. }
  48285. break;
  48286. }
  48287. case "TSParenthesizedType":
  48288. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  48289. case "TSUnionType":
  48290. return flattenTypes(ctx, node.types, scope, isKeyOf);
  48291. case "TSIntersectionType": {
  48292. return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
  48293. (t) => t !== UNKNOWN_TYPE
  48294. );
  48295. }
  48296. case "TSEnumDeclaration":
  48297. return inferEnumType(node);
  48298. case "TSSymbolKeyword":
  48299. return ["Symbol"];
  48300. case "TSIndexedAccessType": {
  48301. const types = resolveIndexType(ctx, node, scope);
  48302. return flattenTypes(ctx, types, scope, isKeyOf);
  48303. }
  48304. case "ClassDeclaration":
  48305. return ["Object"];
  48306. case "TSImportType": {
  48307. const sourceScope = importSourceToScope(
  48308. ctx,
  48309. node.argument,
  48310. scope,
  48311. node.argument.value
  48312. );
  48313. const resolved = resolveTypeReference(ctx, node, sourceScope);
  48314. if (resolved) {
  48315. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  48316. }
  48317. break;
  48318. }
  48319. case "TSTypeQuery": {
  48320. const id = node.exprName;
  48321. if (id.type === "Identifier") {
  48322. const matched = scope.declares[id.name];
  48323. if (matched) {
  48324. return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
  48325. }
  48326. }
  48327. break;
  48328. }
  48329. // e.g. readonly
  48330. case "TSTypeOperator": {
  48331. return inferRuntimeType(
  48332. ctx,
  48333. node.typeAnnotation,
  48334. scope,
  48335. node.operator === "keyof"
  48336. );
  48337. }
  48338. case "TSAnyKeyword": {
  48339. if (isKeyOf) {
  48340. return ["String", "Number", "Symbol"];
  48341. }
  48342. break;
  48343. }
  48344. }
  48345. } catch (e) {
  48346. }
  48347. return [UNKNOWN_TYPE];
  48348. }
  48349. function flattenTypes(ctx, types, scope, isKeyOf = false) {
  48350. if (types.length === 1) {
  48351. return inferRuntimeType(ctx, types[0], scope, isKeyOf);
  48352. }
  48353. return [
  48354. ...new Set(
  48355. [].concat(
  48356. ...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
  48357. )
  48358. )
  48359. ];
  48360. }
  48361. function inferEnumType(node) {
  48362. const types = /* @__PURE__ */ new Set();
  48363. for (const m of node.members) {
  48364. if (m.initializer) {
  48365. switch (m.initializer.type) {
  48366. case "StringLiteral":
  48367. types.add("String");
  48368. break;
  48369. case "NumericLiteral":
  48370. types.add("Number");
  48371. break;
  48372. }
  48373. }
  48374. }
  48375. return types.size ? [...types] : ["Number"];
  48376. }
  48377. function resolveExtractPropTypes({ props }, scope) {
  48378. const res = { props: {} };
  48379. for (const key in props) {
  48380. const raw = props[key];
  48381. res.props[key] = reverseInferType(
  48382. raw.key,
  48383. raw.typeAnnotation.typeAnnotation,
  48384. scope
  48385. );
  48386. }
  48387. return res;
  48388. }
  48389. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  48390. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  48391. const typeType = findStaticPropertyType(node, "type");
  48392. if (typeType) {
  48393. const requiredType = findStaticPropertyType(node, "required");
  48394. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  48395. return reverseInferType(key, typeType, scope, optional2, false);
  48396. }
  48397. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  48398. if (node.typeName.name.endsWith("Constructor")) {
  48399. return createProperty(
  48400. key,
  48401. ctorToType(node.typeName.name),
  48402. scope,
  48403. optional
  48404. );
  48405. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  48406. return createProperty(key, node.typeParameters.params[0], scope, optional);
  48407. }
  48408. }
  48409. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  48410. for (const t of node.typeParameters.params) {
  48411. const inferred = reverseInferType(key, t, scope, optional);
  48412. if (inferred) return inferred;
  48413. }
  48414. }
  48415. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  48416. }
  48417. function ctorToType(ctorType) {
  48418. const ctor = ctorType.slice(0, -11);
  48419. switch (ctor) {
  48420. case "String":
  48421. case "Number":
  48422. case "Boolean":
  48423. return { type: `TS${ctor}Keyword` };
  48424. case "Array":
  48425. case "Function":
  48426. case "Object":
  48427. case "Set":
  48428. case "Map":
  48429. case "WeakSet":
  48430. case "WeakMap":
  48431. case "Date":
  48432. case "Promise":
  48433. return {
  48434. type: "TSTypeReference",
  48435. typeName: { type: "Identifier", name: ctor }
  48436. };
  48437. }
  48438. return { type: `TSNullKeyword` };
  48439. }
  48440. function findStaticPropertyType(node, key) {
  48441. const prop = node.members.find(
  48442. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  48443. );
  48444. return prop && prop.typeAnnotation.typeAnnotation;
  48445. }
  48446. function resolveReturnType(ctx, arg, scope) {
  48447. var _a;
  48448. let resolved = arg;
  48449. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  48450. resolved = resolveTypeReference(ctx, arg, scope);
  48451. }
  48452. if (!resolved) return;
  48453. if (resolved.type === "TSFunctionType") {
  48454. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  48455. }
  48456. if (resolved.type === "TSDeclareFunction") {
  48457. return resolved.returnType;
  48458. }
  48459. }
  48460. function resolveUnionType(ctx, node, scope) {
  48461. if (node.type === "TSTypeReference") {
  48462. const resolved = resolveTypeReference(ctx, node, scope);
  48463. if (resolved) node = resolved;
  48464. }
  48465. let types;
  48466. if (node.type === "TSUnionType") {
  48467. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  48468. } else {
  48469. types = [node];
  48470. }
  48471. return types;
  48472. }
  48473. const DEFINE_MODEL = "defineModel";
  48474. function processDefineModel(ctx, node, declId) {
  48475. if (!isCallOf(node, DEFINE_MODEL)) {
  48476. return false;
  48477. }
  48478. ctx.hasDefineModelCall = true;
  48479. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  48480. let modelName;
  48481. let options;
  48482. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  48483. const hasName = arg0 && arg0.type === "StringLiteral";
  48484. if (hasName) {
  48485. modelName = arg0.value;
  48486. options = node.arguments[1];
  48487. } else {
  48488. modelName = "modelValue";
  48489. options = arg0;
  48490. }
  48491. if (ctx.modelDecls[modelName]) {
  48492. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  48493. }
  48494. let optionsString = options && ctx.getString(options);
  48495. let optionsRemoved = !options;
  48496. const runtimeOptionNodes = [];
  48497. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  48498. let removed = 0;
  48499. for (let i = options.properties.length - 1; i >= 0; i--) {
  48500. const p = options.properties[i];
  48501. const next = options.properties[i + 1];
  48502. const start = p.start;
  48503. const end = next ? next.start : options.end - 1;
  48504. 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"))) {
  48505. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  48506. } else {
  48507. removed++;
  48508. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  48509. runtimeOptionNodes.push(p);
  48510. }
  48511. }
  48512. if (removed === options.properties.length) {
  48513. optionsRemoved = true;
  48514. ctx.s.remove(
  48515. ctx.startOffset + (hasName ? arg0.end : options.start),
  48516. ctx.startOffset + options.end
  48517. );
  48518. }
  48519. }
  48520. ctx.modelDecls[modelName] = {
  48521. type,
  48522. options: optionsString,
  48523. runtimeOptionNodes,
  48524. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  48525. };
  48526. ctx.bindingMetadata[modelName] = "props";
  48527. ctx.s.overwrite(
  48528. ctx.startOffset + node.callee.start,
  48529. ctx.startOffset + node.callee.end,
  48530. ctx.helper("useModel")
  48531. );
  48532. ctx.s.appendLeft(
  48533. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  48534. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  48535. );
  48536. return true;
  48537. }
  48538. function genModelProps(ctx) {
  48539. if (!ctx.hasDefineModelCall) return;
  48540. const isProd = !!ctx.options.isProd;
  48541. let modelPropsDecl = "";
  48542. for (const [name, { type, options: runtimeOptions }] of Object.entries(
  48543. ctx.modelDecls
  48544. )) {
  48545. let skipCheck = false;
  48546. let codegenOptions = ``;
  48547. let runtimeTypes = type && inferRuntimeType(ctx, type);
  48548. if (runtimeTypes) {
  48549. const hasBoolean = runtimeTypes.includes("Boolean");
  48550. const hasFunction = runtimeTypes.includes("Function");
  48551. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  48552. if (hasUnknownType) {
  48553. if (hasBoolean || hasFunction) {
  48554. runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
  48555. skipCheck = true;
  48556. } else {
  48557. runtimeTypes = ["null"];
  48558. }
  48559. }
  48560. if (!isProd) {
  48561. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
  48562. } else if (hasBoolean || runtimeOptions && hasFunction) {
  48563. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
  48564. } else ;
  48565. }
  48566. let decl;
  48567. if (codegenOptions && runtimeOptions) {
  48568. decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
  48569. } else if (codegenOptions) {
  48570. decl = `{ ${codegenOptions} }`;
  48571. } else if (runtimeOptions) {
  48572. decl = runtimeOptions;
  48573. } else {
  48574. decl = `{}`;
  48575. }
  48576. modelPropsDecl += `
  48577. ${JSON.stringify(name)}: ${decl},`;
  48578. const modifierPropName = JSON.stringify(
  48579. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  48580. );
  48581. modelPropsDecl += `
  48582. ${modifierPropName}: {},`;
  48583. }
  48584. return `{${modelPropsDecl}
  48585. }`;
  48586. }
  48587. const DEFINE_PROPS = "defineProps";
  48588. const WITH_DEFAULTS = "withDefaults";
  48589. function processDefineProps(ctx, node, declId, isWithDefaults = false) {
  48590. if (!isCallOf(node, DEFINE_PROPS)) {
  48591. return processWithDefaults(ctx, node, declId);
  48592. }
  48593. if (ctx.hasDefinePropsCall) {
  48594. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  48595. }
  48596. ctx.hasDefinePropsCall = true;
  48597. ctx.propsRuntimeDecl = node.arguments[0];
  48598. if (ctx.propsRuntimeDecl) {
  48599. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  48600. if (!(key in ctx.bindingMetadata)) {
  48601. ctx.bindingMetadata[key] = "props";
  48602. }
  48603. }
  48604. }
  48605. if (node.typeParameters) {
  48606. if (ctx.propsRuntimeDecl) {
  48607. ctx.error(
  48608. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  48609. node
  48610. );
  48611. }
  48612. ctx.propsTypeDecl = node.typeParameters.params[0];
  48613. }
  48614. if (!isWithDefaults && declId && declId.type === "ObjectPattern") {
  48615. processPropsDestructure(ctx, declId);
  48616. }
  48617. ctx.propsCall = node;
  48618. ctx.propsDecl = declId;
  48619. return true;
  48620. }
  48621. function processWithDefaults(ctx, node, declId) {
  48622. if (!isCallOf(node, WITH_DEFAULTS)) {
  48623. return false;
  48624. }
  48625. if (!processDefineProps(
  48626. ctx,
  48627. node.arguments[0],
  48628. declId,
  48629. true
  48630. )) {
  48631. ctx.error(
  48632. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  48633. node.arguments[0] || node
  48634. );
  48635. }
  48636. if (ctx.propsRuntimeDecl) {
  48637. ctx.error(
  48638. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  48639. node
  48640. );
  48641. }
  48642. if (declId && declId.type === "ObjectPattern") {
  48643. ctx.warn(
  48644. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  48645. Reactive destructure will be disabled when using withDefaults().
  48646. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...). `,
  48647. node.callee
  48648. );
  48649. }
  48650. ctx.propsRuntimeDefaults = node.arguments[1];
  48651. if (!ctx.propsRuntimeDefaults) {
  48652. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  48653. }
  48654. ctx.propsCall = node;
  48655. return true;
  48656. }
  48657. function genRuntimeProps(ctx) {
  48658. let propsDecls;
  48659. if (ctx.propsRuntimeDecl) {
  48660. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  48661. if (ctx.propsDestructureDecl) {
  48662. const defaults = [];
  48663. for (const key in ctx.propsDestructuredBindings) {
  48664. const d = genDestructuredDefaultValue(ctx, key);
  48665. const finalKey = getEscapedPropName(key);
  48666. if (d)
  48667. defaults.push(
  48668. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  48669. );
  48670. }
  48671. if (defaults.length) {
  48672. propsDecls = `/*@__PURE__*/${ctx.helper(
  48673. `mergeDefaults`
  48674. )}(${propsDecls}, {
  48675. ${defaults.join(",\n ")}
  48676. })`;
  48677. }
  48678. }
  48679. } else if (ctx.propsTypeDecl) {
  48680. propsDecls = extractRuntimeProps(ctx);
  48681. }
  48682. const modelsDecls = genModelProps(ctx);
  48683. if (propsDecls && modelsDecls) {
  48684. return `/*@__PURE__*/${ctx.helper(
  48685. "mergeModels"
  48686. )}(${propsDecls}, ${modelsDecls})`;
  48687. } else {
  48688. return modelsDecls || propsDecls;
  48689. }
  48690. }
  48691. function extractRuntimeProps(ctx) {
  48692. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  48693. if (!props.length) {
  48694. return;
  48695. }
  48696. const propStrings = [];
  48697. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  48698. for (const prop of props) {
  48699. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  48700. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  48701. ctx.bindingMetadata[prop.key] = "props";
  48702. }
  48703. }
  48704. let propsDecls = `{
  48705. ${propStrings.join(",\n ")}
  48706. }`;
  48707. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  48708. propsDecls = `/*@__PURE__*/${ctx.helper(
  48709. "mergeDefaults"
  48710. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  48711. }
  48712. return propsDecls;
  48713. }
  48714. function resolveRuntimePropsFromType(ctx, node) {
  48715. const props = [];
  48716. const elements = resolveTypeElements(ctx, node);
  48717. for (const key in elements.props) {
  48718. const e = elements.props[key];
  48719. let type = inferRuntimeType(ctx, e);
  48720. let skipCheck = false;
  48721. if (type.includes(UNKNOWN_TYPE)) {
  48722. if (type.includes("Boolean") || type.includes("Function")) {
  48723. type = type.filter((t) => t !== UNKNOWN_TYPE);
  48724. skipCheck = true;
  48725. } else {
  48726. type = ["null"];
  48727. }
  48728. }
  48729. props.push({
  48730. key,
  48731. required: !e.optional,
  48732. type: type || [`null`],
  48733. skipCheck
  48734. });
  48735. }
  48736. return props;
  48737. }
  48738. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  48739. let defaultString;
  48740. const destructured = genDestructuredDefaultValue(ctx, key, type);
  48741. if (destructured) {
  48742. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  48743. } else if (hasStaticDefaults) {
  48744. const prop = ctx.propsRuntimeDefaults.properties.find(
  48745. (node) => {
  48746. if (node.type === "SpreadElement") return false;
  48747. return resolveObjectKey(node.key, node.computed) === key;
  48748. }
  48749. );
  48750. if (prop) {
  48751. if (prop.type === "ObjectProperty") {
  48752. defaultString = `default: ${ctx.getString(prop.value)}`;
  48753. } else {
  48754. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  48755. }
  48756. }
  48757. }
  48758. const finalKey = getEscapedPropName(key);
  48759. if (!ctx.options.isProd) {
  48760. return `${finalKey}: { ${concatStrings([
  48761. `type: ${toRuntimeTypeString(type)}`,
  48762. `required: ${required}`,
  48763. skipCheck && "skipCheck: true",
  48764. defaultString
  48765. ])} }`;
  48766. } else if (type.some(
  48767. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  48768. )) {
  48769. return `${finalKey}: { ${concatStrings([
  48770. `type: ${toRuntimeTypeString(type)}`,
  48771. defaultString
  48772. ])} }`;
  48773. } else {
  48774. if (ctx.isCE) {
  48775. if (defaultString) {
  48776. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  48777. type
  48778. )} }`}`;
  48779. } else {
  48780. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  48781. }
  48782. }
  48783. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  48784. }
  48785. }
  48786. function hasStaticWithDefaults(ctx) {
  48787. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  48788. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  48789. ));
  48790. }
  48791. function genDestructuredDefaultValue(ctx, key, inferredType) {
  48792. const destructured = ctx.propsDestructuredBindings[key];
  48793. const defaultVal = destructured && destructured.default;
  48794. if (defaultVal) {
  48795. const value = ctx.getString(defaultVal);
  48796. const unwrapped = unwrapTSNode(defaultVal);
  48797. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  48798. const valueType = inferValueType(unwrapped);
  48799. if (valueType && !inferredType.includes(valueType)) {
  48800. ctx.error(
  48801. `Default value of prop "${key}" does not match declared type.`,
  48802. unwrapped
  48803. );
  48804. }
  48805. }
  48806. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  48807. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  48808. return {
  48809. valueString: needFactoryWrap ? `() => (${value})` : value,
  48810. needSkipFactory
  48811. };
  48812. }
  48813. }
  48814. function inferValueType(node) {
  48815. switch (node.type) {
  48816. case "StringLiteral":
  48817. return "String";
  48818. case "NumericLiteral":
  48819. return "Number";
  48820. case "BooleanLiteral":
  48821. return "Boolean";
  48822. case "ObjectExpression":
  48823. return "Object";
  48824. case "ArrayExpression":
  48825. return "Array";
  48826. case "FunctionExpression":
  48827. case "ArrowFunctionExpression":
  48828. return "Function";
  48829. }
  48830. }
  48831. function processPropsDestructure(ctx, declId) {
  48832. if (ctx.options.propsDestructure === "error") {
  48833. ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
  48834. } else if (ctx.options.propsDestructure === false) {
  48835. return;
  48836. }
  48837. ctx.propsDestructureDecl = declId;
  48838. const registerBinding = (key, local, defaultValue) => {
  48839. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  48840. if (local !== key) {
  48841. ctx.bindingMetadata[local] = "props-aliased";
  48842. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  48843. }
  48844. };
  48845. for (const prop of declId.properties) {
  48846. if (prop.type === "ObjectProperty") {
  48847. const propKey = resolveObjectKey(prop.key, prop.computed);
  48848. if (!propKey) {
  48849. ctx.error(
  48850. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  48851. prop.key
  48852. );
  48853. }
  48854. if (prop.value.type === "AssignmentPattern") {
  48855. const { left, right } = prop.value;
  48856. if (left.type !== "Identifier") {
  48857. ctx.error(
  48858. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  48859. left
  48860. );
  48861. }
  48862. registerBinding(propKey, left.name, right);
  48863. } else if (prop.value.type === "Identifier") {
  48864. registerBinding(propKey, prop.value.name);
  48865. } else {
  48866. ctx.error(
  48867. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  48868. prop.value
  48869. );
  48870. }
  48871. } else {
  48872. ctx.propsDestructureRestId = prop.argument.name;
  48873. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  48874. }
  48875. }
  48876. }
  48877. function transformDestructuredProps(ctx, vueImportAliases) {
  48878. if (ctx.options.propsDestructure === false) {
  48879. return;
  48880. }
  48881. const rootScope = /* @__PURE__ */ Object.create(null);
  48882. const scopeStack = [rootScope];
  48883. let currentScope = rootScope;
  48884. const excludedIds = /* @__PURE__ */ new WeakSet();
  48885. const parentStack = [];
  48886. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  48887. for (const key in ctx.propsDestructuredBindings) {
  48888. const { local } = ctx.propsDestructuredBindings[key];
  48889. rootScope[local] = true;
  48890. propsLocalToPublicMap[local] = key;
  48891. }
  48892. function pushScope() {
  48893. scopeStack.push(currentScope = Object.create(currentScope));
  48894. }
  48895. function popScope() {
  48896. scopeStack.pop();
  48897. currentScope = scopeStack[scopeStack.length - 1] || null;
  48898. }
  48899. function registerLocalBinding(id) {
  48900. excludedIds.add(id);
  48901. if (currentScope) {
  48902. currentScope[id.name] = false;
  48903. } else {
  48904. ctx.error(
  48905. "registerBinding called without active scope, something is wrong.",
  48906. id
  48907. );
  48908. }
  48909. }
  48910. function walkScope(node, isRoot = false) {
  48911. for (const stmt of node.body) {
  48912. if (stmt.type === "VariableDeclaration") {
  48913. walkVariableDeclaration(stmt, isRoot);
  48914. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  48915. if (stmt.declare || !stmt.id) continue;
  48916. registerLocalBinding(stmt.id);
  48917. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  48918. walkVariableDeclaration(stmt.left);
  48919. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  48920. walkVariableDeclaration(stmt.declaration, isRoot);
  48921. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  48922. walkVariableDeclaration(stmt.body, isRoot);
  48923. }
  48924. }
  48925. }
  48926. function walkVariableDeclaration(stmt, isRoot = false) {
  48927. if (stmt.declare) {
  48928. return;
  48929. }
  48930. for (const decl of stmt.declarations) {
  48931. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  48932. for (const id of extractIdentifiers$1(decl.id)) {
  48933. if (isDefineProps) {
  48934. excludedIds.add(id);
  48935. } else {
  48936. registerLocalBinding(id);
  48937. }
  48938. }
  48939. }
  48940. }
  48941. function rewriteId(id, parent, parentStack2) {
  48942. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  48943. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  48944. }
  48945. if (isStaticProperty(parent) && parent.shorthand) {
  48946. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  48947. ctx.s.appendLeft(
  48948. id.end + ctx.startOffset,
  48949. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  48950. );
  48951. }
  48952. } else {
  48953. ctx.s.overwrite(
  48954. id.start + ctx.startOffset,
  48955. id.end + ctx.startOffset,
  48956. genPropsAccessExp(propsLocalToPublicMap[id.name])
  48957. );
  48958. }
  48959. }
  48960. function checkUsage(node, method, alias = method) {
  48961. if (isCallOf(node, alias)) {
  48962. const arg = unwrapTSNode(node.arguments[0]);
  48963. if (arg.type === "Identifier" && currentScope[arg.name]) {
  48964. ctx.error(
  48965. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  48966. arg
  48967. );
  48968. }
  48969. }
  48970. }
  48971. const ast = ctx.scriptSetupAst;
  48972. walkScope(ast, true);
  48973. walk$2(ast, {
  48974. enter(node, parent) {
  48975. parent && parentStack.push(parent);
  48976. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  48977. return this.skip();
  48978. }
  48979. checkUsage(node, "watch", vueImportAliases.watch);
  48980. checkUsage(node, "toRef", vueImportAliases.toRef);
  48981. if (isFunctionType(node)) {
  48982. pushScope();
  48983. walkFunctionParams(node, registerLocalBinding);
  48984. if (node.body.type === "BlockStatement") {
  48985. walkScope(node.body);
  48986. }
  48987. return;
  48988. }
  48989. if (node.type === "CatchClause") {
  48990. pushScope();
  48991. if (node.param && node.param.type === "Identifier") {
  48992. registerLocalBinding(node.param);
  48993. }
  48994. walkScope(node.body);
  48995. return;
  48996. }
  48997. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  48998. pushScope();
  48999. walkScope(node);
  49000. return;
  49001. }
  49002. if (node.type === "Identifier") {
  49003. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  49004. if (currentScope[node.name]) {
  49005. rewriteId(node, parent, parentStack);
  49006. }
  49007. }
  49008. }
  49009. },
  49010. leave(node, parent) {
  49011. parent && parentStack.pop();
  49012. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node)) {
  49013. popScope();
  49014. }
  49015. }
  49016. });
  49017. }
  49018. const DEFINE_EMITS = "defineEmits";
  49019. function processDefineEmits(ctx, node, declId) {
  49020. if (!isCallOf(node, DEFINE_EMITS)) {
  49021. return false;
  49022. }
  49023. if (ctx.hasDefineEmitCall) {
  49024. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  49025. }
  49026. ctx.hasDefineEmitCall = true;
  49027. ctx.emitsRuntimeDecl = node.arguments[0];
  49028. if (node.typeParameters) {
  49029. if (ctx.emitsRuntimeDecl) {
  49030. ctx.error(
  49031. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  49032. node
  49033. );
  49034. }
  49035. ctx.emitsTypeDecl = node.typeParameters.params[0];
  49036. }
  49037. ctx.emitDecl = declId;
  49038. return true;
  49039. }
  49040. function genRuntimeEmits(ctx) {
  49041. let emitsDecl = "";
  49042. if (ctx.emitsRuntimeDecl) {
  49043. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  49044. } else if (ctx.emitsTypeDecl) {
  49045. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  49046. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  49047. }
  49048. if (ctx.hasDefineModelCall) {
  49049. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  49050. emitsDecl = emitsDecl ? `/*@__PURE__*/${ctx.helper(
  49051. "mergeModels"
  49052. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  49053. }
  49054. return emitsDecl;
  49055. }
  49056. function extractRuntimeEmits(ctx) {
  49057. const emits = /* @__PURE__ */ new Set();
  49058. const node = ctx.emitsTypeDecl;
  49059. if (node.type === "TSFunctionType") {
  49060. extractEventNames(ctx, node.parameters[0], emits);
  49061. return emits;
  49062. }
  49063. const { props, calls } = resolveTypeElements(ctx, node);
  49064. let hasProperty = false;
  49065. for (const key in props) {
  49066. emits.add(key);
  49067. hasProperty = true;
  49068. }
  49069. if (calls) {
  49070. if (hasProperty) {
  49071. ctx.error(
  49072. `defineEmits() type cannot mixed call signature and property syntax.`,
  49073. node
  49074. );
  49075. }
  49076. for (const call of calls) {
  49077. extractEventNames(ctx, call.parameters[0], emits);
  49078. }
  49079. }
  49080. return emits;
  49081. }
  49082. function extractEventNames(ctx, eventName, emits) {
  49083. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  49084. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  49085. for (const type of types) {
  49086. if (type.type === "TSLiteralType") {
  49087. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  49088. emits.add(String(type.literal.value));
  49089. }
  49090. }
  49091. }
  49092. }
  49093. }
  49094. const DEFINE_EXPOSE = "defineExpose";
  49095. function processDefineExpose(ctx, node) {
  49096. if (isCallOf(node, DEFINE_EXPOSE)) {
  49097. if (ctx.hasDefineExposeCall) {
  49098. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  49099. }
  49100. ctx.hasDefineExposeCall = true;
  49101. return true;
  49102. }
  49103. return false;
  49104. }
  49105. const DEFINE_SLOTS = "defineSlots";
  49106. function processDefineSlots(ctx, node, declId) {
  49107. if (!isCallOf(node, DEFINE_SLOTS)) {
  49108. return false;
  49109. }
  49110. if (ctx.hasDefineSlotsCall) {
  49111. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  49112. }
  49113. ctx.hasDefineSlotsCall = true;
  49114. if (node.arguments.length > 0) {
  49115. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  49116. }
  49117. if (declId) {
  49118. ctx.s.overwrite(
  49119. ctx.startOffset + node.start,
  49120. ctx.startOffset + node.end,
  49121. `${ctx.helper("useSlots")}()`
  49122. );
  49123. }
  49124. return true;
  49125. }
  49126. const DEFINE_OPTIONS = "defineOptions";
  49127. function processDefineOptions(ctx, node) {
  49128. if (!isCallOf(node, DEFINE_OPTIONS)) {
  49129. return false;
  49130. }
  49131. if (ctx.hasDefineOptionsCall) {
  49132. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  49133. }
  49134. if (node.typeParameters) {
  49135. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  49136. }
  49137. if (!node.arguments[0]) return true;
  49138. ctx.hasDefineOptionsCall = true;
  49139. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  49140. let propsOption = void 0;
  49141. let emitsOption = void 0;
  49142. let exposeOption = void 0;
  49143. let slotsOption = void 0;
  49144. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  49145. for (const prop of ctx.optionsRuntimeDecl.properties) {
  49146. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  49147. switch (prop.key.name) {
  49148. case "props":
  49149. propsOption = prop;
  49150. break;
  49151. case "emits":
  49152. emitsOption = prop;
  49153. break;
  49154. case "expose":
  49155. exposeOption = prop;
  49156. break;
  49157. case "slots":
  49158. slotsOption = prop;
  49159. break;
  49160. }
  49161. }
  49162. }
  49163. }
  49164. if (propsOption) {
  49165. ctx.error(
  49166. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  49167. propsOption
  49168. );
  49169. }
  49170. if (emitsOption) {
  49171. ctx.error(
  49172. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  49173. emitsOption
  49174. );
  49175. }
  49176. if (exposeOption) {
  49177. ctx.error(
  49178. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  49179. exposeOption
  49180. );
  49181. }
  49182. if (slotsOption) {
  49183. ctx.error(
  49184. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  49185. slotsOption
  49186. );
  49187. }
  49188. return true;
  49189. }
  49190. function processAwait(ctx, node, needSemi, isStatement) {
  49191. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  49192. const startOffset = ctx.startOffset;
  49193. const argumentStr = ctx.descriptor.source.slice(
  49194. argumentStart + startOffset,
  49195. node.argument.end + startOffset
  49196. );
  49197. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  49198. ctx.s.overwrite(
  49199. node.start + startOffset,
  49200. argumentStart + startOffset,
  49201. `${needSemi ? `;` : ``}(
  49202. ([__temp,__restore] = ${ctx.helper(
  49203. `withAsyncContext`
  49204. )}(${containsNestedAwait ? `async ` : ``}() => `
  49205. );
  49206. ctx.s.appendLeft(
  49207. node.end + startOffset,
  49208. `)),
  49209. ${isStatement ? `` : `__temp = `}await __temp,
  49210. __restore()${isStatement ? `` : `,
  49211. __temp`}
  49212. )`
  49213. );
  49214. }
  49215. var __defProp$1 = Object.defineProperty;
  49216. var __defProps = Object.defineProperties;
  49217. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  49218. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  49219. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  49220. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  49221. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  49222. var __spreadValues$1 = (a, b) => {
  49223. for (var prop in b || (b = {}))
  49224. if (__hasOwnProp$1.call(b, prop))
  49225. __defNormalProp$1(a, prop, b[prop]);
  49226. if (__getOwnPropSymbols$1)
  49227. for (var prop of __getOwnPropSymbols$1(b)) {
  49228. if (__propIsEnum$1.call(b, prop))
  49229. __defNormalProp$1(a, prop, b[prop]);
  49230. }
  49231. return a;
  49232. };
  49233. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  49234. const MACROS = [
  49235. DEFINE_PROPS,
  49236. DEFINE_EMITS,
  49237. DEFINE_EXPOSE,
  49238. DEFINE_OPTIONS,
  49239. DEFINE_SLOTS,
  49240. DEFINE_MODEL,
  49241. WITH_DEFAULTS
  49242. ];
  49243. function compileScript(sfc, options) {
  49244. var _a, _b, _c;
  49245. if (!options.id) {
  49246. warnOnce$1(
  49247. `compileScript now requires passing the \`id\` option.
  49248. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  49249. );
  49250. }
  49251. const ctx = new ScriptCompileContext(sfc, options);
  49252. const { script, scriptSetup, source, filename } = sfc;
  49253. const hoistStatic = options.hoistStatic !== false && !script;
  49254. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  49255. const scriptLang = script && script.lang;
  49256. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  49257. if (!scriptSetup) {
  49258. if (!script) {
  49259. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  49260. }
  49261. return processNormalScript(ctx, scopeId);
  49262. }
  49263. if (script && scriptLang !== scriptSetupLang) {
  49264. throw new Error(
  49265. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  49266. );
  49267. }
  49268. if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
  49269. return scriptSetup;
  49270. }
  49271. const scriptBindings = /* @__PURE__ */ Object.create(null);
  49272. const setupBindings = /* @__PURE__ */ Object.create(null);
  49273. let defaultExport;
  49274. let hasAwait = false;
  49275. let hasInlinedSsrRenderFn = false;
  49276. const startOffset = ctx.startOffset;
  49277. const endOffset = ctx.endOffset;
  49278. const scriptStartOffset = script && script.loc.start.offset;
  49279. const scriptEndOffset = script && script.loc.end.offset;
  49280. function hoistNode(node) {
  49281. const start = node.start + startOffset;
  49282. let end = node.end + startOffset;
  49283. if (node.trailingComments && node.trailingComments.length > 0) {
  49284. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  49285. end = lastCommentNode.end + startOffset;
  49286. }
  49287. while (end <= source.length) {
  49288. if (!/\s/.test(source.charAt(end))) {
  49289. break;
  49290. }
  49291. end++;
  49292. }
  49293. ctx.s.move(start, end, 0);
  49294. }
  49295. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  49296. let isUsedInTemplate = needTemplateUsageCheck;
  49297. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  49298. isUsedInTemplate = isImportUsed(local, sfc);
  49299. }
  49300. ctx.userImports[local] = {
  49301. isType,
  49302. imported,
  49303. local,
  49304. source: source2,
  49305. isFromSetup,
  49306. isUsedInTemplate
  49307. };
  49308. }
  49309. function checkInvalidScopeReference(node, method) {
  49310. if (!node) return;
  49311. walkIdentifiers(node, (id) => {
  49312. const binding = setupBindings[id.name];
  49313. if (binding && binding !== "literal-const") {
  49314. ctx.error(
  49315. `\`${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.`,
  49316. id
  49317. );
  49318. }
  49319. });
  49320. }
  49321. const scriptAst = ctx.scriptAst;
  49322. const scriptSetupAst = ctx.scriptSetupAst;
  49323. if (scriptAst) {
  49324. for (const node of scriptAst.body) {
  49325. if (node.type === "ImportDeclaration") {
  49326. for (const specifier of node.specifiers) {
  49327. const imported = getImportedName(specifier);
  49328. registerUserImport(
  49329. node.source.value,
  49330. specifier.local.name,
  49331. imported,
  49332. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  49333. false,
  49334. !options.inlineTemplate
  49335. );
  49336. }
  49337. }
  49338. }
  49339. }
  49340. for (const node of scriptSetupAst.body) {
  49341. if (node.type === "ImportDeclaration") {
  49342. hoistNode(node);
  49343. let removed = 0;
  49344. const removeSpecifier = (i) => {
  49345. const removeLeft = i > removed;
  49346. removed++;
  49347. const current = node.specifiers[i];
  49348. const next = node.specifiers[i + 1];
  49349. ctx.s.remove(
  49350. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  49351. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  49352. );
  49353. };
  49354. for (let i = 0; i < node.specifiers.length; i++) {
  49355. const specifier = node.specifiers[i];
  49356. const local = specifier.local.name;
  49357. const imported = getImportedName(specifier);
  49358. const source2 = node.source.value;
  49359. const existing = ctx.userImports[local];
  49360. if (source2 === "vue" && MACROS.includes(imported)) {
  49361. if (local === imported) {
  49362. warnOnce$1(
  49363. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  49364. );
  49365. } else {
  49366. ctx.error(
  49367. `\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
  49368. specifier
  49369. );
  49370. }
  49371. removeSpecifier(i);
  49372. } else if (existing) {
  49373. if (existing.source === source2 && existing.imported === imported) {
  49374. removeSpecifier(i);
  49375. } else {
  49376. ctx.error(
  49377. `different imports aliased to same local name.`,
  49378. specifier
  49379. );
  49380. }
  49381. } else {
  49382. registerUserImport(
  49383. source2,
  49384. local,
  49385. imported,
  49386. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  49387. true,
  49388. !options.inlineTemplate
  49389. );
  49390. }
  49391. }
  49392. if (node.specifiers.length && removed === node.specifiers.length) {
  49393. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49394. }
  49395. }
  49396. }
  49397. const vueImportAliases = {};
  49398. for (const key in ctx.userImports) {
  49399. const { source: source2, imported, local } = ctx.userImports[key];
  49400. if (source2 === "vue") vueImportAliases[imported] = local;
  49401. }
  49402. if (script && scriptAst) {
  49403. for (const node of scriptAst.body) {
  49404. if (node.type === "ExportDefaultDeclaration") {
  49405. defaultExport = node;
  49406. let optionProperties;
  49407. if (defaultExport.declaration.type === "ObjectExpression") {
  49408. optionProperties = defaultExport.declaration.properties;
  49409. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  49410. optionProperties = defaultExport.declaration.arguments[0].properties;
  49411. }
  49412. if (optionProperties) {
  49413. for (const p of optionProperties) {
  49414. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  49415. ctx.hasDefaultExportName = true;
  49416. }
  49417. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  49418. ctx.hasDefaultExportRender = true;
  49419. }
  49420. }
  49421. }
  49422. const start = node.start + scriptStartOffset;
  49423. const end = node.declaration.start + scriptStartOffset;
  49424. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  49425. } else if (node.type === "ExportNamedDeclaration") {
  49426. const defaultSpecifier = node.specifiers.find(
  49427. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  49428. );
  49429. if (defaultSpecifier) {
  49430. defaultExport = node;
  49431. if (node.specifiers.length > 1) {
  49432. ctx.s.remove(
  49433. defaultSpecifier.start + scriptStartOffset,
  49434. defaultSpecifier.end + scriptStartOffset
  49435. );
  49436. } else {
  49437. ctx.s.remove(
  49438. node.start + scriptStartOffset,
  49439. node.end + scriptStartOffset
  49440. );
  49441. }
  49442. if (node.source) {
  49443. ctx.s.prepend(
  49444. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  49445. `
  49446. );
  49447. } else {
  49448. ctx.s.appendLeft(
  49449. scriptEndOffset,
  49450. `
  49451. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  49452. `
  49453. );
  49454. }
  49455. }
  49456. if (node.declaration) {
  49457. walkDeclaration(
  49458. "script",
  49459. node.declaration,
  49460. scriptBindings,
  49461. vueImportAliases,
  49462. hoistStatic
  49463. );
  49464. }
  49465. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  49466. walkDeclaration(
  49467. "script",
  49468. node,
  49469. scriptBindings,
  49470. vueImportAliases,
  49471. hoistStatic
  49472. );
  49473. }
  49474. }
  49475. if (scriptStartOffset > startOffset) {
  49476. if (!/\n$/.test(script.content.trim())) {
  49477. ctx.s.appendLeft(scriptEndOffset, `
  49478. `);
  49479. }
  49480. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  49481. }
  49482. }
  49483. for (const node of scriptSetupAst.body) {
  49484. if (node.type === "ExpressionStatement") {
  49485. const expr = unwrapTSNode(node.expression);
  49486. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  49487. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49488. } else if (processDefineExpose(ctx, expr)) {
  49489. const callee = expr.callee;
  49490. ctx.s.overwrite(
  49491. callee.start + startOffset,
  49492. callee.end + startOffset,
  49493. "__expose"
  49494. );
  49495. } else {
  49496. processDefineModel(ctx, expr);
  49497. }
  49498. }
  49499. if (node.type === "VariableDeclaration" && !node.declare) {
  49500. const total = node.declarations.length;
  49501. let left = total;
  49502. let lastNonRemoved;
  49503. for (let i = 0; i < total; i++) {
  49504. const decl = node.declarations[i];
  49505. const init = decl.init && unwrapTSNode(decl.init);
  49506. if (init) {
  49507. if (processDefineOptions(ctx, init)) {
  49508. ctx.error(
  49509. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  49510. node
  49511. );
  49512. }
  49513. const isDefineProps = processDefineProps(ctx, init, decl.id);
  49514. if (ctx.propsDestructureRestId) {
  49515. setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
  49516. }
  49517. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  49518. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  49519. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  49520. if (left === 1) {
  49521. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49522. } else {
  49523. let start = decl.start + startOffset;
  49524. let end = decl.end + startOffset;
  49525. if (i === total - 1) {
  49526. start = node.declarations[lastNonRemoved].end + startOffset;
  49527. } else {
  49528. end = node.declarations[i + 1].start + startOffset;
  49529. }
  49530. ctx.s.remove(start, end);
  49531. left--;
  49532. }
  49533. } else if (isDefineEmits) {
  49534. ctx.s.overwrite(
  49535. startOffset + init.start,
  49536. startOffset + init.end,
  49537. "__emit"
  49538. );
  49539. } else {
  49540. lastNonRemoved = i;
  49541. }
  49542. }
  49543. }
  49544. }
  49545. let isAllLiteral = false;
  49546. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  49547. isAllLiteral = walkDeclaration(
  49548. "scriptSetup",
  49549. node,
  49550. setupBindings,
  49551. vueImportAliases,
  49552. hoistStatic,
  49553. !!ctx.propsDestructureDecl
  49554. );
  49555. }
  49556. if (hoistStatic && isAllLiteral) {
  49557. hoistNode(node);
  49558. }
  49559. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  49560. const scope = [scriptSetupAst.body];
  49561. walk$2(node, {
  49562. enter(child, parent) {
  49563. if (isFunctionType(child)) {
  49564. this.skip();
  49565. }
  49566. if (child.type === "BlockStatement") {
  49567. scope.push(child.body);
  49568. }
  49569. if (child.type === "AwaitExpression") {
  49570. hasAwait = true;
  49571. const currentScope = scope[scope.length - 1];
  49572. const needsSemi = currentScope.some((n, i) => {
  49573. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  49574. });
  49575. processAwait(
  49576. ctx,
  49577. child,
  49578. needsSemi,
  49579. parent.type === "ExpressionStatement"
  49580. );
  49581. }
  49582. },
  49583. exit(node2) {
  49584. if (node2.type === "BlockStatement") scope.pop();
  49585. }
  49586. });
  49587. }
  49588. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  49589. ctx.error(
  49590. `<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.`,
  49591. node
  49592. );
  49593. }
  49594. if (ctx.isTS) {
  49595. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  49596. if (node.type !== "TSEnumDeclaration") {
  49597. hoistNode(node);
  49598. }
  49599. }
  49600. }
  49601. }
  49602. if (ctx.propsDestructureDecl) {
  49603. transformDestructuredProps(ctx, vueImportAliases);
  49604. }
  49605. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  49606. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  49607. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  49608. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  49609. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  49610. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  49611. for (const node of runtimeOptionNodes) {
  49612. checkInvalidScopeReference(node, DEFINE_MODEL);
  49613. }
  49614. }
  49615. if (script) {
  49616. if (startOffset < scriptStartOffset) {
  49617. ctx.s.remove(0, startOffset);
  49618. ctx.s.remove(endOffset, scriptStartOffset);
  49619. ctx.s.remove(scriptEndOffset, source.length);
  49620. } else {
  49621. ctx.s.remove(0, scriptStartOffset);
  49622. ctx.s.remove(scriptEndOffset, startOffset);
  49623. ctx.s.remove(endOffset, source.length);
  49624. }
  49625. } else {
  49626. ctx.s.remove(0, startOffset);
  49627. ctx.s.remove(endOffset, source.length);
  49628. }
  49629. if (scriptAst) {
  49630. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  49631. }
  49632. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  49633. ctx.userImports
  49634. )) {
  49635. if (isType) continue;
  49636. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  49637. }
  49638. for (const key in scriptBindings) {
  49639. ctx.bindingMetadata[key] = scriptBindings[key];
  49640. }
  49641. for (const key in setupBindings) {
  49642. ctx.bindingMetadata[key] = setupBindings[key];
  49643. }
  49644. if (sfc.cssVars.length && // no need to do this when targeting SSR
  49645. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  49646. ctx.helperImports.add(CSS_VARS_HELPER);
  49647. ctx.helperImports.add("unref");
  49648. ctx.s.prependLeft(
  49649. startOffset,
  49650. `
  49651. ${genCssVarsCode(
  49652. sfc.cssVars,
  49653. ctx.bindingMetadata,
  49654. scopeId,
  49655. !!options.isProd
  49656. )}
  49657. `
  49658. );
  49659. }
  49660. let args = `__props`;
  49661. if (ctx.propsTypeDecl) {
  49662. args += `: any`;
  49663. }
  49664. if (ctx.propsDecl) {
  49665. if (ctx.propsDestructureRestId) {
  49666. ctx.s.overwrite(
  49667. startOffset + ctx.propsCall.start,
  49668. startOffset + ctx.propsCall.end,
  49669. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  49670. Object.keys(ctx.propsDestructuredBindings)
  49671. )})`
  49672. );
  49673. ctx.s.overwrite(
  49674. startOffset + ctx.propsDestructureDecl.start,
  49675. startOffset + ctx.propsDestructureDecl.end,
  49676. ctx.propsDestructureRestId
  49677. );
  49678. } else if (!ctx.propsDestructureDecl) {
  49679. ctx.s.overwrite(
  49680. startOffset + ctx.propsCall.start,
  49681. startOffset + ctx.propsCall.end,
  49682. "__props"
  49683. );
  49684. }
  49685. }
  49686. if (hasAwait) {
  49687. const any = ctx.isTS ? `: any` : ``;
  49688. ctx.s.prependLeft(startOffset, `
  49689. let __temp${any}, __restore${any}
  49690. `);
  49691. }
  49692. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  49693. if (ctx.emitDecl) {
  49694. destructureElements.push(`emit: __emit`);
  49695. }
  49696. if (destructureElements.length) {
  49697. args += `, { ${destructureElements.join(", ")} }`;
  49698. }
  49699. let returned;
  49700. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  49701. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  49702. for (const key in ctx.userImports) {
  49703. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  49704. allBindings[key] = true;
  49705. }
  49706. }
  49707. returned = `{ `;
  49708. for (const key in allBindings) {
  49709. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  49710. returned += `get ${key}() { return ${key} }, `;
  49711. } else if (ctx.bindingMetadata[key] === "setup-let") {
  49712. const setArg = key === "v" ? `_v` : `v`;
  49713. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  49714. } else {
  49715. returned += `${key}, `;
  49716. }
  49717. }
  49718. returned = returned.replace(/, $/, "") + ` }`;
  49719. } else {
  49720. if (sfc.template && !sfc.template.src) {
  49721. if (options.templateOptions && options.templateOptions.ssr) {
  49722. hasInlinedSsrRenderFn = true;
  49723. }
  49724. const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
  49725. filename,
  49726. ast: sfc.template.ast,
  49727. source: sfc.template.content,
  49728. inMap: sfc.template.map
  49729. }, options.templateOptions), {
  49730. id: scopeId,
  49731. scoped: sfc.styles.some((s) => s.scoped),
  49732. isProd: options.isProd,
  49733. ssrCssVars: sfc.cssVars,
  49734. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  49735. inline: true,
  49736. isTS: ctx.isTS,
  49737. bindingMetadata: ctx.bindingMetadata
  49738. })
  49739. }));
  49740. if (tips.length) {
  49741. tips.forEach(warnOnce$1);
  49742. }
  49743. const err = errors[0];
  49744. if (typeof err === "string") {
  49745. throw new Error(err);
  49746. } else if (err) {
  49747. if (err.loc) {
  49748. err.message += `
  49749. ` + sfc.filename + "\n" + generateCodeFrame(
  49750. source,
  49751. err.loc.start.offset,
  49752. err.loc.end.offset
  49753. ) + `
  49754. `;
  49755. }
  49756. throw err;
  49757. }
  49758. if (preamble) {
  49759. ctx.s.prepend(preamble);
  49760. }
  49761. if (ast && ast.helpers.has(UNREF)) {
  49762. ctx.helperImports.delete("unref");
  49763. }
  49764. returned = code;
  49765. } else {
  49766. returned = `() => {}`;
  49767. }
  49768. }
  49769. if (!options.inlineTemplate && true) {
  49770. ctx.s.appendRight(
  49771. endOffset,
  49772. `
  49773. const __returned__ = ${returned}
  49774. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  49775. return __returned__
  49776. }
  49777. `
  49778. );
  49779. } else {
  49780. ctx.s.appendRight(endOffset, `
  49781. return ${returned}
  49782. }
  49783. `);
  49784. }
  49785. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  49786. let runtimeOptions = ``;
  49787. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  49788. const match = filename.match(/([^/\\]+)\.\w+$/);
  49789. if (match) {
  49790. runtimeOptions += `
  49791. __name: '${match[1]}',`;
  49792. }
  49793. }
  49794. if (hasInlinedSsrRenderFn) {
  49795. runtimeOptions += `
  49796. __ssrInlineRender: true,`;
  49797. }
  49798. const propsDecl = genRuntimeProps(ctx);
  49799. if (propsDecl) runtimeOptions += `
  49800. props: ${propsDecl},`;
  49801. const emitsDecl = genRuntimeEmits(ctx);
  49802. if (emitsDecl) runtimeOptions += `
  49803. emits: ${emitsDecl},`;
  49804. let definedOptions = "";
  49805. if (ctx.optionsRuntimeDecl) {
  49806. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  49807. }
  49808. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  49809. `;
  49810. if (ctx.isTS) {
  49811. const def = (defaultExport ? `
  49812. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  49813. ...${definedOptions},` : "");
  49814. ctx.s.prependLeft(
  49815. startOffset,
  49816. `
  49817. ${genDefaultAs} /*@__PURE__*/${ctx.helper(
  49818. `defineComponent`
  49819. )}({${def}${runtimeOptions}
  49820. ${hasAwait ? `async ` : ``}setup(${args}) {
  49821. ${exposeCall}`
  49822. );
  49823. ctx.s.appendRight(endOffset, `})`);
  49824. } else {
  49825. if (defaultExport || definedOptions) {
  49826. ctx.s.prependLeft(
  49827. startOffset,
  49828. `
  49829. ${genDefaultAs} /*@__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  49830. ${hasAwait ? `async ` : ``}setup(${args}) {
  49831. ${exposeCall}`
  49832. );
  49833. ctx.s.appendRight(endOffset, `})`);
  49834. } else {
  49835. ctx.s.prependLeft(
  49836. startOffset,
  49837. `
  49838. ${genDefaultAs} {${runtimeOptions}
  49839. ${hasAwait ? `async ` : ``}setup(${args}) {
  49840. ${exposeCall}`
  49841. );
  49842. ctx.s.appendRight(endOffset, `}`);
  49843. }
  49844. }
  49845. if (ctx.helperImports.size > 0) {
  49846. const runtimeModuleName = (_c = (_b = options.templateOptions) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.runtimeModuleName;
  49847. const importSrc = runtimeModuleName ? JSON.stringify(runtimeModuleName) : `'vue'`;
  49848. ctx.s.prepend(
  49849. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from ${importSrc}
  49850. `
  49851. );
  49852. }
  49853. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  49854. bindings: ctx.bindingMetadata,
  49855. imports: ctx.userImports,
  49856. content: ctx.s.toString(),
  49857. map: options.sourceMap !== false ? ctx.s.generateMap({
  49858. source: filename,
  49859. hires: true,
  49860. includeContent: true
  49861. }) : void 0,
  49862. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  49863. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  49864. deps: ctx.deps ? [...ctx.deps] : void 0
  49865. });
  49866. }
  49867. function registerBinding(bindings, node, type) {
  49868. bindings[node.name] = type;
  49869. }
  49870. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic, isPropsDestructureEnabled = false) {
  49871. let isAllLiteral = false;
  49872. if (node.type === "VariableDeclaration") {
  49873. const isConst = node.kind === "const";
  49874. isAllLiteral = isConst && node.declarations.every(
  49875. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  49876. );
  49877. for (const { id, init: _init } of node.declarations) {
  49878. const init = _init && unwrapTSNode(_init);
  49879. const isConstMacroCall = isConst && isCallOf(
  49880. init,
  49881. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
  49882. );
  49883. if (id.type === "Identifier") {
  49884. let bindingType;
  49885. const userReactiveBinding = userImportAliases["reactive"];
  49886. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  49887. bindingType = "literal-const";
  49888. } else if (isCallOf(init, userReactiveBinding)) {
  49889. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  49890. } else if (
  49891. // if a declaration is a const literal, we can mark it so that
  49892. // the generated render fn code doesn't need to unref() it
  49893. isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
  49894. ) {
  49895. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  49896. } else if (isConst) {
  49897. if (isCallOf(
  49898. init,
  49899. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === DEFINE_MODEL
  49900. )) {
  49901. bindingType = "setup-ref";
  49902. } else {
  49903. bindingType = "setup-maybe-ref";
  49904. }
  49905. } else {
  49906. bindingType = "setup-let";
  49907. }
  49908. registerBinding(bindings, id, bindingType);
  49909. } else {
  49910. if (isCallOf(init, DEFINE_PROPS) && isPropsDestructureEnabled) {
  49911. continue;
  49912. }
  49913. if (id.type === "ObjectPattern") {
  49914. walkObjectPattern(id, bindings, isConst, isConstMacroCall);
  49915. } else if (id.type === "ArrayPattern") {
  49916. walkArrayPattern(id, bindings, isConst, isConstMacroCall);
  49917. }
  49918. }
  49919. }
  49920. } else if (node.type === "TSEnumDeclaration") {
  49921. isAllLiteral = node.members.every(
  49922. (member) => !member.initializer || isStaticNode(member.initializer)
  49923. );
  49924. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  49925. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  49926. bindings[node.id.name] = "setup-const";
  49927. }
  49928. return isAllLiteral;
  49929. }
  49930. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  49931. for (const p of node.properties) {
  49932. if (p.type === "ObjectProperty") {
  49933. if (p.key.type === "Identifier" && p.key === p.value) {
  49934. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49935. registerBinding(bindings, p.key, type);
  49936. } else {
  49937. walkPattern(p.value, bindings, isConst, isDefineCall);
  49938. }
  49939. } else {
  49940. const type = isConst ? "setup-const" : "setup-let";
  49941. registerBinding(bindings, p.argument, type);
  49942. }
  49943. }
  49944. }
  49945. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  49946. for (const e of node.elements) {
  49947. e && walkPattern(e, bindings, isConst, isDefineCall);
  49948. }
  49949. }
  49950. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  49951. if (node.type === "Identifier") {
  49952. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49953. registerBinding(bindings, node, type);
  49954. } else if (node.type === "RestElement") {
  49955. const type = isConst ? "setup-const" : "setup-let";
  49956. registerBinding(bindings, node.argument, type);
  49957. } else if (node.type === "ObjectPattern") {
  49958. walkObjectPattern(node, bindings, isConst);
  49959. } else if (node.type === "ArrayPattern") {
  49960. walkArrayPattern(node, bindings, isConst);
  49961. } else if (node.type === "AssignmentPattern") {
  49962. if (node.left.type === "Identifier") {
  49963. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49964. registerBinding(bindings, node.left, type);
  49965. } else {
  49966. walkPattern(node.left, bindings, isConst);
  49967. }
  49968. }
  49969. }
  49970. function canNeverBeRef(node, userReactiveImport) {
  49971. if (isCallOf(node, userReactiveImport)) {
  49972. return true;
  49973. }
  49974. switch (node.type) {
  49975. case "UnaryExpression":
  49976. case "BinaryExpression":
  49977. case "ArrayExpression":
  49978. case "ObjectExpression":
  49979. case "FunctionExpression":
  49980. case "ArrowFunctionExpression":
  49981. case "UpdateExpression":
  49982. case "ClassExpression":
  49983. case "TaggedTemplateExpression":
  49984. return true;
  49985. case "SequenceExpression":
  49986. return canNeverBeRef(
  49987. node.expressions[node.expressions.length - 1],
  49988. userReactiveImport
  49989. );
  49990. default:
  49991. if (isLiteralNode(node)) {
  49992. return true;
  49993. }
  49994. return false;
  49995. }
  49996. }
  49997. function isStaticNode(node) {
  49998. node = unwrapTSNode(node);
  49999. switch (node.type) {
  50000. case "UnaryExpression":
  50001. return isStaticNode(node.argument);
  50002. case "LogicalExpression":
  50003. // 1 > 2
  50004. case "BinaryExpression":
  50005. return isStaticNode(node.left) && isStaticNode(node.right);
  50006. case "ConditionalExpression": {
  50007. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  50008. }
  50009. case "SequenceExpression":
  50010. // (1, 2)
  50011. case "TemplateLiteral":
  50012. return node.expressions.every((expr) => isStaticNode(expr));
  50013. case "ParenthesizedExpression":
  50014. return isStaticNode(node.expression);
  50015. case "StringLiteral":
  50016. case "NumericLiteral":
  50017. case "BooleanLiteral":
  50018. case "NullLiteral":
  50019. case "BigIntLiteral":
  50020. return true;
  50021. }
  50022. return false;
  50023. }
  50024. var __defProp = Object.defineProperty;
  50025. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  50026. var __hasOwnProp = Object.prototype.hasOwnProperty;
  50027. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  50028. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  50029. var __spreadValues = (a, b) => {
  50030. for (var prop in b || (b = {}))
  50031. if (__hasOwnProp.call(b, prop))
  50032. __defNormalProp(a, prop, b[prop]);
  50033. if (__getOwnPropSymbols)
  50034. for (var prop of __getOwnPropSymbols(b)) {
  50035. if (__propIsEnum.call(b, prop))
  50036. __defNormalProp(a, prop, b[prop]);
  50037. }
  50038. return a;
  50039. };
  50040. const version = "3.5.13";
  50041. const parseCache = parseCache$1;
  50042. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  50043. const walk = walk$2;
  50044. const shouldTransformRef = () => false;
  50045. var parse$4 = libExports.parse;
  50046. export { MagicString, parse$4 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, errorMessages, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$2 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };