dep-aa4ab47b.js 217 KB

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