dep-8989cf2a.js 221 KB

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