dep-BASfdaBA.js 223 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843
  1. import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-BWSbWtLw.js';
  2. import require$$0__default from 'fs';
  3. import require$$0 from 'postcss';
  4. import require$$0$1 from 'path';
  5. import require$$3 from 'crypto';
  6. import require$$0$2 from 'util';
  7. import { l as lib } from './dep-IQS-Za7F.js';
  8. import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
  9. import { dirname as __cjs_dirname } from 'node:path';
  10. import { createRequire as __cjs_createRequire } from 'node:module';
  11. const __filename = __cjs_fileURLToPath(import.meta.url);
  12. const __dirname = __cjs_dirname(__filename);
  13. const require = __cjs_createRequire(import.meta.url);
  14. const __require = require;
  15. function _mergeNamespaces(n, m) {
  16. for (var i = 0; i < m.length; i++) {
  17. var e = m[i];
  18. if (typeof e !== 'string' && !Array.isArray(e)) { for (var k in e) {
  19. if (k !== 'default' && !(k in n)) {
  20. n[k] = e[k];
  21. }
  22. } }
  23. }
  24. return n;
  25. }
  26. var build = {exports: {}};
  27. var fs = {};
  28. Object.defineProperty(fs, "__esModule", {
  29. value: true
  30. });
  31. fs.getFileSystem = getFileSystem;
  32. fs.setFileSystem = setFileSystem;
  33. let fileSystem = {
  34. readFile: () => {
  35. throw Error("readFile not implemented");
  36. },
  37. writeFile: () => {
  38. throw Error("writeFile not implemented");
  39. }
  40. };
  41. function setFileSystem(fs) {
  42. fileSystem.readFile = fs.readFile;
  43. fileSystem.writeFile = fs.writeFile;
  44. }
  45. function getFileSystem() {
  46. return fileSystem;
  47. }
  48. var pluginFactory = {};
  49. var unquote$1 = {};
  50. Object.defineProperty(unquote$1, "__esModule", {
  51. value: true
  52. });
  53. unquote$1.default = unquote;
  54. // copied from https://github.com/lakenen/node-unquote
  55. const reg = /['"]/;
  56. function unquote(str) {
  57. if (!str) {
  58. return "";
  59. }
  60. if (reg.test(str.charAt(0))) {
  61. str = str.substr(1);
  62. }
  63. if (reg.test(str.charAt(str.length - 1))) {
  64. str = str.substr(0, str.length - 1);
  65. }
  66. return str;
  67. }
  68. var Parser$1 = {};
  69. const matchValueName = /[$]?[\w-]+/g;
  70. const replaceValueSymbols$2 = (value, replacements) => {
  71. let matches;
  72. while ((matches = matchValueName.exec(value))) {
  73. const replacement = replacements[matches[0]];
  74. if (replacement) {
  75. value =
  76. value.slice(0, matches.index) +
  77. replacement +
  78. value.slice(matchValueName.lastIndex);
  79. matchValueName.lastIndex -= matches[0].length - replacement.length;
  80. }
  81. }
  82. return value;
  83. };
  84. var replaceValueSymbols_1 = replaceValueSymbols$2;
  85. const replaceValueSymbols$1 = replaceValueSymbols_1;
  86. const replaceSymbols$1 = (css, replacements) => {
  87. css.walk((node) => {
  88. if (node.type === "decl" && node.value) {
  89. node.value = replaceValueSymbols$1(node.value.toString(), replacements);
  90. } else if (node.type === "rule" && node.selector) {
  91. node.selector = replaceValueSymbols$1(
  92. node.selector.toString(),
  93. replacements
  94. );
  95. } else if (node.type === "atrule" && node.params) {
  96. node.params = replaceValueSymbols$1(node.params.toString(), replacements);
  97. }
  98. });
  99. };
  100. var replaceSymbols_1 = replaceSymbols$1;
  101. const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
  102. const balancedQuotes = /^("[^"]*"|'[^']*'|[^"']+)$/;
  103. const getDeclsObject = (rule) => {
  104. const object = {};
  105. rule.walkDecls((decl) => {
  106. const before = decl.raws.before ? decl.raws.before.trim() : "";
  107. object[before + decl.prop] = decl.value;
  108. });
  109. return object;
  110. };
  111. /**
  112. *
  113. * @param {string} css
  114. * @param {boolean} removeRules
  115. * @param {'auto' | 'rule' | 'at-rule'} mode
  116. */
  117. const extractICSS$2 = (css, removeRules = true, mode = "auto") => {
  118. const icssImports = {};
  119. const icssExports = {};
  120. function addImports(node, path) {
  121. const unquoted = path.replace(/'|"/g, "");
  122. icssImports[unquoted] = Object.assign(
  123. icssImports[unquoted] || {},
  124. getDeclsObject(node)
  125. );
  126. if (removeRules) {
  127. node.remove();
  128. }
  129. }
  130. function addExports(node) {
  131. Object.assign(icssExports, getDeclsObject(node));
  132. if (removeRules) {
  133. node.remove();
  134. }
  135. }
  136. css.each((node) => {
  137. if (node.type === "rule" && mode !== "at-rule") {
  138. if (node.selector.slice(0, 7) === ":import") {
  139. const matches = importPattern.exec(node.selector);
  140. if (matches) {
  141. addImports(node, matches[1]);
  142. }
  143. }
  144. if (node.selector === ":export") {
  145. addExports(node);
  146. }
  147. }
  148. if (node.type === "atrule" && mode !== "rule") {
  149. if (node.name === "icss-import") {
  150. const matches = balancedQuotes.exec(node.params);
  151. if (matches) {
  152. addImports(node, matches[1]);
  153. }
  154. }
  155. if (node.name === "icss-export") {
  156. addExports(node);
  157. }
  158. }
  159. });
  160. return { icssImports, icssExports };
  161. };
  162. var extractICSS_1 = extractICSS$2;
  163. const createImports = (imports, postcss, mode = "rule") => {
  164. return Object.keys(imports).map((path) => {
  165. const aliases = imports[path];
  166. const declarations = Object.keys(aliases).map((key) =>
  167. postcss.decl({
  168. prop: key,
  169. value: aliases[key],
  170. raws: { before: "\n " },
  171. })
  172. );
  173. const hasDeclarations = declarations.length > 0;
  174. const rule =
  175. mode === "rule"
  176. ? postcss.rule({
  177. selector: `:import('${path}')`,
  178. raws: { after: hasDeclarations ? "\n" : "" },
  179. })
  180. : postcss.atRule({
  181. name: "icss-import",
  182. params: `'${path}'`,
  183. raws: { after: hasDeclarations ? "\n" : "" },
  184. });
  185. if (hasDeclarations) {
  186. rule.append(declarations);
  187. }
  188. return rule;
  189. });
  190. };
  191. const createExports = (exports, postcss, mode = "rule") => {
  192. const declarations = Object.keys(exports).map((key) =>
  193. postcss.decl({
  194. prop: key,
  195. value: exports[key],
  196. raws: { before: "\n " },
  197. })
  198. );
  199. if (declarations.length === 0) {
  200. return [];
  201. }
  202. const rule =
  203. mode === "rule"
  204. ? postcss.rule({
  205. selector: `:export`,
  206. raws: { after: "\n" },
  207. })
  208. : postcss.atRule({
  209. name: "icss-export",
  210. raws: { after: "\n" },
  211. });
  212. rule.append(declarations);
  213. return [rule];
  214. };
  215. const createICSSRules$1 = (imports, exports, postcss, mode) => [
  216. ...createImports(imports, postcss, mode),
  217. ...createExports(exports, postcss, mode),
  218. ];
  219. var createICSSRules_1 = createICSSRules$1;
  220. const replaceValueSymbols = replaceValueSymbols_1;
  221. const replaceSymbols = replaceSymbols_1;
  222. const extractICSS$1 = extractICSS_1;
  223. const createICSSRules = createICSSRules_1;
  224. var src$4 = {
  225. replaceValueSymbols,
  226. replaceSymbols,
  227. extractICSS: extractICSS$1,
  228. createICSSRules,
  229. };
  230. Object.defineProperty(Parser$1, "__esModule", {
  231. value: true
  232. });
  233. Parser$1.default = void 0;
  234. var _icssUtils = src$4;
  235. // Initially copied from https://github.com/css-modules/css-modules-loader-core
  236. const importRegexp = /^:import\((.+)\)$/;
  237. class Parser {
  238. constructor(pathFetcher, trace) {
  239. this.pathFetcher = pathFetcher;
  240. this.plugin = this.plugin.bind(this);
  241. this.exportTokens = {};
  242. this.translations = {};
  243. this.trace = trace;
  244. }
  245. plugin() {
  246. const parser = this;
  247. return {
  248. postcssPlugin: "css-modules-parser",
  249. async OnceExit(css) {
  250. await Promise.all(parser.fetchAllImports(css));
  251. parser.linkImportedSymbols(css);
  252. return parser.extractExports(css);
  253. }
  254. };
  255. }
  256. fetchAllImports(css) {
  257. let imports = [];
  258. css.each(node => {
  259. if (node.type == "rule" && node.selector.match(importRegexp)) {
  260. imports.push(this.fetchImport(node, css.source.input.from, imports.length));
  261. }
  262. });
  263. return imports;
  264. }
  265. linkImportedSymbols(css) {
  266. (0, _icssUtils.replaceSymbols)(css, this.translations);
  267. }
  268. extractExports(css) {
  269. css.each(node => {
  270. if (node.type == "rule" && node.selector == ":export") this.handleExport(node);
  271. });
  272. }
  273. handleExport(exportNode) {
  274. exportNode.each(decl => {
  275. if (decl.type == "decl") {
  276. Object.keys(this.translations).forEach(translation => {
  277. decl.value = decl.value.replace(translation, this.translations[translation]);
  278. });
  279. this.exportTokens[decl.prop] = decl.value;
  280. }
  281. });
  282. exportNode.remove();
  283. }
  284. async fetchImport(importNode, relativeTo, depNr) {
  285. const file = importNode.selector.match(importRegexp)[1];
  286. const depTrace = this.trace + String.fromCharCode(depNr);
  287. const exports = await this.pathFetcher(file, relativeTo, depTrace);
  288. try {
  289. importNode.each(decl => {
  290. if (decl.type == "decl") {
  291. this.translations[decl.prop] = exports[decl.value];
  292. }
  293. });
  294. importNode.remove();
  295. } catch (err) {
  296. console.log(err);
  297. }
  298. }
  299. }
  300. Parser$1.default = Parser;
  301. var saveJSON$1 = {};
  302. Object.defineProperty(saveJSON$1, "__esModule", {
  303. value: true
  304. });
  305. saveJSON$1.default = saveJSON;
  306. var _fs$2 = fs;
  307. function saveJSON(cssFile, json) {
  308. return new Promise((resolve, reject) => {
  309. const {
  310. writeFile
  311. } = (0, _fs$2.getFileSystem)();
  312. writeFile(`${cssFile}.json`, JSON.stringify(json), e => e ? reject(e) : resolve(json));
  313. });
  314. }
  315. var localsConvention = {};
  316. /**
  317. * lodash (Custom Build) <https://lodash.com/>
  318. * Build: `lodash modularize exports="npm" -o ./`
  319. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  320. * Released under MIT license <https://lodash.com/license>
  321. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  322. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  323. */
  324. /** Used as references for various `Number` constants. */
  325. var INFINITY = 1 / 0;
  326. /** `Object#toString` result references. */
  327. var symbolTag = '[object Symbol]';
  328. /** Used to match words composed of alphanumeric characters. */
  329. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  330. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  331. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  332. /** Used to compose unicode character classes. */
  333. var rsAstralRange = '\\ud800-\\udfff',
  334. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  335. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  336. rsDingbatRange = '\\u2700-\\u27bf',
  337. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  338. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  339. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  340. rsPunctuationRange = '\\u2000-\\u206f',
  341. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  342. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  343. rsVarRange = '\\ufe0e\\ufe0f',
  344. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  345. /** Used to compose unicode capture groups. */
  346. var rsApos = "['\u2019]",
  347. rsAstral = '[' + rsAstralRange + ']',
  348. rsBreak = '[' + rsBreakRange + ']',
  349. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  350. rsDigits = '\\d+',
  351. rsDingbat = '[' + rsDingbatRange + ']',
  352. rsLower = '[' + rsLowerRange + ']',
  353. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  354. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  355. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  356. rsNonAstral = '[^' + rsAstralRange + ']',
  357. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  358. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  359. rsUpper = '[' + rsUpperRange + ']',
  360. rsZWJ = '\\u200d';
  361. /** Used to compose unicode regexes. */
  362. var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
  363. rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
  364. rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  365. rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  366. reOptMod = rsModifier + '?',
  367. rsOptVar = '[' + rsVarRange + ']?',
  368. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  369. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  370. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  371. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  372. /** Used to match apostrophes. */
  373. var reApos = RegExp(rsApos, 'g');
  374. /**
  375. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  376. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  377. */
  378. var reComboMark = RegExp(rsCombo, 'g');
  379. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  380. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  381. /** Used to match complex or compound words. */
  382. var reUnicodeWord = RegExp([
  383. rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  384. rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
  385. rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
  386. rsUpper + '+' + rsOptUpperContr,
  387. rsDigits,
  388. rsEmoji
  389. ].join('|'), 'g');
  390. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  391. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  392. /** Used to detect strings that need a more robust regexp to match words. */
  393. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  394. /** Used to map Latin Unicode letters to basic Latin letters. */
  395. var deburredLetters = {
  396. // Latin-1 Supplement block.
  397. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  398. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  399. '\xc7': 'C', '\xe7': 'c',
  400. '\xd0': 'D', '\xf0': 'd',
  401. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  402. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  403. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  404. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  405. '\xd1': 'N', '\xf1': 'n',
  406. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  407. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  408. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  409. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  410. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  411. '\xc6': 'Ae', '\xe6': 'ae',
  412. '\xde': 'Th', '\xfe': 'th',
  413. '\xdf': 'ss',
  414. // Latin Extended-A block.
  415. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  416. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  417. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  418. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  419. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  420. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  421. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  422. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  423. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  424. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  425. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  426. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  427. '\u0134': 'J', '\u0135': 'j',
  428. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  429. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  430. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  431. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  432. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  433. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  434. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  435. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  436. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  437. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  438. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  439. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  440. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  441. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  442. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  443. '\u0174': 'W', '\u0175': 'w',
  444. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  445. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  446. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  447. '\u0132': 'IJ', '\u0133': 'ij',
  448. '\u0152': 'Oe', '\u0153': 'oe',
  449. '\u0149': "'n", '\u017f': 'ss'
  450. };
  451. /** Detect free variable `global` from Node.js. */
  452. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  453. /** Detect free variable `self`. */
  454. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  455. /** Used as a reference to the global object. */
  456. var root$2 = freeGlobal || freeSelf || Function('return this')();
  457. /**
  458. * A specialized version of `_.reduce` for arrays without support for
  459. * iteratee shorthands.
  460. *
  461. * @private
  462. * @param {Array} [array] The array to iterate over.
  463. * @param {Function} iteratee The function invoked per iteration.
  464. * @param {*} [accumulator] The initial value.
  465. * @param {boolean} [initAccum] Specify using the first element of `array` as
  466. * the initial value.
  467. * @returns {*} Returns the accumulated value.
  468. */
  469. function arrayReduce(array, iteratee, accumulator, initAccum) {
  470. var index = -1,
  471. length = array ? array.length : 0;
  472. while (++index < length) {
  473. accumulator = iteratee(accumulator, array[index], index, array);
  474. }
  475. return accumulator;
  476. }
  477. /**
  478. * Converts an ASCII `string` to an array.
  479. *
  480. * @private
  481. * @param {string} string The string to convert.
  482. * @returns {Array} Returns the converted array.
  483. */
  484. function asciiToArray(string) {
  485. return string.split('');
  486. }
  487. /**
  488. * Splits an ASCII `string` into an array of its words.
  489. *
  490. * @private
  491. * @param {string} The string to inspect.
  492. * @returns {Array} Returns the words of `string`.
  493. */
  494. function asciiWords(string) {
  495. return string.match(reAsciiWord) || [];
  496. }
  497. /**
  498. * The base implementation of `_.propertyOf` without support for deep paths.
  499. *
  500. * @private
  501. * @param {Object} object The object to query.
  502. * @returns {Function} Returns the new accessor function.
  503. */
  504. function basePropertyOf(object) {
  505. return function(key) {
  506. return object == null ? undefined : object[key];
  507. };
  508. }
  509. /**
  510. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  511. * letters to basic Latin letters.
  512. *
  513. * @private
  514. * @param {string} letter The matched letter to deburr.
  515. * @returns {string} Returns the deburred letter.
  516. */
  517. var deburrLetter = basePropertyOf(deburredLetters);
  518. /**
  519. * Checks if `string` contains Unicode symbols.
  520. *
  521. * @private
  522. * @param {string} string The string to inspect.
  523. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  524. */
  525. function hasUnicode(string) {
  526. return reHasUnicode.test(string);
  527. }
  528. /**
  529. * Checks if `string` contains a word composed of Unicode symbols.
  530. *
  531. * @private
  532. * @param {string} string The string to inspect.
  533. * @returns {boolean} Returns `true` if a word is found, else `false`.
  534. */
  535. function hasUnicodeWord(string) {
  536. return reHasUnicodeWord.test(string);
  537. }
  538. /**
  539. * Converts `string` to an array.
  540. *
  541. * @private
  542. * @param {string} string The string to convert.
  543. * @returns {Array} Returns the converted array.
  544. */
  545. function stringToArray(string) {
  546. return hasUnicode(string)
  547. ? unicodeToArray(string)
  548. : asciiToArray(string);
  549. }
  550. /**
  551. * Converts a Unicode `string` to an array.
  552. *
  553. * @private
  554. * @param {string} string The string to convert.
  555. * @returns {Array} Returns the converted array.
  556. */
  557. function unicodeToArray(string) {
  558. return string.match(reUnicode) || [];
  559. }
  560. /**
  561. * Splits a Unicode `string` into an array of its words.
  562. *
  563. * @private
  564. * @param {string} The string to inspect.
  565. * @returns {Array} Returns the words of `string`.
  566. */
  567. function unicodeWords(string) {
  568. return string.match(reUnicodeWord) || [];
  569. }
  570. /** Used for built-in method references. */
  571. var objectProto = Object.prototype;
  572. /**
  573. * Used to resolve the
  574. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  575. * of values.
  576. */
  577. var objectToString = objectProto.toString;
  578. /** Built-in value references. */
  579. var Symbol$1 = root$2.Symbol;
  580. /** Used to convert symbols to primitives and strings. */
  581. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
  582. symbolToString = symbolProto ? symbolProto.toString : undefined;
  583. /**
  584. * The base implementation of `_.slice` without an iteratee call guard.
  585. *
  586. * @private
  587. * @param {Array} array The array to slice.
  588. * @param {number} [start=0] The start position.
  589. * @param {number} [end=array.length] The end position.
  590. * @returns {Array} Returns the slice of `array`.
  591. */
  592. function baseSlice(array, start, end) {
  593. var index = -1,
  594. length = array.length;
  595. if (start < 0) {
  596. start = -start > length ? 0 : (length + start);
  597. }
  598. end = end > length ? length : end;
  599. if (end < 0) {
  600. end += length;
  601. }
  602. length = start > end ? 0 : ((end - start) >>> 0);
  603. start >>>= 0;
  604. var result = Array(length);
  605. while (++index < length) {
  606. result[index] = array[index + start];
  607. }
  608. return result;
  609. }
  610. /**
  611. * The base implementation of `_.toString` which doesn't convert nullish
  612. * values to empty strings.
  613. *
  614. * @private
  615. * @param {*} value The value to process.
  616. * @returns {string} Returns the string.
  617. */
  618. function baseToString(value) {
  619. // Exit early for strings to avoid a performance hit in some environments.
  620. if (typeof value == 'string') {
  621. return value;
  622. }
  623. if (isSymbol(value)) {
  624. return symbolToString ? symbolToString.call(value) : '';
  625. }
  626. var result = (value + '');
  627. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  628. }
  629. /**
  630. * Casts `array` to a slice if it's needed.
  631. *
  632. * @private
  633. * @param {Array} array The array to inspect.
  634. * @param {number} start The start position.
  635. * @param {number} [end=array.length] The end position.
  636. * @returns {Array} Returns the cast slice.
  637. */
  638. function castSlice(array, start, end) {
  639. var length = array.length;
  640. end = end === undefined ? length : end;
  641. return (!start && end >= length) ? array : baseSlice(array, start, end);
  642. }
  643. /**
  644. * Creates a function like `_.lowerFirst`.
  645. *
  646. * @private
  647. * @param {string} methodName The name of the `String` case method to use.
  648. * @returns {Function} Returns the new case function.
  649. */
  650. function createCaseFirst(methodName) {
  651. return function(string) {
  652. string = toString(string);
  653. var strSymbols = hasUnicode(string)
  654. ? stringToArray(string)
  655. : undefined;
  656. var chr = strSymbols
  657. ? strSymbols[0]
  658. : string.charAt(0);
  659. var trailing = strSymbols
  660. ? castSlice(strSymbols, 1).join('')
  661. : string.slice(1);
  662. return chr[methodName]() + trailing;
  663. };
  664. }
  665. /**
  666. * Creates a function like `_.camelCase`.
  667. *
  668. * @private
  669. * @param {Function} callback The function to combine each word.
  670. * @returns {Function} Returns the new compounder function.
  671. */
  672. function createCompounder(callback) {
  673. return function(string) {
  674. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  675. };
  676. }
  677. /**
  678. * Checks if `value` is object-like. A value is object-like if it's not `null`
  679. * and has a `typeof` result of "object".
  680. *
  681. * @static
  682. * @memberOf _
  683. * @since 4.0.0
  684. * @category Lang
  685. * @param {*} value The value to check.
  686. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  687. * @example
  688. *
  689. * _.isObjectLike({});
  690. * // => true
  691. *
  692. * _.isObjectLike([1, 2, 3]);
  693. * // => true
  694. *
  695. * _.isObjectLike(_.noop);
  696. * // => false
  697. *
  698. * _.isObjectLike(null);
  699. * // => false
  700. */
  701. function isObjectLike(value) {
  702. return !!value && typeof value == 'object';
  703. }
  704. /**
  705. * Checks if `value` is classified as a `Symbol` primitive or object.
  706. *
  707. * @static
  708. * @memberOf _
  709. * @since 4.0.0
  710. * @category Lang
  711. * @param {*} value The value to check.
  712. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  713. * @example
  714. *
  715. * _.isSymbol(Symbol.iterator);
  716. * // => true
  717. *
  718. * _.isSymbol('abc');
  719. * // => false
  720. */
  721. function isSymbol(value) {
  722. return typeof value == 'symbol' ||
  723. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  724. }
  725. /**
  726. * Converts `value` to a string. An empty string is returned for `null`
  727. * and `undefined` values. The sign of `-0` is preserved.
  728. *
  729. * @static
  730. * @memberOf _
  731. * @since 4.0.0
  732. * @category Lang
  733. * @param {*} value The value to process.
  734. * @returns {string} Returns the string.
  735. * @example
  736. *
  737. * _.toString(null);
  738. * // => ''
  739. *
  740. * _.toString(-0);
  741. * // => '-0'
  742. *
  743. * _.toString([1, 2, 3]);
  744. * // => '1,2,3'
  745. */
  746. function toString(value) {
  747. return value == null ? '' : baseToString(value);
  748. }
  749. /**
  750. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  751. *
  752. * @static
  753. * @memberOf _
  754. * @since 3.0.0
  755. * @category String
  756. * @param {string} [string=''] The string to convert.
  757. * @returns {string} Returns the camel cased string.
  758. * @example
  759. *
  760. * _.camelCase('Foo Bar');
  761. * // => 'fooBar'
  762. *
  763. * _.camelCase('--foo-bar--');
  764. * // => 'fooBar'
  765. *
  766. * _.camelCase('__FOO_BAR__');
  767. * // => 'fooBar'
  768. */
  769. var camelCase = createCompounder(function(result, word, index) {
  770. word = word.toLowerCase();
  771. return result + (index ? capitalize(word) : word);
  772. });
  773. /**
  774. * Converts the first character of `string` to upper case and the remaining
  775. * to lower case.
  776. *
  777. * @static
  778. * @memberOf _
  779. * @since 3.0.0
  780. * @category String
  781. * @param {string} [string=''] The string to capitalize.
  782. * @returns {string} Returns the capitalized string.
  783. * @example
  784. *
  785. * _.capitalize('FRED');
  786. * // => 'Fred'
  787. */
  788. function capitalize(string) {
  789. return upperFirst(toString(string).toLowerCase());
  790. }
  791. /**
  792. * Deburrs `string` by converting
  793. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  794. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  795. * letters to basic Latin letters and removing
  796. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  797. *
  798. * @static
  799. * @memberOf _
  800. * @since 3.0.0
  801. * @category String
  802. * @param {string} [string=''] The string to deburr.
  803. * @returns {string} Returns the deburred string.
  804. * @example
  805. *
  806. * _.deburr('déjà vu');
  807. * // => 'deja vu'
  808. */
  809. function deburr(string) {
  810. string = toString(string);
  811. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  812. }
  813. /**
  814. * Converts the first character of `string` to upper case.
  815. *
  816. * @static
  817. * @memberOf _
  818. * @since 4.0.0
  819. * @category String
  820. * @param {string} [string=''] The string to convert.
  821. * @returns {string} Returns the converted string.
  822. * @example
  823. *
  824. * _.upperFirst('fred');
  825. * // => 'Fred'
  826. *
  827. * _.upperFirst('FRED');
  828. * // => 'FRED'
  829. */
  830. var upperFirst = createCaseFirst('toUpperCase');
  831. /**
  832. * Splits `string` into an array of its words.
  833. *
  834. * @static
  835. * @memberOf _
  836. * @since 3.0.0
  837. * @category String
  838. * @param {string} [string=''] The string to inspect.
  839. * @param {RegExp|string} [pattern] The pattern to match words.
  840. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  841. * @returns {Array} Returns the words of `string`.
  842. * @example
  843. *
  844. * _.words('fred, barney, & pebbles');
  845. * // => ['fred', 'barney', 'pebbles']
  846. *
  847. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  848. * // => ['fred', 'barney', '&', 'pebbles']
  849. */
  850. function words(string, pattern, guard) {
  851. string = toString(string);
  852. pattern = pattern;
  853. if (pattern === undefined) {
  854. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  855. }
  856. return string.match(pattern) || [];
  857. }
  858. var lodash_camelcase = camelCase;
  859. Object.defineProperty(localsConvention, "__esModule", {
  860. value: true
  861. });
  862. localsConvention.makeLocalsConventionReducer = makeLocalsConventionReducer;
  863. var _lodash = _interopRequireDefault$5(lodash_camelcase);
  864. function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  865. function dashesCamelCase(string) {
  866. return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
  867. }
  868. function makeLocalsConventionReducer(localsConvention, inputFile) {
  869. const isFunc = typeof localsConvention === "function";
  870. return (tokens, [className, value]) => {
  871. if (isFunc) {
  872. const convention = localsConvention(className, value, inputFile);
  873. tokens[convention] = value;
  874. return tokens;
  875. }
  876. switch (localsConvention) {
  877. case "camelCase":
  878. tokens[className] = value;
  879. tokens[(0, _lodash.default)(className)] = value;
  880. break;
  881. case "camelCaseOnly":
  882. tokens[(0, _lodash.default)(className)] = value;
  883. break;
  884. case "dashes":
  885. tokens[className] = value;
  886. tokens[dashesCamelCase(className)] = value;
  887. break;
  888. case "dashesOnly":
  889. tokens[dashesCamelCase(className)] = value;
  890. break;
  891. }
  892. return tokens;
  893. };
  894. }
  895. var FileSystemLoader$1 = {};
  896. Object.defineProperty(FileSystemLoader$1, "__esModule", {
  897. value: true
  898. });
  899. FileSystemLoader$1.default = void 0;
  900. var _postcss$1 = _interopRequireDefault$4(require$$0);
  901. var _path = _interopRequireDefault$4(require$$0$1);
  902. var _Parser$1 = _interopRequireDefault$4(Parser$1);
  903. var _fs$1 = fs;
  904. function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  905. // Initially copied from https://github.com/css-modules/css-modules-loader-core
  906. class Core {
  907. constructor(plugins) {
  908. this.plugins = plugins || Core.defaultPlugins;
  909. }
  910. async load(sourceString, sourcePath, trace, pathFetcher) {
  911. const parser = new _Parser$1.default(pathFetcher, trace);
  912. const plugins = this.plugins.concat([parser.plugin()]);
  913. const result = await (0, _postcss$1.default)(plugins).process(sourceString, {
  914. from: sourcePath
  915. });
  916. return {
  917. injectableSource: result.css,
  918. exportTokens: parser.exportTokens
  919. };
  920. }
  921. } // Sorts dependencies in the following way:
  922. // AAA comes before AA and A
  923. // AB comes after AA and before A
  924. // All Bs come after all As
  925. // This ensures that the files are always returned in the following order:
  926. // - In the order they were required, except
  927. // - After all their dependencies
  928. const traceKeySorter = (a, b) => {
  929. if (a.length < b.length) {
  930. return a < b.substring(0, a.length) ? -1 : 1;
  931. }
  932. if (a.length > b.length) {
  933. return a.substring(0, b.length) <= b ? -1 : 1;
  934. }
  935. return a < b ? -1 : 1;
  936. };
  937. class FileSystemLoader {
  938. constructor(root, plugins, fileResolve) {
  939. if (root === "/" && process.platform === "win32") {
  940. const cwdDrive = process.cwd().slice(0, 3);
  941. if (!/^[A-Za-z]:\\$/.test(cwdDrive)) {
  942. throw new Error(`Failed to obtain root from "${process.cwd()}".`);
  943. }
  944. root = cwdDrive;
  945. }
  946. this.root = root;
  947. this.fileResolve = fileResolve;
  948. this.sources = {};
  949. this.traces = {};
  950. this.importNr = 0;
  951. this.core = new Core(plugins);
  952. this.tokensByFile = {};
  953. this.fs = (0, _fs$1.getFileSystem)();
  954. }
  955. async fetch(_newPath, relativeTo, _trace) {
  956. const newPath = _newPath.replace(/^["']|["']$/g, "");
  957. const trace = _trace || String.fromCharCode(this.importNr++);
  958. const useFileResolve = typeof this.fileResolve === "function";
  959. const fileResolvedPath = useFileResolve ? await this.fileResolve(newPath, relativeTo) : await Promise.resolve();
  960. if (fileResolvedPath && !_path.default.isAbsolute(fileResolvedPath)) {
  961. throw new Error('The returned path from the "fileResolve" option must be absolute.');
  962. }
  963. const relativeDir = _path.default.dirname(relativeTo);
  964. const rootRelativePath = fileResolvedPath || _path.default.resolve(relativeDir, newPath);
  965. let fileRelativePath = fileResolvedPath || _path.default.resolve(_path.default.resolve(this.root, relativeDir), newPath); // if the path is not relative or absolute, try to resolve it in node_modules
  966. if (!useFileResolve && newPath[0] !== "." && !_path.default.isAbsolute(newPath)) {
  967. try {
  968. fileRelativePath = require.resolve(newPath);
  969. } catch (e) {// noop
  970. }
  971. }
  972. const tokens = this.tokensByFile[fileRelativePath];
  973. if (tokens) return tokens;
  974. return new Promise((resolve, reject) => {
  975. this.fs.readFile(fileRelativePath, "utf-8", async (err, source) => {
  976. if (err) reject(err);
  977. const {
  978. injectableSource,
  979. exportTokens
  980. } = await this.core.load(source, rootRelativePath, trace, this.fetch.bind(this));
  981. this.sources[fileRelativePath] = injectableSource;
  982. this.traces[trace] = fileRelativePath;
  983. this.tokensByFile[fileRelativePath] = exportTokens;
  984. resolve(exportTokens);
  985. });
  986. });
  987. }
  988. get finalSource() {
  989. const traces = this.traces;
  990. const sources = this.sources;
  991. let written = new Set();
  992. return Object.keys(traces).sort(traceKeySorter).map(key => {
  993. const filename = traces[key];
  994. if (written.has(filename)) {
  995. return null;
  996. }
  997. written.add(filename);
  998. return sources[filename];
  999. }).join("");
  1000. }
  1001. }
  1002. FileSystemLoader$1.default = FileSystemLoader;
  1003. var scoping = {};
  1004. var src$3 = {exports: {}};
  1005. const PERMANENT_MARKER = 2;
  1006. const TEMPORARY_MARKER = 1;
  1007. function createError(node, graph) {
  1008. const er = new Error("Nondeterministic import's order");
  1009. const related = graph[node];
  1010. const relatedNode = related.find(
  1011. (relatedNode) => graph[relatedNode].indexOf(node) > -1
  1012. );
  1013. er.nodes = [node, relatedNode];
  1014. return er;
  1015. }
  1016. function walkGraph(node, graph, state, result, strict) {
  1017. if (state[node] === PERMANENT_MARKER) {
  1018. return;
  1019. }
  1020. if (state[node] === TEMPORARY_MARKER) {
  1021. if (strict) {
  1022. return createError(node, graph);
  1023. }
  1024. return;
  1025. }
  1026. state[node] = TEMPORARY_MARKER;
  1027. const children = graph[node];
  1028. const length = children.length;
  1029. for (let i = 0; i < length; ++i) {
  1030. const error = walkGraph(children[i], graph, state, result, strict);
  1031. if (error instanceof Error) {
  1032. return error;
  1033. }
  1034. }
  1035. state[node] = PERMANENT_MARKER;
  1036. result.push(node);
  1037. }
  1038. function topologicalSort$1(graph, strict) {
  1039. const result = [];
  1040. const state = {};
  1041. const nodes = Object.keys(graph);
  1042. const length = nodes.length;
  1043. for (let i = 0; i < length; ++i) {
  1044. const er = walkGraph(nodes[i], graph, state, result, strict);
  1045. if (er instanceof Error) {
  1046. return er;
  1047. }
  1048. }
  1049. return result;
  1050. }
  1051. var topologicalSort_1 = topologicalSort$1;
  1052. const topologicalSort = topologicalSort_1;
  1053. const matchImports$1 = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;
  1054. const icssImport = /^:import\((?:"([^"]+)"|'([^']+)')\)/;
  1055. const VISITED_MARKER = 1;
  1056. /**
  1057. * :import('G') {}
  1058. *
  1059. * Rule
  1060. * composes: ... from 'A'
  1061. * composes: ... from 'B'
  1062. * Rule
  1063. * composes: ... from 'A'
  1064. * composes: ... from 'A'
  1065. * composes: ... from 'C'
  1066. *
  1067. * Results in:
  1068. *
  1069. * graph: {
  1070. * G: [],
  1071. * A: [],
  1072. * B: ['A'],
  1073. * C: ['A'],
  1074. * }
  1075. */
  1076. function addImportToGraph(importId, parentId, graph, visited) {
  1077. const siblingsId = parentId + "_" + "siblings";
  1078. const visitedId = parentId + "_" + importId;
  1079. if (visited[visitedId] !== VISITED_MARKER) {
  1080. if (!Array.isArray(visited[siblingsId])) {
  1081. visited[siblingsId] = [];
  1082. }
  1083. const siblings = visited[siblingsId];
  1084. if (Array.isArray(graph[importId])) {
  1085. graph[importId] = graph[importId].concat(siblings);
  1086. } else {
  1087. graph[importId] = siblings.slice();
  1088. }
  1089. visited[visitedId] = VISITED_MARKER;
  1090. siblings.push(importId);
  1091. }
  1092. }
  1093. src$3.exports = (options = {}) => {
  1094. let importIndex = 0;
  1095. const createImportedName =
  1096. typeof options.createImportedName !== "function"
  1097. ? (importName /*, path*/) =>
  1098. `i__imported_${importName.replace(/\W/g, "_")}_${importIndex++}`
  1099. : options.createImportedName;
  1100. const failOnWrongOrder = options.failOnWrongOrder;
  1101. return {
  1102. postcssPlugin: "postcss-modules-extract-imports",
  1103. prepare() {
  1104. const graph = {};
  1105. const visited = {};
  1106. const existingImports = {};
  1107. const importDecls = {};
  1108. const imports = {};
  1109. return {
  1110. Once(root, postcss) {
  1111. // Check the existing imports order and save refs
  1112. root.walkRules((rule) => {
  1113. const matches = icssImport.exec(rule.selector);
  1114. if (matches) {
  1115. const [, /*match*/ doubleQuotePath, singleQuotePath] = matches;
  1116. const importPath = doubleQuotePath || singleQuotePath;
  1117. addImportToGraph(importPath, "root", graph, visited);
  1118. existingImports[importPath] = rule;
  1119. }
  1120. });
  1121. root.walkDecls(/^composes$/, (declaration) => {
  1122. const matches = declaration.value.match(matchImports$1);
  1123. if (!matches) {
  1124. return;
  1125. }
  1126. let tmpSymbols;
  1127. let [
  1128. ,
  1129. /*match*/ symbols,
  1130. doubleQuotePath,
  1131. singleQuotePath,
  1132. global,
  1133. ] = matches;
  1134. if (global) {
  1135. // Composing globals simply means changing these classes to wrap them in global(name)
  1136. tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
  1137. } else {
  1138. const importPath = doubleQuotePath || singleQuotePath;
  1139. let parent = declaration.parent;
  1140. let parentIndexes = "";
  1141. while (parent.type !== "root") {
  1142. parentIndexes =
  1143. parent.parent.index(parent) + "_" + parentIndexes;
  1144. parent = parent.parent;
  1145. }
  1146. const { selector } = declaration.parent;
  1147. const parentRule = `_${parentIndexes}${selector}`;
  1148. addImportToGraph(importPath, parentRule, graph, visited);
  1149. importDecls[importPath] = declaration;
  1150. imports[importPath] = imports[importPath] || {};
  1151. tmpSymbols = symbols.split(/\s+/).map((s) => {
  1152. if (!imports[importPath][s]) {
  1153. imports[importPath][s] = createImportedName(s, importPath);
  1154. }
  1155. return imports[importPath][s];
  1156. });
  1157. }
  1158. declaration.value = tmpSymbols.join(" ");
  1159. });
  1160. const importsOrder = topologicalSort(graph, failOnWrongOrder);
  1161. if (importsOrder instanceof Error) {
  1162. const importPath = importsOrder.nodes.find((importPath) =>
  1163. // eslint-disable-next-line no-prototype-builtins
  1164. importDecls.hasOwnProperty(importPath)
  1165. );
  1166. const decl = importDecls[importPath];
  1167. throw decl.error(
  1168. "Failed to resolve order of composed modules " +
  1169. importsOrder.nodes
  1170. .map((importPath) => "`" + importPath + "`")
  1171. .join(", ") +
  1172. ".",
  1173. {
  1174. plugin: "postcss-modules-extract-imports",
  1175. word: "composes",
  1176. }
  1177. );
  1178. }
  1179. let lastImportRule;
  1180. importsOrder.forEach((path) => {
  1181. const importedSymbols = imports[path];
  1182. let rule = existingImports[path];
  1183. if (!rule && importedSymbols) {
  1184. rule = postcss.rule({
  1185. selector: `:import("${path}")`,
  1186. raws: { after: "\n" },
  1187. });
  1188. if (lastImportRule) {
  1189. root.insertAfter(lastImportRule, rule);
  1190. } else {
  1191. root.prepend(rule);
  1192. }
  1193. }
  1194. lastImportRule = rule;
  1195. if (!importedSymbols) {
  1196. return;
  1197. }
  1198. Object.keys(importedSymbols).forEach((importedSymbol) => {
  1199. rule.append(
  1200. postcss.decl({
  1201. value: importedSymbol,
  1202. prop: importedSymbols[importedSymbol],
  1203. raws: { before: "\n " },
  1204. })
  1205. );
  1206. });
  1207. });
  1208. },
  1209. };
  1210. },
  1211. };
  1212. };
  1213. src$3.exports.postcss = true;
  1214. var srcExports$2 = src$3.exports;
  1215. var wasmHash = {exports: {}};
  1216. /*
  1217. MIT License http://www.opensource.org/licenses/mit-license.php
  1218. Author Tobias Koppers @sokra
  1219. */
  1220. var hasRequiredWasmHash;
  1221. function requireWasmHash () {
  1222. if (hasRequiredWasmHash) return wasmHash.exports;
  1223. hasRequiredWasmHash = 1;
  1224. // 65536 is the size of a wasm memory page
  1225. // 64 is the maximum chunk size for every possible wasm hash implementation
  1226. // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
  1227. // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
  1228. const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
  1229. class WasmHash {
  1230. /**
  1231. * @param {WebAssembly.Instance} instance wasm instance
  1232. * @param {WebAssembly.Instance[]} instancesPool pool of instances
  1233. * @param {number} chunkSize size of data chunks passed to wasm
  1234. * @param {number} digestSize size of digest returned by wasm
  1235. */
  1236. constructor(instance, instancesPool, chunkSize, digestSize) {
  1237. const exports = /** @type {any} */ (instance.exports);
  1238. exports.init();
  1239. this.exports = exports;
  1240. this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
  1241. this.buffered = 0;
  1242. this.instancesPool = instancesPool;
  1243. this.chunkSize = chunkSize;
  1244. this.digestSize = digestSize;
  1245. }
  1246. reset() {
  1247. this.buffered = 0;
  1248. this.exports.init();
  1249. }
  1250. /**
  1251. * @param {Buffer | string} data data
  1252. * @param {BufferEncoding=} encoding encoding
  1253. * @returns {this} itself
  1254. */
  1255. update(data, encoding) {
  1256. if (typeof data === "string") {
  1257. while (data.length > MAX_SHORT_STRING) {
  1258. this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
  1259. data = data.slice(MAX_SHORT_STRING);
  1260. }
  1261. this._updateWithShortString(data, encoding);
  1262. return this;
  1263. }
  1264. this._updateWithBuffer(data);
  1265. return this;
  1266. }
  1267. /**
  1268. * @param {string} data data
  1269. * @param {BufferEncoding=} encoding encoding
  1270. * @returns {void}
  1271. */
  1272. _updateWithShortString(data, encoding) {
  1273. const { exports, buffered, mem, chunkSize } = this;
  1274. let endPos;
  1275. if (data.length < 70) {
  1276. if (!encoding || encoding === "utf-8" || encoding === "utf8") {
  1277. endPos = buffered;
  1278. for (let i = 0; i < data.length; i++) {
  1279. const cc = data.charCodeAt(i);
  1280. if (cc < 0x80) {
  1281. mem[endPos++] = cc;
  1282. } else if (cc < 0x800) {
  1283. mem[endPos] = (cc >> 6) | 0xc0;
  1284. mem[endPos + 1] = (cc & 0x3f) | 0x80;
  1285. endPos += 2;
  1286. } else {
  1287. // bail-out for weird chars
  1288. endPos += mem.write(data.slice(i), endPos, encoding);
  1289. break;
  1290. }
  1291. }
  1292. } else if (encoding === "latin1") {
  1293. endPos = buffered;
  1294. for (let i = 0; i < data.length; i++) {
  1295. const cc = data.charCodeAt(i);
  1296. mem[endPos++] = cc;
  1297. }
  1298. } else {
  1299. endPos = buffered + mem.write(data, buffered, encoding);
  1300. }
  1301. } else {
  1302. endPos = buffered + mem.write(data, buffered, encoding);
  1303. }
  1304. if (endPos < chunkSize) {
  1305. this.buffered = endPos;
  1306. } else {
  1307. const l = endPos & ~(this.chunkSize - 1);
  1308. exports.update(l);
  1309. const newBuffered = endPos - l;
  1310. this.buffered = newBuffered;
  1311. if (newBuffered > 0) {
  1312. mem.copyWithin(0, l, endPos);
  1313. }
  1314. }
  1315. }
  1316. /**
  1317. * @param {Buffer} data data
  1318. * @returns {void}
  1319. */
  1320. _updateWithBuffer(data) {
  1321. const { exports, buffered, mem } = this;
  1322. const length = data.length;
  1323. if (buffered + length < this.chunkSize) {
  1324. data.copy(mem, buffered, 0, length);
  1325. this.buffered += length;
  1326. } else {
  1327. const l = (buffered + length) & ~(this.chunkSize - 1);
  1328. if (l > 65536) {
  1329. let i = 65536 - buffered;
  1330. data.copy(mem, buffered, 0, i);
  1331. exports.update(65536);
  1332. const stop = l - buffered - 65536;
  1333. while (i < stop) {
  1334. data.copy(mem, 0, i, i + 65536);
  1335. exports.update(65536);
  1336. i += 65536;
  1337. }
  1338. data.copy(mem, 0, i, l - buffered);
  1339. exports.update(l - buffered - i);
  1340. } else {
  1341. data.copy(mem, buffered, 0, l - buffered);
  1342. exports.update(l);
  1343. }
  1344. const newBuffered = length + buffered - l;
  1345. this.buffered = newBuffered;
  1346. if (newBuffered > 0) {
  1347. data.copy(mem, 0, length - newBuffered, length);
  1348. }
  1349. }
  1350. }
  1351. digest(type) {
  1352. const { exports, buffered, mem, digestSize } = this;
  1353. exports.final(buffered);
  1354. this.instancesPool.push(this);
  1355. const hex = mem.toString("latin1", 0, digestSize);
  1356. if (type === "hex") {
  1357. return hex;
  1358. }
  1359. if (type === "binary" || !type) {
  1360. return Buffer.from(hex, "hex");
  1361. }
  1362. return Buffer.from(hex, "hex").toString(type);
  1363. }
  1364. }
  1365. const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
  1366. if (instancesPool.length > 0) {
  1367. const old = instancesPool.pop();
  1368. old.reset();
  1369. return old;
  1370. } else {
  1371. return new WasmHash(
  1372. new WebAssembly.Instance(wasmModule),
  1373. instancesPool,
  1374. chunkSize,
  1375. digestSize
  1376. );
  1377. }
  1378. };
  1379. wasmHash.exports = create;
  1380. wasmHash.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
  1381. return wasmHash.exports;
  1382. }
  1383. /*
  1384. MIT License http://www.opensource.org/licenses/mit-license.php
  1385. Author Tobias Koppers @sokra
  1386. */
  1387. var xxhash64_1;
  1388. var hasRequiredXxhash64;
  1389. function requireXxhash64 () {
  1390. if (hasRequiredXxhash64) return xxhash64_1;
  1391. hasRequiredXxhash64 = 1;
  1392. const create = requireWasmHash();
  1393. //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
  1394. const xxhash64 = new WebAssembly.Module(
  1395. Buffer.from(
  1396. // 1173 bytes
  1397. "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrUIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqwYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAVCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEACfyACIAE1AgBCh5Wvr5i23puef36FQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCECIAFBBGoLIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAiACQh2IhUL5893xmfaZqxZ+IgIgAkIgiIUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
  1398. "base64"
  1399. )
  1400. );
  1401. //#endregion
  1402. xxhash64_1 = create.bind(null, xxhash64, [], 32, 16);
  1403. return xxhash64_1;
  1404. }
  1405. var BatchedHash_1;
  1406. var hasRequiredBatchedHash;
  1407. function requireBatchedHash () {
  1408. if (hasRequiredBatchedHash) return BatchedHash_1;
  1409. hasRequiredBatchedHash = 1;
  1410. const MAX_SHORT_STRING = requireWasmHash().MAX_SHORT_STRING;
  1411. class BatchedHash {
  1412. constructor(hash) {
  1413. this.string = undefined;
  1414. this.encoding = undefined;
  1415. this.hash = hash;
  1416. }
  1417. /**
  1418. * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
  1419. * @param {string|Buffer} data data
  1420. * @param {string=} inputEncoding data encoding
  1421. * @returns {this} updated hash
  1422. */
  1423. update(data, inputEncoding) {
  1424. if (this.string !== undefined) {
  1425. if (
  1426. typeof data === "string" &&
  1427. inputEncoding === this.encoding &&
  1428. this.string.length + data.length < MAX_SHORT_STRING
  1429. ) {
  1430. this.string += data;
  1431. return this;
  1432. }
  1433. this.hash.update(this.string, this.encoding);
  1434. this.string = undefined;
  1435. }
  1436. if (typeof data === "string") {
  1437. if (
  1438. data.length < MAX_SHORT_STRING &&
  1439. // base64 encoding is not valid since it may contain padding chars
  1440. (!inputEncoding || !inputEncoding.startsWith("ba"))
  1441. ) {
  1442. this.string = data;
  1443. this.encoding = inputEncoding;
  1444. } else {
  1445. this.hash.update(data, inputEncoding);
  1446. }
  1447. } else {
  1448. this.hash.update(data);
  1449. }
  1450. return this;
  1451. }
  1452. /**
  1453. * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
  1454. * @param {string=} encoding encoding of the return value
  1455. * @returns {string|Buffer} digest
  1456. */
  1457. digest(encoding) {
  1458. if (this.string !== undefined) {
  1459. this.hash.update(this.string, this.encoding);
  1460. }
  1461. return this.hash.digest(encoding);
  1462. }
  1463. }
  1464. BatchedHash_1 = BatchedHash;
  1465. return BatchedHash_1;
  1466. }
  1467. /*
  1468. MIT License http://www.opensource.org/licenses/mit-license.php
  1469. Author Tobias Koppers @sokra
  1470. */
  1471. var md4_1;
  1472. var hasRequiredMd4;
  1473. function requireMd4 () {
  1474. if (hasRequiredMd4) return md4_1;
  1475. hasRequiredMd4 = 1;
  1476. const create = requireWasmHash();
  1477. //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
  1478. const md4 = new WebAssembly.Module(
  1479. Buffer.from(
  1480. // 2150 bytes
  1481. "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvMCgEYfyMBIQojAiEGIwMhByMEIQgDQCAAIAVLBEAgBSgCCCINIAcgBiAFKAIEIgsgCCAHIAUoAgAiDCAKIAggBiAHIAhzcXNqakEDdyIDIAYgB3Nxc2pqQQd3IgEgAyAGc3FzampBC3chAiAFKAIUIg8gASACIAUoAhAiCSADIAEgBSgCDCIOIAYgAyACIAEgA3Nxc2pqQRN3IgQgASACc3FzampBA3ciAyACIARzcXNqakEHdyEBIAUoAiAiEiADIAEgBSgCHCIRIAQgAyAFKAIYIhAgAiAEIAEgAyAEc3FzampBC3ciAiABIANzcXNqakETdyIEIAEgAnNxc2pqQQN3IQMgBSgCLCIVIAQgAyAFKAIoIhQgAiAEIAUoAiQiEyABIAIgAyACIARzcXNqakEHdyIBIAMgBHNxc2pqQQt3IgIgASADc3FzampBE3chBCAPIBAgCSAVIBQgEyAFKAI4IhYgAiAEIAUoAjQiFyABIAIgBSgCMCIYIAMgASAEIAEgAnNxc2pqQQN3IgEgAiAEc3FzampBB3ciAiABIARzcXNqakELdyIDIAkgAiAMIAEgBSgCPCIJIAQgASADIAEgAnNxc2pqQRN3IgEgAiADcnEgAiADcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyaiASakGZ84nUBWpBCXciAyAPIAQgCyACIBggASADIAIgBHJxIAIgBHFyampBmfOJ1AVqQQ13IgEgAyAEcnEgAyAEcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyampBmfOJ1AVqQQl3IgMgECAEIAIgFyABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmogDWpBmfOJ1AVqQQN3IgIgASADcnEgASADcXJqakGZ84nUBWpBBXciBCABIAJycSABIAJxcmpqQZnzidQFakEJdyIDIBEgBCAOIAIgFiABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmpqQZnzidQFakEDdyICIAEgA3JxIAEgA3FyampBmfOJ1AVqQQV3IgQgASACcnEgASACcXJqakGZ84nUBWpBCXciAyAMIAIgAyAJIAEgAyACIARycSACIARxcmpqQZnzidQFakENdyIBcyAEc2pqQaHX5/YGakEDdyICIAQgASACcyADc2ogEmpBodfn9gZqQQl3IgRzIAFzampBodfn9gZqQQt3IgMgAiADIBggASADIARzIAJzampBodfn9gZqQQ93IgFzIARzaiANakGh1+f2BmpBA3ciAiAUIAQgASACcyADc2pqQaHX5/YGakEJdyIEcyABc2pqQaHX5/YGakELdyIDIAsgAiADIBYgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgIgEyAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3chAyAKIA4gAiADIBcgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgJqIQogBiAJIAEgESADIAIgFSAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3ciAyAEcyACc2pqQaHX5/YGakEPd2ohBiADIAdqIQcgBCAIaiEIIAVBQGshBQwBCwsgCiQBIAYkAiAHJAMgCCQECw0AIAAQASMAIABqJAAL/wQCA38BfiMAIABqrUIDhiEEIABByABqQUBxIgJBCGshAyAAIgFBAWohACABQYABOgAAA0AgACACSUEAIABBB3EbBEAgAEEAOgAAIABBAWohAAwBCwsDQCAAIAJJBEAgAEIANwMAIABBCGohAAwBCwsgAyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
  1482. "base64"
  1483. )
  1484. );
  1485. //#endregion
  1486. md4_1 = create.bind(null, md4, [], 64, 32);
  1487. return md4_1;
  1488. }
  1489. var BulkUpdateDecorator_1;
  1490. var hasRequiredBulkUpdateDecorator;
  1491. function requireBulkUpdateDecorator () {
  1492. if (hasRequiredBulkUpdateDecorator) return BulkUpdateDecorator_1;
  1493. hasRequiredBulkUpdateDecorator = 1;
  1494. const BULK_SIZE = 2000;
  1495. // We are using an object instead of a Map as this will stay static during the runtime
  1496. // so access to it can be optimized by v8
  1497. const digestCaches = {};
  1498. class BulkUpdateDecorator {
  1499. /**
  1500. * @param {Hash | function(): Hash} hashOrFactory function to create a hash
  1501. * @param {string=} hashKey key for caching
  1502. */
  1503. constructor(hashOrFactory, hashKey) {
  1504. this.hashKey = hashKey;
  1505. if (typeof hashOrFactory === "function") {
  1506. this.hashFactory = hashOrFactory;
  1507. this.hash = undefined;
  1508. } else {
  1509. this.hashFactory = undefined;
  1510. this.hash = hashOrFactory;
  1511. }
  1512. this.buffer = "";
  1513. }
  1514. /**
  1515. * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
  1516. * @param {string|Buffer} data data
  1517. * @param {string=} inputEncoding data encoding
  1518. * @returns {this} updated hash
  1519. */
  1520. update(data, inputEncoding) {
  1521. if (
  1522. inputEncoding !== undefined ||
  1523. typeof data !== "string" ||
  1524. data.length > BULK_SIZE
  1525. ) {
  1526. if (this.hash === undefined) {
  1527. this.hash = this.hashFactory();
  1528. }
  1529. if (this.buffer.length > 0) {
  1530. this.hash.update(this.buffer);
  1531. this.buffer = "";
  1532. }
  1533. this.hash.update(data, inputEncoding);
  1534. } else {
  1535. this.buffer += data;
  1536. if (this.buffer.length > BULK_SIZE) {
  1537. if (this.hash === undefined) {
  1538. this.hash = this.hashFactory();
  1539. }
  1540. this.hash.update(this.buffer);
  1541. this.buffer = "";
  1542. }
  1543. }
  1544. return this;
  1545. }
  1546. /**
  1547. * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
  1548. * @param {string=} encoding encoding of the return value
  1549. * @returns {string|Buffer} digest
  1550. */
  1551. digest(encoding) {
  1552. let digestCache;
  1553. const buffer = this.buffer;
  1554. if (this.hash === undefined) {
  1555. // short data for hash, we can use caching
  1556. const cacheKey = `${this.hashKey}-${encoding}`;
  1557. digestCache = digestCaches[cacheKey];
  1558. if (digestCache === undefined) {
  1559. digestCache = digestCaches[cacheKey] = new Map();
  1560. }
  1561. const cacheEntry = digestCache.get(buffer);
  1562. if (cacheEntry !== undefined) {
  1563. return cacheEntry;
  1564. }
  1565. this.hash = this.hashFactory();
  1566. }
  1567. if (buffer.length > 0) {
  1568. this.hash.update(buffer);
  1569. }
  1570. const digestResult = this.hash.digest(encoding);
  1571. if (digestCache !== undefined) {
  1572. digestCache.set(buffer, digestResult);
  1573. }
  1574. return digestResult;
  1575. }
  1576. }
  1577. BulkUpdateDecorator_1 = BulkUpdateDecorator;
  1578. return BulkUpdateDecorator_1;
  1579. }
  1580. const baseEncodeTables = {
  1581. 26: "abcdefghijklmnopqrstuvwxyz",
  1582. 32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio
  1583. 36: "0123456789abcdefghijklmnopqrstuvwxyz",
  1584. 49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no lIO
  1585. 52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  1586. 58: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no 0lIO
  1587. 62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  1588. 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",
  1589. };
  1590. /**
  1591. * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian
  1592. * @param {number} divisor The divisor
  1593. * @return {number} Modulo (remainder) of the division
  1594. */
  1595. function divmod32(uint32Array, divisor) {
  1596. let carry = 0;
  1597. for (let i = uint32Array.length - 1; i >= 0; i--) {
  1598. const value = carry * 0x100000000 + uint32Array[i];
  1599. carry = value % divisor;
  1600. uint32Array[i] = Math.floor(value / divisor);
  1601. }
  1602. return carry;
  1603. }
  1604. function encodeBufferToBase(buffer, base, length) {
  1605. const encodeTable = baseEncodeTables[base];
  1606. if (!encodeTable) {
  1607. throw new Error("Unknown encoding base" + base);
  1608. }
  1609. // Input bits are only enough to generate this many characters
  1610. const limit = Math.ceil((buffer.length * 8) / Math.log2(base));
  1611. length = Math.min(length, limit);
  1612. // Most of the crypto digests (if not all) has length a multiple of 4 bytes.
  1613. // Fewer numbers in the array means faster math.
  1614. const uint32Array = new Uint32Array(Math.ceil(buffer.length / 4));
  1615. // Make sure the input buffer data is copied and is not mutated by reference.
  1616. // divmod32() would corrupt the BulkUpdateDecorator cache otherwise.
  1617. buffer.copy(Buffer.from(uint32Array.buffer));
  1618. let output = "";
  1619. for (let i = 0; i < length; i++) {
  1620. output = encodeTable[divmod32(uint32Array, base)] + output;
  1621. }
  1622. return output;
  1623. }
  1624. let crypto = undefined;
  1625. let createXXHash64 = undefined;
  1626. let createMd4 = undefined;
  1627. let BatchedHash = undefined;
  1628. let BulkUpdateDecorator = undefined;
  1629. function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
  1630. algorithm = algorithm || "xxhash64";
  1631. maxLength = maxLength || 9999;
  1632. let hash;
  1633. if (algorithm === "xxhash64") {
  1634. if (createXXHash64 === undefined) {
  1635. createXXHash64 = requireXxhash64();
  1636. if (BatchedHash === undefined) {
  1637. BatchedHash = requireBatchedHash();
  1638. }
  1639. }
  1640. hash = new BatchedHash(createXXHash64());
  1641. } else if (algorithm === "md4") {
  1642. if (createMd4 === undefined) {
  1643. createMd4 = requireMd4();
  1644. if (BatchedHash === undefined) {
  1645. BatchedHash = requireBatchedHash();
  1646. }
  1647. }
  1648. hash = new BatchedHash(createMd4());
  1649. } else if (algorithm === "native-md4") {
  1650. if (typeof crypto === "undefined") {
  1651. crypto = require$$3;
  1652. if (BulkUpdateDecorator === undefined) {
  1653. BulkUpdateDecorator = requireBulkUpdateDecorator();
  1654. }
  1655. }
  1656. hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
  1657. } else {
  1658. if (typeof crypto === "undefined") {
  1659. crypto = require$$3;
  1660. if (BulkUpdateDecorator === undefined) {
  1661. BulkUpdateDecorator = requireBulkUpdateDecorator();
  1662. }
  1663. }
  1664. hash = new BulkUpdateDecorator(
  1665. () => crypto.createHash(algorithm),
  1666. algorithm
  1667. );
  1668. }
  1669. hash.update(buffer);
  1670. if (
  1671. digestType === "base26" ||
  1672. digestType === "base32" ||
  1673. digestType === "base36" ||
  1674. digestType === "base49" ||
  1675. digestType === "base52" ||
  1676. digestType === "base58" ||
  1677. digestType === "base62"
  1678. ) {
  1679. return encodeBufferToBase(hash.digest(), digestType.substr(4), maxLength);
  1680. } else {
  1681. return hash.digest(digestType || "hex").substr(0, maxLength);
  1682. }
  1683. }
  1684. var getHashDigest_1 = getHashDigest$1;
  1685. const path$1 = require$$0$1;
  1686. const getHashDigest = getHashDigest_1;
  1687. function interpolateName$1(loaderContext, name, options = {}) {
  1688. let filename;
  1689. const hasQuery =
  1690. loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1;
  1691. if (typeof name === "function") {
  1692. filename = name(
  1693. loaderContext.resourcePath,
  1694. hasQuery ? loaderContext.resourceQuery : undefined
  1695. );
  1696. } else {
  1697. filename = name || "[hash].[ext]";
  1698. }
  1699. const context = options.context;
  1700. const content = options.content;
  1701. const regExp = options.regExp;
  1702. let ext = "bin";
  1703. let basename = "file";
  1704. let directory = "";
  1705. let folder = "";
  1706. let query = "";
  1707. if (loaderContext.resourcePath) {
  1708. const parsed = path$1.parse(loaderContext.resourcePath);
  1709. let resourcePath = loaderContext.resourcePath;
  1710. if (parsed.ext) {
  1711. ext = parsed.ext.substr(1);
  1712. }
  1713. if (parsed.dir) {
  1714. basename = parsed.name;
  1715. resourcePath = parsed.dir + path$1.sep;
  1716. }
  1717. if (typeof context !== "undefined") {
  1718. directory = path$1
  1719. .relative(context, resourcePath + "_")
  1720. .replace(/\\/g, "/")
  1721. .replace(/\.\.(\/)?/g, "_$1");
  1722. directory = directory.substr(0, directory.length - 1);
  1723. } else {
  1724. directory = resourcePath.replace(/\\/g, "/").replace(/\.\.(\/)?/g, "_$1");
  1725. }
  1726. if (directory.length === 1) {
  1727. directory = "";
  1728. } else if (directory.length > 1) {
  1729. folder = path$1.basename(directory);
  1730. }
  1731. }
  1732. if (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) {
  1733. query = loaderContext.resourceQuery;
  1734. const hashIdx = query.indexOf("#");
  1735. if (hashIdx >= 0) {
  1736. query = query.substr(0, hashIdx);
  1737. }
  1738. }
  1739. let url = filename;
  1740. if (content) {
  1741. // Match hash template
  1742. url = url
  1743. // `hash` and `contenthash` are same in `loader-utils` context
  1744. // let's keep `hash` for backward compatibility
  1745. .replace(
  1746. /\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
  1747. (all, hashType, digestType, maxLength) =>
  1748. getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
  1749. );
  1750. }
  1751. url = url
  1752. .replace(/\[ext\]/gi, () => ext)
  1753. .replace(/\[name\]/gi, () => basename)
  1754. .replace(/\[path\]/gi, () => directory)
  1755. .replace(/\[folder\]/gi, () => folder)
  1756. .replace(/\[query\]/gi, () => query);
  1757. if (regExp && loaderContext.resourcePath) {
  1758. const match = loaderContext.resourcePath.match(new RegExp(regExp));
  1759. match &&
  1760. match.forEach((matched, i) => {
  1761. url = url.replace(new RegExp("\\[" + i + "\\]", "ig"), matched);
  1762. });
  1763. }
  1764. if (
  1765. typeof loaderContext.options === "object" &&
  1766. typeof loaderContext.options.customInterpolateName === "function"
  1767. ) {
  1768. url = loaderContext.options.customInterpolateName.call(
  1769. loaderContext,
  1770. url,
  1771. name,
  1772. options
  1773. );
  1774. }
  1775. return url;
  1776. }
  1777. var interpolateName_1 = interpolateName$1;
  1778. var interpolateName = interpolateName_1;
  1779. var path = require$$0$1;
  1780. /**
  1781. * @param {string} pattern
  1782. * @param {object} options
  1783. * @param {string} options.context
  1784. * @param {string} options.hashPrefix
  1785. * @return {function}
  1786. */
  1787. var genericNames = function createGenerator(pattern, options) {
  1788. options = options || {};
  1789. var context =
  1790. options && typeof options.context === "string"
  1791. ? options.context
  1792. : process.cwd();
  1793. var hashPrefix =
  1794. options && typeof options.hashPrefix === "string" ? options.hashPrefix : "";
  1795. /**
  1796. * @param {string} localName Usually a class name
  1797. * @param {string} filepath Absolute path
  1798. * @return {string}
  1799. */
  1800. return function generate(localName, filepath) {
  1801. var name = pattern.replace(/\[local\]/gi, localName);
  1802. var loaderContext = {
  1803. resourcePath: filepath,
  1804. };
  1805. var loaderOptions = {
  1806. content:
  1807. hashPrefix +
  1808. path.relative(context, filepath).replace(/\\/g, "/") +
  1809. "\x00" +
  1810. localName,
  1811. context: context,
  1812. };
  1813. var genericName = interpolateName(loaderContext, name, loaderOptions);
  1814. return genericName
  1815. .replace(new RegExp("[^a-zA-Z0-9\\-_\u00A0-\uFFFF]", "g"), "-")
  1816. .replace(/^((-?[0-9])|--)/, "_$1");
  1817. };
  1818. };
  1819. var src$2 = {exports: {}};
  1820. var dist = {exports: {}};
  1821. var processor = {exports: {}};
  1822. var parser = {exports: {}};
  1823. var root$1 = {exports: {}};
  1824. var container = {exports: {}};
  1825. var node$1 = {exports: {}};
  1826. var util = {};
  1827. var unesc = {exports: {}};
  1828. (function (module, exports) {
  1829. exports.__esModule = true;
  1830. exports["default"] = unesc;
  1831. // Many thanks for this post which made this migration much easier.
  1832. // https://mathiasbynens.be/notes/css-escapes
  1833. /**
  1834. *
  1835. * @param {string} str
  1836. * @returns {[string, number]|undefined}
  1837. */
  1838. function gobbleHex(str) {
  1839. var lower = str.toLowerCase();
  1840. var hex = '';
  1841. var spaceTerminated = false;
  1842. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  1843. var code = lower.charCodeAt(i);
  1844. // check to see if we are dealing with a valid hex char [a-f|0-9]
  1845. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  1846. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  1847. spaceTerminated = code === 32;
  1848. if (!valid) {
  1849. break;
  1850. }
  1851. hex += lower[i];
  1852. }
  1853. if (hex.length === 0) {
  1854. return undefined;
  1855. }
  1856. var codePoint = parseInt(hex, 16);
  1857. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  1858. // Add special case for
  1859. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  1860. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  1861. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  1862. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  1863. }
  1864. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  1865. }
  1866. var CONTAINS_ESCAPE = /\\/;
  1867. function unesc(str) {
  1868. var needToProcess = CONTAINS_ESCAPE.test(str);
  1869. if (!needToProcess) {
  1870. return str;
  1871. }
  1872. var ret = "";
  1873. for (var i = 0; i < str.length; i++) {
  1874. if (str[i] === "\\") {
  1875. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  1876. if (gobbled !== undefined) {
  1877. ret += gobbled[0];
  1878. i += gobbled[1];
  1879. continue;
  1880. }
  1881. // Retain a pair of \\ if double escaped `\\\\`
  1882. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  1883. if (str[i + 1] === "\\") {
  1884. ret += "\\";
  1885. i++;
  1886. continue;
  1887. }
  1888. // if \\ is at the end of the string retain it
  1889. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  1890. if (str.length === i + 1) {
  1891. ret += str[i];
  1892. }
  1893. continue;
  1894. }
  1895. ret += str[i];
  1896. }
  1897. return ret;
  1898. }
  1899. module.exports = exports.default;
  1900. } (unesc, unesc.exports));
  1901. var unescExports = unesc.exports;
  1902. var getProp = {exports: {}};
  1903. (function (module, exports) {
  1904. exports.__esModule = true;
  1905. exports["default"] = getProp;
  1906. function getProp(obj) {
  1907. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1908. props[_key - 1] = arguments[_key];
  1909. }
  1910. while (props.length > 0) {
  1911. var prop = props.shift();
  1912. if (!obj[prop]) {
  1913. return undefined;
  1914. }
  1915. obj = obj[prop];
  1916. }
  1917. return obj;
  1918. }
  1919. module.exports = exports.default;
  1920. } (getProp, getProp.exports));
  1921. var getPropExports = getProp.exports;
  1922. var ensureObject = {exports: {}};
  1923. (function (module, exports) {
  1924. exports.__esModule = true;
  1925. exports["default"] = ensureObject;
  1926. function ensureObject(obj) {
  1927. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1928. props[_key - 1] = arguments[_key];
  1929. }
  1930. while (props.length > 0) {
  1931. var prop = props.shift();
  1932. if (!obj[prop]) {
  1933. obj[prop] = {};
  1934. }
  1935. obj = obj[prop];
  1936. }
  1937. }
  1938. module.exports = exports.default;
  1939. } (ensureObject, ensureObject.exports));
  1940. var ensureObjectExports = ensureObject.exports;
  1941. var stripComments = {exports: {}};
  1942. (function (module, exports) {
  1943. exports.__esModule = true;
  1944. exports["default"] = stripComments;
  1945. function stripComments(str) {
  1946. var s = "";
  1947. var commentStart = str.indexOf("/*");
  1948. var lastEnd = 0;
  1949. while (commentStart >= 0) {
  1950. s = s + str.slice(lastEnd, commentStart);
  1951. var commentEnd = str.indexOf("*/", commentStart + 2);
  1952. if (commentEnd < 0) {
  1953. return s;
  1954. }
  1955. lastEnd = commentEnd + 2;
  1956. commentStart = str.indexOf("/*", lastEnd);
  1957. }
  1958. s = s + str.slice(lastEnd);
  1959. return s;
  1960. }
  1961. module.exports = exports.default;
  1962. } (stripComments, stripComments.exports));
  1963. var stripCommentsExports = stripComments.exports;
  1964. util.__esModule = true;
  1965. util.unesc = util.stripComments = util.getProp = util.ensureObject = void 0;
  1966. var _unesc = _interopRequireDefault$3(unescExports);
  1967. util.unesc = _unesc["default"];
  1968. var _getProp = _interopRequireDefault$3(getPropExports);
  1969. util.getProp = _getProp["default"];
  1970. var _ensureObject = _interopRequireDefault$3(ensureObjectExports);
  1971. util.ensureObject = _ensureObject["default"];
  1972. var _stripComments = _interopRequireDefault$3(stripCommentsExports);
  1973. util.stripComments = _stripComments["default"];
  1974. function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  1975. (function (module, exports) {
  1976. exports.__esModule = true;
  1977. exports["default"] = void 0;
  1978. var _util = util;
  1979. 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); } }
  1980. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1981. var cloneNode = function cloneNode(obj, parent) {
  1982. if (typeof obj !== 'object' || obj === null) {
  1983. return obj;
  1984. }
  1985. var cloned = new obj.constructor();
  1986. for (var i in obj) {
  1987. if (!obj.hasOwnProperty(i)) {
  1988. continue;
  1989. }
  1990. var value = obj[i];
  1991. var type = typeof value;
  1992. if (i === 'parent' && type === 'object') {
  1993. if (parent) {
  1994. cloned[i] = parent;
  1995. }
  1996. } else if (value instanceof Array) {
  1997. cloned[i] = value.map(function (j) {
  1998. return cloneNode(j, cloned);
  1999. });
  2000. } else {
  2001. cloned[i] = cloneNode(value, cloned);
  2002. }
  2003. }
  2004. return cloned;
  2005. };
  2006. var Node = /*#__PURE__*/function () {
  2007. function Node(opts) {
  2008. if (opts === void 0) {
  2009. opts = {};
  2010. }
  2011. Object.assign(this, opts);
  2012. this.spaces = this.spaces || {};
  2013. this.spaces.before = this.spaces.before || '';
  2014. this.spaces.after = this.spaces.after || '';
  2015. }
  2016. var _proto = Node.prototype;
  2017. _proto.remove = function remove() {
  2018. if (this.parent) {
  2019. this.parent.removeChild(this);
  2020. }
  2021. this.parent = undefined;
  2022. return this;
  2023. };
  2024. _proto.replaceWith = function replaceWith() {
  2025. if (this.parent) {
  2026. for (var index in arguments) {
  2027. this.parent.insertBefore(this, arguments[index]);
  2028. }
  2029. this.remove();
  2030. }
  2031. return this;
  2032. };
  2033. _proto.next = function next() {
  2034. return this.parent.at(this.parent.index(this) + 1);
  2035. };
  2036. _proto.prev = function prev() {
  2037. return this.parent.at(this.parent.index(this) - 1);
  2038. };
  2039. _proto.clone = function clone(overrides) {
  2040. if (overrides === void 0) {
  2041. overrides = {};
  2042. }
  2043. var cloned = cloneNode(this);
  2044. for (var name in overrides) {
  2045. cloned[name] = overrides[name];
  2046. }
  2047. return cloned;
  2048. }
  2049. /**
  2050. * Some non-standard syntax doesn't follow normal escaping rules for css.
  2051. * This allows non standard syntax to be appended to an existing property
  2052. * by specifying the escaped value. By specifying the escaped value,
  2053. * illegal characters are allowed to be directly inserted into css output.
  2054. * @param {string} name the property to set
  2055. * @param {any} value the unescaped value of the property
  2056. * @param {string} valueEscaped optional. the escaped value of the property.
  2057. */;
  2058. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  2059. if (!this.raws) {
  2060. this.raws = {};
  2061. }
  2062. var originalValue = this[name];
  2063. var originalEscaped = this.raws[name];
  2064. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  2065. if (originalEscaped || valueEscaped !== value) {
  2066. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  2067. } else {
  2068. delete this.raws[name]; // delete any escaped value that was created by the setter.
  2069. }
  2070. }
  2071. /**
  2072. * Some non-standard syntax doesn't follow normal escaping rules for css.
  2073. * This allows the escaped value to be specified directly, allowing illegal
  2074. * characters to be directly inserted into css output.
  2075. * @param {string} name the property to set
  2076. * @param {any} value the unescaped value of the property
  2077. * @param {string} valueEscaped the escaped value of the property.
  2078. */;
  2079. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  2080. if (!this.raws) {
  2081. this.raws = {};
  2082. }
  2083. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  2084. this.raws[name] = valueEscaped;
  2085. }
  2086. /**
  2087. * When you want a value to passed through to CSS directly. This method
  2088. * deletes the corresponding raw value causing the stringifier to fallback
  2089. * to the unescaped value.
  2090. * @param {string} name the property to set.
  2091. * @param {any} value The value that is both escaped and unescaped.
  2092. */;
  2093. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  2094. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  2095. if (this.raws) {
  2096. delete this.raws[name];
  2097. }
  2098. }
  2099. /**
  2100. *
  2101. * @param {number} line The number (starting with 1)
  2102. * @param {number} column The column number (starting with 1)
  2103. */;
  2104. _proto.isAtPosition = function isAtPosition(line, column) {
  2105. if (this.source && this.source.start && this.source.end) {
  2106. if (this.source.start.line > line) {
  2107. return false;
  2108. }
  2109. if (this.source.end.line < line) {
  2110. return false;
  2111. }
  2112. if (this.source.start.line === line && this.source.start.column > column) {
  2113. return false;
  2114. }
  2115. if (this.source.end.line === line && this.source.end.column < column) {
  2116. return false;
  2117. }
  2118. return true;
  2119. }
  2120. return undefined;
  2121. };
  2122. _proto.stringifyProperty = function stringifyProperty(name) {
  2123. return this.raws && this.raws[name] || this[name];
  2124. };
  2125. _proto.valueToString = function valueToString() {
  2126. return String(this.stringifyProperty("value"));
  2127. };
  2128. _proto.toString = function toString() {
  2129. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  2130. };
  2131. _createClass(Node, [{
  2132. key: "rawSpaceBefore",
  2133. get: function get() {
  2134. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  2135. if (rawSpace === undefined) {
  2136. rawSpace = this.spaces && this.spaces.before;
  2137. }
  2138. return rawSpace || "";
  2139. },
  2140. set: function set(raw) {
  2141. (0, _util.ensureObject)(this, "raws", "spaces");
  2142. this.raws.spaces.before = raw;
  2143. }
  2144. }, {
  2145. key: "rawSpaceAfter",
  2146. get: function get() {
  2147. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  2148. if (rawSpace === undefined) {
  2149. rawSpace = this.spaces.after;
  2150. }
  2151. return rawSpace || "";
  2152. },
  2153. set: function set(raw) {
  2154. (0, _util.ensureObject)(this, "raws", "spaces");
  2155. this.raws.spaces.after = raw;
  2156. }
  2157. }]);
  2158. return Node;
  2159. }();
  2160. exports["default"] = Node;
  2161. module.exports = exports.default;
  2162. } (node$1, node$1.exports));
  2163. var nodeExports = node$1.exports;
  2164. var types = {};
  2165. types.__esModule = true;
  2166. 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;
  2167. var TAG = 'tag';
  2168. types.TAG = TAG;
  2169. var STRING = 'string';
  2170. types.STRING = STRING;
  2171. var SELECTOR = 'selector';
  2172. types.SELECTOR = SELECTOR;
  2173. var ROOT = 'root';
  2174. types.ROOT = ROOT;
  2175. var PSEUDO = 'pseudo';
  2176. types.PSEUDO = PSEUDO;
  2177. var NESTING = 'nesting';
  2178. types.NESTING = NESTING;
  2179. var ID = 'id';
  2180. types.ID = ID;
  2181. var COMMENT = 'comment';
  2182. types.COMMENT = COMMENT;
  2183. var COMBINATOR = 'combinator';
  2184. types.COMBINATOR = COMBINATOR;
  2185. var CLASS = 'class';
  2186. types.CLASS = CLASS;
  2187. var ATTRIBUTE = 'attribute';
  2188. types.ATTRIBUTE = ATTRIBUTE;
  2189. var UNIVERSAL = 'universal';
  2190. types.UNIVERSAL = UNIVERSAL;
  2191. (function (module, exports) {
  2192. exports.__esModule = true;
  2193. exports["default"] = void 0;
  2194. var _node = _interopRequireDefault(nodeExports);
  2195. var types$1 = _interopRequireWildcard(types);
  2196. 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); }
  2197. 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; }
  2198. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2199. 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."); }
  2200. 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); }
  2201. 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; }
  2202. 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); } }
  2203. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2204. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2205. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2206. var Container = /*#__PURE__*/function (_Node) {
  2207. _inheritsLoose(Container, _Node);
  2208. function Container(opts) {
  2209. var _this;
  2210. _this = _Node.call(this, opts) || this;
  2211. if (!_this.nodes) {
  2212. _this.nodes = [];
  2213. }
  2214. return _this;
  2215. }
  2216. var _proto = Container.prototype;
  2217. _proto.append = function append(selector) {
  2218. selector.parent = this;
  2219. this.nodes.push(selector);
  2220. return this;
  2221. };
  2222. _proto.prepend = function prepend(selector) {
  2223. selector.parent = this;
  2224. this.nodes.unshift(selector);
  2225. return this;
  2226. };
  2227. _proto.at = function at(index) {
  2228. return this.nodes[index];
  2229. };
  2230. _proto.index = function index(child) {
  2231. if (typeof child === 'number') {
  2232. return child;
  2233. }
  2234. return this.nodes.indexOf(child);
  2235. };
  2236. _proto.removeChild = function removeChild(child) {
  2237. child = this.index(child);
  2238. this.at(child).parent = undefined;
  2239. this.nodes.splice(child, 1);
  2240. var index;
  2241. for (var id in this.indexes) {
  2242. index = this.indexes[id];
  2243. if (index >= child) {
  2244. this.indexes[id] = index - 1;
  2245. }
  2246. }
  2247. return this;
  2248. };
  2249. _proto.removeAll = function removeAll() {
  2250. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  2251. var node = _step.value;
  2252. node.parent = undefined;
  2253. }
  2254. this.nodes = [];
  2255. return this;
  2256. };
  2257. _proto.empty = function empty() {
  2258. return this.removeAll();
  2259. };
  2260. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  2261. newNode.parent = this;
  2262. var oldIndex = this.index(oldNode);
  2263. this.nodes.splice(oldIndex + 1, 0, newNode);
  2264. newNode.parent = this;
  2265. var index;
  2266. for (var id in this.indexes) {
  2267. index = this.indexes[id];
  2268. if (oldIndex <= index) {
  2269. this.indexes[id] = index + 1;
  2270. }
  2271. }
  2272. return this;
  2273. };
  2274. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  2275. newNode.parent = this;
  2276. var oldIndex = this.index(oldNode);
  2277. this.nodes.splice(oldIndex, 0, newNode);
  2278. newNode.parent = this;
  2279. var index;
  2280. for (var id in this.indexes) {
  2281. index = this.indexes[id];
  2282. if (index <= oldIndex) {
  2283. this.indexes[id] = index + 1;
  2284. }
  2285. }
  2286. return this;
  2287. };
  2288. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  2289. var found = undefined;
  2290. this.each(function (node) {
  2291. if (node.atPosition) {
  2292. var foundChild = node.atPosition(line, col);
  2293. if (foundChild) {
  2294. found = foundChild;
  2295. return false;
  2296. }
  2297. } else if (node.isAtPosition(line, col)) {
  2298. found = node;
  2299. return false;
  2300. }
  2301. });
  2302. return found;
  2303. }
  2304. /**
  2305. * Return the most specific node at the line and column number given.
  2306. * The source location is based on the original parsed location, locations aren't
  2307. * updated as selector nodes are mutated.
  2308. *
  2309. * Note that this location is relative to the location of the first character
  2310. * of the selector, and not the location of the selector in the overall document
  2311. * when used in conjunction with postcss.
  2312. *
  2313. * If not found, returns undefined.
  2314. * @param {number} line The line number of the node to find. (1-based index)
  2315. * @param {number} col The column number of the node to find. (1-based index)
  2316. */;
  2317. _proto.atPosition = function atPosition(line, col) {
  2318. if (this.isAtPosition(line, col)) {
  2319. return this._findChildAtPosition(line, col) || this;
  2320. } else {
  2321. return undefined;
  2322. }
  2323. };
  2324. _proto._inferEndPosition = function _inferEndPosition() {
  2325. if (this.last && this.last.source && this.last.source.end) {
  2326. this.source = this.source || {};
  2327. this.source.end = this.source.end || {};
  2328. Object.assign(this.source.end, this.last.source.end);
  2329. }
  2330. };
  2331. _proto.each = function each(callback) {
  2332. if (!this.lastEach) {
  2333. this.lastEach = 0;
  2334. }
  2335. if (!this.indexes) {
  2336. this.indexes = {};
  2337. }
  2338. this.lastEach++;
  2339. var id = this.lastEach;
  2340. this.indexes[id] = 0;
  2341. if (!this.length) {
  2342. return undefined;
  2343. }
  2344. var index, result;
  2345. while (this.indexes[id] < this.length) {
  2346. index = this.indexes[id];
  2347. result = callback(this.at(index), index);
  2348. if (result === false) {
  2349. break;
  2350. }
  2351. this.indexes[id] += 1;
  2352. }
  2353. delete this.indexes[id];
  2354. if (result === false) {
  2355. return false;
  2356. }
  2357. };
  2358. _proto.walk = function walk(callback) {
  2359. return this.each(function (node, i) {
  2360. var result = callback(node, i);
  2361. if (result !== false && node.length) {
  2362. result = node.walk(callback);
  2363. }
  2364. if (result === false) {
  2365. return false;
  2366. }
  2367. });
  2368. };
  2369. _proto.walkAttributes = function walkAttributes(callback) {
  2370. var _this2 = this;
  2371. return this.walk(function (selector) {
  2372. if (selector.type === types$1.ATTRIBUTE) {
  2373. return callback.call(_this2, selector);
  2374. }
  2375. });
  2376. };
  2377. _proto.walkClasses = function walkClasses(callback) {
  2378. var _this3 = this;
  2379. return this.walk(function (selector) {
  2380. if (selector.type === types$1.CLASS) {
  2381. return callback.call(_this3, selector);
  2382. }
  2383. });
  2384. };
  2385. _proto.walkCombinators = function walkCombinators(callback) {
  2386. var _this4 = this;
  2387. return this.walk(function (selector) {
  2388. if (selector.type === types$1.COMBINATOR) {
  2389. return callback.call(_this4, selector);
  2390. }
  2391. });
  2392. };
  2393. _proto.walkComments = function walkComments(callback) {
  2394. var _this5 = this;
  2395. return this.walk(function (selector) {
  2396. if (selector.type === types$1.COMMENT) {
  2397. return callback.call(_this5, selector);
  2398. }
  2399. });
  2400. };
  2401. _proto.walkIds = function walkIds(callback) {
  2402. var _this6 = this;
  2403. return this.walk(function (selector) {
  2404. if (selector.type === types$1.ID) {
  2405. return callback.call(_this6, selector);
  2406. }
  2407. });
  2408. };
  2409. _proto.walkNesting = function walkNesting(callback) {
  2410. var _this7 = this;
  2411. return this.walk(function (selector) {
  2412. if (selector.type === types$1.NESTING) {
  2413. return callback.call(_this7, selector);
  2414. }
  2415. });
  2416. };
  2417. _proto.walkPseudos = function walkPseudos(callback) {
  2418. var _this8 = this;
  2419. return this.walk(function (selector) {
  2420. if (selector.type === types$1.PSEUDO) {
  2421. return callback.call(_this8, selector);
  2422. }
  2423. });
  2424. };
  2425. _proto.walkTags = function walkTags(callback) {
  2426. var _this9 = this;
  2427. return this.walk(function (selector) {
  2428. if (selector.type === types$1.TAG) {
  2429. return callback.call(_this9, selector);
  2430. }
  2431. });
  2432. };
  2433. _proto.walkUniversals = function walkUniversals(callback) {
  2434. var _this10 = this;
  2435. return this.walk(function (selector) {
  2436. if (selector.type === types$1.UNIVERSAL) {
  2437. return callback.call(_this10, selector);
  2438. }
  2439. });
  2440. };
  2441. _proto.split = function split(callback) {
  2442. var _this11 = this;
  2443. var current = [];
  2444. return this.reduce(function (memo, node, index) {
  2445. var split = callback.call(_this11, node);
  2446. current.push(node);
  2447. if (split) {
  2448. memo.push(current);
  2449. current = [];
  2450. } else if (index === _this11.length - 1) {
  2451. memo.push(current);
  2452. }
  2453. return memo;
  2454. }, []);
  2455. };
  2456. _proto.map = function map(callback) {
  2457. return this.nodes.map(callback);
  2458. };
  2459. _proto.reduce = function reduce(callback, memo) {
  2460. return this.nodes.reduce(callback, memo);
  2461. };
  2462. _proto.every = function every(callback) {
  2463. return this.nodes.every(callback);
  2464. };
  2465. _proto.some = function some(callback) {
  2466. return this.nodes.some(callback);
  2467. };
  2468. _proto.filter = function filter(callback) {
  2469. return this.nodes.filter(callback);
  2470. };
  2471. _proto.sort = function sort(callback) {
  2472. return this.nodes.sort(callback);
  2473. };
  2474. _proto.toString = function toString() {
  2475. return this.map(String).join('');
  2476. };
  2477. _createClass(Container, [{
  2478. key: "first",
  2479. get: function get() {
  2480. return this.at(0);
  2481. }
  2482. }, {
  2483. key: "last",
  2484. get: function get() {
  2485. return this.at(this.length - 1);
  2486. }
  2487. }, {
  2488. key: "length",
  2489. get: function get() {
  2490. return this.nodes.length;
  2491. }
  2492. }]);
  2493. return Container;
  2494. }(_node["default"]);
  2495. exports["default"] = Container;
  2496. module.exports = exports.default;
  2497. } (container, container.exports));
  2498. var containerExports = container.exports;
  2499. (function (module, exports) {
  2500. exports.__esModule = true;
  2501. exports["default"] = void 0;
  2502. var _container = _interopRequireDefault(containerExports);
  2503. var _types = types;
  2504. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2505. 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); } }
  2506. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2507. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2508. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2509. var Root = /*#__PURE__*/function (_Container) {
  2510. _inheritsLoose(Root, _Container);
  2511. function Root(opts) {
  2512. var _this;
  2513. _this = _Container.call(this, opts) || this;
  2514. _this.type = _types.ROOT;
  2515. return _this;
  2516. }
  2517. var _proto = Root.prototype;
  2518. _proto.toString = function toString() {
  2519. var str = this.reduce(function (memo, selector) {
  2520. memo.push(String(selector));
  2521. return memo;
  2522. }, []).join(',');
  2523. return this.trailingComma ? str + ',' : str;
  2524. };
  2525. _proto.error = function error(message, options) {
  2526. if (this._error) {
  2527. return this._error(message, options);
  2528. } else {
  2529. return new Error(message);
  2530. }
  2531. };
  2532. _createClass(Root, [{
  2533. key: "errorGenerator",
  2534. set: function set(handler) {
  2535. this._error = handler;
  2536. }
  2537. }]);
  2538. return Root;
  2539. }(_container["default"]);
  2540. exports["default"] = Root;
  2541. module.exports = exports.default;
  2542. } (root$1, root$1.exports));
  2543. var rootExports = root$1.exports;
  2544. var selector$1 = {exports: {}};
  2545. (function (module, exports) {
  2546. exports.__esModule = true;
  2547. exports["default"] = void 0;
  2548. var _container = _interopRequireDefault(containerExports);
  2549. var _types = types;
  2550. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2551. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2552. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2553. var Selector = /*#__PURE__*/function (_Container) {
  2554. _inheritsLoose(Selector, _Container);
  2555. function Selector(opts) {
  2556. var _this;
  2557. _this = _Container.call(this, opts) || this;
  2558. _this.type = _types.SELECTOR;
  2559. return _this;
  2560. }
  2561. return Selector;
  2562. }(_container["default"]);
  2563. exports["default"] = Selector;
  2564. module.exports = exports.default;
  2565. } (selector$1, selector$1.exports));
  2566. var selectorExports = selector$1.exports;
  2567. var className$1 = {exports: {}};
  2568. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  2569. var object = {};
  2570. var hasOwnProperty$1 = object.hasOwnProperty;
  2571. var merge = function merge(options, defaults) {
  2572. if (!options) {
  2573. return defaults;
  2574. }
  2575. var result = {};
  2576. for (var key in defaults) {
  2577. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  2578. // only recognized option names are used.
  2579. result[key] = hasOwnProperty$1.call(options, key) ? options[key] : defaults[key];
  2580. }
  2581. return result;
  2582. };
  2583. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  2584. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  2585. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  2586. // https://mathiasbynens.be/notes/css-escapes#css
  2587. var cssesc = function cssesc(string, options) {
  2588. options = merge(options, cssesc.options);
  2589. if (options.quotes != 'single' && options.quotes != 'double') {
  2590. options.quotes = 'single';
  2591. }
  2592. var quote = options.quotes == 'double' ? '"' : '\'';
  2593. var isIdentifier = options.isIdentifier;
  2594. var firstChar = string.charAt(0);
  2595. var output = '';
  2596. var counter = 0;
  2597. var length = string.length;
  2598. while (counter < length) {
  2599. var character = string.charAt(counter++);
  2600. var codePoint = character.charCodeAt();
  2601. var value = void 0;
  2602. // If it’s not a printable ASCII character…
  2603. if (codePoint < 0x20 || codePoint > 0x7E) {
  2604. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  2605. // It’s a high surrogate, and there is a next character.
  2606. var extra = string.charCodeAt(counter++);
  2607. if ((extra & 0xFC00) == 0xDC00) {
  2608. // next character is low surrogate
  2609. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  2610. } else {
  2611. // It’s an unmatched surrogate; only append this code unit, in case
  2612. // the next code unit is the high surrogate of a surrogate pair.
  2613. counter--;
  2614. }
  2615. }
  2616. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2617. } else {
  2618. if (options.escapeEverything) {
  2619. if (regexAnySingleEscape.test(character)) {
  2620. value = '\\' + character;
  2621. } else {
  2622. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2623. }
  2624. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  2625. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2626. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  2627. value = '\\' + character;
  2628. } else {
  2629. value = character;
  2630. }
  2631. }
  2632. output += value;
  2633. }
  2634. if (isIdentifier) {
  2635. if (/^-[-\d]/.test(output)) {
  2636. output = '\\-' + output.slice(1);
  2637. } else if (/\d/.test(firstChar)) {
  2638. output = '\\3' + firstChar + ' ' + output.slice(1);
  2639. }
  2640. }
  2641. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  2642. // since they’re redundant. Note that this is only possible if the escape
  2643. // sequence isn’t preceded by an odd number of backslashes.
  2644. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  2645. if ($1 && $1.length % 2) {
  2646. // It’s not safe to remove the space, so don’t.
  2647. return $0;
  2648. }
  2649. // Strip the space.
  2650. return ($1 || '') + $2;
  2651. });
  2652. if (!isIdentifier && options.wrap) {
  2653. return quote + output + quote;
  2654. }
  2655. return output;
  2656. };
  2657. // Expose default options (so they can be overridden globally).
  2658. cssesc.options = {
  2659. 'escapeEverything': false,
  2660. 'isIdentifier': false,
  2661. 'quotes': 'single',
  2662. 'wrap': false
  2663. };
  2664. cssesc.version = '3.0.0';
  2665. var cssesc_1 = cssesc;
  2666. (function (module, exports) {
  2667. exports.__esModule = true;
  2668. exports["default"] = void 0;
  2669. var _cssesc = _interopRequireDefault(cssesc_1);
  2670. var _util = util;
  2671. var _node = _interopRequireDefault(nodeExports);
  2672. var _types = types;
  2673. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2674. 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); } }
  2675. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2676. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2677. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2678. var ClassName = /*#__PURE__*/function (_Node) {
  2679. _inheritsLoose(ClassName, _Node);
  2680. function ClassName(opts) {
  2681. var _this;
  2682. _this = _Node.call(this, opts) || this;
  2683. _this.type = _types.CLASS;
  2684. _this._constructed = true;
  2685. return _this;
  2686. }
  2687. var _proto = ClassName.prototype;
  2688. _proto.valueToString = function valueToString() {
  2689. return '.' + _Node.prototype.valueToString.call(this);
  2690. };
  2691. _createClass(ClassName, [{
  2692. key: "value",
  2693. get: function get() {
  2694. return this._value;
  2695. },
  2696. set: function set(v) {
  2697. if (this._constructed) {
  2698. var escaped = (0, _cssesc["default"])(v, {
  2699. isIdentifier: true
  2700. });
  2701. if (escaped !== v) {
  2702. (0, _util.ensureObject)(this, "raws");
  2703. this.raws.value = escaped;
  2704. } else if (this.raws) {
  2705. delete this.raws.value;
  2706. }
  2707. }
  2708. this._value = v;
  2709. }
  2710. }]);
  2711. return ClassName;
  2712. }(_node["default"]);
  2713. exports["default"] = ClassName;
  2714. module.exports = exports.default;
  2715. } (className$1, className$1.exports));
  2716. var classNameExports = className$1.exports;
  2717. var comment$2 = {exports: {}};
  2718. (function (module, exports) {
  2719. exports.__esModule = true;
  2720. exports["default"] = void 0;
  2721. var _node = _interopRequireDefault(nodeExports);
  2722. var _types = types;
  2723. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2724. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2725. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2726. var Comment = /*#__PURE__*/function (_Node) {
  2727. _inheritsLoose(Comment, _Node);
  2728. function Comment(opts) {
  2729. var _this;
  2730. _this = _Node.call(this, opts) || this;
  2731. _this.type = _types.COMMENT;
  2732. return _this;
  2733. }
  2734. return Comment;
  2735. }(_node["default"]);
  2736. exports["default"] = Comment;
  2737. module.exports = exports.default;
  2738. } (comment$2, comment$2.exports));
  2739. var commentExports = comment$2.exports;
  2740. var id$1 = {exports: {}};
  2741. (function (module, exports) {
  2742. exports.__esModule = true;
  2743. exports["default"] = void 0;
  2744. var _node = _interopRequireDefault(nodeExports);
  2745. var _types = types;
  2746. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2747. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2748. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2749. var ID = /*#__PURE__*/function (_Node) {
  2750. _inheritsLoose(ID, _Node);
  2751. function ID(opts) {
  2752. var _this;
  2753. _this = _Node.call(this, opts) || this;
  2754. _this.type = _types.ID;
  2755. return _this;
  2756. }
  2757. var _proto = ID.prototype;
  2758. _proto.valueToString = function valueToString() {
  2759. return '#' + _Node.prototype.valueToString.call(this);
  2760. };
  2761. return ID;
  2762. }(_node["default"]);
  2763. exports["default"] = ID;
  2764. module.exports = exports.default;
  2765. } (id$1, id$1.exports));
  2766. var idExports = id$1.exports;
  2767. var tag$1 = {exports: {}};
  2768. var namespace = {exports: {}};
  2769. (function (module, exports) {
  2770. exports.__esModule = true;
  2771. exports["default"] = void 0;
  2772. var _cssesc = _interopRequireDefault(cssesc_1);
  2773. var _util = util;
  2774. var _node = _interopRequireDefault(nodeExports);
  2775. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2776. 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); } }
  2777. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2778. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2779. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2780. var Namespace = /*#__PURE__*/function (_Node) {
  2781. _inheritsLoose(Namespace, _Node);
  2782. function Namespace() {
  2783. return _Node.apply(this, arguments) || this;
  2784. }
  2785. var _proto = Namespace.prototype;
  2786. _proto.qualifiedName = function qualifiedName(value) {
  2787. if (this.namespace) {
  2788. return this.namespaceString + "|" + value;
  2789. } else {
  2790. return value;
  2791. }
  2792. };
  2793. _proto.valueToString = function valueToString() {
  2794. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  2795. };
  2796. _createClass(Namespace, [{
  2797. key: "namespace",
  2798. get: function get() {
  2799. return this._namespace;
  2800. },
  2801. set: function set(namespace) {
  2802. if (namespace === true || namespace === "*" || namespace === "&") {
  2803. this._namespace = namespace;
  2804. if (this.raws) {
  2805. delete this.raws.namespace;
  2806. }
  2807. return;
  2808. }
  2809. var escaped = (0, _cssesc["default"])(namespace, {
  2810. isIdentifier: true
  2811. });
  2812. this._namespace = namespace;
  2813. if (escaped !== namespace) {
  2814. (0, _util.ensureObject)(this, "raws");
  2815. this.raws.namespace = escaped;
  2816. } else if (this.raws) {
  2817. delete this.raws.namespace;
  2818. }
  2819. }
  2820. }, {
  2821. key: "ns",
  2822. get: function get() {
  2823. return this._namespace;
  2824. },
  2825. set: function set(namespace) {
  2826. this.namespace = namespace;
  2827. }
  2828. }, {
  2829. key: "namespaceString",
  2830. get: function get() {
  2831. if (this.namespace) {
  2832. var ns = this.stringifyProperty("namespace");
  2833. if (ns === true) {
  2834. return '';
  2835. } else {
  2836. return ns;
  2837. }
  2838. } else {
  2839. return '';
  2840. }
  2841. }
  2842. }]);
  2843. return Namespace;
  2844. }(_node["default"]);
  2845. exports["default"] = Namespace;
  2846. module.exports = exports.default;
  2847. } (namespace, namespace.exports));
  2848. var namespaceExports = namespace.exports;
  2849. (function (module, exports) {
  2850. exports.__esModule = true;
  2851. exports["default"] = void 0;
  2852. var _namespace = _interopRequireDefault(namespaceExports);
  2853. var _types = types;
  2854. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2855. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2856. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2857. var Tag = /*#__PURE__*/function (_Namespace) {
  2858. _inheritsLoose(Tag, _Namespace);
  2859. function Tag(opts) {
  2860. var _this;
  2861. _this = _Namespace.call(this, opts) || this;
  2862. _this.type = _types.TAG;
  2863. return _this;
  2864. }
  2865. return Tag;
  2866. }(_namespace["default"]);
  2867. exports["default"] = Tag;
  2868. module.exports = exports.default;
  2869. } (tag$1, tag$1.exports));
  2870. var tagExports = tag$1.exports;
  2871. var string$1 = {exports: {}};
  2872. (function (module, exports) {
  2873. exports.__esModule = true;
  2874. exports["default"] = void 0;
  2875. var _node = _interopRequireDefault(nodeExports);
  2876. var _types = types;
  2877. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2878. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2879. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2880. var String = /*#__PURE__*/function (_Node) {
  2881. _inheritsLoose(String, _Node);
  2882. function String(opts) {
  2883. var _this;
  2884. _this = _Node.call(this, opts) || this;
  2885. _this.type = _types.STRING;
  2886. return _this;
  2887. }
  2888. return String;
  2889. }(_node["default"]);
  2890. exports["default"] = String;
  2891. module.exports = exports.default;
  2892. } (string$1, string$1.exports));
  2893. var stringExports = string$1.exports;
  2894. var pseudo$1 = {exports: {}};
  2895. (function (module, exports) {
  2896. exports.__esModule = true;
  2897. exports["default"] = void 0;
  2898. var _container = _interopRequireDefault(containerExports);
  2899. var _types = types;
  2900. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2901. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2902. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2903. var Pseudo = /*#__PURE__*/function (_Container) {
  2904. _inheritsLoose(Pseudo, _Container);
  2905. function Pseudo(opts) {
  2906. var _this;
  2907. _this = _Container.call(this, opts) || this;
  2908. _this.type = _types.PSEUDO;
  2909. return _this;
  2910. }
  2911. var _proto = Pseudo.prototype;
  2912. _proto.toString = function toString() {
  2913. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  2914. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  2915. };
  2916. return Pseudo;
  2917. }(_container["default"]);
  2918. exports["default"] = Pseudo;
  2919. module.exports = exports.default;
  2920. } (pseudo$1, pseudo$1.exports));
  2921. var pseudoExports = pseudo$1.exports;
  2922. var attribute$1 = {};
  2923. /**
  2924. * For Node.js, simply re-export the core `util.deprecate` function.
  2925. */
  2926. var node = require$$0$2.deprecate;
  2927. (function (exports) {
  2928. exports.__esModule = true;
  2929. exports["default"] = void 0;
  2930. exports.unescapeValue = unescapeValue;
  2931. var _cssesc = _interopRequireDefault(cssesc_1);
  2932. var _unesc = _interopRequireDefault(unescExports);
  2933. var _namespace = _interopRequireDefault(namespaceExports);
  2934. var _types = types;
  2935. var _CSSESC_QUOTE_OPTIONS;
  2936. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2937. 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); } }
  2938. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2939. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2940. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2941. var deprecate = node;
  2942. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  2943. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  2944. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  2945. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  2946. function unescapeValue(value) {
  2947. var deprecatedUsage = false;
  2948. var quoteMark = null;
  2949. var unescaped = value;
  2950. var m = unescaped.match(WRAPPED_IN_QUOTES);
  2951. if (m) {
  2952. quoteMark = m[1];
  2953. unescaped = m[2];
  2954. }
  2955. unescaped = (0, _unesc["default"])(unescaped);
  2956. if (unescaped !== value) {
  2957. deprecatedUsage = true;
  2958. }
  2959. return {
  2960. deprecatedUsage: deprecatedUsage,
  2961. unescaped: unescaped,
  2962. quoteMark: quoteMark
  2963. };
  2964. }
  2965. function handleDeprecatedContructorOpts(opts) {
  2966. if (opts.quoteMark !== undefined) {
  2967. return opts;
  2968. }
  2969. if (opts.value === undefined) {
  2970. return opts;
  2971. }
  2972. warnOfDeprecatedConstructor();
  2973. var _unescapeValue = unescapeValue(opts.value),
  2974. quoteMark = _unescapeValue.quoteMark,
  2975. unescaped = _unescapeValue.unescaped;
  2976. if (!opts.raws) {
  2977. opts.raws = {};
  2978. }
  2979. if (opts.raws.value === undefined) {
  2980. opts.raws.value = opts.value;
  2981. }
  2982. opts.value = unescaped;
  2983. opts.quoteMark = quoteMark;
  2984. return opts;
  2985. }
  2986. var Attribute = /*#__PURE__*/function (_Namespace) {
  2987. _inheritsLoose(Attribute, _Namespace);
  2988. function Attribute(opts) {
  2989. var _this;
  2990. if (opts === void 0) {
  2991. opts = {};
  2992. }
  2993. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  2994. _this.type = _types.ATTRIBUTE;
  2995. _this.raws = _this.raws || {};
  2996. Object.defineProperty(_this.raws, 'unquoted', {
  2997. get: deprecate(function () {
  2998. return _this.value;
  2999. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  3000. set: deprecate(function () {
  3001. return _this.value;
  3002. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  3003. });
  3004. _this._constructed = true;
  3005. return _this;
  3006. }
  3007. /**
  3008. * Returns the Attribute's value quoted such that it would be legal to use
  3009. * in the value of a css file. The original value's quotation setting
  3010. * used for stringification is left unchanged. See `setValue(value, options)`
  3011. * if you want to control the quote settings of a new value for the attribute.
  3012. *
  3013. * You can also change the quotation used for the current value by setting quoteMark.
  3014. *
  3015. * Options:
  3016. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  3017. * option is not set, the original value for quoteMark will be used. If
  3018. * indeterminate, a double quote is used. The legal values are:
  3019. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  3020. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  3021. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  3022. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  3023. * over the quoteMark option value.
  3024. * * smart {boolean} - if true, will select a quote mark based on the value
  3025. * and the other options specified here. See the `smartQuoteMark()`
  3026. * method.
  3027. **/
  3028. var _proto = Attribute.prototype;
  3029. _proto.getQuotedValue = function getQuotedValue(options) {
  3030. if (options === void 0) {
  3031. options = {};
  3032. }
  3033. var quoteMark = this._determineQuoteMark(options);
  3034. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  3035. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  3036. return escaped;
  3037. };
  3038. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  3039. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  3040. }
  3041. /**
  3042. * Set the unescaped value with the specified quotation options. The value
  3043. * provided must not include any wrapping quote marks -- those quotes will
  3044. * be interpreted as part of the value and escaped accordingly.
  3045. */;
  3046. _proto.setValue = function setValue(value, options) {
  3047. if (options === void 0) {
  3048. options = {};
  3049. }
  3050. this._value = value;
  3051. this._quoteMark = this._determineQuoteMark(options);
  3052. this._syncRawValue();
  3053. }
  3054. /**
  3055. * Intelligently select a quoteMark value based on the value's contents. If
  3056. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  3057. * mark will be picked that minimizes the number of escapes.
  3058. *
  3059. * If there's no clear winner, the quote mark from these options is used,
  3060. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  3061. * true). If the quoteMark is unspecified, a double quote is used.
  3062. *
  3063. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  3064. * from the quoteValue method.
  3065. */;
  3066. _proto.smartQuoteMark = function smartQuoteMark(options) {
  3067. var v = this.value;
  3068. var numSingleQuotes = v.replace(/[^']/g, '').length;
  3069. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  3070. if (numSingleQuotes + numDoubleQuotes === 0) {
  3071. var escaped = (0, _cssesc["default"])(v, {
  3072. isIdentifier: true
  3073. });
  3074. if (escaped === v) {
  3075. return Attribute.NO_QUOTE;
  3076. } else {
  3077. var pref = this.preferredQuoteMark(options);
  3078. if (pref === Attribute.NO_QUOTE) {
  3079. // pick a quote mark that isn't none and see if it's smaller
  3080. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  3081. var opts = CSSESC_QUOTE_OPTIONS[quote];
  3082. var quoteValue = (0, _cssesc["default"])(v, opts);
  3083. if (quoteValue.length < escaped.length) {
  3084. return quote;
  3085. }
  3086. }
  3087. return pref;
  3088. }
  3089. } else if (numDoubleQuotes === numSingleQuotes) {
  3090. return this.preferredQuoteMark(options);
  3091. } else if (numDoubleQuotes < numSingleQuotes) {
  3092. return Attribute.DOUBLE_QUOTE;
  3093. } else {
  3094. return Attribute.SINGLE_QUOTE;
  3095. }
  3096. }
  3097. /**
  3098. * Selects the preferred quote mark based on the options and the current quote mark value.
  3099. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  3100. * instead.
  3101. */;
  3102. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  3103. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  3104. if (quoteMark === undefined) {
  3105. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  3106. }
  3107. if (quoteMark === undefined) {
  3108. quoteMark = Attribute.DOUBLE_QUOTE;
  3109. }
  3110. return quoteMark;
  3111. };
  3112. _proto._syncRawValue = function _syncRawValue() {
  3113. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  3114. if (rawValue === this._value) {
  3115. if (this.raws) {
  3116. delete this.raws.value;
  3117. }
  3118. } else {
  3119. this.raws.value = rawValue;
  3120. }
  3121. };
  3122. _proto._handleEscapes = function _handleEscapes(prop, value) {
  3123. if (this._constructed) {
  3124. var escaped = (0, _cssesc["default"])(value, {
  3125. isIdentifier: true
  3126. });
  3127. if (escaped !== value) {
  3128. this.raws[prop] = escaped;
  3129. } else {
  3130. delete this.raws[prop];
  3131. }
  3132. }
  3133. };
  3134. _proto._spacesFor = function _spacesFor(name) {
  3135. var attrSpaces = {
  3136. before: '',
  3137. after: ''
  3138. };
  3139. var spaces = this.spaces[name] || {};
  3140. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  3141. return Object.assign(attrSpaces, spaces, rawSpaces);
  3142. };
  3143. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  3144. if (spaceName === void 0) {
  3145. spaceName = name;
  3146. }
  3147. if (concat === void 0) {
  3148. concat = defaultAttrConcat;
  3149. }
  3150. var attrSpaces = this._spacesFor(spaceName);
  3151. return concat(this.stringifyProperty(name), attrSpaces);
  3152. }
  3153. /**
  3154. * returns the offset of the attribute part specified relative to the
  3155. * start of the node of the output string.
  3156. *
  3157. * * "ns" - alias for "namespace"
  3158. * * "namespace" - the namespace if it exists.
  3159. * * "attribute" - the attribute name
  3160. * * "attributeNS" - the start of the attribute or its namespace
  3161. * * "operator" - the match operator of the attribute
  3162. * * "value" - The value (string or identifier)
  3163. * * "insensitive" - the case insensitivity flag;
  3164. * @param part One of the possible values inside an attribute.
  3165. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  3166. */;
  3167. _proto.offsetOf = function offsetOf(name) {
  3168. var count = 1;
  3169. var attributeSpaces = this._spacesFor("attribute");
  3170. count += attributeSpaces.before.length;
  3171. if (name === "namespace" || name === "ns") {
  3172. return this.namespace ? count : -1;
  3173. }
  3174. if (name === "attributeNS") {
  3175. return count;
  3176. }
  3177. count += this.namespaceString.length;
  3178. if (this.namespace) {
  3179. count += 1;
  3180. }
  3181. if (name === "attribute") {
  3182. return count;
  3183. }
  3184. count += this.stringifyProperty("attribute").length;
  3185. count += attributeSpaces.after.length;
  3186. var operatorSpaces = this._spacesFor("operator");
  3187. count += operatorSpaces.before.length;
  3188. var operator = this.stringifyProperty("operator");
  3189. if (name === "operator") {
  3190. return operator ? count : -1;
  3191. }
  3192. count += operator.length;
  3193. count += operatorSpaces.after.length;
  3194. var valueSpaces = this._spacesFor("value");
  3195. count += valueSpaces.before.length;
  3196. var value = this.stringifyProperty("value");
  3197. if (name === "value") {
  3198. return value ? count : -1;
  3199. }
  3200. count += value.length;
  3201. count += valueSpaces.after.length;
  3202. var insensitiveSpaces = this._spacesFor("insensitive");
  3203. count += insensitiveSpaces.before.length;
  3204. if (name === "insensitive") {
  3205. return this.insensitive ? count : -1;
  3206. }
  3207. return -1;
  3208. };
  3209. _proto.toString = function toString() {
  3210. var _this2 = this;
  3211. var selector = [this.rawSpaceBefore, '['];
  3212. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  3213. if (this.operator && (this.value || this.value === '')) {
  3214. selector.push(this._stringFor('operator'));
  3215. selector.push(this._stringFor('value'));
  3216. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  3217. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  3218. attrSpaces.before = " ";
  3219. }
  3220. return defaultAttrConcat(attrValue, attrSpaces);
  3221. }));
  3222. }
  3223. selector.push(']');
  3224. selector.push(this.rawSpaceAfter);
  3225. return selector.join('');
  3226. };
  3227. _createClass(Attribute, [{
  3228. key: "quoted",
  3229. get: function get() {
  3230. var qm = this.quoteMark;
  3231. return qm === "'" || qm === '"';
  3232. },
  3233. set: function set(value) {
  3234. warnOfDeprecatedQuotedAssignment();
  3235. }
  3236. /**
  3237. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  3238. * returns `null` if the value is not quoted.
  3239. * returns `undefined` if the quotation state is unknown (this can happen when
  3240. * the attribute is constructed without specifying a quote mark.)
  3241. */
  3242. }, {
  3243. key: "quoteMark",
  3244. get: function get() {
  3245. return this._quoteMark;
  3246. }
  3247. /**
  3248. * Set the quote mark to be used by this attribute's value.
  3249. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  3250. * value is updated accordingly.
  3251. *
  3252. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  3253. */,
  3254. set: function set(quoteMark) {
  3255. if (!this._constructed) {
  3256. this._quoteMark = quoteMark;
  3257. return;
  3258. }
  3259. if (this._quoteMark !== quoteMark) {
  3260. this._quoteMark = quoteMark;
  3261. this._syncRawValue();
  3262. }
  3263. }
  3264. }, {
  3265. key: "qualifiedAttribute",
  3266. get: function get() {
  3267. return this.qualifiedName(this.raws.attribute || this.attribute);
  3268. }
  3269. }, {
  3270. key: "insensitiveFlag",
  3271. get: function get() {
  3272. return this.insensitive ? 'i' : '';
  3273. }
  3274. }, {
  3275. key: "value",
  3276. get: function get() {
  3277. return this._value;
  3278. },
  3279. set:
  3280. /**
  3281. * Before 3.0, the value had to be set to an escaped value including any wrapped
  3282. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  3283. * is unescaped during parsing and any quote marks are removed.
  3284. *
  3285. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  3286. * a deprecation warning is raised when the new value contains any characters that would
  3287. * require escaping (including if it contains wrapped quotes).
  3288. *
  3289. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  3290. * how the new value is quoted.
  3291. */
  3292. function set(v) {
  3293. if (this._constructed) {
  3294. var _unescapeValue2 = unescapeValue(v),
  3295. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  3296. unescaped = _unescapeValue2.unescaped,
  3297. quoteMark = _unescapeValue2.quoteMark;
  3298. if (deprecatedUsage) {
  3299. warnOfDeprecatedValueAssignment();
  3300. }
  3301. if (unescaped === this._value && quoteMark === this._quoteMark) {
  3302. return;
  3303. }
  3304. this._value = unescaped;
  3305. this._quoteMark = quoteMark;
  3306. this._syncRawValue();
  3307. } else {
  3308. this._value = v;
  3309. }
  3310. }
  3311. }, {
  3312. key: "insensitive",
  3313. get: function get() {
  3314. return this._insensitive;
  3315. }
  3316. /**
  3317. * Set the case insensitive flag.
  3318. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  3319. * of the attribute is updated accordingly.
  3320. *
  3321. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  3322. */,
  3323. set: function set(insensitive) {
  3324. if (!insensitive) {
  3325. this._insensitive = false;
  3326. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  3327. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  3328. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  3329. this.raws.insensitiveFlag = undefined;
  3330. }
  3331. }
  3332. this._insensitive = insensitive;
  3333. }
  3334. }, {
  3335. key: "attribute",
  3336. get: function get() {
  3337. return this._attribute;
  3338. },
  3339. set: function set(name) {
  3340. this._handleEscapes("attribute", name);
  3341. this._attribute = name;
  3342. }
  3343. }]);
  3344. return Attribute;
  3345. }(_namespace["default"]);
  3346. exports["default"] = Attribute;
  3347. Attribute.NO_QUOTE = null;
  3348. Attribute.SINGLE_QUOTE = "'";
  3349. Attribute.DOUBLE_QUOTE = '"';
  3350. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  3351. "'": {
  3352. quotes: 'single',
  3353. wrap: true
  3354. },
  3355. '"': {
  3356. quotes: 'double',
  3357. wrap: true
  3358. }
  3359. }, _CSSESC_QUOTE_OPTIONS[null] = {
  3360. isIdentifier: true
  3361. }, _CSSESC_QUOTE_OPTIONS);
  3362. function defaultAttrConcat(attrValue, attrSpaces) {
  3363. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  3364. }
  3365. } (attribute$1));
  3366. var universal$1 = {exports: {}};
  3367. (function (module, exports) {
  3368. exports.__esModule = true;
  3369. exports["default"] = void 0;
  3370. var _namespace = _interopRequireDefault(namespaceExports);
  3371. var _types = types;
  3372. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3373. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3374. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3375. var Universal = /*#__PURE__*/function (_Namespace) {
  3376. _inheritsLoose(Universal, _Namespace);
  3377. function Universal(opts) {
  3378. var _this;
  3379. _this = _Namespace.call(this, opts) || this;
  3380. _this.type = _types.UNIVERSAL;
  3381. _this.value = '*';
  3382. return _this;
  3383. }
  3384. return Universal;
  3385. }(_namespace["default"]);
  3386. exports["default"] = Universal;
  3387. module.exports = exports.default;
  3388. } (universal$1, universal$1.exports));
  3389. var universalExports = universal$1.exports;
  3390. var combinator$2 = {exports: {}};
  3391. (function (module, exports) {
  3392. exports.__esModule = true;
  3393. exports["default"] = void 0;
  3394. var _node = _interopRequireDefault(nodeExports);
  3395. var _types = types;
  3396. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3397. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3398. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3399. var Combinator = /*#__PURE__*/function (_Node) {
  3400. _inheritsLoose(Combinator, _Node);
  3401. function Combinator(opts) {
  3402. var _this;
  3403. _this = _Node.call(this, opts) || this;
  3404. _this.type = _types.COMBINATOR;
  3405. return _this;
  3406. }
  3407. return Combinator;
  3408. }(_node["default"]);
  3409. exports["default"] = Combinator;
  3410. module.exports = exports.default;
  3411. } (combinator$2, combinator$2.exports));
  3412. var combinatorExports = combinator$2.exports;
  3413. var nesting$1 = {exports: {}};
  3414. (function (module, exports) {
  3415. exports.__esModule = true;
  3416. exports["default"] = void 0;
  3417. var _node = _interopRequireDefault(nodeExports);
  3418. var _types = types;
  3419. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3420. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3421. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3422. var Nesting = /*#__PURE__*/function (_Node) {
  3423. _inheritsLoose(Nesting, _Node);
  3424. function Nesting(opts) {
  3425. var _this;
  3426. _this = _Node.call(this, opts) || this;
  3427. _this.type = _types.NESTING;
  3428. _this.value = '&';
  3429. return _this;
  3430. }
  3431. return Nesting;
  3432. }(_node["default"]);
  3433. exports["default"] = Nesting;
  3434. module.exports = exports.default;
  3435. } (nesting$1, nesting$1.exports));
  3436. var nestingExports = nesting$1.exports;
  3437. var sortAscending = {exports: {}};
  3438. (function (module, exports) {
  3439. exports.__esModule = true;
  3440. exports["default"] = sortAscending;
  3441. function sortAscending(list) {
  3442. return list.sort(function (a, b) {
  3443. return a - b;
  3444. });
  3445. }
  3446. module.exports = exports.default;
  3447. } (sortAscending, sortAscending.exports));
  3448. var sortAscendingExports = sortAscending.exports;
  3449. var tokenize = {};
  3450. var tokenTypes = {};
  3451. tokenTypes.__esModule = true;
  3452. 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;
  3453. var ampersand = 38; // `&`.charCodeAt(0);
  3454. tokenTypes.ampersand = ampersand;
  3455. var asterisk = 42; // `*`.charCodeAt(0);
  3456. tokenTypes.asterisk = asterisk;
  3457. var at = 64; // `@`.charCodeAt(0);
  3458. tokenTypes.at = at;
  3459. var comma = 44; // `,`.charCodeAt(0);
  3460. tokenTypes.comma = comma;
  3461. var colon = 58; // `:`.charCodeAt(0);
  3462. tokenTypes.colon = colon;
  3463. var semicolon = 59; // `;`.charCodeAt(0);
  3464. tokenTypes.semicolon = semicolon;
  3465. var openParenthesis = 40; // `(`.charCodeAt(0);
  3466. tokenTypes.openParenthesis = openParenthesis;
  3467. var closeParenthesis = 41; // `)`.charCodeAt(0);
  3468. tokenTypes.closeParenthesis = closeParenthesis;
  3469. var openSquare = 91; // `[`.charCodeAt(0);
  3470. tokenTypes.openSquare = openSquare;
  3471. var closeSquare = 93; // `]`.charCodeAt(0);
  3472. tokenTypes.closeSquare = closeSquare;
  3473. var dollar = 36; // `$`.charCodeAt(0);
  3474. tokenTypes.dollar = dollar;
  3475. var tilde = 126; // `~`.charCodeAt(0);
  3476. tokenTypes.tilde = tilde;
  3477. var caret = 94; // `^`.charCodeAt(0);
  3478. tokenTypes.caret = caret;
  3479. var plus = 43; // `+`.charCodeAt(0);
  3480. tokenTypes.plus = plus;
  3481. var equals = 61; // `=`.charCodeAt(0);
  3482. tokenTypes.equals = equals;
  3483. var pipe = 124; // `|`.charCodeAt(0);
  3484. tokenTypes.pipe = pipe;
  3485. var greaterThan = 62; // `>`.charCodeAt(0);
  3486. tokenTypes.greaterThan = greaterThan;
  3487. var space = 32; // ` `.charCodeAt(0);
  3488. tokenTypes.space = space;
  3489. var singleQuote = 39; // `'`.charCodeAt(0);
  3490. tokenTypes.singleQuote = singleQuote;
  3491. var doubleQuote = 34; // `"`.charCodeAt(0);
  3492. tokenTypes.doubleQuote = doubleQuote;
  3493. var slash = 47; // `/`.charCodeAt(0);
  3494. tokenTypes.slash = slash;
  3495. var bang = 33; // `!`.charCodeAt(0);
  3496. tokenTypes.bang = bang;
  3497. var backslash = 92; // '\\'.charCodeAt(0);
  3498. tokenTypes.backslash = backslash;
  3499. var cr = 13; // '\r'.charCodeAt(0);
  3500. tokenTypes.cr = cr;
  3501. var feed = 12; // '\f'.charCodeAt(0);
  3502. tokenTypes.feed = feed;
  3503. var newline = 10; // '\n'.charCodeAt(0);
  3504. tokenTypes.newline = newline;
  3505. var tab = 9; // '\t'.charCodeAt(0);
  3506. // Expose aliases primarily for readability.
  3507. tokenTypes.tab = tab;
  3508. var str = singleQuote;
  3509. // No good single character representation!
  3510. tokenTypes.str = str;
  3511. var comment$1 = -1;
  3512. tokenTypes.comment = comment$1;
  3513. var word = -2;
  3514. tokenTypes.word = word;
  3515. var combinator$1 = -3;
  3516. tokenTypes.combinator = combinator$1;
  3517. (function (exports) {
  3518. exports.__esModule = true;
  3519. exports.FIELDS = void 0;
  3520. exports["default"] = tokenize;
  3521. var t = _interopRequireWildcard(tokenTypes);
  3522. var _unescapable, _wordDelimiters;
  3523. 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); }
  3524. 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; }
  3525. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  3526. 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);
  3527. var hex = {};
  3528. var hexChars = "0123456789abcdefABCDEF";
  3529. for (var i = 0; i < hexChars.length; i++) {
  3530. hex[hexChars.charCodeAt(i)] = true;
  3531. }
  3532. /**
  3533. * Returns the last index of the bar css word
  3534. * @param {string} css The string in which the word begins
  3535. * @param {number} start The index into the string where word's first letter occurs
  3536. */
  3537. function consumeWord(css, start) {
  3538. var next = start;
  3539. var code;
  3540. do {
  3541. code = css.charCodeAt(next);
  3542. if (wordDelimiters[code]) {
  3543. return next - 1;
  3544. } else if (code === t.backslash) {
  3545. next = consumeEscape(css, next) + 1;
  3546. } else {
  3547. // All other characters are part of the word
  3548. next++;
  3549. }
  3550. } while (next < css.length);
  3551. return next - 1;
  3552. }
  3553. /**
  3554. * Returns the last index of the escape sequence
  3555. * @param {string} css The string in which the sequence begins
  3556. * @param {number} start The index into the string where escape character (`\`) occurs.
  3557. */
  3558. function consumeEscape(css, start) {
  3559. var next = start;
  3560. var code = css.charCodeAt(next + 1);
  3561. if (unescapable[code]) ; else if (hex[code]) {
  3562. var hexDigits = 0;
  3563. // consume up to 6 hex chars
  3564. do {
  3565. next++;
  3566. hexDigits++;
  3567. code = css.charCodeAt(next + 1);
  3568. } while (hex[code] && hexDigits < 6);
  3569. // if fewer than 6 hex chars, a trailing space ends the escape
  3570. if (hexDigits < 6 && code === t.space) {
  3571. next++;
  3572. }
  3573. } else {
  3574. // the next char is part of the current word
  3575. next++;
  3576. }
  3577. return next;
  3578. }
  3579. var FIELDS = {
  3580. TYPE: 0,
  3581. START_LINE: 1,
  3582. START_COL: 2,
  3583. END_LINE: 3,
  3584. END_COL: 4,
  3585. START_POS: 5,
  3586. END_POS: 6
  3587. };
  3588. exports.FIELDS = FIELDS;
  3589. function tokenize(input) {
  3590. var tokens = [];
  3591. var css = input.css.valueOf();
  3592. var _css = css,
  3593. length = _css.length;
  3594. var offset = -1;
  3595. var line = 1;
  3596. var start = 0;
  3597. var end = 0;
  3598. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  3599. function unclosed(what, fix) {
  3600. if (input.safe) {
  3601. // fyi: this is never set to true.
  3602. css += fix;
  3603. next = css.length - 1;
  3604. } else {
  3605. throw input.error('Unclosed ' + what, line, start - offset, start);
  3606. }
  3607. }
  3608. while (start < length) {
  3609. code = css.charCodeAt(start);
  3610. if (code === t.newline) {
  3611. offset = start;
  3612. line += 1;
  3613. }
  3614. switch (code) {
  3615. case t.space:
  3616. case t.tab:
  3617. case t.newline:
  3618. case t.cr:
  3619. case t.feed:
  3620. next = start;
  3621. do {
  3622. next += 1;
  3623. code = css.charCodeAt(next);
  3624. if (code === t.newline) {
  3625. offset = next;
  3626. line += 1;
  3627. }
  3628. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  3629. tokenType = t.space;
  3630. endLine = line;
  3631. endColumn = next - offset - 1;
  3632. end = next;
  3633. break;
  3634. case t.plus:
  3635. case t.greaterThan:
  3636. case t.tilde:
  3637. case t.pipe:
  3638. next = start;
  3639. do {
  3640. next += 1;
  3641. code = css.charCodeAt(next);
  3642. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  3643. tokenType = t.combinator;
  3644. endLine = line;
  3645. endColumn = start - offset;
  3646. end = next;
  3647. break;
  3648. // Consume these characters as single tokens.
  3649. case t.asterisk:
  3650. case t.ampersand:
  3651. case t.bang:
  3652. case t.comma:
  3653. case t.equals:
  3654. case t.dollar:
  3655. case t.caret:
  3656. case t.openSquare:
  3657. case t.closeSquare:
  3658. case t.colon:
  3659. case t.semicolon:
  3660. case t.openParenthesis:
  3661. case t.closeParenthesis:
  3662. next = start;
  3663. tokenType = code;
  3664. endLine = line;
  3665. endColumn = start - offset;
  3666. end = next + 1;
  3667. break;
  3668. case t.singleQuote:
  3669. case t.doubleQuote:
  3670. quote = code === t.singleQuote ? "'" : '"';
  3671. next = start;
  3672. do {
  3673. escaped = false;
  3674. next = css.indexOf(quote, next + 1);
  3675. if (next === -1) {
  3676. unclosed('quote', quote);
  3677. }
  3678. escapePos = next;
  3679. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  3680. escapePos -= 1;
  3681. escaped = !escaped;
  3682. }
  3683. } while (escaped);
  3684. tokenType = t.str;
  3685. endLine = line;
  3686. endColumn = start - offset;
  3687. end = next + 1;
  3688. break;
  3689. default:
  3690. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  3691. next = css.indexOf('*/', start + 2) + 1;
  3692. if (next === 0) {
  3693. unclosed('comment', '*/');
  3694. }
  3695. content = css.slice(start, next + 1);
  3696. lines = content.split('\n');
  3697. last = lines.length - 1;
  3698. if (last > 0) {
  3699. nextLine = line + last;
  3700. nextOffset = next - lines[last].length;
  3701. } else {
  3702. nextLine = line;
  3703. nextOffset = offset;
  3704. }
  3705. tokenType = t.comment;
  3706. line = nextLine;
  3707. endLine = nextLine;
  3708. endColumn = next - nextOffset;
  3709. } else if (code === t.slash) {
  3710. next = start;
  3711. tokenType = code;
  3712. endLine = line;
  3713. endColumn = start - offset;
  3714. end = next + 1;
  3715. } else {
  3716. next = consumeWord(css, start);
  3717. tokenType = t.word;
  3718. endLine = line;
  3719. endColumn = next - offset;
  3720. }
  3721. end = next + 1;
  3722. break;
  3723. }
  3724. // Ensure that the token structure remains consistent
  3725. tokens.push([tokenType,
  3726. // [0] Token type
  3727. line,
  3728. // [1] Starting line
  3729. start - offset,
  3730. // [2] Starting column
  3731. endLine,
  3732. // [3] Ending line
  3733. endColumn,
  3734. // [4] Ending column
  3735. start,
  3736. // [5] Start position / Source index
  3737. end // [6] End position
  3738. ]);
  3739. // Reset offset for the next token
  3740. if (nextOffset) {
  3741. offset = nextOffset;
  3742. nextOffset = null;
  3743. }
  3744. start = end;
  3745. }
  3746. return tokens;
  3747. }
  3748. } (tokenize));
  3749. (function (module, exports) {
  3750. exports.__esModule = true;
  3751. exports["default"] = void 0;
  3752. var _root = _interopRequireDefault(rootExports);
  3753. var _selector = _interopRequireDefault(selectorExports);
  3754. var _className = _interopRequireDefault(classNameExports);
  3755. var _comment = _interopRequireDefault(commentExports);
  3756. var _id = _interopRequireDefault(idExports);
  3757. var _tag = _interopRequireDefault(tagExports);
  3758. var _string = _interopRequireDefault(stringExports);
  3759. var _pseudo = _interopRequireDefault(pseudoExports);
  3760. var _attribute = _interopRequireWildcard(attribute$1);
  3761. var _universal = _interopRequireDefault(universalExports);
  3762. var _combinator = _interopRequireDefault(combinatorExports);
  3763. var _nesting = _interopRequireDefault(nestingExports);
  3764. var _sortAscending = _interopRequireDefault(sortAscendingExports);
  3765. var _tokenize = _interopRequireWildcard(tokenize);
  3766. var tokens = _interopRequireWildcard(tokenTypes);
  3767. var types$1 = _interopRequireWildcard(types);
  3768. var _util = util;
  3769. var _WHITESPACE_TOKENS, _Object$assign;
  3770. 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); }
  3771. 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; }
  3772. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3773. 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); } }
  3774. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3775. 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);
  3776. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  3777. function tokenStart(token) {
  3778. return {
  3779. line: token[_tokenize.FIELDS.START_LINE],
  3780. column: token[_tokenize.FIELDS.START_COL]
  3781. };
  3782. }
  3783. function tokenEnd(token) {
  3784. return {
  3785. line: token[_tokenize.FIELDS.END_LINE],
  3786. column: token[_tokenize.FIELDS.END_COL]
  3787. };
  3788. }
  3789. function getSource(startLine, startColumn, endLine, endColumn) {
  3790. return {
  3791. start: {
  3792. line: startLine,
  3793. column: startColumn
  3794. },
  3795. end: {
  3796. line: endLine,
  3797. column: endColumn
  3798. }
  3799. };
  3800. }
  3801. function getTokenSource(token) {
  3802. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  3803. }
  3804. function getTokenSourceSpan(startToken, endToken) {
  3805. if (!startToken) {
  3806. return undefined;
  3807. }
  3808. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  3809. }
  3810. function unescapeProp(node, prop) {
  3811. var value = node[prop];
  3812. if (typeof value !== "string") {
  3813. return;
  3814. }
  3815. if (value.indexOf("\\") !== -1) {
  3816. (0, _util.ensureObject)(node, 'raws');
  3817. node[prop] = (0, _util.unesc)(value);
  3818. if (node.raws[prop] === undefined) {
  3819. node.raws[prop] = value;
  3820. }
  3821. }
  3822. return node;
  3823. }
  3824. function indexesOf(array, item) {
  3825. var i = -1;
  3826. var indexes = [];
  3827. while ((i = array.indexOf(item, i + 1)) !== -1) {
  3828. indexes.push(i);
  3829. }
  3830. return indexes;
  3831. }
  3832. function uniqs() {
  3833. var list = Array.prototype.concat.apply([], arguments);
  3834. return list.filter(function (item, i) {
  3835. return i === list.indexOf(item);
  3836. });
  3837. }
  3838. var Parser = /*#__PURE__*/function () {
  3839. function Parser(rule, options) {
  3840. if (options === void 0) {
  3841. options = {};
  3842. }
  3843. this.rule = rule;
  3844. this.options = Object.assign({
  3845. lossy: false,
  3846. safe: false
  3847. }, options);
  3848. this.position = 0;
  3849. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  3850. this.tokens = (0, _tokenize["default"])({
  3851. css: this.css,
  3852. error: this._errorGenerator(),
  3853. safe: this.options.safe
  3854. });
  3855. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  3856. this.root = new _root["default"]({
  3857. source: rootSource
  3858. });
  3859. this.root.errorGenerator = this._errorGenerator();
  3860. var selector = new _selector["default"]({
  3861. source: {
  3862. start: {
  3863. line: 1,
  3864. column: 1
  3865. }
  3866. },
  3867. sourceIndex: 0
  3868. });
  3869. this.root.append(selector);
  3870. this.current = selector;
  3871. this.loop();
  3872. }
  3873. var _proto = Parser.prototype;
  3874. _proto._errorGenerator = function _errorGenerator() {
  3875. var _this = this;
  3876. return function (message, errorOptions) {
  3877. if (typeof _this.rule === 'string') {
  3878. return new Error(message);
  3879. }
  3880. return _this.rule.error(message, errorOptions);
  3881. };
  3882. };
  3883. _proto.attribute = function attribute() {
  3884. var attr = [];
  3885. var startingToken = this.currToken;
  3886. this.position++;
  3887. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  3888. attr.push(this.currToken);
  3889. this.position++;
  3890. }
  3891. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  3892. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  3893. }
  3894. var len = attr.length;
  3895. var node = {
  3896. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  3897. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  3898. };
  3899. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  3900. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  3901. }
  3902. var pos = 0;
  3903. var spaceBefore = '';
  3904. var commentBefore = '';
  3905. var lastAdded = null;
  3906. var spaceAfterMeaningfulToken = false;
  3907. while (pos < len) {
  3908. var token = attr[pos];
  3909. var content = this.content(token);
  3910. var next = attr[pos + 1];
  3911. switch (token[_tokenize.FIELDS.TYPE]) {
  3912. case tokens.space:
  3913. // if (
  3914. // len === 1 ||
  3915. // pos === 0 && this.content(next) === '|'
  3916. // ) {
  3917. // return this.expected('attribute', token[TOKEN.START_POS], content);
  3918. // }
  3919. spaceAfterMeaningfulToken = true;
  3920. if (this.options.lossy) {
  3921. break;
  3922. }
  3923. if (lastAdded) {
  3924. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  3925. var prevContent = node.spaces[lastAdded].after || '';
  3926. node.spaces[lastAdded].after = prevContent + content;
  3927. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  3928. if (existingComment) {
  3929. node.raws.spaces[lastAdded].after = existingComment + content;
  3930. }
  3931. } else {
  3932. spaceBefore = spaceBefore + content;
  3933. commentBefore = commentBefore + content;
  3934. }
  3935. break;
  3936. case tokens.asterisk:
  3937. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3938. node.operator = content;
  3939. lastAdded = 'operator';
  3940. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  3941. if (spaceBefore) {
  3942. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  3943. node.spaces.attribute.before = spaceBefore;
  3944. spaceBefore = '';
  3945. }
  3946. if (commentBefore) {
  3947. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  3948. node.raws.spaces.attribute.before = spaceBefore;
  3949. commentBefore = '';
  3950. }
  3951. node.namespace = (node.namespace || "") + content;
  3952. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  3953. if (rawValue) {
  3954. node.raws.namespace += content;
  3955. }
  3956. lastAdded = 'namespace';
  3957. }
  3958. spaceAfterMeaningfulToken = false;
  3959. break;
  3960. case tokens.dollar:
  3961. if (lastAdded === "value") {
  3962. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  3963. node.value += "$";
  3964. if (oldRawValue) {
  3965. node.raws.value = oldRawValue + "$";
  3966. }
  3967. break;
  3968. }
  3969. // Falls through
  3970. case tokens.caret:
  3971. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3972. node.operator = content;
  3973. lastAdded = 'operator';
  3974. }
  3975. spaceAfterMeaningfulToken = false;
  3976. break;
  3977. case tokens.combinator:
  3978. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3979. node.operator = content;
  3980. lastAdded = 'operator';
  3981. }
  3982. if (content !== '|') {
  3983. spaceAfterMeaningfulToken = false;
  3984. break;
  3985. }
  3986. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3987. node.operator = content;
  3988. lastAdded = 'operator';
  3989. } else if (!node.namespace && !node.attribute) {
  3990. node.namespace = true;
  3991. }
  3992. spaceAfterMeaningfulToken = false;
  3993. break;
  3994. case tokens.word:
  3995. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  3996. // this look-ahead probably fails with comment nodes involved.
  3997. !node.operator && !node.namespace) {
  3998. node.namespace = content;
  3999. lastAdded = 'namespace';
  4000. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  4001. if (spaceBefore) {
  4002. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  4003. node.spaces.attribute.before = spaceBefore;
  4004. spaceBefore = '';
  4005. }
  4006. if (commentBefore) {
  4007. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  4008. node.raws.spaces.attribute.before = commentBefore;
  4009. commentBefore = '';
  4010. }
  4011. node.attribute = (node.attribute || "") + content;
  4012. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  4013. if (_rawValue) {
  4014. node.raws.attribute += content;
  4015. }
  4016. lastAdded = 'attribute';
  4017. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  4018. var _unescaped = (0, _util.unesc)(content);
  4019. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  4020. var oldValue = node.value || '';
  4021. node.value = oldValue + _unescaped;
  4022. node.quoteMark = null;
  4023. if (_unescaped !== content || _oldRawValue) {
  4024. (0, _util.ensureObject)(node, 'raws');
  4025. node.raws.value = (_oldRawValue || oldValue) + content;
  4026. }
  4027. lastAdded = 'value';
  4028. } else {
  4029. var insensitive = content === 'i' || content === "I";
  4030. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  4031. node.insensitive = insensitive;
  4032. if (!insensitive || content === "I") {
  4033. (0, _util.ensureObject)(node, 'raws');
  4034. node.raws.insensitiveFlag = content;
  4035. }
  4036. lastAdded = 'insensitive';
  4037. if (spaceBefore) {
  4038. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  4039. node.spaces.insensitive.before = spaceBefore;
  4040. spaceBefore = '';
  4041. }
  4042. if (commentBefore) {
  4043. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  4044. node.raws.spaces.insensitive.before = commentBefore;
  4045. commentBefore = '';
  4046. }
  4047. } else if (node.value || node.value === '') {
  4048. lastAdded = 'value';
  4049. node.value += content;
  4050. if (node.raws.value) {
  4051. node.raws.value += content;
  4052. }
  4053. }
  4054. }
  4055. spaceAfterMeaningfulToken = false;
  4056. break;
  4057. case tokens.str:
  4058. if (!node.attribute || !node.operator) {
  4059. return this.error("Expected an attribute followed by an operator preceding the string.", {
  4060. index: token[_tokenize.FIELDS.START_POS]
  4061. });
  4062. }
  4063. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  4064. unescaped = _unescapeValue.unescaped,
  4065. quoteMark = _unescapeValue.quoteMark;
  4066. node.value = unescaped;
  4067. node.quoteMark = quoteMark;
  4068. lastAdded = 'value';
  4069. (0, _util.ensureObject)(node, 'raws');
  4070. node.raws.value = content;
  4071. spaceAfterMeaningfulToken = false;
  4072. break;
  4073. case tokens.equals:
  4074. if (!node.attribute) {
  4075. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  4076. }
  4077. if (node.value) {
  4078. return this.error('Unexpected "=" found; an operator was already defined.', {
  4079. index: token[_tokenize.FIELDS.START_POS]
  4080. });
  4081. }
  4082. node.operator = node.operator ? node.operator + content : content;
  4083. lastAdded = 'operator';
  4084. spaceAfterMeaningfulToken = false;
  4085. break;
  4086. case tokens.comment:
  4087. if (lastAdded) {
  4088. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  4089. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  4090. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  4091. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  4092. node.raws.spaces[lastAdded].after = rawLastComment + content;
  4093. } else {
  4094. var lastValue = node[lastAdded] || '';
  4095. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  4096. (0, _util.ensureObject)(node, 'raws');
  4097. node.raws[lastAdded] = rawLastValue + content;
  4098. }
  4099. } else {
  4100. commentBefore = commentBefore + content;
  4101. }
  4102. break;
  4103. default:
  4104. return this.error("Unexpected \"" + content + "\" found.", {
  4105. index: token[_tokenize.FIELDS.START_POS]
  4106. });
  4107. }
  4108. pos++;
  4109. }
  4110. unescapeProp(node, "attribute");
  4111. unescapeProp(node, "namespace");
  4112. this.newNode(new _attribute["default"](node));
  4113. this.position++;
  4114. }
  4115. /**
  4116. * return a node containing meaningless garbage up to (but not including) the specified token position.
  4117. * if the token position is negative, all remaining tokens are consumed.
  4118. *
  4119. * This returns an array containing a single string node if all whitespace,
  4120. * otherwise an array of comment nodes with space before and after.
  4121. *
  4122. * These tokens are not added to the current selector, the caller can add them or use them to amend
  4123. * a previous node's space metadata.
  4124. *
  4125. * In lossy mode, this returns only comments.
  4126. */;
  4127. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  4128. if (stopPosition < 0) {
  4129. stopPosition = this.tokens.length;
  4130. }
  4131. var startPosition = this.position;
  4132. var nodes = [];
  4133. var space = "";
  4134. var lastComment = undefined;
  4135. do {
  4136. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  4137. if (!this.options.lossy) {
  4138. space += this.content();
  4139. }
  4140. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  4141. var spaces = {};
  4142. if (space) {
  4143. spaces.before = space;
  4144. space = "";
  4145. }
  4146. lastComment = new _comment["default"]({
  4147. value: this.content(),
  4148. source: getTokenSource(this.currToken),
  4149. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  4150. spaces: spaces
  4151. });
  4152. nodes.push(lastComment);
  4153. }
  4154. } while (++this.position < stopPosition);
  4155. if (space) {
  4156. if (lastComment) {
  4157. lastComment.spaces.after = space;
  4158. } else if (!this.options.lossy) {
  4159. var firstToken = this.tokens[startPosition];
  4160. var lastToken = this.tokens[this.position - 1];
  4161. nodes.push(new _string["default"]({
  4162. value: '',
  4163. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  4164. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  4165. spaces: {
  4166. before: space,
  4167. after: ''
  4168. }
  4169. }));
  4170. }
  4171. }
  4172. return nodes;
  4173. }
  4174. /**
  4175. *
  4176. * @param {*} nodes
  4177. */;
  4178. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  4179. var _this2 = this;
  4180. if (requiredSpace === void 0) {
  4181. requiredSpace = false;
  4182. }
  4183. var space = "";
  4184. var rawSpace = "";
  4185. nodes.forEach(function (n) {
  4186. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  4187. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  4188. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  4189. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  4190. });
  4191. if (rawSpace === space) {
  4192. rawSpace = undefined;
  4193. }
  4194. var result = {
  4195. space: space,
  4196. rawSpace: rawSpace
  4197. };
  4198. return result;
  4199. };
  4200. _proto.isNamedCombinator = function isNamedCombinator(position) {
  4201. if (position === void 0) {
  4202. position = this.position;
  4203. }
  4204. 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;
  4205. };
  4206. _proto.namedCombinator = function namedCombinator() {
  4207. if (this.isNamedCombinator()) {
  4208. var nameRaw = this.content(this.tokens[this.position + 1]);
  4209. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  4210. var raws = {};
  4211. if (name !== nameRaw) {
  4212. raws.value = "/" + nameRaw + "/";
  4213. }
  4214. var node = new _combinator["default"]({
  4215. value: "/" + name + "/",
  4216. 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]),
  4217. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  4218. raws: raws
  4219. });
  4220. this.position = this.position + 3;
  4221. return node;
  4222. } else {
  4223. this.unexpected();
  4224. }
  4225. };
  4226. _proto.combinator = function combinator() {
  4227. var _this3 = this;
  4228. if (this.content() === '|') {
  4229. return this.namespace();
  4230. }
  4231. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  4232. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  4233. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  4234. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  4235. if (nodes.length > 0) {
  4236. var last = this.current.last;
  4237. if (last) {
  4238. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  4239. space = _this$convertWhitespa.space,
  4240. rawSpace = _this$convertWhitespa.rawSpace;
  4241. if (rawSpace !== undefined) {
  4242. last.rawSpaceAfter += rawSpace;
  4243. }
  4244. last.spaces.after += space;
  4245. } else {
  4246. nodes.forEach(function (n) {
  4247. return _this3.newNode(n);
  4248. });
  4249. }
  4250. }
  4251. return;
  4252. }
  4253. var firstToken = this.currToken;
  4254. var spaceOrDescendantSelectorNodes = undefined;
  4255. if (nextSigTokenPos > this.position) {
  4256. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  4257. }
  4258. var node;
  4259. if (this.isNamedCombinator()) {
  4260. node = this.namedCombinator();
  4261. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  4262. node = new _combinator["default"]({
  4263. value: this.content(),
  4264. source: getTokenSource(this.currToken),
  4265. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  4266. });
  4267. this.position++;
  4268. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  4269. this.unexpected();
  4270. }
  4271. if (node) {
  4272. if (spaceOrDescendantSelectorNodes) {
  4273. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  4274. _space = _this$convertWhitespa2.space,
  4275. _rawSpace = _this$convertWhitespa2.rawSpace;
  4276. node.spaces.before = _space;
  4277. node.rawSpaceBefore = _rawSpace;
  4278. }
  4279. } else {
  4280. // descendant combinator
  4281. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  4282. _space2 = _this$convertWhitespa3.space,
  4283. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  4284. if (!_rawSpace2) {
  4285. _rawSpace2 = _space2;
  4286. }
  4287. var spaces = {};
  4288. var raws = {
  4289. spaces: {}
  4290. };
  4291. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  4292. spaces.before = _space2.slice(0, _space2.length - 1);
  4293. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  4294. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  4295. spaces.after = _space2.slice(1);
  4296. raws.spaces.after = _rawSpace2.slice(1);
  4297. } else {
  4298. raws.value = _rawSpace2;
  4299. }
  4300. node = new _combinator["default"]({
  4301. value: ' ',
  4302. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  4303. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  4304. spaces: spaces,
  4305. raws: raws
  4306. });
  4307. }
  4308. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  4309. node.spaces.after = this.optionalSpace(this.content());
  4310. this.position++;
  4311. }
  4312. return this.newNode(node);
  4313. };
  4314. _proto.comma = function comma() {
  4315. if (this.position === this.tokens.length - 1) {
  4316. this.root.trailingComma = true;
  4317. this.position++;
  4318. return;
  4319. }
  4320. this.current._inferEndPosition();
  4321. var selector = new _selector["default"]({
  4322. source: {
  4323. start: tokenStart(this.tokens[this.position + 1])
  4324. },
  4325. sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
  4326. });
  4327. this.current.parent.append(selector);
  4328. this.current = selector;
  4329. this.position++;
  4330. };
  4331. _proto.comment = function comment() {
  4332. var current = this.currToken;
  4333. this.newNode(new _comment["default"]({
  4334. value: this.content(),
  4335. source: getTokenSource(current),
  4336. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4337. }));
  4338. this.position++;
  4339. };
  4340. _proto.error = function error(message, opts) {
  4341. throw this.root.error(message, opts);
  4342. };
  4343. _proto.missingBackslash = function missingBackslash() {
  4344. return this.error('Expected a backslash preceding the semicolon.', {
  4345. index: this.currToken[_tokenize.FIELDS.START_POS]
  4346. });
  4347. };
  4348. _proto.missingParenthesis = function missingParenthesis() {
  4349. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  4350. };
  4351. _proto.missingSquareBracket = function missingSquareBracket() {
  4352. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  4353. };
  4354. _proto.unexpected = function unexpected() {
  4355. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  4356. };
  4357. _proto.unexpectedPipe = function unexpectedPipe() {
  4358. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  4359. };
  4360. _proto.namespace = function namespace() {
  4361. var before = this.prevToken && this.content(this.prevToken) || true;
  4362. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  4363. this.position++;
  4364. return this.word(before);
  4365. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  4366. this.position++;
  4367. return this.universal(before);
  4368. }
  4369. this.unexpectedPipe();
  4370. };
  4371. _proto.nesting = function nesting() {
  4372. if (this.nextToken) {
  4373. var nextContent = this.content(this.nextToken);
  4374. if (nextContent === "|") {
  4375. this.position++;
  4376. return;
  4377. }
  4378. }
  4379. var current = this.currToken;
  4380. this.newNode(new _nesting["default"]({
  4381. value: this.content(),
  4382. source: getTokenSource(current),
  4383. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4384. }));
  4385. this.position++;
  4386. };
  4387. _proto.parentheses = function parentheses() {
  4388. var last = this.current.last;
  4389. var unbalanced = 1;
  4390. this.position++;
  4391. if (last && last.type === types$1.PSEUDO) {
  4392. var selector = new _selector["default"]({
  4393. source: {
  4394. start: tokenStart(this.tokens[this.position])
  4395. },
  4396. sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
  4397. });
  4398. var cache = this.current;
  4399. last.append(selector);
  4400. this.current = selector;
  4401. while (this.position < this.tokens.length && unbalanced) {
  4402. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4403. unbalanced++;
  4404. }
  4405. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4406. unbalanced--;
  4407. }
  4408. if (unbalanced) {
  4409. this.parse();
  4410. } else {
  4411. this.current.source.end = tokenEnd(this.currToken);
  4412. this.current.parent.source.end = tokenEnd(this.currToken);
  4413. this.position++;
  4414. }
  4415. }
  4416. this.current = cache;
  4417. } else {
  4418. // I think this case should be an error. It's used to implement a basic parse of media queries
  4419. // but I don't think it's a good idea.
  4420. var parenStart = this.currToken;
  4421. var parenValue = "(";
  4422. var parenEnd;
  4423. while (this.position < this.tokens.length && unbalanced) {
  4424. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4425. unbalanced++;
  4426. }
  4427. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4428. unbalanced--;
  4429. }
  4430. parenEnd = this.currToken;
  4431. parenValue += this.parseParenthesisToken(this.currToken);
  4432. this.position++;
  4433. }
  4434. if (last) {
  4435. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  4436. } else {
  4437. this.newNode(new _string["default"]({
  4438. value: parenValue,
  4439. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  4440. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  4441. }));
  4442. }
  4443. }
  4444. if (unbalanced) {
  4445. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  4446. }
  4447. };
  4448. _proto.pseudo = function pseudo() {
  4449. var _this4 = this;
  4450. var pseudoStr = '';
  4451. var startingToken = this.currToken;
  4452. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  4453. pseudoStr += this.content();
  4454. this.position++;
  4455. }
  4456. if (!this.currToken) {
  4457. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  4458. }
  4459. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  4460. this.splitWord(false, function (first, length) {
  4461. pseudoStr += first;
  4462. _this4.newNode(new _pseudo["default"]({
  4463. value: pseudoStr,
  4464. source: getTokenSourceSpan(startingToken, _this4.currToken),
  4465. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  4466. }));
  4467. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4468. _this4.error('Misplaced parenthesis.', {
  4469. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  4470. });
  4471. }
  4472. });
  4473. } else {
  4474. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  4475. }
  4476. };
  4477. _proto.space = function space() {
  4478. var content = this.content();
  4479. // Handle space before and after the selector
  4480. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  4481. return node.type === 'comment';
  4482. })) {
  4483. this.spaces = this.optionalSpace(content);
  4484. this.position++;
  4485. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4486. this.current.last.spaces.after = this.optionalSpace(content);
  4487. this.position++;
  4488. } else {
  4489. this.combinator();
  4490. }
  4491. };
  4492. _proto.string = function string() {
  4493. var current = this.currToken;
  4494. this.newNode(new _string["default"]({
  4495. value: this.content(),
  4496. source: getTokenSource(current),
  4497. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4498. }));
  4499. this.position++;
  4500. };
  4501. _proto.universal = function universal(namespace) {
  4502. var nextToken = this.nextToken;
  4503. if (nextToken && this.content(nextToken) === '|') {
  4504. this.position++;
  4505. return this.namespace();
  4506. }
  4507. var current = this.currToken;
  4508. this.newNode(new _universal["default"]({
  4509. value: this.content(),
  4510. source: getTokenSource(current),
  4511. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4512. }), namespace);
  4513. this.position++;
  4514. };
  4515. _proto.splitWord = function splitWord(namespace, firstCallback) {
  4516. var _this5 = this;
  4517. var nextToken = this.nextToken;
  4518. var word = this.content();
  4519. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  4520. this.position++;
  4521. var current = this.content();
  4522. word += current;
  4523. if (current.lastIndexOf('\\') === current.length - 1) {
  4524. var next = this.nextToken;
  4525. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  4526. word += this.requiredSpace(this.content(next));
  4527. this.position++;
  4528. }
  4529. }
  4530. nextToken = this.nextToken;
  4531. }
  4532. var hasClass = indexesOf(word, '.').filter(function (i) {
  4533. // Allow escaped dot within class name
  4534. var escapedDot = word[i - 1] === '\\';
  4535. // Allow decimal numbers percent in @keyframes
  4536. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  4537. return !escapedDot && !isKeyframesPercent;
  4538. });
  4539. var hasId = indexesOf(word, '#').filter(function (i) {
  4540. return word[i - 1] !== '\\';
  4541. });
  4542. // Eliminate Sass interpolations from the list of id indexes
  4543. var interpolations = indexesOf(word, '#{');
  4544. if (interpolations.length) {
  4545. hasId = hasId.filter(function (hashIndex) {
  4546. return !~interpolations.indexOf(hashIndex);
  4547. });
  4548. }
  4549. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  4550. indices.forEach(function (ind, i) {
  4551. var index = indices[i + 1] || word.length;
  4552. var value = word.slice(ind, index);
  4553. if (i === 0 && firstCallback) {
  4554. return firstCallback.call(_this5, value, indices.length);
  4555. }
  4556. var node;
  4557. var current = _this5.currToken;
  4558. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  4559. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  4560. if (~hasClass.indexOf(ind)) {
  4561. var classNameOpts = {
  4562. value: value.slice(1),
  4563. source: source,
  4564. sourceIndex: sourceIndex
  4565. };
  4566. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  4567. } else if (~hasId.indexOf(ind)) {
  4568. var idOpts = {
  4569. value: value.slice(1),
  4570. source: source,
  4571. sourceIndex: sourceIndex
  4572. };
  4573. node = new _id["default"](unescapeProp(idOpts, "value"));
  4574. } else {
  4575. var tagOpts = {
  4576. value: value,
  4577. source: source,
  4578. sourceIndex: sourceIndex
  4579. };
  4580. unescapeProp(tagOpts, "value");
  4581. node = new _tag["default"](tagOpts);
  4582. }
  4583. _this5.newNode(node, namespace);
  4584. // Ensure that the namespace is used only once
  4585. namespace = null;
  4586. });
  4587. this.position++;
  4588. };
  4589. _proto.word = function word(namespace) {
  4590. var nextToken = this.nextToken;
  4591. if (nextToken && this.content(nextToken) === '|') {
  4592. this.position++;
  4593. return this.namespace();
  4594. }
  4595. return this.splitWord(namespace);
  4596. };
  4597. _proto.loop = function loop() {
  4598. while (this.position < this.tokens.length) {
  4599. this.parse(true);
  4600. }
  4601. this.current._inferEndPosition();
  4602. return this.root;
  4603. };
  4604. _proto.parse = function parse(throwOnParenthesis) {
  4605. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  4606. case tokens.space:
  4607. this.space();
  4608. break;
  4609. case tokens.comment:
  4610. this.comment();
  4611. break;
  4612. case tokens.openParenthesis:
  4613. this.parentheses();
  4614. break;
  4615. case tokens.closeParenthesis:
  4616. if (throwOnParenthesis) {
  4617. this.missingParenthesis();
  4618. }
  4619. break;
  4620. case tokens.openSquare:
  4621. this.attribute();
  4622. break;
  4623. case tokens.dollar:
  4624. case tokens.caret:
  4625. case tokens.equals:
  4626. case tokens.word:
  4627. this.word();
  4628. break;
  4629. case tokens.colon:
  4630. this.pseudo();
  4631. break;
  4632. case tokens.comma:
  4633. this.comma();
  4634. break;
  4635. case tokens.asterisk:
  4636. this.universal();
  4637. break;
  4638. case tokens.ampersand:
  4639. this.nesting();
  4640. break;
  4641. case tokens.slash:
  4642. case tokens.combinator:
  4643. this.combinator();
  4644. break;
  4645. case tokens.str:
  4646. this.string();
  4647. break;
  4648. // These cases throw; no break needed.
  4649. case tokens.closeSquare:
  4650. this.missingSquareBracket();
  4651. case tokens.semicolon:
  4652. this.missingBackslash();
  4653. default:
  4654. this.unexpected();
  4655. }
  4656. }
  4657. /**
  4658. * Helpers
  4659. */;
  4660. _proto.expected = function expected(description, index, found) {
  4661. if (Array.isArray(description)) {
  4662. var last = description.pop();
  4663. description = description.join(', ') + " or " + last;
  4664. }
  4665. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  4666. if (!found) {
  4667. return this.error("Expected " + an + " " + description + ".", {
  4668. index: index
  4669. });
  4670. }
  4671. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  4672. index: index
  4673. });
  4674. };
  4675. _proto.requiredSpace = function requiredSpace(space) {
  4676. return this.options.lossy ? ' ' : space;
  4677. };
  4678. _proto.optionalSpace = function optionalSpace(space) {
  4679. return this.options.lossy ? '' : space;
  4680. };
  4681. _proto.lossySpace = function lossySpace(space, required) {
  4682. if (this.options.lossy) {
  4683. return required ? ' ' : '';
  4684. } else {
  4685. return space;
  4686. }
  4687. };
  4688. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  4689. var content = this.content(token);
  4690. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  4691. return this.requiredSpace(content);
  4692. } else {
  4693. return content;
  4694. }
  4695. };
  4696. _proto.newNode = function newNode(node, namespace) {
  4697. if (namespace) {
  4698. if (/^ +$/.test(namespace)) {
  4699. if (!this.options.lossy) {
  4700. this.spaces = (this.spaces || '') + namespace;
  4701. }
  4702. namespace = true;
  4703. }
  4704. node.namespace = namespace;
  4705. unescapeProp(node, "namespace");
  4706. }
  4707. if (this.spaces) {
  4708. node.spaces.before = this.spaces;
  4709. this.spaces = '';
  4710. }
  4711. return this.current.append(node);
  4712. };
  4713. _proto.content = function content(token) {
  4714. if (token === void 0) {
  4715. token = this.currToken;
  4716. }
  4717. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  4718. };
  4719. /**
  4720. * returns the index of the next non-whitespace, non-comment token.
  4721. * returns -1 if no meaningful token is found.
  4722. */
  4723. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  4724. if (startPosition === void 0) {
  4725. startPosition = this.position + 1;
  4726. }
  4727. var searchPosition = startPosition;
  4728. while (searchPosition < this.tokens.length) {
  4729. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  4730. searchPosition++;
  4731. continue;
  4732. } else {
  4733. return searchPosition;
  4734. }
  4735. }
  4736. return -1;
  4737. };
  4738. _createClass(Parser, [{
  4739. key: "currToken",
  4740. get: function get() {
  4741. return this.tokens[this.position];
  4742. }
  4743. }, {
  4744. key: "nextToken",
  4745. get: function get() {
  4746. return this.tokens[this.position + 1];
  4747. }
  4748. }, {
  4749. key: "prevToken",
  4750. get: function get() {
  4751. return this.tokens[this.position - 1];
  4752. }
  4753. }]);
  4754. return Parser;
  4755. }();
  4756. exports["default"] = Parser;
  4757. module.exports = exports.default;
  4758. } (parser, parser.exports));
  4759. var parserExports = parser.exports;
  4760. (function (module, exports) {
  4761. exports.__esModule = true;
  4762. exports["default"] = void 0;
  4763. var _parser = _interopRequireDefault(parserExports);
  4764. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4765. var Processor = /*#__PURE__*/function () {
  4766. function Processor(func, options) {
  4767. this.func = func || function noop() {};
  4768. this.funcRes = null;
  4769. this.options = options;
  4770. }
  4771. var _proto = Processor.prototype;
  4772. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  4773. if (options === void 0) {
  4774. options = {};
  4775. }
  4776. var merged = Object.assign({}, this.options, options);
  4777. if (merged.updateSelector === false) {
  4778. return false;
  4779. } else {
  4780. return typeof rule !== "string";
  4781. }
  4782. };
  4783. _proto._isLossy = function _isLossy(options) {
  4784. if (options === void 0) {
  4785. options = {};
  4786. }
  4787. var merged = Object.assign({}, this.options, options);
  4788. if (merged.lossless === false) {
  4789. return true;
  4790. } else {
  4791. return false;
  4792. }
  4793. };
  4794. _proto._root = function _root(rule, options) {
  4795. if (options === void 0) {
  4796. options = {};
  4797. }
  4798. var parser = new _parser["default"](rule, this._parseOptions(options));
  4799. return parser.root;
  4800. };
  4801. _proto._parseOptions = function _parseOptions(options) {
  4802. return {
  4803. lossy: this._isLossy(options)
  4804. };
  4805. };
  4806. _proto._run = function _run(rule, options) {
  4807. var _this = this;
  4808. if (options === void 0) {
  4809. options = {};
  4810. }
  4811. return new Promise(function (resolve, reject) {
  4812. try {
  4813. var root = _this._root(rule, options);
  4814. Promise.resolve(_this.func(root)).then(function (transform) {
  4815. var string = undefined;
  4816. if (_this._shouldUpdateSelector(rule, options)) {
  4817. string = root.toString();
  4818. rule.selector = string;
  4819. }
  4820. return {
  4821. transform: transform,
  4822. root: root,
  4823. string: string
  4824. };
  4825. }).then(resolve, reject);
  4826. } catch (e) {
  4827. reject(e);
  4828. return;
  4829. }
  4830. });
  4831. };
  4832. _proto._runSync = function _runSync(rule, options) {
  4833. if (options === void 0) {
  4834. options = {};
  4835. }
  4836. var root = this._root(rule, options);
  4837. var transform = this.func(root);
  4838. if (transform && typeof transform.then === "function") {
  4839. throw new Error("Selector processor returned a promise to a synchronous call.");
  4840. }
  4841. var string = undefined;
  4842. if (options.updateSelector && typeof rule !== "string") {
  4843. string = root.toString();
  4844. rule.selector = string;
  4845. }
  4846. return {
  4847. transform: transform,
  4848. root: root,
  4849. string: string
  4850. };
  4851. }
  4852. /**
  4853. * Process rule into a selector AST.
  4854. *
  4855. * @param rule {postcss.Rule | string} The css selector to be processed
  4856. * @param options The options for processing
  4857. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  4858. */;
  4859. _proto.ast = function ast(rule, options) {
  4860. return this._run(rule, options).then(function (result) {
  4861. return result.root;
  4862. });
  4863. }
  4864. /**
  4865. * Process rule into a selector AST synchronously.
  4866. *
  4867. * @param rule {postcss.Rule | string} The css selector to be processed
  4868. * @param options The options for processing
  4869. * @returns {parser.Root} The AST of the selector after processing it.
  4870. */;
  4871. _proto.astSync = function astSync(rule, options) {
  4872. return this._runSync(rule, options).root;
  4873. }
  4874. /**
  4875. * Process a selector into a transformed value asynchronously
  4876. *
  4877. * @param rule {postcss.Rule | string} The css selector to be processed
  4878. * @param options The options for processing
  4879. * @returns {Promise<any>} The value returned by the processor.
  4880. */;
  4881. _proto.transform = function transform(rule, options) {
  4882. return this._run(rule, options).then(function (result) {
  4883. return result.transform;
  4884. });
  4885. }
  4886. /**
  4887. * Process a selector into a transformed value synchronously.
  4888. *
  4889. * @param rule {postcss.Rule | string} The css selector to be processed
  4890. * @param options The options for processing
  4891. * @returns {any} The value returned by the processor.
  4892. */;
  4893. _proto.transformSync = function transformSync(rule, options) {
  4894. return this._runSync(rule, options).transform;
  4895. }
  4896. /**
  4897. * Process a selector into a new selector string asynchronously.
  4898. *
  4899. * @param rule {postcss.Rule | string} The css selector to be processed
  4900. * @param options The options for processing
  4901. * @returns {string} the selector after processing.
  4902. */;
  4903. _proto.process = function process(rule, options) {
  4904. return this._run(rule, options).then(function (result) {
  4905. return result.string || result.root.toString();
  4906. });
  4907. }
  4908. /**
  4909. * Process a selector into a new selector string synchronously.
  4910. *
  4911. * @param rule {postcss.Rule | string} The css selector to be processed
  4912. * @param options The options for processing
  4913. * @returns {string} the selector after processing.
  4914. */;
  4915. _proto.processSync = function processSync(rule, options) {
  4916. var result = this._runSync(rule, options);
  4917. return result.string || result.root.toString();
  4918. };
  4919. return Processor;
  4920. }();
  4921. exports["default"] = Processor;
  4922. module.exports = exports.default;
  4923. } (processor, processor.exports));
  4924. var processorExports = processor.exports;
  4925. var selectors = {};
  4926. var constructors = {};
  4927. constructors.__esModule = true;
  4928. 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;
  4929. var _attribute = _interopRequireDefault$2(attribute$1);
  4930. var _className = _interopRequireDefault$2(classNameExports);
  4931. var _combinator = _interopRequireDefault$2(combinatorExports);
  4932. var _comment = _interopRequireDefault$2(commentExports);
  4933. var _id = _interopRequireDefault$2(idExports);
  4934. var _nesting = _interopRequireDefault$2(nestingExports);
  4935. var _pseudo = _interopRequireDefault$2(pseudoExports);
  4936. var _root = _interopRequireDefault$2(rootExports);
  4937. var _selector = _interopRequireDefault$2(selectorExports);
  4938. var _string = _interopRequireDefault$2(stringExports);
  4939. var _tag = _interopRequireDefault$2(tagExports);
  4940. var _universal = _interopRequireDefault$2(universalExports);
  4941. function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4942. var attribute = function attribute(opts) {
  4943. return new _attribute["default"](opts);
  4944. };
  4945. constructors.attribute = attribute;
  4946. var className = function className(opts) {
  4947. return new _className["default"](opts);
  4948. };
  4949. constructors.className = className;
  4950. var combinator = function combinator(opts) {
  4951. return new _combinator["default"](opts);
  4952. };
  4953. constructors.combinator = combinator;
  4954. var comment = function comment(opts) {
  4955. return new _comment["default"](opts);
  4956. };
  4957. constructors.comment = comment;
  4958. var id = function id(opts) {
  4959. return new _id["default"](opts);
  4960. };
  4961. constructors.id = id;
  4962. var nesting = function nesting(opts) {
  4963. return new _nesting["default"](opts);
  4964. };
  4965. constructors.nesting = nesting;
  4966. var pseudo = function pseudo(opts) {
  4967. return new _pseudo["default"](opts);
  4968. };
  4969. constructors.pseudo = pseudo;
  4970. var root = function root(opts) {
  4971. return new _root["default"](opts);
  4972. };
  4973. constructors.root = root;
  4974. var selector = function selector(opts) {
  4975. return new _selector["default"](opts);
  4976. };
  4977. constructors.selector = selector;
  4978. var string = function string(opts) {
  4979. return new _string["default"](opts);
  4980. };
  4981. constructors.string = string;
  4982. var tag = function tag(opts) {
  4983. return new _tag["default"](opts);
  4984. };
  4985. constructors.tag = tag;
  4986. var universal = function universal(opts) {
  4987. return new _universal["default"](opts);
  4988. };
  4989. constructors.universal = universal;
  4990. var guards = {};
  4991. guards.__esModule = true;
  4992. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  4993. guards.isContainer = isContainer;
  4994. guards.isIdentifier = void 0;
  4995. guards.isNamespace = isNamespace;
  4996. guards.isNesting = void 0;
  4997. guards.isNode = isNode;
  4998. guards.isPseudo = void 0;
  4999. guards.isPseudoClass = isPseudoClass;
  5000. guards.isPseudoElement = isPseudoElement;
  5001. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  5002. var _types = types;
  5003. var _IS_TYPE;
  5004. 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);
  5005. function isNode(node) {
  5006. return typeof node === "object" && IS_TYPE[node.type];
  5007. }
  5008. function isNodeType(type, node) {
  5009. return isNode(node) && node.type === type;
  5010. }
  5011. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  5012. guards.isAttribute = isAttribute;
  5013. var isClassName = isNodeType.bind(null, _types.CLASS);
  5014. guards.isClassName = isClassName;
  5015. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  5016. guards.isCombinator = isCombinator;
  5017. var isComment = isNodeType.bind(null, _types.COMMENT);
  5018. guards.isComment = isComment;
  5019. var isIdentifier = isNodeType.bind(null, _types.ID);
  5020. guards.isIdentifier = isIdentifier;
  5021. var isNesting = isNodeType.bind(null, _types.NESTING);
  5022. guards.isNesting = isNesting;
  5023. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  5024. guards.isPseudo = isPseudo;
  5025. var isRoot = isNodeType.bind(null, _types.ROOT);
  5026. guards.isRoot = isRoot;
  5027. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  5028. guards.isSelector = isSelector;
  5029. var isString = isNodeType.bind(null, _types.STRING);
  5030. guards.isString = isString;
  5031. var isTag = isNodeType.bind(null, _types.TAG);
  5032. guards.isTag = isTag;
  5033. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  5034. guards.isUniversal = isUniversal;
  5035. function isPseudoElement(node) {
  5036. 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");
  5037. }
  5038. function isPseudoClass(node) {
  5039. return isPseudo(node) && !isPseudoElement(node);
  5040. }
  5041. function isContainer(node) {
  5042. return !!(isNode(node) && node.walk);
  5043. }
  5044. function isNamespace(node) {
  5045. return isAttribute(node) || isTag(node);
  5046. }
  5047. (function (exports) {
  5048. exports.__esModule = true;
  5049. var _types = types;
  5050. Object.keys(_types).forEach(function (key) {
  5051. if (key === "default" || key === "__esModule") return;
  5052. if (key in exports && exports[key] === _types[key]) return;
  5053. exports[key] = _types[key];
  5054. });
  5055. var _constructors = constructors;
  5056. Object.keys(_constructors).forEach(function (key) {
  5057. if (key === "default" || key === "__esModule") return;
  5058. if (key in exports && exports[key] === _constructors[key]) return;
  5059. exports[key] = _constructors[key];
  5060. });
  5061. var _guards = guards;
  5062. Object.keys(_guards).forEach(function (key) {
  5063. if (key === "default" || key === "__esModule") return;
  5064. if (key in exports && exports[key] === _guards[key]) return;
  5065. exports[key] = _guards[key];
  5066. });
  5067. } (selectors));
  5068. (function (module, exports) {
  5069. exports.__esModule = true;
  5070. exports["default"] = void 0;
  5071. var _processor = _interopRequireDefault(processorExports);
  5072. var selectors$1 = _interopRequireWildcard(selectors);
  5073. 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); }
  5074. 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; }
  5075. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5076. var parser = function parser(processor) {
  5077. return new _processor["default"](processor);
  5078. };
  5079. Object.assign(parser, selectors$1);
  5080. delete parser.__esModule;
  5081. var _default = parser;
  5082. exports["default"] = _default;
  5083. module.exports = exports.default;
  5084. } (dist, dist.exports));
  5085. var distExports = dist.exports;
  5086. const selectorParser$1 = distExports;
  5087. const valueParser = lib;
  5088. const { extractICSS } = src$4;
  5089. const isSpacing = (node) => node.type === "combinator" && node.value === " ";
  5090. function normalizeNodeArray(nodes) {
  5091. const array = [];
  5092. nodes.forEach((x) => {
  5093. if (Array.isArray(x)) {
  5094. normalizeNodeArray(x).forEach((item) => {
  5095. array.push(item);
  5096. });
  5097. } else if (x) {
  5098. array.push(x);
  5099. }
  5100. });
  5101. if (array.length > 0 && isSpacing(array[array.length - 1])) {
  5102. array.pop();
  5103. }
  5104. return array;
  5105. }
  5106. function localizeNode(rule, mode, localAliasMap) {
  5107. const transform = (node, context) => {
  5108. if (context.ignoreNextSpacing && !isSpacing(node)) {
  5109. throw new Error("Missing whitespace after " + context.ignoreNextSpacing);
  5110. }
  5111. if (context.enforceNoSpacing && isSpacing(node)) {
  5112. throw new Error("Missing whitespace before " + context.enforceNoSpacing);
  5113. }
  5114. let newNodes;
  5115. switch (node.type) {
  5116. case "root": {
  5117. let resultingGlobal;
  5118. context.hasPureGlobals = false;
  5119. newNodes = node.nodes.map((n) => {
  5120. const nContext = {
  5121. global: context.global,
  5122. lastWasSpacing: true,
  5123. hasLocals: false,
  5124. explicit: false,
  5125. };
  5126. n = transform(n, nContext);
  5127. if (typeof resultingGlobal === "undefined") {
  5128. resultingGlobal = nContext.global;
  5129. } else if (resultingGlobal !== nContext.global) {
  5130. throw new Error(
  5131. 'Inconsistent rule global/local result in rule "' +
  5132. node +
  5133. '" (multiple selectors must result in the same mode for the rule)'
  5134. );
  5135. }
  5136. if (!nContext.hasLocals) {
  5137. context.hasPureGlobals = true;
  5138. }
  5139. return n;
  5140. });
  5141. context.global = resultingGlobal;
  5142. node.nodes = normalizeNodeArray(newNodes);
  5143. break;
  5144. }
  5145. case "selector": {
  5146. newNodes = node.map((childNode) => transform(childNode, context));
  5147. node = node.clone();
  5148. node.nodes = normalizeNodeArray(newNodes);
  5149. break;
  5150. }
  5151. case "combinator": {
  5152. if (isSpacing(node)) {
  5153. if (context.ignoreNextSpacing) {
  5154. context.ignoreNextSpacing = false;
  5155. context.lastWasSpacing = false;
  5156. context.enforceNoSpacing = false;
  5157. return null;
  5158. }
  5159. context.lastWasSpacing = true;
  5160. return node;
  5161. }
  5162. break;
  5163. }
  5164. case "pseudo": {
  5165. let childContext;
  5166. const isNested = !!node.length;
  5167. const isScoped = node.value === ":local" || node.value === ":global";
  5168. const isImportExport =
  5169. node.value === ":import" || node.value === ":export";
  5170. if (isImportExport) {
  5171. context.hasLocals = true;
  5172. // :local(.foo)
  5173. } else if (isNested) {
  5174. if (isScoped) {
  5175. if (node.nodes.length === 0) {
  5176. throw new Error(`${node.value}() can't be empty`);
  5177. }
  5178. if (context.inside) {
  5179. throw new Error(
  5180. `A ${node.value} is not allowed inside of a ${context.inside}(...)`
  5181. );
  5182. }
  5183. childContext = {
  5184. global: node.value === ":global",
  5185. inside: node.value,
  5186. hasLocals: false,
  5187. explicit: true,
  5188. };
  5189. newNodes = node
  5190. .map((childNode) => transform(childNode, childContext))
  5191. .reduce((acc, next) => acc.concat(next.nodes), []);
  5192. if (newNodes.length) {
  5193. const { before, after } = node.spaces;
  5194. const first = newNodes[0];
  5195. const last = newNodes[newNodes.length - 1];
  5196. first.spaces = { before, after: first.spaces.after };
  5197. last.spaces = { before: last.spaces.before, after };
  5198. }
  5199. node = newNodes;
  5200. break;
  5201. } else {
  5202. childContext = {
  5203. global: context.global,
  5204. inside: context.inside,
  5205. lastWasSpacing: true,
  5206. hasLocals: false,
  5207. explicit: context.explicit,
  5208. };
  5209. newNodes = node.map((childNode) =>
  5210. transform(childNode, childContext)
  5211. );
  5212. node = node.clone();
  5213. node.nodes = normalizeNodeArray(newNodes);
  5214. if (childContext.hasLocals) {
  5215. context.hasLocals = true;
  5216. }
  5217. }
  5218. break;
  5219. //:local .foo .bar
  5220. } else if (isScoped) {
  5221. if (context.inside) {
  5222. throw new Error(
  5223. `A ${node.value} is not allowed inside of a ${context.inside}(...)`
  5224. );
  5225. }
  5226. const addBackSpacing = !!node.spaces.before;
  5227. context.ignoreNextSpacing = context.lastWasSpacing
  5228. ? node.value
  5229. : false;
  5230. context.enforceNoSpacing = context.lastWasSpacing
  5231. ? false
  5232. : node.value;
  5233. context.global = node.value === ":global";
  5234. context.explicit = true;
  5235. // because this node has spacing that is lost when we remove it
  5236. // we make up for it by adding an extra combinator in since adding
  5237. // spacing on the parent selector doesn't work
  5238. return addBackSpacing
  5239. ? selectorParser$1.combinator({ value: " " })
  5240. : null;
  5241. }
  5242. break;
  5243. }
  5244. case "id":
  5245. case "class": {
  5246. if (!node.value) {
  5247. throw new Error("Invalid class or id selector syntax");
  5248. }
  5249. if (context.global) {
  5250. break;
  5251. }
  5252. const isImportedValue = localAliasMap.has(node.value);
  5253. const isImportedWithExplicitScope = isImportedValue && context.explicit;
  5254. if (!isImportedValue || isImportedWithExplicitScope) {
  5255. const innerNode = node.clone();
  5256. innerNode.spaces = { before: "", after: "" };
  5257. node = selectorParser$1.pseudo({
  5258. value: ":local",
  5259. nodes: [innerNode],
  5260. spaces: node.spaces,
  5261. });
  5262. context.hasLocals = true;
  5263. }
  5264. break;
  5265. }
  5266. }
  5267. context.lastWasSpacing = false;
  5268. context.ignoreNextSpacing = false;
  5269. context.enforceNoSpacing = false;
  5270. return node;
  5271. };
  5272. const rootContext = {
  5273. global: mode === "global",
  5274. hasPureGlobals: false,
  5275. };
  5276. rootContext.selector = selectorParser$1((root) => {
  5277. transform(root, rootContext);
  5278. }).processSync(rule, { updateSelector: false, lossless: true });
  5279. return rootContext;
  5280. }
  5281. function localizeDeclNode(node, context) {
  5282. switch (node.type) {
  5283. case "word":
  5284. if (context.localizeNextItem) {
  5285. if (!context.localAliasMap.has(node.value)) {
  5286. node.value = ":local(" + node.value + ")";
  5287. context.localizeNextItem = false;
  5288. }
  5289. }
  5290. break;
  5291. case "function":
  5292. if (
  5293. context.options &&
  5294. context.options.rewriteUrl &&
  5295. node.value.toLowerCase() === "url"
  5296. ) {
  5297. node.nodes.map((nestedNode) => {
  5298. if (nestedNode.type !== "string" && nestedNode.type !== "word") {
  5299. return;
  5300. }
  5301. let newUrl = context.options.rewriteUrl(
  5302. context.global,
  5303. nestedNode.value
  5304. );
  5305. switch (nestedNode.type) {
  5306. case "string":
  5307. if (nestedNode.quote === "'") {
  5308. newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'");
  5309. }
  5310. if (nestedNode.quote === '"') {
  5311. newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/"/g, '\\"');
  5312. }
  5313. break;
  5314. case "word":
  5315. newUrl = newUrl.replace(/("|'|\)|\\)/g, "\\$1");
  5316. break;
  5317. }
  5318. nestedNode.value = newUrl;
  5319. });
  5320. }
  5321. break;
  5322. }
  5323. return node;
  5324. }
  5325. function isWordAFunctionArgument(wordNode, functionNode) {
  5326. return functionNode
  5327. ? functionNode.nodes.some(
  5328. (functionNodeChild) =>
  5329. functionNodeChild.sourceIndex === wordNode.sourceIndex
  5330. )
  5331. : false;
  5332. }
  5333. function localizeDeclarationValues(localize, declaration, context) {
  5334. const valueNodes = valueParser(declaration.value);
  5335. valueNodes.walk((node, index, nodes) => {
  5336. const subContext = {
  5337. options: context.options,
  5338. global: context.global,
  5339. localizeNextItem: localize && !context.global,
  5340. localAliasMap: context.localAliasMap,
  5341. };
  5342. nodes[index] = localizeDeclNode(node, subContext);
  5343. });
  5344. declaration.value = valueNodes.toString();
  5345. }
  5346. function localizeDeclaration(declaration, context) {
  5347. const isAnimation = /animation$/i.test(declaration.prop);
  5348. if (isAnimation) {
  5349. const validIdent = /^-?[_a-z][_a-z0-9-]*$/i;
  5350. /*
  5351. The spec defines some keywords that you can use to describe properties such as the timing
  5352. function. These are still valid animation names, so as long as there is a property that accepts
  5353. a keyword, it is given priority. Only when all the properties that can take a keyword are
  5354. exhausted can the animation name be set to the keyword. I.e.
  5355. animation: infinite infinite;
  5356. The animation will repeat an infinite number of times from the first argument, and will have an
  5357. animation name of infinite from the second.
  5358. */
  5359. const animationKeywords = {
  5360. $alternate: 1,
  5361. "$alternate-reverse": 1,
  5362. $backwards: 1,
  5363. $both: 1,
  5364. $ease: 1,
  5365. "$ease-in": 1,
  5366. "$ease-in-out": 1,
  5367. "$ease-out": 1,
  5368. $forwards: 1,
  5369. $infinite: 1,
  5370. $linear: 1,
  5371. $none: Infinity, // No matter how many times you write none, it will never be an animation name
  5372. $normal: 1,
  5373. $paused: 1,
  5374. $reverse: 1,
  5375. $running: 1,
  5376. "$step-end": 1,
  5377. "$step-start": 1,
  5378. $initial: Infinity,
  5379. $inherit: Infinity,
  5380. $unset: Infinity,
  5381. };
  5382. let parsedAnimationKeywords = {};
  5383. let stepsFunctionNode = null;
  5384. const valueNodes = valueParser(declaration.value).walk((node) => {
  5385. /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
  5386. if (node.type === "div") {
  5387. parsedAnimationKeywords = {};
  5388. }
  5389. if (node.type === "function" && node.value.toLowerCase() === "steps") {
  5390. stepsFunctionNode = node;
  5391. }
  5392. const value =
  5393. node.type === "word" &&
  5394. !isWordAFunctionArgument(node, stepsFunctionNode)
  5395. ? node.value.toLowerCase()
  5396. : null;
  5397. let shouldParseAnimationName = false;
  5398. if (value && validIdent.test(value)) {
  5399. if ("$" + value in animationKeywords) {
  5400. parsedAnimationKeywords["$" + value] =
  5401. "$" + value in parsedAnimationKeywords
  5402. ? parsedAnimationKeywords["$" + value] + 1
  5403. : 0;
  5404. shouldParseAnimationName =
  5405. parsedAnimationKeywords["$" + value] >=
  5406. animationKeywords["$" + value];
  5407. } else {
  5408. shouldParseAnimationName = true;
  5409. }
  5410. }
  5411. const subContext = {
  5412. options: context.options,
  5413. global: context.global,
  5414. localizeNextItem: shouldParseAnimationName && !context.global,
  5415. localAliasMap: context.localAliasMap,
  5416. };
  5417. return localizeDeclNode(node, subContext);
  5418. });
  5419. declaration.value = valueNodes.toString();
  5420. return;
  5421. }
  5422. const isAnimationName = /animation(-name)?$/i.test(declaration.prop);
  5423. if (isAnimationName) {
  5424. return localizeDeclarationValues(true, declaration, context);
  5425. }
  5426. const hasUrl = /url\(/i.test(declaration.value);
  5427. if (hasUrl) {
  5428. return localizeDeclarationValues(false, declaration, context);
  5429. }
  5430. }
  5431. src$2.exports = (options = {}) => {
  5432. if (
  5433. options &&
  5434. options.mode &&
  5435. options.mode !== "global" &&
  5436. options.mode !== "local" &&
  5437. options.mode !== "pure"
  5438. ) {
  5439. throw new Error(
  5440. 'options.mode must be either "global", "local" or "pure" (default "local")'
  5441. );
  5442. }
  5443. const pureMode = options && options.mode === "pure";
  5444. const globalMode = options && options.mode === "global";
  5445. return {
  5446. postcssPlugin: "postcss-modules-local-by-default",
  5447. prepare() {
  5448. const localAliasMap = new Map();
  5449. return {
  5450. Once(root) {
  5451. const { icssImports } = extractICSS(root, false);
  5452. Object.keys(icssImports).forEach((key) => {
  5453. Object.keys(icssImports[key]).forEach((prop) => {
  5454. localAliasMap.set(prop, icssImports[key][prop]);
  5455. });
  5456. });
  5457. root.walkAtRules((atRule) => {
  5458. if (/keyframes$/i.test(atRule.name)) {
  5459. const globalMatch = /^\s*:global\s*\((.+)\)\s*$/.exec(
  5460. atRule.params
  5461. );
  5462. const localMatch = /^\s*:local\s*\((.+)\)\s*$/.exec(
  5463. atRule.params
  5464. );
  5465. let globalKeyframes = globalMode;
  5466. if (globalMatch) {
  5467. if (pureMode) {
  5468. throw atRule.error(
  5469. "@keyframes :global(...) is not allowed in pure mode"
  5470. );
  5471. }
  5472. atRule.params = globalMatch[1];
  5473. globalKeyframes = true;
  5474. } else if (localMatch) {
  5475. atRule.params = localMatch[0];
  5476. globalKeyframes = false;
  5477. } else if (!globalMode) {
  5478. if (atRule.params && !localAliasMap.has(atRule.params)) {
  5479. atRule.params = ":local(" + atRule.params + ")";
  5480. }
  5481. }
  5482. atRule.walkDecls((declaration) => {
  5483. localizeDeclaration(declaration, {
  5484. localAliasMap,
  5485. options: options,
  5486. global: globalKeyframes,
  5487. });
  5488. });
  5489. } else if (atRule.nodes) {
  5490. atRule.nodes.forEach((declaration) => {
  5491. if (declaration.type === "decl") {
  5492. localizeDeclaration(declaration, {
  5493. localAliasMap,
  5494. options: options,
  5495. global: globalMode,
  5496. });
  5497. }
  5498. });
  5499. }
  5500. });
  5501. root.walkRules((rule) => {
  5502. if (
  5503. rule.parent &&
  5504. rule.parent.type === "atrule" &&
  5505. /keyframes$/i.test(rule.parent.name)
  5506. ) {
  5507. // ignore keyframe rules
  5508. return;
  5509. }
  5510. const context = localizeNode(rule, options.mode, localAliasMap);
  5511. context.options = options;
  5512. context.localAliasMap = localAliasMap;
  5513. if (pureMode && context.hasPureGlobals) {
  5514. throw rule.error(
  5515. 'Selector "' +
  5516. rule.selector +
  5517. '" is not pure ' +
  5518. "(pure selectors must contain at least one local class or id)"
  5519. );
  5520. }
  5521. rule.selector = context.selector;
  5522. // Less-syntax mixins parse as rules with no nodes
  5523. if (rule.nodes) {
  5524. rule.nodes.forEach((declaration) =>
  5525. localizeDeclaration(declaration, context)
  5526. );
  5527. }
  5528. });
  5529. },
  5530. };
  5531. },
  5532. };
  5533. };
  5534. src$2.exports.postcss = true;
  5535. var srcExports$1 = src$2.exports;
  5536. const selectorParser = distExports;
  5537. const hasOwnProperty = Object.prototype.hasOwnProperty;
  5538. function getSingleLocalNamesForComposes(root) {
  5539. return root.nodes.map((node) => {
  5540. if (node.type !== "selector" || node.nodes.length !== 1) {
  5541. throw new Error(
  5542. `composition is only allowed when selector is single :local class name not in "${root}"`
  5543. );
  5544. }
  5545. node = node.nodes[0];
  5546. if (
  5547. node.type !== "pseudo" ||
  5548. node.value !== ":local" ||
  5549. node.nodes.length !== 1
  5550. ) {
  5551. throw new Error(
  5552. 'composition is only allowed when selector is single :local class name not in "' +
  5553. root +
  5554. '", "' +
  5555. node +
  5556. '" is weird'
  5557. );
  5558. }
  5559. node = node.first;
  5560. if (node.type !== "selector" || node.length !== 1) {
  5561. throw new Error(
  5562. 'composition is only allowed when selector is single :local class name not in "' +
  5563. root +
  5564. '", "' +
  5565. node +
  5566. '" is weird'
  5567. );
  5568. }
  5569. node = node.first;
  5570. if (node.type !== "class") {
  5571. // 'id' is not possible, because you can't compose ids
  5572. throw new Error(
  5573. 'composition is only allowed when selector is single :local class name not in "' +
  5574. root +
  5575. '", "' +
  5576. node +
  5577. '" is weird'
  5578. );
  5579. }
  5580. return node.value;
  5581. });
  5582. }
  5583. const whitespace = "[\\x20\\t\\r\\n\\f]";
  5584. const unescapeRegExp = new RegExp(
  5585. "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)",
  5586. "ig"
  5587. );
  5588. function unescape(str) {
  5589. return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
  5590. const high = "0x" + escaped - 0x10000;
  5591. // NaN means non-codepoint
  5592. // Workaround erroneous numeric interpretation of +"0x"
  5593. return high !== high || escapedWhitespace
  5594. ? escaped
  5595. : high < 0
  5596. ? // BMP codepoint
  5597. String.fromCharCode(high + 0x10000)
  5598. : // Supplemental Plane codepoint (surrogate pair)
  5599. String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00);
  5600. });
  5601. }
  5602. const plugin = (options = {}) => {
  5603. const generateScopedName =
  5604. (options && options.generateScopedName) || plugin.generateScopedName;
  5605. const generateExportEntry =
  5606. (options && options.generateExportEntry) || plugin.generateExportEntry;
  5607. const exportGlobals = options && options.exportGlobals;
  5608. return {
  5609. postcssPlugin: "postcss-modules-scope",
  5610. Once(root, { rule }) {
  5611. const exports = Object.create(null);
  5612. function exportScopedName(name, rawName) {
  5613. const scopedName = generateScopedName(
  5614. rawName ? rawName : name,
  5615. root.source.input.from,
  5616. root.source.input.css
  5617. );
  5618. const exportEntry = generateExportEntry(
  5619. rawName ? rawName : name,
  5620. scopedName,
  5621. root.source.input.from,
  5622. root.source.input.css
  5623. );
  5624. const { key, value } = exportEntry;
  5625. exports[key] = exports[key] || [];
  5626. if (exports[key].indexOf(value) < 0) {
  5627. exports[key].push(value);
  5628. }
  5629. return scopedName;
  5630. }
  5631. function localizeNode(node) {
  5632. switch (node.type) {
  5633. case "selector":
  5634. node.nodes = node.map(localizeNode);
  5635. return node;
  5636. case "class":
  5637. return selectorParser.className({
  5638. value: exportScopedName(
  5639. node.value,
  5640. node.raws && node.raws.value ? node.raws.value : null
  5641. ),
  5642. });
  5643. case "id": {
  5644. return selectorParser.id({
  5645. value: exportScopedName(
  5646. node.value,
  5647. node.raws && node.raws.value ? node.raws.value : null
  5648. ),
  5649. });
  5650. }
  5651. }
  5652. throw new Error(
  5653. `${node.type} ("${node}") is not allowed in a :local block`
  5654. );
  5655. }
  5656. function traverseNode(node) {
  5657. switch (node.type) {
  5658. case "pseudo":
  5659. if (node.value === ":local") {
  5660. if (node.nodes.length !== 1) {
  5661. throw new Error('Unexpected comma (",") in :local block');
  5662. }
  5663. const selector = localizeNode(node.first);
  5664. // move the spaces that were around the psuedo selector to the first
  5665. // non-container node
  5666. selector.first.spaces = node.spaces;
  5667. const nextNode = node.next();
  5668. if (
  5669. nextNode &&
  5670. nextNode.type === "combinator" &&
  5671. nextNode.value === " " &&
  5672. /\\[A-F0-9]{1,6}$/.test(selector.last.value)
  5673. ) {
  5674. selector.last.spaces.after = " ";
  5675. }
  5676. node.replaceWith(selector);
  5677. return;
  5678. }
  5679. /* falls through */
  5680. case "root":
  5681. case "selector": {
  5682. node.each(traverseNode);
  5683. break;
  5684. }
  5685. case "id":
  5686. case "class":
  5687. if (exportGlobals) {
  5688. exports[node.value] = [node.value];
  5689. }
  5690. break;
  5691. }
  5692. return node;
  5693. }
  5694. // Find any :import and remember imported names
  5695. const importedNames = {};
  5696. root.walkRules(/^:import\(.+\)$/, (rule) => {
  5697. rule.walkDecls((decl) => {
  5698. importedNames[decl.prop] = true;
  5699. });
  5700. });
  5701. // Find any :local selectors
  5702. root.walkRules((rule) => {
  5703. let parsedSelector = selectorParser().astSync(rule);
  5704. rule.selector = traverseNode(parsedSelector.clone()).toString();
  5705. rule.walkDecls(/composes|compose-with/i, (decl) => {
  5706. const localNames = getSingleLocalNamesForComposes(parsedSelector);
  5707. const classes = decl.value.split(/\s+/);
  5708. classes.forEach((className) => {
  5709. const global = /^global\(([^)]+)\)$/.exec(className);
  5710. if (global) {
  5711. localNames.forEach((exportedName) => {
  5712. exports[exportedName].push(global[1]);
  5713. });
  5714. } else if (hasOwnProperty.call(importedNames, className)) {
  5715. localNames.forEach((exportedName) => {
  5716. exports[exportedName].push(className);
  5717. });
  5718. } else if (hasOwnProperty.call(exports, className)) {
  5719. localNames.forEach((exportedName) => {
  5720. exports[className].forEach((item) => {
  5721. exports[exportedName].push(item);
  5722. });
  5723. });
  5724. } else {
  5725. throw decl.error(
  5726. `referenced class name "${className}" in ${decl.prop} not found`
  5727. );
  5728. }
  5729. });
  5730. decl.remove();
  5731. });
  5732. // Find any :local values
  5733. rule.walkDecls((decl) => {
  5734. if (!/:local\s*\((.+?)\)/.test(decl.value)) {
  5735. return;
  5736. }
  5737. let tokens = decl.value.split(/(,|'[^']*'|"[^"]*")/);
  5738. tokens = tokens.map((token, idx) => {
  5739. if (idx === 0 || tokens[idx - 1] === ",") {
  5740. let result = token;
  5741. const localMatch = /:local\s*\((.+?)\)/.exec(token);
  5742. if (localMatch) {
  5743. const input = localMatch.input;
  5744. const matchPattern = localMatch[0];
  5745. const matchVal = localMatch[1];
  5746. const newVal = exportScopedName(matchVal);
  5747. result = input.replace(matchPattern, newVal);
  5748. } else {
  5749. return token;
  5750. }
  5751. return result;
  5752. } else {
  5753. return token;
  5754. }
  5755. });
  5756. decl.value = tokens.join("");
  5757. });
  5758. });
  5759. // Find any :local keyframes
  5760. root.walkAtRules(/keyframes$/i, (atRule) => {
  5761. const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(atRule.params);
  5762. if (!localMatch) {
  5763. return;
  5764. }
  5765. atRule.params = exportScopedName(localMatch[1]);
  5766. });
  5767. // If we found any :locals, insert an :export rule
  5768. const exportedNames = Object.keys(exports);
  5769. if (exportedNames.length > 0) {
  5770. const exportRule = rule({ selector: ":export" });
  5771. exportedNames.forEach((exportedName) =>
  5772. exportRule.append({
  5773. prop: exportedName,
  5774. value: exports[exportedName].join(" "),
  5775. raws: { before: "\n " },
  5776. })
  5777. );
  5778. root.append(exportRule);
  5779. }
  5780. },
  5781. };
  5782. };
  5783. plugin.postcss = true;
  5784. plugin.generateScopedName = function (name, path) {
  5785. const sanitisedPath = path
  5786. .replace(/\.[^./\\]+$/, "")
  5787. .replace(/[\W_]+/g, "_")
  5788. .replace(/^_|_$/g, "");
  5789. return `_${sanitisedPath}__${name}`.trim();
  5790. };
  5791. plugin.generateExportEntry = function (name, scopedName) {
  5792. return {
  5793. key: unescape(name),
  5794. value: unescape(scopedName),
  5795. };
  5796. };
  5797. var src$1 = plugin;
  5798. function hash(str) {
  5799. var hash = 5381,
  5800. i = str.length;
  5801. while(i) {
  5802. hash = (hash * 33) ^ str.charCodeAt(--i);
  5803. }
  5804. /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
  5805. * integers. Since we want the results to be always positive, convert the
  5806. * signed int to an unsigned by doing an unsigned bitshift. */
  5807. return hash >>> 0;
  5808. }
  5809. var stringHash = hash;
  5810. var src = {exports: {}};
  5811. const ICSSUtils = src$4;
  5812. const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
  5813. const matchValueDefinition = /(?:\s+|^)([\w-]+):?(.*?)$/;
  5814. const matchImport = /^([\w-]+)(?:\s+as\s+([\w-]+))?/;
  5815. src.exports = (options) => {
  5816. let importIndex = 0;
  5817. const createImportedName =
  5818. (options && options.createImportedName) ||
  5819. ((importName /*, path*/) =>
  5820. `i__const_${importName.replace(/\W/g, "_")}_${importIndex++}`);
  5821. return {
  5822. postcssPlugin: "postcss-modules-values",
  5823. prepare(result) {
  5824. const importAliases = [];
  5825. const definitions = {};
  5826. return {
  5827. Once(root, postcss) {
  5828. root.walkAtRules(/value/i, (atRule) => {
  5829. const matches = atRule.params.match(matchImports);
  5830. if (matches) {
  5831. let [, /*match*/ aliases, path] = matches;
  5832. // We can use constants for path names
  5833. if (definitions[path]) {
  5834. path = definitions[path];
  5835. }
  5836. const imports = aliases
  5837. .replace(/^\(\s*([\s\S]+)\s*\)$/, "$1")
  5838. .split(/\s*,\s*/)
  5839. .map((alias) => {
  5840. const tokens = matchImport.exec(alias);
  5841. if (tokens) {
  5842. const [, /*match*/ theirName, myName = theirName] = tokens;
  5843. const importedName = createImportedName(myName);
  5844. definitions[myName] = importedName;
  5845. return { theirName, importedName };
  5846. } else {
  5847. throw new Error(`@import statement "${alias}" is invalid!`);
  5848. }
  5849. });
  5850. importAliases.push({ path, imports });
  5851. atRule.remove();
  5852. return;
  5853. }
  5854. if (atRule.params.indexOf("@value") !== -1) {
  5855. result.warn("Invalid value definition: " + atRule.params);
  5856. }
  5857. let [, key, value] = `${atRule.params}${atRule.raws.between}`.match(
  5858. matchValueDefinition
  5859. );
  5860. const normalizedValue = value.replace(/\/\*((?!\*\/).*?)\*\//g, "");
  5861. if (normalizedValue.length === 0) {
  5862. result.warn("Invalid value definition: " + atRule.params);
  5863. atRule.remove();
  5864. return;
  5865. }
  5866. let isOnlySpace = /^\s+$/.test(normalizedValue);
  5867. if (!isOnlySpace) {
  5868. value = value.trim();
  5869. }
  5870. // Add to the definitions, knowing that values can refer to each other
  5871. definitions[key] = ICSSUtils.replaceValueSymbols(
  5872. value,
  5873. definitions
  5874. );
  5875. atRule.remove();
  5876. });
  5877. /* If we have no definitions, don't continue */
  5878. if (!Object.keys(definitions).length) {
  5879. return;
  5880. }
  5881. /* Perform replacements */
  5882. ICSSUtils.replaceSymbols(root, definitions);
  5883. /* We want to export anything defined by now, but don't add it to the CSS yet or it well get picked up by the replacement stuff */
  5884. const exportDeclarations = Object.keys(definitions).map((key) =>
  5885. postcss.decl({
  5886. value: definitions[key],
  5887. prop: key,
  5888. raws: { before: "\n " },
  5889. })
  5890. );
  5891. /* Add export rules if any */
  5892. if (exportDeclarations.length > 0) {
  5893. const exportRule = postcss.rule({
  5894. selector: ":export",
  5895. raws: { after: "\n" },
  5896. });
  5897. exportRule.append(exportDeclarations);
  5898. root.prepend(exportRule);
  5899. }
  5900. /* Add import rules */
  5901. importAliases.reverse().forEach(({ path, imports }) => {
  5902. const importRule = postcss.rule({
  5903. selector: `:import(${path})`,
  5904. raws: { after: "\n" },
  5905. });
  5906. imports.forEach(({ theirName, importedName }) => {
  5907. importRule.append({
  5908. value: theirName,
  5909. prop: importedName,
  5910. raws: { before: "\n " },
  5911. });
  5912. });
  5913. root.prepend(importRule);
  5914. });
  5915. },
  5916. };
  5917. },
  5918. };
  5919. };
  5920. src.exports.postcss = true;
  5921. var srcExports = src.exports;
  5922. Object.defineProperty(scoping, "__esModule", {
  5923. value: true
  5924. });
  5925. scoping.behaviours = void 0;
  5926. scoping.getDefaultPlugins = getDefaultPlugins;
  5927. scoping.getDefaultScopeBehaviour = getDefaultScopeBehaviour;
  5928. scoping.getScopedNameGenerator = getScopedNameGenerator;
  5929. var _postcssModulesExtractImports = _interopRequireDefault$1(srcExports$2);
  5930. var _genericNames = _interopRequireDefault$1(genericNames);
  5931. var _postcssModulesLocalByDefault = _interopRequireDefault$1(srcExports$1);
  5932. var _postcssModulesScope = _interopRequireDefault$1(src$1);
  5933. var _stringHash = _interopRequireDefault$1(stringHash);
  5934. var _postcssModulesValues = _interopRequireDefault$1(srcExports);
  5935. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5936. const behaviours = {
  5937. LOCAL: "local",
  5938. GLOBAL: "global"
  5939. };
  5940. scoping.behaviours = behaviours;
  5941. function getDefaultPlugins({
  5942. behaviour,
  5943. generateScopedName,
  5944. exportGlobals
  5945. }) {
  5946. const scope = (0, _postcssModulesScope.default)({
  5947. generateScopedName,
  5948. exportGlobals
  5949. });
  5950. const plugins = {
  5951. [behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
  5952. mode: "local"
  5953. }), _postcssModulesExtractImports.default, scope],
  5954. [behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
  5955. mode: "global"
  5956. }), _postcssModulesExtractImports.default, scope]
  5957. };
  5958. return plugins[behaviour];
  5959. }
  5960. function isValidBehaviour(behaviour) {
  5961. return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
  5962. }
  5963. function getDefaultScopeBehaviour(scopeBehaviour) {
  5964. return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
  5965. }
  5966. function generateScopedNameDefault(name, filename, css) {
  5967. const i = css.indexOf(`.${name}`);
  5968. const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
  5969. const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
  5970. return `_${name}_${hash}_${lineNumber}`;
  5971. }
  5972. function getScopedNameGenerator(generateScopedName, hashPrefix) {
  5973. const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
  5974. if (typeof scopedNameGenerator === "function") {
  5975. return scopedNameGenerator;
  5976. }
  5977. return (0, _genericNames.default)(scopedNameGenerator, {
  5978. context: process.cwd(),
  5979. hashPrefix: hashPrefix
  5980. });
  5981. }
  5982. Object.defineProperty(pluginFactory, "__esModule", {
  5983. value: true
  5984. });
  5985. pluginFactory.makePlugin = makePlugin;
  5986. var _postcss = _interopRequireDefault(require$$0);
  5987. var _unquote = _interopRequireDefault(unquote$1);
  5988. var _Parser = _interopRequireDefault(Parser$1);
  5989. var _saveJSON = _interopRequireDefault(saveJSON$1);
  5990. var _localsConvention = localsConvention;
  5991. var _FileSystemLoader = _interopRequireDefault(FileSystemLoader$1);
  5992. var _scoping = scoping;
  5993. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5994. const PLUGIN_NAME = "postcss-modules";
  5995. function isGlobalModule(globalModules, inputFile) {
  5996. return globalModules.some(regex => inputFile.match(regex));
  5997. }
  5998. function getDefaultPluginsList(opts, inputFile) {
  5999. const globalModulesList = opts.globalModulePaths || null;
  6000. const exportGlobals = opts.exportGlobals || false;
  6001. const defaultBehaviour = (0, _scoping.getDefaultScopeBehaviour)(opts.scopeBehaviour);
  6002. const generateScopedName = (0, _scoping.getScopedNameGenerator)(opts.generateScopedName, opts.hashPrefix);
  6003. if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
  6004. return (0, _scoping.getDefaultPlugins)({
  6005. behaviour: _scoping.behaviours.GLOBAL,
  6006. generateScopedName,
  6007. exportGlobals
  6008. });
  6009. }
  6010. return (0, _scoping.getDefaultPlugins)({
  6011. behaviour: defaultBehaviour,
  6012. generateScopedName,
  6013. exportGlobals
  6014. });
  6015. }
  6016. function getLoader(opts, plugins) {
  6017. const root = typeof opts.root === "undefined" ? "/" : opts.root;
  6018. return typeof opts.Loader === "function" ? new opts.Loader(root, plugins, opts.resolve) : new _FileSystemLoader.default(root, plugins, opts.resolve);
  6019. }
  6020. function isOurPlugin(plugin) {
  6021. return plugin.postcssPlugin === PLUGIN_NAME;
  6022. }
  6023. function makePlugin(opts) {
  6024. return {
  6025. postcssPlugin: PLUGIN_NAME,
  6026. async OnceExit(css, {
  6027. result
  6028. }) {
  6029. const getJSON = opts.getJSON || _saveJSON.default;
  6030. const inputFile = css.source.input.file;
  6031. const pluginList = getDefaultPluginsList(opts, inputFile);
  6032. const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
  6033. if (resultPluginIndex === -1) {
  6034. throw new Error("Plugin missing from options.");
  6035. }
  6036. const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
  6037. const loaderPlugins = [...earlierPlugins, ...pluginList];
  6038. const loader = getLoader(opts, loaderPlugins);
  6039. const fetcher = async (file, relativeTo, depTrace) => {
  6040. const unquoteFile = (0, _unquote.default)(file);
  6041. return loader.fetch.call(loader, unquoteFile, relativeTo, depTrace);
  6042. };
  6043. const parser = new _Parser.default(fetcher);
  6044. await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
  6045. from: inputFile
  6046. });
  6047. const out = loader.finalSource;
  6048. if (out) css.prepend(out);
  6049. if (opts.localsConvention) {
  6050. const reducer = (0, _localsConvention.makeLocalsConventionReducer)(opts.localsConvention, inputFile);
  6051. parser.exportTokens = Object.entries(parser.exportTokens).reduce(reducer, {});
  6052. }
  6053. result.messages.push({
  6054. type: "export",
  6055. plugin: "postcss-modules",
  6056. exportTokens: parser.exportTokens
  6057. }); // getJSON may return a promise
  6058. return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
  6059. }
  6060. };
  6061. }
  6062. var _fs = require$$0__default;
  6063. var _fs2 = fs;
  6064. var _pluginFactory = pluginFactory;
  6065. (0, _fs2.setFileSystem)({
  6066. readFile: _fs.readFile,
  6067. writeFile: _fs.writeFile
  6068. });
  6069. build.exports = (opts = {}) => (0, _pluginFactory.makePlugin)(opts);
  6070. var postcss = build.exports.postcss = true;
  6071. var buildExports = build.exports;
  6072. var index = /*@__PURE__*/getDefaultExportFromCjs(buildExports);
  6073. var index$1 = /*#__PURE__*/_mergeNamespaces({
  6074. __proto__: null,
  6075. default: index,
  6076. postcss: postcss
  6077. }, [buildExports]);
  6078. export { index$1 as i };