dep-f597f42f.js 223 KB

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