bin-prettier.js 509 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var require$$0$2 = require('path');
  4. var require$$0$5 = require('fs');
  5. var require$$0$1 = require('os');
  6. var require$$1 = require('tty');
  7. var require$$0$3 = require('util');
  8. var require$$0$4 = require('stream');
  9. var require$$0$6 = require('events');
  10. var require$$0$7 = require('readline');
  11. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  12. var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
  13. var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
  14. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
  15. var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
  16. var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
  17. var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
  18. var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
  19. var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
  20. var require$$0 = require("./package.json");
  21. var semverCompare$1 = function cmp(a, b) {
  22. var pa = a.split('.');
  23. var pb = b.split('.');
  24. for (var i = 0; i < 3; i++) {
  25. var na = Number(pa[i]);
  26. var nb = Number(pb[i]);
  27. if (na > nb) return 1;
  28. if (nb > na) return -1;
  29. if (!isNaN(na) && isNaN(nb)) return 1;
  30. if (isNaN(na) && !isNaN(nb)) return -1;
  31. }
  32. return 0;
  33. };
  34. var semverCompare = semverCompare$1;
  35. var pleaseUpgradeNode = function pleaseUpgradeNode(pkg, opts) {
  36. var opts = opts || {};
  37. var requiredVersion = pkg.engines.node.replace('>=', '');
  38. var currentVersion = process.version.replace('v', '');
  39. if (semverCompare(currentVersion, requiredVersion) === -1) {
  40. if (opts.message) {
  41. console.error(opts.message(requiredVersion));
  42. } else {
  43. console.error(pkg.name + ' requires at least version ' + requiredVersion + ' of Node, please upgrade');
  44. }
  45. if (opts.hasOwnProperty('exitCode')) {
  46. process.exit(opts.exitCode);
  47. } else {
  48. process.exit(1);
  49. }
  50. }
  51. };
  52. var check = function (it) {
  53. return it && it.Math == Math && it;
  54. };
  55. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  56. var global$r =
  57. // eslint-disable-next-line es/no-global-this -- safe
  58. check(typeof globalThis == 'object' && globalThis) ||
  59. check(typeof window == 'object' && window) ||
  60. // eslint-disable-next-line no-restricted-globals -- safe
  61. check(typeof self == 'object' && self) ||
  62. check(typeof global$r == 'object' && global$r) ||
  63. // eslint-disable-next-line no-new-func -- fallback
  64. (function () { return this; })() || Function('return this')();
  65. var objectGetOwnPropertyDescriptor = {};
  66. var fails$8 = function (exec) {
  67. try {
  68. return !!exec();
  69. } catch (error) {
  70. return true;
  71. }
  72. };
  73. var fails$7 = fails$8;
  74. // Detect IE8's incomplete defineProperty implementation
  75. var descriptors = !fails$7(function () {
  76. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  77. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  78. });
  79. var call$7 = Function.prototype.call;
  80. var functionCall = call$7.bind ? call$7.bind(call$7) : function () {
  81. return call$7.apply(call$7, arguments);
  82. };
  83. var objectPropertyIsEnumerable = {};
  84. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  85. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  86. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  87. // Nashorn ~ JDK8 bug
  88. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  89. // `Object.prototype.propertyIsEnumerable` method implementation
  90. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  91. objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  92. var descriptor = getOwnPropertyDescriptor$1(this, V);
  93. return !!descriptor && descriptor.enumerable;
  94. } : $propertyIsEnumerable;
  95. var createPropertyDescriptor$3 = function (bitmap, value) {
  96. return {
  97. enumerable: !(bitmap & 1),
  98. configurable: !(bitmap & 2),
  99. writable: !(bitmap & 4),
  100. value: value
  101. };
  102. };
  103. var FunctionPrototype$1 = Function.prototype;
  104. var bind$3 = FunctionPrototype$1.bind;
  105. var call$6 = FunctionPrototype$1.call;
  106. var callBind = bind$3 && bind$3.bind(call$6);
  107. var functionUncurryThis = bind$3 ? function (fn) {
  108. return fn && callBind(call$6, fn);
  109. } : function (fn) {
  110. return fn && function () {
  111. return call$6.apply(fn, arguments);
  112. };
  113. };
  114. var uncurryThis$c = functionUncurryThis;
  115. var toString$5 = uncurryThis$c({}.toString);
  116. var stringSlice = uncurryThis$c(''.slice);
  117. var classofRaw$1 = function (it) {
  118. return stringSlice(toString$5(it), 8, -1);
  119. };
  120. var global$q = global$r;
  121. var uncurryThis$b = functionUncurryThis;
  122. var fails$6 = fails$8;
  123. var classof$5 = classofRaw$1;
  124. var Object$4 = global$q.Object;
  125. var split = uncurryThis$b(''.split);
  126. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  127. var indexedObject = fails$6(function () {
  128. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  129. // eslint-disable-next-line no-prototype-builtins -- safe
  130. return !Object$4('z').propertyIsEnumerable(0);
  131. }) ? function (it) {
  132. return classof$5(it) == 'String' ? split(it, '') : Object$4(it);
  133. } : Object$4;
  134. var global$p = global$r;
  135. var TypeError$a = global$p.TypeError;
  136. // `RequireObjectCoercible` abstract operation
  137. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  138. var requireObjectCoercible$2 = function (it) {
  139. if (it == undefined) throw TypeError$a("Can't call method on " + it);
  140. return it;
  141. };
  142. // toObject with fallback for non-array-like ES3 strings
  143. var IndexedObject = indexedObject;
  144. var requireObjectCoercible$1 = requireObjectCoercible$2;
  145. var toIndexedObject$4 = function (it) {
  146. return IndexedObject(requireObjectCoercible$1(it));
  147. };
  148. // `IsCallable` abstract operation
  149. // https://tc39.es/ecma262/#sec-iscallable
  150. var isCallable$b = function (argument) {
  151. return typeof argument == 'function';
  152. };
  153. var isCallable$a = isCallable$b;
  154. var isObject$d = function (it) {
  155. return typeof it == 'object' ? it !== null : isCallable$a(it);
  156. };
  157. var global$o = global$r;
  158. var isCallable$9 = isCallable$b;
  159. var aFunction = function (argument) {
  160. return isCallable$9(argument) ? argument : undefined;
  161. };
  162. var getBuiltIn$5 = function (namespace, method) {
  163. return arguments.length < 2 ? aFunction(global$o[namespace]) : global$o[namespace] && global$o[namespace][method];
  164. };
  165. var uncurryThis$a = functionUncurryThis;
  166. var objectIsPrototypeOf = uncurryThis$a({}.isPrototypeOf);
  167. var getBuiltIn$4 = getBuiltIn$5;
  168. var engineUserAgent = getBuiltIn$4('navigator', 'userAgent') || '';
  169. var global$n = global$r;
  170. var userAgent$2 = engineUserAgent;
  171. var process$1 = global$n.process;
  172. var Deno = global$n.Deno;
  173. var versions = process$1 && process$1.versions || Deno && Deno.version;
  174. var v8 = versions && versions.v8;
  175. var match, version;
  176. if (v8) {
  177. match = v8.split('.');
  178. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  179. // but their correct versions are not interesting for us
  180. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  181. }
  182. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  183. // so check `userAgent` even if `.v8` exists, but 0
  184. if (!version && userAgent$2) {
  185. match = userAgent$2.match(/Edge\/(\d+)/);
  186. if (!match || match[1] >= 74) {
  187. match = userAgent$2.match(/Chrome\/(\d+)/);
  188. if (match) version = +match[1];
  189. }
  190. }
  191. var engineV8Version = version;
  192. /* eslint-disable es/no-symbol -- required for testing */
  193. var V8_VERSION = engineV8Version;
  194. var fails$5 = fails$8;
  195. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  196. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$5(function () {
  197. var symbol = Symbol();
  198. // Chrome 38 Symbol has incorrect toString conversion
  199. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  200. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  201. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  202. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  203. });
  204. /* eslint-disable es/no-symbol -- required for testing */
  205. var NATIVE_SYMBOL$1 = nativeSymbol;
  206. var useSymbolAsUid = NATIVE_SYMBOL$1
  207. && !Symbol.sham
  208. && typeof Symbol.iterator == 'symbol';
  209. var global$m = global$r;
  210. var getBuiltIn$3 = getBuiltIn$5;
  211. var isCallable$8 = isCallable$b;
  212. var isPrototypeOf$1 = objectIsPrototypeOf;
  213. var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
  214. var Object$3 = global$m.Object;
  215. var isSymbol$6 = USE_SYMBOL_AS_UID$1 ? function (it) {
  216. return typeof it == 'symbol';
  217. } : function (it) {
  218. var $Symbol = getBuiltIn$3('Symbol');
  219. return isCallable$8($Symbol) && isPrototypeOf$1($Symbol.prototype, Object$3(it));
  220. };
  221. var global$l = global$r;
  222. var String$3 = global$l.String;
  223. var tryToString$3 = function (argument) {
  224. try {
  225. return String$3(argument);
  226. } catch (error) {
  227. return 'Object';
  228. }
  229. };
  230. var global$k = global$r;
  231. var isCallable$7 = isCallable$b;
  232. var tryToString$2 = tryToString$3;
  233. var TypeError$9 = global$k.TypeError;
  234. // `Assert: IsCallable(argument) is true`
  235. var aCallable$5 = function (argument) {
  236. if (isCallable$7(argument)) return argument;
  237. throw TypeError$9(tryToString$2(argument) + ' is not a function');
  238. };
  239. var aCallable$4 = aCallable$5;
  240. // `GetMethod` abstract operation
  241. // https://tc39.es/ecma262/#sec-getmethod
  242. var getMethod$3 = function (V, P) {
  243. var func = V[P];
  244. return func == null ? undefined : aCallable$4(func);
  245. };
  246. var global$j = global$r;
  247. var call$5 = functionCall;
  248. var isCallable$6 = isCallable$b;
  249. var isObject$c = isObject$d;
  250. var TypeError$8 = global$j.TypeError;
  251. // `OrdinaryToPrimitive` abstract operation
  252. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  253. var ordinaryToPrimitive$1 = function (input, pref) {
  254. var fn, val;
  255. if (pref === 'string' && isCallable$6(fn = input.toString) && !isObject$c(val = call$5(fn, input))) return val;
  256. if (isCallable$6(fn = input.valueOf) && !isObject$c(val = call$5(fn, input))) return val;
  257. if (pref !== 'string' && isCallable$6(fn = input.toString) && !isObject$c(val = call$5(fn, input))) return val;
  258. throw TypeError$8("Can't convert object to primitive value");
  259. };
  260. var shared$3 = {exports: {}};
  261. var global$i = global$r;
  262. // eslint-disable-next-line es/no-object-defineproperty -- safe
  263. var defineProperty$3 = Object.defineProperty;
  264. var setGlobal$3 = function (key, value) {
  265. try {
  266. defineProperty$3(global$i, key, { value: value, configurable: true, writable: true });
  267. } catch (error) {
  268. global$i[key] = value;
  269. } return value;
  270. };
  271. var global$h = global$r;
  272. var setGlobal$2 = setGlobal$3;
  273. var SHARED = '__core-js_shared__';
  274. var store$3 = global$h[SHARED] || setGlobal$2(SHARED, {});
  275. var sharedStore = store$3;
  276. var store$2 = sharedStore;
  277. (shared$3.exports = function (key, value) {
  278. return store$2[key] || (store$2[key] = value !== undefined ? value : {});
  279. })('versions', []).push({
  280. version: '3.19.1',
  281. mode: 'global',
  282. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  283. });
  284. var global$g = global$r;
  285. var requireObjectCoercible = requireObjectCoercible$2;
  286. var Object$2 = global$g.Object;
  287. // `ToObject` abstract operation
  288. // https://tc39.es/ecma262/#sec-toobject
  289. var toObject$4 = function (argument) {
  290. return Object$2(requireObjectCoercible(argument));
  291. };
  292. var uncurryThis$9 = functionUncurryThis;
  293. var toObject$3 = toObject$4;
  294. var hasOwnProperty$b = uncurryThis$9({}.hasOwnProperty);
  295. // `HasOwnProperty` abstract operation
  296. // https://tc39.es/ecma262/#sec-hasownproperty
  297. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  298. return hasOwnProperty$b(toObject$3(it), key);
  299. };
  300. var uncurryThis$8 = functionUncurryThis;
  301. var id = 0;
  302. var postfix = Math.random();
  303. var toString$4 = uncurryThis$8(1.0.toString);
  304. var uid$2 = function (key) {
  305. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$4(++id + postfix, 36);
  306. };
  307. var global$f = global$r;
  308. var shared$2 = shared$3.exports;
  309. var hasOwn$6 = hasOwnProperty_1;
  310. var uid$1 = uid$2;
  311. var NATIVE_SYMBOL = nativeSymbol;
  312. var USE_SYMBOL_AS_UID = useSymbolAsUid;
  313. var WellKnownSymbolsStore = shared$2('wks');
  314. var Symbol$7 = global$f.Symbol;
  315. var symbolFor = Symbol$7 && Symbol$7['for'];
  316. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$7 : Symbol$7 && Symbol$7.withoutSetter || uid$1;
  317. var wellKnownSymbol$7 = function (name) {
  318. if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  319. var description = 'Symbol.' + name;
  320. if (NATIVE_SYMBOL && hasOwn$6(Symbol$7, name)) {
  321. WellKnownSymbolsStore[name] = Symbol$7[name];
  322. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  323. WellKnownSymbolsStore[name] = symbolFor(description);
  324. } else {
  325. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  326. }
  327. } return WellKnownSymbolsStore[name];
  328. };
  329. var global$e = global$r;
  330. var call$4 = functionCall;
  331. var isObject$b = isObject$d;
  332. var isSymbol$5 = isSymbol$6;
  333. var getMethod$2 = getMethod$3;
  334. var ordinaryToPrimitive = ordinaryToPrimitive$1;
  335. var wellKnownSymbol$6 = wellKnownSymbol$7;
  336. var TypeError$7 = global$e.TypeError;
  337. var TO_PRIMITIVE = wellKnownSymbol$6('toPrimitive');
  338. // `ToPrimitive` abstract operation
  339. // https://tc39.es/ecma262/#sec-toprimitive
  340. var toPrimitive$1 = function (input, pref) {
  341. if (!isObject$b(input) || isSymbol$5(input)) return input;
  342. var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
  343. var result;
  344. if (exoticToPrim) {
  345. if (pref === undefined) pref = 'default';
  346. result = call$4(exoticToPrim, input, pref);
  347. if (!isObject$b(result) || isSymbol$5(result)) return result;
  348. throw TypeError$7("Can't convert object to primitive value");
  349. }
  350. if (pref === undefined) pref = 'number';
  351. return ordinaryToPrimitive(input, pref);
  352. };
  353. var toPrimitive = toPrimitive$1;
  354. var isSymbol$4 = isSymbol$6;
  355. // `ToPropertyKey` abstract operation
  356. // https://tc39.es/ecma262/#sec-topropertykey
  357. var toPropertyKey$3 = function (argument) {
  358. var key = toPrimitive(argument, 'string');
  359. return isSymbol$4(key) ? key : key + '';
  360. };
  361. var global$d = global$r;
  362. var isObject$a = isObject$d;
  363. var document$1 = global$d.document;
  364. // typeof document.createElement is 'object' in old IE
  365. var EXISTS$1 = isObject$a(document$1) && isObject$a(document$1.createElement);
  366. var documentCreateElement$1 = function (it) {
  367. return EXISTS$1 ? document$1.createElement(it) : {};
  368. };
  369. var DESCRIPTORS$5 = descriptors;
  370. var fails$4 = fails$8;
  371. var createElement = documentCreateElement$1;
  372. // Thank's IE8 for his funny defineProperty
  373. var ie8DomDefine = !DESCRIPTORS$5 && !fails$4(function () {
  374. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  375. return Object.defineProperty(createElement('div'), 'a', {
  376. get: function () { return 7; }
  377. }).a != 7;
  378. });
  379. var DESCRIPTORS$4 = descriptors;
  380. var call$3 = functionCall;
  381. var propertyIsEnumerableModule = objectPropertyIsEnumerable;
  382. var createPropertyDescriptor$2 = createPropertyDescriptor$3;
  383. var toIndexedObject$3 = toIndexedObject$4;
  384. var toPropertyKey$2 = toPropertyKey$3;
  385. var hasOwn$5 = hasOwnProperty_1;
  386. var IE8_DOM_DEFINE$1 = ie8DomDefine;
  387. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  388. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  389. // `Object.getOwnPropertyDescriptor` method
  390. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  391. objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  392. O = toIndexedObject$3(O);
  393. P = toPropertyKey$2(P);
  394. if (IE8_DOM_DEFINE$1) try {
  395. return $getOwnPropertyDescriptor(O, P);
  396. } catch (error) { /* empty */ }
  397. if (hasOwn$5(O, P)) return createPropertyDescriptor$2(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
  398. };
  399. var objectDefineProperty = {};
  400. var global$c = global$r;
  401. var isObject$9 = isObject$d;
  402. var String$2 = global$c.String;
  403. var TypeError$6 = global$c.TypeError;
  404. // `Assert: Type(argument) is Object`
  405. var anObject$7 = function (argument) {
  406. if (isObject$9(argument)) return argument;
  407. throw TypeError$6(String$2(argument) + ' is not an object');
  408. };
  409. var global$b = global$r;
  410. var DESCRIPTORS$3 = descriptors;
  411. var IE8_DOM_DEFINE = ie8DomDefine;
  412. var anObject$6 = anObject$7;
  413. var toPropertyKey$1 = toPropertyKey$3;
  414. var TypeError$5 = global$b.TypeError;
  415. // eslint-disable-next-line es/no-object-defineproperty -- safe
  416. var $defineProperty = Object.defineProperty;
  417. // `Object.defineProperty` method
  418. // https://tc39.es/ecma262/#sec-object.defineproperty
  419. objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
  420. anObject$6(O);
  421. P = toPropertyKey$1(P);
  422. anObject$6(Attributes);
  423. if (IE8_DOM_DEFINE) try {
  424. return $defineProperty(O, P, Attributes);
  425. } catch (error) { /* empty */ }
  426. if ('get' in Attributes || 'set' in Attributes) throw TypeError$5('Accessors not supported');
  427. if ('value' in Attributes) O[P] = Attributes.value;
  428. return O;
  429. };
  430. var DESCRIPTORS$2 = descriptors;
  431. var definePropertyModule$4 = objectDefineProperty;
  432. var createPropertyDescriptor$1 = createPropertyDescriptor$3;
  433. var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
  434. return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
  435. } : function (object, key, value) {
  436. object[key] = value;
  437. return object;
  438. };
  439. var redefine$1 = {exports: {}};
  440. var uncurryThis$7 = functionUncurryThis;
  441. var isCallable$5 = isCallable$b;
  442. var store$1 = sharedStore;
  443. var functionToString = uncurryThis$7(Function.toString);
  444. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  445. if (!isCallable$5(store$1.inspectSource)) {
  446. store$1.inspectSource = function (it) {
  447. return functionToString(it);
  448. };
  449. }
  450. var inspectSource$3 = store$1.inspectSource;
  451. var global$a = global$r;
  452. var isCallable$4 = isCallable$b;
  453. var inspectSource$2 = inspectSource$3;
  454. var WeakMap$4 = global$a.WeakMap;
  455. var nativeWeakMap = isCallable$4(WeakMap$4) && /native code/.test(inspectSource$2(WeakMap$4));
  456. var shared$1 = shared$3.exports;
  457. var uid = uid$2;
  458. var keys$4 = shared$1('keys');
  459. var sharedKey$2 = function (key) {
  460. return keys$4[key] || (keys$4[key] = uid(key));
  461. };
  462. var hiddenKeys$4 = {};
  463. var NATIVE_WEAK_MAP = nativeWeakMap;
  464. var global$9 = global$r;
  465. var uncurryThis$6 = functionUncurryThis;
  466. var isObject$8 = isObject$d;
  467. var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
  468. var hasOwn$4 = hasOwnProperty_1;
  469. var shared = sharedStore;
  470. var sharedKey$1 = sharedKey$2;
  471. var hiddenKeys$3 = hiddenKeys$4;
  472. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  473. var TypeError$4 = global$9.TypeError;
  474. var WeakMap$3 = global$9.WeakMap;
  475. var set, get$2, has;
  476. var enforce = function (it) {
  477. return has(it) ? get$2(it) : set(it, {});
  478. };
  479. var getterFor = function (TYPE) {
  480. return function (it) {
  481. var state;
  482. if (!isObject$8(it) || (state = get$2(it)).type !== TYPE) {
  483. throw TypeError$4('Incompatible receiver, ' + TYPE + ' required');
  484. } return state;
  485. };
  486. };
  487. if (NATIVE_WEAK_MAP || shared.state) {
  488. var store = shared.state || (shared.state = new WeakMap$3());
  489. var wmget = uncurryThis$6(store.get);
  490. var wmhas = uncurryThis$6(store.has);
  491. var wmset = uncurryThis$6(store.set);
  492. set = function (it, metadata) {
  493. if (wmhas(store, it)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
  494. metadata.facade = it;
  495. wmset(store, it, metadata);
  496. return metadata;
  497. };
  498. get$2 = function (it) {
  499. return wmget(store, it) || {};
  500. };
  501. has = function (it) {
  502. return wmhas(store, it);
  503. };
  504. } else {
  505. var STATE = sharedKey$1('state');
  506. hiddenKeys$3[STATE] = true;
  507. set = function (it, metadata) {
  508. if (hasOwn$4(it, STATE)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
  509. metadata.facade = it;
  510. createNonEnumerableProperty$2(it, STATE, metadata);
  511. return metadata;
  512. };
  513. get$2 = function (it) {
  514. return hasOwn$4(it, STATE) ? it[STATE] : {};
  515. };
  516. has = function (it) {
  517. return hasOwn$4(it, STATE);
  518. };
  519. }
  520. var internalState = {
  521. set: set,
  522. get: get$2,
  523. has: has,
  524. enforce: enforce,
  525. getterFor: getterFor
  526. };
  527. var DESCRIPTORS$1 = descriptors;
  528. var hasOwn$3 = hasOwnProperty_1;
  529. var FunctionPrototype = Function.prototype;
  530. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  531. var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
  532. var EXISTS = hasOwn$3(FunctionPrototype, 'name');
  533. // additional protection from minified / mangled / dropped function names
  534. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  535. var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
  536. var functionName = {
  537. EXISTS: EXISTS,
  538. PROPER: PROPER,
  539. CONFIGURABLE: CONFIGURABLE
  540. };
  541. var global$8 = global$r;
  542. var isCallable$3 = isCallable$b;
  543. var hasOwn$2 = hasOwnProperty_1;
  544. var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
  545. var setGlobal$1 = setGlobal$3;
  546. var inspectSource$1 = inspectSource$3;
  547. var InternalStateModule = internalState;
  548. var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
  549. var getInternalState = InternalStateModule.get;
  550. var enforceInternalState = InternalStateModule.enforce;
  551. var TEMPLATE = String(String).split('String');
  552. (redefine$1.exports = function (O, key, value, options) {
  553. var unsafe = options ? !!options.unsafe : false;
  554. var simple = options ? !!options.enumerable : false;
  555. var noTargetGet = options ? !!options.noTargetGet : false;
  556. var name = options && options.name !== undefined ? options.name : key;
  557. var state;
  558. if (isCallable$3(value)) {
  559. if (String(name).slice(0, 7) === 'Symbol(') {
  560. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  561. }
  562. if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  563. createNonEnumerableProperty$1(value, 'name', name);
  564. }
  565. state = enforceInternalState(value);
  566. if (!state.source) {
  567. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  568. }
  569. }
  570. if (O === global$8) {
  571. if (simple) O[key] = value;
  572. else setGlobal$1(key, value);
  573. return;
  574. } else if (!unsafe) {
  575. delete O[key];
  576. } else if (!noTargetGet && O[key]) {
  577. simple = true;
  578. }
  579. if (simple) O[key] = value;
  580. else createNonEnumerableProperty$1(O, key, value);
  581. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  582. })(Function.prototype, 'toString', function toString() {
  583. return isCallable$3(this) && getInternalState(this).source || inspectSource$1(this);
  584. });
  585. var objectGetOwnPropertyNames = {};
  586. var ceil = Math.ceil;
  587. var floor$1 = Math.floor;
  588. // `ToIntegerOrInfinity` abstract operation
  589. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  590. var toIntegerOrInfinity$3 = function (argument) {
  591. var number = +argument;
  592. // eslint-disable-next-line no-self-compare -- safe
  593. return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
  594. };
  595. var toIntegerOrInfinity$2 = toIntegerOrInfinity$3;
  596. var max = Math.max;
  597. var min$1 = Math.min;
  598. // Helper for a popular repeating case of the spec:
  599. // Let integer be ? ToInteger(index).
  600. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  601. var toAbsoluteIndex$1 = function (index, length) {
  602. var integer = toIntegerOrInfinity$2(index);
  603. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  604. };
  605. var toIntegerOrInfinity$1 = toIntegerOrInfinity$3;
  606. var min = Math.min;
  607. // `ToLength` abstract operation
  608. // https://tc39.es/ecma262/#sec-tolength
  609. var toLength$1 = function (argument) {
  610. return argument > 0 ? min(toIntegerOrInfinity$1(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  611. };
  612. var toLength = toLength$1;
  613. // `LengthOfArrayLike` abstract operation
  614. // https://tc39.es/ecma262/#sec-lengthofarraylike
  615. var lengthOfArrayLike$6 = function (obj) {
  616. return toLength(obj.length);
  617. };
  618. var toIndexedObject$2 = toIndexedObject$4;
  619. var toAbsoluteIndex = toAbsoluteIndex$1;
  620. var lengthOfArrayLike$5 = lengthOfArrayLike$6;
  621. // `Array.prototype.{ indexOf, includes }` methods implementation
  622. var createMethod = function (IS_INCLUDES) {
  623. return function ($this, el, fromIndex) {
  624. var O = toIndexedObject$2($this);
  625. var length = lengthOfArrayLike$5(O);
  626. var index = toAbsoluteIndex(fromIndex, length);
  627. var value;
  628. // Array#includes uses SameValueZero equality algorithm
  629. // eslint-disable-next-line no-self-compare -- NaN check
  630. if (IS_INCLUDES && el != el) while (length > index) {
  631. value = O[index++];
  632. // eslint-disable-next-line no-self-compare -- NaN check
  633. if (value != value) return true;
  634. // Array#indexOf ignores holes, Array#includes - not
  635. } else for (;length > index; index++) {
  636. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  637. } return !IS_INCLUDES && -1;
  638. };
  639. };
  640. var arrayIncludes = {
  641. // `Array.prototype.includes` method
  642. // https://tc39.es/ecma262/#sec-array.prototype.includes
  643. includes: createMethod(true),
  644. // `Array.prototype.indexOf` method
  645. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  646. indexOf: createMethod(false)
  647. };
  648. var uncurryThis$5 = functionUncurryThis;
  649. var hasOwn$1 = hasOwnProperty_1;
  650. var toIndexedObject$1 = toIndexedObject$4;
  651. var indexOf = arrayIncludes.indexOf;
  652. var hiddenKeys$2 = hiddenKeys$4;
  653. var push$1 = uncurryThis$5([].push);
  654. var objectKeysInternal = function (object, names) {
  655. var O = toIndexedObject$1(object);
  656. var i = 0;
  657. var result = [];
  658. var key;
  659. for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && push$1(result, key);
  660. // Don't enum bug & hidden keys
  661. while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
  662. ~indexOf(result, key) || push$1(result, key);
  663. }
  664. return result;
  665. };
  666. // IE8- don't enum bug keys
  667. var enumBugKeys$3 = [
  668. 'constructor',
  669. 'hasOwnProperty',
  670. 'isPrototypeOf',
  671. 'propertyIsEnumerable',
  672. 'toLocaleString',
  673. 'toString',
  674. 'valueOf'
  675. ];
  676. var internalObjectKeys$1 = objectKeysInternal;
  677. var enumBugKeys$2 = enumBugKeys$3;
  678. var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
  679. // `Object.getOwnPropertyNames` method
  680. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  681. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  682. objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  683. return internalObjectKeys$1(O, hiddenKeys$1);
  684. };
  685. var objectGetOwnPropertySymbols = {};
  686. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  687. objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
  688. var getBuiltIn$2 = getBuiltIn$5;
  689. var uncurryThis$4 = functionUncurryThis;
  690. var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
  691. var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
  692. var anObject$5 = anObject$7;
  693. var concat = uncurryThis$4([].concat);
  694. // all object keys, includes non-enumerable and symbols
  695. var ownKeys$1 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
  696. var keys = getOwnPropertyNamesModule.f(anObject$5(it));
  697. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  698. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  699. };
  700. var hasOwn = hasOwnProperty_1;
  701. var ownKeys = ownKeys$1;
  702. var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
  703. var definePropertyModule$3 = objectDefineProperty;
  704. var copyConstructorProperties$1 = function (target, source) {
  705. var keys = ownKeys(source);
  706. var defineProperty = definePropertyModule$3.f;
  707. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  708. for (var i = 0; i < keys.length; i++) {
  709. var key = keys[i];
  710. if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  711. }
  712. };
  713. var fails$3 = fails$8;
  714. var isCallable$2 = isCallable$b;
  715. var replacement = /#|\.prototype\./;
  716. var isForced$1 = function (feature, detection) {
  717. var value = data[normalize(feature)];
  718. return value == POLYFILL ? true
  719. : value == NATIVE ? false
  720. : isCallable$2(detection) ? fails$3(detection)
  721. : !!detection;
  722. };
  723. var normalize = isForced$1.normalize = function (string) {
  724. return String(string).replace(replacement, '.').toLowerCase();
  725. };
  726. var data = isForced$1.data = {};
  727. var NATIVE = isForced$1.NATIVE = 'N';
  728. var POLYFILL = isForced$1.POLYFILL = 'P';
  729. var isForced_1 = isForced$1;
  730. var global$7 = global$r;
  731. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  732. var createNonEnumerableProperty = createNonEnumerableProperty$3;
  733. var redefine = redefine$1.exports;
  734. var setGlobal = setGlobal$3;
  735. var copyConstructorProperties = copyConstructorProperties$1;
  736. var isForced = isForced_1;
  737. /*
  738. options.target - name of the target object
  739. options.global - target is the global object
  740. options.stat - export as static methods of target
  741. options.proto - export as prototype methods of target
  742. options.real - real prototype method for the `pure` version
  743. options.forced - export even if the native feature is available
  744. options.bind - bind methods to the target, required for the `pure` version
  745. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  746. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  747. options.sham - add a flag to not completely full polyfills
  748. options.enumerable - export as enumerable property
  749. options.noTargetGet - prevent calling a getter on target
  750. options.name - the .name of the function if it does not match the key
  751. */
  752. var _export = function (options, source) {
  753. var TARGET = options.target;
  754. var GLOBAL = options.global;
  755. var STATIC = options.stat;
  756. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  757. if (GLOBAL) {
  758. target = global$7;
  759. } else if (STATIC) {
  760. target = global$7[TARGET] || setGlobal(TARGET, {});
  761. } else {
  762. target = (global$7[TARGET] || {}).prototype;
  763. }
  764. if (target) for (key in source) {
  765. sourceProperty = source[key];
  766. if (options.noTargetGet) {
  767. descriptor = getOwnPropertyDescriptor(target, key);
  768. targetProperty = descriptor && descriptor.value;
  769. } else targetProperty = target[key];
  770. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  771. // contained in target
  772. if (!FORCED && targetProperty !== undefined) {
  773. if (typeof sourceProperty == typeof targetProperty) continue;
  774. copyConstructorProperties(sourceProperty, targetProperty);
  775. }
  776. // add a flag to not completely full polyfills
  777. if (options.sham || (targetProperty && targetProperty.sham)) {
  778. createNonEnumerableProperty(sourceProperty, 'sham', true);
  779. }
  780. // extend global
  781. redefine(target, key, sourceProperty, options);
  782. }
  783. };
  784. var wellKnownSymbol$5 = wellKnownSymbol$7;
  785. var TO_STRING_TAG$1 = wellKnownSymbol$5('toStringTag');
  786. var test$1 = {};
  787. test$1[TO_STRING_TAG$1] = 'z';
  788. var toStringTagSupport = String(test$1) === '[object z]';
  789. var global$6 = global$r;
  790. var TO_STRING_TAG_SUPPORT = toStringTagSupport;
  791. var isCallable$1 = isCallable$b;
  792. var classofRaw = classofRaw$1;
  793. var wellKnownSymbol$4 = wellKnownSymbol$7;
  794. var TO_STRING_TAG = wellKnownSymbol$4('toStringTag');
  795. var Object$1 = global$6.Object;
  796. // ES3 wrong here
  797. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  798. // fallback for IE11 Script Access Denied error
  799. var tryGet = function (it, key) {
  800. try {
  801. return it[key];
  802. } catch (error) { /* empty */ }
  803. };
  804. // getting tag from ES6+ `Object.prototype.toString`
  805. var classof$4 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  806. var O, tag, result;
  807. return it === undefined ? 'Undefined' : it === null ? 'Null'
  808. // @@toStringTag case
  809. : typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
  810. // builtinTag case
  811. : CORRECT_ARGUMENTS ? classofRaw(O)
  812. // ES3 arguments fallback
  813. : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
  814. };
  815. var global$5 = global$r;
  816. var classof$3 = classof$4;
  817. var String$1 = global$5.String;
  818. var toString$3 = function (argument) {
  819. if (classof$3(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  820. return String$1(argument);
  821. };
  822. var uncurryThis$3 = functionUncurryThis;
  823. var arraySlice$1 = uncurryThis$3([].slice);
  824. var arraySlice = arraySlice$1;
  825. var floor = Math.floor;
  826. var mergeSort = function (array, comparefn) {
  827. var length = array.length;
  828. var middle = floor(length / 2);
  829. return length < 8 ? insertionSort(array, comparefn) : merge$3(
  830. array,
  831. mergeSort(arraySlice(array, 0, middle), comparefn),
  832. mergeSort(arraySlice(array, middle), comparefn),
  833. comparefn
  834. );
  835. };
  836. var insertionSort = function (array, comparefn) {
  837. var length = array.length;
  838. var i = 1;
  839. var element, j;
  840. while (i < length) {
  841. j = i;
  842. element = array[i];
  843. while (j && comparefn(array[j - 1], element) > 0) {
  844. array[j] = array[--j];
  845. }
  846. if (j !== i++) array[j] = element;
  847. } return array;
  848. };
  849. var merge$3 = function (array, left, right, comparefn) {
  850. var llength = left.length;
  851. var rlength = right.length;
  852. var lindex = 0;
  853. var rindex = 0;
  854. while (lindex < llength || rindex < rlength) {
  855. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  856. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  857. : lindex < llength ? left[lindex++] : right[rindex++];
  858. } return array;
  859. };
  860. var arraySort = mergeSort;
  861. var fails$2 = fails$8;
  862. var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
  863. var method = [][METHOD_NAME];
  864. return !!method && fails$2(function () {
  865. // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
  866. method.call(null, argument || function () { throw 1; }, 1);
  867. });
  868. };
  869. var userAgent$1 = engineUserAgent;
  870. var firefox = userAgent$1.match(/firefox\/(\d+)/i);
  871. var engineFfVersion = !!firefox && +firefox[1];
  872. var UA = engineUserAgent;
  873. var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
  874. var userAgent = engineUserAgent;
  875. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  876. var engineWebkitVersion = !!webkit && +webkit[1];
  877. var $$3 = _export;
  878. var uncurryThis$2 = functionUncurryThis;
  879. var aCallable$3 = aCallable$5;
  880. var toObject$2 = toObject$4;
  881. var lengthOfArrayLike$4 = lengthOfArrayLike$6;
  882. var toString$2 = toString$3;
  883. var fails$1 = fails$8;
  884. var internalSort = arraySort;
  885. var arrayMethodIsStrict = arrayMethodIsStrict$1;
  886. var FF = engineFfVersion;
  887. var IE_OR_EDGE = engineIsIeOrEdge;
  888. var V8 = engineV8Version;
  889. var WEBKIT = engineWebkitVersion;
  890. var test = [];
  891. var un$Sort = uncurryThis$2(test.sort);
  892. var push = uncurryThis$2(test.push);
  893. // IE8-
  894. var FAILS_ON_UNDEFINED = fails$1(function () {
  895. test.sort(undefined);
  896. });
  897. // V8 bug
  898. var FAILS_ON_NULL = fails$1(function () {
  899. test.sort(null);
  900. });
  901. // Old WebKit
  902. var STRICT_METHOD = arrayMethodIsStrict('sort');
  903. var STABLE_SORT = !fails$1(function () {
  904. // feature detection can be too slow, so check engines versions
  905. if (V8) return V8 < 70;
  906. if (FF && FF > 3) return;
  907. if (IE_OR_EDGE) return true;
  908. if (WEBKIT) return WEBKIT < 603;
  909. var result = '';
  910. var code, chr, value, index;
  911. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  912. for (code = 65; code < 76; code++) {
  913. chr = String.fromCharCode(code);
  914. switch (code) {
  915. case 66: case 69: case 70: case 72: value = 3; break;
  916. case 68: case 71: value = 4; break;
  917. default: value = 2;
  918. }
  919. for (index = 0; index < 47; index++) {
  920. test.push({ k: chr + index, v: value });
  921. }
  922. }
  923. test.sort(function (a, b) { return b.v - a.v; });
  924. for (index = 0; index < test.length; index++) {
  925. chr = test[index].k.charAt(0);
  926. if (result.charAt(result.length - 1) !== chr) result += chr;
  927. }
  928. return result !== 'DGBEFHACIJK';
  929. });
  930. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  931. var getSortCompare = function (comparefn) {
  932. return function (x, y) {
  933. if (y === undefined) return -1;
  934. if (x === undefined) return 1;
  935. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  936. return toString$2(x) > toString$2(y) ? 1 : -1;
  937. };
  938. };
  939. // `Array.prototype.sort` method
  940. // https://tc39.es/ecma262/#sec-array.prototype.sort
  941. $$3({ target: 'Array', proto: true, forced: FORCED }, {
  942. sort: function sort(comparefn) {
  943. if (comparefn !== undefined) aCallable$3(comparefn);
  944. var array = toObject$2(this);
  945. if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
  946. var items = [];
  947. var arrayLength = lengthOfArrayLike$4(array);
  948. var itemsLength, index;
  949. for (index = 0; index < arrayLength; index++) {
  950. if (index in array) push(items, array[index]);
  951. }
  952. internalSort(items, getSortCompare(comparefn));
  953. itemsLength = items.length;
  954. index = 0;
  955. while (index < itemsLength) array[index] = items[index++];
  956. while (index < arrayLength) delete array[index++];
  957. return array;
  958. }
  959. });
  960. var fastJsonStableStringify = function (data, opts) {
  961. if (!opts) opts = {};
  962. if (typeof opts === 'function') opts = {
  963. cmp: opts
  964. };
  965. var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
  966. var cmp = opts.cmp && function (f) {
  967. return function (node) {
  968. return function (a, b) {
  969. var aobj = {
  970. key: a,
  971. value: node[a]
  972. };
  973. var bobj = {
  974. key: b,
  975. value: node[b]
  976. };
  977. return f(aobj, bobj);
  978. };
  979. };
  980. }(opts.cmp);
  981. var seen = [];
  982. return function stringify(node) {
  983. if (node && node.toJSON && typeof node.toJSON === 'function') {
  984. node = node.toJSON();
  985. }
  986. if (node === undefined) return;
  987. if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
  988. if (typeof node !== 'object') return JSON.stringify(node);
  989. var i, out;
  990. if (Array.isArray(node)) {
  991. out = '[';
  992. for (i = 0; i < node.length; i++) {
  993. if (i) out += ',';
  994. out += stringify(node[i]) || 'null';
  995. }
  996. return out + ']';
  997. }
  998. if (node === null) return 'null';
  999. if (seen.indexOf(node) !== -1) {
  1000. if (cycles) return JSON.stringify('__cycle__');
  1001. throw new TypeError('Converting circular structure to JSON');
  1002. }
  1003. var seenIndex = seen.push(node) - 1;
  1004. var keys = Object.keys(node).sort(cmp && cmp(node));
  1005. out = '';
  1006. for (i = 0; i < keys.length; i++) {
  1007. var key = keys[i];
  1008. var value = stringify(node[key]);
  1009. if (!value) continue;
  1010. if (out) out += ',';
  1011. out += JSON.stringify(key) + ':' + value;
  1012. }
  1013. seen.splice(seenIndex, 1);
  1014. return '{' + out + '}';
  1015. }(data);
  1016. };
  1017. var require$$3 = require("./index.js");
  1018. var ansiStyles$1 = {exports: {}};
  1019. var colorName = {
  1020. "aliceblue": [240, 248, 255],
  1021. "antiquewhite": [250, 235, 215],
  1022. "aqua": [0, 255, 255],
  1023. "aquamarine": [127, 255, 212],
  1024. "azure": [240, 255, 255],
  1025. "beige": [245, 245, 220],
  1026. "bisque": [255, 228, 196],
  1027. "black": [0, 0, 0],
  1028. "blanchedalmond": [255, 235, 205],
  1029. "blue": [0, 0, 255],
  1030. "blueviolet": [138, 43, 226],
  1031. "brown": [165, 42, 42],
  1032. "burlywood": [222, 184, 135],
  1033. "cadetblue": [95, 158, 160],
  1034. "chartreuse": [127, 255, 0],
  1035. "chocolate": [210, 105, 30],
  1036. "coral": [255, 127, 80],
  1037. "cornflowerblue": [100, 149, 237],
  1038. "cornsilk": [255, 248, 220],
  1039. "crimson": [220, 20, 60],
  1040. "cyan": [0, 255, 255],
  1041. "darkblue": [0, 0, 139],
  1042. "darkcyan": [0, 139, 139],
  1043. "darkgoldenrod": [184, 134, 11],
  1044. "darkgray": [169, 169, 169],
  1045. "darkgreen": [0, 100, 0],
  1046. "darkgrey": [169, 169, 169],
  1047. "darkkhaki": [189, 183, 107],
  1048. "darkmagenta": [139, 0, 139],
  1049. "darkolivegreen": [85, 107, 47],
  1050. "darkorange": [255, 140, 0],
  1051. "darkorchid": [153, 50, 204],
  1052. "darkred": [139, 0, 0],
  1053. "darksalmon": [233, 150, 122],
  1054. "darkseagreen": [143, 188, 143],
  1055. "darkslateblue": [72, 61, 139],
  1056. "darkslategray": [47, 79, 79],
  1057. "darkslategrey": [47, 79, 79],
  1058. "darkturquoise": [0, 206, 209],
  1059. "darkviolet": [148, 0, 211],
  1060. "deeppink": [255, 20, 147],
  1061. "deepskyblue": [0, 191, 255],
  1062. "dimgray": [105, 105, 105],
  1063. "dimgrey": [105, 105, 105],
  1064. "dodgerblue": [30, 144, 255],
  1065. "firebrick": [178, 34, 34],
  1066. "floralwhite": [255, 250, 240],
  1067. "forestgreen": [34, 139, 34],
  1068. "fuchsia": [255, 0, 255],
  1069. "gainsboro": [220, 220, 220],
  1070. "ghostwhite": [248, 248, 255],
  1071. "gold": [255, 215, 0],
  1072. "goldenrod": [218, 165, 32],
  1073. "gray": [128, 128, 128],
  1074. "green": [0, 128, 0],
  1075. "greenyellow": [173, 255, 47],
  1076. "grey": [128, 128, 128],
  1077. "honeydew": [240, 255, 240],
  1078. "hotpink": [255, 105, 180],
  1079. "indianred": [205, 92, 92],
  1080. "indigo": [75, 0, 130],
  1081. "ivory": [255, 255, 240],
  1082. "khaki": [240, 230, 140],
  1083. "lavender": [230, 230, 250],
  1084. "lavenderblush": [255, 240, 245],
  1085. "lawngreen": [124, 252, 0],
  1086. "lemonchiffon": [255, 250, 205],
  1087. "lightblue": [173, 216, 230],
  1088. "lightcoral": [240, 128, 128],
  1089. "lightcyan": [224, 255, 255],
  1090. "lightgoldenrodyellow": [250, 250, 210],
  1091. "lightgray": [211, 211, 211],
  1092. "lightgreen": [144, 238, 144],
  1093. "lightgrey": [211, 211, 211],
  1094. "lightpink": [255, 182, 193],
  1095. "lightsalmon": [255, 160, 122],
  1096. "lightseagreen": [32, 178, 170],
  1097. "lightskyblue": [135, 206, 250],
  1098. "lightslategray": [119, 136, 153],
  1099. "lightslategrey": [119, 136, 153],
  1100. "lightsteelblue": [176, 196, 222],
  1101. "lightyellow": [255, 255, 224],
  1102. "lime": [0, 255, 0],
  1103. "limegreen": [50, 205, 50],
  1104. "linen": [250, 240, 230],
  1105. "magenta": [255, 0, 255],
  1106. "maroon": [128, 0, 0],
  1107. "mediumaquamarine": [102, 205, 170],
  1108. "mediumblue": [0, 0, 205],
  1109. "mediumorchid": [186, 85, 211],
  1110. "mediumpurple": [147, 112, 219],
  1111. "mediumseagreen": [60, 179, 113],
  1112. "mediumslateblue": [123, 104, 238],
  1113. "mediumspringgreen": [0, 250, 154],
  1114. "mediumturquoise": [72, 209, 204],
  1115. "mediumvioletred": [199, 21, 133],
  1116. "midnightblue": [25, 25, 112],
  1117. "mintcream": [245, 255, 250],
  1118. "mistyrose": [255, 228, 225],
  1119. "moccasin": [255, 228, 181],
  1120. "navajowhite": [255, 222, 173],
  1121. "navy": [0, 0, 128],
  1122. "oldlace": [253, 245, 230],
  1123. "olive": [128, 128, 0],
  1124. "olivedrab": [107, 142, 35],
  1125. "orange": [255, 165, 0],
  1126. "orangered": [255, 69, 0],
  1127. "orchid": [218, 112, 214],
  1128. "palegoldenrod": [238, 232, 170],
  1129. "palegreen": [152, 251, 152],
  1130. "paleturquoise": [175, 238, 238],
  1131. "palevioletred": [219, 112, 147],
  1132. "papayawhip": [255, 239, 213],
  1133. "peachpuff": [255, 218, 185],
  1134. "peru": [205, 133, 63],
  1135. "pink": [255, 192, 203],
  1136. "plum": [221, 160, 221],
  1137. "powderblue": [176, 224, 230],
  1138. "purple": [128, 0, 128],
  1139. "rebeccapurple": [102, 51, 153],
  1140. "red": [255, 0, 0],
  1141. "rosybrown": [188, 143, 143],
  1142. "royalblue": [65, 105, 225],
  1143. "saddlebrown": [139, 69, 19],
  1144. "salmon": [250, 128, 114],
  1145. "sandybrown": [244, 164, 96],
  1146. "seagreen": [46, 139, 87],
  1147. "seashell": [255, 245, 238],
  1148. "sienna": [160, 82, 45],
  1149. "silver": [192, 192, 192],
  1150. "skyblue": [135, 206, 235],
  1151. "slateblue": [106, 90, 205],
  1152. "slategray": [112, 128, 144],
  1153. "slategrey": [112, 128, 144],
  1154. "snow": [255, 250, 250],
  1155. "springgreen": [0, 255, 127],
  1156. "steelblue": [70, 130, 180],
  1157. "tan": [210, 180, 140],
  1158. "teal": [0, 128, 128],
  1159. "thistle": [216, 191, 216],
  1160. "tomato": [255, 99, 71],
  1161. "turquoise": [64, 224, 208],
  1162. "violet": [238, 130, 238],
  1163. "wheat": [245, 222, 179],
  1164. "white": [255, 255, 255],
  1165. "whitesmoke": [245, 245, 245],
  1166. "yellow": [255, 255, 0],
  1167. "yellowgreen": [154, 205, 50]
  1168. };
  1169. /* MIT license */
  1170. /* eslint-disable no-mixed-operators */
  1171. const cssKeywords = colorName; // NOTE: conversions should only return primitive values (i.e. arrays, or
  1172. // values that give correct `typeof` results).
  1173. // do not use box values types (i.e. Number(), String(), etc.)
  1174. const reverseKeywords = {};
  1175. for (const key of Object.keys(cssKeywords)) {
  1176. reverseKeywords[cssKeywords[key]] = key;
  1177. }
  1178. const convert$1 = {
  1179. rgb: {
  1180. channels: 3,
  1181. labels: 'rgb'
  1182. },
  1183. hsl: {
  1184. channels: 3,
  1185. labels: 'hsl'
  1186. },
  1187. hsv: {
  1188. channels: 3,
  1189. labels: 'hsv'
  1190. },
  1191. hwb: {
  1192. channels: 3,
  1193. labels: 'hwb'
  1194. },
  1195. cmyk: {
  1196. channels: 4,
  1197. labels: 'cmyk'
  1198. },
  1199. xyz: {
  1200. channels: 3,
  1201. labels: 'xyz'
  1202. },
  1203. lab: {
  1204. channels: 3,
  1205. labels: 'lab'
  1206. },
  1207. lch: {
  1208. channels: 3,
  1209. labels: 'lch'
  1210. },
  1211. hex: {
  1212. channels: 1,
  1213. labels: ['hex']
  1214. },
  1215. keyword: {
  1216. channels: 1,
  1217. labels: ['keyword']
  1218. },
  1219. ansi16: {
  1220. channels: 1,
  1221. labels: ['ansi16']
  1222. },
  1223. ansi256: {
  1224. channels: 1,
  1225. labels: ['ansi256']
  1226. },
  1227. hcg: {
  1228. channels: 3,
  1229. labels: ['h', 'c', 'g']
  1230. },
  1231. apple: {
  1232. channels: 3,
  1233. labels: ['r16', 'g16', 'b16']
  1234. },
  1235. gray: {
  1236. channels: 1,
  1237. labels: ['gray']
  1238. }
  1239. };
  1240. var conversions$2 = convert$1; // Hide .channels and .labels properties
  1241. for (const model of Object.keys(convert$1)) {
  1242. if (!('channels' in convert$1[model])) {
  1243. throw new Error('missing channels property: ' + model);
  1244. }
  1245. if (!('labels' in convert$1[model])) {
  1246. throw new Error('missing channel labels property: ' + model);
  1247. }
  1248. if (convert$1[model].labels.length !== convert$1[model].channels) {
  1249. throw new Error('channel and label counts mismatch: ' + model);
  1250. }
  1251. const {
  1252. channels,
  1253. labels
  1254. } = convert$1[model];
  1255. delete convert$1[model].channels;
  1256. delete convert$1[model].labels;
  1257. Object.defineProperty(convert$1[model], 'channels', {
  1258. value: channels
  1259. });
  1260. Object.defineProperty(convert$1[model], 'labels', {
  1261. value: labels
  1262. });
  1263. }
  1264. convert$1.rgb.hsl = function (rgb) {
  1265. const r = rgb[0] / 255;
  1266. const g = rgb[1] / 255;
  1267. const b = rgb[2] / 255;
  1268. const min = Math.min(r, g, b);
  1269. const max = Math.max(r, g, b);
  1270. const delta = max - min;
  1271. let h;
  1272. let s;
  1273. if (max === min) {
  1274. h = 0;
  1275. } else if (r === max) {
  1276. h = (g - b) / delta;
  1277. } else if (g === max) {
  1278. h = 2 + (b - r) / delta;
  1279. } else if (b === max) {
  1280. h = 4 + (r - g) / delta;
  1281. }
  1282. h = Math.min(h * 60, 360);
  1283. if (h < 0) {
  1284. h += 360;
  1285. }
  1286. const l = (min + max) / 2;
  1287. if (max === min) {
  1288. s = 0;
  1289. } else if (l <= 0.5) {
  1290. s = delta / (max + min);
  1291. } else {
  1292. s = delta / (2 - max - min);
  1293. }
  1294. return [h, s * 100, l * 100];
  1295. };
  1296. convert$1.rgb.hsv = function (rgb) {
  1297. let rdif;
  1298. let gdif;
  1299. let bdif;
  1300. let h;
  1301. let s;
  1302. const r = rgb[0] / 255;
  1303. const g = rgb[1] / 255;
  1304. const b = rgb[2] / 255;
  1305. const v = Math.max(r, g, b);
  1306. const diff = v - Math.min(r, g, b);
  1307. const diffc = function (c) {
  1308. return (v - c) / 6 / diff + 1 / 2;
  1309. };
  1310. if (diff === 0) {
  1311. h = 0;
  1312. s = 0;
  1313. } else {
  1314. s = diff / v;
  1315. rdif = diffc(r);
  1316. gdif = diffc(g);
  1317. bdif = diffc(b);
  1318. if (r === v) {
  1319. h = bdif - gdif;
  1320. } else if (g === v) {
  1321. h = 1 / 3 + rdif - bdif;
  1322. } else if (b === v) {
  1323. h = 2 / 3 + gdif - rdif;
  1324. }
  1325. if (h < 0) {
  1326. h += 1;
  1327. } else if (h > 1) {
  1328. h -= 1;
  1329. }
  1330. }
  1331. return [h * 360, s * 100, v * 100];
  1332. };
  1333. convert$1.rgb.hwb = function (rgb) {
  1334. const r = rgb[0];
  1335. const g = rgb[1];
  1336. let b = rgb[2];
  1337. const h = convert$1.rgb.hsl(rgb)[0];
  1338. const w = 1 / 255 * Math.min(r, Math.min(g, b));
  1339. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  1340. return [h, w * 100, b * 100];
  1341. };
  1342. convert$1.rgb.cmyk = function (rgb) {
  1343. const r = rgb[0] / 255;
  1344. const g = rgb[1] / 255;
  1345. const b = rgb[2] / 255;
  1346. const k = Math.min(1 - r, 1 - g, 1 - b);
  1347. const c = (1 - r - k) / (1 - k) || 0;
  1348. const m = (1 - g - k) / (1 - k) || 0;
  1349. const y = (1 - b - k) / (1 - k) || 0;
  1350. return [c * 100, m * 100, y * 100, k * 100];
  1351. };
  1352. function comparativeDistance(x, y) {
  1353. /*
  1354. See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  1355. */
  1356. return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
  1357. }
  1358. convert$1.rgb.keyword = function (rgb) {
  1359. const reversed = reverseKeywords[rgb];
  1360. if (reversed) {
  1361. return reversed;
  1362. }
  1363. let currentClosestDistance = Infinity;
  1364. let currentClosestKeyword;
  1365. for (const keyword of Object.keys(cssKeywords)) {
  1366. const value = cssKeywords[keyword]; // Compute comparative distance
  1367. const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  1368. if (distance < currentClosestDistance) {
  1369. currentClosestDistance = distance;
  1370. currentClosestKeyword = keyword;
  1371. }
  1372. }
  1373. return currentClosestKeyword;
  1374. };
  1375. convert$1.keyword.rgb = function (keyword) {
  1376. return cssKeywords[keyword];
  1377. };
  1378. convert$1.rgb.xyz = function (rgb) {
  1379. let r = rgb[0] / 255;
  1380. let g = rgb[1] / 255;
  1381. let b = rgb[2] / 255; // Assume sRGB
  1382. r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
  1383. g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
  1384. b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
  1385. const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  1386. const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  1387. const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  1388. return [x * 100, y * 100, z * 100];
  1389. };
  1390. convert$1.rgb.lab = function (rgb) {
  1391. const xyz = convert$1.rgb.xyz(rgb);
  1392. let x = xyz[0];
  1393. let y = xyz[1];
  1394. let z = xyz[2];
  1395. x /= 95.047;
  1396. y /= 100;
  1397. z /= 108.883;
  1398. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  1399. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  1400. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  1401. const l = 116 * y - 16;
  1402. const a = 500 * (x - y);
  1403. const b = 200 * (y - z);
  1404. return [l, a, b];
  1405. };
  1406. convert$1.hsl.rgb = function (hsl) {
  1407. const h = hsl[0] / 360;
  1408. const s = hsl[1] / 100;
  1409. const l = hsl[2] / 100;
  1410. let t2;
  1411. let t3;
  1412. let val;
  1413. if (s === 0) {
  1414. val = l * 255;
  1415. return [val, val, val];
  1416. }
  1417. if (l < 0.5) {
  1418. t2 = l * (1 + s);
  1419. } else {
  1420. t2 = l + s - l * s;
  1421. }
  1422. const t1 = 2 * l - t2;
  1423. const rgb = [0, 0, 0];
  1424. for (let i = 0; i < 3; i++) {
  1425. t3 = h + 1 / 3 * -(i - 1);
  1426. if (t3 < 0) {
  1427. t3++;
  1428. }
  1429. if (t3 > 1) {
  1430. t3--;
  1431. }
  1432. if (6 * t3 < 1) {
  1433. val = t1 + (t2 - t1) * 6 * t3;
  1434. } else if (2 * t3 < 1) {
  1435. val = t2;
  1436. } else if (3 * t3 < 2) {
  1437. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  1438. } else {
  1439. val = t1;
  1440. }
  1441. rgb[i] = val * 255;
  1442. }
  1443. return rgb;
  1444. };
  1445. convert$1.hsl.hsv = function (hsl) {
  1446. const h = hsl[0];
  1447. let s = hsl[1] / 100;
  1448. let l = hsl[2] / 100;
  1449. let smin = s;
  1450. const lmin = Math.max(l, 0.01);
  1451. l *= 2;
  1452. s *= l <= 1 ? l : 2 - l;
  1453. smin *= lmin <= 1 ? lmin : 2 - lmin;
  1454. const v = (l + s) / 2;
  1455. const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  1456. return [h, sv * 100, v * 100];
  1457. };
  1458. convert$1.hsv.rgb = function (hsv) {
  1459. const h = hsv[0] / 60;
  1460. const s = hsv[1] / 100;
  1461. let v = hsv[2] / 100;
  1462. const hi = Math.floor(h) % 6;
  1463. const f = h - Math.floor(h);
  1464. const p = 255 * v * (1 - s);
  1465. const q = 255 * v * (1 - s * f);
  1466. const t = 255 * v * (1 - s * (1 - f));
  1467. v *= 255;
  1468. switch (hi) {
  1469. case 0:
  1470. return [v, t, p];
  1471. case 1:
  1472. return [q, v, p];
  1473. case 2:
  1474. return [p, v, t];
  1475. case 3:
  1476. return [p, q, v];
  1477. case 4:
  1478. return [t, p, v];
  1479. case 5:
  1480. return [v, p, q];
  1481. }
  1482. };
  1483. convert$1.hsv.hsl = function (hsv) {
  1484. const h = hsv[0];
  1485. const s = hsv[1] / 100;
  1486. const v = hsv[2] / 100;
  1487. const vmin = Math.max(v, 0.01);
  1488. let sl;
  1489. let l;
  1490. l = (2 - s) * v;
  1491. const lmin = (2 - s) * vmin;
  1492. sl = s * vmin;
  1493. sl /= lmin <= 1 ? lmin : 2 - lmin;
  1494. sl = sl || 0;
  1495. l /= 2;
  1496. return [h, sl * 100, l * 100];
  1497. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  1498. convert$1.hwb.rgb = function (hwb) {
  1499. const h = hwb[0] / 360;
  1500. let wh = hwb[1] / 100;
  1501. let bl = hwb[2] / 100;
  1502. const ratio = wh + bl;
  1503. let f; // Wh + bl cant be > 1
  1504. if (ratio > 1) {
  1505. wh /= ratio;
  1506. bl /= ratio;
  1507. }
  1508. const i = Math.floor(6 * h);
  1509. const v = 1 - bl;
  1510. f = 6 * h - i;
  1511. if ((i & 0x01) !== 0) {
  1512. f = 1 - f;
  1513. }
  1514. const n = wh + f * (v - wh); // Linear interpolation
  1515. let r;
  1516. let g;
  1517. let b;
  1518. /* eslint-disable max-statements-per-line,no-multi-spaces */
  1519. switch (i) {
  1520. default:
  1521. case 6:
  1522. case 0:
  1523. r = v;
  1524. g = n;
  1525. b = wh;
  1526. break;
  1527. case 1:
  1528. r = n;
  1529. g = v;
  1530. b = wh;
  1531. break;
  1532. case 2:
  1533. r = wh;
  1534. g = v;
  1535. b = n;
  1536. break;
  1537. case 3:
  1538. r = wh;
  1539. g = n;
  1540. b = v;
  1541. break;
  1542. case 4:
  1543. r = n;
  1544. g = wh;
  1545. b = v;
  1546. break;
  1547. case 5:
  1548. r = v;
  1549. g = wh;
  1550. b = n;
  1551. break;
  1552. }
  1553. /* eslint-enable max-statements-per-line,no-multi-spaces */
  1554. return [r * 255, g * 255, b * 255];
  1555. };
  1556. convert$1.cmyk.rgb = function (cmyk) {
  1557. const c = cmyk[0] / 100;
  1558. const m = cmyk[1] / 100;
  1559. const y = cmyk[2] / 100;
  1560. const k = cmyk[3] / 100;
  1561. const r = 1 - Math.min(1, c * (1 - k) + k);
  1562. const g = 1 - Math.min(1, m * (1 - k) + k);
  1563. const b = 1 - Math.min(1, y * (1 - k) + k);
  1564. return [r * 255, g * 255, b * 255];
  1565. };
  1566. convert$1.xyz.rgb = function (xyz) {
  1567. const x = xyz[0] / 100;
  1568. const y = xyz[1] / 100;
  1569. const z = xyz[2] / 100;
  1570. let r;
  1571. let g;
  1572. let b;
  1573. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  1574. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  1575. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
  1576. r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
  1577. g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
  1578. b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
  1579. r = Math.min(Math.max(0, r), 1);
  1580. g = Math.min(Math.max(0, g), 1);
  1581. b = Math.min(Math.max(0, b), 1);
  1582. return [r * 255, g * 255, b * 255];
  1583. };
  1584. convert$1.xyz.lab = function (xyz) {
  1585. let x = xyz[0];
  1586. let y = xyz[1];
  1587. let z = xyz[2];
  1588. x /= 95.047;
  1589. y /= 100;
  1590. z /= 108.883;
  1591. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  1592. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  1593. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  1594. const l = 116 * y - 16;
  1595. const a = 500 * (x - y);
  1596. const b = 200 * (y - z);
  1597. return [l, a, b];
  1598. };
  1599. convert$1.lab.xyz = function (lab) {
  1600. const l = lab[0];
  1601. const a = lab[1];
  1602. const b = lab[2];
  1603. let x;
  1604. let y;
  1605. let z;
  1606. y = (l + 16) / 116;
  1607. x = a / 500 + y;
  1608. z = y - b / 200;
  1609. const y2 = y ** 3;
  1610. const x2 = x ** 3;
  1611. const z2 = z ** 3;
  1612. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  1613. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  1614. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  1615. x *= 95.047;
  1616. y *= 100;
  1617. z *= 108.883;
  1618. return [x, y, z];
  1619. };
  1620. convert$1.lab.lch = function (lab) {
  1621. const l = lab[0];
  1622. const a = lab[1];
  1623. const b = lab[2];
  1624. let h;
  1625. const hr = Math.atan2(b, a);
  1626. h = hr * 360 / 2 / Math.PI;
  1627. if (h < 0) {
  1628. h += 360;
  1629. }
  1630. const c = Math.sqrt(a * a + b * b);
  1631. return [l, c, h];
  1632. };
  1633. convert$1.lch.lab = function (lch) {
  1634. const l = lch[0];
  1635. const c = lch[1];
  1636. const h = lch[2];
  1637. const hr = h / 360 * 2 * Math.PI;
  1638. const a = c * Math.cos(hr);
  1639. const b = c * Math.sin(hr);
  1640. return [l, a, b];
  1641. };
  1642. convert$1.rgb.ansi16 = function (args, saturation = null) {
  1643. const [r, g, b] = args;
  1644. let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
  1645. value = Math.round(value / 50);
  1646. if (value === 0) {
  1647. return 30;
  1648. }
  1649. let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  1650. if (value === 2) {
  1651. ansi += 60;
  1652. }
  1653. return ansi;
  1654. };
  1655. convert$1.hsv.ansi16 = function (args) {
  1656. // Optimization here; we already know the value and don't need to get
  1657. // it converted for us.
  1658. return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
  1659. };
  1660. convert$1.rgb.ansi256 = function (args) {
  1661. const r = args[0];
  1662. const g = args[1];
  1663. const b = args[2]; // We use the extended greyscale palette here, with the exception of
  1664. // black and white. normal palette only has 4 greyscale shades.
  1665. if (r === g && g === b) {
  1666. if (r < 8) {
  1667. return 16;
  1668. }
  1669. if (r > 248) {
  1670. return 231;
  1671. }
  1672. return Math.round((r - 8) / 247 * 24) + 232;
  1673. }
  1674. const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  1675. return ansi;
  1676. };
  1677. convert$1.ansi16.rgb = function (args) {
  1678. let color = args % 10; // Handle greyscale
  1679. if (color === 0 || color === 7) {
  1680. if (args > 50) {
  1681. color += 3.5;
  1682. }
  1683. color = color / 10.5 * 255;
  1684. return [color, color, color];
  1685. }
  1686. const mult = (~~(args > 50) + 1) * 0.5;
  1687. const r = (color & 1) * mult * 255;
  1688. const g = (color >> 1 & 1) * mult * 255;
  1689. const b = (color >> 2 & 1) * mult * 255;
  1690. return [r, g, b];
  1691. };
  1692. convert$1.ansi256.rgb = function (args) {
  1693. // Handle greyscale
  1694. if (args >= 232) {
  1695. const c = (args - 232) * 10 + 8;
  1696. return [c, c, c];
  1697. }
  1698. args -= 16;
  1699. let rem;
  1700. const r = Math.floor(args / 36) / 5 * 255;
  1701. const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  1702. const b = rem % 6 / 5 * 255;
  1703. return [r, g, b];
  1704. };
  1705. convert$1.rgb.hex = function (args) {
  1706. const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  1707. const string = integer.toString(16).toUpperCase();
  1708. return '000000'.substring(string.length) + string;
  1709. };
  1710. convert$1.hex.rgb = function (args) {
  1711. const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  1712. if (!match) {
  1713. return [0, 0, 0];
  1714. }
  1715. let colorString = match[0];
  1716. if (match[0].length === 3) {
  1717. colorString = colorString.split('').map(char => {
  1718. return char + char;
  1719. }).join('');
  1720. }
  1721. const integer = parseInt(colorString, 16);
  1722. const r = integer >> 16 & 0xFF;
  1723. const g = integer >> 8 & 0xFF;
  1724. const b = integer & 0xFF;
  1725. return [r, g, b];
  1726. };
  1727. convert$1.rgb.hcg = function (rgb) {
  1728. const r = rgb[0] / 255;
  1729. const g = rgb[1] / 255;
  1730. const b = rgb[2] / 255;
  1731. const max = Math.max(Math.max(r, g), b);
  1732. const min = Math.min(Math.min(r, g), b);
  1733. const chroma = max - min;
  1734. let grayscale;
  1735. let hue;
  1736. if (chroma < 1) {
  1737. grayscale = min / (1 - chroma);
  1738. } else {
  1739. grayscale = 0;
  1740. }
  1741. if (chroma <= 0) {
  1742. hue = 0;
  1743. } else if (max === r) {
  1744. hue = (g - b) / chroma % 6;
  1745. } else if (max === g) {
  1746. hue = 2 + (b - r) / chroma;
  1747. } else {
  1748. hue = 4 + (r - g) / chroma;
  1749. }
  1750. hue /= 6;
  1751. hue %= 1;
  1752. return [hue * 360, chroma * 100, grayscale * 100];
  1753. };
  1754. convert$1.hsl.hcg = function (hsl) {
  1755. const s = hsl[1] / 100;
  1756. const l = hsl[2] / 100;
  1757. const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
  1758. let f = 0;
  1759. if (c < 1.0) {
  1760. f = (l - 0.5 * c) / (1.0 - c);
  1761. }
  1762. return [hsl[0], c * 100, f * 100];
  1763. };
  1764. convert$1.hsv.hcg = function (hsv) {
  1765. const s = hsv[1] / 100;
  1766. const v = hsv[2] / 100;
  1767. const c = s * v;
  1768. let f = 0;
  1769. if (c < 1.0) {
  1770. f = (v - c) / (1 - c);
  1771. }
  1772. return [hsv[0], c * 100, f * 100];
  1773. };
  1774. convert$1.hcg.rgb = function (hcg) {
  1775. const h = hcg[0] / 360;
  1776. const c = hcg[1] / 100;
  1777. const g = hcg[2] / 100;
  1778. if (c === 0.0) {
  1779. return [g * 255, g * 255, g * 255];
  1780. }
  1781. const pure = [0, 0, 0];
  1782. const hi = h % 1 * 6;
  1783. const v = hi % 1;
  1784. const w = 1 - v;
  1785. let mg = 0;
  1786. /* eslint-disable max-statements-per-line */
  1787. switch (Math.floor(hi)) {
  1788. case 0:
  1789. pure[0] = 1;
  1790. pure[1] = v;
  1791. pure[2] = 0;
  1792. break;
  1793. case 1:
  1794. pure[0] = w;
  1795. pure[1] = 1;
  1796. pure[2] = 0;
  1797. break;
  1798. case 2:
  1799. pure[0] = 0;
  1800. pure[1] = 1;
  1801. pure[2] = v;
  1802. break;
  1803. case 3:
  1804. pure[0] = 0;
  1805. pure[1] = w;
  1806. pure[2] = 1;
  1807. break;
  1808. case 4:
  1809. pure[0] = v;
  1810. pure[1] = 0;
  1811. pure[2] = 1;
  1812. break;
  1813. default:
  1814. pure[0] = 1;
  1815. pure[1] = 0;
  1816. pure[2] = w;
  1817. }
  1818. /* eslint-enable max-statements-per-line */
  1819. mg = (1.0 - c) * g;
  1820. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  1821. };
  1822. convert$1.hcg.hsv = function (hcg) {
  1823. const c = hcg[1] / 100;
  1824. const g = hcg[2] / 100;
  1825. const v = c + g * (1.0 - c);
  1826. let f = 0;
  1827. if (v > 0.0) {
  1828. f = c / v;
  1829. }
  1830. return [hcg[0], f * 100, v * 100];
  1831. };
  1832. convert$1.hcg.hsl = function (hcg) {
  1833. const c = hcg[1] / 100;
  1834. const g = hcg[2] / 100;
  1835. const l = g * (1.0 - c) + 0.5 * c;
  1836. let s = 0;
  1837. if (l > 0.0 && l < 0.5) {
  1838. s = c / (2 * l);
  1839. } else if (l >= 0.5 && l < 1.0) {
  1840. s = c / (2 * (1 - l));
  1841. }
  1842. return [hcg[0], s * 100, l * 100];
  1843. };
  1844. convert$1.hcg.hwb = function (hcg) {
  1845. const c = hcg[1] / 100;
  1846. const g = hcg[2] / 100;
  1847. const v = c + g * (1.0 - c);
  1848. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  1849. };
  1850. convert$1.hwb.hcg = function (hwb) {
  1851. const w = hwb[1] / 100;
  1852. const b = hwb[2] / 100;
  1853. const v = 1 - b;
  1854. const c = v - w;
  1855. let g = 0;
  1856. if (c < 1) {
  1857. g = (v - c) / (1 - c);
  1858. }
  1859. return [hwb[0], c * 100, g * 100];
  1860. };
  1861. convert$1.apple.rgb = function (apple) {
  1862. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  1863. };
  1864. convert$1.rgb.apple = function (rgb) {
  1865. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  1866. };
  1867. convert$1.gray.rgb = function (args) {
  1868. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  1869. };
  1870. convert$1.gray.hsl = function (args) {
  1871. return [0, 0, args[0]];
  1872. };
  1873. convert$1.gray.hsv = convert$1.gray.hsl;
  1874. convert$1.gray.hwb = function (gray) {
  1875. return [0, 100, gray[0]];
  1876. };
  1877. convert$1.gray.cmyk = function (gray) {
  1878. return [0, 0, 0, gray[0]];
  1879. };
  1880. convert$1.gray.lab = function (gray) {
  1881. return [gray[0], 0, 0];
  1882. };
  1883. convert$1.gray.hex = function (gray) {
  1884. const val = Math.round(gray[0] / 100 * 255) & 0xFF;
  1885. const integer = (val << 16) + (val << 8) + val;
  1886. const string = integer.toString(16).toUpperCase();
  1887. return '000000'.substring(string.length) + string;
  1888. };
  1889. convert$1.rgb.gray = function (rgb) {
  1890. const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  1891. return [val / 255 * 100];
  1892. };
  1893. const conversions$1 = conversions$2;
  1894. /*
  1895. This function routes a model to all other models.
  1896. all functions that are routed have a property `.conversion` attached
  1897. to the returned synthetic function. This property is an array
  1898. of strings, each with the steps in between the 'from' and 'to'
  1899. color models (inclusive).
  1900. conversions that are not possible simply are not included.
  1901. */
  1902. function buildGraph() {
  1903. const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  1904. const models = Object.keys(conversions$1);
  1905. for (let len = models.length, i = 0; i < len; i++) {
  1906. graph[models[i]] = {
  1907. // http://jsperf.com/1-vs-infinity
  1908. // micro-opt, but this is simple.
  1909. distance: -1,
  1910. parent: null
  1911. };
  1912. }
  1913. return graph;
  1914. } // https://en.wikipedia.org/wiki/Breadth-first_search
  1915. function deriveBFS(fromModel) {
  1916. const graph = buildGraph();
  1917. const queue = [fromModel]; // Unshift -> queue -> pop
  1918. graph[fromModel].distance = 0;
  1919. while (queue.length) {
  1920. const current = queue.pop();
  1921. const adjacents = Object.keys(conversions$1[current]);
  1922. for (let len = adjacents.length, i = 0; i < len; i++) {
  1923. const adjacent = adjacents[i];
  1924. const node = graph[adjacent];
  1925. if (node.distance === -1) {
  1926. node.distance = graph[current].distance + 1;
  1927. node.parent = current;
  1928. queue.unshift(adjacent);
  1929. }
  1930. }
  1931. }
  1932. return graph;
  1933. }
  1934. function link(from, to) {
  1935. return function (args) {
  1936. return to(from(args));
  1937. };
  1938. }
  1939. function wrapConversion(toModel, graph) {
  1940. const path = [graph[toModel].parent, toModel];
  1941. let fn = conversions$1[graph[toModel].parent][toModel];
  1942. let cur = graph[toModel].parent;
  1943. while (graph[cur].parent) {
  1944. path.unshift(graph[cur].parent);
  1945. fn = link(conversions$1[graph[cur].parent][cur], fn);
  1946. cur = graph[cur].parent;
  1947. }
  1948. fn.conversion = path;
  1949. return fn;
  1950. }
  1951. var route$1 = function (fromModel) {
  1952. const graph = deriveBFS(fromModel);
  1953. const conversion = {};
  1954. const models = Object.keys(graph);
  1955. for (let len = models.length, i = 0; i < len; i++) {
  1956. const toModel = models[i];
  1957. const node = graph[toModel];
  1958. if (node.parent === null) {
  1959. // No possible conversion, or this node is the source model.
  1960. continue;
  1961. }
  1962. conversion[toModel] = wrapConversion(toModel, graph);
  1963. }
  1964. return conversion;
  1965. };
  1966. const conversions = conversions$2;
  1967. const route = route$1;
  1968. const convert = {};
  1969. const models = Object.keys(conversions);
  1970. function wrapRaw(fn) {
  1971. const wrappedFn = function (...args) {
  1972. const arg0 = args[0];
  1973. if (arg0 === undefined || arg0 === null) {
  1974. return arg0;
  1975. }
  1976. if (arg0.length > 1) {
  1977. args = arg0;
  1978. }
  1979. return fn(args);
  1980. }; // Preserve .conversion property if there is one
  1981. if ('conversion' in fn) {
  1982. wrappedFn.conversion = fn.conversion;
  1983. }
  1984. return wrappedFn;
  1985. }
  1986. function wrapRounded(fn) {
  1987. const wrappedFn = function (...args) {
  1988. const arg0 = args[0];
  1989. if (arg0 === undefined || arg0 === null) {
  1990. return arg0;
  1991. }
  1992. if (arg0.length > 1) {
  1993. args = arg0;
  1994. }
  1995. const result = fn(args); // We're assuming the result is an array here.
  1996. // see notice in conversions.js; don't use box types
  1997. // in conversion functions.
  1998. if (typeof result === 'object') {
  1999. for (let len = result.length, i = 0; i < len; i++) {
  2000. result[i] = Math.round(result[i]);
  2001. }
  2002. }
  2003. return result;
  2004. }; // Preserve .conversion property if there is one
  2005. if ('conversion' in fn) {
  2006. wrappedFn.conversion = fn.conversion;
  2007. }
  2008. return wrappedFn;
  2009. }
  2010. models.forEach(fromModel => {
  2011. convert[fromModel] = {};
  2012. Object.defineProperty(convert[fromModel], 'channels', {
  2013. value: conversions[fromModel].channels
  2014. });
  2015. Object.defineProperty(convert[fromModel], 'labels', {
  2016. value: conversions[fromModel].labels
  2017. });
  2018. const routes = route(fromModel);
  2019. const routeModels = Object.keys(routes);
  2020. routeModels.forEach(toModel => {
  2021. const fn = routes[toModel];
  2022. convert[fromModel][toModel] = wrapRounded(fn);
  2023. convert[fromModel][toModel].raw = wrapRaw(fn);
  2024. });
  2025. });
  2026. var colorConvert = convert;
  2027. (function (module) {
  2028. const wrapAnsi16 = (fn, offset) => (...args) => {
  2029. const code = fn(...args);
  2030. return `\u001B[${code + offset}m`;
  2031. };
  2032. const wrapAnsi256 = (fn, offset) => (...args) => {
  2033. const code = fn(...args);
  2034. return `\u001B[${38 + offset};5;${code}m`;
  2035. };
  2036. const wrapAnsi16m = (fn, offset) => (...args) => {
  2037. const rgb = fn(...args);
  2038. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  2039. };
  2040. const ansi2ansi = n => n;
  2041. const rgb2rgb = (r, g, b) => [r, g, b];
  2042. const setLazyProperty = (object, property, get) => {
  2043. Object.defineProperty(object, property, {
  2044. get: () => {
  2045. const value = get();
  2046. Object.defineProperty(object, property, {
  2047. value,
  2048. enumerable: true,
  2049. configurable: true
  2050. });
  2051. return value;
  2052. },
  2053. enumerable: true,
  2054. configurable: true
  2055. });
  2056. };
  2057. /** @type {typeof import('color-convert')} */
  2058. let colorConvert$1;
  2059. const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
  2060. if (colorConvert$1 === undefined) {
  2061. colorConvert$1 = colorConvert;
  2062. }
  2063. const offset = isBackground ? 10 : 0;
  2064. const styles = {};
  2065. for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
  2066. const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
  2067. if (sourceSpace === targetSpace) {
  2068. styles[name] = wrap(identity, offset);
  2069. } else if (typeof suite === 'object') {
  2070. styles[name] = wrap(suite[targetSpace], offset);
  2071. }
  2072. }
  2073. return styles;
  2074. };
  2075. function assembleStyles() {
  2076. const codes = new Map();
  2077. const styles = {
  2078. modifier: {
  2079. reset: [0, 0],
  2080. // 21 isn't widely supported and 22 does the same thing
  2081. bold: [1, 22],
  2082. dim: [2, 22],
  2083. italic: [3, 23],
  2084. underline: [4, 24],
  2085. inverse: [7, 27],
  2086. hidden: [8, 28],
  2087. strikethrough: [9, 29]
  2088. },
  2089. color: {
  2090. black: [30, 39],
  2091. red: [31, 39],
  2092. green: [32, 39],
  2093. yellow: [33, 39],
  2094. blue: [34, 39],
  2095. magenta: [35, 39],
  2096. cyan: [36, 39],
  2097. white: [37, 39],
  2098. // Bright color
  2099. blackBright: [90, 39],
  2100. redBright: [91, 39],
  2101. greenBright: [92, 39],
  2102. yellowBright: [93, 39],
  2103. blueBright: [94, 39],
  2104. magentaBright: [95, 39],
  2105. cyanBright: [96, 39],
  2106. whiteBright: [97, 39]
  2107. },
  2108. bgColor: {
  2109. bgBlack: [40, 49],
  2110. bgRed: [41, 49],
  2111. bgGreen: [42, 49],
  2112. bgYellow: [43, 49],
  2113. bgBlue: [44, 49],
  2114. bgMagenta: [45, 49],
  2115. bgCyan: [46, 49],
  2116. bgWhite: [47, 49],
  2117. // Bright color
  2118. bgBlackBright: [100, 49],
  2119. bgRedBright: [101, 49],
  2120. bgGreenBright: [102, 49],
  2121. bgYellowBright: [103, 49],
  2122. bgBlueBright: [104, 49],
  2123. bgMagentaBright: [105, 49],
  2124. bgCyanBright: [106, 49],
  2125. bgWhiteBright: [107, 49]
  2126. }
  2127. }; // Alias bright black as gray (and grey)
  2128. styles.color.gray = styles.color.blackBright;
  2129. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  2130. styles.color.grey = styles.color.blackBright;
  2131. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  2132. for (const [groupName, group] of Object.entries(styles)) {
  2133. for (const [styleName, style] of Object.entries(group)) {
  2134. styles[styleName] = {
  2135. open: `\u001B[${style[0]}m`,
  2136. close: `\u001B[${style[1]}m`
  2137. };
  2138. group[styleName] = styles[styleName];
  2139. codes.set(style[0], style[1]);
  2140. }
  2141. Object.defineProperty(styles, groupName, {
  2142. value: group,
  2143. enumerable: false
  2144. });
  2145. }
  2146. Object.defineProperty(styles, 'codes', {
  2147. value: codes,
  2148. enumerable: false
  2149. });
  2150. styles.color.close = '\u001B[39m';
  2151. styles.bgColor.close = '\u001B[49m';
  2152. setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
  2153. setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
  2154. setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
  2155. setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
  2156. setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
  2157. setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
  2158. return styles;
  2159. } // Make the export immutable
  2160. Object.defineProperty(module, 'exports', {
  2161. enumerable: true,
  2162. get: assembleStyles
  2163. });
  2164. })(ansiStyles$1);
  2165. var hasFlag$1 = (flag, argv = process.argv) => {
  2166. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  2167. const position = argv.indexOf(prefix + flag);
  2168. const terminatorPosition = argv.indexOf('--');
  2169. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  2170. };
  2171. const os = require$$0__default["default"];
  2172. const tty = require$$1__default["default"];
  2173. const hasFlag = hasFlag$1;
  2174. const {
  2175. env
  2176. } = process;
  2177. let forceColor;
  2178. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
  2179. forceColor = 0;
  2180. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  2181. forceColor = 1;
  2182. }
  2183. if ('FORCE_COLOR' in env) {
  2184. if (env.FORCE_COLOR === 'true') {
  2185. forceColor = 1;
  2186. } else if (env.FORCE_COLOR === 'false') {
  2187. forceColor = 0;
  2188. } else {
  2189. forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
  2190. }
  2191. }
  2192. function translateLevel(level) {
  2193. if (level === 0) {
  2194. return false;
  2195. }
  2196. return {
  2197. level,
  2198. hasBasic: true,
  2199. has256: level >= 2,
  2200. has16m: level >= 3
  2201. };
  2202. }
  2203. function supportsColor(haveStream, streamIsTTY) {
  2204. if (forceColor === 0) {
  2205. return 0;
  2206. }
  2207. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  2208. return 3;
  2209. }
  2210. if (hasFlag('color=256')) {
  2211. return 2;
  2212. }
  2213. if (haveStream && !streamIsTTY && forceColor === undefined) {
  2214. return 0;
  2215. }
  2216. const min = forceColor || 0;
  2217. if (env.TERM === 'dumb') {
  2218. return min;
  2219. }
  2220. if (process.platform === 'win32') {
  2221. // Windows 10 build 10586 is the first Windows release that supports 256 colors.
  2222. // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
  2223. const osRelease = os.release().split('.');
  2224. if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  2225. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  2226. }
  2227. return 1;
  2228. }
  2229. if ('CI' in env) {
  2230. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
  2231. return 1;
  2232. }
  2233. return min;
  2234. }
  2235. if ('TEAMCITY_VERSION' in env) {
  2236. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  2237. }
  2238. if (env.COLORTERM === 'truecolor') {
  2239. return 3;
  2240. }
  2241. if ('TERM_PROGRAM' in env) {
  2242. const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  2243. switch (env.TERM_PROGRAM) {
  2244. case 'iTerm.app':
  2245. return version >= 3 ? 3 : 2;
  2246. case 'Apple_Terminal':
  2247. return 2;
  2248. // No default
  2249. }
  2250. }
  2251. if (/-256(color)?$/i.test(env.TERM)) {
  2252. return 2;
  2253. }
  2254. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  2255. return 1;
  2256. }
  2257. if ('COLORTERM' in env) {
  2258. return 1;
  2259. }
  2260. return min;
  2261. }
  2262. function getSupportLevel(stream) {
  2263. const level = supportsColor(stream, stream && stream.isTTY);
  2264. return translateLevel(level);
  2265. }
  2266. var supportsColor_1 = {
  2267. supportsColor: getSupportLevel,
  2268. stdout: translateLevel(supportsColor(true, tty.isatty(1))),
  2269. stderr: translateLevel(supportsColor(true, tty.isatty(2)))
  2270. };
  2271. const stringReplaceAll$1 = (string, substring, replacer) => {
  2272. let index = string.indexOf(substring);
  2273. if (index === -1) {
  2274. return string;
  2275. }
  2276. const substringLength = substring.length;
  2277. let endIndex = 0;
  2278. let returnValue = '';
  2279. do {
  2280. returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
  2281. endIndex = index + substringLength;
  2282. index = string.indexOf(substring, endIndex);
  2283. } while (index !== -1);
  2284. returnValue += string.substr(endIndex);
  2285. return returnValue;
  2286. };
  2287. const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
  2288. let endIndex = 0;
  2289. let returnValue = '';
  2290. do {
  2291. const gotCR = string[index - 1] === '\r';
  2292. returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
  2293. endIndex = index + 1;
  2294. index = string.indexOf('\n', endIndex);
  2295. } while (index !== -1);
  2296. returnValue += string.substr(endIndex);
  2297. return returnValue;
  2298. };
  2299. var util$2 = {
  2300. stringReplaceAll: stringReplaceAll$1,
  2301. stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
  2302. };
  2303. const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  2304. const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  2305. const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  2306. const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
  2307. const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  2308. function unescape(c) {
  2309. const u = c[0] === 'u';
  2310. const bracket = c[1] === '{';
  2311. if (u && !bracket && c.length === 5 || c[0] === 'x' && c.length === 3) {
  2312. return String.fromCharCode(parseInt(c.slice(1), 16));
  2313. }
  2314. if (u && bracket) {
  2315. return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
  2316. }
  2317. return ESCAPES.get(c) || c;
  2318. }
  2319. function parseArguments(name, arguments_) {
  2320. const results = [];
  2321. const chunks = arguments_.trim().split(/\s*,\s*/g);
  2322. let matches;
  2323. for (const chunk of chunks) {
  2324. const number = Number(chunk);
  2325. if (!Number.isNaN(number)) {
  2326. results.push(number);
  2327. } else if (matches = chunk.match(STRING_REGEX)) {
  2328. results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
  2329. } else {
  2330. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  2331. }
  2332. }
  2333. return results;
  2334. }
  2335. function parseStyle(style) {
  2336. STYLE_REGEX.lastIndex = 0;
  2337. const results = [];
  2338. let matches;
  2339. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  2340. const name = matches[1];
  2341. if (matches[2]) {
  2342. const args = parseArguments(name, matches[2]);
  2343. results.push([name].concat(args));
  2344. } else {
  2345. results.push([name]);
  2346. }
  2347. }
  2348. return results;
  2349. }
  2350. function buildStyle(chalk, styles) {
  2351. const enabled = {};
  2352. for (const layer of styles) {
  2353. for (const style of layer.styles) {
  2354. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  2355. }
  2356. }
  2357. let current = chalk;
  2358. for (const [styleName, styles] of Object.entries(enabled)) {
  2359. if (!Array.isArray(styles)) {
  2360. continue;
  2361. }
  2362. if (!(styleName in current)) {
  2363. throw new Error(`Unknown Chalk style: ${styleName}`);
  2364. }
  2365. current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
  2366. }
  2367. return current;
  2368. }
  2369. var templates = (chalk, temporary) => {
  2370. const styles = [];
  2371. const chunks = [];
  2372. let chunk = []; // eslint-disable-next-line max-params
  2373. temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
  2374. if (escapeCharacter) {
  2375. chunk.push(unescape(escapeCharacter));
  2376. } else if (style) {
  2377. const string = chunk.join('');
  2378. chunk = [];
  2379. chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
  2380. styles.push({
  2381. inverse,
  2382. styles: parseStyle(style)
  2383. });
  2384. } else if (close) {
  2385. if (styles.length === 0) {
  2386. throw new Error('Found extraneous } in Chalk template literal');
  2387. }
  2388. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  2389. chunk = [];
  2390. styles.pop();
  2391. } else {
  2392. chunk.push(character);
  2393. }
  2394. });
  2395. chunks.push(chunk.join(''));
  2396. if (styles.length > 0) {
  2397. const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  2398. throw new Error(errMessage);
  2399. }
  2400. return chunks.join('');
  2401. };
  2402. const ansiStyles = ansiStyles$1.exports;
  2403. const {
  2404. stdout: stdoutColor,
  2405. stderr: stderrColor
  2406. } = supportsColor_1;
  2407. const {
  2408. stringReplaceAll,
  2409. stringEncaseCRLFWithFirstIndex
  2410. } = util$2;
  2411. const {
  2412. isArray: isArray$e
  2413. } = Array; // `supportsColor.level` → `ansiStyles.color[name]` mapping
  2414. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
  2415. const styles = Object.create(null);
  2416. const applyOptions = (object, options = {}) => {
  2417. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  2418. throw new Error('The `level` option should be an integer from 0 to 3');
  2419. } // Detect level if not set manually
  2420. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  2421. object.level = options.level === undefined ? colorLevel : options.level;
  2422. };
  2423. class ChalkClass {
  2424. constructor(options) {
  2425. // eslint-disable-next-line no-constructor-return
  2426. return chalkFactory(options);
  2427. }
  2428. }
  2429. const chalkFactory = options => {
  2430. const chalk = {};
  2431. applyOptions(chalk, options);
  2432. chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
  2433. Object.setPrototypeOf(chalk, Chalk.prototype);
  2434. Object.setPrototypeOf(chalk.template, chalk);
  2435. chalk.template.constructor = () => {
  2436. throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
  2437. };
  2438. chalk.template.Instance = ChalkClass;
  2439. return chalk.template;
  2440. };
  2441. function Chalk(options) {
  2442. return chalkFactory(options);
  2443. }
  2444. for (const [styleName, style] of Object.entries(ansiStyles)) {
  2445. styles[styleName] = {
  2446. get() {
  2447. const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
  2448. Object.defineProperty(this, styleName, {
  2449. value: builder
  2450. });
  2451. return builder;
  2452. }
  2453. };
  2454. }
  2455. styles.visible = {
  2456. get() {
  2457. const builder = createBuilder(this, this._styler, true);
  2458. Object.defineProperty(this, 'visible', {
  2459. value: builder
  2460. });
  2461. return builder;
  2462. }
  2463. };
  2464. const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
  2465. for (const model of usedModels) {
  2466. styles[model] = {
  2467. get() {
  2468. const {
  2469. level
  2470. } = this;
  2471. return function (...arguments_) {
  2472. const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
  2473. return createBuilder(this, styler, this._isEmpty);
  2474. };
  2475. }
  2476. };
  2477. }
  2478. for (const model of usedModels) {
  2479. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  2480. styles[bgModel] = {
  2481. get() {
  2482. const {
  2483. level
  2484. } = this;
  2485. return function (...arguments_) {
  2486. const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
  2487. return createBuilder(this, styler, this._isEmpty);
  2488. };
  2489. }
  2490. };
  2491. }
  2492. const proto = Object.defineProperties(() => {}, Object.assign(Object.assign({}, styles), {}, {
  2493. level: {
  2494. enumerable: true,
  2495. get() {
  2496. return this._generator.level;
  2497. },
  2498. set(level) {
  2499. this._generator.level = level;
  2500. }
  2501. }
  2502. }));
  2503. const createStyler = (open, close, parent) => {
  2504. let openAll;
  2505. let closeAll;
  2506. if (parent === undefined) {
  2507. openAll = open;
  2508. closeAll = close;
  2509. } else {
  2510. openAll = parent.openAll + open;
  2511. closeAll = close + parent.closeAll;
  2512. }
  2513. return {
  2514. open,
  2515. close,
  2516. openAll,
  2517. closeAll,
  2518. parent
  2519. };
  2520. };
  2521. const createBuilder = (self, _styler, _isEmpty) => {
  2522. const builder = (...arguments_) => {
  2523. if (isArray$e(arguments_[0]) && isArray$e(arguments_[0].raw)) {
  2524. // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
  2525. return applyStyle(builder, chalkTag(builder, ...arguments_));
  2526. } // Single argument is hot path, implicit coercion is faster than anything
  2527. // eslint-disable-next-line no-implicit-coercion
  2528. return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
  2529. }; // We alter the prototype because we must return a function, but there is
  2530. // no way to create a function with a different prototype
  2531. Object.setPrototypeOf(builder, proto);
  2532. builder._generator = self;
  2533. builder._styler = _styler;
  2534. builder._isEmpty = _isEmpty;
  2535. return builder;
  2536. };
  2537. const applyStyle = (self, string) => {
  2538. if (self.level <= 0 || !string) {
  2539. return self._isEmpty ? '' : string;
  2540. }
  2541. let styler = self._styler;
  2542. if (styler === undefined) {
  2543. return string;
  2544. }
  2545. const {
  2546. openAll,
  2547. closeAll
  2548. } = styler;
  2549. if (string.indexOf('\u001B') !== -1) {
  2550. while (styler !== undefined) {
  2551. // Replace any instances already present with a re-opening code
  2552. // otherwise only the part of the string until said closing code
  2553. // will be colored, and the rest will simply be 'plain'.
  2554. string = stringReplaceAll(string, styler.close, styler.open);
  2555. styler = styler.parent;
  2556. }
  2557. } // We can move both next actions out of loop, because remaining actions in loop won't have
  2558. // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
  2559. // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
  2560. const lfIndex = string.indexOf('\n');
  2561. if (lfIndex !== -1) {
  2562. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  2563. }
  2564. return openAll + string + closeAll;
  2565. };
  2566. let template;
  2567. const chalkTag = (chalk, ...strings) => {
  2568. const [firstString] = strings;
  2569. if (!isArray$e(firstString) || !isArray$e(firstString.raw)) {
  2570. // If chalk() was called by itself or with a string,
  2571. // return the string itself as a string.
  2572. return strings.join(' ');
  2573. }
  2574. const arguments_ = strings.slice(1);
  2575. const parts = [firstString.raw[0]];
  2576. for (let i = 1; i < firstString.length; i++) {
  2577. parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
  2578. }
  2579. if (template === undefined) {
  2580. template = templates;
  2581. }
  2582. return template(chalk, parts.join(''));
  2583. };
  2584. Object.defineProperties(Chalk.prototype, styles);
  2585. const chalk$2 = Chalk(); // eslint-disable-line new-cap
  2586. chalk$2.supportsColor = stdoutColor;
  2587. chalk$2.stderr = Chalk({
  2588. level: stderrColor ? stderrColor.level : 0
  2589. }); // eslint-disable-line new-cap
  2590. chalk$2.stderr.supportsColor = stderrColor;
  2591. var source = chalk$2;
  2592. var require$$4 = require("./third-party.js");
  2593. var prettierInternal = require$$3.__internal;
  2594. var classof$2 = classofRaw$1;
  2595. // `IsArray` abstract operation
  2596. // https://tc39.es/ecma262/#sec-isarray
  2597. // eslint-disable-next-line es/no-array-isarray -- safe
  2598. var isArray$d = Array.isArray || function isArray(argument) {
  2599. return classof$2(argument) == 'Array';
  2600. };
  2601. var uncurryThis$1 = functionUncurryThis;
  2602. var aCallable$2 = aCallable$5;
  2603. var bind$2 = uncurryThis$1(uncurryThis$1.bind);
  2604. // optional / simple context binding
  2605. var functionBindContext = function (fn, that) {
  2606. aCallable$2(fn);
  2607. return that === undefined ? fn : bind$2 ? bind$2(fn, that) : function (/* ...args */) {
  2608. return fn.apply(that, arguments);
  2609. };
  2610. };
  2611. var global$4 = global$r;
  2612. var isArray$c = isArray$d;
  2613. var lengthOfArrayLike$3 = lengthOfArrayLike$6;
  2614. var bind$1 = functionBindContext;
  2615. var TypeError$3 = global$4.TypeError;
  2616. // `FlattenIntoArray` abstract operation
  2617. // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
  2618. var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
  2619. var targetIndex = start;
  2620. var sourceIndex = 0;
  2621. var mapFn = mapper ? bind$1(mapper, thisArg) : false;
  2622. var element, elementLen;
  2623. while (sourceIndex < sourceLen) {
  2624. if (sourceIndex in source) {
  2625. element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
  2626. if (depth > 0 && isArray$c(element)) {
  2627. elementLen = lengthOfArrayLike$3(element);
  2628. targetIndex = flattenIntoArray$2(target, original, element, elementLen, targetIndex, depth - 1) - 1;
  2629. } else {
  2630. if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError$3('Exceed the acceptable array length');
  2631. target[targetIndex] = element;
  2632. }
  2633. targetIndex++;
  2634. }
  2635. sourceIndex++;
  2636. }
  2637. return targetIndex;
  2638. };
  2639. var flattenIntoArray_1 = flattenIntoArray$2;
  2640. var uncurryThis = functionUncurryThis;
  2641. var fails = fails$8;
  2642. var isCallable = isCallable$b;
  2643. var classof$1 = classof$4;
  2644. var getBuiltIn$1 = getBuiltIn$5;
  2645. var inspectSource = inspectSource$3;
  2646. var noop$1 = function () { /* empty */ };
  2647. var empty = [];
  2648. var construct = getBuiltIn$1('Reflect', 'construct');
  2649. var constructorRegExp = /^\s*(?:class|function)\b/;
  2650. var exec = uncurryThis(constructorRegExp.exec);
  2651. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop$1);
  2652. var isConstructorModern = function (argument) {
  2653. if (!isCallable(argument)) return false;
  2654. try {
  2655. construct(noop$1, empty, argument);
  2656. return true;
  2657. } catch (error) {
  2658. return false;
  2659. }
  2660. };
  2661. var isConstructorLegacy = function (argument) {
  2662. if (!isCallable(argument)) return false;
  2663. switch (classof$1(argument)) {
  2664. case 'AsyncFunction':
  2665. case 'GeneratorFunction':
  2666. case 'AsyncGeneratorFunction': return false;
  2667. // we can't check .prototype since constructors produced by .bind haven't it
  2668. } return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  2669. };
  2670. // `IsConstructor` abstract operation
  2671. // https://tc39.es/ecma262/#sec-isconstructor
  2672. var isConstructor$1 = !construct || fails(function () {
  2673. var called;
  2674. return isConstructorModern(isConstructorModern.call)
  2675. || !isConstructorModern(Object)
  2676. || !isConstructorModern(function () { called = true; })
  2677. || called;
  2678. }) ? isConstructorLegacy : isConstructorModern;
  2679. var global$3 = global$r;
  2680. var isArray$b = isArray$d;
  2681. var isConstructor = isConstructor$1;
  2682. var isObject$7 = isObject$d;
  2683. var wellKnownSymbol$3 = wellKnownSymbol$7;
  2684. var SPECIES = wellKnownSymbol$3('species');
  2685. var Array$1 = global$3.Array;
  2686. // a part of `ArraySpeciesCreate` abstract operation
  2687. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  2688. var arraySpeciesConstructor$1 = function (originalArray) {
  2689. var C;
  2690. if (isArray$b(originalArray)) {
  2691. C = originalArray.constructor;
  2692. // cross-realm fallback
  2693. if (isConstructor(C) && (C === Array$1 || isArray$b(C.prototype))) C = undefined;
  2694. else if (isObject$7(C)) {
  2695. C = C[SPECIES];
  2696. if (C === null) C = undefined;
  2697. }
  2698. } return C === undefined ? Array$1 : C;
  2699. };
  2700. var arraySpeciesConstructor = arraySpeciesConstructor$1;
  2701. // `ArraySpeciesCreate` abstract operation
  2702. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  2703. var arraySpeciesCreate$2 = function (originalArray, length) {
  2704. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  2705. };
  2706. var $$2 = _export;
  2707. var flattenIntoArray$1 = flattenIntoArray_1;
  2708. var aCallable$1 = aCallable$5;
  2709. var toObject$1 = toObject$4;
  2710. var lengthOfArrayLike$2 = lengthOfArrayLike$6;
  2711. var arraySpeciesCreate$1 = arraySpeciesCreate$2;
  2712. // `Array.prototype.flatMap` method
  2713. // https://tc39.es/ecma262/#sec-array.prototype.flatmap
  2714. $$2({ target: 'Array', proto: true }, {
  2715. flatMap: function flatMap(callbackfn /* , thisArg */) {
  2716. var O = toObject$1(this);
  2717. var sourceLen = lengthOfArrayLike$2(O);
  2718. var A;
  2719. aCallable$1(callbackfn);
  2720. A = arraySpeciesCreate$1(O, 0);
  2721. A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2722. return A;
  2723. }
  2724. });
  2725. var tasks = {};
  2726. var utils$k = {};
  2727. var array$3 = {};
  2728. Object.defineProperty(array$3, "__esModule", {
  2729. value: true
  2730. });
  2731. array$3.splitWhen = array$3.flatten = void 0;
  2732. function flatten$2(items) {
  2733. return items.reduce((collection, item) => [].concat(collection, item), []);
  2734. }
  2735. array$3.flatten = flatten$2;
  2736. function splitWhen(items, predicate) {
  2737. const result = [[]];
  2738. let groupIndex = 0;
  2739. for (const item of items) {
  2740. if (predicate(item)) {
  2741. groupIndex++;
  2742. result[groupIndex] = [];
  2743. } else {
  2744. result[groupIndex].push(item);
  2745. }
  2746. }
  2747. return result;
  2748. }
  2749. array$3.splitWhen = splitWhen;
  2750. var errno$1 = {};
  2751. Object.defineProperty(errno$1, "__esModule", {
  2752. value: true
  2753. });
  2754. errno$1.isEnoentCodeError = void 0;
  2755. function isEnoentCodeError(error) {
  2756. return error.code === 'ENOENT';
  2757. }
  2758. errno$1.isEnoentCodeError = isEnoentCodeError;
  2759. var fs$9 = {};
  2760. Object.defineProperty(fs$9, "__esModule", {
  2761. value: true
  2762. });
  2763. fs$9.createDirentFromStats = void 0;
  2764. class DirentFromStats$1 {
  2765. constructor(name, stats) {
  2766. this.name = name;
  2767. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  2768. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  2769. this.isDirectory = stats.isDirectory.bind(stats);
  2770. this.isFIFO = stats.isFIFO.bind(stats);
  2771. this.isFile = stats.isFile.bind(stats);
  2772. this.isSocket = stats.isSocket.bind(stats);
  2773. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  2774. }
  2775. }
  2776. function createDirentFromStats$1(name, stats) {
  2777. return new DirentFromStats$1(name, stats);
  2778. }
  2779. fs$9.createDirentFromStats = createDirentFromStats$1;
  2780. var path$c = {};
  2781. Object.defineProperty(path$c, "__esModule", {
  2782. value: true
  2783. });
  2784. path$c.removeLeadingDotSegment = path$c.escape = path$c.makeAbsolute = path$c.unixify = void 0;
  2785. const path$b = require$$0__default$1["default"];
  2786. const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
  2787. const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
  2788. /**
  2789. * Designed to work only with simple paths: `dir\\file`.
  2790. */
  2791. function unixify(filepath) {
  2792. return filepath.replace(/\\/g, '/');
  2793. }
  2794. path$c.unixify = unixify;
  2795. function makeAbsolute(cwd, filepath) {
  2796. return path$b.resolve(cwd, filepath);
  2797. }
  2798. path$c.makeAbsolute = makeAbsolute;
  2799. function escape(pattern) {
  2800. return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  2801. }
  2802. path$c.escape = escape;
  2803. function removeLeadingDotSegment(entry) {
  2804. // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
  2805. // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
  2806. if (entry.charAt(0) === '.') {
  2807. const secondCharactery = entry.charAt(1);
  2808. if (secondCharactery === '/' || secondCharactery === '\\') {
  2809. return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
  2810. }
  2811. }
  2812. return entry;
  2813. }
  2814. path$c.removeLeadingDotSegment = removeLeadingDotSegment;
  2815. var pattern$1 = {};
  2816. /*!
  2817. * is-extglob <https://github.com/jonschlinkert/is-extglob>
  2818. *
  2819. * Copyright (c) 2014-2016, Jon Schlinkert.
  2820. * Licensed under the MIT License.
  2821. */
  2822. var isExtglob$1 = function isExtglob(str) {
  2823. if (typeof str !== 'string' || str === '') {
  2824. return false;
  2825. }
  2826. var match;
  2827. while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
  2828. if (match[2]) return true;
  2829. str = str.slice(match.index + match[0].length);
  2830. }
  2831. return false;
  2832. };
  2833. /*!
  2834. * is-glob <https://github.com/jonschlinkert/is-glob>
  2835. *
  2836. * Copyright (c) 2014-2017, Jon Schlinkert.
  2837. * Released under the MIT License.
  2838. */
  2839. var isExtglob = isExtglob$1;
  2840. var chars = {
  2841. '{': '}',
  2842. '(': ')',
  2843. '[': ']'
  2844. };
  2845. var strictCheck = function (str) {
  2846. if (str[0] === '!') {
  2847. return true;
  2848. }
  2849. var index = 0;
  2850. var pipeIndex = -2;
  2851. var closeSquareIndex = -2;
  2852. var closeCurlyIndex = -2;
  2853. var closeParenIndex = -2;
  2854. var backSlashIndex = -2;
  2855. while (index < str.length) {
  2856. if (str[index] === '*') {
  2857. return true;
  2858. }
  2859. if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
  2860. return true;
  2861. }
  2862. if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') {
  2863. if (closeSquareIndex < index) {
  2864. closeSquareIndex = str.indexOf(']', index);
  2865. }
  2866. if (closeSquareIndex > index) {
  2867. if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
  2868. return true;
  2869. }
  2870. backSlashIndex = str.indexOf('\\', index);
  2871. if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
  2872. return true;
  2873. }
  2874. }
  2875. }
  2876. if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') {
  2877. closeCurlyIndex = str.indexOf('}', index);
  2878. if (closeCurlyIndex > index) {
  2879. backSlashIndex = str.indexOf('\\', index);
  2880. if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) {
  2881. return true;
  2882. }
  2883. }
  2884. }
  2885. if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
  2886. closeParenIndex = str.indexOf(')', index);
  2887. if (closeParenIndex > index) {
  2888. backSlashIndex = str.indexOf('\\', index);
  2889. if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
  2890. return true;
  2891. }
  2892. }
  2893. }
  2894. if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') {
  2895. if (pipeIndex < index) {
  2896. pipeIndex = str.indexOf('|', index);
  2897. }
  2898. if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') {
  2899. closeParenIndex = str.indexOf(')', pipeIndex);
  2900. if (closeParenIndex > pipeIndex) {
  2901. backSlashIndex = str.indexOf('\\', pipeIndex);
  2902. if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
  2903. return true;
  2904. }
  2905. }
  2906. }
  2907. }
  2908. if (str[index] === '\\') {
  2909. var open = str[index + 1];
  2910. index += 2;
  2911. var close = chars[open];
  2912. if (close) {
  2913. var n = str.indexOf(close, index);
  2914. if (n !== -1) {
  2915. index = n + 1;
  2916. }
  2917. }
  2918. if (str[index] === '!') {
  2919. return true;
  2920. }
  2921. } else {
  2922. index++;
  2923. }
  2924. }
  2925. return false;
  2926. };
  2927. var relaxedCheck = function (str) {
  2928. if (str[0] === '!') {
  2929. return true;
  2930. }
  2931. var index = 0;
  2932. while (index < str.length) {
  2933. if (/[*?{}()[\]]/.test(str[index])) {
  2934. return true;
  2935. }
  2936. if (str[index] === '\\') {
  2937. var open = str[index + 1];
  2938. index += 2;
  2939. var close = chars[open];
  2940. if (close) {
  2941. var n = str.indexOf(close, index);
  2942. if (n !== -1) {
  2943. index = n + 1;
  2944. }
  2945. }
  2946. if (str[index] === '!') {
  2947. return true;
  2948. }
  2949. } else {
  2950. index++;
  2951. }
  2952. }
  2953. return false;
  2954. };
  2955. var isGlob$1 = function isGlob(str, options) {
  2956. if (typeof str !== 'string' || str === '') {
  2957. return false;
  2958. }
  2959. if (isExtglob(str)) {
  2960. return true;
  2961. }
  2962. var check = strictCheck; // optionally relax check
  2963. if (options && options.strict === false) {
  2964. check = relaxedCheck;
  2965. }
  2966. return check(str);
  2967. };
  2968. var isGlob = isGlob$1;
  2969. var pathPosixDirname = require$$0__default$1["default"].posix.dirname;
  2970. var isWin32 = require$$0__default["default"].platform() === 'win32';
  2971. var slash = '/';
  2972. var backslash = /\\/g;
  2973. var enclosure = /[\{\[].*[\}\]]$/;
  2974. var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
  2975. var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
  2976. /**
  2977. * @param {string} str
  2978. * @param {Object} opts
  2979. * @param {boolean} [opts.flipBackslashes=true]
  2980. * @returns {string}
  2981. */
  2982. var globParent$1 = function globParent(str, opts) {
  2983. var options = Object.assign({
  2984. flipBackslashes: true
  2985. }, opts); // flip windows path separators
  2986. if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
  2987. str = str.replace(backslash, slash);
  2988. } // special case for strings ending in enclosure containing path separator
  2989. if (enclosure.test(str)) {
  2990. str += slash;
  2991. } // preserves full path in case of trailing path separator
  2992. str += 'a'; // remove path parts that are globby
  2993. do {
  2994. str = pathPosixDirname(str);
  2995. } while (isGlob(str) || globby.test(str)); // remove escape chars and return result
  2996. return str.replace(escaped, '$1');
  2997. };
  2998. var utils$j = {};
  2999. (function (exports) {
  3000. exports.isInteger = num => {
  3001. if (typeof num === 'number') {
  3002. return Number.isInteger(num);
  3003. }
  3004. if (typeof num === 'string' && num.trim() !== '') {
  3005. return Number.isInteger(Number(num));
  3006. }
  3007. return false;
  3008. };
  3009. /**
  3010. * Find a node of the given type
  3011. */
  3012. exports.find = (node, type) => node.nodes.find(node => node.type === type);
  3013. /**
  3014. * Find a node of the given type
  3015. */
  3016. exports.exceedsLimit = (min, max, step = 1, limit) => {
  3017. if (limit === false) return false;
  3018. if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
  3019. return (Number(max) - Number(min)) / Number(step) >= limit;
  3020. };
  3021. /**
  3022. * Escape the given node with '\\' before node.value
  3023. */
  3024. exports.escapeNode = (block, n = 0, type) => {
  3025. let node = block.nodes[n];
  3026. if (!node) return;
  3027. if (type && node.type === type || node.type === 'open' || node.type === 'close') {
  3028. if (node.escaped !== true) {
  3029. node.value = '\\' + node.value;
  3030. node.escaped = true;
  3031. }
  3032. }
  3033. };
  3034. /**
  3035. * Returns true if the given brace node should be enclosed in literal braces
  3036. */
  3037. exports.encloseBrace = node => {
  3038. if (node.type !== 'brace') return false;
  3039. if (node.commas >> 0 + node.ranges >> 0 === 0) {
  3040. node.invalid = true;
  3041. return true;
  3042. }
  3043. return false;
  3044. };
  3045. /**
  3046. * Returns true if a brace node is invalid.
  3047. */
  3048. exports.isInvalidBrace = block => {
  3049. if (block.type !== 'brace') return false;
  3050. if (block.invalid === true || block.dollar) return true;
  3051. if (block.commas >> 0 + block.ranges >> 0 === 0) {
  3052. block.invalid = true;
  3053. return true;
  3054. }
  3055. if (block.open !== true || block.close !== true) {
  3056. block.invalid = true;
  3057. return true;
  3058. }
  3059. return false;
  3060. };
  3061. /**
  3062. * Returns true if a node is an open or close node
  3063. */
  3064. exports.isOpenOrClose = node => {
  3065. if (node.type === 'open' || node.type === 'close') {
  3066. return true;
  3067. }
  3068. return node.open === true || node.close === true;
  3069. };
  3070. /**
  3071. * Reduce an array of text nodes.
  3072. */
  3073. exports.reduce = nodes => nodes.reduce((acc, node) => {
  3074. if (node.type === 'text') acc.push(node.value);
  3075. if (node.type === 'range') node.type = 'text';
  3076. return acc;
  3077. }, []);
  3078. /**
  3079. * Flatten an array
  3080. */
  3081. exports.flatten = (...args) => {
  3082. const result = [];
  3083. const flat = arr => {
  3084. for (let i = 0; i < arr.length; i++) {
  3085. let ele = arr[i];
  3086. Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
  3087. }
  3088. return result;
  3089. };
  3090. flat(args);
  3091. return result;
  3092. };
  3093. })(utils$j);
  3094. const utils$i = utils$j;
  3095. var stringify$6 = (ast, options = {}) => {
  3096. let stringify = (node, parent = {}) => {
  3097. let invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
  3098. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  3099. let output = '';
  3100. if (node.value) {
  3101. if ((invalidBlock || invalidNode) && utils$i.isOpenOrClose(node)) {
  3102. return '\\' + node.value;
  3103. }
  3104. return node.value;
  3105. }
  3106. if (node.value) {
  3107. return node.value;
  3108. }
  3109. if (node.nodes) {
  3110. for (let child of node.nodes) {
  3111. output += stringify(child);
  3112. }
  3113. }
  3114. return output;
  3115. };
  3116. return stringify(ast);
  3117. };
  3118. /*!
  3119. * is-number <https://github.com/jonschlinkert/is-number>
  3120. *
  3121. * Copyright (c) 2014-present, Jon Schlinkert.
  3122. * Released under the MIT License.
  3123. */
  3124. var isNumber$3 = function (num) {
  3125. if (typeof num === 'number') {
  3126. return num - num === 0;
  3127. }
  3128. if (typeof num === 'string' && num.trim() !== '') {
  3129. return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
  3130. }
  3131. return false;
  3132. };
  3133. const isNumber$2 = isNumber$3;
  3134. const toRegexRange$1 = (min, max, options) => {
  3135. if (isNumber$2(min) === false) {
  3136. throw new TypeError('toRegexRange: expected the first argument to be a number');
  3137. }
  3138. if (max === void 0 || min === max) {
  3139. return String(min);
  3140. }
  3141. if (isNumber$2(max) === false) {
  3142. throw new TypeError('toRegexRange: expected the second argument to be a number.');
  3143. }
  3144. let opts = Object.assign({
  3145. relaxZeros: true
  3146. }, options);
  3147. if (typeof opts.strictZeros === 'boolean') {
  3148. opts.relaxZeros = opts.strictZeros === false;
  3149. }
  3150. let relax = String(opts.relaxZeros);
  3151. let shorthand = String(opts.shorthand);
  3152. let capture = String(opts.capture);
  3153. let wrap = String(opts.wrap);
  3154. let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
  3155. if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) {
  3156. return toRegexRange$1.cache[cacheKey].result;
  3157. }
  3158. let a = Math.min(min, max);
  3159. let b = Math.max(min, max);
  3160. if (Math.abs(a - b) === 1) {
  3161. let result = min + '|' + max;
  3162. if (opts.capture) {
  3163. return `(${result})`;
  3164. }
  3165. if (opts.wrap === false) {
  3166. return result;
  3167. }
  3168. return `(?:${result})`;
  3169. }
  3170. let isPadded = hasPadding(min) || hasPadding(max);
  3171. let state = {
  3172. min,
  3173. max,
  3174. a,
  3175. b
  3176. };
  3177. let positives = [];
  3178. let negatives = [];
  3179. if (isPadded) {
  3180. state.isPadded = isPadded;
  3181. state.maxLen = String(state.max).length;
  3182. }
  3183. if (a < 0) {
  3184. let newMin = b < 0 ? Math.abs(b) : 1;
  3185. negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
  3186. a = state.a = 0;
  3187. }
  3188. if (b >= 0) {
  3189. positives = splitToPatterns(a, b, state, opts);
  3190. }
  3191. state.negatives = negatives;
  3192. state.positives = positives;
  3193. state.result = collatePatterns(negatives, positives);
  3194. if (opts.capture === true) {
  3195. state.result = `(${state.result})`;
  3196. } else if (opts.wrap !== false && positives.length + negatives.length > 1) {
  3197. state.result = `(?:${state.result})`;
  3198. }
  3199. toRegexRange$1.cache[cacheKey] = state;
  3200. return state.result;
  3201. };
  3202. function collatePatterns(neg, pos, options) {
  3203. let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
  3204. let onlyPositive = filterPatterns(pos, neg, '', false) || [];
  3205. let intersected = filterPatterns(neg, pos, '-?', true) || [];
  3206. let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
  3207. return subpatterns.join('|');
  3208. }
  3209. function splitToRanges(min, max) {
  3210. let nines = 1;
  3211. let zeros = 1;
  3212. let stop = countNines(min, nines);
  3213. let stops = new Set([max]);
  3214. while (min <= stop && stop <= max) {
  3215. stops.add(stop);
  3216. nines += 1;
  3217. stop = countNines(min, nines);
  3218. }
  3219. stop = countZeros(max + 1, zeros) - 1;
  3220. while (min < stop && stop <= max) {
  3221. stops.add(stop);
  3222. zeros += 1;
  3223. stop = countZeros(max + 1, zeros) - 1;
  3224. }
  3225. stops = [...stops];
  3226. stops.sort(compare);
  3227. return stops;
  3228. }
  3229. /**
  3230. * Convert a range to a regex pattern
  3231. * @param {Number} `start`
  3232. * @param {Number} `stop`
  3233. * @return {String}
  3234. */
  3235. function rangeToPattern(start, stop, options) {
  3236. if (start === stop) {
  3237. return {
  3238. pattern: start,
  3239. count: [],
  3240. digits: 0
  3241. };
  3242. }
  3243. let zipped = zip(start, stop);
  3244. let digits = zipped.length;
  3245. let pattern = '';
  3246. let count = 0;
  3247. for (let i = 0; i < digits; i++) {
  3248. let [startDigit, stopDigit] = zipped[i];
  3249. if (startDigit === stopDigit) {
  3250. pattern += startDigit;
  3251. } else if (startDigit !== '0' || stopDigit !== '9') {
  3252. pattern += toCharacterClass(startDigit, stopDigit);
  3253. } else {
  3254. count++;
  3255. }
  3256. }
  3257. if (count) {
  3258. pattern += options.shorthand === true ? '\\d' : '[0-9]';
  3259. }
  3260. return {
  3261. pattern,
  3262. count: [count],
  3263. digits
  3264. };
  3265. }
  3266. function splitToPatterns(min, max, tok, options) {
  3267. let ranges = splitToRanges(min, max);
  3268. let tokens = [];
  3269. let start = min;
  3270. let prev;
  3271. for (let i = 0; i < ranges.length; i++) {
  3272. let max = ranges[i];
  3273. let obj = rangeToPattern(String(start), String(max), options);
  3274. let zeros = '';
  3275. if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
  3276. if (prev.count.length > 1) {
  3277. prev.count.pop();
  3278. }
  3279. prev.count.push(obj.count[0]);
  3280. prev.string = prev.pattern + toQuantifier(prev.count);
  3281. start = max + 1;
  3282. continue;
  3283. }
  3284. if (tok.isPadded) {
  3285. zeros = padZeros(max, tok, options);
  3286. }
  3287. obj.string = zeros + obj.pattern + toQuantifier(obj.count);
  3288. tokens.push(obj);
  3289. start = max + 1;
  3290. prev = obj;
  3291. }
  3292. return tokens;
  3293. }
  3294. function filterPatterns(arr, comparison, prefix, intersection, options) {
  3295. let result = [];
  3296. for (let ele of arr) {
  3297. let {
  3298. string
  3299. } = ele; // only push if _both_ are negative...
  3300. if (!intersection && !contains(comparison, 'string', string)) {
  3301. result.push(prefix + string);
  3302. } // or _both_ are positive
  3303. if (intersection && contains(comparison, 'string', string)) {
  3304. result.push(prefix + string);
  3305. }
  3306. }
  3307. return result;
  3308. }
  3309. /**
  3310. * Zip strings
  3311. */
  3312. function zip(a, b) {
  3313. let arr = [];
  3314. for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
  3315. return arr;
  3316. }
  3317. function compare(a, b) {
  3318. return a > b ? 1 : b > a ? -1 : 0;
  3319. }
  3320. function contains(arr, key, val) {
  3321. return arr.some(ele => ele[key] === val);
  3322. }
  3323. function countNines(min, len) {
  3324. return Number(String(min).slice(0, -len) + '9'.repeat(len));
  3325. }
  3326. function countZeros(integer, zeros) {
  3327. return integer - integer % Math.pow(10, zeros);
  3328. }
  3329. function toQuantifier(digits) {
  3330. let [start = 0, stop = ''] = digits;
  3331. if (stop || start > 1) {
  3332. return `{${start + (stop ? ',' + stop : '')}}`;
  3333. }
  3334. return '';
  3335. }
  3336. function toCharacterClass(a, b, options) {
  3337. return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
  3338. }
  3339. function hasPadding(str) {
  3340. return /^-?(0+)\d/.test(str);
  3341. }
  3342. function padZeros(value, tok, options) {
  3343. if (!tok.isPadded) {
  3344. return value;
  3345. }
  3346. let diff = Math.abs(tok.maxLen - String(value).length);
  3347. let relax = options.relaxZeros !== false;
  3348. switch (diff) {
  3349. case 0:
  3350. return '';
  3351. case 1:
  3352. return relax ? '0?' : '0';
  3353. case 2:
  3354. return relax ? '0{0,2}' : '00';
  3355. default:
  3356. {
  3357. return relax ? `0{0,${diff}}` : `0{${diff}}`;
  3358. }
  3359. }
  3360. }
  3361. /**
  3362. * Cache
  3363. */
  3364. toRegexRange$1.cache = {};
  3365. toRegexRange$1.clearCache = () => toRegexRange$1.cache = {};
  3366. /**
  3367. * Expose `toRegexRange`
  3368. */
  3369. var toRegexRange_1 = toRegexRange$1;
  3370. const util$1 = require$$0__default$2["default"];
  3371. const toRegexRange = toRegexRange_1;
  3372. const isObject$6 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  3373. const transform = toNumber => {
  3374. return value => toNumber === true ? Number(value) : String(value);
  3375. };
  3376. const isValidValue = value => {
  3377. return typeof value === 'number' || typeof value === 'string' && value !== '';
  3378. };
  3379. const isNumber$1 = num => Number.isInteger(+num);
  3380. const zeros = input => {
  3381. let value = `${input}`;
  3382. let index = -1;
  3383. if (value[0] === '-') value = value.slice(1);
  3384. if (value === '0') return false;
  3385. while (value[++index] === '0');
  3386. return index > 0;
  3387. };
  3388. const stringify$5 = (start, end, options) => {
  3389. if (typeof start === 'string' || typeof end === 'string') {
  3390. return true;
  3391. }
  3392. return options.stringify === true;
  3393. };
  3394. const pad = (input, maxLength, toNumber) => {
  3395. if (maxLength > 0) {
  3396. let dash = input[0] === '-' ? '-' : '';
  3397. if (dash) input = input.slice(1);
  3398. input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
  3399. }
  3400. if (toNumber === false) {
  3401. return String(input);
  3402. }
  3403. return input;
  3404. };
  3405. const toMaxLen = (input, maxLength) => {
  3406. let negative = input[0] === '-' ? '-' : '';
  3407. if (negative) {
  3408. input = input.slice(1);
  3409. maxLength--;
  3410. }
  3411. while (input.length < maxLength) input = '0' + input;
  3412. return negative ? '-' + input : input;
  3413. };
  3414. const toSequence = (parts, options) => {
  3415. parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  3416. parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  3417. let prefix = options.capture ? '' : '?:';
  3418. let positives = '';
  3419. let negatives = '';
  3420. let result;
  3421. if (parts.positives.length) {
  3422. positives = parts.positives.join('|');
  3423. }
  3424. if (parts.negatives.length) {
  3425. negatives = `-(${prefix}${parts.negatives.join('|')})`;
  3426. }
  3427. if (positives && negatives) {
  3428. result = `${positives}|${negatives}`;
  3429. } else {
  3430. result = positives || negatives;
  3431. }
  3432. if (options.wrap) {
  3433. return `(${prefix}${result})`;
  3434. }
  3435. return result;
  3436. };
  3437. const toRange = (a, b, isNumbers, options) => {
  3438. if (isNumbers) {
  3439. return toRegexRange(a, b, Object.assign({
  3440. wrap: false
  3441. }, options));
  3442. }
  3443. let start = String.fromCharCode(a);
  3444. if (a === b) return start;
  3445. let stop = String.fromCharCode(b);
  3446. return `[${start}-${stop}]`;
  3447. };
  3448. const toRegex = (start, end, options) => {
  3449. if (Array.isArray(start)) {
  3450. let wrap = options.wrap === true;
  3451. let prefix = options.capture ? '' : '?:';
  3452. return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
  3453. }
  3454. return toRegexRange(start, end, options);
  3455. };
  3456. const rangeError = (...args) => {
  3457. return new RangeError('Invalid range arguments: ' + util$1.inspect(...args));
  3458. };
  3459. const invalidRange = (start, end, options) => {
  3460. if (options.strictRanges === true) throw rangeError([start, end]);
  3461. return [];
  3462. };
  3463. const invalidStep = (step, options) => {
  3464. if (options.strictRanges === true) {
  3465. throw new TypeError(`Expected step "${step}" to be a number`);
  3466. }
  3467. return [];
  3468. };
  3469. const fillNumbers = (start, end, step = 1, options = {}) => {
  3470. let a = Number(start);
  3471. let b = Number(end);
  3472. if (!Number.isInteger(a) || !Number.isInteger(b)) {
  3473. if (options.strictRanges === true) throw rangeError([start, end]);
  3474. return [];
  3475. } // fix negative zero
  3476. if (a === 0) a = 0;
  3477. if (b === 0) b = 0;
  3478. let descending = a > b;
  3479. let startString = String(start);
  3480. let endString = String(end);
  3481. let stepString = String(step);
  3482. step = Math.max(Math.abs(step), 1);
  3483. let padded = zeros(startString) || zeros(endString) || zeros(stepString);
  3484. let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
  3485. let toNumber = padded === false && stringify$5(start, end, options) === false;
  3486. let format = options.transform || transform(toNumber);
  3487. if (options.toRegex && step === 1) {
  3488. return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
  3489. }
  3490. let parts = {
  3491. negatives: [],
  3492. positives: []
  3493. };
  3494. let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
  3495. let range = [];
  3496. let index = 0;
  3497. while (descending ? a >= b : a <= b) {
  3498. if (options.toRegex === true && step > 1) {
  3499. push(a);
  3500. } else {
  3501. range.push(pad(format(a, index), maxLen, toNumber));
  3502. }
  3503. a = descending ? a - step : a + step;
  3504. index++;
  3505. }
  3506. if (options.toRegex === true) {
  3507. return step > 1 ? toSequence(parts, options) : toRegex(range, null, Object.assign({
  3508. wrap: false
  3509. }, options));
  3510. }
  3511. return range;
  3512. };
  3513. const fillLetters = (start, end, step = 1, options = {}) => {
  3514. if (!isNumber$1(start) && start.length > 1 || !isNumber$1(end) && end.length > 1) {
  3515. return invalidRange(start, end, options);
  3516. }
  3517. let format = options.transform || (val => String.fromCharCode(val));
  3518. let a = `${start}`.charCodeAt(0);
  3519. let b = `${end}`.charCodeAt(0);
  3520. let descending = a > b;
  3521. let min = Math.min(a, b);
  3522. let max = Math.max(a, b);
  3523. if (options.toRegex && step === 1) {
  3524. return toRange(min, max, false, options);
  3525. }
  3526. let range = [];
  3527. let index = 0;
  3528. while (descending ? a >= b : a <= b) {
  3529. range.push(format(a, index));
  3530. a = descending ? a - step : a + step;
  3531. index++;
  3532. }
  3533. if (options.toRegex === true) {
  3534. return toRegex(range, null, {
  3535. wrap: false,
  3536. options
  3537. });
  3538. }
  3539. return range;
  3540. };
  3541. const fill$2 = (start, end, step, options = {}) => {
  3542. if (end == null && isValidValue(start)) {
  3543. return [start];
  3544. }
  3545. if (!isValidValue(start) || !isValidValue(end)) {
  3546. return invalidRange(start, end, options);
  3547. }
  3548. if (typeof step === 'function') {
  3549. return fill$2(start, end, 1, {
  3550. transform: step
  3551. });
  3552. }
  3553. if (isObject$6(step)) {
  3554. return fill$2(start, end, 0, step);
  3555. }
  3556. let opts = Object.assign({}, options);
  3557. if (opts.capture === true) opts.wrap = true;
  3558. step = step || opts.step || 1;
  3559. if (!isNumber$1(step)) {
  3560. if (step != null && !isObject$6(step)) return invalidStep(step, opts);
  3561. return fill$2(start, end, 1, step);
  3562. }
  3563. if (isNumber$1(start) && isNumber$1(end)) {
  3564. return fillNumbers(start, end, step, opts);
  3565. }
  3566. return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
  3567. };
  3568. var fillRange = fill$2;
  3569. const fill$1 = fillRange;
  3570. const utils$h = utils$j;
  3571. const compile$1 = (ast, options = {}) => {
  3572. let walk = (node, parent = {}) => {
  3573. let invalidBlock = utils$h.isInvalidBrace(parent);
  3574. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  3575. let invalid = invalidBlock === true || invalidNode === true;
  3576. let prefix = options.escapeInvalid === true ? '\\' : '';
  3577. let output = '';
  3578. if (node.isOpen === true) {
  3579. return prefix + node.value;
  3580. }
  3581. if (node.isClose === true) {
  3582. return prefix + node.value;
  3583. }
  3584. if (node.type === 'open') {
  3585. return invalid ? prefix + node.value : '(';
  3586. }
  3587. if (node.type === 'close') {
  3588. return invalid ? prefix + node.value : ')';
  3589. }
  3590. if (node.type === 'comma') {
  3591. return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
  3592. }
  3593. if (node.value) {
  3594. return node.value;
  3595. }
  3596. if (node.nodes && node.ranges > 0) {
  3597. let args = utils$h.reduce(node.nodes);
  3598. let range = fill$1(...args, Object.assign(Object.assign({}, options), {}, {
  3599. wrap: false,
  3600. toRegex: true
  3601. }));
  3602. if (range.length !== 0) {
  3603. return args.length > 1 && range.length > 1 ? `(${range})` : range;
  3604. }
  3605. }
  3606. if (node.nodes) {
  3607. for (let child of node.nodes) {
  3608. output += walk(child, node);
  3609. }
  3610. }
  3611. return output;
  3612. };
  3613. return walk(ast);
  3614. };
  3615. var compile_1 = compile$1;
  3616. const fill = fillRange;
  3617. const stringify$4 = stringify$6;
  3618. const utils$g = utils$j;
  3619. const append = (queue = '', stash = '', enclose = false) => {
  3620. let result = [];
  3621. queue = [].concat(queue);
  3622. stash = [].concat(stash);
  3623. if (!stash.length) return queue;
  3624. if (!queue.length) {
  3625. return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
  3626. }
  3627. for (let item of queue) {
  3628. if (Array.isArray(item)) {
  3629. for (let value of item) {
  3630. result.push(append(value, stash, enclose));
  3631. }
  3632. } else {
  3633. for (let ele of stash) {
  3634. if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
  3635. result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
  3636. }
  3637. }
  3638. }
  3639. return utils$g.flatten(result);
  3640. };
  3641. const expand$1 = (ast, options = {}) => {
  3642. let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
  3643. let walk = (node, parent = {}) => {
  3644. node.queue = [];
  3645. let p = parent;
  3646. let q = parent.queue;
  3647. while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
  3648. p = p.parent;
  3649. q = p.queue;
  3650. }
  3651. if (node.invalid || node.dollar) {
  3652. q.push(append(q.pop(), stringify$4(node, options)));
  3653. return;
  3654. }
  3655. if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
  3656. q.push(append(q.pop(), ['{}']));
  3657. return;
  3658. }
  3659. if (node.nodes && node.ranges > 0) {
  3660. let args = utils$g.reduce(node.nodes);
  3661. if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
  3662. throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
  3663. }
  3664. let range = fill(...args, options);
  3665. if (range.length === 0) {
  3666. range = stringify$4(node, options);
  3667. }
  3668. q.push(append(q.pop(), range));
  3669. node.nodes = [];
  3670. return;
  3671. }
  3672. let enclose = utils$g.encloseBrace(node);
  3673. let queue = node.queue;
  3674. let block = node;
  3675. while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
  3676. block = block.parent;
  3677. queue = block.queue;
  3678. }
  3679. for (let i = 0; i < node.nodes.length; i++) {
  3680. let child = node.nodes[i];
  3681. if (child.type === 'comma' && node.type === 'brace') {
  3682. if (i === 1) queue.push('');
  3683. queue.push('');
  3684. continue;
  3685. }
  3686. if (child.type === 'close') {
  3687. q.push(append(q.pop(), queue, enclose));
  3688. continue;
  3689. }
  3690. if (child.value && child.type !== 'open') {
  3691. queue.push(append(queue.pop(), child.value));
  3692. continue;
  3693. }
  3694. if (child.nodes) {
  3695. walk(child, node);
  3696. }
  3697. }
  3698. return queue;
  3699. };
  3700. return utils$g.flatten(walk(ast));
  3701. };
  3702. var expand_1 = expand$1;
  3703. var constants$4 = {
  3704. MAX_LENGTH: 1024 * 64,
  3705. // Digits
  3706. CHAR_0: '0',
  3707. /* 0 */
  3708. CHAR_9: '9',
  3709. /* 9 */
  3710. // Alphabet chars.
  3711. CHAR_UPPERCASE_A: 'A',
  3712. /* A */
  3713. CHAR_LOWERCASE_A: 'a',
  3714. /* a */
  3715. CHAR_UPPERCASE_Z: 'Z',
  3716. /* Z */
  3717. CHAR_LOWERCASE_Z: 'z',
  3718. /* z */
  3719. CHAR_LEFT_PARENTHESES: '(',
  3720. /* ( */
  3721. CHAR_RIGHT_PARENTHESES: ')',
  3722. /* ) */
  3723. CHAR_ASTERISK: '*',
  3724. /* * */
  3725. // Non-alphabetic chars.
  3726. CHAR_AMPERSAND: '&',
  3727. /* & */
  3728. CHAR_AT: '@',
  3729. /* @ */
  3730. CHAR_BACKSLASH: '\\',
  3731. /* \ */
  3732. CHAR_BACKTICK: '`',
  3733. /* ` */
  3734. CHAR_CARRIAGE_RETURN: '\r',
  3735. /* \r */
  3736. CHAR_CIRCUMFLEX_ACCENT: '^',
  3737. /* ^ */
  3738. CHAR_COLON: ':',
  3739. /* : */
  3740. CHAR_COMMA: ',',
  3741. /* , */
  3742. CHAR_DOLLAR: '$',
  3743. /* . */
  3744. CHAR_DOT: '.',
  3745. /* . */
  3746. CHAR_DOUBLE_QUOTE: '"',
  3747. /* " */
  3748. CHAR_EQUAL: '=',
  3749. /* = */
  3750. CHAR_EXCLAMATION_MARK: '!',
  3751. /* ! */
  3752. CHAR_FORM_FEED: '\f',
  3753. /* \f */
  3754. CHAR_FORWARD_SLASH: '/',
  3755. /* / */
  3756. CHAR_HASH: '#',
  3757. /* # */
  3758. CHAR_HYPHEN_MINUS: '-',
  3759. /* - */
  3760. CHAR_LEFT_ANGLE_BRACKET: '<',
  3761. /* < */
  3762. CHAR_LEFT_CURLY_BRACE: '{',
  3763. /* { */
  3764. CHAR_LEFT_SQUARE_BRACKET: '[',
  3765. /* [ */
  3766. CHAR_LINE_FEED: '\n',
  3767. /* \n */
  3768. CHAR_NO_BREAK_SPACE: '\u00A0',
  3769. /* \u00A0 */
  3770. CHAR_PERCENT: '%',
  3771. /* % */
  3772. CHAR_PLUS: '+',
  3773. /* + */
  3774. CHAR_QUESTION_MARK: '?',
  3775. /* ? */
  3776. CHAR_RIGHT_ANGLE_BRACKET: '>',
  3777. /* > */
  3778. CHAR_RIGHT_CURLY_BRACE: '}',
  3779. /* } */
  3780. CHAR_RIGHT_SQUARE_BRACKET: ']',
  3781. /* ] */
  3782. CHAR_SEMICOLON: ';',
  3783. /* ; */
  3784. CHAR_SINGLE_QUOTE: '\'',
  3785. /* ' */
  3786. CHAR_SPACE: ' ',
  3787. /* */
  3788. CHAR_TAB: '\t',
  3789. /* \t */
  3790. CHAR_UNDERSCORE: '_',
  3791. /* _ */
  3792. CHAR_VERTICAL_LINE: '|',
  3793. /* | */
  3794. CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
  3795. /* \uFEFF */
  3796. };
  3797. const stringify$3 = stringify$6;
  3798. /**
  3799. * Constants
  3800. */
  3801. const {
  3802. MAX_LENGTH: MAX_LENGTH$1,
  3803. CHAR_BACKSLASH,
  3804. /* \ */
  3805. CHAR_BACKTICK,
  3806. /* ` */
  3807. CHAR_COMMA: CHAR_COMMA$1,
  3808. /* , */
  3809. CHAR_DOT: CHAR_DOT$1,
  3810. /* . */
  3811. CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1,
  3812. /* ( */
  3813. CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1,
  3814. /* ) */
  3815. CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1,
  3816. /* { */
  3817. CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1,
  3818. /* } */
  3819. CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1,
  3820. /* [ */
  3821. CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1,
  3822. /* ] */
  3823. CHAR_DOUBLE_QUOTE,
  3824. /* " */
  3825. CHAR_SINGLE_QUOTE,
  3826. /* ' */
  3827. CHAR_NO_BREAK_SPACE,
  3828. CHAR_ZERO_WIDTH_NOBREAK_SPACE
  3829. } = constants$4;
  3830. /**
  3831. * parse
  3832. */
  3833. const parse$4 = (input, options = {}) => {
  3834. if (typeof input !== 'string') {
  3835. throw new TypeError('Expected a string');
  3836. }
  3837. let opts = options || {};
  3838. let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
  3839. if (input.length > max) {
  3840. throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
  3841. }
  3842. let ast = {
  3843. type: 'root',
  3844. input,
  3845. nodes: []
  3846. };
  3847. let stack = [ast];
  3848. let block = ast;
  3849. let prev = ast;
  3850. let brackets = 0;
  3851. let length = input.length;
  3852. let index = 0;
  3853. let depth = 0;
  3854. let value;
  3855. /**
  3856. * Helpers
  3857. */
  3858. const advance = () => input[index++];
  3859. const push = node => {
  3860. if (node.type === 'text' && prev.type === 'dot') {
  3861. prev.type = 'text';
  3862. }
  3863. if (prev && prev.type === 'text' && node.type === 'text') {
  3864. prev.value += node.value;
  3865. return;
  3866. }
  3867. block.nodes.push(node);
  3868. node.parent = block;
  3869. node.prev = prev;
  3870. prev = node;
  3871. return node;
  3872. };
  3873. push({
  3874. type: 'bos'
  3875. });
  3876. while (index < length) {
  3877. block = stack[stack.length - 1];
  3878. value = advance();
  3879. /**
  3880. * Invalid chars
  3881. */
  3882. if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
  3883. continue;
  3884. }
  3885. /**
  3886. * Escaped chars
  3887. */
  3888. if (value === CHAR_BACKSLASH) {
  3889. push({
  3890. type: 'text',
  3891. value: (options.keepEscaping ? value : '') + advance()
  3892. });
  3893. continue;
  3894. }
  3895. /**
  3896. * Right square bracket (literal): ']'
  3897. */
  3898. if (value === CHAR_RIGHT_SQUARE_BRACKET$1) {
  3899. push({
  3900. type: 'text',
  3901. value: '\\' + value
  3902. });
  3903. continue;
  3904. }
  3905. /**
  3906. * Left square bracket: '['
  3907. */
  3908. if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
  3909. brackets++;
  3910. let next;
  3911. while (index < length && (next = advance())) {
  3912. value += next;
  3913. if (next === CHAR_LEFT_SQUARE_BRACKET$1) {
  3914. brackets++;
  3915. continue;
  3916. }
  3917. if (next === CHAR_BACKSLASH) {
  3918. value += advance();
  3919. continue;
  3920. }
  3921. if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
  3922. brackets--;
  3923. if (brackets === 0) {
  3924. break;
  3925. }
  3926. }
  3927. }
  3928. push({
  3929. type: 'text',
  3930. value
  3931. });
  3932. continue;
  3933. }
  3934. /**
  3935. * Parentheses
  3936. */
  3937. if (value === CHAR_LEFT_PARENTHESES$1) {
  3938. block = push({
  3939. type: 'paren',
  3940. nodes: []
  3941. });
  3942. stack.push(block);
  3943. push({
  3944. type: 'text',
  3945. value
  3946. });
  3947. continue;
  3948. }
  3949. if (value === CHAR_RIGHT_PARENTHESES$1) {
  3950. if (block.type !== 'paren') {
  3951. push({
  3952. type: 'text',
  3953. value
  3954. });
  3955. continue;
  3956. }
  3957. block = stack.pop();
  3958. push({
  3959. type: 'text',
  3960. value
  3961. });
  3962. block = stack[stack.length - 1];
  3963. continue;
  3964. }
  3965. /**
  3966. * Quotes: '|"|`
  3967. */
  3968. if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
  3969. let open = value;
  3970. let next;
  3971. if (options.keepQuotes !== true) {
  3972. value = '';
  3973. }
  3974. while (index < length && (next = advance())) {
  3975. if (next === CHAR_BACKSLASH) {
  3976. value += next + advance();
  3977. continue;
  3978. }
  3979. if (next === open) {
  3980. if (options.keepQuotes === true) value += next;
  3981. break;
  3982. }
  3983. value += next;
  3984. }
  3985. push({
  3986. type: 'text',
  3987. value
  3988. });
  3989. continue;
  3990. }
  3991. /**
  3992. * Left curly brace: '{'
  3993. */
  3994. if (value === CHAR_LEFT_CURLY_BRACE$1) {
  3995. depth++;
  3996. let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
  3997. let brace = {
  3998. type: 'brace',
  3999. open: true,
  4000. close: false,
  4001. dollar,
  4002. depth,
  4003. commas: 0,
  4004. ranges: 0,
  4005. nodes: []
  4006. };
  4007. block = push(brace);
  4008. stack.push(block);
  4009. push({
  4010. type: 'open',
  4011. value
  4012. });
  4013. continue;
  4014. }
  4015. /**
  4016. * Right curly brace: '}'
  4017. */
  4018. if (value === CHAR_RIGHT_CURLY_BRACE$1) {
  4019. if (block.type !== 'brace') {
  4020. push({
  4021. type: 'text',
  4022. value
  4023. });
  4024. continue;
  4025. }
  4026. let type = 'close';
  4027. block = stack.pop();
  4028. block.close = true;
  4029. push({
  4030. type,
  4031. value
  4032. });
  4033. depth--;
  4034. block = stack[stack.length - 1];
  4035. continue;
  4036. }
  4037. /**
  4038. * Comma: ','
  4039. */
  4040. if (value === CHAR_COMMA$1 && depth > 0) {
  4041. if (block.ranges > 0) {
  4042. block.ranges = 0;
  4043. let open = block.nodes.shift();
  4044. block.nodes = [open, {
  4045. type: 'text',
  4046. value: stringify$3(block)
  4047. }];
  4048. }
  4049. push({
  4050. type: 'comma',
  4051. value
  4052. });
  4053. block.commas++;
  4054. continue;
  4055. }
  4056. /**
  4057. * Dot: '.'
  4058. */
  4059. if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
  4060. let siblings = block.nodes;
  4061. if (depth === 0 || siblings.length === 0) {
  4062. push({
  4063. type: 'text',
  4064. value
  4065. });
  4066. continue;
  4067. }
  4068. if (prev.type === 'dot') {
  4069. block.range = [];
  4070. prev.value += value;
  4071. prev.type = 'range';
  4072. if (block.nodes.length !== 3 && block.nodes.length !== 5) {
  4073. block.invalid = true;
  4074. block.ranges = 0;
  4075. prev.type = 'text';
  4076. continue;
  4077. }
  4078. block.ranges++;
  4079. block.args = [];
  4080. continue;
  4081. }
  4082. if (prev.type === 'range') {
  4083. siblings.pop();
  4084. let before = siblings[siblings.length - 1];
  4085. before.value += prev.value + value;
  4086. prev = before;
  4087. block.ranges--;
  4088. continue;
  4089. }
  4090. push({
  4091. type: 'dot',
  4092. value
  4093. });
  4094. continue;
  4095. }
  4096. /**
  4097. * Text
  4098. */
  4099. push({
  4100. type: 'text',
  4101. value
  4102. });
  4103. } // Mark imbalanced braces and brackets as invalid
  4104. do {
  4105. block = stack.pop();
  4106. if (block.type !== 'root') {
  4107. block.nodes.forEach(node => {
  4108. if (!node.nodes) {
  4109. if (node.type === 'open') node.isOpen = true;
  4110. if (node.type === 'close') node.isClose = true;
  4111. if (!node.nodes) node.type = 'text';
  4112. node.invalid = true;
  4113. }
  4114. }); // get the location of the block on parent.nodes (block's siblings)
  4115. let parent = stack[stack.length - 1];
  4116. let index = parent.nodes.indexOf(block); // replace the (invalid) block with it's nodes
  4117. parent.nodes.splice(index, 1, ...block.nodes);
  4118. }
  4119. } while (stack.length > 0);
  4120. push({
  4121. type: 'eos'
  4122. });
  4123. return ast;
  4124. };
  4125. var parse_1$1 = parse$4;
  4126. const stringify$2 = stringify$6;
  4127. const compile = compile_1;
  4128. const expand = expand_1;
  4129. const parse$3 = parse_1$1;
  4130. /**
  4131. * Expand the given pattern or create a regex-compatible string.
  4132. *
  4133. * ```js
  4134. * const braces = require('braces');
  4135. * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
  4136. * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
  4137. * ```
  4138. * @param {String} `str`
  4139. * @param {Object} `options`
  4140. * @return {String}
  4141. * @api public
  4142. */
  4143. const braces$1 = (input, options = {}) => {
  4144. let output = [];
  4145. if (Array.isArray(input)) {
  4146. for (let pattern of input) {
  4147. let result = braces$1.create(pattern, options);
  4148. if (Array.isArray(result)) {
  4149. output.push(...result);
  4150. } else {
  4151. output.push(result);
  4152. }
  4153. }
  4154. } else {
  4155. output = [].concat(braces$1.create(input, options));
  4156. }
  4157. if (options && options.expand === true && options.nodupes === true) {
  4158. output = [...new Set(output)];
  4159. }
  4160. return output;
  4161. };
  4162. /**
  4163. * Parse the given `str` with the given `options`.
  4164. *
  4165. * ```js
  4166. * // braces.parse(pattern, [, options]);
  4167. * const ast = braces.parse('a/{b,c}/d');
  4168. * console.log(ast);
  4169. * ```
  4170. * @param {String} pattern Brace pattern to parse
  4171. * @param {Object} options
  4172. * @return {Object} Returns an AST
  4173. * @api public
  4174. */
  4175. braces$1.parse = (input, options = {}) => parse$3(input, options);
  4176. /**
  4177. * Creates a braces string from an AST, or an AST node.
  4178. *
  4179. * ```js
  4180. * const braces = require('braces');
  4181. * let ast = braces.parse('foo/{a,b}/bar');
  4182. * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
  4183. * ```
  4184. * @param {String} `input` Brace pattern or AST.
  4185. * @param {Object} `options`
  4186. * @return {Array} Returns an array of expanded values.
  4187. * @api public
  4188. */
  4189. braces$1.stringify = (input, options = {}) => {
  4190. if (typeof input === 'string') {
  4191. return stringify$2(braces$1.parse(input, options), options);
  4192. }
  4193. return stringify$2(input, options);
  4194. };
  4195. /**
  4196. * Compiles a brace pattern into a regex-compatible, optimized string.
  4197. * This method is called by the main [braces](#braces) function by default.
  4198. *
  4199. * ```js
  4200. * const braces = require('braces');
  4201. * console.log(braces.compile('a/{b,c}/d'));
  4202. * //=> ['a/(b|c)/d']
  4203. * ```
  4204. * @param {String} `input` Brace pattern or AST.
  4205. * @param {Object} `options`
  4206. * @return {Array} Returns an array of expanded values.
  4207. * @api public
  4208. */
  4209. braces$1.compile = (input, options = {}) => {
  4210. if (typeof input === 'string') {
  4211. input = braces$1.parse(input, options);
  4212. }
  4213. return compile(input, options);
  4214. };
  4215. /**
  4216. * Expands a brace pattern into an array. This method is called by the
  4217. * main [braces](#braces) function when `options.expand` is true. Before
  4218. * using this method it's recommended that you read the [performance notes](#performance))
  4219. * and advantages of using [.compile](#compile) instead.
  4220. *
  4221. * ```js
  4222. * const braces = require('braces');
  4223. * console.log(braces.expand('a/{b,c}/d'));
  4224. * //=> ['a/b/d', 'a/c/d'];
  4225. * ```
  4226. * @param {String} `pattern` Brace pattern
  4227. * @param {Object} `options`
  4228. * @return {Array} Returns an array of expanded values.
  4229. * @api public
  4230. */
  4231. braces$1.expand = (input, options = {}) => {
  4232. if (typeof input === 'string') {
  4233. input = braces$1.parse(input, options);
  4234. }
  4235. let result = expand(input, options); // filter out empty strings if specified
  4236. if (options.noempty === true) {
  4237. result = result.filter(Boolean);
  4238. } // filter out duplicates if specified
  4239. if (options.nodupes === true) {
  4240. result = [...new Set(result)];
  4241. }
  4242. return result;
  4243. };
  4244. /**
  4245. * Processes a brace pattern and returns either an expanded array
  4246. * (if `options.expand` is true), a highly optimized regex-compatible string.
  4247. * This method is called by the main [braces](#braces) function.
  4248. *
  4249. * ```js
  4250. * const braces = require('braces');
  4251. * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
  4252. * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
  4253. * ```
  4254. * @param {String} `pattern` Brace pattern
  4255. * @param {Object} `options`
  4256. * @return {Array} Returns an array of expanded values.
  4257. * @api public
  4258. */
  4259. braces$1.create = (input, options = {}) => {
  4260. if (input === '' || input.length < 3) {
  4261. return [input];
  4262. }
  4263. return options.expand !== true ? braces$1.compile(input, options) : braces$1.expand(input, options);
  4264. };
  4265. /**
  4266. * Expose "braces"
  4267. */
  4268. var braces_1 = braces$1;
  4269. var utils$f = {};
  4270. const path$a = require$$0__default$1["default"];
  4271. const WIN_SLASH = '\\\\/';
  4272. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  4273. /**
  4274. * Posix glob regex
  4275. */
  4276. const DOT_LITERAL = '\\.';
  4277. const PLUS_LITERAL = '\\+';
  4278. const QMARK_LITERAL = '\\?';
  4279. const SLASH_LITERAL = '\\/';
  4280. const ONE_CHAR = '(?=.)';
  4281. const QMARK = '[^/]';
  4282. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  4283. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  4284. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  4285. const NO_DOT = `(?!${DOT_LITERAL})`;
  4286. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  4287. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  4288. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  4289. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  4290. const STAR = `${QMARK}*?`;
  4291. const POSIX_CHARS = {
  4292. DOT_LITERAL,
  4293. PLUS_LITERAL,
  4294. QMARK_LITERAL,
  4295. SLASH_LITERAL,
  4296. ONE_CHAR,
  4297. QMARK,
  4298. END_ANCHOR,
  4299. DOTS_SLASH,
  4300. NO_DOT,
  4301. NO_DOTS,
  4302. NO_DOT_SLASH,
  4303. NO_DOTS_SLASH,
  4304. QMARK_NO_DOT,
  4305. STAR,
  4306. START_ANCHOR
  4307. };
  4308. /**
  4309. * Windows glob regex
  4310. */
  4311. const WINDOWS_CHARS = Object.assign(Object.assign({}, POSIX_CHARS), {}, {
  4312. SLASH_LITERAL: `[${WIN_SLASH}]`,
  4313. QMARK: WIN_NO_SLASH,
  4314. STAR: `${WIN_NO_SLASH}*?`,
  4315. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  4316. NO_DOT: `(?!${DOT_LITERAL})`,
  4317. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  4318. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  4319. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  4320. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  4321. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  4322. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
  4323. });
  4324. /**
  4325. * POSIX Bracket Regex
  4326. */
  4327. const POSIX_REGEX_SOURCE$1 = {
  4328. alnum: 'a-zA-Z0-9',
  4329. alpha: 'a-zA-Z',
  4330. ascii: '\\x00-\\x7F',
  4331. blank: ' \\t',
  4332. cntrl: '\\x00-\\x1F\\x7F',
  4333. digit: '0-9',
  4334. graph: '\\x21-\\x7E',
  4335. lower: 'a-z',
  4336. print: '\\x20-\\x7E ',
  4337. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  4338. space: ' \\t\\r\\n\\v\\f',
  4339. upper: 'A-Z',
  4340. word: 'A-Za-z0-9_',
  4341. xdigit: 'A-Fa-f0-9'
  4342. };
  4343. var constants$3 = {
  4344. MAX_LENGTH: 1024 * 64,
  4345. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  4346. // regular expressions
  4347. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  4348. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  4349. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  4350. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  4351. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  4352. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  4353. // Replace globs with equivalent patterns to reduce parsing time.
  4354. REPLACEMENTS: {
  4355. '***': '*',
  4356. '**/**': '**',
  4357. '**/**/**': '**'
  4358. },
  4359. // Digits
  4360. CHAR_0: 48,
  4361. /* 0 */
  4362. CHAR_9: 57,
  4363. /* 9 */
  4364. // Alphabet chars.
  4365. CHAR_UPPERCASE_A: 65,
  4366. /* A */
  4367. CHAR_LOWERCASE_A: 97,
  4368. /* a */
  4369. CHAR_UPPERCASE_Z: 90,
  4370. /* Z */
  4371. CHAR_LOWERCASE_Z: 122,
  4372. /* z */
  4373. CHAR_LEFT_PARENTHESES: 40,
  4374. /* ( */
  4375. CHAR_RIGHT_PARENTHESES: 41,
  4376. /* ) */
  4377. CHAR_ASTERISK: 42,
  4378. /* * */
  4379. // Non-alphabetic chars.
  4380. CHAR_AMPERSAND: 38,
  4381. /* & */
  4382. CHAR_AT: 64,
  4383. /* @ */
  4384. CHAR_BACKWARD_SLASH: 92,
  4385. /* \ */
  4386. CHAR_CARRIAGE_RETURN: 13,
  4387. /* \r */
  4388. CHAR_CIRCUMFLEX_ACCENT: 94,
  4389. /* ^ */
  4390. CHAR_COLON: 58,
  4391. /* : */
  4392. CHAR_COMMA: 44,
  4393. /* , */
  4394. CHAR_DOT: 46,
  4395. /* . */
  4396. CHAR_DOUBLE_QUOTE: 34,
  4397. /* " */
  4398. CHAR_EQUAL: 61,
  4399. /* = */
  4400. CHAR_EXCLAMATION_MARK: 33,
  4401. /* ! */
  4402. CHAR_FORM_FEED: 12,
  4403. /* \f */
  4404. CHAR_FORWARD_SLASH: 47,
  4405. /* / */
  4406. CHAR_GRAVE_ACCENT: 96,
  4407. /* ` */
  4408. CHAR_HASH: 35,
  4409. /* # */
  4410. CHAR_HYPHEN_MINUS: 45,
  4411. /* - */
  4412. CHAR_LEFT_ANGLE_BRACKET: 60,
  4413. /* < */
  4414. CHAR_LEFT_CURLY_BRACE: 123,
  4415. /* { */
  4416. CHAR_LEFT_SQUARE_BRACKET: 91,
  4417. /* [ */
  4418. CHAR_LINE_FEED: 10,
  4419. /* \n */
  4420. CHAR_NO_BREAK_SPACE: 160,
  4421. /* \u00A0 */
  4422. CHAR_PERCENT: 37,
  4423. /* % */
  4424. CHAR_PLUS: 43,
  4425. /* + */
  4426. CHAR_QUESTION_MARK: 63,
  4427. /* ? */
  4428. CHAR_RIGHT_ANGLE_BRACKET: 62,
  4429. /* > */
  4430. CHAR_RIGHT_CURLY_BRACE: 125,
  4431. /* } */
  4432. CHAR_RIGHT_SQUARE_BRACKET: 93,
  4433. /* ] */
  4434. CHAR_SEMICOLON: 59,
  4435. /* ; */
  4436. CHAR_SINGLE_QUOTE: 39,
  4437. /* ' */
  4438. CHAR_SPACE: 32,
  4439. /* */
  4440. CHAR_TAB: 9,
  4441. /* \t */
  4442. CHAR_UNDERSCORE: 95,
  4443. /* _ */
  4444. CHAR_VERTICAL_LINE: 124,
  4445. /* | */
  4446. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
  4447. /* \uFEFF */
  4448. SEP: path$a.sep,
  4449. /**
  4450. * Create EXTGLOB_CHARS
  4451. */
  4452. extglobChars(chars) {
  4453. return {
  4454. '!': {
  4455. type: 'negate',
  4456. open: '(?:(?!(?:',
  4457. close: `))${chars.STAR})`
  4458. },
  4459. '?': {
  4460. type: 'qmark',
  4461. open: '(?:',
  4462. close: ')?'
  4463. },
  4464. '+': {
  4465. type: 'plus',
  4466. open: '(?:',
  4467. close: ')+'
  4468. },
  4469. '*': {
  4470. type: 'star',
  4471. open: '(?:',
  4472. close: ')*'
  4473. },
  4474. '@': {
  4475. type: 'at',
  4476. open: '(?:',
  4477. close: ')'
  4478. }
  4479. };
  4480. },
  4481. /**
  4482. * Create GLOB_CHARS
  4483. */
  4484. globChars(win32) {
  4485. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  4486. }
  4487. };
  4488. (function (exports) {
  4489. const path = require$$0__default$1["default"];
  4490. const win32 = process.platform === 'win32';
  4491. const {
  4492. REGEX_BACKSLASH,
  4493. REGEX_REMOVE_BACKSLASH,
  4494. REGEX_SPECIAL_CHARS,
  4495. REGEX_SPECIAL_CHARS_GLOBAL
  4496. } = constants$3;
  4497. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  4498. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  4499. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  4500. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  4501. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  4502. exports.removeBackslashes = str => {
  4503. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  4504. return match === '\\' ? '' : match;
  4505. });
  4506. };
  4507. exports.supportsLookbehinds = () => {
  4508. const segs = process.version.slice(1).split('.').map(Number);
  4509. if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
  4510. return true;
  4511. }
  4512. return false;
  4513. };
  4514. exports.isWindows = options => {
  4515. if (options && typeof options.windows === 'boolean') {
  4516. return options.windows;
  4517. }
  4518. return win32 === true || path.sep === '\\';
  4519. };
  4520. exports.escapeLast = (input, char, lastIdx) => {
  4521. const idx = input.lastIndexOf(char, lastIdx);
  4522. if (idx === -1) return input;
  4523. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  4524. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  4525. };
  4526. exports.removePrefix = (input, state = {}) => {
  4527. let output = input;
  4528. if (output.startsWith('./')) {
  4529. output = output.slice(2);
  4530. state.prefix = './';
  4531. }
  4532. return output;
  4533. };
  4534. exports.wrapOutput = (input, state = {}, options = {}) => {
  4535. const prepend = options.contains ? '' : '^';
  4536. const append = options.contains ? '' : '$';
  4537. let output = `${prepend}(?:${input})${append}`;
  4538. if (state.negated === true) {
  4539. output = `(?:^(?!${output}).*$)`;
  4540. }
  4541. return output;
  4542. };
  4543. })(utils$f);
  4544. const utils$e = utils$f;
  4545. const {
  4546. CHAR_ASTERISK,
  4547. /* * */
  4548. CHAR_AT,
  4549. /* @ */
  4550. CHAR_BACKWARD_SLASH,
  4551. /* \ */
  4552. CHAR_COMMA,
  4553. /* , */
  4554. CHAR_DOT,
  4555. /* . */
  4556. CHAR_EXCLAMATION_MARK,
  4557. /* ! */
  4558. CHAR_FORWARD_SLASH,
  4559. /* / */
  4560. CHAR_LEFT_CURLY_BRACE,
  4561. /* { */
  4562. CHAR_LEFT_PARENTHESES,
  4563. /* ( */
  4564. CHAR_LEFT_SQUARE_BRACKET,
  4565. /* [ */
  4566. CHAR_PLUS,
  4567. /* + */
  4568. CHAR_QUESTION_MARK,
  4569. /* ? */
  4570. CHAR_RIGHT_CURLY_BRACE,
  4571. /* } */
  4572. CHAR_RIGHT_PARENTHESES,
  4573. /* ) */
  4574. CHAR_RIGHT_SQUARE_BRACKET
  4575. /* ] */
  4576. } = constants$3;
  4577. const isPathSeparator = code => {
  4578. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  4579. };
  4580. const depth = token => {
  4581. if (token.isPrefix !== true) {
  4582. token.depth = token.isGlobstar ? Infinity : 1;
  4583. }
  4584. };
  4585. /**
  4586. * Quickly scans a glob pattern and returns an object with a handful of
  4587. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  4588. * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
  4589. * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
  4590. *
  4591. * ```js
  4592. * const pm = require('picomatch');
  4593. * console.log(pm.scan('foo/bar/*.js'));
  4594. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  4595. * ```
  4596. * @param {String} `str`
  4597. * @param {Object} `options`
  4598. * @return {Object} Returns an object with tokens and regex source string.
  4599. * @api public
  4600. */
  4601. const scan$1 = (input, options) => {
  4602. const opts = options || {};
  4603. const length = input.length - 1;
  4604. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  4605. const slashes = [];
  4606. const tokens = [];
  4607. const parts = [];
  4608. let str = input;
  4609. let index = -1;
  4610. let start = 0;
  4611. let lastIndex = 0;
  4612. let isBrace = false;
  4613. let isBracket = false;
  4614. let isGlob = false;
  4615. let isExtglob = false;
  4616. let isGlobstar = false;
  4617. let braceEscaped = false;
  4618. let backslashes = false;
  4619. let negated = false;
  4620. let negatedExtglob = false;
  4621. let finished = false;
  4622. let braces = 0;
  4623. let prev;
  4624. let code;
  4625. let token = {
  4626. value: '',
  4627. depth: 0,
  4628. isGlob: false
  4629. };
  4630. const eos = () => index >= length;
  4631. const peek = () => str.charCodeAt(index + 1);
  4632. const advance = () => {
  4633. prev = code;
  4634. return str.charCodeAt(++index);
  4635. };
  4636. while (index < length) {
  4637. code = advance();
  4638. let next;
  4639. if (code === CHAR_BACKWARD_SLASH) {
  4640. backslashes = token.backslashes = true;
  4641. code = advance();
  4642. if (code === CHAR_LEFT_CURLY_BRACE) {
  4643. braceEscaped = true;
  4644. }
  4645. continue;
  4646. }
  4647. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  4648. braces++;
  4649. while (eos() !== true && (code = advance())) {
  4650. if (code === CHAR_BACKWARD_SLASH) {
  4651. backslashes = token.backslashes = true;
  4652. advance();
  4653. continue;
  4654. }
  4655. if (code === CHAR_LEFT_CURLY_BRACE) {
  4656. braces++;
  4657. continue;
  4658. }
  4659. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  4660. isBrace = token.isBrace = true;
  4661. isGlob = token.isGlob = true;
  4662. finished = true;
  4663. if (scanToEnd === true) {
  4664. continue;
  4665. }
  4666. break;
  4667. }
  4668. if (braceEscaped !== true && code === CHAR_COMMA) {
  4669. isBrace = token.isBrace = true;
  4670. isGlob = token.isGlob = true;
  4671. finished = true;
  4672. if (scanToEnd === true) {
  4673. continue;
  4674. }
  4675. break;
  4676. }
  4677. if (code === CHAR_RIGHT_CURLY_BRACE) {
  4678. braces--;
  4679. if (braces === 0) {
  4680. braceEscaped = false;
  4681. isBrace = token.isBrace = true;
  4682. finished = true;
  4683. break;
  4684. }
  4685. }
  4686. }
  4687. if (scanToEnd === true) {
  4688. continue;
  4689. }
  4690. break;
  4691. }
  4692. if (code === CHAR_FORWARD_SLASH) {
  4693. slashes.push(index);
  4694. tokens.push(token);
  4695. token = {
  4696. value: '',
  4697. depth: 0,
  4698. isGlob: false
  4699. };
  4700. if (finished === true) continue;
  4701. if (prev === CHAR_DOT && index === start + 1) {
  4702. start += 2;
  4703. continue;
  4704. }
  4705. lastIndex = index + 1;
  4706. continue;
  4707. }
  4708. if (opts.noext !== true) {
  4709. const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
  4710. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  4711. isGlob = token.isGlob = true;
  4712. isExtglob = token.isExtglob = true;
  4713. finished = true;
  4714. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  4715. negatedExtglob = true;
  4716. }
  4717. if (scanToEnd === true) {
  4718. while (eos() !== true && (code = advance())) {
  4719. if (code === CHAR_BACKWARD_SLASH) {
  4720. backslashes = token.backslashes = true;
  4721. code = advance();
  4722. continue;
  4723. }
  4724. if (code === CHAR_RIGHT_PARENTHESES) {
  4725. isGlob = token.isGlob = true;
  4726. finished = true;
  4727. break;
  4728. }
  4729. }
  4730. continue;
  4731. }
  4732. break;
  4733. }
  4734. }
  4735. if (code === CHAR_ASTERISK) {
  4736. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  4737. isGlob = token.isGlob = true;
  4738. finished = true;
  4739. if (scanToEnd === true) {
  4740. continue;
  4741. }
  4742. break;
  4743. }
  4744. if (code === CHAR_QUESTION_MARK) {
  4745. isGlob = token.isGlob = true;
  4746. finished = true;
  4747. if (scanToEnd === true) {
  4748. continue;
  4749. }
  4750. break;
  4751. }
  4752. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  4753. while (eos() !== true && (next = advance())) {
  4754. if (next === CHAR_BACKWARD_SLASH) {
  4755. backslashes = token.backslashes = true;
  4756. advance();
  4757. continue;
  4758. }
  4759. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  4760. isBracket = token.isBracket = true;
  4761. isGlob = token.isGlob = true;
  4762. finished = true;
  4763. break;
  4764. }
  4765. }
  4766. if (scanToEnd === true) {
  4767. continue;
  4768. }
  4769. break;
  4770. }
  4771. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  4772. negated = token.negated = true;
  4773. start++;
  4774. continue;
  4775. }
  4776. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  4777. isGlob = token.isGlob = true;
  4778. if (scanToEnd === true) {
  4779. while (eos() !== true && (code = advance())) {
  4780. if (code === CHAR_LEFT_PARENTHESES) {
  4781. backslashes = token.backslashes = true;
  4782. code = advance();
  4783. continue;
  4784. }
  4785. if (code === CHAR_RIGHT_PARENTHESES) {
  4786. finished = true;
  4787. break;
  4788. }
  4789. }
  4790. continue;
  4791. }
  4792. break;
  4793. }
  4794. if (isGlob === true) {
  4795. finished = true;
  4796. if (scanToEnd === true) {
  4797. continue;
  4798. }
  4799. break;
  4800. }
  4801. }
  4802. if (opts.noext === true) {
  4803. isExtglob = false;
  4804. isGlob = false;
  4805. }
  4806. let base = str;
  4807. let prefix = '';
  4808. let glob = '';
  4809. if (start > 0) {
  4810. prefix = str.slice(0, start);
  4811. str = str.slice(start);
  4812. lastIndex -= start;
  4813. }
  4814. if (base && isGlob === true && lastIndex > 0) {
  4815. base = str.slice(0, lastIndex);
  4816. glob = str.slice(lastIndex);
  4817. } else if (isGlob === true) {
  4818. base = '';
  4819. glob = str;
  4820. } else {
  4821. base = str;
  4822. }
  4823. if (base && base !== '' && base !== '/' && base !== str) {
  4824. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  4825. base = base.slice(0, -1);
  4826. }
  4827. }
  4828. if (opts.unescape === true) {
  4829. if (glob) glob = utils$e.removeBackslashes(glob);
  4830. if (base && backslashes === true) {
  4831. base = utils$e.removeBackslashes(base);
  4832. }
  4833. }
  4834. const state = {
  4835. prefix,
  4836. input,
  4837. start,
  4838. base,
  4839. glob,
  4840. isBrace,
  4841. isBracket,
  4842. isGlob,
  4843. isExtglob,
  4844. isGlobstar,
  4845. negated,
  4846. negatedExtglob
  4847. };
  4848. if (opts.tokens === true) {
  4849. state.maxDepth = 0;
  4850. if (!isPathSeparator(code)) {
  4851. tokens.push(token);
  4852. }
  4853. state.tokens = tokens;
  4854. }
  4855. if (opts.parts === true || opts.tokens === true) {
  4856. let prevIndex;
  4857. for (let idx = 0; idx < slashes.length; idx++) {
  4858. const n = prevIndex ? prevIndex + 1 : start;
  4859. const i = slashes[idx];
  4860. const value = input.slice(n, i);
  4861. if (opts.tokens) {
  4862. if (idx === 0 && start !== 0) {
  4863. tokens[idx].isPrefix = true;
  4864. tokens[idx].value = prefix;
  4865. } else {
  4866. tokens[idx].value = value;
  4867. }
  4868. depth(tokens[idx]);
  4869. state.maxDepth += tokens[idx].depth;
  4870. }
  4871. if (idx !== 0 || value !== '') {
  4872. parts.push(value);
  4873. }
  4874. prevIndex = i;
  4875. }
  4876. if (prevIndex && prevIndex + 1 < input.length) {
  4877. const value = input.slice(prevIndex + 1);
  4878. parts.push(value);
  4879. if (opts.tokens) {
  4880. tokens[tokens.length - 1].value = value;
  4881. depth(tokens[tokens.length - 1]);
  4882. state.maxDepth += tokens[tokens.length - 1].depth;
  4883. }
  4884. }
  4885. state.slashes = slashes;
  4886. state.parts = parts;
  4887. }
  4888. return state;
  4889. };
  4890. var scan_1 = scan$1;
  4891. const constants$2 = constants$3;
  4892. const utils$d = utils$f;
  4893. /**
  4894. * Constants
  4895. */
  4896. const {
  4897. MAX_LENGTH,
  4898. POSIX_REGEX_SOURCE,
  4899. REGEX_NON_SPECIAL_CHARS,
  4900. REGEX_SPECIAL_CHARS_BACKREF,
  4901. REPLACEMENTS
  4902. } = constants$2;
  4903. /**
  4904. * Helpers
  4905. */
  4906. const expandRange = (args, options) => {
  4907. if (typeof options.expandRange === 'function') {
  4908. return options.expandRange(...args, options);
  4909. }
  4910. args.sort();
  4911. const value = `[${args.join('-')}]`;
  4912. try {
  4913. /* eslint-disable-next-line no-new */
  4914. new RegExp(value);
  4915. } catch (ex) {
  4916. return args.map(v => utils$d.escapeRegex(v)).join('..');
  4917. }
  4918. return value;
  4919. };
  4920. /**
  4921. * Create the message for a syntax error
  4922. */
  4923. const syntaxError = (type, char) => {
  4924. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  4925. };
  4926. /**
  4927. * Parse the given input string.
  4928. * @param {String} input
  4929. * @param {Object} options
  4930. * @return {Object}
  4931. */
  4932. const parse$2 = (input, options) => {
  4933. if (typeof input !== 'string') {
  4934. throw new TypeError('Expected a string');
  4935. }
  4936. input = REPLACEMENTS[input] || input;
  4937. const opts = Object.assign({}, options);
  4938. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  4939. let len = input.length;
  4940. if (len > max) {
  4941. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  4942. }
  4943. const bos = {
  4944. type: 'bos',
  4945. value: '',
  4946. output: opts.prepend || ''
  4947. };
  4948. const tokens = [bos];
  4949. const capture = opts.capture ? '' : '?:';
  4950. const win32 = utils$d.isWindows(options); // create constants based on platform, for windows or posix
  4951. const PLATFORM_CHARS = constants$2.globChars(win32);
  4952. const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
  4953. const {
  4954. DOT_LITERAL,
  4955. PLUS_LITERAL,
  4956. SLASH_LITERAL,
  4957. ONE_CHAR,
  4958. DOTS_SLASH,
  4959. NO_DOT,
  4960. NO_DOT_SLASH,
  4961. NO_DOTS_SLASH,
  4962. QMARK,
  4963. QMARK_NO_DOT,
  4964. STAR,
  4965. START_ANCHOR
  4966. } = PLATFORM_CHARS;
  4967. const globstar = opts => {
  4968. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  4969. };
  4970. const nodot = opts.dot ? '' : NO_DOT;
  4971. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  4972. let star = opts.bash === true ? globstar(opts) : STAR;
  4973. if (opts.capture) {
  4974. star = `(${star})`;
  4975. } // minimatch options support
  4976. if (typeof opts.noext === 'boolean') {
  4977. opts.noextglob = opts.noext;
  4978. }
  4979. const state = {
  4980. input,
  4981. index: -1,
  4982. start: 0,
  4983. dot: opts.dot === true,
  4984. consumed: '',
  4985. output: '',
  4986. prefix: '',
  4987. backtrack: false,
  4988. negated: false,
  4989. brackets: 0,
  4990. braces: 0,
  4991. parens: 0,
  4992. quotes: 0,
  4993. globstar: false,
  4994. tokens
  4995. };
  4996. input = utils$d.removePrefix(input, state);
  4997. len = input.length;
  4998. const extglobs = [];
  4999. const braces = [];
  5000. const stack = [];
  5001. let prev = bos;
  5002. let value;
  5003. /**
  5004. * Tokenizing helpers
  5005. */
  5006. const eos = () => state.index === len - 1;
  5007. const peek = state.peek = (n = 1) => input[state.index + n];
  5008. const advance = state.advance = () => input[++state.index] || '';
  5009. const remaining = () => input.slice(state.index + 1);
  5010. const consume = (value = '', num = 0) => {
  5011. state.consumed += value;
  5012. state.index += num;
  5013. };
  5014. const append = token => {
  5015. state.output += token.output != null ? token.output : token.value;
  5016. consume(token.value);
  5017. };
  5018. const negate = () => {
  5019. let count = 1;
  5020. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  5021. advance();
  5022. state.start++;
  5023. count++;
  5024. }
  5025. if (count % 2 === 0) {
  5026. return false;
  5027. }
  5028. state.negated = true;
  5029. state.start++;
  5030. return true;
  5031. };
  5032. const increment = type => {
  5033. state[type]++;
  5034. stack.push(type);
  5035. };
  5036. const decrement = type => {
  5037. state[type]--;
  5038. stack.pop();
  5039. };
  5040. /**
  5041. * Push tokens onto the tokens array. This helper speeds up
  5042. * tokenizing by 1) helping us avoid backtracking as much as possible,
  5043. * and 2) helping us avoid creating extra tokens when consecutive
  5044. * characters are plain text. This improves performance and simplifies
  5045. * lookbehinds.
  5046. */
  5047. const push = tok => {
  5048. if (prev.type === 'globstar') {
  5049. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  5050. const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren');
  5051. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  5052. state.output = state.output.slice(0, -prev.output.length);
  5053. prev.type = 'star';
  5054. prev.value = '*';
  5055. prev.output = star;
  5056. state.output += prev.output;
  5057. }
  5058. }
  5059. if (extglobs.length && tok.type !== 'paren') {
  5060. extglobs[extglobs.length - 1].inner += tok.value;
  5061. }
  5062. if (tok.value || tok.output) append(tok);
  5063. if (prev && prev.type === 'text' && tok.type === 'text') {
  5064. prev.value += tok.value;
  5065. prev.output = (prev.output || '') + tok.value;
  5066. return;
  5067. }
  5068. tok.prev = prev;
  5069. tokens.push(tok);
  5070. prev = tok;
  5071. };
  5072. const extglobOpen = (type, value) => {
  5073. const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, {
  5074. conditions: 1,
  5075. inner: ''
  5076. });
  5077. token.prev = prev;
  5078. token.parens = state.parens;
  5079. token.output = state.output;
  5080. const output = (opts.capture ? '(' : '') + token.open;
  5081. increment('parens');
  5082. push({
  5083. type,
  5084. value,
  5085. output: state.output ? '' : ONE_CHAR
  5086. });
  5087. push({
  5088. type: 'paren',
  5089. extglob: true,
  5090. value: advance(),
  5091. output
  5092. });
  5093. extglobs.push(token);
  5094. };
  5095. const extglobClose = token => {
  5096. let output = token.close + (opts.capture ? ')' : '');
  5097. let rest;
  5098. if (token.type === 'negate') {
  5099. let extglobStar = star;
  5100. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  5101. extglobStar = globstar(opts);
  5102. }
  5103. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  5104. output = token.close = `)$))${extglobStar}`;
  5105. }
  5106. if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  5107. output = token.close = `)${rest})${extglobStar})`;
  5108. }
  5109. if (token.prev.type === 'bos') {
  5110. state.negatedExtglob = true;
  5111. }
  5112. }
  5113. push({
  5114. type: 'paren',
  5115. extglob: true,
  5116. value,
  5117. output
  5118. });
  5119. decrement('parens');
  5120. };
  5121. /**
  5122. * Fast paths
  5123. */
  5124. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  5125. let backslashes = false;
  5126. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  5127. if (first === '\\') {
  5128. backslashes = true;
  5129. return m;
  5130. }
  5131. if (first === '?') {
  5132. if (esc) {
  5133. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  5134. }
  5135. if (index === 0) {
  5136. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  5137. }
  5138. return QMARK.repeat(chars.length);
  5139. }
  5140. if (first === '.') {
  5141. return DOT_LITERAL.repeat(chars.length);
  5142. }
  5143. if (first === '*') {
  5144. if (esc) {
  5145. return esc + first + (rest ? star : '');
  5146. }
  5147. return star;
  5148. }
  5149. return esc ? m : `\\${m}`;
  5150. });
  5151. if (backslashes === true) {
  5152. if (opts.unescape === true) {
  5153. output = output.replace(/\\/g, '');
  5154. } else {
  5155. output = output.replace(/\\+/g, m => {
  5156. return m.length % 2 === 0 ? '\\\\' : m ? '\\' : '';
  5157. });
  5158. }
  5159. }
  5160. if (output === input && opts.contains === true) {
  5161. state.output = input;
  5162. return state;
  5163. }
  5164. state.output = utils$d.wrapOutput(output, state, options);
  5165. return state;
  5166. }
  5167. /**
  5168. * Tokenize input until we reach end-of-string
  5169. */
  5170. while (!eos()) {
  5171. value = advance();
  5172. if (value === '\u0000') {
  5173. continue;
  5174. }
  5175. /**
  5176. * Escaped characters
  5177. */
  5178. if (value === '\\') {
  5179. const next = peek();
  5180. if (next === '/' && opts.bash !== true) {
  5181. continue;
  5182. }
  5183. if (next === '.' || next === ';') {
  5184. continue;
  5185. }
  5186. if (!next) {
  5187. value += '\\';
  5188. push({
  5189. type: 'text',
  5190. value
  5191. });
  5192. continue;
  5193. } // collapse slashes to reduce potential for exploits
  5194. const match = /^\\+/.exec(remaining());
  5195. let slashes = 0;
  5196. if (match && match[0].length > 2) {
  5197. slashes = match[0].length;
  5198. state.index += slashes;
  5199. if (slashes % 2 !== 0) {
  5200. value += '\\';
  5201. }
  5202. }
  5203. if (opts.unescape === true) {
  5204. value = advance();
  5205. } else {
  5206. value += advance();
  5207. }
  5208. if (state.brackets === 0) {
  5209. push({
  5210. type: 'text',
  5211. value
  5212. });
  5213. continue;
  5214. }
  5215. }
  5216. /**
  5217. * If we're inside a regex character class, continue
  5218. * until we reach the closing bracket.
  5219. */
  5220. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  5221. if (opts.posix !== false && value === ':') {
  5222. const inner = prev.value.slice(1);
  5223. if (inner.includes('[')) {
  5224. prev.posix = true;
  5225. if (inner.includes(':')) {
  5226. const idx = prev.value.lastIndexOf('[');
  5227. const pre = prev.value.slice(0, idx);
  5228. const rest = prev.value.slice(idx + 2);
  5229. const posix = POSIX_REGEX_SOURCE[rest];
  5230. if (posix) {
  5231. prev.value = pre + posix;
  5232. state.backtrack = true;
  5233. advance();
  5234. if (!bos.output && tokens.indexOf(prev) === 1) {
  5235. bos.output = ONE_CHAR;
  5236. }
  5237. continue;
  5238. }
  5239. }
  5240. }
  5241. }
  5242. if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') {
  5243. value = `\\${value}`;
  5244. }
  5245. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  5246. value = `\\${value}`;
  5247. }
  5248. if (opts.posix === true && value === '!' && prev.value === '[') {
  5249. value = '^';
  5250. }
  5251. prev.value += value;
  5252. append({
  5253. value
  5254. });
  5255. continue;
  5256. }
  5257. /**
  5258. * If we're inside a quoted string, continue
  5259. * until we reach the closing double quote.
  5260. */
  5261. if (state.quotes === 1 && value !== '"') {
  5262. value = utils$d.escapeRegex(value);
  5263. prev.value += value;
  5264. append({
  5265. value
  5266. });
  5267. continue;
  5268. }
  5269. /**
  5270. * Double quotes
  5271. */
  5272. if (value === '"') {
  5273. state.quotes = state.quotes === 1 ? 0 : 1;
  5274. if (opts.keepQuotes === true) {
  5275. push({
  5276. type: 'text',
  5277. value
  5278. });
  5279. }
  5280. continue;
  5281. }
  5282. /**
  5283. * Parentheses
  5284. */
  5285. if (value === '(') {
  5286. increment('parens');
  5287. push({
  5288. type: 'paren',
  5289. value
  5290. });
  5291. continue;
  5292. }
  5293. if (value === ')') {
  5294. if (state.parens === 0 && opts.strictBrackets === true) {
  5295. throw new SyntaxError(syntaxError('opening', '('));
  5296. }
  5297. const extglob = extglobs[extglobs.length - 1];
  5298. if (extglob && state.parens === extglob.parens + 1) {
  5299. extglobClose(extglobs.pop());
  5300. continue;
  5301. }
  5302. push({
  5303. type: 'paren',
  5304. value,
  5305. output: state.parens ? ')' : '\\)'
  5306. });
  5307. decrement('parens');
  5308. continue;
  5309. }
  5310. /**
  5311. * Square brackets
  5312. */
  5313. if (value === '[') {
  5314. if (opts.nobracket === true || !remaining().includes(']')) {
  5315. if (opts.nobracket !== true && opts.strictBrackets === true) {
  5316. throw new SyntaxError(syntaxError('closing', ']'));
  5317. }
  5318. value = `\\${value}`;
  5319. } else {
  5320. increment('brackets');
  5321. }
  5322. push({
  5323. type: 'bracket',
  5324. value
  5325. });
  5326. continue;
  5327. }
  5328. if (value === ']') {
  5329. if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) {
  5330. push({
  5331. type: 'text',
  5332. value,
  5333. output: `\\${value}`
  5334. });
  5335. continue;
  5336. }
  5337. if (state.brackets === 0) {
  5338. if (opts.strictBrackets === true) {
  5339. throw new SyntaxError(syntaxError('opening', '['));
  5340. }
  5341. push({
  5342. type: 'text',
  5343. value,
  5344. output: `\\${value}`
  5345. });
  5346. continue;
  5347. }
  5348. decrement('brackets');
  5349. const prevValue = prev.value.slice(1);
  5350. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  5351. value = `/${value}`;
  5352. }
  5353. prev.value += value;
  5354. append({
  5355. value
  5356. }); // when literal brackets are explicitly disabled
  5357. // assume we should match with a regex character class
  5358. if (opts.literalBrackets === false || utils$d.hasRegexChars(prevValue)) {
  5359. continue;
  5360. }
  5361. const escaped = utils$d.escapeRegex(prev.value);
  5362. state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled
  5363. // assume we should escape the brackets to match literal characters
  5364. if (opts.literalBrackets === true) {
  5365. state.output += escaped;
  5366. prev.value = escaped;
  5367. continue;
  5368. } // when the user specifies nothing, try to match both
  5369. prev.value = `(${capture}${escaped}|${prev.value})`;
  5370. state.output += prev.value;
  5371. continue;
  5372. }
  5373. /**
  5374. * Braces
  5375. */
  5376. if (value === '{' && opts.nobrace !== true) {
  5377. increment('braces');
  5378. const open = {
  5379. type: 'brace',
  5380. value,
  5381. output: '(',
  5382. outputIndex: state.output.length,
  5383. tokensIndex: state.tokens.length
  5384. };
  5385. braces.push(open);
  5386. push(open);
  5387. continue;
  5388. }
  5389. if (value === '}') {
  5390. const brace = braces[braces.length - 1];
  5391. if (opts.nobrace === true || !brace) {
  5392. push({
  5393. type: 'text',
  5394. value,
  5395. output: value
  5396. });
  5397. continue;
  5398. }
  5399. let output = ')';
  5400. if (brace.dots === true) {
  5401. const arr = tokens.slice();
  5402. const range = [];
  5403. for (let i = arr.length - 1; i >= 0; i--) {
  5404. tokens.pop();
  5405. if (arr[i].type === 'brace') {
  5406. break;
  5407. }
  5408. if (arr[i].type !== 'dots') {
  5409. range.unshift(arr[i].value);
  5410. }
  5411. }
  5412. output = expandRange(range, opts);
  5413. state.backtrack = true;
  5414. }
  5415. if (brace.comma !== true && brace.dots !== true) {
  5416. const out = state.output.slice(0, brace.outputIndex);
  5417. const toks = state.tokens.slice(brace.tokensIndex);
  5418. brace.value = brace.output = '\\{';
  5419. value = output = '\\}';
  5420. state.output = out;
  5421. for (const t of toks) {
  5422. state.output += t.output || t.value;
  5423. }
  5424. }
  5425. push({
  5426. type: 'brace',
  5427. value,
  5428. output
  5429. });
  5430. decrement('braces');
  5431. braces.pop();
  5432. continue;
  5433. }
  5434. /**
  5435. * Pipes
  5436. */
  5437. if (value === '|') {
  5438. if (extglobs.length > 0) {
  5439. extglobs[extglobs.length - 1].conditions++;
  5440. }
  5441. push({
  5442. type: 'text',
  5443. value
  5444. });
  5445. continue;
  5446. }
  5447. /**
  5448. * Commas
  5449. */
  5450. if (value === ',') {
  5451. let output = value;
  5452. const brace = braces[braces.length - 1];
  5453. if (brace && stack[stack.length - 1] === 'braces') {
  5454. brace.comma = true;
  5455. output = '|';
  5456. }
  5457. push({
  5458. type: 'comma',
  5459. value,
  5460. output
  5461. });
  5462. continue;
  5463. }
  5464. /**
  5465. * Slashes
  5466. */
  5467. if (value === '/') {
  5468. // if the beginning of the glob is "./", advance the start
  5469. // to the current index, and don't add the "./" characters
  5470. // to the state. This greatly simplifies lookbehinds when
  5471. // checking for BOS characters like "!" and "." (not "./")
  5472. if (prev.type === 'dot' && state.index === state.start + 1) {
  5473. state.start = state.index + 1;
  5474. state.consumed = '';
  5475. state.output = '';
  5476. tokens.pop();
  5477. prev = bos; // reset "prev" to the first token
  5478. continue;
  5479. }
  5480. push({
  5481. type: 'slash',
  5482. value,
  5483. output: SLASH_LITERAL
  5484. });
  5485. continue;
  5486. }
  5487. /**
  5488. * Dots
  5489. */
  5490. if (value === '.') {
  5491. if (state.braces > 0 && prev.type === 'dot') {
  5492. if (prev.value === '.') prev.output = DOT_LITERAL;
  5493. const brace = braces[braces.length - 1];
  5494. prev.type = 'dots';
  5495. prev.output += value;
  5496. prev.value += value;
  5497. brace.dots = true;
  5498. continue;
  5499. }
  5500. if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  5501. push({
  5502. type: 'text',
  5503. value,
  5504. output: DOT_LITERAL
  5505. });
  5506. continue;
  5507. }
  5508. push({
  5509. type: 'dot',
  5510. value,
  5511. output: DOT_LITERAL
  5512. });
  5513. continue;
  5514. }
  5515. /**
  5516. * Question marks
  5517. */
  5518. if (value === '?') {
  5519. const isGroup = prev && prev.value === '(';
  5520. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  5521. extglobOpen('qmark', value);
  5522. continue;
  5523. }
  5524. if (prev && prev.type === 'paren') {
  5525. const next = peek();
  5526. let output = value;
  5527. if (next === '<' && !utils$d.supportsLookbehinds()) {
  5528. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  5529. }
  5530. if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) {
  5531. output = `\\${value}`;
  5532. }
  5533. push({
  5534. type: 'text',
  5535. value,
  5536. output
  5537. });
  5538. continue;
  5539. }
  5540. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  5541. push({
  5542. type: 'qmark',
  5543. value,
  5544. output: QMARK_NO_DOT
  5545. });
  5546. continue;
  5547. }
  5548. push({
  5549. type: 'qmark',
  5550. value,
  5551. output: QMARK
  5552. });
  5553. continue;
  5554. }
  5555. /**
  5556. * Exclamation
  5557. */
  5558. if (value === '!') {
  5559. if (opts.noextglob !== true && peek() === '(') {
  5560. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  5561. extglobOpen('negate', value);
  5562. continue;
  5563. }
  5564. }
  5565. if (opts.nonegate !== true && state.index === 0) {
  5566. negate();
  5567. continue;
  5568. }
  5569. }
  5570. /**
  5571. * Plus
  5572. */
  5573. if (value === '+') {
  5574. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  5575. extglobOpen('plus', value);
  5576. continue;
  5577. }
  5578. if (prev && prev.value === '(' || opts.regex === false) {
  5579. push({
  5580. type: 'plus',
  5581. value,
  5582. output: PLUS_LITERAL
  5583. });
  5584. continue;
  5585. }
  5586. if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) {
  5587. push({
  5588. type: 'plus',
  5589. value
  5590. });
  5591. continue;
  5592. }
  5593. push({
  5594. type: 'plus',
  5595. value: PLUS_LITERAL
  5596. });
  5597. continue;
  5598. }
  5599. /**
  5600. * Plain text
  5601. */
  5602. if (value === '@') {
  5603. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  5604. push({
  5605. type: 'at',
  5606. extglob: true,
  5607. value,
  5608. output: ''
  5609. });
  5610. continue;
  5611. }
  5612. push({
  5613. type: 'text',
  5614. value
  5615. });
  5616. continue;
  5617. }
  5618. /**
  5619. * Plain text
  5620. */
  5621. if (value !== '*') {
  5622. if (value === '$' || value === '^') {
  5623. value = `\\${value}`;
  5624. }
  5625. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  5626. if (match) {
  5627. value += match[0];
  5628. state.index += match[0].length;
  5629. }
  5630. push({
  5631. type: 'text',
  5632. value
  5633. });
  5634. continue;
  5635. }
  5636. /**
  5637. * Stars
  5638. */
  5639. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  5640. prev.type = 'star';
  5641. prev.star = true;
  5642. prev.value += value;
  5643. prev.output = star;
  5644. state.backtrack = true;
  5645. state.globstar = true;
  5646. consume(value);
  5647. continue;
  5648. }
  5649. let rest = remaining();
  5650. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  5651. extglobOpen('star', value);
  5652. continue;
  5653. }
  5654. if (prev.type === 'star') {
  5655. if (opts.noglobstar === true) {
  5656. consume(value);
  5657. continue;
  5658. }
  5659. const prior = prev.prev;
  5660. const before = prior.prev;
  5661. const isStart = prior.type === 'slash' || prior.type === 'bos';
  5662. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  5663. if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) {
  5664. push({
  5665. type: 'star',
  5666. value,
  5667. output: ''
  5668. });
  5669. continue;
  5670. }
  5671. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  5672. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  5673. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  5674. push({
  5675. type: 'star',
  5676. value,
  5677. output: ''
  5678. });
  5679. continue;
  5680. } // strip consecutive `/**/`
  5681. while (rest.slice(0, 3) === '/**') {
  5682. const after = input[state.index + 4];
  5683. if (after && after !== '/') {
  5684. break;
  5685. }
  5686. rest = rest.slice(3);
  5687. consume('/**', 3);
  5688. }
  5689. if (prior.type === 'bos' && eos()) {
  5690. prev.type = 'globstar';
  5691. prev.value += value;
  5692. prev.output = globstar(opts);
  5693. state.output = prev.output;
  5694. state.globstar = true;
  5695. consume(value);
  5696. continue;
  5697. }
  5698. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  5699. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  5700. prior.output = `(?:${prior.output}`;
  5701. prev.type = 'globstar';
  5702. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  5703. prev.value += value;
  5704. state.globstar = true;
  5705. state.output += prior.output + prev.output;
  5706. consume(value);
  5707. continue;
  5708. }
  5709. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  5710. const end = rest[1] !== void 0 ? '|$' : '';
  5711. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  5712. prior.output = `(?:${prior.output}`;
  5713. prev.type = 'globstar';
  5714. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  5715. prev.value += value;
  5716. state.output += prior.output + prev.output;
  5717. state.globstar = true;
  5718. consume(value + advance());
  5719. push({
  5720. type: 'slash',
  5721. value: '/',
  5722. output: ''
  5723. });
  5724. continue;
  5725. }
  5726. if (prior.type === 'bos' && rest[0] === '/') {
  5727. prev.type = 'globstar';
  5728. prev.value += value;
  5729. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  5730. state.output = prev.output;
  5731. state.globstar = true;
  5732. consume(value + advance());
  5733. push({
  5734. type: 'slash',
  5735. value: '/',
  5736. output: ''
  5737. });
  5738. continue;
  5739. } // remove single star from output
  5740. state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar
  5741. prev.type = 'globstar';
  5742. prev.output = globstar(opts);
  5743. prev.value += value; // reset output with globstar
  5744. state.output += prev.output;
  5745. state.globstar = true;
  5746. consume(value);
  5747. continue;
  5748. }
  5749. const token = {
  5750. type: 'star',
  5751. value,
  5752. output: star
  5753. };
  5754. if (opts.bash === true) {
  5755. token.output = '.*?';
  5756. if (prev.type === 'bos' || prev.type === 'slash') {
  5757. token.output = nodot + token.output;
  5758. }
  5759. push(token);
  5760. continue;
  5761. }
  5762. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  5763. token.output = value;
  5764. push(token);
  5765. continue;
  5766. }
  5767. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  5768. if (prev.type === 'dot') {
  5769. state.output += NO_DOT_SLASH;
  5770. prev.output += NO_DOT_SLASH;
  5771. } else if (opts.dot === true) {
  5772. state.output += NO_DOTS_SLASH;
  5773. prev.output += NO_DOTS_SLASH;
  5774. } else {
  5775. state.output += nodot;
  5776. prev.output += nodot;
  5777. }
  5778. if (peek() !== '*') {
  5779. state.output += ONE_CHAR;
  5780. prev.output += ONE_CHAR;
  5781. }
  5782. }
  5783. push(token);
  5784. }
  5785. while (state.brackets > 0) {
  5786. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
  5787. state.output = utils$d.escapeLast(state.output, '[');
  5788. decrement('brackets');
  5789. }
  5790. while (state.parens > 0) {
  5791. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
  5792. state.output = utils$d.escapeLast(state.output, '(');
  5793. decrement('parens');
  5794. }
  5795. while (state.braces > 0) {
  5796. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
  5797. state.output = utils$d.escapeLast(state.output, '{');
  5798. decrement('braces');
  5799. }
  5800. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  5801. push({
  5802. type: 'maybe_slash',
  5803. value: '',
  5804. output: `${SLASH_LITERAL}?`
  5805. });
  5806. } // rebuild the output if we had to backtrack at any point
  5807. if (state.backtrack === true) {
  5808. state.output = '';
  5809. for (const token of state.tokens) {
  5810. state.output += token.output != null ? token.output : token.value;
  5811. if (token.suffix) {
  5812. state.output += token.suffix;
  5813. }
  5814. }
  5815. }
  5816. return state;
  5817. };
  5818. /**
  5819. * Fast paths for creating regular expressions for common glob patterns.
  5820. * This can significantly speed up processing and has very little downside
  5821. * impact when none of the fast paths match.
  5822. */
  5823. parse$2.fastpaths = (input, options) => {
  5824. const opts = Object.assign({}, options);
  5825. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  5826. const len = input.length;
  5827. if (len > max) {
  5828. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  5829. }
  5830. input = REPLACEMENTS[input] || input;
  5831. const win32 = utils$d.isWindows(options); // create constants based on platform, for windows or posix
  5832. const {
  5833. DOT_LITERAL,
  5834. SLASH_LITERAL,
  5835. ONE_CHAR,
  5836. DOTS_SLASH,
  5837. NO_DOT,
  5838. NO_DOTS,
  5839. NO_DOTS_SLASH,
  5840. STAR,
  5841. START_ANCHOR
  5842. } = constants$2.globChars(win32);
  5843. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  5844. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  5845. const capture = opts.capture ? '' : '?:';
  5846. const state = {
  5847. negated: false,
  5848. prefix: ''
  5849. };
  5850. let star = opts.bash === true ? '.*?' : STAR;
  5851. if (opts.capture) {
  5852. star = `(${star})`;
  5853. }
  5854. const globstar = opts => {
  5855. if (opts.noglobstar === true) return star;
  5856. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  5857. };
  5858. const create = str => {
  5859. switch (str) {
  5860. case '*':
  5861. return `${nodot}${ONE_CHAR}${star}`;
  5862. case '.*':
  5863. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  5864. case '*.*':
  5865. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  5866. case '*/*':
  5867. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  5868. case '**':
  5869. return nodot + globstar(opts);
  5870. case '**/*':
  5871. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  5872. case '**/*.*':
  5873. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  5874. case '**/.*':
  5875. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  5876. default:
  5877. {
  5878. const match = /^(.*?)\.(\w+)$/.exec(str);
  5879. if (!match) return;
  5880. const source = create(match[1]);
  5881. if (!source) return;
  5882. return source + DOT_LITERAL + match[2];
  5883. }
  5884. }
  5885. };
  5886. const output = utils$d.removePrefix(input, state);
  5887. let source = create(output);
  5888. if (source && opts.strictSlashes !== true) {
  5889. source += `${SLASH_LITERAL}?`;
  5890. }
  5891. return source;
  5892. };
  5893. var parse_1 = parse$2;
  5894. const path$9 = require$$0__default$1["default"];
  5895. const scan = scan_1;
  5896. const parse$1 = parse_1;
  5897. const utils$c = utils$f;
  5898. const constants$1 = constants$3;
  5899. const isObject$5 = val => val && typeof val === 'object' && !Array.isArray(val);
  5900. /**
  5901. * Creates a matcher function from one or more glob patterns. The
  5902. * returned function takes a string to match as its first argument,
  5903. * and returns true if the string is a match. The returned matcher
  5904. * function also takes a boolean as the second argument that, when true,
  5905. * returns an object with additional information.
  5906. *
  5907. * ```js
  5908. * const picomatch = require('picomatch');
  5909. * // picomatch(glob[, options]);
  5910. *
  5911. * const isMatch = picomatch('*.!(*a)');
  5912. * console.log(isMatch('a.a')); //=> false
  5913. * console.log(isMatch('a.b')); //=> true
  5914. * ```
  5915. * @name picomatch
  5916. * @param {String|Array} `globs` One or more glob patterns.
  5917. * @param {Object=} `options`
  5918. * @return {Function=} Returns a matcher function.
  5919. * @api public
  5920. */
  5921. const picomatch$2 = (glob, options, returnState = false) => {
  5922. if (Array.isArray(glob)) {
  5923. const fns = glob.map(input => picomatch$2(input, options, returnState));
  5924. const arrayMatcher = str => {
  5925. for (const isMatch of fns) {
  5926. const state = isMatch(str);
  5927. if (state) return state;
  5928. }
  5929. return false;
  5930. };
  5931. return arrayMatcher;
  5932. }
  5933. const isState = isObject$5(glob) && glob.tokens && glob.input;
  5934. if (glob === '' || typeof glob !== 'string' && !isState) {
  5935. throw new TypeError('Expected pattern to be a non-empty string');
  5936. }
  5937. const opts = options || {};
  5938. const posix = utils$c.isWindows(options);
  5939. const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
  5940. const state = regex.state;
  5941. delete regex.state;
  5942. let isIgnored = () => false;
  5943. if (opts.ignore) {
  5944. const ignoreOpts = Object.assign(Object.assign({}, options), {}, {
  5945. ignore: null,
  5946. onMatch: null,
  5947. onResult: null
  5948. });
  5949. isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
  5950. }
  5951. const matcher = (input, returnObject = false) => {
  5952. const {
  5953. isMatch,
  5954. match,
  5955. output
  5956. } = picomatch$2.test(input, regex, options, {
  5957. glob,
  5958. posix
  5959. });
  5960. const result = {
  5961. glob,
  5962. state,
  5963. regex,
  5964. posix,
  5965. input,
  5966. output,
  5967. match,
  5968. isMatch
  5969. };
  5970. if (typeof opts.onResult === 'function') {
  5971. opts.onResult(result);
  5972. }
  5973. if (isMatch === false) {
  5974. result.isMatch = false;
  5975. return returnObject ? result : false;
  5976. }
  5977. if (isIgnored(input)) {
  5978. if (typeof opts.onIgnore === 'function') {
  5979. opts.onIgnore(result);
  5980. }
  5981. result.isMatch = false;
  5982. return returnObject ? result : false;
  5983. }
  5984. if (typeof opts.onMatch === 'function') {
  5985. opts.onMatch(result);
  5986. }
  5987. return returnObject ? result : true;
  5988. };
  5989. if (returnState) {
  5990. matcher.state = state;
  5991. }
  5992. return matcher;
  5993. };
  5994. /**
  5995. * Test `input` with the given `regex`. This is used by the main
  5996. * `picomatch()` function to test the input string.
  5997. *
  5998. * ```js
  5999. * const picomatch = require('picomatch');
  6000. * // picomatch.test(input, regex[, options]);
  6001. *
  6002. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  6003. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  6004. * ```
  6005. * @param {String} `input` String to test.
  6006. * @param {RegExp} `regex`
  6007. * @return {Object} Returns an object with matching info.
  6008. * @api public
  6009. */
  6010. picomatch$2.test = (input, regex, options, {
  6011. glob,
  6012. posix
  6013. } = {}) => {
  6014. if (typeof input !== 'string') {
  6015. throw new TypeError('Expected input to be a string');
  6016. }
  6017. if (input === '') {
  6018. return {
  6019. isMatch: false,
  6020. output: ''
  6021. };
  6022. }
  6023. const opts = options || {};
  6024. const format = opts.format || (posix ? utils$c.toPosixSlashes : null);
  6025. let match = input === glob;
  6026. let output = match && format ? format(input) : input;
  6027. if (match === false) {
  6028. output = format ? format(input) : input;
  6029. match = output === glob;
  6030. }
  6031. if (match === false || opts.capture === true) {
  6032. if (opts.matchBase === true || opts.basename === true) {
  6033. match = picomatch$2.matchBase(input, regex, options, posix);
  6034. } else {
  6035. match = regex.exec(output);
  6036. }
  6037. }
  6038. return {
  6039. isMatch: Boolean(match),
  6040. match,
  6041. output
  6042. };
  6043. };
  6044. /**
  6045. * Match the basename of a filepath.
  6046. *
  6047. * ```js
  6048. * const picomatch = require('picomatch');
  6049. * // picomatch.matchBase(input, glob[, options]);
  6050. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  6051. * ```
  6052. * @param {String} `input` String to test.
  6053. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  6054. * @return {Boolean}
  6055. * @api public
  6056. */
  6057. picomatch$2.matchBase = (input, glob, options, posix = utils$c.isWindows(options)) => {
  6058. const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
  6059. return regex.test(path$9.basename(input));
  6060. };
  6061. /**
  6062. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  6063. *
  6064. * ```js
  6065. * const picomatch = require('picomatch');
  6066. * // picomatch.isMatch(string, patterns[, options]);
  6067. *
  6068. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  6069. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  6070. * ```
  6071. * @param {String|Array} str The string to test.
  6072. * @param {String|Array} patterns One or more glob patterns to use for matching.
  6073. * @param {Object} [options] See available [options](#options).
  6074. * @return {Boolean} Returns true if any patterns match `str`
  6075. * @api public
  6076. */
  6077. picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
  6078. /**
  6079. * Parse a glob pattern to create the source string for a regular
  6080. * expression.
  6081. *
  6082. * ```js
  6083. * const picomatch = require('picomatch');
  6084. * const result = picomatch.parse(pattern[, options]);
  6085. * ```
  6086. * @param {String} `pattern`
  6087. * @param {Object} `options`
  6088. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  6089. * @api public
  6090. */
  6091. picomatch$2.parse = (pattern, options) => {
  6092. if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
  6093. return parse$1(pattern, Object.assign(Object.assign({}, options), {}, {
  6094. fastpaths: false
  6095. }));
  6096. };
  6097. /**
  6098. * Scan a glob pattern to separate the pattern into segments.
  6099. *
  6100. * ```js
  6101. * const picomatch = require('picomatch');
  6102. * // picomatch.scan(input[, options]);
  6103. *
  6104. * const result = picomatch.scan('!./foo/*.js');
  6105. * console.log(result);
  6106. * { prefix: '!./',
  6107. * input: '!./foo/*.js',
  6108. * start: 3,
  6109. * base: 'foo',
  6110. * glob: '*.js',
  6111. * isBrace: false,
  6112. * isBracket: false,
  6113. * isGlob: true,
  6114. * isExtglob: false,
  6115. * isGlobstar: false,
  6116. * negated: true }
  6117. * ```
  6118. * @param {String} `input` Glob pattern to scan.
  6119. * @param {Object} `options`
  6120. * @return {Object} Returns an object with
  6121. * @api public
  6122. */
  6123. picomatch$2.scan = (input, options) => scan(input, options);
  6124. /**
  6125. * Compile a regular expression from the `state` object returned by the
  6126. * [parse()](#parse) method.
  6127. *
  6128. * @param {Object} `state`
  6129. * @param {Object} `options`
  6130. * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
  6131. * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  6132. * @return {RegExp}
  6133. * @api public
  6134. */
  6135. picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
  6136. if (returnOutput === true) {
  6137. return state.output;
  6138. }
  6139. const opts = options || {};
  6140. const prepend = opts.contains ? '' : '^';
  6141. const append = opts.contains ? '' : '$';
  6142. let source = `${prepend}(?:${state.output})${append}`;
  6143. if (state && state.negated === true) {
  6144. source = `^(?!${source}).*$`;
  6145. }
  6146. const regex = picomatch$2.toRegex(source, options);
  6147. if (returnState === true) {
  6148. regex.state = state;
  6149. }
  6150. return regex;
  6151. };
  6152. /**
  6153. * Create a regular expression from a parsed glob pattern.
  6154. *
  6155. * ```js
  6156. * const picomatch = require('picomatch');
  6157. * const state = picomatch.parse('*.js');
  6158. * // picomatch.compileRe(state[, options]);
  6159. *
  6160. * console.log(picomatch.compileRe(state));
  6161. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  6162. * ```
  6163. * @param {String} `state` The object returned from the `.parse` method.
  6164. * @param {Object} `options`
  6165. * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
  6166. * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  6167. * @return {RegExp} Returns a regex created from the given pattern.
  6168. * @api public
  6169. */
  6170. picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  6171. if (!input || typeof input !== 'string') {
  6172. throw new TypeError('Expected a non-empty string');
  6173. }
  6174. let parsed = {
  6175. negated: false,
  6176. fastpaths: true
  6177. };
  6178. if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  6179. parsed.output = parse$1.fastpaths(input, options);
  6180. }
  6181. if (!parsed.output) {
  6182. parsed = parse$1(input, options);
  6183. }
  6184. return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
  6185. };
  6186. /**
  6187. * Create a regular expression from the given regex source string.
  6188. *
  6189. * ```js
  6190. * const picomatch = require('picomatch');
  6191. * // picomatch.toRegex(source[, options]);
  6192. *
  6193. * const { output } = picomatch.parse('*.js');
  6194. * console.log(picomatch.toRegex(output));
  6195. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  6196. * ```
  6197. * @param {String} `source` Regular expression source string.
  6198. * @param {Object} `options`
  6199. * @return {RegExp}
  6200. * @api public
  6201. */
  6202. picomatch$2.toRegex = (source, options) => {
  6203. try {
  6204. const opts = options || {};
  6205. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  6206. } catch (err) {
  6207. if (options && options.debug === true) throw err;
  6208. return /$^/;
  6209. }
  6210. };
  6211. /**
  6212. * Picomatch constants.
  6213. * @return {Object}
  6214. */
  6215. picomatch$2.constants = constants$1;
  6216. /**
  6217. * Expose "picomatch"
  6218. */
  6219. var picomatch_1 = picomatch$2;
  6220. var picomatch$1 = picomatch_1;
  6221. const util = require$$0__default$2["default"];
  6222. const braces = braces_1;
  6223. const picomatch = picomatch$1;
  6224. const utils$b = utils$f;
  6225. const isEmptyString = val => val === '' || val === './';
  6226. /**
  6227. * Returns an array of strings that match one or more glob patterns.
  6228. *
  6229. * ```js
  6230. * const mm = require('micromatch');
  6231. * // mm(list, patterns[, options]);
  6232. *
  6233. * console.log(mm(['a.js', 'a.txt'], ['*.js']));
  6234. * //=> [ 'a.js' ]
  6235. * ```
  6236. * @param {String|Array<string>} `list` List of strings to match.
  6237. * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
  6238. * @param {Object} `options` See available [options](#options)
  6239. * @return {Array} Returns an array of matches
  6240. * @summary false
  6241. * @api public
  6242. */
  6243. const micromatch$1 = (list, patterns, options) => {
  6244. patterns = [].concat(patterns);
  6245. list = [].concat(list);
  6246. let omit = new Set();
  6247. let keep = new Set();
  6248. let items = new Set();
  6249. let negatives = 0;
  6250. let onResult = state => {
  6251. items.add(state.output);
  6252. if (options && options.onResult) {
  6253. options.onResult(state);
  6254. }
  6255. };
  6256. for (let i = 0; i < patterns.length; i++) {
  6257. let isMatch = picomatch(String(patterns[i]), Object.assign(Object.assign({}, options), {}, {
  6258. onResult
  6259. }), true);
  6260. let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
  6261. if (negated) negatives++;
  6262. for (let item of list) {
  6263. let matched = isMatch(item, true);
  6264. let match = negated ? !matched.isMatch : matched.isMatch;
  6265. if (!match) continue;
  6266. if (negated) {
  6267. omit.add(matched.output);
  6268. } else {
  6269. omit.delete(matched.output);
  6270. keep.add(matched.output);
  6271. }
  6272. }
  6273. }
  6274. let result = negatives === patterns.length ? [...items] : [...keep];
  6275. let matches = result.filter(item => !omit.has(item));
  6276. if (options && matches.length === 0) {
  6277. if (options.failglob === true) {
  6278. throw new Error(`No matches found for "${patterns.join(', ')}"`);
  6279. }
  6280. if (options.nonull === true || options.nullglob === true) {
  6281. return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
  6282. }
  6283. }
  6284. return matches;
  6285. };
  6286. /**
  6287. * Backwards compatibility
  6288. */
  6289. micromatch$1.match = micromatch$1;
  6290. /**
  6291. * Returns a matcher function from the given glob `pattern` and `options`.
  6292. * The returned function takes a string to match as its only argument and returns
  6293. * true if the string is a match.
  6294. *
  6295. * ```js
  6296. * const mm = require('micromatch');
  6297. * // mm.matcher(pattern[, options]);
  6298. *
  6299. * const isMatch = mm.matcher('*.!(*a)');
  6300. * console.log(isMatch('a.a')); //=> false
  6301. * console.log(isMatch('a.b')); //=> true
  6302. * ```
  6303. * @param {String} `pattern` Glob pattern
  6304. * @param {Object} `options`
  6305. * @return {Function} Returns a matcher function.
  6306. * @api public
  6307. */
  6308. micromatch$1.matcher = (pattern, options) => picomatch(pattern, options);
  6309. /**
  6310. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  6311. *
  6312. * ```js
  6313. * const mm = require('micromatch');
  6314. * // mm.isMatch(string, patterns[, options]);
  6315. *
  6316. * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
  6317. * console.log(mm.isMatch('a.a', 'b.*')); //=> false
  6318. * ```
  6319. * @param {String} `str` The string to test.
  6320. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  6321. * @param {Object} `[options]` See available [options](#options).
  6322. * @return {Boolean} Returns true if any patterns match `str`
  6323. * @api public
  6324. */
  6325. micromatch$1.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
  6326. /**
  6327. * Backwards compatibility
  6328. */
  6329. micromatch$1.any = micromatch$1.isMatch;
  6330. /**
  6331. * Returns a list of strings that _**do not match any**_ of the given `patterns`.
  6332. *
  6333. * ```js
  6334. * const mm = require('micromatch');
  6335. * // mm.not(list, patterns[, options]);
  6336. *
  6337. * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
  6338. * //=> ['b.b', 'c.c']
  6339. * ```
  6340. * @param {Array} `list` Array of strings to match.
  6341. * @param {String|Array} `patterns` One or more glob pattern to use for matching.
  6342. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6343. * @return {Array} Returns an array of strings that **do not match** the given patterns.
  6344. * @api public
  6345. */
  6346. micromatch$1.not = (list, patterns, options = {}) => {
  6347. patterns = [].concat(patterns).map(String);
  6348. let result = new Set();
  6349. let items = [];
  6350. let onResult = state => {
  6351. if (options.onResult) options.onResult(state);
  6352. items.push(state.output);
  6353. };
  6354. let matches = micromatch$1(list, patterns, Object.assign(Object.assign({}, options), {}, {
  6355. onResult
  6356. }));
  6357. for (let item of items) {
  6358. if (!matches.includes(item)) {
  6359. result.add(item);
  6360. }
  6361. }
  6362. return [...result];
  6363. };
  6364. /**
  6365. * Returns true if the given `string` contains the given pattern. Similar
  6366. * to [.isMatch](#isMatch) but the pattern can match any part of the string.
  6367. *
  6368. * ```js
  6369. * var mm = require('micromatch');
  6370. * // mm.contains(string, pattern[, options]);
  6371. *
  6372. * console.log(mm.contains('aa/bb/cc', '*b'));
  6373. * //=> true
  6374. * console.log(mm.contains('aa/bb/cc', '*d'));
  6375. * //=> false
  6376. * ```
  6377. * @param {String} `str` The string to match.
  6378. * @param {String|Array} `patterns` Glob pattern to use for matching.
  6379. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6380. * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
  6381. * @api public
  6382. */
  6383. micromatch$1.contains = (str, pattern, options) => {
  6384. if (typeof str !== 'string') {
  6385. throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
  6386. }
  6387. if (Array.isArray(pattern)) {
  6388. return pattern.some(p => micromatch$1.contains(str, p, options));
  6389. }
  6390. if (typeof pattern === 'string') {
  6391. if (isEmptyString(str) || isEmptyString(pattern)) {
  6392. return false;
  6393. }
  6394. if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) {
  6395. return true;
  6396. }
  6397. }
  6398. return micromatch$1.isMatch(str, pattern, Object.assign(Object.assign({}, options), {}, {
  6399. contains: true
  6400. }));
  6401. };
  6402. /**
  6403. * Filter the keys of the given object with the given `glob` pattern
  6404. * and `options`. Does not attempt to match nested keys. If you need this feature,
  6405. * use [glob-object][] instead.
  6406. *
  6407. * ```js
  6408. * const mm = require('micromatch');
  6409. * // mm.matchKeys(object, patterns[, options]);
  6410. *
  6411. * const obj = { aa: 'a', ab: 'b', ac: 'c' };
  6412. * console.log(mm.matchKeys(obj, '*b'));
  6413. * //=> { ab: 'b' }
  6414. * ```
  6415. * @param {Object} `object` The object with keys to filter.
  6416. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  6417. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6418. * @return {Object} Returns an object with only keys that match the given patterns.
  6419. * @api public
  6420. */
  6421. micromatch$1.matchKeys = (obj, patterns, options) => {
  6422. if (!utils$b.isObject(obj)) {
  6423. throw new TypeError('Expected the first argument to be an object');
  6424. }
  6425. let keys = micromatch$1(Object.keys(obj), patterns, options);
  6426. let res = {};
  6427. for (let key of keys) res[key] = obj[key];
  6428. return res;
  6429. };
  6430. /**
  6431. * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
  6432. *
  6433. * ```js
  6434. * const mm = require('micromatch');
  6435. * // mm.some(list, patterns[, options]);
  6436. *
  6437. * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  6438. * // true
  6439. * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
  6440. * // false
  6441. * ```
  6442. * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
  6443. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  6444. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6445. * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
  6446. * @api public
  6447. */
  6448. micromatch$1.some = (list, patterns, options) => {
  6449. let items = [].concat(list);
  6450. for (let pattern of [].concat(patterns)) {
  6451. let isMatch = picomatch(String(pattern), options);
  6452. if (items.some(item => isMatch(item))) {
  6453. return true;
  6454. }
  6455. }
  6456. return false;
  6457. };
  6458. /**
  6459. * Returns true if every string in the given `list` matches
  6460. * any of the given glob `patterns`.
  6461. *
  6462. * ```js
  6463. * const mm = require('micromatch');
  6464. * // mm.every(list, patterns[, options]);
  6465. *
  6466. * console.log(mm.every('foo.js', ['foo.js']));
  6467. * // true
  6468. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
  6469. * // true
  6470. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  6471. * // false
  6472. * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
  6473. * // false
  6474. * ```
  6475. * @param {String|Array} `list` The string or array of strings to test.
  6476. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  6477. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6478. * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
  6479. * @api public
  6480. */
  6481. micromatch$1.every = (list, patterns, options) => {
  6482. let items = [].concat(list);
  6483. for (let pattern of [].concat(patterns)) {
  6484. let isMatch = picomatch(String(pattern), options);
  6485. if (!items.every(item => isMatch(item))) {
  6486. return false;
  6487. }
  6488. }
  6489. return true;
  6490. };
  6491. /**
  6492. * Returns true if **all** of the given `patterns` match
  6493. * the specified string.
  6494. *
  6495. * ```js
  6496. * const mm = require('micromatch');
  6497. * // mm.all(string, patterns[, options]);
  6498. *
  6499. * console.log(mm.all('foo.js', ['foo.js']));
  6500. * // true
  6501. *
  6502. * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
  6503. * // false
  6504. *
  6505. * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
  6506. * // true
  6507. *
  6508. * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
  6509. * // true
  6510. * ```
  6511. * @param {String|Array} `str` The string to test.
  6512. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  6513. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6514. * @return {Boolean} Returns true if any patterns match `str`
  6515. * @api public
  6516. */
  6517. micromatch$1.all = (str, patterns, options) => {
  6518. if (typeof str !== 'string') {
  6519. throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
  6520. }
  6521. return [].concat(patterns).every(p => picomatch(p, options)(str));
  6522. };
  6523. /**
  6524. * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
  6525. *
  6526. * ```js
  6527. * const mm = require('micromatch');
  6528. * // mm.capture(pattern, string[, options]);
  6529. *
  6530. * console.log(mm.capture('test/*.js', 'test/foo.js'));
  6531. * //=> ['foo']
  6532. * console.log(mm.capture('test/*.js', 'foo/bar.css'));
  6533. * //=> null
  6534. * ```
  6535. * @param {String} `glob` Glob pattern to use for matching.
  6536. * @param {String} `input` String to match
  6537. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  6538. * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
  6539. * @api public
  6540. */
  6541. micromatch$1.capture = (glob, input, options) => {
  6542. let posix = utils$b.isWindows(options);
  6543. let regex = picomatch.makeRe(String(glob), Object.assign(Object.assign({}, options), {}, {
  6544. capture: true
  6545. }));
  6546. let match = regex.exec(posix ? utils$b.toPosixSlashes(input) : input);
  6547. if (match) {
  6548. return match.slice(1).map(v => v === void 0 ? '' : v);
  6549. }
  6550. };
  6551. /**
  6552. * Create a regular expression from the given glob `pattern`.
  6553. *
  6554. * ```js
  6555. * const mm = require('micromatch');
  6556. * // mm.makeRe(pattern[, options]);
  6557. *
  6558. * console.log(mm.makeRe('*.js'));
  6559. * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
  6560. * ```
  6561. * @param {String} `pattern` A glob pattern to convert to regex.
  6562. * @param {Object} `options`
  6563. * @return {RegExp} Returns a regex created from the given pattern.
  6564. * @api public
  6565. */
  6566. micromatch$1.makeRe = (...args) => picomatch.makeRe(...args);
  6567. /**
  6568. * Scan a glob pattern to separate the pattern into segments. Used
  6569. * by the [split](#split) method.
  6570. *
  6571. * ```js
  6572. * const mm = require('micromatch');
  6573. * const state = mm.scan(pattern[, options]);
  6574. * ```
  6575. * @param {String} `pattern`
  6576. * @param {Object} `options`
  6577. * @return {Object} Returns an object with
  6578. * @api public
  6579. */
  6580. micromatch$1.scan = (...args) => picomatch.scan(...args);
  6581. /**
  6582. * Parse a glob pattern to create the source string for a regular
  6583. * expression.
  6584. *
  6585. * ```js
  6586. * const mm = require('micromatch');
  6587. * const state = mm(pattern[, options]);
  6588. * ```
  6589. * @param {String} `glob`
  6590. * @param {Object} `options`
  6591. * @return {Object} Returns an object with useful properties and output to be used as regex source string.
  6592. * @api public
  6593. */
  6594. micromatch$1.parse = (patterns, options) => {
  6595. let res = [];
  6596. for (let pattern of [].concat(patterns || [])) {
  6597. for (let str of braces(String(pattern), options)) {
  6598. res.push(picomatch.parse(str, options));
  6599. }
  6600. }
  6601. return res;
  6602. };
  6603. /**
  6604. * Process the given brace `pattern`.
  6605. *
  6606. * ```js
  6607. * const { braces } = require('micromatch');
  6608. * console.log(braces('foo/{a,b,c}/bar'));
  6609. * //=> [ 'foo/(a|b|c)/bar' ]
  6610. *
  6611. * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
  6612. * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
  6613. * ```
  6614. * @param {String} `pattern` String with brace pattern to process.
  6615. * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
  6616. * @return {Array}
  6617. * @api public
  6618. */
  6619. micromatch$1.braces = (pattern, options) => {
  6620. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  6621. if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
  6622. return [pattern];
  6623. }
  6624. return braces(pattern, options);
  6625. };
  6626. /**
  6627. * Expand braces
  6628. */
  6629. micromatch$1.braceExpand = (pattern, options) => {
  6630. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  6631. return micromatch$1.braces(pattern, Object.assign(Object.assign({}, options), {}, {
  6632. expand: true
  6633. }));
  6634. };
  6635. /**
  6636. * Expose micromatch
  6637. */
  6638. var micromatch_1 = micromatch$1;
  6639. Object.defineProperty(pattern$1, "__esModule", {
  6640. value: true
  6641. });
  6642. pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
  6643. const path$8 = require$$0__default$1["default"];
  6644. const globParent = globParent$1;
  6645. const micromatch = micromatch_1;
  6646. const GLOBSTAR = '**';
  6647. const ESCAPE_SYMBOL = '\\';
  6648. const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
  6649. const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
  6650. const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
  6651. const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
  6652. const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
  6653. function isStaticPattern(pattern, options = {}) {
  6654. return !isDynamicPattern(pattern, options);
  6655. }
  6656. pattern$1.isStaticPattern = isStaticPattern;
  6657. function isDynamicPattern(pattern, options = {}) {
  6658. /**
  6659. * A special case with an empty string is necessary for matching patterns that start with a forward slash.
  6660. * An empty string cannot be a dynamic pattern.
  6661. * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
  6662. */
  6663. if (pattern === '') {
  6664. return false;
  6665. }
  6666. /**
  6667. * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
  6668. * filepath directly (without read directory).
  6669. */
  6670. if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
  6671. return true;
  6672. }
  6673. if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
  6674. return true;
  6675. }
  6676. if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
  6677. return true;
  6678. }
  6679. if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
  6680. return true;
  6681. }
  6682. return false;
  6683. }
  6684. pattern$1.isDynamicPattern = isDynamicPattern;
  6685. function convertToPositivePattern(pattern) {
  6686. return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
  6687. }
  6688. pattern$1.convertToPositivePattern = convertToPositivePattern;
  6689. function convertToNegativePattern(pattern) {
  6690. return '!' + pattern;
  6691. }
  6692. pattern$1.convertToNegativePattern = convertToNegativePattern;
  6693. function isNegativePattern(pattern) {
  6694. return pattern.startsWith('!') && pattern[1] !== '(';
  6695. }
  6696. pattern$1.isNegativePattern = isNegativePattern;
  6697. function isPositivePattern(pattern) {
  6698. return !isNegativePattern(pattern);
  6699. }
  6700. pattern$1.isPositivePattern = isPositivePattern;
  6701. function getNegativePatterns(patterns) {
  6702. return patterns.filter(isNegativePattern);
  6703. }
  6704. pattern$1.getNegativePatterns = getNegativePatterns;
  6705. function getPositivePatterns$1(patterns) {
  6706. return patterns.filter(isPositivePattern);
  6707. }
  6708. pattern$1.getPositivePatterns = getPositivePatterns$1;
  6709. /**
  6710. * Returns patterns that can be applied inside the current directory.
  6711. *
  6712. * @example
  6713. * // ['./*', '*', 'a/*']
  6714. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  6715. */
  6716. function getPatternsInsideCurrentDirectory(patterns) {
  6717. return patterns.filter(pattern => !isPatternRelatedToParentDirectory(pattern));
  6718. }
  6719. pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
  6720. /**
  6721. * Returns patterns to be expanded relative to (outside) the current directory.
  6722. *
  6723. * @example
  6724. * // ['../*', './../*']
  6725. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  6726. */
  6727. function getPatternsOutsideCurrentDirectory(patterns) {
  6728. return patterns.filter(isPatternRelatedToParentDirectory);
  6729. }
  6730. pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
  6731. function isPatternRelatedToParentDirectory(pattern) {
  6732. return pattern.startsWith('..') || pattern.startsWith('./..');
  6733. }
  6734. pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
  6735. function getBaseDirectory(pattern) {
  6736. return globParent(pattern, {
  6737. flipBackslashes: false
  6738. });
  6739. }
  6740. pattern$1.getBaseDirectory = getBaseDirectory;
  6741. function hasGlobStar(pattern) {
  6742. return pattern.includes(GLOBSTAR);
  6743. }
  6744. pattern$1.hasGlobStar = hasGlobStar;
  6745. function endsWithSlashGlobStar(pattern) {
  6746. return pattern.endsWith('/' + GLOBSTAR);
  6747. }
  6748. pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
  6749. function isAffectDepthOfReadingPattern(pattern) {
  6750. const basename = path$8.basename(pattern);
  6751. return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
  6752. }
  6753. pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
  6754. function expandPatternsWithBraceExpansion(patterns) {
  6755. return patterns.reduce((collection, pattern) => {
  6756. return collection.concat(expandBraceExpansion(pattern));
  6757. }, []);
  6758. }
  6759. pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
  6760. function expandBraceExpansion(pattern) {
  6761. return micromatch.braces(pattern, {
  6762. expand: true,
  6763. nodupes: true
  6764. });
  6765. }
  6766. pattern$1.expandBraceExpansion = expandBraceExpansion;
  6767. function getPatternParts(pattern, options) {
  6768. let {
  6769. parts
  6770. } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), {
  6771. parts: true
  6772. }));
  6773. /**
  6774. * The scan method returns an empty array in some cases.
  6775. * See micromatch/picomatch#58 for more details.
  6776. */
  6777. if (parts.length === 0) {
  6778. parts = [pattern];
  6779. }
  6780. /**
  6781. * The scan method does not return an empty part for the pattern with a forward slash.
  6782. * This is another part of micromatch/picomatch#58.
  6783. */
  6784. if (parts[0].startsWith('/')) {
  6785. parts[0] = parts[0].slice(1);
  6786. parts.unshift('');
  6787. }
  6788. return parts;
  6789. }
  6790. pattern$1.getPatternParts = getPatternParts;
  6791. function makeRe(pattern, options) {
  6792. return micromatch.makeRe(pattern, options);
  6793. }
  6794. pattern$1.makeRe = makeRe;
  6795. function convertPatternsToRe(patterns, options) {
  6796. return patterns.map(pattern => makeRe(pattern, options));
  6797. }
  6798. pattern$1.convertPatternsToRe = convertPatternsToRe;
  6799. function matchAny(entry, patternsRe) {
  6800. return patternsRe.some(patternRe => patternRe.test(entry));
  6801. }
  6802. pattern$1.matchAny = matchAny;
  6803. var stream$4 = {};
  6804. /*
  6805. * merge2
  6806. * https://github.com/teambition/merge2
  6807. *
  6808. * Copyright (c) 2014-2020 Teambition
  6809. * Licensed under the MIT license.
  6810. */
  6811. const Stream = require$$0__default$3["default"];
  6812. const PassThrough = Stream.PassThrough;
  6813. const slice = Array.prototype.slice;
  6814. var merge2_1 = merge2$1;
  6815. function merge2$1() {
  6816. const streamsQueue = [];
  6817. const args = slice.call(arguments);
  6818. let merging = false;
  6819. let options = args[args.length - 1];
  6820. if (options && !Array.isArray(options) && options.pipe == null) {
  6821. args.pop();
  6822. } else {
  6823. options = {};
  6824. }
  6825. const doEnd = options.end !== false;
  6826. const doPipeError = options.pipeError === true;
  6827. if (options.objectMode == null) {
  6828. options.objectMode = true;
  6829. }
  6830. if (options.highWaterMark == null) {
  6831. options.highWaterMark = 64 * 1024;
  6832. }
  6833. const mergedStream = PassThrough(options);
  6834. function addStream() {
  6835. for (let i = 0, len = arguments.length; i < len; i++) {
  6836. streamsQueue.push(pauseStreams(arguments[i], options));
  6837. }
  6838. mergeStream();
  6839. return this;
  6840. }
  6841. function mergeStream() {
  6842. if (merging) {
  6843. return;
  6844. }
  6845. merging = true;
  6846. let streams = streamsQueue.shift();
  6847. if (!streams) {
  6848. process.nextTick(endStream);
  6849. return;
  6850. }
  6851. if (!Array.isArray(streams)) {
  6852. streams = [streams];
  6853. }
  6854. let pipesCount = streams.length + 1;
  6855. function next() {
  6856. if (--pipesCount > 0) {
  6857. return;
  6858. }
  6859. merging = false;
  6860. mergeStream();
  6861. }
  6862. function pipe(stream) {
  6863. function onend() {
  6864. stream.removeListener('merge2UnpipeEnd', onend);
  6865. stream.removeListener('end', onend);
  6866. if (doPipeError) {
  6867. stream.removeListener('error', onerror);
  6868. }
  6869. next();
  6870. }
  6871. function onerror(err) {
  6872. mergedStream.emit('error', err);
  6873. } // skip ended stream
  6874. if (stream._readableState.endEmitted) {
  6875. return next();
  6876. }
  6877. stream.on('merge2UnpipeEnd', onend);
  6878. stream.on('end', onend);
  6879. if (doPipeError) {
  6880. stream.on('error', onerror);
  6881. }
  6882. stream.pipe(mergedStream, {
  6883. end: false
  6884. }); // compatible for old stream
  6885. stream.resume();
  6886. }
  6887. for (let i = 0; i < streams.length; i++) {
  6888. pipe(streams[i]);
  6889. }
  6890. next();
  6891. }
  6892. function endStream() {
  6893. merging = false; // emit 'queueDrain' when all streams merged.
  6894. mergedStream.emit('queueDrain');
  6895. if (doEnd) {
  6896. mergedStream.end();
  6897. }
  6898. }
  6899. mergedStream.setMaxListeners(0);
  6900. mergedStream.add = addStream;
  6901. mergedStream.on('unpipe', function (stream) {
  6902. stream.emit('merge2UnpipeEnd');
  6903. });
  6904. if (args.length) {
  6905. addStream.apply(null, args);
  6906. }
  6907. return mergedStream;
  6908. } // check and pause streams for pipe.
  6909. function pauseStreams(streams, options) {
  6910. if (!Array.isArray(streams)) {
  6911. // Backwards-compat with old-style streams
  6912. if (!streams._readableState && streams.pipe) {
  6913. streams = streams.pipe(PassThrough(options));
  6914. }
  6915. if (!streams._readableState || !streams.pause || !streams.pipe) {
  6916. throw new Error('Only readable stream can be merged.');
  6917. }
  6918. streams.pause();
  6919. } else {
  6920. for (let i = 0, len = streams.length; i < len; i++) {
  6921. streams[i] = pauseStreams(streams[i], options);
  6922. }
  6923. }
  6924. return streams;
  6925. }
  6926. Object.defineProperty(stream$4, "__esModule", {
  6927. value: true
  6928. });
  6929. stream$4.merge = void 0;
  6930. const merge2 = merge2_1;
  6931. function merge$2(streams) {
  6932. const mergedStream = merge2(streams);
  6933. streams.forEach(stream => {
  6934. stream.once('error', error => mergedStream.emit('error', error));
  6935. });
  6936. mergedStream.once('close', () => propagateCloseEventToSources(streams));
  6937. mergedStream.once('end', () => propagateCloseEventToSources(streams));
  6938. return mergedStream;
  6939. }
  6940. stream$4.merge = merge$2;
  6941. function propagateCloseEventToSources(streams) {
  6942. streams.forEach(stream => stream.emit('close'));
  6943. }
  6944. var string$1 = {};
  6945. Object.defineProperty(string$1, "__esModule", {
  6946. value: true
  6947. });
  6948. string$1.isEmpty = string$1.isString = void 0;
  6949. function isString(input) {
  6950. return typeof input === 'string';
  6951. }
  6952. string$1.isString = isString;
  6953. function isEmpty(input) {
  6954. return input === '';
  6955. }
  6956. string$1.isEmpty = isEmpty;
  6957. Object.defineProperty(utils$k, "__esModule", {
  6958. value: true
  6959. });
  6960. utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
  6961. const array$2 = array$3;
  6962. utils$k.array = array$2;
  6963. const errno = errno$1;
  6964. utils$k.errno = errno;
  6965. const fs$8 = fs$9;
  6966. utils$k.fs = fs$8;
  6967. const path$7 = path$c;
  6968. utils$k.path = path$7;
  6969. const pattern = pattern$1;
  6970. utils$k.pattern = pattern;
  6971. const stream$3 = stream$4;
  6972. utils$k.stream = stream$3;
  6973. const string = string$1;
  6974. utils$k.string = string;
  6975. Object.defineProperty(tasks, "__esModule", {
  6976. value: true
  6977. });
  6978. tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
  6979. const utils$a = utils$k;
  6980. function generate(patterns, settings) {
  6981. const positivePatterns = getPositivePatterns(patterns);
  6982. const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
  6983. const staticPatterns = positivePatterns.filter(pattern => utils$a.pattern.isStaticPattern(pattern, settings));
  6984. const dynamicPatterns = positivePatterns.filter(pattern => utils$a.pattern.isDynamicPattern(pattern, settings));
  6985. const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns,
  6986. /* dynamic */
  6987. false);
  6988. const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns,
  6989. /* dynamic */
  6990. true);
  6991. return staticTasks.concat(dynamicTasks);
  6992. }
  6993. tasks.generate = generate;
  6994. /**
  6995. * Returns tasks grouped by basic pattern directories.
  6996. *
  6997. * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
  6998. * This is necessary because directory traversal starts at the base directory and goes deeper.
  6999. */
  7000. function convertPatternsToTasks(positive, negative, dynamic) {
  7001. const tasks = [];
  7002. const patternsOutsideCurrentDirectory = utils$a.pattern.getPatternsOutsideCurrentDirectory(positive);
  7003. const patternsInsideCurrentDirectory = utils$a.pattern.getPatternsInsideCurrentDirectory(positive);
  7004. const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
  7005. const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
  7006. tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
  7007. /*
  7008. * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
  7009. * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
  7010. */
  7011. if ('.' in insideCurrentDirectoryGroup) {
  7012. tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
  7013. } else {
  7014. tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
  7015. }
  7016. return tasks;
  7017. }
  7018. tasks.convertPatternsToTasks = convertPatternsToTasks;
  7019. function getPositivePatterns(patterns) {
  7020. return utils$a.pattern.getPositivePatterns(patterns);
  7021. }
  7022. tasks.getPositivePatterns = getPositivePatterns;
  7023. function getNegativePatternsAsPositive(patterns, ignore) {
  7024. const negative = utils$a.pattern.getNegativePatterns(patterns).concat(ignore);
  7025. const positive = negative.map(utils$a.pattern.convertToPositivePattern);
  7026. return positive;
  7027. }
  7028. tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
  7029. function groupPatternsByBaseDirectory(patterns) {
  7030. const group = {};
  7031. return patterns.reduce((collection, pattern) => {
  7032. const base = utils$a.pattern.getBaseDirectory(pattern);
  7033. if (base in collection) {
  7034. collection[base].push(pattern);
  7035. } else {
  7036. collection[base] = [pattern];
  7037. }
  7038. return collection;
  7039. }, group);
  7040. }
  7041. tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
  7042. function convertPatternGroupsToTasks(positive, negative, dynamic) {
  7043. return Object.keys(positive).map(base => {
  7044. return convertPatternGroupToTask(base, positive[base], negative, dynamic);
  7045. });
  7046. }
  7047. tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
  7048. function convertPatternGroupToTask(base, positive, negative, dynamic) {
  7049. return {
  7050. dynamic,
  7051. positive,
  7052. negative,
  7053. base,
  7054. patterns: [].concat(positive, negative.map(utils$a.pattern.convertToNegativePattern))
  7055. };
  7056. }
  7057. tasks.convertPatternGroupToTask = convertPatternGroupToTask;
  7058. var async$6 = {};
  7059. var stream$2 = {};
  7060. var out$3 = {};
  7061. var async$5 = {};
  7062. Object.defineProperty(async$5, "__esModule", {
  7063. value: true
  7064. });
  7065. async$5.read = void 0;
  7066. function read$3(path, settings, callback) {
  7067. settings.fs.lstat(path, (lstatError, lstat) => {
  7068. if (lstatError !== null) {
  7069. callFailureCallback$2(callback, lstatError);
  7070. return;
  7071. }
  7072. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  7073. callSuccessCallback$2(callback, lstat);
  7074. return;
  7075. }
  7076. settings.fs.stat(path, (statError, stat) => {
  7077. if (statError !== null) {
  7078. if (settings.throwErrorOnBrokenSymbolicLink) {
  7079. callFailureCallback$2(callback, statError);
  7080. return;
  7081. }
  7082. callSuccessCallback$2(callback, lstat);
  7083. return;
  7084. }
  7085. if (settings.markSymbolicLink) {
  7086. stat.isSymbolicLink = () => true;
  7087. }
  7088. callSuccessCallback$2(callback, stat);
  7089. });
  7090. });
  7091. }
  7092. async$5.read = read$3;
  7093. function callFailureCallback$2(callback, error) {
  7094. callback(error);
  7095. }
  7096. function callSuccessCallback$2(callback, result) {
  7097. callback(null, result);
  7098. }
  7099. var sync$7 = {};
  7100. Object.defineProperty(sync$7, "__esModule", {
  7101. value: true
  7102. });
  7103. sync$7.read = void 0;
  7104. function read$2(path, settings) {
  7105. const lstat = settings.fs.lstatSync(path);
  7106. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  7107. return lstat;
  7108. }
  7109. try {
  7110. const stat = settings.fs.statSync(path);
  7111. if (settings.markSymbolicLink) {
  7112. stat.isSymbolicLink = () => true;
  7113. }
  7114. return stat;
  7115. } catch (error) {
  7116. if (!settings.throwErrorOnBrokenSymbolicLink) {
  7117. return lstat;
  7118. }
  7119. throw error;
  7120. }
  7121. }
  7122. sync$7.read = read$2;
  7123. var settings$3 = {};
  7124. var fs$7 = {};
  7125. (function (exports) {
  7126. Object.defineProperty(exports, "__esModule", {
  7127. value: true
  7128. });
  7129. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  7130. const fs = require$$0__default$4["default"];
  7131. exports.FILE_SYSTEM_ADAPTER = {
  7132. lstat: fs.lstat,
  7133. stat: fs.stat,
  7134. lstatSync: fs.lstatSync,
  7135. statSync: fs.statSync
  7136. };
  7137. function createFileSystemAdapter(fsMethods) {
  7138. if (fsMethods === undefined) {
  7139. return exports.FILE_SYSTEM_ADAPTER;
  7140. }
  7141. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  7142. }
  7143. exports.createFileSystemAdapter = createFileSystemAdapter;
  7144. })(fs$7);
  7145. Object.defineProperty(settings$3, "__esModule", {
  7146. value: true
  7147. });
  7148. const fs$6 = fs$7;
  7149. class Settings$2 {
  7150. constructor(_options = {}) {
  7151. this._options = _options;
  7152. this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
  7153. this.fs = fs$6.createFileSystemAdapter(this._options.fs);
  7154. this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
  7155. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  7156. }
  7157. _getValue(option, value) {
  7158. return option !== null && option !== void 0 ? option : value;
  7159. }
  7160. }
  7161. settings$3.default = Settings$2;
  7162. Object.defineProperty(out$3, "__esModule", {
  7163. value: true
  7164. });
  7165. out$3.statSync = out$3.stat = out$3.Settings = void 0;
  7166. const async$4 = async$5;
  7167. const sync$6 = sync$7;
  7168. const settings_1$3 = settings$3;
  7169. out$3.Settings = settings_1$3.default;
  7170. function stat(path, optionsOrSettingsOrCallback, callback) {
  7171. if (typeof optionsOrSettingsOrCallback === 'function') {
  7172. async$4.read(path, getSettings$2(), optionsOrSettingsOrCallback);
  7173. return;
  7174. }
  7175. async$4.read(path, getSettings$2(optionsOrSettingsOrCallback), callback);
  7176. }
  7177. out$3.stat = stat;
  7178. function statSync(path, optionsOrSettings) {
  7179. const settings = getSettings$2(optionsOrSettings);
  7180. return sync$6.read(path, settings);
  7181. }
  7182. out$3.statSync = statSync;
  7183. function getSettings$2(settingsOrOptions = {}) {
  7184. if (settingsOrOptions instanceof settings_1$3.default) {
  7185. return settingsOrOptions;
  7186. }
  7187. return new settings_1$3.default(settingsOrOptions);
  7188. }
  7189. var out$2 = {};
  7190. var async$3 = {};
  7191. var async$2 = {};
  7192. var out$1 = {};
  7193. var async$1 = {};
  7194. /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  7195. let promise;
  7196. var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : global) // reuse resolved promise, and allocate it lazily
  7197. : cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {
  7198. throw err;
  7199. }, 0));
  7200. /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  7201. var runParallel_1 = runParallel;
  7202. const queueMicrotask$1 = queueMicrotask_1;
  7203. function runParallel(tasks, cb) {
  7204. let results, pending, keys;
  7205. let isSync = true;
  7206. if (Array.isArray(tasks)) {
  7207. results = [];
  7208. pending = tasks.length;
  7209. } else {
  7210. keys = Object.keys(tasks);
  7211. results = {};
  7212. pending = keys.length;
  7213. }
  7214. function done(err) {
  7215. function end() {
  7216. if (cb) cb(err, results);
  7217. cb = null;
  7218. }
  7219. if (isSync) queueMicrotask$1(end);else end();
  7220. }
  7221. function each(i, err, result) {
  7222. results[i] = result;
  7223. if (--pending === 0 || err) {
  7224. done(err);
  7225. }
  7226. }
  7227. if (!pending) {
  7228. // empty
  7229. done(null);
  7230. } else if (keys) {
  7231. // object
  7232. keys.forEach(function (key) {
  7233. tasks[key](function (err, result) {
  7234. each(key, err, result);
  7235. });
  7236. });
  7237. } else {
  7238. // array
  7239. tasks.forEach(function (task, i) {
  7240. task(function (err, result) {
  7241. each(i, err, result);
  7242. });
  7243. });
  7244. }
  7245. isSync = false;
  7246. }
  7247. var constants = {};
  7248. Object.defineProperty(constants, "__esModule", {
  7249. value: true
  7250. });
  7251. constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
  7252. const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
  7253. if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) {
  7254. throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);
  7255. }
  7256. const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
  7257. const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
  7258. const SUPPORTED_MAJOR_VERSION = 10;
  7259. const SUPPORTED_MINOR_VERSION = 10;
  7260. const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
  7261. const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
  7262. /**
  7263. * IS `true` for Node.js 10.10 and greater.
  7264. */
  7265. constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
  7266. var utils$9 = {};
  7267. var fs$5 = {};
  7268. Object.defineProperty(fs$5, "__esModule", {
  7269. value: true
  7270. });
  7271. fs$5.createDirentFromStats = void 0;
  7272. class DirentFromStats {
  7273. constructor(name, stats) {
  7274. this.name = name;
  7275. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  7276. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  7277. this.isDirectory = stats.isDirectory.bind(stats);
  7278. this.isFIFO = stats.isFIFO.bind(stats);
  7279. this.isFile = stats.isFile.bind(stats);
  7280. this.isSocket = stats.isSocket.bind(stats);
  7281. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  7282. }
  7283. }
  7284. function createDirentFromStats(name, stats) {
  7285. return new DirentFromStats(name, stats);
  7286. }
  7287. fs$5.createDirentFromStats = createDirentFromStats;
  7288. Object.defineProperty(utils$9, "__esModule", {
  7289. value: true
  7290. });
  7291. utils$9.fs = void 0;
  7292. const fs$4 = fs$5;
  7293. utils$9.fs = fs$4;
  7294. var common$6 = {};
  7295. Object.defineProperty(common$6, "__esModule", {
  7296. value: true
  7297. });
  7298. common$6.joinPathSegments = void 0;
  7299. function joinPathSegments$1(a, b, separator) {
  7300. /**
  7301. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  7302. */
  7303. if (a.endsWith(separator)) {
  7304. return a + b;
  7305. }
  7306. return a + separator + b;
  7307. }
  7308. common$6.joinPathSegments = joinPathSegments$1;
  7309. Object.defineProperty(async$1, "__esModule", {
  7310. value: true
  7311. });
  7312. async$1.readdir = async$1.readdirWithFileTypes = async$1.read = void 0;
  7313. const fsStat$5 = out$3;
  7314. const rpl = runParallel_1;
  7315. const constants_1$1 = constants;
  7316. const utils$8 = utils$9;
  7317. const common$5 = common$6;
  7318. function read$1(directory, settings, callback) {
  7319. if (!settings.stats && constants_1$1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  7320. readdirWithFileTypes$1(directory, settings, callback);
  7321. return;
  7322. }
  7323. readdir$1(directory, settings, callback);
  7324. }
  7325. async$1.read = read$1;
  7326. function readdirWithFileTypes$1(directory, settings, callback) {
  7327. settings.fs.readdir(directory, {
  7328. withFileTypes: true
  7329. }, (readdirError, dirents) => {
  7330. if (readdirError !== null) {
  7331. callFailureCallback$1(callback, readdirError);
  7332. return;
  7333. }
  7334. const entries = dirents.map(dirent => ({
  7335. dirent,
  7336. name: dirent.name,
  7337. path: common$5.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  7338. }));
  7339. if (!settings.followSymbolicLinks) {
  7340. callSuccessCallback$1(callback, entries);
  7341. return;
  7342. }
  7343. const tasks = entries.map(entry => makeRplTaskEntry(entry, settings));
  7344. rpl(tasks, (rplError, rplEntries) => {
  7345. if (rplError !== null) {
  7346. callFailureCallback$1(callback, rplError);
  7347. return;
  7348. }
  7349. callSuccessCallback$1(callback, rplEntries);
  7350. });
  7351. });
  7352. }
  7353. async$1.readdirWithFileTypes = readdirWithFileTypes$1;
  7354. function makeRplTaskEntry(entry, settings) {
  7355. return done => {
  7356. if (!entry.dirent.isSymbolicLink()) {
  7357. done(null, entry);
  7358. return;
  7359. }
  7360. settings.fs.stat(entry.path, (statError, stats) => {
  7361. if (statError !== null) {
  7362. if (settings.throwErrorOnBrokenSymbolicLink) {
  7363. done(statError);
  7364. return;
  7365. }
  7366. done(null, entry);
  7367. return;
  7368. }
  7369. entry.dirent = utils$8.fs.createDirentFromStats(entry.name, stats);
  7370. done(null, entry);
  7371. });
  7372. };
  7373. }
  7374. function readdir$1(directory, settings, callback) {
  7375. settings.fs.readdir(directory, (readdirError, names) => {
  7376. if (readdirError !== null) {
  7377. callFailureCallback$1(callback, readdirError);
  7378. return;
  7379. }
  7380. const tasks = names.map(name => {
  7381. const path = common$5.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  7382. return done => {
  7383. fsStat$5.stat(path, settings.fsStatSettings, (error, stats) => {
  7384. if (error !== null) {
  7385. done(error);
  7386. return;
  7387. }
  7388. const entry = {
  7389. name,
  7390. path,
  7391. dirent: utils$8.fs.createDirentFromStats(name, stats)
  7392. };
  7393. if (settings.stats) {
  7394. entry.stats = stats;
  7395. }
  7396. done(null, entry);
  7397. });
  7398. };
  7399. });
  7400. rpl(tasks, (rplError, entries) => {
  7401. if (rplError !== null) {
  7402. callFailureCallback$1(callback, rplError);
  7403. return;
  7404. }
  7405. callSuccessCallback$1(callback, entries);
  7406. });
  7407. });
  7408. }
  7409. async$1.readdir = readdir$1;
  7410. function callFailureCallback$1(callback, error) {
  7411. callback(error);
  7412. }
  7413. function callSuccessCallback$1(callback, result) {
  7414. callback(null, result);
  7415. }
  7416. var sync$5 = {};
  7417. Object.defineProperty(sync$5, "__esModule", {
  7418. value: true
  7419. });
  7420. sync$5.readdir = sync$5.readdirWithFileTypes = sync$5.read = void 0;
  7421. const fsStat$4 = out$3;
  7422. const constants_1 = constants;
  7423. const utils$7 = utils$9;
  7424. const common$4 = common$6;
  7425. function read(directory, settings) {
  7426. if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  7427. return readdirWithFileTypes(directory, settings);
  7428. }
  7429. return readdir(directory, settings);
  7430. }
  7431. sync$5.read = read;
  7432. function readdirWithFileTypes(directory, settings) {
  7433. const dirents = settings.fs.readdirSync(directory, {
  7434. withFileTypes: true
  7435. });
  7436. return dirents.map(dirent => {
  7437. const entry = {
  7438. dirent,
  7439. name: dirent.name,
  7440. path: common$4.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  7441. };
  7442. if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
  7443. try {
  7444. const stats = settings.fs.statSync(entry.path);
  7445. entry.dirent = utils$7.fs.createDirentFromStats(entry.name, stats);
  7446. } catch (error) {
  7447. if (settings.throwErrorOnBrokenSymbolicLink) {
  7448. throw error;
  7449. }
  7450. }
  7451. }
  7452. return entry;
  7453. });
  7454. }
  7455. sync$5.readdirWithFileTypes = readdirWithFileTypes;
  7456. function readdir(directory, settings) {
  7457. const names = settings.fs.readdirSync(directory);
  7458. return names.map(name => {
  7459. const entryPath = common$4.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  7460. const stats = fsStat$4.statSync(entryPath, settings.fsStatSettings);
  7461. const entry = {
  7462. name,
  7463. path: entryPath,
  7464. dirent: utils$7.fs.createDirentFromStats(name, stats)
  7465. };
  7466. if (settings.stats) {
  7467. entry.stats = stats;
  7468. }
  7469. return entry;
  7470. });
  7471. }
  7472. sync$5.readdir = readdir;
  7473. var settings$2 = {};
  7474. var fs$3 = {};
  7475. (function (exports) {
  7476. Object.defineProperty(exports, "__esModule", {
  7477. value: true
  7478. });
  7479. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  7480. const fs = require$$0__default$4["default"];
  7481. exports.FILE_SYSTEM_ADAPTER = {
  7482. lstat: fs.lstat,
  7483. stat: fs.stat,
  7484. lstatSync: fs.lstatSync,
  7485. statSync: fs.statSync,
  7486. readdir: fs.readdir,
  7487. readdirSync: fs.readdirSync
  7488. };
  7489. function createFileSystemAdapter(fsMethods) {
  7490. if (fsMethods === undefined) {
  7491. return exports.FILE_SYSTEM_ADAPTER;
  7492. }
  7493. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  7494. }
  7495. exports.createFileSystemAdapter = createFileSystemAdapter;
  7496. })(fs$3);
  7497. Object.defineProperty(settings$2, "__esModule", {
  7498. value: true
  7499. });
  7500. const path$6 = require$$0__default$1["default"];
  7501. const fsStat$3 = out$3;
  7502. const fs$2 = fs$3;
  7503. class Settings$1 {
  7504. constructor(_options = {}) {
  7505. this._options = _options;
  7506. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
  7507. this.fs = fs$2.createFileSystemAdapter(this._options.fs);
  7508. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$6.sep);
  7509. this.stats = this._getValue(this._options.stats, false);
  7510. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  7511. this.fsStatSettings = new fsStat$3.Settings({
  7512. followSymbolicLink: this.followSymbolicLinks,
  7513. fs: this.fs,
  7514. throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
  7515. });
  7516. }
  7517. _getValue(option, value) {
  7518. return option !== null && option !== void 0 ? option : value;
  7519. }
  7520. }
  7521. settings$2.default = Settings$1;
  7522. Object.defineProperty(out$1, "__esModule", {
  7523. value: true
  7524. });
  7525. out$1.Settings = out$1.scandirSync = out$1.scandir = void 0;
  7526. const async = async$1;
  7527. const sync$4 = sync$5;
  7528. const settings_1$2 = settings$2;
  7529. out$1.Settings = settings_1$2.default;
  7530. function scandir(path, optionsOrSettingsOrCallback, callback) {
  7531. if (typeof optionsOrSettingsOrCallback === 'function') {
  7532. async.read(path, getSettings$1(), optionsOrSettingsOrCallback);
  7533. return;
  7534. }
  7535. async.read(path, getSettings$1(optionsOrSettingsOrCallback), callback);
  7536. }
  7537. out$1.scandir = scandir;
  7538. function scandirSync(path, optionsOrSettings) {
  7539. const settings = getSettings$1(optionsOrSettings);
  7540. return sync$4.read(path, settings);
  7541. }
  7542. out$1.scandirSync = scandirSync;
  7543. function getSettings$1(settingsOrOptions = {}) {
  7544. if (settingsOrOptions instanceof settings_1$2.default) {
  7545. return settingsOrOptions;
  7546. }
  7547. return new settings_1$2.default(settingsOrOptions);
  7548. }
  7549. var queue = {exports: {}};
  7550. function reusify$1(Constructor) {
  7551. var head = new Constructor();
  7552. var tail = head;
  7553. function get() {
  7554. var current = head;
  7555. if (current.next) {
  7556. head = current.next;
  7557. } else {
  7558. head = new Constructor();
  7559. tail = head;
  7560. }
  7561. current.next = null;
  7562. return current;
  7563. }
  7564. function release(obj) {
  7565. tail.next = obj;
  7566. tail = obj;
  7567. }
  7568. return {
  7569. get: get,
  7570. release: release
  7571. };
  7572. }
  7573. var reusify_1 = reusify$1;
  7574. /* eslint-disable no-var */
  7575. var reusify = reusify_1;
  7576. function fastqueue(context, worker, concurrency) {
  7577. if (typeof context === 'function') {
  7578. concurrency = worker;
  7579. worker = context;
  7580. context = null;
  7581. }
  7582. if (concurrency < 1) {
  7583. throw new Error('fastqueue concurrency must be greater than 1');
  7584. }
  7585. var cache = reusify(Task);
  7586. var queueHead = null;
  7587. var queueTail = null;
  7588. var _running = 0;
  7589. var errorHandler = null;
  7590. var self = {
  7591. push: push,
  7592. drain: noop,
  7593. saturated: noop,
  7594. pause: pause,
  7595. paused: false,
  7596. concurrency: concurrency,
  7597. running: running,
  7598. resume: resume,
  7599. idle: idle,
  7600. length: length,
  7601. getQueue: getQueue,
  7602. unshift: unshift,
  7603. empty: noop,
  7604. kill: kill,
  7605. killAndDrain: killAndDrain,
  7606. error: error
  7607. };
  7608. return self;
  7609. function running() {
  7610. return _running;
  7611. }
  7612. function pause() {
  7613. self.paused = true;
  7614. }
  7615. function length() {
  7616. var current = queueHead;
  7617. var counter = 0;
  7618. while (current) {
  7619. current = current.next;
  7620. counter++;
  7621. }
  7622. return counter;
  7623. }
  7624. function getQueue() {
  7625. var current = queueHead;
  7626. var tasks = [];
  7627. while (current) {
  7628. tasks.push(current.value);
  7629. current = current.next;
  7630. }
  7631. return tasks;
  7632. }
  7633. function resume() {
  7634. if (!self.paused) return;
  7635. self.paused = false;
  7636. for (var i = 0; i < self.concurrency; i++) {
  7637. _running++;
  7638. release();
  7639. }
  7640. }
  7641. function idle() {
  7642. return _running === 0 && self.length() === 0;
  7643. }
  7644. function push(value, done) {
  7645. var current = cache.get();
  7646. current.context = context;
  7647. current.release = release;
  7648. current.value = value;
  7649. current.callback = done || noop;
  7650. current.errorHandler = errorHandler;
  7651. if (_running === self.concurrency || self.paused) {
  7652. if (queueTail) {
  7653. queueTail.next = current;
  7654. queueTail = current;
  7655. } else {
  7656. queueHead = current;
  7657. queueTail = current;
  7658. self.saturated();
  7659. }
  7660. } else {
  7661. _running++;
  7662. worker.call(context, current.value, current.worked);
  7663. }
  7664. }
  7665. function unshift(value, done) {
  7666. var current = cache.get();
  7667. current.context = context;
  7668. current.release = release;
  7669. current.value = value;
  7670. current.callback = done || noop;
  7671. if (_running === self.concurrency || self.paused) {
  7672. if (queueHead) {
  7673. current.next = queueHead;
  7674. queueHead = current;
  7675. } else {
  7676. queueHead = current;
  7677. queueTail = current;
  7678. self.saturated();
  7679. }
  7680. } else {
  7681. _running++;
  7682. worker.call(context, current.value, current.worked);
  7683. }
  7684. }
  7685. function release(holder) {
  7686. if (holder) {
  7687. cache.release(holder);
  7688. }
  7689. var next = queueHead;
  7690. if (next) {
  7691. if (!self.paused) {
  7692. if (queueTail === queueHead) {
  7693. queueTail = null;
  7694. }
  7695. queueHead = next.next;
  7696. next.next = null;
  7697. worker.call(context, next.value, next.worked);
  7698. if (queueTail === null) {
  7699. self.empty();
  7700. }
  7701. } else {
  7702. _running--;
  7703. }
  7704. } else if (--_running === 0) {
  7705. self.drain();
  7706. }
  7707. }
  7708. function kill() {
  7709. queueHead = null;
  7710. queueTail = null;
  7711. self.drain = noop;
  7712. }
  7713. function killAndDrain() {
  7714. queueHead = null;
  7715. queueTail = null;
  7716. self.drain();
  7717. self.drain = noop;
  7718. }
  7719. function error(handler) {
  7720. errorHandler = handler;
  7721. }
  7722. }
  7723. function noop() {}
  7724. function Task() {
  7725. this.value = null;
  7726. this.callback = noop;
  7727. this.next = null;
  7728. this.release = noop;
  7729. this.context = null;
  7730. this.errorHandler = null;
  7731. var self = this;
  7732. this.worked = function worked(err, result) {
  7733. var callback = self.callback;
  7734. var errorHandler = self.errorHandler;
  7735. var val = self.value;
  7736. self.value = null;
  7737. self.callback = noop;
  7738. if (self.errorHandler) {
  7739. errorHandler(err, val);
  7740. }
  7741. callback.call(self.context, err, result);
  7742. self.release(self);
  7743. };
  7744. }
  7745. function queueAsPromised(context, worker, concurrency) {
  7746. if (typeof context === 'function') {
  7747. concurrency = worker;
  7748. worker = context;
  7749. context = null;
  7750. }
  7751. function asyncWrapper(arg, cb) {
  7752. worker.call(this, arg).then(function (res) {
  7753. cb(null, res);
  7754. }, cb);
  7755. }
  7756. var queue = fastqueue(context, asyncWrapper, concurrency);
  7757. var pushCb = queue.push;
  7758. var unshiftCb = queue.unshift;
  7759. queue.push = push;
  7760. queue.unshift = unshift;
  7761. queue.drained = drained;
  7762. return queue;
  7763. function push(value) {
  7764. var p = new Promise(function (resolve, reject) {
  7765. pushCb(value, function (err, result) {
  7766. if (err) {
  7767. reject(err);
  7768. return;
  7769. }
  7770. resolve(result);
  7771. });
  7772. }); // Let's fork the promise chain to
  7773. // make the error bubble up to the user but
  7774. // not lead to a unhandledRejection
  7775. p.catch(noop);
  7776. return p;
  7777. }
  7778. function unshift(value) {
  7779. var p = new Promise(function (resolve, reject) {
  7780. unshiftCb(value, function (err, result) {
  7781. if (err) {
  7782. reject(err);
  7783. return;
  7784. }
  7785. resolve(result);
  7786. });
  7787. }); // Let's fork the promise chain to
  7788. // make the error bubble up to the user but
  7789. // not lead to a unhandledRejection
  7790. p.catch(noop);
  7791. return p;
  7792. }
  7793. function drained() {
  7794. var previousDrain = queue.drain;
  7795. var p = new Promise(function (resolve) {
  7796. queue.drain = function () {
  7797. previousDrain();
  7798. resolve();
  7799. };
  7800. });
  7801. return p;
  7802. }
  7803. }
  7804. queue.exports = fastqueue;
  7805. queue.exports.promise = queueAsPromised;
  7806. var common$3 = {};
  7807. Object.defineProperty(common$3, "__esModule", {
  7808. value: true
  7809. });
  7810. common$3.joinPathSegments = common$3.replacePathSegmentSeparator = common$3.isAppliedFilter = common$3.isFatalError = void 0;
  7811. function isFatalError(settings, error) {
  7812. if (settings.errorFilter === null) {
  7813. return true;
  7814. }
  7815. return !settings.errorFilter(error);
  7816. }
  7817. common$3.isFatalError = isFatalError;
  7818. function isAppliedFilter(filter, value) {
  7819. return filter === null || filter(value);
  7820. }
  7821. common$3.isAppliedFilter = isAppliedFilter;
  7822. function replacePathSegmentSeparator(filepath, separator) {
  7823. return filepath.split(/[/\\]/).join(separator);
  7824. }
  7825. common$3.replacePathSegmentSeparator = replacePathSegmentSeparator;
  7826. function joinPathSegments(a, b, separator) {
  7827. if (a === '') {
  7828. return b;
  7829. }
  7830. /**
  7831. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  7832. */
  7833. if (a.endsWith(separator)) {
  7834. return a + b;
  7835. }
  7836. return a + separator + b;
  7837. }
  7838. common$3.joinPathSegments = joinPathSegments;
  7839. var reader$1 = {};
  7840. Object.defineProperty(reader$1, "__esModule", {
  7841. value: true
  7842. });
  7843. const common$2 = common$3;
  7844. class Reader$1 {
  7845. constructor(_root, _settings) {
  7846. this._root = _root;
  7847. this._settings = _settings;
  7848. this._root = common$2.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
  7849. }
  7850. }
  7851. reader$1.default = Reader$1;
  7852. Object.defineProperty(async$2, "__esModule", {
  7853. value: true
  7854. });
  7855. const events_1 = require$$0__default$5["default"];
  7856. const fsScandir$2 = out$1;
  7857. const fastq = queue.exports;
  7858. const common$1 = common$3;
  7859. const reader_1$3 = reader$1;
  7860. class AsyncReader extends reader_1$3.default {
  7861. constructor(_root, _settings) {
  7862. super(_root, _settings);
  7863. this._settings = _settings;
  7864. this._scandir = fsScandir$2.scandir;
  7865. this._emitter = new events_1.EventEmitter();
  7866. this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
  7867. this._isFatalError = false;
  7868. this._isDestroyed = false;
  7869. this._queue.drain = () => {
  7870. if (!this._isFatalError) {
  7871. this._emitter.emit('end');
  7872. }
  7873. };
  7874. }
  7875. read() {
  7876. this._isFatalError = false;
  7877. this._isDestroyed = false;
  7878. setImmediate(() => {
  7879. this._pushToQueue(this._root, this._settings.basePath);
  7880. });
  7881. return this._emitter;
  7882. }
  7883. get isDestroyed() {
  7884. return this._isDestroyed;
  7885. }
  7886. destroy() {
  7887. if (this._isDestroyed) {
  7888. throw new Error('The reader is already destroyed');
  7889. }
  7890. this._isDestroyed = true;
  7891. this._queue.killAndDrain();
  7892. }
  7893. onEntry(callback) {
  7894. this._emitter.on('entry', callback);
  7895. }
  7896. onError(callback) {
  7897. this._emitter.once('error', callback);
  7898. }
  7899. onEnd(callback) {
  7900. this._emitter.once('end', callback);
  7901. }
  7902. _pushToQueue(directory, base) {
  7903. const queueItem = {
  7904. directory,
  7905. base
  7906. };
  7907. this._queue.push(queueItem, error => {
  7908. if (error !== null) {
  7909. this._handleError(error);
  7910. }
  7911. });
  7912. }
  7913. _worker(item, done) {
  7914. this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
  7915. if (error !== null) {
  7916. done(error, undefined);
  7917. return;
  7918. }
  7919. for (const entry of entries) {
  7920. this._handleEntry(entry, item.base);
  7921. }
  7922. done(null, undefined);
  7923. });
  7924. }
  7925. _handleError(error) {
  7926. if (this._isDestroyed || !common$1.isFatalError(this._settings, error)) {
  7927. return;
  7928. }
  7929. this._isFatalError = true;
  7930. this._isDestroyed = true;
  7931. this._emitter.emit('error', error);
  7932. }
  7933. _handleEntry(entry, base) {
  7934. if (this._isDestroyed || this._isFatalError) {
  7935. return;
  7936. }
  7937. const fullpath = entry.path;
  7938. if (base !== undefined) {
  7939. entry.path = common$1.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  7940. }
  7941. if (common$1.isAppliedFilter(this._settings.entryFilter, entry)) {
  7942. this._emitEntry(entry);
  7943. }
  7944. if (entry.dirent.isDirectory() && common$1.isAppliedFilter(this._settings.deepFilter, entry)) {
  7945. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  7946. }
  7947. }
  7948. _emitEntry(entry) {
  7949. this._emitter.emit('entry', entry);
  7950. }
  7951. }
  7952. async$2.default = AsyncReader;
  7953. Object.defineProperty(async$3, "__esModule", {
  7954. value: true
  7955. });
  7956. const async_1$3 = async$2;
  7957. class AsyncProvider {
  7958. constructor(_root, _settings) {
  7959. this._root = _root;
  7960. this._settings = _settings;
  7961. this._reader = new async_1$3.default(this._root, this._settings);
  7962. this._storage = [];
  7963. }
  7964. read(callback) {
  7965. this._reader.onError(error => {
  7966. callFailureCallback(callback, error);
  7967. });
  7968. this._reader.onEntry(entry => {
  7969. this._storage.push(entry);
  7970. });
  7971. this._reader.onEnd(() => {
  7972. callSuccessCallback(callback, this._storage);
  7973. });
  7974. this._reader.read();
  7975. }
  7976. }
  7977. async$3.default = AsyncProvider;
  7978. function callFailureCallback(callback, error) {
  7979. callback(error);
  7980. }
  7981. function callSuccessCallback(callback, entries) {
  7982. callback(null, entries);
  7983. }
  7984. var stream$1 = {};
  7985. Object.defineProperty(stream$1, "__esModule", {
  7986. value: true
  7987. });
  7988. const stream_1$5 = require$$0__default$3["default"];
  7989. const async_1$2 = async$2;
  7990. class StreamProvider {
  7991. constructor(_root, _settings) {
  7992. this._root = _root;
  7993. this._settings = _settings;
  7994. this._reader = new async_1$2.default(this._root, this._settings);
  7995. this._stream = new stream_1$5.Readable({
  7996. objectMode: true,
  7997. read: () => {},
  7998. destroy: () => {
  7999. if (!this._reader.isDestroyed) {
  8000. this._reader.destroy();
  8001. }
  8002. }
  8003. });
  8004. }
  8005. read() {
  8006. this._reader.onError(error => {
  8007. this._stream.emit('error', error);
  8008. });
  8009. this._reader.onEntry(entry => {
  8010. this._stream.push(entry);
  8011. });
  8012. this._reader.onEnd(() => {
  8013. this._stream.push(null);
  8014. });
  8015. this._reader.read();
  8016. return this._stream;
  8017. }
  8018. }
  8019. stream$1.default = StreamProvider;
  8020. var sync$3 = {};
  8021. var sync$2 = {};
  8022. Object.defineProperty(sync$2, "__esModule", {
  8023. value: true
  8024. });
  8025. const fsScandir$1 = out$1;
  8026. const common = common$3;
  8027. const reader_1$2 = reader$1;
  8028. class SyncReader extends reader_1$2.default {
  8029. constructor() {
  8030. super(...arguments);
  8031. this._scandir = fsScandir$1.scandirSync;
  8032. this._storage = [];
  8033. this._queue = new Set();
  8034. }
  8035. read() {
  8036. this._pushToQueue(this._root, this._settings.basePath);
  8037. this._handleQueue();
  8038. return this._storage;
  8039. }
  8040. _pushToQueue(directory, base) {
  8041. this._queue.add({
  8042. directory,
  8043. base
  8044. });
  8045. }
  8046. _handleQueue() {
  8047. for (const item of this._queue.values()) {
  8048. this._handleDirectory(item.directory, item.base);
  8049. }
  8050. }
  8051. _handleDirectory(directory, base) {
  8052. try {
  8053. const entries = this._scandir(directory, this._settings.fsScandirSettings);
  8054. for (const entry of entries) {
  8055. this._handleEntry(entry, base);
  8056. }
  8057. } catch (error) {
  8058. this._handleError(error);
  8059. }
  8060. }
  8061. _handleError(error) {
  8062. if (!common.isFatalError(this._settings, error)) {
  8063. return;
  8064. }
  8065. throw error;
  8066. }
  8067. _handleEntry(entry, base) {
  8068. const fullpath = entry.path;
  8069. if (base !== undefined) {
  8070. entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  8071. }
  8072. if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
  8073. this._pushToStorage(entry);
  8074. }
  8075. if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
  8076. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  8077. }
  8078. }
  8079. _pushToStorage(entry) {
  8080. this._storage.push(entry);
  8081. }
  8082. }
  8083. sync$2.default = SyncReader;
  8084. Object.defineProperty(sync$3, "__esModule", {
  8085. value: true
  8086. });
  8087. const sync_1$3 = sync$2;
  8088. class SyncProvider {
  8089. constructor(_root, _settings) {
  8090. this._root = _root;
  8091. this._settings = _settings;
  8092. this._reader = new sync_1$3.default(this._root, this._settings);
  8093. }
  8094. read() {
  8095. return this._reader.read();
  8096. }
  8097. }
  8098. sync$3.default = SyncProvider;
  8099. var settings$1 = {};
  8100. Object.defineProperty(settings$1, "__esModule", {
  8101. value: true
  8102. });
  8103. const path$5 = require$$0__default$1["default"];
  8104. const fsScandir = out$1;
  8105. class Settings {
  8106. constructor(_options = {}) {
  8107. this._options = _options;
  8108. this.basePath = this._getValue(this._options.basePath, undefined);
  8109. this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
  8110. this.deepFilter = this._getValue(this._options.deepFilter, null);
  8111. this.entryFilter = this._getValue(this._options.entryFilter, null);
  8112. this.errorFilter = this._getValue(this._options.errorFilter, null);
  8113. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$5.sep);
  8114. this.fsScandirSettings = new fsScandir.Settings({
  8115. followSymbolicLinks: this._options.followSymbolicLinks,
  8116. fs: this._options.fs,
  8117. pathSegmentSeparator: this._options.pathSegmentSeparator,
  8118. stats: this._options.stats,
  8119. throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
  8120. });
  8121. }
  8122. _getValue(option, value) {
  8123. return option !== null && option !== void 0 ? option : value;
  8124. }
  8125. }
  8126. settings$1.default = Settings;
  8127. Object.defineProperty(out$2, "__esModule", {
  8128. value: true
  8129. });
  8130. out$2.Settings = out$2.walkStream = out$2.walkSync = out$2.walk = void 0;
  8131. const async_1$1 = async$3;
  8132. const stream_1$4 = stream$1;
  8133. const sync_1$2 = sync$3;
  8134. const settings_1$1 = settings$1;
  8135. out$2.Settings = settings_1$1.default;
  8136. function walk(directory, optionsOrSettingsOrCallback, callback) {
  8137. if (typeof optionsOrSettingsOrCallback === 'function') {
  8138. new async_1$1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
  8139. return;
  8140. }
  8141. new async_1$1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
  8142. }
  8143. out$2.walk = walk;
  8144. function walkSync(directory, optionsOrSettings) {
  8145. const settings = getSettings(optionsOrSettings);
  8146. const provider = new sync_1$2.default(directory, settings);
  8147. return provider.read();
  8148. }
  8149. out$2.walkSync = walkSync;
  8150. function walkStream(directory, optionsOrSettings) {
  8151. const settings = getSettings(optionsOrSettings);
  8152. const provider = new stream_1$4.default(directory, settings);
  8153. return provider.read();
  8154. }
  8155. out$2.walkStream = walkStream;
  8156. function getSettings(settingsOrOptions = {}) {
  8157. if (settingsOrOptions instanceof settings_1$1.default) {
  8158. return settingsOrOptions;
  8159. }
  8160. return new settings_1$1.default(settingsOrOptions);
  8161. }
  8162. var reader = {};
  8163. Object.defineProperty(reader, "__esModule", {
  8164. value: true
  8165. });
  8166. const path$4 = require$$0__default$1["default"];
  8167. const fsStat$2 = out$3;
  8168. const utils$6 = utils$k;
  8169. class Reader {
  8170. constructor(_settings) {
  8171. this._settings = _settings;
  8172. this._fsStatSettings = new fsStat$2.Settings({
  8173. followSymbolicLink: this._settings.followSymbolicLinks,
  8174. fs: this._settings.fs,
  8175. throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
  8176. });
  8177. }
  8178. _getFullEntryPath(filepath) {
  8179. return path$4.resolve(this._settings.cwd, filepath);
  8180. }
  8181. _makeEntry(stats, pattern) {
  8182. const entry = {
  8183. name: pattern,
  8184. path: pattern,
  8185. dirent: utils$6.fs.createDirentFromStats(pattern, stats)
  8186. };
  8187. if (this._settings.stats) {
  8188. entry.stats = stats;
  8189. }
  8190. return entry;
  8191. }
  8192. _isFatalError(error) {
  8193. return !utils$6.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
  8194. }
  8195. }
  8196. reader.default = Reader;
  8197. Object.defineProperty(stream$2, "__esModule", {
  8198. value: true
  8199. });
  8200. const stream_1$3 = require$$0__default$3["default"];
  8201. const fsStat$1 = out$3;
  8202. const fsWalk$1 = out$2;
  8203. const reader_1$1 = reader;
  8204. class ReaderStream extends reader_1$1.default {
  8205. constructor() {
  8206. super(...arguments);
  8207. this._walkStream = fsWalk$1.walkStream;
  8208. this._stat = fsStat$1.stat;
  8209. }
  8210. dynamic(root, options) {
  8211. return this._walkStream(root, options);
  8212. }
  8213. static(patterns, options) {
  8214. const filepaths = patterns.map(this._getFullEntryPath, this);
  8215. const stream = new stream_1$3.PassThrough({
  8216. objectMode: true
  8217. });
  8218. stream._write = (index, _enc, done) => {
  8219. return this._getEntry(filepaths[index], patterns[index], options).then(entry => {
  8220. if (entry !== null && options.entryFilter(entry)) {
  8221. stream.push(entry);
  8222. }
  8223. if (index === filepaths.length - 1) {
  8224. stream.end();
  8225. }
  8226. done();
  8227. }).catch(done);
  8228. };
  8229. for (let i = 0; i < filepaths.length; i++) {
  8230. stream.write(i);
  8231. }
  8232. return stream;
  8233. }
  8234. _getEntry(filepath, pattern, options) {
  8235. return this._getStat(filepath).then(stats => this._makeEntry(stats, pattern)).catch(error => {
  8236. if (options.errorFilter(error)) {
  8237. return null;
  8238. }
  8239. throw error;
  8240. });
  8241. }
  8242. _getStat(filepath) {
  8243. return new Promise((resolve, reject) => {
  8244. this._stat(filepath, this._fsStatSettings, (error, stats) => {
  8245. return error === null ? resolve(stats) : reject(error);
  8246. });
  8247. });
  8248. }
  8249. }
  8250. stream$2.default = ReaderStream;
  8251. var provider = {};
  8252. var deep = {};
  8253. var partial = {};
  8254. var matcher = {};
  8255. Object.defineProperty(matcher, "__esModule", {
  8256. value: true
  8257. });
  8258. const utils$5 = utils$k;
  8259. class Matcher {
  8260. constructor(_patterns, _settings, _micromatchOptions) {
  8261. this._patterns = _patterns;
  8262. this._settings = _settings;
  8263. this._micromatchOptions = _micromatchOptions;
  8264. this._storage = [];
  8265. this._fillStorage();
  8266. }
  8267. _fillStorage() {
  8268. /**
  8269. * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
  8270. * So, before expand patterns with brace expansion into separated patterns.
  8271. */
  8272. const patterns = utils$5.pattern.expandPatternsWithBraceExpansion(this._patterns);
  8273. for (const pattern of patterns) {
  8274. const segments = this._getPatternSegments(pattern);
  8275. const sections = this._splitSegmentsIntoSections(segments);
  8276. this._storage.push({
  8277. complete: sections.length <= 1,
  8278. pattern,
  8279. segments,
  8280. sections
  8281. });
  8282. }
  8283. }
  8284. _getPatternSegments(pattern) {
  8285. const parts = utils$5.pattern.getPatternParts(pattern, this._micromatchOptions);
  8286. return parts.map(part => {
  8287. const dynamic = utils$5.pattern.isDynamicPattern(part, this._settings);
  8288. if (!dynamic) {
  8289. return {
  8290. dynamic: false,
  8291. pattern: part
  8292. };
  8293. }
  8294. return {
  8295. dynamic: true,
  8296. pattern: part,
  8297. patternRe: utils$5.pattern.makeRe(part, this._micromatchOptions)
  8298. };
  8299. });
  8300. }
  8301. _splitSegmentsIntoSections(segments) {
  8302. return utils$5.array.splitWhen(segments, segment => segment.dynamic && utils$5.pattern.hasGlobStar(segment.pattern));
  8303. }
  8304. }
  8305. matcher.default = Matcher;
  8306. Object.defineProperty(partial, "__esModule", {
  8307. value: true
  8308. });
  8309. const matcher_1 = matcher;
  8310. class PartialMatcher extends matcher_1.default {
  8311. match(filepath) {
  8312. const parts = filepath.split('/');
  8313. const levels = parts.length;
  8314. const patterns = this._storage.filter(info => !info.complete || info.segments.length > levels);
  8315. for (const pattern of patterns) {
  8316. const section = pattern.sections[0];
  8317. /**
  8318. * In this case, the pattern has a globstar and we must read all directories unconditionally,
  8319. * but only if the level has reached the end of the first group.
  8320. *
  8321. * fixtures/{a,b}/**
  8322. * ^ true/false ^ always true
  8323. */
  8324. if (!pattern.complete && levels > section.length) {
  8325. return true;
  8326. }
  8327. const match = parts.every((part, index) => {
  8328. const segment = pattern.segments[index];
  8329. if (segment.dynamic && segment.patternRe.test(part)) {
  8330. return true;
  8331. }
  8332. if (!segment.dynamic && segment.pattern === part) {
  8333. return true;
  8334. }
  8335. return false;
  8336. });
  8337. if (match) {
  8338. return true;
  8339. }
  8340. }
  8341. return false;
  8342. }
  8343. }
  8344. partial.default = PartialMatcher;
  8345. Object.defineProperty(deep, "__esModule", {
  8346. value: true
  8347. });
  8348. const utils$4 = utils$k;
  8349. const partial_1 = partial;
  8350. class DeepFilter {
  8351. constructor(_settings, _micromatchOptions) {
  8352. this._settings = _settings;
  8353. this._micromatchOptions = _micromatchOptions;
  8354. }
  8355. getFilter(basePath, positive, negative) {
  8356. const matcher = this._getMatcher(positive);
  8357. const negativeRe = this._getNegativePatternsRe(negative);
  8358. return entry => this._filter(basePath, entry, matcher, negativeRe);
  8359. }
  8360. _getMatcher(patterns) {
  8361. return new partial_1.default(patterns, this._settings, this._micromatchOptions);
  8362. }
  8363. _getNegativePatternsRe(patterns) {
  8364. const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
  8365. return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
  8366. }
  8367. _filter(basePath, entry, matcher, negativeRe) {
  8368. if (this._isSkippedByDeep(basePath, entry.path)) {
  8369. return false;
  8370. }
  8371. if (this._isSkippedSymbolicLink(entry)) {
  8372. return false;
  8373. }
  8374. const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
  8375. if (this._isSkippedByPositivePatterns(filepath, matcher)) {
  8376. return false;
  8377. }
  8378. return this._isSkippedByNegativePatterns(filepath, negativeRe);
  8379. }
  8380. _isSkippedByDeep(basePath, entryPath) {
  8381. /**
  8382. * Avoid unnecessary depth calculations when it doesn't matter.
  8383. */
  8384. if (this._settings.deep === Infinity) {
  8385. return false;
  8386. }
  8387. return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
  8388. }
  8389. _getEntryLevel(basePath, entryPath) {
  8390. const entryPathDepth = entryPath.split('/').length;
  8391. if (basePath === '') {
  8392. return entryPathDepth;
  8393. }
  8394. const basePathDepth = basePath.split('/').length;
  8395. return entryPathDepth - basePathDepth;
  8396. }
  8397. _isSkippedSymbolicLink(entry) {
  8398. return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
  8399. }
  8400. _isSkippedByPositivePatterns(entryPath, matcher) {
  8401. return !this._settings.baseNameMatch && !matcher.match(entryPath);
  8402. }
  8403. _isSkippedByNegativePatterns(entryPath, patternsRe) {
  8404. return !utils$4.pattern.matchAny(entryPath, patternsRe);
  8405. }
  8406. }
  8407. deep.default = DeepFilter;
  8408. var entry$1 = {};
  8409. Object.defineProperty(entry$1, "__esModule", {
  8410. value: true
  8411. });
  8412. const utils$3 = utils$k;
  8413. class EntryFilter {
  8414. constructor(_settings, _micromatchOptions) {
  8415. this._settings = _settings;
  8416. this._micromatchOptions = _micromatchOptions;
  8417. this.index = new Map();
  8418. }
  8419. getFilter(positive, negative) {
  8420. const positiveRe = utils$3.pattern.convertPatternsToRe(positive, this._micromatchOptions);
  8421. const negativeRe = utils$3.pattern.convertPatternsToRe(negative, this._micromatchOptions);
  8422. return entry => this._filter(entry, positiveRe, negativeRe);
  8423. }
  8424. _filter(entry, positiveRe, negativeRe) {
  8425. if (this._settings.unique && this._isDuplicateEntry(entry)) {
  8426. return false;
  8427. }
  8428. if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
  8429. return false;
  8430. }
  8431. if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
  8432. return false;
  8433. }
  8434. const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
  8435. const isMatched = this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe);
  8436. if (this._settings.unique && isMatched) {
  8437. this._createIndexRecord(entry);
  8438. }
  8439. return isMatched;
  8440. }
  8441. _isDuplicateEntry(entry) {
  8442. return this.index.has(entry.path);
  8443. }
  8444. _createIndexRecord(entry) {
  8445. this.index.set(entry.path, undefined);
  8446. }
  8447. _onlyFileFilter(entry) {
  8448. return this._settings.onlyFiles && !entry.dirent.isFile();
  8449. }
  8450. _onlyDirectoryFilter(entry) {
  8451. return this._settings.onlyDirectories && !entry.dirent.isDirectory();
  8452. }
  8453. _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
  8454. if (!this._settings.absolute) {
  8455. return false;
  8456. }
  8457. const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
  8458. return utils$3.pattern.matchAny(fullpath, patternsRe);
  8459. }
  8460. _isMatchToPatterns(entryPath, patternsRe) {
  8461. const filepath = utils$3.path.removeLeadingDotSegment(entryPath);
  8462. return utils$3.pattern.matchAny(filepath, patternsRe);
  8463. }
  8464. }
  8465. entry$1.default = EntryFilter;
  8466. var error = {};
  8467. Object.defineProperty(error, "__esModule", {
  8468. value: true
  8469. });
  8470. const utils$2 = utils$k;
  8471. class ErrorFilter {
  8472. constructor(_settings) {
  8473. this._settings = _settings;
  8474. }
  8475. getFilter() {
  8476. return error => this._isNonFatalError(error);
  8477. }
  8478. _isNonFatalError(error) {
  8479. return utils$2.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
  8480. }
  8481. }
  8482. error.default = ErrorFilter;
  8483. var entry = {};
  8484. Object.defineProperty(entry, "__esModule", {
  8485. value: true
  8486. });
  8487. const utils$1 = utils$k;
  8488. class EntryTransformer {
  8489. constructor(_settings) {
  8490. this._settings = _settings;
  8491. }
  8492. getTransformer() {
  8493. return entry => this._transform(entry);
  8494. }
  8495. _transform(entry) {
  8496. let filepath = entry.path;
  8497. if (this._settings.absolute) {
  8498. filepath = utils$1.path.makeAbsolute(this._settings.cwd, filepath);
  8499. filepath = utils$1.path.unixify(filepath);
  8500. }
  8501. if (this._settings.markDirectories && entry.dirent.isDirectory()) {
  8502. filepath += '/';
  8503. }
  8504. if (!this._settings.objectMode) {
  8505. return filepath;
  8506. }
  8507. return Object.assign(Object.assign({}, entry), {
  8508. path: filepath
  8509. });
  8510. }
  8511. }
  8512. entry.default = EntryTransformer;
  8513. Object.defineProperty(provider, "__esModule", {
  8514. value: true
  8515. });
  8516. const path$3 = require$$0__default$1["default"];
  8517. const deep_1 = deep;
  8518. const entry_1 = entry$1;
  8519. const error_1 = error;
  8520. const entry_2 = entry;
  8521. class Provider {
  8522. constructor(_settings) {
  8523. this._settings = _settings;
  8524. this.errorFilter = new error_1.default(this._settings);
  8525. this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
  8526. this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
  8527. this.entryTransformer = new entry_2.default(this._settings);
  8528. }
  8529. _getRootDirectory(task) {
  8530. return path$3.resolve(this._settings.cwd, task.base);
  8531. }
  8532. _getReaderOptions(task) {
  8533. const basePath = task.base === '.' ? '' : task.base;
  8534. return {
  8535. basePath,
  8536. pathSegmentSeparator: '/',
  8537. concurrency: this._settings.concurrency,
  8538. deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
  8539. entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
  8540. errorFilter: this.errorFilter.getFilter(),
  8541. followSymbolicLinks: this._settings.followSymbolicLinks,
  8542. fs: this._settings.fs,
  8543. stats: this._settings.stats,
  8544. throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
  8545. transform: this.entryTransformer.getTransformer()
  8546. };
  8547. }
  8548. _getMicromatchOptions() {
  8549. return {
  8550. dot: this._settings.dot,
  8551. matchBase: this._settings.baseNameMatch,
  8552. nobrace: !this._settings.braceExpansion,
  8553. nocase: !this._settings.caseSensitiveMatch,
  8554. noext: !this._settings.extglob,
  8555. noglobstar: !this._settings.globstar,
  8556. posix: true,
  8557. strictSlashes: false
  8558. };
  8559. }
  8560. }
  8561. provider.default = Provider;
  8562. Object.defineProperty(async$6, "__esModule", {
  8563. value: true
  8564. });
  8565. const stream_1$2 = stream$2;
  8566. const provider_1$2 = provider;
  8567. class ProviderAsync extends provider_1$2.default {
  8568. constructor() {
  8569. super(...arguments);
  8570. this._reader = new stream_1$2.default(this._settings);
  8571. }
  8572. read(task) {
  8573. const root = this._getRootDirectory(task);
  8574. const options = this._getReaderOptions(task);
  8575. const entries = [];
  8576. return new Promise((resolve, reject) => {
  8577. const stream = this.api(root, task, options);
  8578. stream.once('error', reject);
  8579. stream.on('data', entry => entries.push(options.transform(entry)));
  8580. stream.once('end', () => resolve(entries));
  8581. });
  8582. }
  8583. api(root, task, options) {
  8584. if (task.dynamic) {
  8585. return this._reader.dynamic(root, options);
  8586. }
  8587. return this._reader.static(task.patterns, options);
  8588. }
  8589. }
  8590. async$6.default = ProviderAsync;
  8591. var stream = {};
  8592. Object.defineProperty(stream, "__esModule", {
  8593. value: true
  8594. });
  8595. const stream_1$1 = require$$0__default$3["default"];
  8596. const stream_2 = stream$2;
  8597. const provider_1$1 = provider;
  8598. class ProviderStream extends provider_1$1.default {
  8599. constructor() {
  8600. super(...arguments);
  8601. this._reader = new stream_2.default(this._settings);
  8602. }
  8603. read(task) {
  8604. const root = this._getRootDirectory(task);
  8605. const options = this._getReaderOptions(task);
  8606. const source = this.api(root, task, options);
  8607. const destination = new stream_1$1.Readable({
  8608. objectMode: true,
  8609. read: () => {}
  8610. });
  8611. source.once('error', error => destination.emit('error', error)).on('data', entry => destination.emit('data', options.transform(entry))).once('end', () => destination.emit('end'));
  8612. destination.once('close', () => source.destroy());
  8613. return destination;
  8614. }
  8615. api(root, task, options) {
  8616. if (task.dynamic) {
  8617. return this._reader.dynamic(root, options);
  8618. }
  8619. return this._reader.static(task.patterns, options);
  8620. }
  8621. }
  8622. stream.default = ProviderStream;
  8623. var sync$1 = {};
  8624. var sync = {};
  8625. Object.defineProperty(sync, "__esModule", {
  8626. value: true
  8627. });
  8628. const fsStat = out$3;
  8629. const fsWalk = out$2;
  8630. const reader_1 = reader;
  8631. class ReaderSync extends reader_1.default {
  8632. constructor() {
  8633. super(...arguments);
  8634. this._walkSync = fsWalk.walkSync;
  8635. this._statSync = fsStat.statSync;
  8636. }
  8637. dynamic(root, options) {
  8638. return this._walkSync(root, options);
  8639. }
  8640. static(patterns, options) {
  8641. const entries = [];
  8642. for (const pattern of patterns) {
  8643. const filepath = this._getFullEntryPath(pattern);
  8644. const entry = this._getEntry(filepath, pattern, options);
  8645. if (entry === null || !options.entryFilter(entry)) {
  8646. continue;
  8647. }
  8648. entries.push(entry);
  8649. }
  8650. return entries;
  8651. }
  8652. _getEntry(filepath, pattern, options) {
  8653. try {
  8654. const stats = this._getStat(filepath);
  8655. return this._makeEntry(stats, pattern);
  8656. } catch (error) {
  8657. if (options.errorFilter(error)) {
  8658. return null;
  8659. }
  8660. throw error;
  8661. }
  8662. }
  8663. _getStat(filepath) {
  8664. return this._statSync(filepath, this._fsStatSettings);
  8665. }
  8666. }
  8667. sync.default = ReaderSync;
  8668. Object.defineProperty(sync$1, "__esModule", {
  8669. value: true
  8670. });
  8671. const sync_1$1 = sync;
  8672. const provider_1 = provider;
  8673. class ProviderSync extends provider_1.default {
  8674. constructor() {
  8675. super(...arguments);
  8676. this._reader = new sync_1$1.default(this._settings);
  8677. }
  8678. read(task) {
  8679. const root = this._getRootDirectory(task);
  8680. const options = this._getReaderOptions(task);
  8681. const entries = this.api(root, task, options);
  8682. return entries.map(options.transform);
  8683. }
  8684. api(root, task, options) {
  8685. if (task.dynamic) {
  8686. return this._reader.dynamic(root, options);
  8687. }
  8688. return this._reader.static(task.patterns, options);
  8689. }
  8690. }
  8691. sync$1.default = ProviderSync;
  8692. var settings = {};
  8693. (function (exports) {
  8694. Object.defineProperty(exports, "__esModule", {
  8695. value: true
  8696. });
  8697. exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
  8698. const fs = require$$0__default$4["default"];
  8699. const os = require$$0__default["default"];
  8700. /**
  8701. * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
  8702. * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
  8703. */
  8704. const CPU_COUNT = Math.max(os.cpus().length, 1);
  8705. exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
  8706. lstat: fs.lstat,
  8707. lstatSync: fs.lstatSync,
  8708. stat: fs.stat,
  8709. statSync: fs.statSync,
  8710. readdir: fs.readdir,
  8711. readdirSync: fs.readdirSync
  8712. };
  8713. class Settings {
  8714. constructor(_options = {}) {
  8715. this._options = _options;
  8716. this.absolute = this._getValue(this._options.absolute, false);
  8717. this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
  8718. this.braceExpansion = this._getValue(this._options.braceExpansion, true);
  8719. this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
  8720. this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
  8721. this.cwd = this._getValue(this._options.cwd, process.cwd());
  8722. this.deep = this._getValue(this._options.deep, Infinity);
  8723. this.dot = this._getValue(this._options.dot, false);
  8724. this.extglob = this._getValue(this._options.extglob, true);
  8725. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
  8726. this.fs = this._getFileSystemMethods(this._options.fs);
  8727. this.globstar = this._getValue(this._options.globstar, true);
  8728. this.ignore = this._getValue(this._options.ignore, []);
  8729. this.markDirectories = this._getValue(this._options.markDirectories, false);
  8730. this.objectMode = this._getValue(this._options.objectMode, false);
  8731. this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
  8732. this.onlyFiles = this._getValue(this._options.onlyFiles, true);
  8733. this.stats = this._getValue(this._options.stats, false);
  8734. this.suppressErrors = this._getValue(this._options.suppressErrors, false);
  8735. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
  8736. this.unique = this._getValue(this._options.unique, true);
  8737. if (this.onlyDirectories) {
  8738. this.onlyFiles = false;
  8739. }
  8740. if (this.stats) {
  8741. this.objectMode = true;
  8742. }
  8743. }
  8744. _getValue(option, value) {
  8745. return option === undefined ? value : option;
  8746. }
  8747. _getFileSystemMethods(methods = {}) {
  8748. return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
  8749. }
  8750. }
  8751. exports.default = Settings;
  8752. })(settings);
  8753. const taskManager = tasks;
  8754. const async_1 = async$6;
  8755. const stream_1 = stream;
  8756. const sync_1 = sync$1;
  8757. const settings_1 = settings;
  8758. const utils = utils$k;
  8759. async function FastGlob(source, options) {
  8760. assertPatternsInput(source);
  8761. const works = getWorks(source, async_1.default, options);
  8762. const result = await Promise.all(works);
  8763. return utils.array.flatten(result);
  8764. } // https://github.com/typescript-eslint/typescript-eslint/issues/60
  8765. // eslint-disable-next-line no-redeclare
  8766. (function (FastGlob) {
  8767. function sync(source, options) {
  8768. assertPatternsInput(source);
  8769. const works = getWorks(source, sync_1.default, options);
  8770. return utils.array.flatten(works);
  8771. }
  8772. FastGlob.sync = sync;
  8773. function stream(source, options) {
  8774. assertPatternsInput(source);
  8775. const works = getWorks(source, stream_1.default, options);
  8776. /**
  8777. * The stream returned by the provider cannot work with an asynchronous iterator.
  8778. * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
  8779. * This affects performance (+25%). I don't see best solution right now.
  8780. */
  8781. return utils.stream.merge(works);
  8782. }
  8783. FastGlob.stream = stream;
  8784. function generateTasks(source, options) {
  8785. assertPatternsInput(source);
  8786. const patterns = [].concat(source);
  8787. const settings = new settings_1.default(options);
  8788. return taskManager.generate(patterns, settings);
  8789. }
  8790. FastGlob.generateTasks = generateTasks;
  8791. function isDynamicPattern(source, options) {
  8792. assertPatternsInput(source);
  8793. const settings = new settings_1.default(options);
  8794. return utils.pattern.isDynamicPattern(source, settings);
  8795. }
  8796. FastGlob.isDynamicPattern = isDynamicPattern;
  8797. function escapePath(source) {
  8798. assertPatternsInput(source);
  8799. return utils.path.escape(source);
  8800. }
  8801. FastGlob.escapePath = escapePath;
  8802. })(FastGlob || (FastGlob = {}));
  8803. function getWorks(source, _Provider, options) {
  8804. const patterns = [].concat(source);
  8805. const settings = new settings_1.default(options);
  8806. const tasks = taskManager.generate(patterns, settings);
  8807. const provider = new _Provider(settings);
  8808. return tasks.map(provider.read, provider);
  8809. }
  8810. function assertPatternsInput(input) {
  8811. const source = [].concat(input);
  8812. const isValidSource = source.every(item => utils.string.isString(item) && !utils.string.isEmpty(item));
  8813. if (!isValidSource) {
  8814. throw new TypeError('Patterns must be a string (non empty) or an array of strings');
  8815. }
  8816. }
  8817. var out = FastGlob;
  8818. const path$2 = require$$0__default$1["default"];
  8819. const {
  8820. promises: fs$1
  8821. } = require$$0__default$4["default"];
  8822. const fastGlob = out;
  8823. /** @typedef {import('./context').Context} Context */
  8824. /**
  8825. * @param {Context} context
  8826. */
  8827. async function* expandPatterns$1(context) {
  8828. const cwd = process.cwd();
  8829. const seen = new Set();
  8830. let noResults = true;
  8831. for await (const pathOrError of expandPatternsInternal(context)) {
  8832. noResults = false;
  8833. if (typeof pathOrError !== "string") {
  8834. yield pathOrError;
  8835. continue;
  8836. }
  8837. const relativePath = path$2.relative(cwd, pathOrError); // filter out duplicates
  8838. if (seen.has(relativePath)) {
  8839. continue;
  8840. }
  8841. seen.add(relativePath);
  8842. yield relativePath;
  8843. }
  8844. if (noResults && context.argv["error-on-unmatched-pattern"] !== false) {
  8845. // If there was no files and no other errors, let's yield a general error.
  8846. yield {
  8847. error: `No matching files. Patterns: ${context.filePatterns.join(" ")}`
  8848. };
  8849. }
  8850. }
  8851. /**
  8852. * @param {Context} context
  8853. */
  8854. async function* expandPatternsInternal(context) {
  8855. // Ignores files in version control systems directories and `node_modules`
  8856. const silentlyIgnoredDirs = [".git", ".svn", ".hg"];
  8857. if (context.argv["with-node-modules"] !== true) {
  8858. silentlyIgnoredDirs.push("node_modules");
  8859. }
  8860. const globOptions = {
  8861. dot: true,
  8862. ignore: silentlyIgnoredDirs.map(dir => "**/" + dir)
  8863. };
  8864. let supportedFilesGlob;
  8865. const cwd = process.cwd();
  8866. /** @type {Array<{ type: 'file' | 'dir' | 'glob'; glob: string; input: string; }>} */
  8867. const entries = [];
  8868. for (const pattern of context.filePatterns) {
  8869. const absolutePath = path$2.resolve(cwd, pattern);
  8870. if (containsIgnoredPathSegment(absolutePath, cwd, silentlyIgnoredDirs)) {
  8871. continue;
  8872. }
  8873. const stat = await statSafe(absolutePath);
  8874. if (stat) {
  8875. if (stat.isFile()) {
  8876. entries.push({
  8877. type: "file",
  8878. glob: escapePathForGlob(fixWindowsSlashes$1(pattern)),
  8879. input: pattern
  8880. });
  8881. } else if (stat.isDirectory()) {
  8882. /*
  8883. 1. Remove trailing `/`, `fast-glob` can't find files for `src//*.js` pattern
  8884. 2. Cleanup dirname, when glob `src/../*.js` pattern with `fast-glob`,
  8885. it returns files like 'src/../index.js'
  8886. */
  8887. const relativePath = path$2.relative(cwd, absolutePath) || ".";
  8888. entries.push({
  8889. type: "dir",
  8890. glob: escapePathForGlob(fixWindowsSlashes$1(relativePath)) + "/" + getSupportedFilesGlob(),
  8891. input: pattern
  8892. });
  8893. }
  8894. } else if (pattern[0] === "!") {
  8895. // convert negative patterns to `ignore` entries
  8896. globOptions.ignore.push(fixWindowsSlashes$1(pattern.slice(1)));
  8897. } else {
  8898. entries.push({
  8899. type: "glob",
  8900. glob: fixWindowsSlashes$1(pattern),
  8901. input: pattern
  8902. });
  8903. }
  8904. }
  8905. for (const {
  8906. type,
  8907. glob,
  8908. input
  8909. } of entries) {
  8910. let result;
  8911. try {
  8912. result = await fastGlob(glob, globOptions);
  8913. } catch ({
  8914. message
  8915. }) {
  8916. /* istanbul ignore next */
  8917. yield {
  8918. error: `${errorMessages.globError[type]}: ${input}\n${message}`
  8919. };
  8920. /* istanbul ignore next */
  8921. continue;
  8922. }
  8923. if (result.length === 0) {
  8924. if (context.argv["error-on-unmatched-pattern"] !== false) {
  8925. yield {
  8926. error: `${errorMessages.emptyResults[type]}: "${input}".`
  8927. };
  8928. }
  8929. } else {
  8930. yield* sortPaths(result);
  8931. }
  8932. }
  8933. function getSupportedFilesGlob() {
  8934. if (!supportedFilesGlob) {
  8935. const extensions = context.languages.flatMap(lang => lang.extensions || []);
  8936. const filenames = context.languages.flatMap(lang => lang.filenames || []);
  8937. supportedFilesGlob = `**/{${[...extensions.map(ext => "*" + (ext[0] === "." ? ext : "." + ext)), ...filenames]}}`;
  8938. }
  8939. return supportedFilesGlob;
  8940. }
  8941. }
  8942. const errorMessages = {
  8943. globError: {
  8944. file: "Unable to resolve file",
  8945. dir: "Unable to expand directory",
  8946. glob: "Unable to expand glob pattern"
  8947. },
  8948. emptyResults: {
  8949. file: "Explicitly specified file was ignored due to negative glob patterns",
  8950. dir: "No supported files were found in the directory",
  8951. glob: "No files matching the pattern were found"
  8952. }
  8953. };
  8954. /**
  8955. * @param {string} absolutePath
  8956. * @param {string} cwd
  8957. * @param {string[]} ignoredDirectories
  8958. */
  8959. function containsIgnoredPathSegment(absolutePath, cwd, ignoredDirectories) {
  8960. return path$2.relative(cwd, absolutePath).split(path$2.sep).some(dir => ignoredDirectories.includes(dir));
  8961. }
  8962. /**
  8963. * @param {string[]} paths
  8964. */
  8965. function sortPaths(paths) {
  8966. return paths.sort((a, b) => a.localeCompare(b));
  8967. }
  8968. /**
  8969. * Get stats of a given path.
  8970. * @param {string} filePath The path to target file.
  8971. * @returns {Promise<import('fs').Stats | undefined>} The stats.
  8972. */
  8973. async function statSafe(filePath) {
  8974. try {
  8975. return await fs$1.stat(filePath);
  8976. } catch (error) {
  8977. /* istanbul ignore next */
  8978. if (error.code !== "ENOENT") {
  8979. throw error;
  8980. }
  8981. }
  8982. }
  8983. /**
  8984. * This function should be replaced with `fastGlob.escapePath` when these issues are fixed:
  8985. * - https://github.com/mrmlnc/fast-glob/issues/261
  8986. * - https://github.com/mrmlnc/fast-glob/issues/262
  8987. * @param {string} path
  8988. */
  8989. function escapePathForGlob(path) {
  8990. return fastGlob.escapePath(path.replace(/\\/g, "\0") // Workaround for fast-glob#262 (part 1)
  8991. ).replace(/\\!/g, "@(!)") // Workaround for fast-glob#261
  8992. .replace(/\0/g, "@(\\\\)"); // Workaround for fast-glob#262 (part 2)
  8993. }
  8994. const isWindows = path$2.sep === "\\";
  8995. /**
  8996. * Using backslashes in globs is probably not okay, but not accepting
  8997. * backslashes as path separators on Windows is even more not okay.
  8998. * https://github.com/prettier/prettier/pull/6776#discussion_r380723717
  8999. * https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
  9000. * @param {string} pattern
  9001. */
  9002. function fixWindowsSlashes$1(pattern) {
  9003. return isWindows ? pattern.replace(/\\/g, "/") : pattern;
  9004. }
  9005. var expandPatterns_1 = {
  9006. expandPatterns: expandPatterns$1,
  9007. fixWindowsSlashes: fixWindowsSlashes$1
  9008. };
  9009. var iterators = {};
  9010. var wellKnownSymbol$2 = wellKnownSymbol$7;
  9011. var Iterators$1 = iterators;
  9012. var ITERATOR$1 = wellKnownSymbol$2('iterator');
  9013. var ArrayPrototype$1 = Array.prototype;
  9014. // check on default Array iterator
  9015. var isArrayIteratorMethod$1 = function (it) {
  9016. return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$1[ITERATOR$1] === it);
  9017. };
  9018. var classof = classof$4;
  9019. var getMethod$1 = getMethod$3;
  9020. var Iterators = iterators;
  9021. var wellKnownSymbol$1 = wellKnownSymbol$7;
  9022. var ITERATOR = wellKnownSymbol$1('iterator');
  9023. var getIteratorMethod$2 = function (it) {
  9024. if (it != undefined) return getMethod$1(it, ITERATOR)
  9025. || getMethod$1(it, '@@iterator')
  9026. || Iterators[classof(it)];
  9027. };
  9028. var global$2 = global$r;
  9029. var call$2 = functionCall;
  9030. var aCallable = aCallable$5;
  9031. var anObject$4 = anObject$7;
  9032. var tryToString$1 = tryToString$3;
  9033. var getIteratorMethod$1 = getIteratorMethod$2;
  9034. var TypeError$2 = global$2.TypeError;
  9035. var getIterator$1 = function (argument, usingIterator) {
  9036. var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
  9037. if (aCallable(iteratorMethod)) return anObject$4(call$2(iteratorMethod, argument));
  9038. throw TypeError$2(tryToString$1(argument) + ' is not iterable');
  9039. };
  9040. var call$1 = functionCall;
  9041. var anObject$3 = anObject$7;
  9042. var getMethod = getMethod$3;
  9043. var iteratorClose$1 = function (iterator, kind, value) {
  9044. var innerResult, innerError;
  9045. anObject$3(iterator);
  9046. try {
  9047. innerResult = getMethod(iterator, 'return');
  9048. if (!innerResult) {
  9049. if (kind === 'throw') throw value;
  9050. return value;
  9051. }
  9052. innerResult = call$1(innerResult, iterator);
  9053. } catch (error) {
  9054. innerError = true;
  9055. innerResult = error;
  9056. }
  9057. if (kind === 'throw') throw value;
  9058. if (innerError) throw innerResult;
  9059. anObject$3(innerResult);
  9060. return value;
  9061. };
  9062. var global$1 = global$r;
  9063. var bind = functionBindContext;
  9064. var call = functionCall;
  9065. var anObject$2 = anObject$7;
  9066. var tryToString = tryToString$3;
  9067. var isArrayIteratorMethod = isArrayIteratorMethod$1;
  9068. var lengthOfArrayLike$1 = lengthOfArrayLike$6;
  9069. var isPrototypeOf = objectIsPrototypeOf;
  9070. var getIterator = getIterator$1;
  9071. var getIteratorMethod = getIteratorMethod$2;
  9072. var iteratorClose = iteratorClose$1;
  9073. var TypeError$1 = global$1.TypeError;
  9074. var Result = function (stopped, result) {
  9075. this.stopped = stopped;
  9076. this.result = result;
  9077. };
  9078. var ResultPrototype = Result.prototype;
  9079. var iterate$1 = function (iterable, unboundFunction, options) {
  9080. var that = options && options.that;
  9081. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  9082. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  9083. var INTERRUPTED = !!(options && options.INTERRUPTED);
  9084. var fn = bind(unboundFunction, that);
  9085. var iterator, iterFn, index, length, result, next, step;
  9086. var stop = function (condition) {
  9087. if (iterator) iteratorClose(iterator, 'normal', condition);
  9088. return new Result(true, condition);
  9089. };
  9090. var callFn = function (value) {
  9091. if (AS_ENTRIES) {
  9092. anObject$2(value);
  9093. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  9094. } return INTERRUPTED ? fn(value, stop) : fn(value);
  9095. };
  9096. if (IS_ITERATOR) {
  9097. iterator = iterable;
  9098. } else {
  9099. iterFn = getIteratorMethod(iterable);
  9100. if (!iterFn) throw TypeError$1(tryToString(iterable) + ' is not iterable');
  9101. // optimisation for array iterators
  9102. if (isArrayIteratorMethod(iterFn)) {
  9103. for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
  9104. result = callFn(iterable[index]);
  9105. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  9106. } return new Result(false);
  9107. }
  9108. iterator = getIterator(iterable, iterFn);
  9109. }
  9110. next = iterator.next;
  9111. while (!(step = call(next, iterator)).done) {
  9112. try {
  9113. result = callFn(step.value);
  9114. } catch (error) {
  9115. iteratorClose(iterator, 'throw', error);
  9116. }
  9117. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  9118. } return new Result(false);
  9119. };
  9120. var toPropertyKey = toPropertyKey$3;
  9121. var definePropertyModule$2 = objectDefineProperty;
  9122. var createPropertyDescriptor = createPropertyDescriptor$3;
  9123. var createProperty$1 = function (object, key, value) {
  9124. var propertyKey = toPropertyKey(key);
  9125. if (propertyKey in object) definePropertyModule$2.f(object, propertyKey, createPropertyDescriptor(0, value));
  9126. else object[propertyKey] = value;
  9127. };
  9128. var $$1 = _export;
  9129. var iterate = iterate$1;
  9130. var createProperty = createProperty$1;
  9131. // `Object.fromEntries` method
  9132. // https://github.com/tc39/proposal-object-from-entries
  9133. $$1({ target: 'Object', stat: true }, {
  9134. fromEntries: function fromEntries(iterable) {
  9135. var obj = {};
  9136. iterate(iterable, function (k, v) {
  9137. createProperty(obj, k, v);
  9138. }, { AS_ENTRIES: true });
  9139. return obj;
  9140. }
  9141. });
  9142. /*!
  9143. * dashify <https://github.com/jonschlinkert/dashify>
  9144. *
  9145. * Copyright (c) 2015-2017, Jon Schlinkert.
  9146. * Released under the MIT License.
  9147. */
  9148. var dashify$2 = (str, options) => {
  9149. if (typeof str !== 'string') throw new TypeError('expected a string');
  9150. return str.trim().replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\W/g, m => /[À-ž]/.test(m) ? m : '-').replace(/^-+|-+$/g, '').replace(/-{2,}/g, m => options && options.condense ? '-' : m).toLowerCase();
  9151. };
  9152. var minimist$3 = function (args, opts) {
  9153. if (!opts) opts = {};
  9154. var flags = {
  9155. bools: {},
  9156. strings: {},
  9157. unknownFn: null
  9158. };
  9159. if (typeof opts['unknown'] === 'function') {
  9160. flags.unknownFn = opts['unknown'];
  9161. }
  9162. if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
  9163. flags.allBools = true;
  9164. } else {
  9165. [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
  9166. flags.bools[key] = true;
  9167. });
  9168. }
  9169. var aliases = {};
  9170. Object.keys(opts.alias || {}).forEach(function (key) {
  9171. aliases[key] = [].concat(opts.alias[key]);
  9172. aliases[key].forEach(function (x) {
  9173. aliases[x] = [key].concat(aliases[key].filter(function (y) {
  9174. return x !== y;
  9175. }));
  9176. });
  9177. });
  9178. [].concat(opts.string).filter(Boolean).forEach(function (key) {
  9179. flags.strings[key] = true;
  9180. if (aliases[key]) {
  9181. flags.strings[aliases[key]] = true;
  9182. }
  9183. });
  9184. var defaults = opts['default'] || {};
  9185. var argv = {
  9186. _: []
  9187. };
  9188. Object.keys(flags.bools).forEach(function (key) {
  9189. setArg(key, defaults[key] === undefined ? false : defaults[key]);
  9190. });
  9191. var notFlags = [];
  9192. if (args.indexOf('--') !== -1) {
  9193. notFlags = args.slice(args.indexOf('--') + 1);
  9194. args = args.slice(0, args.indexOf('--'));
  9195. }
  9196. function argDefined(key, arg) {
  9197. return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key];
  9198. }
  9199. function setArg(key, val, arg) {
  9200. if (arg && flags.unknownFn && !argDefined(key, arg)) {
  9201. if (flags.unknownFn(arg) === false) return;
  9202. }
  9203. var value = !flags.strings[key] && isNumber(val) ? Number(val) : val;
  9204. setKey(argv, key.split('.'), value);
  9205. (aliases[key] || []).forEach(function (x) {
  9206. setKey(argv, x.split('.'), value);
  9207. });
  9208. }
  9209. function setKey(obj, keys, value) {
  9210. var o = obj;
  9211. for (var i = 0; i < keys.length - 1; i++) {
  9212. var key = keys[i];
  9213. if (key === '__proto__') return;
  9214. if (o[key] === undefined) o[key] = {};
  9215. if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) o[key] = {};
  9216. if (o[key] === Array.prototype) o[key] = [];
  9217. o = o[key];
  9218. }
  9219. var key = keys[keys.length - 1];
  9220. if (key === '__proto__') return;
  9221. if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {};
  9222. if (o === Array.prototype) o = [];
  9223. if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
  9224. o[key] = value;
  9225. } else if (Array.isArray(o[key])) {
  9226. o[key].push(value);
  9227. } else {
  9228. o[key] = [o[key], value];
  9229. }
  9230. }
  9231. function aliasIsBoolean(key) {
  9232. return aliases[key].some(function (x) {
  9233. return flags.bools[x];
  9234. });
  9235. }
  9236. for (var i = 0; i < args.length; i++) {
  9237. var arg = args[i];
  9238. if (/^--.+=/.test(arg)) {
  9239. // Using [\s\S] instead of . because js doesn't support the
  9240. // 'dotall' regex modifier. See:
  9241. // http://stackoverflow.com/a/1068308/13216
  9242. var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
  9243. var key = m[1];
  9244. var value = m[2];
  9245. if (flags.bools[key]) {
  9246. value = value !== 'false';
  9247. }
  9248. setArg(key, value, arg);
  9249. } else if (/^--no-.+/.test(arg)) {
  9250. var key = arg.match(/^--no-(.+)/)[1];
  9251. setArg(key, false, arg);
  9252. } else if (/^--.+/.test(arg)) {
  9253. var key = arg.match(/^--(.+)/)[1];
  9254. var next = args[i + 1];
  9255. if (next !== undefined && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
  9256. setArg(key, next, arg);
  9257. i++;
  9258. } else if (/^(true|false)$/.test(next)) {
  9259. setArg(key, next === 'true', arg);
  9260. i++;
  9261. } else {
  9262. setArg(key, flags.strings[key] ? '' : true, arg);
  9263. }
  9264. } else if (/^-[^-]+/.test(arg)) {
  9265. var letters = arg.slice(1, -1).split('');
  9266. var broken = false;
  9267. for (var j = 0; j < letters.length; j++) {
  9268. var next = arg.slice(j + 2);
  9269. if (next === '-') {
  9270. setArg(letters[j], next, arg);
  9271. continue;
  9272. }
  9273. if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
  9274. setArg(letters[j], next.split('=')[1], arg);
  9275. broken = true;
  9276. break;
  9277. }
  9278. if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
  9279. setArg(letters[j], next, arg);
  9280. broken = true;
  9281. break;
  9282. }
  9283. if (letters[j + 1] && letters[j + 1].match(/\W/)) {
  9284. setArg(letters[j], arg.slice(j + 2), arg);
  9285. broken = true;
  9286. break;
  9287. } else {
  9288. setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
  9289. }
  9290. }
  9291. var key = arg.slice(-1)[0];
  9292. if (!broken && key !== '-') {
  9293. if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
  9294. setArg(key, args[i + 1], arg);
  9295. i++;
  9296. } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
  9297. setArg(key, args[i + 1] === 'true', arg);
  9298. i++;
  9299. } else {
  9300. setArg(key, flags.strings[key] ? '' : true, arg);
  9301. }
  9302. }
  9303. } else {
  9304. if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
  9305. argv._.push(flags.strings['_'] || !isNumber(arg) ? arg : Number(arg));
  9306. }
  9307. if (opts.stopEarly) {
  9308. argv._.push.apply(argv._, args.slice(i + 1));
  9309. break;
  9310. }
  9311. }
  9312. }
  9313. Object.keys(defaults).forEach(function (key) {
  9314. if (!hasKey(argv, key.split('.'))) {
  9315. setKey(argv, key.split('.'), defaults[key]);
  9316. (aliases[key] || []).forEach(function (x) {
  9317. setKey(argv, x.split('.'), defaults[key]);
  9318. });
  9319. }
  9320. });
  9321. if (opts['--']) {
  9322. argv['--'] = new Array();
  9323. notFlags.forEach(function (key) {
  9324. argv['--'].push(key);
  9325. });
  9326. } else {
  9327. notFlags.forEach(function (key) {
  9328. argv._.push(key);
  9329. });
  9330. }
  9331. return argv;
  9332. };
  9333. function hasKey(obj, keys) {
  9334. var o = obj;
  9335. keys.slice(0, -1).forEach(function (key) {
  9336. o = o[key] || {};
  9337. });
  9338. var key = keys[keys.length - 1];
  9339. return key in o;
  9340. }
  9341. function isNumber(x) {
  9342. if (typeof x === 'number') return true;
  9343. if (/^0x[0-9a-f]+$/i.test(x)) return true;
  9344. return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
  9345. }
  9346. const minimist$2 = minimist$3;
  9347. const PLACEHOLDER = null;
  9348. /**
  9349. * unspecified boolean flag without default value is parsed as `undefined` instead of `false`
  9350. */
  9351. var minimist_1 = function (args, options) {
  9352. const boolean = options.boolean || [];
  9353. const defaults = options.default || {};
  9354. const booleanWithoutDefault = boolean.filter(key => !(key in defaults));
  9355. const newDefaults = Object.assign(Object.assign({}, defaults), Object.fromEntries(booleanWithoutDefault.map(key => [key, PLACEHOLDER])));
  9356. const parsed = minimist$2(args, Object.assign(Object.assign({}, options), {}, {
  9357. default: newDefaults
  9358. }));
  9359. return Object.fromEntries(Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER));
  9360. };
  9361. /**
  9362. * A specialized version of `baseAggregator` for arrays.
  9363. *
  9364. * @private
  9365. * @param {Array} [array] The array to iterate over.
  9366. * @param {Function} setter The function to set `accumulator` values.
  9367. * @param {Function} iteratee The iteratee to transform keys.
  9368. * @param {Object} accumulator The initial aggregated object.
  9369. * @returns {Function} Returns `accumulator`.
  9370. */
  9371. function arrayAggregator$1(array, setter, iteratee, accumulator) {
  9372. var index = -1,
  9373. length = array == null ? 0 : array.length;
  9374. while (++index < length) {
  9375. var value = array[index];
  9376. setter(accumulator, value, iteratee(value), array);
  9377. }
  9378. return accumulator;
  9379. }
  9380. var _arrayAggregator = arrayAggregator$1;
  9381. /**
  9382. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  9383. *
  9384. * @private
  9385. * @param {boolean} [fromRight] Specify iterating from right to left.
  9386. * @returns {Function} Returns the new base function.
  9387. */
  9388. function createBaseFor$1(fromRight) {
  9389. return function (object, iteratee, keysFunc) {
  9390. var index = -1,
  9391. iterable = Object(object),
  9392. props = keysFunc(object),
  9393. length = props.length;
  9394. while (length--) {
  9395. var key = props[fromRight ? length : ++index];
  9396. if (iteratee(iterable[key], key, iterable) === false) {
  9397. break;
  9398. }
  9399. }
  9400. return object;
  9401. };
  9402. }
  9403. var _createBaseFor = createBaseFor$1;
  9404. var createBaseFor = _createBaseFor;
  9405. /**
  9406. * The base implementation of `baseForOwn` which iterates over `object`
  9407. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  9408. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9409. *
  9410. * @private
  9411. * @param {Object} object The object to iterate over.
  9412. * @param {Function} iteratee The function invoked per iteration.
  9413. * @param {Function} keysFunc The function to get the keys of `object`.
  9414. * @returns {Object} Returns `object`.
  9415. */
  9416. var baseFor$1 = createBaseFor();
  9417. var _baseFor = baseFor$1;
  9418. /**
  9419. * The base implementation of `_.times` without support for iteratee shorthands
  9420. * or max array length checks.
  9421. *
  9422. * @private
  9423. * @param {number} n The number of times to invoke `iteratee`.
  9424. * @param {Function} iteratee The function invoked per iteration.
  9425. * @returns {Array} Returns the array of results.
  9426. */
  9427. function baseTimes$1(n, iteratee) {
  9428. var index = -1,
  9429. result = Array(n);
  9430. while (++index < n) {
  9431. result[index] = iteratee(index);
  9432. }
  9433. return result;
  9434. }
  9435. var _baseTimes = baseTimes$1;
  9436. /** Detect free variable `global` from Node.js. */
  9437. var freeGlobal$1 = typeof global == 'object' && global && global.Object === Object && global;
  9438. var _freeGlobal = freeGlobal$1;
  9439. var freeGlobal = _freeGlobal;
  9440. /** Detect free variable `self`. */
  9441. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  9442. /** Used as a reference to the global object. */
  9443. var root$8 = freeGlobal || freeSelf || Function('return this')();
  9444. var _root = root$8;
  9445. var root$7 = _root;
  9446. /** Built-in value references. */
  9447. var Symbol$6 = root$7.Symbol;
  9448. var _Symbol = Symbol$6;
  9449. var Symbol$5 = _Symbol;
  9450. /** Used for built-in method references. */
  9451. var objectProto$d = Object.prototype;
  9452. /** Used to check objects for own properties. */
  9453. var hasOwnProperty$a = objectProto$d.hasOwnProperty;
  9454. /**
  9455. * Used to resolve the
  9456. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  9457. * of values.
  9458. */
  9459. var nativeObjectToString$1 = objectProto$d.toString;
  9460. /** Built-in value references. */
  9461. var symToStringTag$1 = Symbol$5 ? Symbol$5.toStringTag : undefined;
  9462. /**
  9463. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  9464. *
  9465. * @private
  9466. * @param {*} value The value to query.
  9467. * @returns {string} Returns the raw `toStringTag`.
  9468. */
  9469. function getRawTag$1(value) {
  9470. var isOwn = hasOwnProperty$a.call(value, symToStringTag$1),
  9471. tag = value[symToStringTag$1];
  9472. try {
  9473. value[symToStringTag$1] = undefined;
  9474. var unmasked = true;
  9475. } catch (e) {}
  9476. var result = nativeObjectToString$1.call(value);
  9477. if (unmasked) {
  9478. if (isOwn) {
  9479. value[symToStringTag$1] = tag;
  9480. } else {
  9481. delete value[symToStringTag$1];
  9482. }
  9483. }
  9484. return result;
  9485. }
  9486. var _getRawTag = getRawTag$1;
  9487. /** Used for built-in method references. */
  9488. var objectProto$c = Object.prototype;
  9489. /**
  9490. * Used to resolve the
  9491. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  9492. * of values.
  9493. */
  9494. var nativeObjectToString = objectProto$c.toString;
  9495. /**
  9496. * Converts `value` to a string using `Object.prototype.toString`.
  9497. *
  9498. * @private
  9499. * @param {*} value The value to convert.
  9500. * @returns {string} Returns the converted string.
  9501. */
  9502. function objectToString$1(value) {
  9503. return nativeObjectToString.call(value);
  9504. }
  9505. var _objectToString = objectToString$1;
  9506. var Symbol$4 = _Symbol,
  9507. getRawTag = _getRawTag,
  9508. objectToString = _objectToString;
  9509. /** `Object#toString` result references. */
  9510. var nullTag = '[object Null]',
  9511. undefinedTag = '[object Undefined]';
  9512. /** Built-in value references. */
  9513. var symToStringTag = Symbol$4 ? Symbol$4.toStringTag : undefined;
  9514. /**
  9515. * The base implementation of `getTag` without fallbacks for buggy environments.
  9516. *
  9517. * @private
  9518. * @param {*} value The value to query.
  9519. * @returns {string} Returns the `toStringTag`.
  9520. */
  9521. function baseGetTag$5(value) {
  9522. if (value == null) {
  9523. return value === undefined ? undefinedTag : nullTag;
  9524. }
  9525. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  9526. }
  9527. var _baseGetTag = baseGetTag$5;
  9528. /**
  9529. * Checks if `value` is object-like. A value is object-like if it's not `null`
  9530. * and has a `typeof` result of "object".
  9531. *
  9532. * @static
  9533. * @memberOf _
  9534. * @since 4.0.0
  9535. * @category Lang
  9536. * @param {*} value The value to check.
  9537. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  9538. * @example
  9539. *
  9540. * _.isObjectLike({});
  9541. * // => true
  9542. *
  9543. * _.isObjectLike([1, 2, 3]);
  9544. * // => true
  9545. *
  9546. * _.isObjectLike(_.noop);
  9547. * // => false
  9548. *
  9549. * _.isObjectLike(null);
  9550. * // => false
  9551. */
  9552. function isObjectLike$5(value) {
  9553. return value != null && typeof value == 'object';
  9554. }
  9555. var isObjectLike_1 = isObjectLike$5;
  9556. var baseGetTag$4 = _baseGetTag,
  9557. isObjectLike$4 = isObjectLike_1;
  9558. /** `Object#toString` result references. */
  9559. var argsTag$2 = '[object Arguments]';
  9560. /**
  9561. * The base implementation of `_.isArguments`.
  9562. *
  9563. * @private
  9564. * @param {*} value The value to check.
  9565. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  9566. */
  9567. function baseIsArguments$1(value) {
  9568. return isObjectLike$4(value) && baseGetTag$4(value) == argsTag$2;
  9569. }
  9570. var _baseIsArguments = baseIsArguments$1;
  9571. var baseIsArguments = _baseIsArguments,
  9572. isObjectLike$3 = isObjectLike_1;
  9573. /** Used for built-in method references. */
  9574. var objectProto$b = Object.prototype;
  9575. /** Used to check objects for own properties. */
  9576. var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
  9577. /** Built-in value references. */
  9578. var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
  9579. /**
  9580. * Checks if `value` is likely an `arguments` object.
  9581. *
  9582. * @static
  9583. * @memberOf _
  9584. * @since 0.1.0
  9585. * @category Lang
  9586. * @param {*} value The value to check.
  9587. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  9588. * else `false`.
  9589. * @example
  9590. *
  9591. * _.isArguments(function() { return arguments; }());
  9592. * // => true
  9593. *
  9594. * _.isArguments([1, 2, 3]);
  9595. * // => false
  9596. */
  9597. var isArguments$3 = baseIsArguments(function () {
  9598. return arguments;
  9599. }()) ? baseIsArguments : function (value) {
  9600. return isObjectLike$3(value) && hasOwnProperty$9.call(value, 'callee') && !propertyIsEnumerable$1.call(value, 'callee');
  9601. };
  9602. var isArguments_1 = isArguments$3;
  9603. /**
  9604. * Checks if `value` is classified as an `Array` object.
  9605. *
  9606. * @static
  9607. * @memberOf _
  9608. * @since 0.1.0
  9609. * @category Lang
  9610. * @param {*} value The value to check.
  9611. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  9612. * @example
  9613. *
  9614. * _.isArray([1, 2, 3]);
  9615. * // => true
  9616. *
  9617. * _.isArray(document.body.children);
  9618. * // => false
  9619. *
  9620. * _.isArray('abc');
  9621. * // => false
  9622. *
  9623. * _.isArray(_.noop);
  9624. * // => false
  9625. */
  9626. var isArray$a = Array.isArray;
  9627. var isArray_1 = isArray$a;
  9628. var isBuffer$2 = {exports: {}};
  9629. /**
  9630. * This method returns `false`.
  9631. *
  9632. * @static
  9633. * @memberOf _
  9634. * @since 4.13.0
  9635. * @category Util
  9636. * @returns {boolean} Returns `false`.
  9637. * @example
  9638. *
  9639. * _.times(2, _.stubFalse);
  9640. * // => [false, false]
  9641. */
  9642. function stubFalse() {
  9643. return false;
  9644. }
  9645. var stubFalse_1 = stubFalse;
  9646. (function (module, exports) {
  9647. var root = _root,
  9648. stubFalse = stubFalse_1;
  9649. /** Detect free variable `exports`. */
  9650. var freeExports = exports && !exports.nodeType && exports;
  9651. /** Detect free variable `module`. */
  9652. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  9653. /** Detect the popular CommonJS extension `module.exports`. */
  9654. var moduleExports = freeModule && freeModule.exports === freeExports;
  9655. /** Built-in value references. */
  9656. var Buffer = moduleExports ? root.Buffer : undefined;
  9657. /* Built-in method references for those with the same name as other `lodash` methods. */
  9658. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  9659. /**
  9660. * Checks if `value` is a buffer.
  9661. *
  9662. * @static
  9663. * @memberOf _
  9664. * @since 4.3.0
  9665. * @category Lang
  9666. * @param {*} value The value to check.
  9667. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  9668. * @example
  9669. *
  9670. * _.isBuffer(new Buffer(2));
  9671. * // => true
  9672. *
  9673. * _.isBuffer(new Uint8Array(2));
  9674. * // => false
  9675. */
  9676. var isBuffer = nativeIsBuffer || stubFalse;
  9677. module.exports = isBuffer;
  9678. })(isBuffer$2, isBuffer$2.exports);
  9679. /** Used as references for various `Number` constants. */
  9680. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  9681. /** Used to detect unsigned integer values. */
  9682. var reIsUint = /^(?:0|[1-9]\d*)$/;
  9683. /**
  9684. * Checks if `value` is a valid array-like index.
  9685. *
  9686. * @private
  9687. * @param {*} value The value to check.
  9688. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  9689. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  9690. */
  9691. function isIndex$3(value, length) {
  9692. var type = typeof value;
  9693. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  9694. return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  9695. }
  9696. var _isIndex = isIndex$3;
  9697. /** Used as references for various `Number` constants. */
  9698. var MAX_SAFE_INTEGER = 9007199254740991;
  9699. /**
  9700. * Checks if `value` is a valid array-like length.
  9701. *
  9702. * **Note:** This method is loosely based on
  9703. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  9704. *
  9705. * @static
  9706. * @memberOf _
  9707. * @since 4.0.0
  9708. * @category Lang
  9709. * @param {*} value The value to check.
  9710. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  9711. * @example
  9712. *
  9713. * _.isLength(3);
  9714. * // => true
  9715. *
  9716. * _.isLength(Number.MIN_VALUE);
  9717. * // => false
  9718. *
  9719. * _.isLength(Infinity);
  9720. * // => false
  9721. *
  9722. * _.isLength('3');
  9723. * // => false
  9724. */
  9725. function isLength$3(value) {
  9726. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  9727. }
  9728. var isLength_1 = isLength$3;
  9729. var baseGetTag$3 = _baseGetTag,
  9730. isLength$2 = isLength_1,
  9731. isObjectLike$2 = isObjectLike_1;
  9732. /** `Object#toString` result references. */
  9733. var argsTag$1 = '[object Arguments]',
  9734. arrayTag$1 = '[object Array]',
  9735. boolTag$1 = '[object Boolean]',
  9736. dateTag$1 = '[object Date]',
  9737. errorTag$1 = '[object Error]',
  9738. funcTag$1 = '[object Function]',
  9739. mapTag$2 = '[object Map]',
  9740. numberTag$1 = '[object Number]',
  9741. objectTag$2 = '[object Object]',
  9742. regexpTag$1 = '[object RegExp]',
  9743. setTag$2 = '[object Set]',
  9744. stringTag$1 = '[object String]',
  9745. weakMapTag$1 = '[object WeakMap]';
  9746. var arrayBufferTag$1 = '[object ArrayBuffer]',
  9747. dataViewTag$2 = '[object DataView]',
  9748. float32Tag = '[object Float32Array]',
  9749. float64Tag = '[object Float64Array]',
  9750. int8Tag = '[object Int8Array]',
  9751. int16Tag = '[object Int16Array]',
  9752. int32Tag = '[object Int32Array]',
  9753. uint8Tag = '[object Uint8Array]',
  9754. uint8ClampedTag = '[object Uint8ClampedArray]',
  9755. uint16Tag = '[object Uint16Array]',
  9756. uint32Tag = '[object Uint32Array]';
  9757. /** Used to identify `toStringTag` values of typed arrays. */
  9758. var typedArrayTags = {};
  9759. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  9760. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
  9761. /**
  9762. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  9763. *
  9764. * @private
  9765. * @param {*} value The value to check.
  9766. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  9767. */
  9768. function baseIsTypedArray$1(value) {
  9769. return isObjectLike$2(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$3(value)];
  9770. }
  9771. var _baseIsTypedArray = baseIsTypedArray$1;
  9772. /**
  9773. * The base implementation of `_.unary` without support for storing metadata.
  9774. *
  9775. * @private
  9776. * @param {Function} func The function to cap arguments for.
  9777. * @returns {Function} Returns the new capped function.
  9778. */
  9779. function baseUnary$1(func) {
  9780. return function (value) {
  9781. return func(value);
  9782. };
  9783. }
  9784. var _baseUnary = baseUnary$1;
  9785. var _nodeUtil = {exports: {}};
  9786. (function (module, exports) {
  9787. var freeGlobal = _freeGlobal;
  9788. /** Detect free variable `exports`. */
  9789. var freeExports = exports && !exports.nodeType && exports;
  9790. /** Detect free variable `module`. */
  9791. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  9792. /** Detect the popular CommonJS extension `module.exports`. */
  9793. var moduleExports = freeModule && freeModule.exports === freeExports;
  9794. /** Detect free variable `process` from Node.js. */
  9795. var freeProcess = moduleExports && freeGlobal.process;
  9796. /** Used to access faster Node.js helpers. */
  9797. var nodeUtil = function () {
  9798. try {
  9799. // Use `util.types` for Node.js 10+.
  9800. var types = freeModule && freeModule.require && freeModule.require('util').types;
  9801. if (types) {
  9802. return types;
  9803. } // Legacy `process.binding('util')` for Node.js < 10.
  9804. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  9805. } catch (e) {}
  9806. }();
  9807. module.exports = nodeUtil;
  9808. })(_nodeUtil, _nodeUtil.exports);
  9809. var baseIsTypedArray = _baseIsTypedArray,
  9810. baseUnary = _baseUnary,
  9811. nodeUtil = _nodeUtil.exports;
  9812. /* Node.js helper references. */
  9813. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  9814. /**
  9815. * Checks if `value` is classified as a typed array.
  9816. *
  9817. * @static
  9818. * @memberOf _
  9819. * @since 3.0.0
  9820. * @category Lang
  9821. * @param {*} value The value to check.
  9822. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  9823. * @example
  9824. *
  9825. * _.isTypedArray(new Uint8Array);
  9826. * // => true
  9827. *
  9828. * _.isTypedArray([]);
  9829. * // => false
  9830. */
  9831. var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  9832. var isTypedArray_1 = isTypedArray$2;
  9833. var baseTimes = _baseTimes,
  9834. isArguments$2 = isArguments_1,
  9835. isArray$9 = isArray_1,
  9836. isBuffer$1 = isBuffer$2.exports,
  9837. isIndex$2 = _isIndex,
  9838. isTypedArray$1 = isTypedArray_1;
  9839. /** Used for built-in method references. */
  9840. var objectProto$a = Object.prototype;
  9841. /** Used to check objects for own properties. */
  9842. var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
  9843. /**
  9844. * Creates an array of the enumerable property names of the array-like `value`.
  9845. *
  9846. * @private
  9847. * @param {*} value The value to query.
  9848. * @param {boolean} inherited Specify returning inherited property names.
  9849. * @returns {Array} Returns the array of property names.
  9850. */
  9851. function arrayLikeKeys$1(value, inherited) {
  9852. var isArr = isArray$9(value),
  9853. isArg = !isArr && isArguments$2(value),
  9854. isBuff = !isArr && !isArg && isBuffer$1(value),
  9855. isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
  9856. skipIndexes = isArr || isArg || isBuff || isType,
  9857. result = skipIndexes ? baseTimes(value.length, String) : [],
  9858. length = result.length;
  9859. for (var key in value) {
  9860. if ((inherited || hasOwnProperty$8.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
  9861. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
  9862. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
  9863. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
  9864. isIndex$2(key, length)))) {
  9865. result.push(key);
  9866. }
  9867. }
  9868. return result;
  9869. }
  9870. var _arrayLikeKeys = arrayLikeKeys$1;
  9871. /** Used for built-in method references. */
  9872. var objectProto$9 = Object.prototype;
  9873. /**
  9874. * Checks if `value` is likely a prototype object.
  9875. *
  9876. * @private
  9877. * @param {*} value The value to check.
  9878. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  9879. */
  9880. function isPrototype$1(value) {
  9881. var Ctor = value && value.constructor,
  9882. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$9;
  9883. return value === proto;
  9884. }
  9885. var _isPrototype = isPrototype$1;
  9886. /**
  9887. * Creates a unary function that invokes `func` with its argument transformed.
  9888. *
  9889. * @private
  9890. * @param {Function} func The function to wrap.
  9891. * @param {Function} transform The argument transform.
  9892. * @returns {Function} Returns the new function.
  9893. */
  9894. function overArg$1(func, transform) {
  9895. return function (arg) {
  9896. return func(transform(arg));
  9897. };
  9898. }
  9899. var _overArg = overArg$1;
  9900. var overArg = _overArg;
  9901. /* Built-in method references for those with the same name as other `lodash` methods. */
  9902. var nativeKeys$1 = overArg(Object.keys, Object);
  9903. var _nativeKeys = nativeKeys$1;
  9904. var isPrototype = _isPrototype,
  9905. nativeKeys = _nativeKeys;
  9906. /** Used for built-in method references. */
  9907. var objectProto$8 = Object.prototype;
  9908. /** Used to check objects for own properties. */
  9909. var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
  9910. /**
  9911. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  9912. *
  9913. * @private
  9914. * @param {Object} object The object to query.
  9915. * @returns {Array} Returns the array of property names.
  9916. */
  9917. function baseKeys$1(object) {
  9918. if (!isPrototype(object)) {
  9919. return nativeKeys(object);
  9920. }
  9921. var result = [];
  9922. for (var key in Object(object)) {
  9923. if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
  9924. result.push(key);
  9925. }
  9926. }
  9927. return result;
  9928. }
  9929. var _baseKeys = baseKeys$1;
  9930. /**
  9931. * Checks if `value` is the
  9932. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  9933. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  9934. *
  9935. * @static
  9936. * @memberOf _
  9937. * @since 0.1.0
  9938. * @category Lang
  9939. * @param {*} value The value to check.
  9940. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  9941. * @example
  9942. *
  9943. * _.isObject({});
  9944. * // => true
  9945. *
  9946. * _.isObject([1, 2, 3]);
  9947. * // => true
  9948. *
  9949. * _.isObject(_.noop);
  9950. * // => true
  9951. *
  9952. * _.isObject(null);
  9953. * // => false
  9954. */
  9955. function isObject$4(value) {
  9956. var type = typeof value;
  9957. return value != null && (type == 'object' || type == 'function');
  9958. }
  9959. var isObject_1 = isObject$4;
  9960. var baseGetTag$2 = _baseGetTag,
  9961. isObject$3 = isObject_1;
  9962. /** `Object#toString` result references. */
  9963. var asyncTag = '[object AsyncFunction]',
  9964. funcTag = '[object Function]',
  9965. genTag = '[object GeneratorFunction]',
  9966. proxyTag = '[object Proxy]';
  9967. /**
  9968. * Checks if `value` is classified as a `Function` object.
  9969. *
  9970. * @static
  9971. * @memberOf _
  9972. * @since 0.1.0
  9973. * @category Lang
  9974. * @param {*} value The value to check.
  9975. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  9976. * @example
  9977. *
  9978. * _.isFunction(_);
  9979. * // => true
  9980. *
  9981. * _.isFunction(/abc/);
  9982. * // => false
  9983. */
  9984. function isFunction$2(value) {
  9985. if (!isObject$3(value)) {
  9986. return false;
  9987. } // The use of `Object#toString` avoids issues with the `typeof` operator
  9988. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  9989. var tag = baseGetTag$2(value);
  9990. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  9991. }
  9992. var isFunction_1 = isFunction$2;
  9993. var isFunction$1 = isFunction_1,
  9994. isLength$1 = isLength_1;
  9995. /**
  9996. * Checks if `value` is array-like. A value is considered array-like if it's
  9997. * not a function and has a `value.length` that's an integer greater than or
  9998. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  9999. *
  10000. * @static
  10001. * @memberOf _
  10002. * @since 4.0.0
  10003. * @category Lang
  10004. * @param {*} value The value to check.
  10005. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  10006. * @example
  10007. *
  10008. * _.isArrayLike([1, 2, 3]);
  10009. * // => true
  10010. *
  10011. * _.isArrayLike(document.body.children);
  10012. * // => true
  10013. *
  10014. * _.isArrayLike('abc');
  10015. * // => true
  10016. *
  10017. * _.isArrayLike(_.noop);
  10018. * // => false
  10019. */
  10020. function isArrayLike$2(value) {
  10021. return value != null && isLength$1(value.length) && !isFunction$1(value);
  10022. }
  10023. var isArrayLike_1 = isArrayLike$2;
  10024. var arrayLikeKeys = _arrayLikeKeys,
  10025. baseKeys = _baseKeys,
  10026. isArrayLike$1 = isArrayLike_1;
  10027. /**
  10028. * Creates an array of the own enumerable property names of `object`.
  10029. *
  10030. * **Note:** Non-object values are coerced to objects. See the
  10031. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  10032. * for more details.
  10033. *
  10034. * @static
  10035. * @since 0.1.0
  10036. * @memberOf _
  10037. * @category Object
  10038. * @param {Object} object The object to query.
  10039. * @returns {Array} Returns the array of property names.
  10040. * @example
  10041. *
  10042. * function Foo() {
  10043. * this.a = 1;
  10044. * this.b = 2;
  10045. * }
  10046. *
  10047. * Foo.prototype.c = 3;
  10048. *
  10049. * _.keys(new Foo);
  10050. * // => ['a', 'b'] (iteration order is not guaranteed)
  10051. *
  10052. * _.keys('hi');
  10053. * // => ['0', '1']
  10054. */
  10055. function keys$3(object) {
  10056. return isArrayLike$1(object) ? arrayLikeKeys(object) : baseKeys(object);
  10057. }
  10058. var keys_1 = keys$3;
  10059. var baseFor = _baseFor,
  10060. keys$2 = keys_1;
  10061. /**
  10062. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  10063. *
  10064. * @private
  10065. * @param {Object} object The object to iterate over.
  10066. * @param {Function} iteratee The function invoked per iteration.
  10067. * @returns {Object} Returns `object`.
  10068. */
  10069. function baseForOwn$1(object, iteratee) {
  10070. return object && baseFor(object, iteratee, keys$2);
  10071. }
  10072. var _baseForOwn = baseForOwn$1;
  10073. var isArrayLike = isArrayLike_1;
  10074. /**
  10075. * Creates a `baseEach` or `baseEachRight` function.
  10076. *
  10077. * @private
  10078. * @param {Function} eachFunc The function to iterate over a collection.
  10079. * @param {boolean} [fromRight] Specify iterating from right to left.
  10080. * @returns {Function} Returns the new base function.
  10081. */
  10082. function createBaseEach$1(eachFunc, fromRight) {
  10083. return function (collection, iteratee) {
  10084. if (collection == null) {
  10085. return collection;
  10086. }
  10087. if (!isArrayLike(collection)) {
  10088. return eachFunc(collection, iteratee);
  10089. }
  10090. var length = collection.length,
  10091. index = fromRight ? length : -1,
  10092. iterable = Object(collection);
  10093. while (fromRight ? index-- : ++index < length) {
  10094. if (iteratee(iterable[index], index, iterable) === false) {
  10095. break;
  10096. }
  10097. }
  10098. return collection;
  10099. };
  10100. }
  10101. var _createBaseEach = createBaseEach$1;
  10102. var baseForOwn = _baseForOwn,
  10103. createBaseEach = _createBaseEach;
  10104. /**
  10105. * The base implementation of `_.forEach` without support for iteratee shorthands.
  10106. *
  10107. * @private
  10108. * @param {Array|Object} collection The collection to iterate over.
  10109. * @param {Function} iteratee The function invoked per iteration.
  10110. * @returns {Array|Object} Returns `collection`.
  10111. */
  10112. var baseEach$1 = createBaseEach(baseForOwn);
  10113. var _baseEach = baseEach$1;
  10114. var baseEach = _baseEach;
  10115. /**
  10116. * Aggregates elements of `collection` on `accumulator` with keys transformed
  10117. * by `iteratee` and values set by `setter`.
  10118. *
  10119. * @private
  10120. * @param {Array|Object} collection The collection to iterate over.
  10121. * @param {Function} setter The function to set `accumulator` values.
  10122. * @param {Function} iteratee The iteratee to transform keys.
  10123. * @param {Object} accumulator The initial aggregated object.
  10124. * @returns {Function} Returns `accumulator`.
  10125. */
  10126. function baseAggregator$1(collection, setter, iteratee, accumulator) {
  10127. baseEach(collection, function (value, key, collection) {
  10128. setter(accumulator, value, iteratee(value), collection);
  10129. });
  10130. return accumulator;
  10131. }
  10132. var _baseAggregator = baseAggregator$1;
  10133. /**
  10134. * Removes all key-value entries from the list cache.
  10135. *
  10136. * @private
  10137. * @name clear
  10138. * @memberOf ListCache
  10139. */
  10140. function listCacheClear$1() {
  10141. this.__data__ = [];
  10142. this.size = 0;
  10143. }
  10144. var _listCacheClear = listCacheClear$1;
  10145. /**
  10146. * Performs a
  10147. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10148. * comparison between two values to determine if they are equivalent.
  10149. *
  10150. * @static
  10151. * @memberOf _
  10152. * @since 4.0.0
  10153. * @category Lang
  10154. * @param {*} value The value to compare.
  10155. * @param {*} other The other value to compare.
  10156. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  10157. * @example
  10158. *
  10159. * var object = { 'a': 1 };
  10160. * var other = { 'a': 1 };
  10161. *
  10162. * _.eq(object, object);
  10163. * // => true
  10164. *
  10165. * _.eq(object, other);
  10166. * // => false
  10167. *
  10168. * _.eq('a', 'a');
  10169. * // => true
  10170. *
  10171. * _.eq('a', Object('a'));
  10172. * // => false
  10173. *
  10174. * _.eq(NaN, NaN);
  10175. * // => true
  10176. */
  10177. function eq$3(value, other) {
  10178. return value === other || value !== value && other !== other;
  10179. }
  10180. var eq_1 = eq$3;
  10181. var eq$2 = eq_1;
  10182. /**
  10183. * Gets the index at which the `key` is found in `array` of key-value pairs.
  10184. *
  10185. * @private
  10186. * @param {Array} array The array to inspect.
  10187. * @param {*} key The key to search for.
  10188. * @returns {number} Returns the index of the matched value, else `-1`.
  10189. */
  10190. function assocIndexOf$4(array, key) {
  10191. var length = array.length;
  10192. while (length--) {
  10193. if (eq$2(array[length][0], key)) {
  10194. return length;
  10195. }
  10196. }
  10197. return -1;
  10198. }
  10199. var _assocIndexOf = assocIndexOf$4;
  10200. var assocIndexOf$3 = _assocIndexOf;
  10201. /** Used for built-in method references. */
  10202. var arrayProto = Array.prototype;
  10203. /** Built-in value references. */
  10204. var splice = arrayProto.splice;
  10205. /**
  10206. * Removes `key` and its value from the list cache.
  10207. *
  10208. * @private
  10209. * @name delete
  10210. * @memberOf ListCache
  10211. * @param {string} key The key of the value to remove.
  10212. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10213. */
  10214. function listCacheDelete$1(key) {
  10215. var data = this.__data__,
  10216. index = assocIndexOf$3(data, key);
  10217. if (index < 0) {
  10218. return false;
  10219. }
  10220. var lastIndex = data.length - 1;
  10221. if (index == lastIndex) {
  10222. data.pop();
  10223. } else {
  10224. splice.call(data, index, 1);
  10225. }
  10226. --this.size;
  10227. return true;
  10228. }
  10229. var _listCacheDelete = listCacheDelete$1;
  10230. var assocIndexOf$2 = _assocIndexOf;
  10231. /**
  10232. * Gets the list cache value for `key`.
  10233. *
  10234. * @private
  10235. * @name get
  10236. * @memberOf ListCache
  10237. * @param {string} key The key of the value to get.
  10238. * @returns {*} Returns the entry value.
  10239. */
  10240. function listCacheGet$1(key) {
  10241. var data = this.__data__,
  10242. index = assocIndexOf$2(data, key);
  10243. return index < 0 ? undefined : data[index][1];
  10244. }
  10245. var _listCacheGet = listCacheGet$1;
  10246. var assocIndexOf$1 = _assocIndexOf;
  10247. /**
  10248. * Checks if a list cache value for `key` exists.
  10249. *
  10250. * @private
  10251. * @name has
  10252. * @memberOf ListCache
  10253. * @param {string} key The key of the entry to check.
  10254. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10255. */
  10256. function listCacheHas$1(key) {
  10257. return assocIndexOf$1(this.__data__, key) > -1;
  10258. }
  10259. var _listCacheHas = listCacheHas$1;
  10260. var assocIndexOf = _assocIndexOf;
  10261. /**
  10262. * Sets the list cache `key` to `value`.
  10263. *
  10264. * @private
  10265. * @name set
  10266. * @memberOf ListCache
  10267. * @param {string} key The key of the value to set.
  10268. * @param {*} value The value to set.
  10269. * @returns {Object} Returns the list cache instance.
  10270. */
  10271. function listCacheSet$1(key, value) {
  10272. var data = this.__data__,
  10273. index = assocIndexOf(data, key);
  10274. if (index < 0) {
  10275. ++this.size;
  10276. data.push([key, value]);
  10277. } else {
  10278. data[index][1] = value;
  10279. }
  10280. return this;
  10281. }
  10282. var _listCacheSet = listCacheSet$1;
  10283. var listCacheClear = _listCacheClear,
  10284. listCacheDelete = _listCacheDelete,
  10285. listCacheGet = _listCacheGet,
  10286. listCacheHas = _listCacheHas,
  10287. listCacheSet = _listCacheSet;
  10288. /**
  10289. * Creates an list cache object.
  10290. *
  10291. * @private
  10292. * @constructor
  10293. * @param {Array} [entries] The key-value pairs to cache.
  10294. */
  10295. function ListCache$4(entries) {
  10296. var index = -1,
  10297. length = entries == null ? 0 : entries.length;
  10298. this.clear();
  10299. while (++index < length) {
  10300. var entry = entries[index];
  10301. this.set(entry[0], entry[1]);
  10302. }
  10303. } // Add methods to `ListCache`.
  10304. ListCache$4.prototype.clear = listCacheClear;
  10305. ListCache$4.prototype['delete'] = listCacheDelete;
  10306. ListCache$4.prototype.get = listCacheGet;
  10307. ListCache$4.prototype.has = listCacheHas;
  10308. ListCache$4.prototype.set = listCacheSet;
  10309. var _ListCache = ListCache$4;
  10310. var ListCache$3 = _ListCache;
  10311. /**
  10312. * Removes all key-value entries from the stack.
  10313. *
  10314. * @private
  10315. * @name clear
  10316. * @memberOf Stack
  10317. */
  10318. function stackClear$1() {
  10319. this.__data__ = new ListCache$3();
  10320. this.size = 0;
  10321. }
  10322. var _stackClear = stackClear$1;
  10323. /**
  10324. * Removes `key` and its value from the stack.
  10325. *
  10326. * @private
  10327. * @name delete
  10328. * @memberOf Stack
  10329. * @param {string} key The key of the value to remove.
  10330. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10331. */
  10332. function stackDelete$1(key) {
  10333. var data = this.__data__,
  10334. result = data['delete'](key);
  10335. this.size = data.size;
  10336. return result;
  10337. }
  10338. var _stackDelete = stackDelete$1;
  10339. /**
  10340. * Gets the stack value for `key`.
  10341. *
  10342. * @private
  10343. * @name get
  10344. * @memberOf Stack
  10345. * @param {string} key The key of the value to get.
  10346. * @returns {*} Returns the entry value.
  10347. */
  10348. function stackGet$1(key) {
  10349. return this.__data__.get(key);
  10350. }
  10351. var _stackGet = stackGet$1;
  10352. /**
  10353. * Checks if a stack value for `key` exists.
  10354. *
  10355. * @private
  10356. * @name has
  10357. * @memberOf Stack
  10358. * @param {string} key The key of the entry to check.
  10359. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10360. */
  10361. function stackHas$1(key) {
  10362. return this.__data__.has(key);
  10363. }
  10364. var _stackHas = stackHas$1;
  10365. var root$6 = _root;
  10366. /** Used to detect overreaching core-js shims. */
  10367. var coreJsData$1 = root$6['__core-js_shared__'];
  10368. var _coreJsData = coreJsData$1;
  10369. var coreJsData = _coreJsData;
  10370. /** Used to detect methods masquerading as native. */
  10371. var maskSrcKey = function () {
  10372. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  10373. return uid ? 'Symbol(src)_1.' + uid : '';
  10374. }();
  10375. /**
  10376. * Checks if `func` has its source masked.
  10377. *
  10378. * @private
  10379. * @param {Function} func The function to check.
  10380. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10381. */
  10382. function isMasked$1(func) {
  10383. return !!maskSrcKey && maskSrcKey in func;
  10384. }
  10385. var _isMasked = isMasked$1;
  10386. /** Used for built-in method references. */
  10387. var funcProto$1 = Function.prototype;
  10388. /** Used to resolve the decompiled source of functions. */
  10389. var funcToString$1 = funcProto$1.toString;
  10390. /**
  10391. * Converts `func` to its source code.
  10392. *
  10393. * @private
  10394. * @param {Function} func The function to convert.
  10395. * @returns {string} Returns the source code.
  10396. */
  10397. function toSource$2(func) {
  10398. if (func != null) {
  10399. try {
  10400. return funcToString$1.call(func);
  10401. } catch (e) {}
  10402. try {
  10403. return func + '';
  10404. } catch (e) {}
  10405. }
  10406. return '';
  10407. }
  10408. var _toSource = toSource$2;
  10409. var isFunction = isFunction_1,
  10410. isMasked = _isMasked,
  10411. isObject$2 = isObject_1,
  10412. toSource$1 = _toSource;
  10413. /**
  10414. * Used to match `RegExp`
  10415. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  10416. */
  10417. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  10418. /** Used to detect host constructors (Safari). */
  10419. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  10420. /** Used for built-in method references. */
  10421. var funcProto = Function.prototype,
  10422. objectProto$7 = Object.prototype;
  10423. /** Used to resolve the decompiled source of functions. */
  10424. var funcToString = funcProto.toString;
  10425. /** Used to check objects for own properties. */
  10426. var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
  10427. /** Used to detect if a method is native. */
  10428. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$6).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  10429. /**
  10430. * The base implementation of `_.isNative` without bad shim checks.
  10431. *
  10432. * @private
  10433. * @param {*} value The value to check.
  10434. * @returns {boolean} Returns `true` if `value` is a native function,
  10435. * else `false`.
  10436. */
  10437. function baseIsNative$1(value) {
  10438. if (!isObject$2(value) || isMasked(value)) {
  10439. return false;
  10440. }
  10441. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  10442. return pattern.test(toSource$1(value));
  10443. }
  10444. var _baseIsNative = baseIsNative$1;
  10445. /**
  10446. * Gets the value at `key` of `object`.
  10447. *
  10448. * @private
  10449. * @param {Object} [object] The object to query.
  10450. * @param {string} key The key of the property to get.
  10451. * @returns {*} Returns the property value.
  10452. */
  10453. function getValue$1(object, key) {
  10454. return object == null ? undefined : object[key];
  10455. }
  10456. var _getValue = getValue$1;
  10457. var baseIsNative = _baseIsNative,
  10458. getValue = _getValue;
  10459. /**
  10460. * Gets the native function at `key` of `object`.
  10461. *
  10462. * @private
  10463. * @param {Object} object The object to query.
  10464. * @param {string} key The key of the method to get.
  10465. * @returns {*} Returns the function if it's native, else `undefined`.
  10466. */
  10467. function getNative$7(object, key) {
  10468. var value = getValue(object, key);
  10469. return baseIsNative(value) ? value : undefined;
  10470. }
  10471. var _getNative = getNative$7;
  10472. var getNative$6 = _getNative,
  10473. root$5 = _root;
  10474. /* Built-in method references that are verified to be native. */
  10475. var Map$4 = getNative$6(root$5, 'Map');
  10476. var _Map = Map$4;
  10477. var getNative$5 = _getNative;
  10478. /* Built-in method references that are verified to be native. */
  10479. var nativeCreate$4 = getNative$5(Object, 'create');
  10480. var _nativeCreate = nativeCreate$4;
  10481. var nativeCreate$3 = _nativeCreate;
  10482. /**
  10483. * Removes all key-value entries from the hash.
  10484. *
  10485. * @private
  10486. * @name clear
  10487. * @memberOf Hash
  10488. */
  10489. function hashClear$1() {
  10490. this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
  10491. this.size = 0;
  10492. }
  10493. var _hashClear = hashClear$1;
  10494. /**
  10495. * Removes `key` and its value from the hash.
  10496. *
  10497. * @private
  10498. * @name delete
  10499. * @memberOf Hash
  10500. * @param {Object} hash The hash to modify.
  10501. * @param {string} key The key of the value to remove.
  10502. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10503. */
  10504. function hashDelete$1(key) {
  10505. var result = this.has(key) && delete this.__data__[key];
  10506. this.size -= result ? 1 : 0;
  10507. return result;
  10508. }
  10509. var _hashDelete = hashDelete$1;
  10510. var nativeCreate$2 = _nativeCreate;
  10511. /** Used to stand-in for `undefined` hash values. */
  10512. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  10513. /** Used for built-in method references. */
  10514. var objectProto$6 = Object.prototype;
  10515. /** Used to check objects for own properties. */
  10516. var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
  10517. /**
  10518. * Gets the hash value for `key`.
  10519. *
  10520. * @private
  10521. * @name get
  10522. * @memberOf Hash
  10523. * @param {string} key The key of the value to get.
  10524. * @returns {*} Returns the entry value.
  10525. */
  10526. function hashGet$1(key) {
  10527. var data = this.__data__;
  10528. if (nativeCreate$2) {
  10529. var result = data[key];
  10530. return result === HASH_UNDEFINED$2 ? undefined : result;
  10531. }
  10532. return hasOwnProperty$5.call(data, key) ? data[key] : undefined;
  10533. }
  10534. var _hashGet = hashGet$1;
  10535. var nativeCreate$1 = _nativeCreate;
  10536. /** Used for built-in method references. */
  10537. var objectProto$5 = Object.prototype;
  10538. /** Used to check objects for own properties. */
  10539. var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
  10540. /**
  10541. * Checks if a hash value for `key` exists.
  10542. *
  10543. * @private
  10544. * @name has
  10545. * @memberOf Hash
  10546. * @param {string} key The key of the entry to check.
  10547. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10548. */
  10549. function hashHas$1(key) {
  10550. var data = this.__data__;
  10551. return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty$4.call(data, key);
  10552. }
  10553. var _hashHas = hashHas$1;
  10554. var nativeCreate = _nativeCreate;
  10555. /** Used to stand-in for `undefined` hash values. */
  10556. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  10557. /**
  10558. * Sets the hash `key` to `value`.
  10559. *
  10560. * @private
  10561. * @name set
  10562. * @memberOf Hash
  10563. * @param {string} key The key of the value to set.
  10564. * @param {*} value The value to set.
  10565. * @returns {Object} Returns the hash instance.
  10566. */
  10567. function hashSet$1(key, value) {
  10568. var data = this.__data__;
  10569. this.size += this.has(key) ? 0 : 1;
  10570. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
  10571. return this;
  10572. }
  10573. var _hashSet = hashSet$1;
  10574. var hashClear = _hashClear,
  10575. hashDelete = _hashDelete,
  10576. hashGet = _hashGet,
  10577. hashHas = _hashHas,
  10578. hashSet = _hashSet;
  10579. /**
  10580. * Creates a hash object.
  10581. *
  10582. * @private
  10583. * @constructor
  10584. * @param {Array} [entries] The key-value pairs to cache.
  10585. */
  10586. function Hash$1(entries) {
  10587. var index = -1,
  10588. length = entries == null ? 0 : entries.length;
  10589. this.clear();
  10590. while (++index < length) {
  10591. var entry = entries[index];
  10592. this.set(entry[0], entry[1]);
  10593. }
  10594. } // Add methods to `Hash`.
  10595. Hash$1.prototype.clear = hashClear;
  10596. Hash$1.prototype['delete'] = hashDelete;
  10597. Hash$1.prototype.get = hashGet;
  10598. Hash$1.prototype.has = hashHas;
  10599. Hash$1.prototype.set = hashSet;
  10600. var _Hash = Hash$1;
  10601. var Hash = _Hash,
  10602. ListCache$2 = _ListCache,
  10603. Map$3 = _Map;
  10604. /**
  10605. * Removes all key-value entries from the map.
  10606. *
  10607. * @private
  10608. * @name clear
  10609. * @memberOf MapCache
  10610. */
  10611. function mapCacheClear$1() {
  10612. this.size = 0;
  10613. this.__data__ = {
  10614. 'hash': new Hash(),
  10615. 'map': new (Map$3 || ListCache$2)(),
  10616. 'string': new Hash()
  10617. };
  10618. }
  10619. var _mapCacheClear = mapCacheClear$1;
  10620. /**
  10621. * Checks if `value` is suitable for use as unique object key.
  10622. *
  10623. * @private
  10624. * @param {*} value The value to check.
  10625. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10626. */
  10627. function isKeyable$1(value) {
  10628. var type = typeof value;
  10629. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  10630. }
  10631. var _isKeyable = isKeyable$1;
  10632. var isKeyable = _isKeyable;
  10633. /**
  10634. * Gets the data for `map`.
  10635. *
  10636. * @private
  10637. * @param {Object} map The map to query.
  10638. * @param {string} key The reference key.
  10639. * @returns {*} Returns the map data.
  10640. */
  10641. function getMapData$4(map, key) {
  10642. var data = map.__data__;
  10643. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  10644. }
  10645. var _getMapData = getMapData$4;
  10646. var getMapData$3 = _getMapData;
  10647. /**
  10648. * Removes `key` and its value from the map.
  10649. *
  10650. * @private
  10651. * @name delete
  10652. * @memberOf MapCache
  10653. * @param {string} key The key of the value to remove.
  10654. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10655. */
  10656. function mapCacheDelete$1(key) {
  10657. var result = getMapData$3(this, key)['delete'](key);
  10658. this.size -= result ? 1 : 0;
  10659. return result;
  10660. }
  10661. var _mapCacheDelete = mapCacheDelete$1;
  10662. var getMapData$2 = _getMapData;
  10663. /**
  10664. * Gets the map value for `key`.
  10665. *
  10666. * @private
  10667. * @name get
  10668. * @memberOf MapCache
  10669. * @param {string} key The key of the value to get.
  10670. * @returns {*} Returns the entry value.
  10671. */
  10672. function mapCacheGet$1(key) {
  10673. return getMapData$2(this, key).get(key);
  10674. }
  10675. var _mapCacheGet = mapCacheGet$1;
  10676. var getMapData$1 = _getMapData;
  10677. /**
  10678. * Checks if a map value for `key` exists.
  10679. *
  10680. * @private
  10681. * @name has
  10682. * @memberOf MapCache
  10683. * @param {string} key The key of the entry to check.
  10684. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10685. */
  10686. function mapCacheHas$1(key) {
  10687. return getMapData$1(this, key).has(key);
  10688. }
  10689. var _mapCacheHas = mapCacheHas$1;
  10690. var getMapData = _getMapData;
  10691. /**
  10692. * Sets the map `key` to `value`.
  10693. *
  10694. * @private
  10695. * @name set
  10696. * @memberOf MapCache
  10697. * @param {string} key The key of the value to set.
  10698. * @param {*} value The value to set.
  10699. * @returns {Object} Returns the map cache instance.
  10700. */
  10701. function mapCacheSet$1(key, value) {
  10702. var data = getMapData(this, key),
  10703. size = data.size;
  10704. data.set(key, value);
  10705. this.size += data.size == size ? 0 : 1;
  10706. return this;
  10707. }
  10708. var _mapCacheSet = mapCacheSet$1;
  10709. var mapCacheClear = _mapCacheClear,
  10710. mapCacheDelete = _mapCacheDelete,
  10711. mapCacheGet = _mapCacheGet,
  10712. mapCacheHas = _mapCacheHas,
  10713. mapCacheSet = _mapCacheSet;
  10714. /**
  10715. * Creates a map cache object to store key-value pairs.
  10716. *
  10717. * @private
  10718. * @constructor
  10719. * @param {Array} [entries] The key-value pairs to cache.
  10720. */
  10721. function MapCache$3(entries) {
  10722. var index = -1,
  10723. length = entries == null ? 0 : entries.length;
  10724. this.clear();
  10725. while (++index < length) {
  10726. var entry = entries[index];
  10727. this.set(entry[0], entry[1]);
  10728. }
  10729. } // Add methods to `MapCache`.
  10730. MapCache$3.prototype.clear = mapCacheClear;
  10731. MapCache$3.prototype['delete'] = mapCacheDelete;
  10732. MapCache$3.prototype.get = mapCacheGet;
  10733. MapCache$3.prototype.has = mapCacheHas;
  10734. MapCache$3.prototype.set = mapCacheSet;
  10735. var _MapCache = MapCache$3;
  10736. var ListCache$1 = _ListCache,
  10737. Map$2 = _Map,
  10738. MapCache$2 = _MapCache;
  10739. /** Used as the size to enable large array optimizations. */
  10740. var LARGE_ARRAY_SIZE = 200;
  10741. /**
  10742. * Sets the stack `key` to `value`.
  10743. *
  10744. * @private
  10745. * @name set
  10746. * @memberOf Stack
  10747. * @param {string} key The key of the value to set.
  10748. * @param {*} value The value to set.
  10749. * @returns {Object} Returns the stack cache instance.
  10750. */
  10751. function stackSet$1(key, value) {
  10752. var data = this.__data__;
  10753. if (data instanceof ListCache$1) {
  10754. var pairs = data.__data__;
  10755. if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
  10756. pairs.push([key, value]);
  10757. this.size = ++data.size;
  10758. return this;
  10759. }
  10760. data = this.__data__ = new MapCache$2(pairs);
  10761. }
  10762. data.set(key, value);
  10763. this.size = data.size;
  10764. return this;
  10765. }
  10766. var _stackSet = stackSet$1;
  10767. var ListCache = _ListCache,
  10768. stackClear = _stackClear,
  10769. stackDelete = _stackDelete,
  10770. stackGet = _stackGet,
  10771. stackHas = _stackHas,
  10772. stackSet = _stackSet;
  10773. /**
  10774. * Creates a stack cache object to store key-value pairs.
  10775. *
  10776. * @private
  10777. * @constructor
  10778. * @param {Array} [entries] The key-value pairs to cache.
  10779. */
  10780. function Stack$2(entries) {
  10781. var data = this.__data__ = new ListCache(entries);
  10782. this.size = data.size;
  10783. } // Add methods to `Stack`.
  10784. Stack$2.prototype.clear = stackClear;
  10785. Stack$2.prototype['delete'] = stackDelete;
  10786. Stack$2.prototype.get = stackGet;
  10787. Stack$2.prototype.has = stackHas;
  10788. Stack$2.prototype.set = stackSet;
  10789. var _Stack = Stack$2;
  10790. /** Used to stand-in for `undefined` hash values. */
  10791. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10792. /**
  10793. * Adds `value` to the array cache.
  10794. *
  10795. * @private
  10796. * @name add
  10797. * @memberOf SetCache
  10798. * @alias push
  10799. * @param {*} value The value to cache.
  10800. * @returns {Object} Returns the cache instance.
  10801. */
  10802. function setCacheAdd$1(value) {
  10803. this.__data__.set(value, HASH_UNDEFINED);
  10804. return this;
  10805. }
  10806. var _setCacheAdd = setCacheAdd$1;
  10807. /**
  10808. * Checks if `value` is in the array cache.
  10809. *
  10810. * @private
  10811. * @name has
  10812. * @memberOf SetCache
  10813. * @param {*} value The value to search for.
  10814. * @returns {number} Returns `true` if `value` is found, else `false`.
  10815. */
  10816. function setCacheHas$1(value) {
  10817. return this.__data__.has(value);
  10818. }
  10819. var _setCacheHas = setCacheHas$1;
  10820. var MapCache$1 = _MapCache,
  10821. setCacheAdd = _setCacheAdd,
  10822. setCacheHas = _setCacheHas;
  10823. /**
  10824. *
  10825. * Creates an array cache object to store unique values.
  10826. *
  10827. * @private
  10828. * @constructor
  10829. * @param {Array} [values] The values to cache.
  10830. */
  10831. function SetCache$1(values) {
  10832. var index = -1,
  10833. length = values == null ? 0 : values.length;
  10834. this.__data__ = new MapCache$1();
  10835. while (++index < length) {
  10836. this.add(values[index]);
  10837. }
  10838. } // Add methods to `SetCache`.
  10839. SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
  10840. SetCache$1.prototype.has = setCacheHas;
  10841. var _SetCache = SetCache$1;
  10842. /**
  10843. * A specialized version of `_.some` for arrays without support for iteratee
  10844. * shorthands.
  10845. *
  10846. * @private
  10847. * @param {Array} [array] The array to iterate over.
  10848. * @param {Function} predicate The function invoked per iteration.
  10849. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10850. * else `false`.
  10851. */
  10852. function arraySome$1(array, predicate) {
  10853. var index = -1,
  10854. length = array == null ? 0 : array.length;
  10855. while (++index < length) {
  10856. if (predicate(array[index], index, array)) {
  10857. return true;
  10858. }
  10859. }
  10860. return false;
  10861. }
  10862. var _arraySome = arraySome$1;
  10863. /**
  10864. * Checks if a `cache` value for `key` exists.
  10865. *
  10866. * @private
  10867. * @param {Object} cache The cache to query.
  10868. * @param {string} key The key of the entry to check.
  10869. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10870. */
  10871. function cacheHas$1(cache, key) {
  10872. return cache.has(key);
  10873. }
  10874. var _cacheHas = cacheHas$1;
  10875. var SetCache = _SetCache,
  10876. arraySome = _arraySome,
  10877. cacheHas = _cacheHas;
  10878. /** Used to compose bitmasks for value comparisons. */
  10879. var COMPARE_PARTIAL_FLAG$5 = 1,
  10880. COMPARE_UNORDERED_FLAG$3 = 2;
  10881. /**
  10882. * A specialized version of `baseIsEqualDeep` for arrays with support for
  10883. * partial deep comparisons.
  10884. *
  10885. * @private
  10886. * @param {Array} array The array to compare.
  10887. * @param {Array} other The other array to compare.
  10888. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10889. * @param {Function} customizer The function to customize comparisons.
  10890. * @param {Function} equalFunc The function to determine equivalents of values.
  10891. * @param {Object} stack Tracks traversed `array` and `other` objects.
  10892. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  10893. */
  10894. function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
  10895. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
  10896. arrLength = array.length,
  10897. othLength = other.length;
  10898. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  10899. return false;
  10900. } // Check that cyclic values are equal.
  10901. var arrStacked = stack.get(array);
  10902. var othStacked = stack.get(other);
  10903. if (arrStacked && othStacked) {
  10904. return arrStacked == other && othStacked == array;
  10905. }
  10906. var index = -1,
  10907. result = true,
  10908. seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : undefined;
  10909. stack.set(array, other);
  10910. stack.set(other, array); // Ignore non-index properties.
  10911. while (++index < arrLength) {
  10912. var arrValue = array[index],
  10913. othValue = other[index];
  10914. if (customizer) {
  10915. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  10916. }
  10917. if (compared !== undefined) {
  10918. if (compared) {
  10919. continue;
  10920. }
  10921. result = false;
  10922. break;
  10923. } // Recursively compare arrays (susceptible to call stack limits).
  10924. if (seen) {
  10925. if (!arraySome(other, function (othValue, othIndex) {
  10926. if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  10927. return seen.push(othIndex);
  10928. }
  10929. })) {
  10930. result = false;
  10931. break;
  10932. }
  10933. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  10934. result = false;
  10935. break;
  10936. }
  10937. }
  10938. stack['delete'](array);
  10939. stack['delete'](other);
  10940. return result;
  10941. }
  10942. var _equalArrays = equalArrays$2;
  10943. var root$4 = _root;
  10944. /** Built-in value references. */
  10945. var Uint8Array$1 = root$4.Uint8Array;
  10946. var _Uint8Array = Uint8Array$1;
  10947. /**
  10948. * Converts `map` to its key-value pairs.
  10949. *
  10950. * @private
  10951. * @param {Object} map The map to convert.
  10952. * @returns {Array} Returns the key-value pairs.
  10953. */
  10954. function mapToArray$1(map) {
  10955. var index = -1,
  10956. result = Array(map.size);
  10957. map.forEach(function (value, key) {
  10958. result[++index] = [key, value];
  10959. });
  10960. return result;
  10961. }
  10962. var _mapToArray = mapToArray$1;
  10963. /**
  10964. * Converts `set` to an array of its values.
  10965. *
  10966. * @private
  10967. * @param {Object} set The set to convert.
  10968. * @returns {Array} Returns the values.
  10969. */
  10970. function setToArray$1(set) {
  10971. var index = -1,
  10972. result = Array(set.size);
  10973. set.forEach(function (value) {
  10974. result[++index] = value;
  10975. });
  10976. return result;
  10977. }
  10978. var _setToArray = setToArray$1;
  10979. var Symbol$3 = _Symbol,
  10980. Uint8Array = _Uint8Array,
  10981. eq$1 = eq_1,
  10982. equalArrays$1 = _equalArrays,
  10983. mapToArray = _mapToArray,
  10984. setToArray = _setToArray;
  10985. /** Used to compose bitmasks for value comparisons. */
  10986. var COMPARE_PARTIAL_FLAG$4 = 1,
  10987. COMPARE_UNORDERED_FLAG$2 = 2;
  10988. /** `Object#toString` result references. */
  10989. var boolTag = '[object Boolean]',
  10990. dateTag = '[object Date]',
  10991. errorTag = '[object Error]',
  10992. mapTag$1 = '[object Map]',
  10993. numberTag = '[object Number]',
  10994. regexpTag = '[object RegExp]',
  10995. setTag$1 = '[object Set]',
  10996. stringTag = '[object String]',
  10997. symbolTag$1 = '[object Symbol]';
  10998. var arrayBufferTag = '[object ArrayBuffer]',
  10999. dataViewTag$1 = '[object DataView]';
  11000. /** Used to convert symbols to primitives and strings. */
  11001. var symbolProto$1 = Symbol$3 ? Symbol$3.prototype : undefined,
  11002. symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
  11003. /**
  11004. * A specialized version of `baseIsEqualDeep` for comparing objects of
  11005. * the same `toStringTag`.
  11006. *
  11007. * **Note:** This function only supports comparing values with tags of
  11008. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  11009. *
  11010. * @private
  11011. * @param {Object} object The object to compare.
  11012. * @param {Object} other The other object to compare.
  11013. * @param {string} tag The `toStringTag` of the objects to compare.
  11014. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11015. * @param {Function} customizer The function to customize comparisons.
  11016. * @param {Function} equalFunc The function to determine equivalents of values.
  11017. * @param {Object} stack Tracks traversed `object` and `other` objects.
  11018. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11019. */
  11020. function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
  11021. switch (tag) {
  11022. case dataViewTag$1:
  11023. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  11024. return false;
  11025. }
  11026. object = object.buffer;
  11027. other = other.buffer;
  11028. case arrayBufferTag:
  11029. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  11030. return false;
  11031. }
  11032. return true;
  11033. case boolTag:
  11034. case dateTag:
  11035. case numberTag:
  11036. // Coerce booleans to `1` or `0` and dates to milliseconds.
  11037. // Invalid dates are coerced to `NaN`.
  11038. return eq$1(+object, +other);
  11039. case errorTag:
  11040. return object.name == other.name && object.message == other.message;
  11041. case regexpTag:
  11042. case stringTag:
  11043. // Coerce regexes to strings and treat strings, primitives and objects,
  11044. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  11045. // for more details.
  11046. return object == other + '';
  11047. case mapTag$1:
  11048. var convert = mapToArray;
  11049. case setTag$1:
  11050. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
  11051. convert || (convert = setToArray);
  11052. if (object.size != other.size && !isPartial) {
  11053. return false;
  11054. } // Assume cyclic values are equal.
  11055. var stacked = stack.get(object);
  11056. if (stacked) {
  11057. return stacked == other;
  11058. }
  11059. bitmask |= COMPARE_UNORDERED_FLAG$2; // Recursively compare objects (susceptible to call stack limits).
  11060. stack.set(object, other);
  11061. var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  11062. stack['delete'](object);
  11063. return result;
  11064. case symbolTag$1:
  11065. if (symbolValueOf) {
  11066. return symbolValueOf.call(object) == symbolValueOf.call(other);
  11067. }
  11068. }
  11069. return false;
  11070. }
  11071. var _equalByTag = equalByTag$1;
  11072. /**
  11073. * Appends the elements of `values` to `array`.
  11074. *
  11075. * @private
  11076. * @param {Array} array The array to modify.
  11077. * @param {Array} values The values to append.
  11078. * @returns {Array} Returns `array`.
  11079. */
  11080. function arrayPush$2(array, values) {
  11081. var index = -1,
  11082. length = values.length,
  11083. offset = array.length;
  11084. while (++index < length) {
  11085. array[offset + index] = values[index];
  11086. }
  11087. return array;
  11088. }
  11089. var _arrayPush = arrayPush$2;
  11090. var arrayPush$1 = _arrayPush,
  11091. isArray$8 = isArray_1;
  11092. /**
  11093. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  11094. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  11095. * symbols of `object`.
  11096. *
  11097. * @private
  11098. * @param {Object} object The object to query.
  11099. * @param {Function} keysFunc The function to get the keys of `object`.
  11100. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  11101. * @returns {Array} Returns the array of property names and symbols.
  11102. */
  11103. function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
  11104. var result = keysFunc(object);
  11105. return isArray$8(object) ? result : arrayPush$1(result, symbolsFunc(object));
  11106. }
  11107. var _baseGetAllKeys = baseGetAllKeys$1;
  11108. /**
  11109. * A specialized version of `_.filter` for arrays without support for
  11110. * iteratee shorthands.
  11111. *
  11112. * @private
  11113. * @param {Array} [array] The array to iterate over.
  11114. * @param {Function} predicate The function invoked per iteration.
  11115. * @returns {Array} Returns the new filtered array.
  11116. */
  11117. function arrayFilter$1(array, predicate) {
  11118. var index = -1,
  11119. length = array == null ? 0 : array.length,
  11120. resIndex = 0,
  11121. result = [];
  11122. while (++index < length) {
  11123. var value = array[index];
  11124. if (predicate(value, index, array)) {
  11125. result[resIndex++] = value;
  11126. }
  11127. }
  11128. return result;
  11129. }
  11130. var _arrayFilter = arrayFilter$1;
  11131. /**
  11132. * This method returns a new empty array.
  11133. *
  11134. * @static
  11135. * @memberOf _
  11136. * @since 4.13.0
  11137. * @category Util
  11138. * @returns {Array} Returns the new empty array.
  11139. * @example
  11140. *
  11141. * var arrays = _.times(2, _.stubArray);
  11142. *
  11143. * console.log(arrays);
  11144. * // => [[], []]
  11145. *
  11146. * console.log(arrays[0] === arrays[1]);
  11147. * // => false
  11148. */
  11149. function stubArray$1() {
  11150. return [];
  11151. }
  11152. var stubArray_1 = stubArray$1;
  11153. var arrayFilter = _arrayFilter,
  11154. stubArray = stubArray_1;
  11155. /** Used for built-in method references. */
  11156. var objectProto$4 = Object.prototype;
  11157. /** Built-in value references. */
  11158. var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
  11159. /* Built-in method references for those with the same name as other `lodash` methods. */
  11160. var nativeGetSymbols = Object.getOwnPropertySymbols;
  11161. /**
  11162. * Creates an array of the own enumerable symbols of `object`.
  11163. *
  11164. * @private
  11165. * @param {Object} object The object to query.
  11166. * @returns {Array} Returns the array of symbols.
  11167. */
  11168. var getSymbols$1 = !nativeGetSymbols ? stubArray : function (object) {
  11169. if (object == null) {
  11170. return [];
  11171. }
  11172. object = Object(object);
  11173. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  11174. return propertyIsEnumerable.call(object, symbol);
  11175. });
  11176. };
  11177. var _getSymbols = getSymbols$1;
  11178. var baseGetAllKeys = _baseGetAllKeys,
  11179. getSymbols = _getSymbols,
  11180. keys$1 = keys_1;
  11181. /**
  11182. * Creates an array of own enumerable property names and symbols of `object`.
  11183. *
  11184. * @private
  11185. * @param {Object} object The object to query.
  11186. * @returns {Array} Returns the array of property names and symbols.
  11187. */
  11188. function getAllKeys$1(object) {
  11189. return baseGetAllKeys(object, keys$1, getSymbols);
  11190. }
  11191. var _getAllKeys = getAllKeys$1;
  11192. var getAllKeys = _getAllKeys;
  11193. /** Used to compose bitmasks for value comparisons. */
  11194. var COMPARE_PARTIAL_FLAG$3 = 1;
  11195. /** Used for built-in method references. */
  11196. var objectProto$3 = Object.prototype;
  11197. /** Used to check objects for own properties. */
  11198. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  11199. /**
  11200. * A specialized version of `baseIsEqualDeep` for objects with support for
  11201. * partial deep comparisons.
  11202. *
  11203. * @private
  11204. * @param {Object} object The object to compare.
  11205. * @param {Object} other The other object to compare.
  11206. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11207. * @param {Function} customizer The function to customize comparisons.
  11208. * @param {Function} equalFunc The function to determine equivalents of values.
  11209. * @param {Object} stack Tracks traversed `object` and `other` objects.
  11210. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11211. */
  11212. function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
  11213. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
  11214. objProps = getAllKeys(object),
  11215. objLength = objProps.length,
  11216. othProps = getAllKeys(other),
  11217. othLength = othProps.length;
  11218. if (objLength != othLength && !isPartial) {
  11219. return false;
  11220. }
  11221. var index = objLength;
  11222. while (index--) {
  11223. var key = objProps[index];
  11224. if (!(isPartial ? key in other : hasOwnProperty$3.call(other, key))) {
  11225. return false;
  11226. }
  11227. } // Check that cyclic values are equal.
  11228. var objStacked = stack.get(object);
  11229. var othStacked = stack.get(other);
  11230. if (objStacked && othStacked) {
  11231. return objStacked == other && othStacked == object;
  11232. }
  11233. var result = true;
  11234. stack.set(object, other);
  11235. stack.set(other, object);
  11236. var skipCtor = isPartial;
  11237. while (++index < objLength) {
  11238. key = objProps[index];
  11239. var objValue = object[key],
  11240. othValue = other[key];
  11241. if (customizer) {
  11242. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  11243. } // Recursively compare objects (susceptible to call stack limits).
  11244. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
  11245. result = false;
  11246. break;
  11247. }
  11248. skipCtor || (skipCtor = key == 'constructor');
  11249. }
  11250. if (result && !skipCtor) {
  11251. var objCtor = object.constructor,
  11252. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  11253. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  11254. result = false;
  11255. }
  11256. }
  11257. stack['delete'](object);
  11258. stack['delete'](other);
  11259. return result;
  11260. }
  11261. var _equalObjects = equalObjects$1;
  11262. var getNative$4 = _getNative,
  11263. root$3 = _root;
  11264. /* Built-in method references that are verified to be native. */
  11265. var DataView$1 = getNative$4(root$3, 'DataView');
  11266. var _DataView = DataView$1;
  11267. var getNative$3 = _getNative,
  11268. root$2 = _root;
  11269. /* Built-in method references that are verified to be native. */
  11270. var Promise$2 = getNative$3(root$2, 'Promise');
  11271. var _Promise = Promise$2;
  11272. var getNative$2 = _getNative,
  11273. root$1 = _root;
  11274. /* Built-in method references that are verified to be native. */
  11275. var Set$2 = getNative$2(root$1, 'Set');
  11276. var _Set = Set$2;
  11277. var getNative$1 = _getNative,
  11278. root = _root;
  11279. /* Built-in method references that are verified to be native. */
  11280. var WeakMap$2 = getNative$1(root, 'WeakMap');
  11281. var _WeakMap = WeakMap$2;
  11282. var DataView = _DataView,
  11283. Map$1 = _Map,
  11284. Promise$1 = _Promise,
  11285. Set$1 = _Set,
  11286. WeakMap$1 = _WeakMap,
  11287. baseGetTag$1 = _baseGetTag,
  11288. toSource = _toSource;
  11289. /** `Object#toString` result references. */
  11290. var mapTag = '[object Map]',
  11291. objectTag$1 = '[object Object]',
  11292. promiseTag = '[object Promise]',
  11293. setTag = '[object Set]',
  11294. weakMapTag = '[object WeakMap]';
  11295. var dataViewTag = '[object DataView]';
  11296. /** Used to detect maps, sets, and weakmaps. */
  11297. var dataViewCtorString = toSource(DataView),
  11298. mapCtorString = toSource(Map$1),
  11299. promiseCtorString = toSource(Promise$1),
  11300. setCtorString = toSource(Set$1),
  11301. weakMapCtorString = toSource(WeakMap$1);
  11302. /**
  11303. * Gets the `toStringTag` of `value`.
  11304. *
  11305. * @private
  11306. * @param {*} value The value to query.
  11307. * @returns {string} Returns the `toStringTag`.
  11308. */
  11309. var getTag$1 = baseGetTag$1; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11310. if (DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag$1(new Map$1()) != mapTag || Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag || Set$1 && getTag$1(new Set$1()) != setTag || WeakMap$1 && getTag$1(new WeakMap$1()) != weakMapTag) {
  11311. getTag$1 = function (value) {
  11312. var result = baseGetTag$1(value),
  11313. Ctor = result == objectTag$1 ? value.constructor : undefined,
  11314. ctorString = Ctor ? toSource(Ctor) : '';
  11315. if (ctorString) {
  11316. switch (ctorString) {
  11317. case dataViewCtorString:
  11318. return dataViewTag;
  11319. case mapCtorString:
  11320. return mapTag;
  11321. case promiseCtorString:
  11322. return promiseTag;
  11323. case setCtorString:
  11324. return setTag;
  11325. case weakMapCtorString:
  11326. return weakMapTag;
  11327. }
  11328. }
  11329. return result;
  11330. };
  11331. }
  11332. var _getTag = getTag$1;
  11333. var Stack$1 = _Stack,
  11334. equalArrays = _equalArrays,
  11335. equalByTag = _equalByTag,
  11336. equalObjects = _equalObjects,
  11337. getTag = _getTag,
  11338. isArray$7 = isArray_1,
  11339. isBuffer = isBuffer$2.exports,
  11340. isTypedArray = isTypedArray_1;
  11341. /** Used to compose bitmasks for value comparisons. */
  11342. var COMPARE_PARTIAL_FLAG$2 = 1;
  11343. /** `Object#toString` result references. */
  11344. var argsTag = '[object Arguments]',
  11345. arrayTag = '[object Array]',
  11346. objectTag = '[object Object]';
  11347. /** Used for built-in method references. */
  11348. var objectProto$2 = Object.prototype;
  11349. /** Used to check objects for own properties. */
  11350. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  11351. /**
  11352. * A specialized version of `baseIsEqual` for arrays and objects which performs
  11353. * deep comparisons and tracks traversed objects enabling objects with circular
  11354. * references to be compared.
  11355. *
  11356. * @private
  11357. * @param {Object} object The object to compare.
  11358. * @param {Object} other The other object to compare.
  11359. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11360. * @param {Function} customizer The function to customize comparisons.
  11361. * @param {Function} equalFunc The function to determine equivalents of values.
  11362. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  11363. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11364. */
  11365. function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
  11366. var objIsArr = isArray$7(object),
  11367. othIsArr = isArray$7(other),
  11368. objTag = objIsArr ? arrayTag : getTag(object),
  11369. othTag = othIsArr ? arrayTag : getTag(other);
  11370. objTag = objTag == argsTag ? objectTag : objTag;
  11371. othTag = othTag == argsTag ? objectTag : othTag;
  11372. var objIsObj = objTag == objectTag,
  11373. othIsObj = othTag == objectTag,
  11374. isSameTag = objTag == othTag;
  11375. if (isSameTag && isBuffer(object)) {
  11376. if (!isBuffer(other)) {
  11377. return false;
  11378. }
  11379. objIsArr = true;
  11380. objIsObj = false;
  11381. }
  11382. if (isSameTag && !objIsObj) {
  11383. stack || (stack = new Stack$1());
  11384. return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  11385. }
  11386. if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
  11387. var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, '__wrapped__'),
  11388. othIsWrapped = othIsObj && hasOwnProperty$2.call(other, '__wrapped__');
  11389. if (objIsWrapped || othIsWrapped) {
  11390. var objUnwrapped = objIsWrapped ? object.value() : object,
  11391. othUnwrapped = othIsWrapped ? other.value() : other;
  11392. stack || (stack = new Stack$1());
  11393. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  11394. }
  11395. }
  11396. if (!isSameTag) {
  11397. return false;
  11398. }
  11399. stack || (stack = new Stack$1());
  11400. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  11401. }
  11402. var _baseIsEqualDeep = baseIsEqualDeep$1;
  11403. var baseIsEqualDeep = _baseIsEqualDeep,
  11404. isObjectLike$1 = isObjectLike_1;
  11405. /**
  11406. * The base implementation of `_.isEqual` which supports partial comparisons
  11407. * and tracks traversed objects.
  11408. *
  11409. * @private
  11410. * @param {*} value The value to compare.
  11411. * @param {*} other The other value to compare.
  11412. * @param {boolean} bitmask The bitmask flags.
  11413. * 1 - Unordered comparison
  11414. * 2 - Partial comparison
  11415. * @param {Function} [customizer] The function to customize comparisons.
  11416. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  11417. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11418. */
  11419. function baseIsEqual$2(value, other, bitmask, customizer, stack) {
  11420. if (value === other) {
  11421. return true;
  11422. }
  11423. if (value == null || other == null || !isObjectLike$1(value) && !isObjectLike$1(other)) {
  11424. return value !== value && other !== other;
  11425. }
  11426. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
  11427. }
  11428. var _baseIsEqual = baseIsEqual$2;
  11429. var Stack = _Stack,
  11430. baseIsEqual$1 = _baseIsEqual;
  11431. /** Used to compose bitmasks for value comparisons. */
  11432. var COMPARE_PARTIAL_FLAG$1 = 1,
  11433. COMPARE_UNORDERED_FLAG$1 = 2;
  11434. /**
  11435. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  11436. *
  11437. * @private
  11438. * @param {Object} object The object to inspect.
  11439. * @param {Object} source The object of property values to match.
  11440. * @param {Array} matchData The property names, values, and compare flags to match.
  11441. * @param {Function} [customizer] The function to customize comparisons.
  11442. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11443. */
  11444. function baseIsMatch$1(object, source, matchData, customizer) {
  11445. var index = matchData.length,
  11446. length = index,
  11447. noCustomizer = !customizer;
  11448. if (object == null) {
  11449. return !length;
  11450. }
  11451. object = Object(object);
  11452. while (index--) {
  11453. var data = matchData[index];
  11454. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  11455. return false;
  11456. }
  11457. }
  11458. while (++index < length) {
  11459. data = matchData[index];
  11460. var key = data[0],
  11461. objValue = object[key],
  11462. srcValue = data[1];
  11463. if (noCustomizer && data[2]) {
  11464. if (objValue === undefined && !(key in object)) {
  11465. return false;
  11466. }
  11467. } else {
  11468. var stack = new Stack();
  11469. if (customizer) {
  11470. var result = customizer(objValue, srcValue, key, object, source, stack);
  11471. }
  11472. if (!(result === undefined ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
  11473. return false;
  11474. }
  11475. }
  11476. }
  11477. return true;
  11478. }
  11479. var _baseIsMatch = baseIsMatch$1;
  11480. var isObject$1 = isObject_1;
  11481. /**
  11482. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  11483. *
  11484. * @private
  11485. * @param {*} value The value to check.
  11486. * @returns {boolean} Returns `true` if `value` if suitable for strict
  11487. * equality comparisons, else `false`.
  11488. */
  11489. function isStrictComparable$2(value) {
  11490. return value === value && !isObject$1(value);
  11491. }
  11492. var _isStrictComparable = isStrictComparable$2;
  11493. var isStrictComparable$1 = _isStrictComparable,
  11494. keys = keys_1;
  11495. /**
  11496. * Gets the property names, values, and compare flags of `object`.
  11497. *
  11498. * @private
  11499. * @param {Object} object The object to query.
  11500. * @returns {Array} Returns the match data of `object`.
  11501. */
  11502. function getMatchData$1(object) {
  11503. var result = keys(object),
  11504. length = result.length;
  11505. while (length--) {
  11506. var key = result[length],
  11507. value = object[key];
  11508. result[length] = [key, value, isStrictComparable$1(value)];
  11509. }
  11510. return result;
  11511. }
  11512. var _getMatchData = getMatchData$1;
  11513. /**
  11514. * A specialized version of `matchesProperty` for source values suitable
  11515. * for strict equality comparisons, i.e. `===`.
  11516. *
  11517. * @private
  11518. * @param {string} key The key of the property to get.
  11519. * @param {*} srcValue The value to match.
  11520. * @returns {Function} Returns the new spec function.
  11521. */
  11522. function matchesStrictComparable$2(key, srcValue) {
  11523. return function (object) {
  11524. if (object == null) {
  11525. return false;
  11526. }
  11527. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  11528. };
  11529. }
  11530. var _matchesStrictComparable = matchesStrictComparable$2;
  11531. var baseIsMatch = _baseIsMatch,
  11532. getMatchData = _getMatchData,
  11533. matchesStrictComparable$1 = _matchesStrictComparable;
  11534. /**
  11535. * The base implementation of `_.matches` which doesn't clone `source`.
  11536. *
  11537. * @private
  11538. * @param {Object} source The object of property values to match.
  11539. * @returns {Function} Returns the new spec function.
  11540. */
  11541. function baseMatches$1(source) {
  11542. var matchData = getMatchData(source);
  11543. if (matchData.length == 1 && matchData[0][2]) {
  11544. return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
  11545. }
  11546. return function (object) {
  11547. return object === source || baseIsMatch(object, source, matchData);
  11548. };
  11549. }
  11550. var _baseMatches = baseMatches$1;
  11551. var baseGetTag = _baseGetTag,
  11552. isObjectLike = isObjectLike_1;
  11553. /** `Object#toString` result references. */
  11554. var symbolTag = '[object Symbol]';
  11555. /**
  11556. * Checks if `value` is classified as a `Symbol` primitive or object.
  11557. *
  11558. * @static
  11559. * @memberOf _
  11560. * @since 4.0.0
  11561. * @category Lang
  11562. * @param {*} value The value to check.
  11563. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  11564. * @example
  11565. *
  11566. * _.isSymbol(Symbol.iterator);
  11567. * // => true
  11568. *
  11569. * _.isSymbol('abc');
  11570. * // => false
  11571. */
  11572. function isSymbol$3(value) {
  11573. return typeof value == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
  11574. }
  11575. var isSymbol_1 = isSymbol$3;
  11576. var isArray$6 = isArray_1,
  11577. isSymbol$2 = isSymbol_1;
  11578. /** Used to match property names within property paths. */
  11579. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  11580. reIsPlainProp = /^\w*$/;
  11581. /**
  11582. * Checks if `value` is a property name and not a property path.
  11583. *
  11584. * @private
  11585. * @param {*} value The value to check.
  11586. * @param {Object} [object] The object to query keys on.
  11587. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  11588. */
  11589. function isKey$3(value, object) {
  11590. if (isArray$6(value)) {
  11591. return false;
  11592. }
  11593. var type = typeof value;
  11594. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
  11595. return true;
  11596. }
  11597. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  11598. }
  11599. var _isKey = isKey$3;
  11600. var MapCache = _MapCache;
  11601. /** Error message constants. */
  11602. var FUNC_ERROR_TEXT = 'Expected a function';
  11603. /**
  11604. * Creates a function that memoizes the result of `func`. If `resolver` is
  11605. * provided, it determines the cache key for storing the result based on the
  11606. * arguments provided to the memoized function. By default, the first argument
  11607. * provided to the memoized function is used as the map cache key. The `func`
  11608. * is invoked with the `this` binding of the memoized function.
  11609. *
  11610. * **Note:** The cache is exposed as the `cache` property on the memoized
  11611. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  11612. * constructor with one whose instances implement the
  11613. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  11614. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  11615. *
  11616. * @static
  11617. * @memberOf _
  11618. * @since 0.1.0
  11619. * @category Function
  11620. * @param {Function} func The function to have its output memoized.
  11621. * @param {Function} [resolver] The function to resolve the cache key.
  11622. * @returns {Function} Returns the new memoized function.
  11623. * @example
  11624. *
  11625. * var object = { 'a': 1, 'b': 2 };
  11626. * var other = { 'c': 3, 'd': 4 };
  11627. *
  11628. * var values = _.memoize(_.values);
  11629. * values(object);
  11630. * // => [1, 2]
  11631. *
  11632. * values(other);
  11633. * // => [3, 4]
  11634. *
  11635. * object.a = 2;
  11636. * values(object);
  11637. * // => [1, 2]
  11638. *
  11639. * // Modify the result cache.
  11640. * values.cache.set(object, ['a', 'b']);
  11641. * values(object);
  11642. * // => ['a', 'b']
  11643. *
  11644. * // Replace `_.memoize.Cache`.
  11645. * _.memoize.Cache = WeakMap;
  11646. */
  11647. function memoize$1(func, resolver) {
  11648. if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
  11649. throw new TypeError(FUNC_ERROR_TEXT);
  11650. }
  11651. var memoized = function () {
  11652. var args = arguments,
  11653. key = resolver ? resolver.apply(this, args) : args[0],
  11654. cache = memoized.cache;
  11655. if (cache.has(key)) {
  11656. return cache.get(key);
  11657. }
  11658. var result = func.apply(this, args);
  11659. memoized.cache = cache.set(key, result) || cache;
  11660. return result;
  11661. };
  11662. memoized.cache = new (memoize$1.Cache || MapCache)();
  11663. return memoized;
  11664. } // Expose `MapCache`.
  11665. memoize$1.Cache = MapCache;
  11666. var memoize_1 = memoize$1;
  11667. var memoize = memoize_1;
  11668. /** Used as the maximum memoize cache size. */
  11669. var MAX_MEMOIZE_SIZE = 500;
  11670. /**
  11671. * A specialized version of `_.memoize` which clears the memoized function's
  11672. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  11673. *
  11674. * @private
  11675. * @param {Function} func The function to have its output memoized.
  11676. * @returns {Function} Returns the new memoized function.
  11677. */
  11678. function memoizeCapped$1(func) {
  11679. var result = memoize(func, function (key) {
  11680. if (cache.size === MAX_MEMOIZE_SIZE) {
  11681. cache.clear();
  11682. }
  11683. return key;
  11684. });
  11685. var cache = result.cache;
  11686. return result;
  11687. }
  11688. var _memoizeCapped = memoizeCapped$1;
  11689. var memoizeCapped = _memoizeCapped;
  11690. /** Used to match property names within property paths. */
  11691. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  11692. /** Used to match backslashes in property paths. */
  11693. var reEscapeChar = /\\(\\)?/g;
  11694. /**
  11695. * Converts `string` to a property path array.
  11696. *
  11697. * @private
  11698. * @param {string} string The string to convert.
  11699. * @returns {Array} Returns the property path array.
  11700. */
  11701. var stringToPath$1 = memoizeCapped(function (string) {
  11702. var result = [];
  11703. if (string.charCodeAt(0) === 46
  11704. /* . */
  11705. ) {
  11706. result.push('');
  11707. }
  11708. string.replace(rePropName, function (match, number, quote, subString) {
  11709. result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
  11710. });
  11711. return result;
  11712. });
  11713. var _stringToPath = stringToPath$1;
  11714. /**
  11715. * A specialized version of `_.map` for arrays without support for iteratee
  11716. * shorthands.
  11717. *
  11718. * @private
  11719. * @param {Array} [array] The array to iterate over.
  11720. * @param {Function} iteratee The function invoked per iteration.
  11721. * @returns {Array} Returns the new mapped array.
  11722. */
  11723. function arrayMap$1(array, iteratee) {
  11724. var index = -1,
  11725. length = array == null ? 0 : array.length,
  11726. result = Array(length);
  11727. while (++index < length) {
  11728. result[index] = iteratee(array[index], index, array);
  11729. }
  11730. return result;
  11731. }
  11732. var _arrayMap = arrayMap$1;
  11733. var Symbol$2 = _Symbol,
  11734. arrayMap = _arrayMap,
  11735. isArray$5 = isArray_1,
  11736. isSymbol$1 = isSymbol_1;
  11737. /** Used as references for various `Number` constants. */
  11738. var INFINITY$1 = 1 / 0;
  11739. /** Used to convert symbols to primitives and strings. */
  11740. var symbolProto = Symbol$2 ? Symbol$2.prototype : undefined,
  11741. symbolToString = symbolProto ? symbolProto.toString : undefined;
  11742. /**
  11743. * The base implementation of `_.toString` which doesn't convert nullish
  11744. * values to empty strings.
  11745. *
  11746. * @private
  11747. * @param {*} value The value to process.
  11748. * @returns {string} Returns the string.
  11749. */
  11750. function baseToString$1(value) {
  11751. // Exit early for strings to avoid a performance hit in some environments.
  11752. if (typeof value == 'string') {
  11753. return value;
  11754. }
  11755. if (isArray$5(value)) {
  11756. // Recursively convert values (susceptible to call stack limits).
  11757. return arrayMap(value, baseToString$1) + '';
  11758. }
  11759. if (isSymbol$1(value)) {
  11760. return symbolToString ? symbolToString.call(value) : '';
  11761. }
  11762. var result = value + '';
  11763. return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
  11764. }
  11765. var _baseToString = baseToString$1;
  11766. var baseToString = _baseToString;
  11767. /**
  11768. * Converts `value` to a string. An empty string is returned for `null`
  11769. * and `undefined` values. The sign of `-0` is preserved.
  11770. *
  11771. * @static
  11772. * @memberOf _
  11773. * @since 4.0.0
  11774. * @category Lang
  11775. * @param {*} value The value to convert.
  11776. * @returns {string} Returns the converted string.
  11777. * @example
  11778. *
  11779. * _.toString(null);
  11780. * // => ''
  11781. *
  11782. * _.toString(-0);
  11783. * // => '-0'
  11784. *
  11785. * _.toString([1, 2, 3]);
  11786. * // => '1,2,3'
  11787. */
  11788. function toString$1(value) {
  11789. return value == null ? '' : baseToString(value);
  11790. }
  11791. var toString_1 = toString$1;
  11792. var isArray$4 = isArray_1,
  11793. isKey$2 = _isKey,
  11794. stringToPath = _stringToPath,
  11795. toString = toString_1;
  11796. /**
  11797. * Casts `value` to a path array if it's not one.
  11798. *
  11799. * @private
  11800. * @param {*} value The value to inspect.
  11801. * @param {Object} [object] The object to query keys on.
  11802. * @returns {Array} Returns the cast property path array.
  11803. */
  11804. function castPath$4(value, object) {
  11805. if (isArray$4(value)) {
  11806. return value;
  11807. }
  11808. return isKey$2(value, object) ? [value] : stringToPath(toString(value));
  11809. }
  11810. var _castPath = castPath$4;
  11811. var isSymbol = isSymbol_1;
  11812. /** Used as references for various `Number` constants. */
  11813. var INFINITY = 1 / 0;
  11814. /**
  11815. * Converts `value` to a string key if it's not a string or symbol.
  11816. *
  11817. * @private
  11818. * @param {*} value The value to inspect.
  11819. * @returns {string|symbol} Returns the key.
  11820. */
  11821. function toKey$5(value) {
  11822. if (typeof value == 'string' || isSymbol(value)) {
  11823. return value;
  11824. }
  11825. var result = value + '';
  11826. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  11827. }
  11828. var _toKey = toKey$5;
  11829. var castPath$3 = _castPath,
  11830. toKey$4 = _toKey;
  11831. /**
  11832. * The base implementation of `_.get` without support for default values.
  11833. *
  11834. * @private
  11835. * @param {Object} object The object to query.
  11836. * @param {Array|string} path The path of the property to get.
  11837. * @returns {*} Returns the resolved value.
  11838. */
  11839. function baseGet$3(object, path) {
  11840. path = castPath$3(path, object);
  11841. var index = 0,
  11842. length = path.length;
  11843. while (object != null && index < length) {
  11844. object = object[toKey$4(path[index++])];
  11845. }
  11846. return index && index == length ? object : undefined;
  11847. }
  11848. var _baseGet = baseGet$3;
  11849. var baseGet$2 = _baseGet;
  11850. /**
  11851. * Gets the value at `path` of `object`. If the resolved value is
  11852. * `undefined`, the `defaultValue` is returned in its place.
  11853. *
  11854. * @static
  11855. * @memberOf _
  11856. * @since 3.7.0
  11857. * @category Object
  11858. * @param {Object} object The object to query.
  11859. * @param {Array|string} path The path of the property to get.
  11860. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  11861. * @returns {*} Returns the resolved value.
  11862. * @example
  11863. *
  11864. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  11865. *
  11866. * _.get(object, 'a[0].b.c');
  11867. * // => 3
  11868. *
  11869. * _.get(object, ['a', '0', 'b', 'c']);
  11870. * // => 3
  11871. *
  11872. * _.get(object, 'a.b.c', 'default');
  11873. * // => 'default'
  11874. */
  11875. function get$1(object, path, defaultValue) {
  11876. var result = object == null ? undefined : baseGet$2(object, path);
  11877. return result === undefined ? defaultValue : result;
  11878. }
  11879. var get_1 = get$1;
  11880. /**
  11881. * The base implementation of `_.hasIn` without support for deep paths.
  11882. *
  11883. * @private
  11884. * @param {Object} [object] The object to query.
  11885. * @param {Array|string} key The key to check.
  11886. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  11887. */
  11888. function baseHasIn$1(object, key) {
  11889. return object != null && key in Object(object);
  11890. }
  11891. var _baseHasIn = baseHasIn$1;
  11892. var castPath$2 = _castPath,
  11893. isArguments$1 = isArguments_1,
  11894. isArray$3 = isArray_1,
  11895. isIndex$1 = _isIndex,
  11896. isLength = isLength_1,
  11897. toKey$3 = _toKey;
  11898. /**
  11899. * Checks if `path` exists on `object`.
  11900. *
  11901. * @private
  11902. * @param {Object} object The object to query.
  11903. * @param {Array|string} path The path to check.
  11904. * @param {Function} hasFunc The function to check properties.
  11905. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  11906. */
  11907. function hasPath$1(object, path, hasFunc) {
  11908. path = castPath$2(path, object);
  11909. var index = -1,
  11910. length = path.length,
  11911. result = false;
  11912. while (++index < length) {
  11913. var key = toKey$3(path[index]);
  11914. if (!(result = object != null && hasFunc(object, key))) {
  11915. break;
  11916. }
  11917. object = object[key];
  11918. }
  11919. if (result || ++index != length) {
  11920. return result;
  11921. }
  11922. length = object == null ? 0 : object.length;
  11923. return !!length && isLength(length) && isIndex$1(key, length) && (isArray$3(object) || isArguments$1(object));
  11924. }
  11925. var _hasPath = hasPath$1;
  11926. var baseHasIn = _baseHasIn,
  11927. hasPath = _hasPath;
  11928. /**
  11929. * Checks if `path` is a direct or inherited property of `object`.
  11930. *
  11931. * @static
  11932. * @memberOf _
  11933. * @since 4.0.0
  11934. * @category Object
  11935. * @param {Object} object The object to query.
  11936. * @param {Array|string} path The path to check.
  11937. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  11938. * @example
  11939. *
  11940. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  11941. *
  11942. * _.hasIn(object, 'a');
  11943. * // => true
  11944. *
  11945. * _.hasIn(object, 'a.b');
  11946. * // => true
  11947. *
  11948. * _.hasIn(object, ['a', 'b']);
  11949. * // => true
  11950. *
  11951. * _.hasIn(object, 'b');
  11952. * // => false
  11953. */
  11954. function hasIn$2(object, path) {
  11955. return object != null && hasPath(object, path, baseHasIn);
  11956. }
  11957. var hasIn_1 = hasIn$2;
  11958. var baseIsEqual = _baseIsEqual,
  11959. get = get_1,
  11960. hasIn$1 = hasIn_1,
  11961. isKey$1 = _isKey,
  11962. isStrictComparable = _isStrictComparable,
  11963. matchesStrictComparable = _matchesStrictComparable,
  11964. toKey$2 = _toKey;
  11965. /** Used to compose bitmasks for value comparisons. */
  11966. var COMPARE_PARTIAL_FLAG = 1,
  11967. COMPARE_UNORDERED_FLAG = 2;
  11968. /**
  11969. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  11970. *
  11971. * @private
  11972. * @param {string} path The path of the property to get.
  11973. * @param {*} srcValue The value to match.
  11974. * @returns {Function} Returns the new spec function.
  11975. */
  11976. function baseMatchesProperty$1(path, srcValue) {
  11977. if (isKey$1(path) && isStrictComparable(srcValue)) {
  11978. return matchesStrictComparable(toKey$2(path), srcValue);
  11979. }
  11980. return function (object) {
  11981. var objValue = get(object, path);
  11982. return objValue === undefined && objValue === srcValue ? hasIn$1(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  11983. };
  11984. }
  11985. var _baseMatchesProperty = baseMatchesProperty$1;
  11986. /**
  11987. * This method returns the first argument it receives.
  11988. *
  11989. * @static
  11990. * @since 0.1.0
  11991. * @memberOf _
  11992. * @category Util
  11993. * @param {*} value Any value.
  11994. * @returns {*} Returns `value`.
  11995. * @example
  11996. *
  11997. * var object = { 'a': 1 };
  11998. *
  11999. * console.log(_.identity(object) === object);
  12000. * // => true
  12001. */
  12002. function identity$2(value) {
  12003. return value;
  12004. }
  12005. var identity_1 = identity$2;
  12006. /**
  12007. * The base implementation of `_.property` without support for deep paths.
  12008. *
  12009. * @private
  12010. * @param {string} key The key of the property to get.
  12011. * @returns {Function} Returns the new accessor function.
  12012. */
  12013. function baseProperty$1(key) {
  12014. return function (object) {
  12015. return object == null ? undefined : object[key];
  12016. };
  12017. }
  12018. var _baseProperty = baseProperty$1;
  12019. var baseGet$1 = _baseGet;
  12020. /**
  12021. * A specialized version of `baseProperty` which supports deep paths.
  12022. *
  12023. * @private
  12024. * @param {Array|string} path The path of the property to get.
  12025. * @returns {Function} Returns the new accessor function.
  12026. */
  12027. function basePropertyDeep$1(path) {
  12028. return function (object) {
  12029. return baseGet$1(object, path);
  12030. };
  12031. }
  12032. var _basePropertyDeep = basePropertyDeep$1;
  12033. var baseProperty = _baseProperty,
  12034. basePropertyDeep = _basePropertyDeep,
  12035. isKey = _isKey,
  12036. toKey$1 = _toKey;
  12037. /**
  12038. * Creates a function that returns the value at `path` of a given object.
  12039. *
  12040. * @static
  12041. * @memberOf _
  12042. * @since 2.4.0
  12043. * @category Util
  12044. * @param {Array|string} path The path of the property to get.
  12045. * @returns {Function} Returns the new accessor function.
  12046. * @example
  12047. *
  12048. * var objects = [
  12049. * { 'a': { 'b': 2 } },
  12050. * { 'a': { 'b': 1 } }
  12051. * ];
  12052. *
  12053. * _.map(objects, _.property('a.b'));
  12054. * // => [2, 1]
  12055. *
  12056. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  12057. * // => [1, 2]
  12058. */
  12059. function property$1(path) {
  12060. return isKey(path) ? baseProperty(toKey$1(path)) : basePropertyDeep(path);
  12061. }
  12062. var property_1 = property$1;
  12063. var baseMatches = _baseMatches,
  12064. baseMatchesProperty = _baseMatchesProperty,
  12065. identity$1 = identity_1,
  12066. isArray$2 = isArray_1,
  12067. property = property_1;
  12068. /**
  12069. * The base implementation of `_.iteratee`.
  12070. *
  12071. * @private
  12072. * @param {*} [value=_.identity] The value to convert to an iteratee.
  12073. * @returns {Function} Returns the iteratee.
  12074. */
  12075. function baseIteratee$1(value) {
  12076. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  12077. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  12078. if (typeof value == 'function') {
  12079. return value;
  12080. }
  12081. if (value == null) {
  12082. return identity$1;
  12083. }
  12084. if (typeof value == 'object') {
  12085. return isArray$2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  12086. }
  12087. return property(value);
  12088. }
  12089. var _baseIteratee = baseIteratee$1;
  12090. var arrayAggregator = _arrayAggregator,
  12091. baseAggregator = _baseAggregator,
  12092. baseIteratee = _baseIteratee,
  12093. isArray$1 = isArray_1;
  12094. /**
  12095. * Creates a function like `_.groupBy`.
  12096. *
  12097. * @private
  12098. * @param {Function} setter The function to set accumulator values.
  12099. * @param {Function} [initializer] The accumulator object initializer.
  12100. * @returns {Function} Returns the new aggregator function.
  12101. */
  12102. function createAggregator$2(setter, initializer) {
  12103. return function (collection, iteratee) {
  12104. var func = isArray$1(collection) ? arrayAggregator : baseAggregator,
  12105. accumulator = initializer ? initializer() : {};
  12106. return func(collection, setter, baseIteratee(iteratee), accumulator);
  12107. };
  12108. }
  12109. var _createAggregator = createAggregator$2;
  12110. var createAggregator$1 = _createAggregator;
  12111. /**
  12112. * Creates an array of elements split into two groups, the first of which
  12113. * contains elements `predicate` returns truthy for, the second of which
  12114. * contains elements `predicate` returns falsey for. The predicate is
  12115. * invoked with one argument: (value).
  12116. *
  12117. * @static
  12118. * @memberOf _
  12119. * @since 3.0.0
  12120. * @category Collection
  12121. * @param {Array|Object} collection The collection to iterate over.
  12122. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12123. * @returns {Array} Returns the array of grouped elements.
  12124. * @example
  12125. *
  12126. * var users = [
  12127. * { 'user': 'barney', 'age': 36, 'active': false },
  12128. * { 'user': 'fred', 'age': 40, 'active': true },
  12129. * { 'user': 'pebbles', 'age': 1, 'active': false }
  12130. * ];
  12131. *
  12132. * _.partition(users, function(o) { return o.active; });
  12133. * // => objects for [['fred'], ['barney', 'pebbles']]
  12134. *
  12135. * // The `_.matches` iteratee shorthand.
  12136. * _.partition(users, { 'age': 1, 'active': false });
  12137. * // => objects for [['pebbles'], ['barney', 'fred']]
  12138. *
  12139. * // The `_.matchesProperty` iteratee shorthand.
  12140. * _.partition(users, ['active', false]);
  12141. * // => objects for [['barney', 'pebbles'], ['fred']]
  12142. *
  12143. * // The `_.property` iteratee shorthand.
  12144. * _.partition(users, 'active');
  12145. * // => objects for [['fred'], ['barney', 'pebbles']]
  12146. */
  12147. var partition$1 = createAggregator$1(function (result, value, key) {
  12148. result[key ? 0 : 1].push(value);
  12149. }, function () {
  12150. return [[], []];
  12151. });
  12152. var partition_1 = partition$1;
  12153. const partition = partition_1;
  12154. var createMinimistOptions$2 = function createMinimistOptions(detailedOptions) {
  12155. const [boolean, string] = partition(detailedOptions, ({
  12156. type
  12157. }) => type === "boolean").map(detailedOptions => detailedOptions.flatMap(({
  12158. name,
  12159. alias
  12160. }) => alias ? [name, alias] : [name]));
  12161. const defaults = Object.fromEntries(detailedOptions.filter(option => !option.deprecated && (!option.forwardToApi || option.name === "plugin" || option.name === "plugin-search-dir") && option.default !== undefined).map(option => [option.name, option.default]));
  12162. return {
  12163. // we use vnopts' AliasSchema to handle aliases for better error messages
  12164. alias: {},
  12165. boolean,
  12166. string,
  12167. default: defaults
  12168. };
  12169. };
  12170. const dashify$1 = dashify$2; // eslint-disable-next-line no-restricted-modules
  12171. const prettier$5 = require$$3;
  12172. const minimist$1 = minimist_1;
  12173. const {
  12174. optionsNormalizer
  12175. } = prettierInternal;
  12176. const createMinimistOptions$1 = createMinimistOptions$2;
  12177. function getOptions(argv, detailedOptions) {
  12178. return Object.fromEntries(detailedOptions.filter(({
  12179. forwardToApi
  12180. }) => forwardToApi).map(({
  12181. forwardToApi,
  12182. name
  12183. }) => [forwardToApi, argv[name]]));
  12184. }
  12185. function cliifyOptions(object, apiDetailedOptionMap) {
  12186. return Object.fromEntries(Object.entries(object || {}).map(([key, value]) => {
  12187. const apiOption = apiDetailedOptionMap[key];
  12188. const cliKey = apiOption ? apiOption.name : key;
  12189. return [dashify$1(cliKey), value];
  12190. }));
  12191. }
  12192. function createApiDetailedOptionMap(detailedOptions) {
  12193. return Object.fromEntries(detailedOptions.filter(option => option.forwardToApi && option.forwardToApi !== option.name).map(option => [option.forwardToApi, option]));
  12194. }
  12195. function parseArgsToOptions(context, overrideDefaults) {
  12196. const minimistOptions = createMinimistOptions$1(context.detailedOptions);
  12197. const apiDetailedOptionMap = createApiDetailedOptionMap(context.detailedOptions);
  12198. return getOptions(optionsNormalizer.normalizeCliOptions(minimist$1(context.rawArguments, {
  12199. string: minimistOptions.string,
  12200. boolean: minimistOptions.boolean,
  12201. default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
  12202. }), context.detailedOptions, {
  12203. logger: false
  12204. }), context.detailedOptions);
  12205. }
  12206. async function getOptionsOrDie(context, filePath) {
  12207. try {
  12208. if (context.argv.config === false) {
  12209. context.logger.debug("'--no-config' option found, skip loading config file.");
  12210. return null;
  12211. }
  12212. context.logger.debug(context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`);
  12213. const options = await prettier$5.resolveConfig(filePath, {
  12214. editorconfig: context.argv.editorconfig,
  12215. config: context.argv.config
  12216. });
  12217. context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
  12218. return options;
  12219. } catch (error) {
  12220. context.logger.error(`Invalid configuration file \`${filePath}\`: ` + error.message);
  12221. process.exit(2);
  12222. }
  12223. }
  12224. function applyConfigPrecedence(context, options) {
  12225. try {
  12226. switch (context.argv["config-precedence"]) {
  12227. case "cli-override":
  12228. return parseArgsToOptions(context, options);
  12229. case "file-override":
  12230. return Object.assign(Object.assign({}, parseArgsToOptions(context)), options);
  12231. case "prefer-file":
  12232. return options || parseArgsToOptions(context);
  12233. }
  12234. } catch (error) {
  12235. /* istanbul ignore next */
  12236. context.logger.error(error.toString());
  12237. /* istanbul ignore next */
  12238. process.exit(2);
  12239. }
  12240. }
  12241. async function getOptionsForFile$1(context, filepath) {
  12242. const options = await getOptionsOrDie(context, filepath);
  12243. const hasPlugins = options && options.plugins;
  12244. if (hasPlugins) {
  12245. context.pushContextPlugins(options.plugins);
  12246. }
  12247. const appliedOptions = Object.assign({
  12248. filepath
  12249. }, applyConfigPrecedence(context, options && optionsNormalizer.normalizeApiOptions(options, context.supportOptions, {
  12250. logger: context.logger
  12251. })));
  12252. context.logger.debug(`applied config-precedence (${context.argv["config-precedence"]}): ` + `${JSON.stringify(appliedOptions)}`);
  12253. if (hasPlugins) {
  12254. context.popContextPlugins();
  12255. }
  12256. return appliedOptions;
  12257. }
  12258. var option = {
  12259. getOptionsForFile: getOptionsForFile$1,
  12260. createMinimistOptions: createMinimistOptions$1
  12261. };
  12262. const {
  12263. isCI
  12264. } = require$$4; // Some CI pipelines incorrectly report process.stdout.isTTY status,
  12265. // which causes unwanted lines in the output. An additional check for isCI() helps.
  12266. // See https://github.com/prettier/prettier/issues/5801
  12267. var isTty = function isTTY() {
  12268. return process.stdout.isTTY && !isCI();
  12269. };
  12270. var lib$1 = {};
  12271. var base = {};
  12272. /*istanbul ignore start*/
  12273. (function (exports) {
  12274. Object.defineProperty(exports, "__esModule", {
  12275. value: true
  12276. });
  12277. exports["default"] = Diff;
  12278. /*istanbul ignore end*/
  12279. function Diff() {}
  12280. Diff.prototype = {
  12281. /*istanbul ignore start*/
  12282. /*istanbul ignore end*/
  12283. diff: function diff(oldString, newString) {
  12284. /*istanbul ignore start*/
  12285. var
  12286. /*istanbul ignore end*/
  12287. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12288. var callback = options.callback;
  12289. if (typeof options === 'function') {
  12290. callback = options;
  12291. options = {};
  12292. }
  12293. this.options = options;
  12294. var self = this;
  12295. function done(value) {
  12296. if (callback) {
  12297. setTimeout(function () {
  12298. callback(undefined, value);
  12299. }, 0);
  12300. return true;
  12301. } else {
  12302. return value;
  12303. }
  12304. } // Allow subclasses to massage the input prior to running
  12305. oldString = this.castInput(oldString);
  12306. newString = this.castInput(newString);
  12307. oldString = this.removeEmpty(this.tokenize(oldString));
  12308. newString = this.removeEmpty(this.tokenize(newString));
  12309. var newLen = newString.length,
  12310. oldLen = oldString.length;
  12311. var editLength = 1;
  12312. var maxEditLength = newLen + oldLen;
  12313. var bestPath = [{
  12314. newPos: -1,
  12315. components: []
  12316. }]; // Seed editLength = 0, i.e. the content starts with the same values
  12317. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  12318. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  12319. // Identity per the equality and tokenizer
  12320. return done([{
  12321. value: this.join(newString),
  12322. count: newString.length
  12323. }]);
  12324. } // Main worker method. checks all permutations of a given edit length for acceptance.
  12325. function execEditLength() {
  12326. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  12327. var basePath =
  12328. /*istanbul ignore start*/
  12329. void 0
  12330. /*istanbul ignore end*/
  12331. ;
  12332. var addPath = bestPath[diagonalPath - 1],
  12333. removePath = bestPath[diagonalPath + 1],
  12334. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  12335. if (addPath) {
  12336. // No one else is going to attempt to use this value, clear it
  12337. bestPath[diagonalPath - 1] = undefined;
  12338. }
  12339. var canAdd = addPath && addPath.newPos + 1 < newLen,
  12340. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  12341. if (!canAdd && !canRemove) {
  12342. // If this path is a terminal then prune
  12343. bestPath[diagonalPath] = undefined;
  12344. continue;
  12345. } // Select the diagonal that we want to branch from. We select the prior
  12346. // path whose position in the new string is the farthest from the origin
  12347. // and does not pass the bounds of the diff graph
  12348. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  12349. basePath = clonePath(removePath);
  12350. self.pushComponent(basePath.components, undefined, true);
  12351. } else {
  12352. basePath = addPath; // No need to clone, we've pulled it from the list
  12353. basePath.newPos++;
  12354. self.pushComponent(basePath.components, true, undefined);
  12355. }
  12356. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  12357. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  12358. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  12359. } else {
  12360. // Otherwise track this path as a potential candidate and continue.
  12361. bestPath[diagonalPath] = basePath;
  12362. }
  12363. }
  12364. editLength++;
  12365. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  12366. // sync and async mode which is never fun. Loops over execEditLength until a value
  12367. // is produced.
  12368. if (callback) {
  12369. (function exec() {
  12370. setTimeout(function () {
  12371. // This should not happen, but we want to be safe.
  12372. /* istanbul ignore next */
  12373. if (editLength > maxEditLength) {
  12374. return callback();
  12375. }
  12376. if (!execEditLength()) {
  12377. exec();
  12378. }
  12379. }, 0);
  12380. })();
  12381. } else {
  12382. while (editLength <= maxEditLength) {
  12383. var ret = execEditLength();
  12384. if (ret) {
  12385. return ret;
  12386. }
  12387. }
  12388. }
  12389. },
  12390. /*istanbul ignore start*/
  12391. /*istanbul ignore end*/
  12392. pushComponent: function pushComponent(components, added, removed) {
  12393. var last = components[components.length - 1];
  12394. if (last && last.added === added && last.removed === removed) {
  12395. // We need to clone here as the component clone operation is just
  12396. // as shallow array clone
  12397. components[components.length - 1] = {
  12398. count: last.count + 1,
  12399. added: added,
  12400. removed: removed
  12401. };
  12402. } else {
  12403. components.push({
  12404. count: 1,
  12405. added: added,
  12406. removed: removed
  12407. });
  12408. }
  12409. },
  12410. /*istanbul ignore start*/
  12411. /*istanbul ignore end*/
  12412. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  12413. var newLen = newString.length,
  12414. oldLen = oldString.length,
  12415. newPos = basePath.newPos,
  12416. oldPos = newPos - diagonalPath,
  12417. commonCount = 0;
  12418. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  12419. newPos++;
  12420. oldPos++;
  12421. commonCount++;
  12422. }
  12423. if (commonCount) {
  12424. basePath.components.push({
  12425. count: commonCount
  12426. });
  12427. }
  12428. basePath.newPos = newPos;
  12429. return oldPos;
  12430. },
  12431. /*istanbul ignore start*/
  12432. /*istanbul ignore end*/
  12433. equals: function equals(left, right) {
  12434. if (this.options.comparator) {
  12435. return this.options.comparator(left, right);
  12436. } else {
  12437. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  12438. }
  12439. },
  12440. /*istanbul ignore start*/
  12441. /*istanbul ignore end*/
  12442. removeEmpty: function removeEmpty(array) {
  12443. var ret = [];
  12444. for (var i = 0; i < array.length; i++) {
  12445. if (array[i]) {
  12446. ret.push(array[i]);
  12447. }
  12448. }
  12449. return ret;
  12450. },
  12451. /*istanbul ignore start*/
  12452. /*istanbul ignore end*/
  12453. castInput: function castInput(value) {
  12454. return value;
  12455. },
  12456. /*istanbul ignore start*/
  12457. /*istanbul ignore end*/
  12458. tokenize: function tokenize(value) {
  12459. return value.split('');
  12460. },
  12461. /*istanbul ignore start*/
  12462. /*istanbul ignore end*/
  12463. join: function join(chars) {
  12464. return chars.join('');
  12465. }
  12466. };
  12467. function buildValues(diff, components, newString, oldString, useLongestToken) {
  12468. var componentPos = 0,
  12469. componentLen = components.length,
  12470. newPos = 0,
  12471. oldPos = 0;
  12472. for (; componentPos < componentLen; componentPos++) {
  12473. var component = components[componentPos];
  12474. if (!component.removed) {
  12475. if (!component.added && useLongestToken) {
  12476. var value = newString.slice(newPos, newPos + component.count);
  12477. value = value.map(function (value, i) {
  12478. var oldValue = oldString[oldPos + i];
  12479. return oldValue.length > value.length ? oldValue : value;
  12480. });
  12481. component.value = diff.join(value);
  12482. } else {
  12483. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  12484. }
  12485. newPos += component.count; // Common case
  12486. if (!component.added) {
  12487. oldPos += component.count;
  12488. }
  12489. } else {
  12490. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  12491. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  12492. // The diffing algorithm is tied to add then remove output and this is the simplest
  12493. // route to get the desired output with minimal overhead.
  12494. if (componentPos && components[componentPos - 1].added) {
  12495. var tmp = components[componentPos - 1];
  12496. components[componentPos - 1] = components[componentPos];
  12497. components[componentPos] = tmp;
  12498. }
  12499. }
  12500. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  12501. // For this case we merge the terminal into the prior string and drop the change.
  12502. // This is only available for string mode.
  12503. var lastComponent = components[componentLen - 1];
  12504. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  12505. components[componentLen - 2].value += lastComponent.value;
  12506. components.pop();
  12507. }
  12508. return components;
  12509. }
  12510. function clonePath(path) {
  12511. return {
  12512. newPos: path.newPos,
  12513. components: path.components.slice(0)
  12514. };
  12515. }
  12516. })(base);
  12517. var character = {};
  12518. /*istanbul ignore start*/
  12519. Object.defineProperty(character, "__esModule", {
  12520. value: true
  12521. });
  12522. character.diffChars = diffChars;
  12523. character.characterDiff = void 0;
  12524. /*istanbul ignore end*/
  12525. var
  12526. /*istanbul ignore start*/
  12527. _base$6 = _interopRequireDefault$7(base)
  12528. /*istanbul ignore end*/
  12529. ;
  12530. /*istanbul ignore start*/
  12531. function _interopRequireDefault$7(obj) {
  12532. return obj && obj.__esModule ? obj : {
  12533. "default": obj
  12534. };
  12535. }
  12536. /*istanbul ignore end*/
  12537. var characterDiff = new
  12538. /*istanbul ignore start*/
  12539. _base$6
  12540. /*istanbul ignore end*/
  12541. [
  12542. /*istanbul ignore start*/
  12543. "default"
  12544. /*istanbul ignore end*/
  12545. ]();
  12546. /*istanbul ignore start*/
  12547. character.characterDiff = characterDiff;
  12548. /*istanbul ignore end*/
  12549. function diffChars(oldStr, newStr, options) {
  12550. return characterDiff.diff(oldStr, newStr, options);
  12551. }
  12552. var word = {};
  12553. var params = {};
  12554. /*istanbul ignore start*/
  12555. Object.defineProperty(params, "__esModule", {
  12556. value: true
  12557. });
  12558. params.generateOptions = generateOptions;
  12559. /*istanbul ignore end*/
  12560. function generateOptions(options, defaults) {
  12561. if (typeof options === 'function') {
  12562. defaults.callback = options;
  12563. } else if (options) {
  12564. for (var name in options) {
  12565. /* istanbul ignore else */
  12566. if (options.hasOwnProperty(name)) {
  12567. defaults[name] = options[name];
  12568. }
  12569. }
  12570. }
  12571. return defaults;
  12572. }
  12573. /*istanbul ignore start*/
  12574. Object.defineProperty(word, "__esModule", {
  12575. value: true
  12576. });
  12577. word.diffWords = diffWords;
  12578. word.diffWordsWithSpace = diffWordsWithSpace;
  12579. word.wordDiff = void 0;
  12580. /*istanbul ignore end*/
  12581. var
  12582. /*istanbul ignore start*/
  12583. _base$5 = _interopRequireDefault$6(base)
  12584. /*istanbul ignore end*/
  12585. ;
  12586. var
  12587. /*istanbul ignore start*/
  12588. _params$1 = params
  12589. /*istanbul ignore end*/
  12590. ;
  12591. /*istanbul ignore start*/
  12592. function _interopRequireDefault$6(obj) {
  12593. return obj && obj.__esModule ? obj : {
  12594. "default": obj
  12595. };
  12596. }
  12597. /*istanbul ignore end*/
  12598. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  12599. //
  12600. // Ranges and exceptions:
  12601. // Latin-1 Supplement, 0080–00FF
  12602. // - U+00D7 × Multiplication sign
  12603. // - U+00F7 ÷ Division sign
  12604. // Latin Extended-A, 0100–017F
  12605. // Latin Extended-B, 0180–024F
  12606. // IPA Extensions, 0250–02AF
  12607. // Spacing Modifier Letters, 02B0–02FF
  12608. // - U+02C7 ˇ &#711; Caron
  12609. // - U+02D8 ˘ &#728; Breve
  12610. // - U+02D9 ˙ &#729; Dot Above
  12611. // - U+02DA ˚ &#730; Ring Above
  12612. // - U+02DB ˛ &#731; Ogonek
  12613. // - U+02DC ˜ &#732; Small Tilde
  12614. // - U+02DD ˝ &#733; Double Acute Accent
  12615. // Latin Extended Additional, 1E00–1EFF
  12616. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  12617. var reWhitespace = /\S/;
  12618. var wordDiff = new
  12619. /*istanbul ignore start*/
  12620. _base$5
  12621. /*istanbul ignore end*/
  12622. [
  12623. /*istanbul ignore start*/
  12624. "default"
  12625. /*istanbul ignore end*/
  12626. ]();
  12627. /*istanbul ignore start*/
  12628. word.wordDiff = wordDiff;
  12629. /*istanbul ignore end*/
  12630. wordDiff.equals = function (left, right) {
  12631. if (this.options.ignoreCase) {
  12632. left = left.toLowerCase();
  12633. right = right.toLowerCase();
  12634. }
  12635. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  12636. };
  12637. wordDiff.tokenize = function (value) {
  12638. // All whitespace symbols except newline group into one token, each newline - in separate token
  12639. var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  12640. for (var i = 0; i < tokens.length - 1; i++) {
  12641. // If we have an empty string in the next field and we have only word chars before and after, merge
  12642. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  12643. tokens[i] += tokens[i + 2];
  12644. tokens.splice(i + 1, 2);
  12645. i--;
  12646. }
  12647. }
  12648. return tokens;
  12649. };
  12650. function diffWords(oldStr, newStr, options) {
  12651. options =
  12652. /*istanbul ignore start*/
  12653. (/*istanbul ignore end*/
  12654. /*istanbul ignore start*/
  12655. 0, _params$1
  12656. /*istanbul ignore end*/
  12657. .
  12658. /*istanbul ignore start*/
  12659. generateOptions
  12660. /*istanbul ignore end*/
  12661. )(options, {
  12662. ignoreWhitespace: true
  12663. });
  12664. return wordDiff.diff(oldStr, newStr, options);
  12665. }
  12666. function diffWordsWithSpace(oldStr, newStr, options) {
  12667. return wordDiff.diff(oldStr, newStr, options);
  12668. }
  12669. var line = {};
  12670. /*istanbul ignore start*/
  12671. Object.defineProperty(line, "__esModule", {
  12672. value: true
  12673. });
  12674. line.diffLines = diffLines;
  12675. line.diffTrimmedLines = diffTrimmedLines;
  12676. line.lineDiff = void 0;
  12677. /*istanbul ignore end*/
  12678. var
  12679. /*istanbul ignore start*/
  12680. _base$4 = _interopRequireDefault$5(base)
  12681. /*istanbul ignore end*/
  12682. ;
  12683. var
  12684. /*istanbul ignore start*/
  12685. _params = params
  12686. /*istanbul ignore end*/
  12687. ;
  12688. /*istanbul ignore start*/
  12689. function _interopRequireDefault$5(obj) {
  12690. return obj && obj.__esModule ? obj : {
  12691. "default": obj
  12692. };
  12693. }
  12694. /*istanbul ignore end*/
  12695. var lineDiff = new
  12696. /*istanbul ignore start*/
  12697. _base$4
  12698. /*istanbul ignore end*/
  12699. [
  12700. /*istanbul ignore start*/
  12701. "default"
  12702. /*istanbul ignore end*/
  12703. ]();
  12704. /*istanbul ignore start*/
  12705. line.lineDiff = lineDiff;
  12706. /*istanbul ignore end*/
  12707. lineDiff.tokenize = function (value) {
  12708. var retLines = [],
  12709. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  12710. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  12711. linesAndNewlines.pop();
  12712. } // Merge the content and line separators into single tokens
  12713. for (var i = 0; i < linesAndNewlines.length; i++) {
  12714. var line = linesAndNewlines[i];
  12715. if (i % 2 && !this.options.newlineIsToken) {
  12716. retLines[retLines.length - 1] += line;
  12717. } else {
  12718. if (this.options.ignoreWhitespace) {
  12719. line = line.trim();
  12720. }
  12721. retLines.push(line);
  12722. }
  12723. }
  12724. return retLines;
  12725. };
  12726. function diffLines(oldStr, newStr, callback) {
  12727. return lineDiff.diff(oldStr, newStr, callback);
  12728. }
  12729. function diffTrimmedLines(oldStr, newStr, callback) {
  12730. var options =
  12731. /*istanbul ignore start*/
  12732. (/*istanbul ignore end*/
  12733. /*istanbul ignore start*/
  12734. 0, _params
  12735. /*istanbul ignore end*/
  12736. .
  12737. /*istanbul ignore start*/
  12738. generateOptions
  12739. /*istanbul ignore end*/
  12740. )(callback, {
  12741. ignoreWhitespace: true
  12742. });
  12743. return lineDiff.diff(oldStr, newStr, options);
  12744. }
  12745. var sentence = {};
  12746. /*istanbul ignore start*/
  12747. Object.defineProperty(sentence, "__esModule", {
  12748. value: true
  12749. });
  12750. sentence.diffSentences = diffSentences;
  12751. sentence.sentenceDiff = void 0;
  12752. /*istanbul ignore end*/
  12753. var
  12754. /*istanbul ignore start*/
  12755. _base$3 = _interopRequireDefault$4(base)
  12756. /*istanbul ignore end*/
  12757. ;
  12758. /*istanbul ignore start*/
  12759. function _interopRequireDefault$4(obj) {
  12760. return obj && obj.__esModule ? obj : {
  12761. "default": obj
  12762. };
  12763. }
  12764. /*istanbul ignore end*/
  12765. var sentenceDiff = new
  12766. /*istanbul ignore start*/
  12767. _base$3
  12768. /*istanbul ignore end*/
  12769. [
  12770. /*istanbul ignore start*/
  12771. "default"
  12772. /*istanbul ignore end*/
  12773. ]();
  12774. /*istanbul ignore start*/
  12775. sentence.sentenceDiff = sentenceDiff;
  12776. /*istanbul ignore end*/
  12777. sentenceDiff.tokenize = function (value) {
  12778. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  12779. };
  12780. function diffSentences(oldStr, newStr, callback) {
  12781. return sentenceDiff.diff(oldStr, newStr, callback);
  12782. }
  12783. var css = {};
  12784. /*istanbul ignore start*/
  12785. Object.defineProperty(css, "__esModule", {
  12786. value: true
  12787. });
  12788. css.diffCss = diffCss;
  12789. css.cssDiff = void 0;
  12790. /*istanbul ignore end*/
  12791. var
  12792. /*istanbul ignore start*/
  12793. _base$2 = _interopRequireDefault$3(base)
  12794. /*istanbul ignore end*/
  12795. ;
  12796. /*istanbul ignore start*/
  12797. function _interopRequireDefault$3(obj) {
  12798. return obj && obj.__esModule ? obj : {
  12799. "default": obj
  12800. };
  12801. }
  12802. /*istanbul ignore end*/
  12803. var cssDiff = new
  12804. /*istanbul ignore start*/
  12805. _base$2
  12806. /*istanbul ignore end*/
  12807. [
  12808. /*istanbul ignore start*/
  12809. "default"
  12810. /*istanbul ignore end*/
  12811. ]();
  12812. /*istanbul ignore start*/
  12813. css.cssDiff = cssDiff;
  12814. /*istanbul ignore end*/
  12815. cssDiff.tokenize = function (value) {
  12816. return value.split(/([{}:;,]|\s+)/);
  12817. };
  12818. function diffCss(oldStr, newStr, callback) {
  12819. return cssDiff.diff(oldStr, newStr, callback);
  12820. }
  12821. var json = {};
  12822. Object.defineProperty(json, "__esModule", {
  12823. value: true
  12824. });
  12825. json.diffJson = diffJson;
  12826. json.canonicalize = canonicalize;
  12827. json.jsonDiff = void 0;
  12828. /*istanbul ignore end*/
  12829. var
  12830. /*istanbul ignore start*/
  12831. _base$1 = _interopRequireDefault$2(base)
  12832. /*istanbul ignore end*/
  12833. ;
  12834. var
  12835. /*istanbul ignore start*/
  12836. _line$1 = line
  12837. /*istanbul ignore end*/
  12838. ;
  12839. /*istanbul ignore start*/
  12840. function _interopRequireDefault$2(obj) {
  12841. return obj && obj.__esModule ? obj : {
  12842. "default": obj
  12843. };
  12844. }
  12845. function _typeof(obj) {
  12846. "@babel/helpers - typeof";
  12847. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  12848. _typeof = function _typeof(obj) {
  12849. return typeof obj;
  12850. };
  12851. } else {
  12852. _typeof = function _typeof(obj) {
  12853. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  12854. };
  12855. }
  12856. return _typeof(obj);
  12857. }
  12858. /*istanbul ignore end*/
  12859. var objectPrototypeToString = Object.prototype.toString;
  12860. var jsonDiff = new
  12861. /*istanbul ignore start*/
  12862. _base$1
  12863. /*istanbul ignore end*/
  12864. [
  12865. /*istanbul ignore start*/
  12866. "default"
  12867. /*istanbul ignore end*/
  12868. ](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  12869. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  12870. /*istanbul ignore start*/
  12871. json.jsonDiff = jsonDiff;
  12872. /*istanbul ignore end*/
  12873. jsonDiff.useLongestToken = true;
  12874. jsonDiff.tokenize =
  12875. /*istanbul ignore start*/
  12876. _line$1
  12877. /*istanbul ignore end*/
  12878. .
  12879. /*istanbul ignore start*/
  12880. lineDiff
  12881. /*istanbul ignore end*/
  12882. .tokenize;
  12883. jsonDiff.castInput = function (value) {
  12884. /*istanbul ignore start*/
  12885. var _this$options =
  12886. /*istanbul ignore end*/
  12887. this.options,
  12888. undefinedReplacement = _this$options.undefinedReplacement,
  12889. _this$options$stringi = _this$options.stringifyReplacer,
  12890. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v)
  12891. /*istanbul ignore start*/
  12892. {
  12893. return (
  12894. /*istanbul ignore end*/
  12895. typeof v === 'undefined' ? undefinedReplacement : v
  12896. );
  12897. } : _this$options$stringi;
  12898. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  12899. };
  12900. jsonDiff.equals = function (left, right) {
  12901. return (
  12902. /*istanbul ignore start*/
  12903. _base$1
  12904. /*istanbul ignore end*/
  12905. [
  12906. /*istanbul ignore start*/
  12907. "default"
  12908. /*istanbul ignore end*/
  12909. ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  12910. );
  12911. };
  12912. function diffJson(oldObj, newObj, options) {
  12913. return jsonDiff.diff(oldObj, newObj, options);
  12914. } // This function handles the presence of circular references by bailing out when encountering an
  12915. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  12916. function canonicalize(obj, stack, replacementStack, replacer, key) {
  12917. stack = stack || [];
  12918. replacementStack = replacementStack || [];
  12919. if (replacer) {
  12920. obj = replacer(key, obj);
  12921. }
  12922. var i;
  12923. for (i = 0; i < stack.length; i += 1) {
  12924. if (stack[i] === obj) {
  12925. return replacementStack[i];
  12926. }
  12927. }
  12928. var canonicalizedObj;
  12929. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  12930. stack.push(obj);
  12931. canonicalizedObj = new Array(obj.length);
  12932. replacementStack.push(canonicalizedObj);
  12933. for (i = 0; i < obj.length; i += 1) {
  12934. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  12935. }
  12936. stack.pop();
  12937. replacementStack.pop();
  12938. return canonicalizedObj;
  12939. }
  12940. if (obj && obj.toJSON) {
  12941. obj = obj.toJSON();
  12942. }
  12943. if (
  12944. /*istanbul ignore start*/
  12945. _typeof(
  12946. /*istanbul ignore end*/
  12947. obj) === 'object' && obj !== null) {
  12948. stack.push(obj);
  12949. canonicalizedObj = {};
  12950. replacementStack.push(canonicalizedObj);
  12951. var sortedKeys = [],
  12952. _key;
  12953. for (_key in obj) {
  12954. /* istanbul ignore else */
  12955. if (obj.hasOwnProperty(_key)) {
  12956. sortedKeys.push(_key);
  12957. }
  12958. }
  12959. sortedKeys.sort();
  12960. for (i = 0; i < sortedKeys.length; i += 1) {
  12961. _key = sortedKeys[i];
  12962. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  12963. }
  12964. stack.pop();
  12965. replacementStack.pop();
  12966. } else {
  12967. canonicalizedObj = obj;
  12968. }
  12969. return canonicalizedObj;
  12970. }
  12971. var array$1 = {};
  12972. /*istanbul ignore start*/
  12973. Object.defineProperty(array$1, "__esModule", {
  12974. value: true
  12975. });
  12976. array$1.diffArrays = diffArrays;
  12977. array$1.arrayDiff = void 0;
  12978. /*istanbul ignore end*/
  12979. var
  12980. /*istanbul ignore start*/
  12981. _base = _interopRequireDefault$1(base)
  12982. /*istanbul ignore end*/
  12983. ;
  12984. /*istanbul ignore start*/
  12985. function _interopRequireDefault$1(obj) {
  12986. return obj && obj.__esModule ? obj : {
  12987. "default": obj
  12988. };
  12989. }
  12990. /*istanbul ignore end*/
  12991. var arrayDiff = new
  12992. /*istanbul ignore start*/
  12993. _base
  12994. /*istanbul ignore end*/
  12995. [
  12996. /*istanbul ignore start*/
  12997. "default"
  12998. /*istanbul ignore end*/
  12999. ]();
  13000. /*istanbul ignore start*/
  13001. array$1.arrayDiff = arrayDiff;
  13002. /*istanbul ignore end*/
  13003. arrayDiff.tokenize = function (value) {
  13004. return value.slice();
  13005. };
  13006. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  13007. return value;
  13008. };
  13009. function diffArrays(oldArr, newArr, callback) {
  13010. return arrayDiff.diff(oldArr, newArr, callback);
  13011. }
  13012. var apply$2 = {};
  13013. var parse = {};
  13014. /*istanbul ignore start*/
  13015. Object.defineProperty(parse, "__esModule", {
  13016. value: true
  13017. });
  13018. parse.parsePatch = parsePatch;
  13019. /*istanbul ignore end*/
  13020. function parsePatch(uniDiff) {
  13021. /*istanbul ignore start*/
  13022. var
  13023. /*istanbul ignore end*/
  13024. options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13025. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  13026. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  13027. list = [],
  13028. i = 0;
  13029. function parseIndex() {
  13030. var index = {};
  13031. list.push(index); // Parse diff metadata
  13032. while (i < diffstr.length) {
  13033. var line = diffstr[i]; // File header found, end parsing diff metadata
  13034. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  13035. break;
  13036. } // Diff index
  13037. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  13038. if (header) {
  13039. index.index = header[1];
  13040. }
  13041. i++;
  13042. } // Parse file headers if they are defined. Unified diff requires them, but
  13043. // there's no technical issues to have an isolated hunk without file header
  13044. parseFileHeader(index);
  13045. parseFileHeader(index); // Parse hunks
  13046. index.hunks = [];
  13047. while (i < diffstr.length) {
  13048. var _line = diffstr[i];
  13049. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  13050. break;
  13051. } else if (/^@@/.test(_line)) {
  13052. index.hunks.push(parseHunk());
  13053. } else if (_line && options.strict) {
  13054. // Ignore unexpected content unless in strict mode
  13055. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  13056. } else {
  13057. i++;
  13058. }
  13059. }
  13060. } // Parses the --- and +++ headers, if none are found, no lines
  13061. // are consumed.
  13062. function parseFileHeader(index) {
  13063. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  13064. if (fileHeader) {
  13065. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  13066. var data = fileHeader[2].split('\t', 2);
  13067. var fileName = data[0].replace(/\\\\/g, '\\');
  13068. if (/^".*"$/.test(fileName)) {
  13069. fileName = fileName.substr(1, fileName.length - 2);
  13070. }
  13071. index[keyPrefix + 'FileName'] = fileName;
  13072. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  13073. i++;
  13074. }
  13075. } // Parses a hunk
  13076. // This assumes that we are at the start of a hunk.
  13077. function parseHunk() {
  13078. var chunkHeaderIndex = i,
  13079. chunkHeaderLine = diffstr[i++],
  13080. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  13081. var hunk = {
  13082. oldStart: +chunkHeader[1],
  13083. oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
  13084. newStart: +chunkHeader[3],
  13085. newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
  13086. lines: [],
  13087. linedelimiters: []
  13088. }; // Unified Diff Format quirk: If the chunk size is 0,
  13089. // the first number is one lower than one would expect.
  13090. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  13091. if (hunk.oldLines === 0) {
  13092. hunk.oldStart += 1;
  13093. }
  13094. if (hunk.newLines === 0) {
  13095. hunk.newStart += 1;
  13096. }
  13097. var addCount = 0,
  13098. removeCount = 0;
  13099. for (; i < diffstr.length; i++) {
  13100. // Lines starting with '---' could be mistaken for the "remove line" operation
  13101. // But they could be the header for the next file. Therefore prune such cases out.
  13102. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  13103. break;
  13104. }
  13105. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  13106. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  13107. hunk.lines.push(diffstr[i]);
  13108. hunk.linedelimiters.push(delimiters[i] || '\n');
  13109. if (operation === '+') {
  13110. addCount++;
  13111. } else if (operation === '-') {
  13112. removeCount++;
  13113. } else if (operation === ' ') {
  13114. addCount++;
  13115. removeCount++;
  13116. }
  13117. } else {
  13118. break;
  13119. }
  13120. } // Handle the empty block count case
  13121. if (!addCount && hunk.newLines === 1) {
  13122. hunk.newLines = 0;
  13123. }
  13124. if (!removeCount && hunk.oldLines === 1) {
  13125. hunk.oldLines = 0;
  13126. } // Perform optional sanity checking
  13127. if (options.strict) {
  13128. if (addCount !== hunk.newLines) {
  13129. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  13130. }
  13131. if (removeCount !== hunk.oldLines) {
  13132. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  13133. }
  13134. }
  13135. return hunk;
  13136. }
  13137. while (i < diffstr.length) {
  13138. parseIndex();
  13139. }
  13140. return list;
  13141. }
  13142. var distanceIterator = {};
  13143. /*istanbul ignore start*/
  13144. (function (exports) {
  13145. Object.defineProperty(exports, "__esModule", {
  13146. value: true
  13147. });
  13148. exports["default"] = _default;
  13149. /*istanbul ignore end*/
  13150. // Iterator that traverses in the range of [min, max], stepping
  13151. // by distance from a given start position. I.e. for [0, 4], with
  13152. // start of 2, this will iterate 2, 3, 1, 4, 0.
  13153. function
  13154. /*istanbul ignore start*/
  13155. _default
  13156. /*istanbul ignore end*/
  13157. (start, minLine, maxLine) {
  13158. var wantForward = true,
  13159. backwardExhausted = false,
  13160. forwardExhausted = false,
  13161. localOffset = 1;
  13162. return function iterator() {
  13163. if (wantForward && !forwardExhausted) {
  13164. if (backwardExhausted) {
  13165. localOffset++;
  13166. } else {
  13167. wantForward = false;
  13168. } // Check if trying to fit beyond text length, and if not, check it fits
  13169. // after offset location (or desired location on first iteration)
  13170. if (start + localOffset <= maxLine) {
  13171. return localOffset;
  13172. }
  13173. forwardExhausted = true;
  13174. }
  13175. if (!backwardExhausted) {
  13176. if (!forwardExhausted) {
  13177. wantForward = true;
  13178. } // Check if trying to fit before text beginning, and if not, check it fits
  13179. // before offset location
  13180. if (minLine <= start - localOffset) {
  13181. return -localOffset++;
  13182. }
  13183. backwardExhausted = true;
  13184. return iterator();
  13185. } // We tried to fit hunk before text beginning and beyond text length, then
  13186. // hunk can't fit on the text. Return undefined
  13187. };
  13188. }
  13189. })(distanceIterator);
  13190. /*istanbul ignore start*/
  13191. Object.defineProperty(apply$2, "__esModule", {
  13192. value: true
  13193. });
  13194. apply$2.applyPatch = applyPatch;
  13195. apply$2.applyPatches = applyPatches;
  13196. /*istanbul ignore end*/
  13197. var
  13198. /*istanbul ignore start*/
  13199. _parse$1 = parse
  13200. /*istanbul ignore end*/
  13201. ;
  13202. var
  13203. /*istanbul ignore start*/
  13204. _distanceIterator = _interopRequireDefault(distanceIterator)
  13205. /*istanbul ignore end*/
  13206. ;
  13207. /*istanbul ignore start*/
  13208. function _interopRequireDefault(obj) {
  13209. return obj && obj.__esModule ? obj : {
  13210. "default": obj
  13211. };
  13212. }
  13213. /*istanbul ignore end*/
  13214. function applyPatch(source, uniDiff) {
  13215. /*istanbul ignore start*/
  13216. var
  13217. /*istanbul ignore end*/
  13218. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  13219. if (typeof uniDiff === 'string') {
  13220. uniDiff =
  13221. /*istanbul ignore start*/
  13222. (/*istanbul ignore end*/
  13223. /*istanbul ignore start*/
  13224. 0, _parse$1
  13225. /*istanbul ignore end*/
  13226. .
  13227. /*istanbul ignore start*/
  13228. parsePatch
  13229. /*istanbul ignore end*/
  13230. )(uniDiff);
  13231. }
  13232. if (Array.isArray(uniDiff)) {
  13233. if (uniDiff.length > 1) {
  13234. throw new Error('applyPatch only works with a single input.');
  13235. }
  13236. uniDiff = uniDiff[0];
  13237. } // Apply the diff to the input
  13238. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  13239. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  13240. hunks = uniDiff.hunks,
  13241. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  13242. /*istanbul ignore start*/
  13243. {
  13244. return (
  13245. /*istanbul ignore end*/
  13246. line === patchContent
  13247. );
  13248. },
  13249. errorCount = 0,
  13250. fuzzFactor = options.fuzzFactor || 0,
  13251. minLine = 0,
  13252. offset = 0,
  13253. removeEOFNL,
  13254. addEOFNL;
  13255. /**
  13256. * Checks if the hunk exactly fits on the provided location
  13257. */
  13258. function hunkFits(hunk, toPos) {
  13259. for (var j = 0; j < hunk.lines.length; j++) {
  13260. var line = hunk.lines[j],
  13261. operation = line.length > 0 ? line[0] : ' ',
  13262. content = line.length > 0 ? line.substr(1) : line;
  13263. if (operation === ' ' || operation === '-') {
  13264. // Context sanity check
  13265. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  13266. errorCount++;
  13267. if (errorCount > fuzzFactor) {
  13268. return false;
  13269. }
  13270. }
  13271. toPos++;
  13272. }
  13273. }
  13274. return true;
  13275. } // Search best fit offsets for each hunk based on the previous ones
  13276. for (var i = 0; i < hunks.length; i++) {
  13277. var hunk = hunks[i],
  13278. maxLine = lines.length - hunk.oldLines,
  13279. localOffset = 0,
  13280. toPos = offset + hunk.oldStart - 1;
  13281. var iterator =
  13282. /*istanbul ignore start*/
  13283. (/*istanbul ignore end*/
  13284. /*istanbul ignore start*/
  13285. 0, _distanceIterator
  13286. /*istanbul ignore end*/
  13287. [
  13288. /*istanbul ignore start*/
  13289. "default"
  13290. /*istanbul ignore end*/
  13291. ])(toPos, minLine, maxLine);
  13292. for (; localOffset !== undefined; localOffset = iterator()) {
  13293. if (hunkFits(hunk, toPos + localOffset)) {
  13294. hunk.offset = offset += localOffset;
  13295. break;
  13296. }
  13297. }
  13298. if (localOffset === undefined) {
  13299. return false;
  13300. } // Set lower text limit to end of the current hunk, so next ones don't try
  13301. // to fit over already patched text
  13302. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  13303. } // Apply patch hunks
  13304. var diffOffset = 0;
  13305. for (var _i = 0; _i < hunks.length; _i++) {
  13306. var _hunk = hunks[_i],
  13307. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  13308. diffOffset += _hunk.newLines - _hunk.oldLines;
  13309. for (var j = 0; j < _hunk.lines.length; j++) {
  13310. var line = _hunk.lines[j],
  13311. operation = line.length > 0 ? line[0] : ' ',
  13312. content = line.length > 0 ? line.substr(1) : line,
  13313. delimiter = _hunk.linedelimiters[j];
  13314. if (operation === ' ') {
  13315. _toPos++;
  13316. } else if (operation === '-') {
  13317. lines.splice(_toPos, 1);
  13318. delimiters.splice(_toPos, 1);
  13319. /* istanbul ignore else */
  13320. } else if (operation === '+') {
  13321. lines.splice(_toPos, 0, content);
  13322. delimiters.splice(_toPos, 0, delimiter);
  13323. _toPos++;
  13324. } else if (operation === '\\') {
  13325. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  13326. if (previousOperation === '+') {
  13327. removeEOFNL = true;
  13328. } else if (previousOperation === '-') {
  13329. addEOFNL = true;
  13330. }
  13331. }
  13332. }
  13333. } // Handle EOFNL insertion/removal
  13334. if (removeEOFNL) {
  13335. while (!lines[lines.length - 1]) {
  13336. lines.pop();
  13337. delimiters.pop();
  13338. }
  13339. } else if (addEOFNL) {
  13340. lines.push('');
  13341. delimiters.push('\n');
  13342. }
  13343. for (var _k = 0; _k < lines.length - 1; _k++) {
  13344. lines[_k] = lines[_k] + delimiters[_k];
  13345. }
  13346. return lines.join('');
  13347. } // Wrapper that supports multiple file patches via callbacks.
  13348. function applyPatches(uniDiff, options) {
  13349. if (typeof uniDiff === 'string') {
  13350. uniDiff =
  13351. /*istanbul ignore start*/
  13352. (/*istanbul ignore end*/
  13353. /*istanbul ignore start*/
  13354. 0, _parse$1
  13355. /*istanbul ignore end*/
  13356. .
  13357. /*istanbul ignore start*/
  13358. parsePatch
  13359. /*istanbul ignore end*/
  13360. )(uniDiff);
  13361. }
  13362. var currentIndex = 0;
  13363. function processIndex() {
  13364. var index = uniDiff[currentIndex++];
  13365. if (!index) {
  13366. return options.complete();
  13367. }
  13368. options.loadFile(index, function (err, data) {
  13369. if (err) {
  13370. return options.complete(err);
  13371. }
  13372. var updatedContent = applyPatch(data, index, options);
  13373. options.patched(index, updatedContent, function (err) {
  13374. if (err) {
  13375. return options.complete(err);
  13376. }
  13377. processIndex();
  13378. });
  13379. });
  13380. }
  13381. processIndex();
  13382. }
  13383. var merge$1 = {};
  13384. var create$1 = {};
  13385. /*istanbul ignore start*/
  13386. Object.defineProperty(create$1, "__esModule", {
  13387. value: true
  13388. });
  13389. create$1.structuredPatch = structuredPatch;
  13390. create$1.formatPatch = formatPatch;
  13391. create$1.createTwoFilesPatch = createTwoFilesPatch;
  13392. create$1.createPatch = createPatch;
  13393. /*istanbul ignore end*/
  13394. var
  13395. /*istanbul ignore start*/
  13396. _line = line
  13397. /*istanbul ignore end*/
  13398. ;
  13399. /*istanbul ignore start*/
  13400. function _toConsumableArray$1(arr) {
  13401. return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
  13402. }
  13403. function _nonIterableSpread$1() {
  13404. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  13405. }
  13406. function _unsupportedIterableToArray$1(o, minLen) {
  13407. if (!o) return;
  13408. if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
  13409. var n = Object.prototype.toString.call(o).slice(8, -1);
  13410. if (n === "Object" && o.constructor) n = o.constructor.name;
  13411. if (n === "Map" || n === "Set") return Array.from(o);
  13412. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
  13413. }
  13414. function _iterableToArray$1(iter) {
  13415. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  13416. }
  13417. function _arrayWithoutHoles$1(arr) {
  13418. if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
  13419. }
  13420. function _arrayLikeToArray$1(arr, len) {
  13421. if (len == null || len > arr.length) len = arr.length;
  13422. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  13423. arr2[i] = arr[i];
  13424. }
  13425. return arr2;
  13426. }
  13427. /*istanbul ignore end*/
  13428. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  13429. if (!options) {
  13430. options = {};
  13431. }
  13432. if (typeof options.context === 'undefined') {
  13433. options.context = 4;
  13434. }
  13435. var diff =
  13436. /*istanbul ignore start*/
  13437. (/*istanbul ignore end*/
  13438. /*istanbul ignore start*/
  13439. 0, _line
  13440. /*istanbul ignore end*/
  13441. .
  13442. /*istanbul ignore start*/
  13443. diffLines
  13444. /*istanbul ignore end*/
  13445. )(oldStr, newStr, options);
  13446. diff.push({
  13447. value: '',
  13448. lines: []
  13449. }); // Append an empty value to make cleanup easier
  13450. function contextLines(lines) {
  13451. return lines.map(function (entry) {
  13452. return ' ' + entry;
  13453. });
  13454. }
  13455. var hunks = [];
  13456. var oldRangeStart = 0,
  13457. newRangeStart = 0,
  13458. curRange = [],
  13459. oldLine = 1,
  13460. newLine = 1;
  13461. /*istanbul ignore start*/
  13462. var _loop = function _loop(
  13463. /*istanbul ignore end*/
  13464. i) {
  13465. var current = diff[i],
  13466. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  13467. current.lines = lines;
  13468. if (current.added || current.removed) {
  13469. /*istanbul ignore start*/
  13470. var _curRange;
  13471. /*istanbul ignore end*/
  13472. // If we have previous context, start with that
  13473. if (!oldRangeStart) {
  13474. var prev = diff[i - 1];
  13475. oldRangeStart = oldLine;
  13476. newRangeStart = newLine;
  13477. if (prev) {
  13478. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  13479. oldRangeStart -= curRange.length;
  13480. newRangeStart -= curRange.length;
  13481. }
  13482. } // Output our changes
  13483. /*istanbul ignore start*/
  13484. /*istanbul ignore end*/
  13485. /*istanbul ignore start*/
  13486. (_curRange =
  13487. /*istanbul ignore end*/
  13488. curRange).push.apply(
  13489. /*istanbul ignore start*/
  13490. _curRange
  13491. /*istanbul ignore end*/
  13492. ,
  13493. /*istanbul ignore start*/
  13494. _toConsumableArray$1(
  13495. /*istanbul ignore end*/
  13496. lines.map(function (entry) {
  13497. return (current.added ? '+' : '-') + entry;
  13498. }))); // Track the updated file position
  13499. if (current.added) {
  13500. newLine += lines.length;
  13501. } else {
  13502. oldLine += lines.length;
  13503. }
  13504. } else {
  13505. // Identical context lines. Track line changes
  13506. if (oldRangeStart) {
  13507. // Close out any changes that have been output (or join overlapping)
  13508. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  13509. /*istanbul ignore start*/
  13510. var _curRange2;
  13511. /*istanbul ignore end*/
  13512. // Overlapping
  13513. /*istanbul ignore start*/
  13514. /*istanbul ignore end*/
  13515. /*istanbul ignore start*/
  13516. (_curRange2 =
  13517. /*istanbul ignore end*/
  13518. curRange).push.apply(
  13519. /*istanbul ignore start*/
  13520. _curRange2
  13521. /*istanbul ignore end*/
  13522. ,
  13523. /*istanbul ignore start*/
  13524. _toConsumableArray$1(
  13525. /*istanbul ignore end*/
  13526. contextLines(lines)));
  13527. } else {
  13528. /*istanbul ignore start*/
  13529. var _curRange3;
  13530. /*istanbul ignore end*/
  13531. // end the range and output
  13532. var contextSize = Math.min(lines.length, options.context);
  13533. /*istanbul ignore start*/
  13534. /*istanbul ignore end*/
  13535. /*istanbul ignore start*/
  13536. (_curRange3 =
  13537. /*istanbul ignore end*/
  13538. curRange).push.apply(
  13539. /*istanbul ignore start*/
  13540. _curRange3
  13541. /*istanbul ignore end*/
  13542. ,
  13543. /*istanbul ignore start*/
  13544. _toConsumableArray$1(
  13545. /*istanbul ignore end*/
  13546. contextLines(lines.slice(0, contextSize))));
  13547. var hunk = {
  13548. oldStart: oldRangeStart,
  13549. oldLines: oldLine - oldRangeStart + contextSize,
  13550. newStart: newRangeStart,
  13551. newLines: newLine - newRangeStart + contextSize,
  13552. lines: curRange
  13553. };
  13554. if (i >= diff.length - 2 && lines.length <= options.context) {
  13555. // EOF is inside this hunk
  13556. var oldEOFNewline = /\n$/.test(oldStr);
  13557. var newEOFNewline = /\n$/.test(newStr);
  13558. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  13559. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  13560. // special case: old has no eol and no trailing context; no-nl can end up before adds
  13561. // however, if the old file is empty, do not output the no-nl line
  13562. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  13563. }
  13564. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  13565. curRange.push('\\ No newline at end of file');
  13566. }
  13567. }
  13568. hunks.push(hunk);
  13569. oldRangeStart = 0;
  13570. newRangeStart = 0;
  13571. curRange = [];
  13572. }
  13573. }
  13574. oldLine += lines.length;
  13575. newLine += lines.length;
  13576. }
  13577. };
  13578. for (var i = 0; i < diff.length; i++) {
  13579. /*istanbul ignore start*/
  13580. _loop(
  13581. /*istanbul ignore end*/
  13582. i);
  13583. }
  13584. return {
  13585. oldFileName: oldFileName,
  13586. newFileName: newFileName,
  13587. oldHeader: oldHeader,
  13588. newHeader: newHeader,
  13589. hunks: hunks
  13590. };
  13591. }
  13592. function formatPatch(diff) {
  13593. var ret = [];
  13594. if (diff.oldFileName == diff.newFileName) {
  13595. ret.push('Index: ' + diff.oldFileName);
  13596. }
  13597. ret.push('===================================================================');
  13598. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  13599. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  13600. for (var i = 0; i < diff.hunks.length; i++) {
  13601. var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
  13602. // the first number is one lower than one would expect.
  13603. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  13604. if (hunk.oldLines === 0) {
  13605. hunk.oldStart -= 1;
  13606. }
  13607. if (hunk.newLines === 0) {
  13608. hunk.newStart -= 1;
  13609. }
  13610. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  13611. ret.push.apply(ret, hunk.lines);
  13612. }
  13613. return ret.join('\n') + '\n';
  13614. }
  13615. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  13616. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  13617. }
  13618. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  13619. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  13620. }
  13621. var array = {};
  13622. /*istanbul ignore start*/
  13623. Object.defineProperty(array, "__esModule", {
  13624. value: true
  13625. });
  13626. array.arrayEqual = arrayEqual;
  13627. array.arrayStartsWith = arrayStartsWith;
  13628. /*istanbul ignore end*/
  13629. function arrayEqual(a, b) {
  13630. if (a.length !== b.length) {
  13631. return false;
  13632. }
  13633. return arrayStartsWith(a, b);
  13634. }
  13635. function arrayStartsWith(array, start) {
  13636. if (start.length > array.length) {
  13637. return false;
  13638. }
  13639. for (var i = 0; i < start.length; i++) {
  13640. if (start[i] !== array[i]) {
  13641. return false;
  13642. }
  13643. }
  13644. return true;
  13645. }
  13646. /*istanbul ignore start*/
  13647. Object.defineProperty(merge$1, "__esModule", {
  13648. value: true
  13649. });
  13650. merge$1.calcLineCount = calcLineCount;
  13651. merge$1.merge = merge;
  13652. /*istanbul ignore end*/
  13653. var
  13654. /*istanbul ignore start*/
  13655. _create = create$1
  13656. /*istanbul ignore end*/
  13657. ;
  13658. var
  13659. /*istanbul ignore start*/
  13660. _parse = parse
  13661. /*istanbul ignore end*/
  13662. ;
  13663. var
  13664. /*istanbul ignore start*/
  13665. _array = array
  13666. /*istanbul ignore end*/
  13667. ;
  13668. /*istanbul ignore start*/
  13669. function _toConsumableArray(arr) {
  13670. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  13671. }
  13672. function _nonIterableSpread() {
  13673. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  13674. }
  13675. function _unsupportedIterableToArray(o, minLen) {
  13676. if (!o) return;
  13677. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  13678. var n = Object.prototype.toString.call(o).slice(8, -1);
  13679. if (n === "Object" && o.constructor) n = o.constructor.name;
  13680. if (n === "Map" || n === "Set") return Array.from(o);
  13681. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  13682. }
  13683. function _iterableToArray(iter) {
  13684. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  13685. }
  13686. function _arrayWithoutHoles(arr) {
  13687. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  13688. }
  13689. function _arrayLikeToArray(arr, len) {
  13690. if (len == null || len > arr.length) len = arr.length;
  13691. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  13692. arr2[i] = arr[i];
  13693. }
  13694. return arr2;
  13695. }
  13696. /*istanbul ignore end*/
  13697. function calcLineCount(hunk) {
  13698. /*istanbul ignore start*/
  13699. var _calcOldNewLineCount =
  13700. /*istanbul ignore end*/
  13701. calcOldNewLineCount(hunk.lines),
  13702. oldLines = _calcOldNewLineCount.oldLines,
  13703. newLines = _calcOldNewLineCount.newLines;
  13704. if (oldLines !== undefined) {
  13705. hunk.oldLines = oldLines;
  13706. } else {
  13707. delete hunk.oldLines;
  13708. }
  13709. if (newLines !== undefined) {
  13710. hunk.newLines = newLines;
  13711. } else {
  13712. delete hunk.newLines;
  13713. }
  13714. }
  13715. function merge(mine, theirs, base) {
  13716. mine = loadPatch(mine, base);
  13717. theirs = loadPatch(theirs, base);
  13718. var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
  13719. // Leaving sanity checks on this to the API consumer that may know more about the
  13720. // meaning in their own context.
  13721. if (mine.index || theirs.index) {
  13722. ret.index = mine.index || theirs.index;
  13723. }
  13724. if (mine.newFileName || theirs.newFileName) {
  13725. if (!fileNameChanged(mine)) {
  13726. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  13727. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  13728. ret.newFileName = theirs.newFileName || mine.newFileName;
  13729. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  13730. ret.newHeader = theirs.newHeader || mine.newHeader;
  13731. } else if (!fileNameChanged(theirs)) {
  13732. // No header or no change in theirs, use ours
  13733. ret.oldFileName = mine.oldFileName;
  13734. ret.newFileName = mine.newFileName;
  13735. ret.oldHeader = mine.oldHeader;
  13736. ret.newHeader = mine.newHeader;
  13737. } else {
  13738. // Both changed... figure it out
  13739. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  13740. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  13741. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  13742. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  13743. }
  13744. }
  13745. ret.hunks = [];
  13746. var mineIndex = 0,
  13747. theirsIndex = 0,
  13748. mineOffset = 0,
  13749. theirsOffset = 0;
  13750. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  13751. var mineCurrent = mine.hunks[mineIndex] || {
  13752. oldStart: Infinity
  13753. },
  13754. theirsCurrent = theirs.hunks[theirsIndex] || {
  13755. oldStart: Infinity
  13756. };
  13757. if (hunkBefore(mineCurrent, theirsCurrent)) {
  13758. // This patch does not overlap with any of the others, yay.
  13759. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  13760. mineIndex++;
  13761. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  13762. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  13763. // This patch does not overlap with any of the others, yay.
  13764. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  13765. theirsIndex++;
  13766. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  13767. } else {
  13768. // Overlap, merge as best we can
  13769. var mergedHunk = {
  13770. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  13771. oldLines: 0,
  13772. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  13773. newLines: 0,
  13774. lines: []
  13775. };
  13776. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  13777. theirsIndex++;
  13778. mineIndex++;
  13779. ret.hunks.push(mergedHunk);
  13780. }
  13781. }
  13782. return ret;
  13783. }
  13784. function loadPatch(param, base) {
  13785. if (typeof param === 'string') {
  13786. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  13787. return (
  13788. /*istanbul ignore start*/
  13789. (/*istanbul ignore end*/
  13790. /*istanbul ignore start*/
  13791. 0, _parse
  13792. /*istanbul ignore end*/
  13793. .
  13794. /*istanbul ignore start*/
  13795. parsePatch
  13796. /*istanbul ignore end*/
  13797. )(param)[0]
  13798. );
  13799. }
  13800. if (!base) {
  13801. throw new Error('Must provide a base reference or pass in a patch');
  13802. }
  13803. return (
  13804. /*istanbul ignore start*/
  13805. (/*istanbul ignore end*/
  13806. /*istanbul ignore start*/
  13807. 0, _create
  13808. /*istanbul ignore end*/
  13809. .
  13810. /*istanbul ignore start*/
  13811. structuredPatch
  13812. /*istanbul ignore end*/
  13813. )(undefined, undefined, base, param)
  13814. );
  13815. }
  13816. return param;
  13817. }
  13818. function fileNameChanged(patch) {
  13819. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  13820. }
  13821. function selectField(index, mine, theirs) {
  13822. if (mine === theirs) {
  13823. return mine;
  13824. } else {
  13825. index.conflict = true;
  13826. return {
  13827. mine: mine,
  13828. theirs: theirs
  13829. };
  13830. }
  13831. }
  13832. function hunkBefore(test, check) {
  13833. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  13834. }
  13835. function cloneHunk(hunk, offset) {
  13836. return {
  13837. oldStart: hunk.oldStart,
  13838. oldLines: hunk.oldLines,
  13839. newStart: hunk.newStart + offset,
  13840. newLines: hunk.newLines,
  13841. lines: hunk.lines
  13842. };
  13843. }
  13844. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  13845. // This will generally result in a conflicted hunk, but there are cases where the context
  13846. // is the only overlap where we can successfully merge the content here.
  13847. var mine = {
  13848. offset: mineOffset,
  13849. lines: mineLines,
  13850. index: 0
  13851. },
  13852. their = {
  13853. offset: theirOffset,
  13854. lines: theirLines,
  13855. index: 0
  13856. }; // Handle any leading content
  13857. insertLeading(hunk, mine, their);
  13858. insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
  13859. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  13860. var mineCurrent = mine.lines[mine.index],
  13861. theirCurrent = their.lines[their.index];
  13862. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  13863. // Both modified ...
  13864. mutualChange(hunk, mine, their);
  13865. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  13866. /*istanbul ignore start*/
  13867. var _hunk$lines;
  13868. /*istanbul ignore end*/
  13869. // Mine inserted
  13870. /*istanbul ignore start*/
  13871. /*istanbul ignore end*/
  13872. /*istanbul ignore start*/
  13873. (_hunk$lines =
  13874. /*istanbul ignore end*/
  13875. hunk.lines).push.apply(
  13876. /*istanbul ignore start*/
  13877. _hunk$lines
  13878. /*istanbul ignore end*/
  13879. ,
  13880. /*istanbul ignore start*/
  13881. _toConsumableArray(
  13882. /*istanbul ignore end*/
  13883. collectChange(mine)));
  13884. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  13885. /*istanbul ignore start*/
  13886. var _hunk$lines2;
  13887. /*istanbul ignore end*/
  13888. // Theirs inserted
  13889. /*istanbul ignore start*/
  13890. /*istanbul ignore end*/
  13891. /*istanbul ignore start*/
  13892. (_hunk$lines2 =
  13893. /*istanbul ignore end*/
  13894. hunk.lines).push.apply(
  13895. /*istanbul ignore start*/
  13896. _hunk$lines2
  13897. /*istanbul ignore end*/
  13898. ,
  13899. /*istanbul ignore start*/
  13900. _toConsumableArray(
  13901. /*istanbul ignore end*/
  13902. collectChange(their)));
  13903. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  13904. // Mine removed or edited
  13905. removal(hunk, mine, their);
  13906. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  13907. // Their removed or edited
  13908. removal(hunk, their, mine, true);
  13909. } else if (mineCurrent === theirCurrent) {
  13910. // Context identity
  13911. hunk.lines.push(mineCurrent);
  13912. mine.index++;
  13913. their.index++;
  13914. } else {
  13915. // Context mismatch
  13916. conflict(hunk, collectChange(mine), collectChange(their));
  13917. }
  13918. } // Now push anything that may be remaining
  13919. insertTrailing(hunk, mine);
  13920. insertTrailing(hunk, their);
  13921. calcLineCount(hunk);
  13922. }
  13923. function mutualChange(hunk, mine, their) {
  13924. var myChanges = collectChange(mine),
  13925. theirChanges = collectChange(their);
  13926. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  13927. // Special case for remove changes that are supersets of one another
  13928. if (
  13929. /*istanbul ignore start*/
  13930. (/*istanbul ignore end*/
  13931. /*istanbul ignore start*/
  13932. 0, _array
  13933. /*istanbul ignore end*/
  13934. .
  13935. /*istanbul ignore start*/
  13936. arrayStartsWith
  13937. /*istanbul ignore end*/
  13938. )(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  13939. /*istanbul ignore start*/
  13940. var _hunk$lines3;
  13941. /*istanbul ignore end*/
  13942. /*istanbul ignore start*/
  13943. /*istanbul ignore end*/
  13944. /*istanbul ignore start*/
  13945. (_hunk$lines3 =
  13946. /*istanbul ignore end*/
  13947. hunk.lines).push.apply(
  13948. /*istanbul ignore start*/
  13949. _hunk$lines3
  13950. /*istanbul ignore end*/
  13951. ,
  13952. /*istanbul ignore start*/
  13953. _toConsumableArray(
  13954. /*istanbul ignore end*/
  13955. myChanges));
  13956. return;
  13957. } else if (
  13958. /*istanbul ignore start*/
  13959. (/*istanbul ignore end*/
  13960. /*istanbul ignore start*/
  13961. 0, _array
  13962. /*istanbul ignore end*/
  13963. .
  13964. /*istanbul ignore start*/
  13965. arrayStartsWith
  13966. /*istanbul ignore end*/
  13967. )(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  13968. /*istanbul ignore start*/
  13969. var _hunk$lines4;
  13970. /*istanbul ignore end*/
  13971. /*istanbul ignore start*/
  13972. /*istanbul ignore end*/
  13973. /*istanbul ignore start*/
  13974. (_hunk$lines4 =
  13975. /*istanbul ignore end*/
  13976. hunk.lines).push.apply(
  13977. /*istanbul ignore start*/
  13978. _hunk$lines4
  13979. /*istanbul ignore end*/
  13980. ,
  13981. /*istanbul ignore start*/
  13982. _toConsumableArray(
  13983. /*istanbul ignore end*/
  13984. theirChanges));
  13985. return;
  13986. }
  13987. } else if (
  13988. /*istanbul ignore start*/
  13989. (/*istanbul ignore end*/
  13990. /*istanbul ignore start*/
  13991. 0, _array
  13992. /*istanbul ignore end*/
  13993. .
  13994. /*istanbul ignore start*/
  13995. arrayEqual
  13996. /*istanbul ignore end*/
  13997. )(myChanges, theirChanges)) {
  13998. /*istanbul ignore start*/
  13999. var _hunk$lines5;
  14000. /*istanbul ignore end*/
  14001. /*istanbul ignore start*/
  14002. /*istanbul ignore end*/
  14003. /*istanbul ignore start*/
  14004. (_hunk$lines5 =
  14005. /*istanbul ignore end*/
  14006. hunk.lines).push.apply(
  14007. /*istanbul ignore start*/
  14008. _hunk$lines5
  14009. /*istanbul ignore end*/
  14010. ,
  14011. /*istanbul ignore start*/
  14012. _toConsumableArray(
  14013. /*istanbul ignore end*/
  14014. myChanges));
  14015. return;
  14016. }
  14017. conflict(hunk, myChanges, theirChanges);
  14018. }
  14019. function removal(hunk, mine, their, swap) {
  14020. var myChanges = collectChange(mine),
  14021. theirChanges = collectContext(their, myChanges);
  14022. if (theirChanges.merged) {
  14023. /*istanbul ignore start*/
  14024. var _hunk$lines6;
  14025. /*istanbul ignore end*/
  14026. /*istanbul ignore start*/
  14027. /*istanbul ignore end*/
  14028. /*istanbul ignore start*/
  14029. (_hunk$lines6 =
  14030. /*istanbul ignore end*/
  14031. hunk.lines).push.apply(
  14032. /*istanbul ignore start*/
  14033. _hunk$lines6
  14034. /*istanbul ignore end*/
  14035. ,
  14036. /*istanbul ignore start*/
  14037. _toConsumableArray(
  14038. /*istanbul ignore end*/
  14039. theirChanges.merged));
  14040. } else {
  14041. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  14042. }
  14043. }
  14044. function conflict(hunk, mine, their) {
  14045. hunk.conflict = true;
  14046. hunk.lines.push({
  14047. conflict: true,
  14048. mine: mine,
  14049. theirs: their
  14050. });
  14051. }
  14052. function insertLeading(hunk, insert, their) {
  14053. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  14054. var line = insert.lines[insert.index++];
  14055. hunk.lines.push(line);
  14056. insert.offset++;
  14057. }
  14058. }
  14059. function insertTrailing(hunk, insert) {
  14060. while (insert.index < insert.lines.length) {
  14061. var line = insert.lines[insert.index++];
  14062. hunk.lines.push(line);
  14063. }
  14064. }
  14065. function collectChange(state) {
  14066. var ret = [],
  14067. operation = state.lines[state.index][0];
  14068. while (state.index < state.lines.length) {
  14069. var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  14070. if (operation === '-' && line[0] === '+') {
  14071. operation = '+';
  14072. }
  14073. if (operation === line[0]) {
  14074. ret.push(line);
  14075. state.index++;
  14076. } else {
  14077. break;
  14078. }
  14079. }
  14080. return ret;
  14081. }
  14082. function collectContext(state, matchChanges) {
  14083. var changes = [],
  14084. merged = [],
  14085. matchIndex = 0,
  14086. contextChanges = false,
  14087. conflicted = false;
  14088. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  14089. var change = state.lines[state.index],
  14090. match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
  14091. if (match[0] === '+') {
  14092. break;
  14093. }
  14094. contextChanges = contextChanges || change[0] !== ' ';
  14095. merged.push(match);
  14096. matchIndex++; // Consume any additions in the other block as a conflict to attempt
  14097. // to pull in the remaining context after this
  14098. if (change[0] === '+') {
  14099. conflicted = true;
  14100. while (change[0] === '+') {
  14101. changes.push(change);
  14102. change = state.lines[++state.index];
  14103. }
  14104. }
  14105. if (match.substr(1) === change.substr(1)) {
  14106. changes.push(change);
  14107. state.index++;
  14108. } else {
  14109. conflicted = true;
  14110. }
  14111. }
  14112. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  14113. conflicted = true;
  14114. }
  14115. if (conflicted) {
  14116. return changes;
  14117. }
  14118. while (matchIndex < matchChanges.length) {
  14119. merged.push(matchChanges[matchIndex++]);
  14120. }
  14121. return {
  14122. merged: merged,
  14123. changes: changes
  14124. };
  14125. }
  14126. function allRemoves(changes) {
  14127. return changes.reduce(function (prev, change) {
  14128. return prev && change[0] === '-';
  14129. }, true);
  14130. }
  14131. function skipRemoveSuperset(state, removeChanges, delta) {
  14132. for (var i = 0; i < delta; i++) {
  14133. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  14134. if (state.lines[state.index + i] !== ' ' + changeContent) {
  14135. return false;
  14136. }
  14137. }
  14138. state.index += delta;
  14139. return true;
  14140. }
  14141. function calcOldNewLineCount(lines) {
  14142. var oldLines = 0;
  14143. var newLines = 0;
  14144. lines.forEach(function (line) {
  14145. if (typeof line !== 'string') {
  14146. var myCount = calcOldNewLineCount(line.mine);
  14147. var theirCount = calcOldNewLineCount(line.theirs);
  14148. if (oldLines !== undefined) {
  14149. if (myCount.oldLines === theirCount.oldLines) {
  14150. oldLines += myCount.oldLines;
  14151. } else {
  14152. oldLines = undefined;
  14153. }
  14154. }
  14155. if (newLines !== undefined) {
  14156. if (myCount.newLines === theirCount.newLines) {
  14157. newLines += myCount.newLines;
  14158. } else {
  14159. newLines = undefined;
  14160. }
  14161. }
  14162. } else {
  14163. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  14164. newLines++;
  14165. }
  14166. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  14167. oldLines++;
  14168. }
  14169. }
  14170. });
  14171. return {
  14172. oldLines: oldLines,
  14173. newLines: newLines
  14174. };
  14175. }
  14176. var dmp = {};
  14177. /*istanbul ignore start*/
  14178. Object.defineProperty(dmp, "__esModule", {
  14179. value: true
  14180. });
  14181. dmp.convertChangesToDMP = convertChangesToDMP;
  14182. /*istanbul ignore end*/
  14183. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  14184. function convertChangesToDMP(changes) {
  14185. var ret = [],
  14186. change,
  14187. operation;
  14188. for (var i = 0; i < changes.length; i++) {
  14189. change = changes[i];
  14190. if (change.added) {
  14191. operation = 1;
  14192. } else if (change.removed) {
  14193. operation = -1;
  14194. } else {
  14195. operation = 0;
  14196. }
  14197. ret.push([operation, change.value]);
  14198. }
  14199. return ret;
  14200. }
  14201. var xml = {};
  14202. /*istanbul ignore start*/
  14203. Object.defineProperty(xml, "__esModule", {
  14204. value: true
  14205. });
  14206. xml.convertChangesToXML = convertChangesToXML;
  14207. /*istanbul ignore end*/
  14208. function convertChangesToXML(changes) {
  14209. var ret = [];
  14210. for (var i = 0; i < changes.length; i++) {
  14211. var change = changes[i];
  14212. if (change.added) {
  14213. ret.push('<ins>');
  14214. } else if (change.removed) {
  14215. ret.push('<del>');
  14216. }
  14217. ret.push(escapeHTML(change.value));
  14218. if (change.added) {
  14219. ret.push('</ins>');
  14220. } else if (change.removed) {
  14221. ret.push('</del>');
  14222. }
  14223. }
  14224. return ret.join('');
  14225. }
  14226. function escapeHTML(s) {
  14227. var n = s;
  14228. n = n.replace(/&/g, '&amp;');
  14229. n = n.replace(/</g, '&lt;');
  14230. n = n.replace(/>/g, '&gt;');
  14231. n = n.replace(/"/g, '&quot;');
  14232. return n;
  14233. }
  14234. /*istanbul ignore start*/
  14235. (function (exports) {
  14236. Object.defineProperty(exports, "__esModule", {
  14237. value: true
  14238. });
  14239. Object.defineProperty(exports, "Diff", {
  14240. enumerable: true,
  14241. get: function get() {
  14242. return _base["default"];
  14243. }
  14244. });
  14245. Object.defineProperty(exports, "diffChars", {
  14246. enumerable: true,
  14247. get: function get() {
  14248. return _character.diffChars;
  14249. }
  14250. });
  14251. Object.defineProperty(exports, "diffWords", {
  14252. enumerable: true,
  14253. get: function get() {
  14254. return _word.diffWords;
  14255. }
  14256. });
  14257. Object.defineProperty(exports, "diffWordsWithSpace", {
  14258. enumerable: true,
  14259. get: function get() {
  14260. return _word.diffWordsWithSpace;
  14261. }
  14262. });
  14263. Object.defineProperty(exports, "diffLines", {
  14264. enumerable: true,
  14265. get: function get() {
  14266. return _line.diffLines;
  14267. }
  14268. });
  14269. Object.defineProperty(exports, "diffTrimmedLines", {
  14270. enumerable: true,
  14271. get: function get() {
  14272. return _line.diffTrimmedLines;
  14273. }
  14274. });
  14275. Object.defineProperty(exports, "diffSentences", {
  14276. enumerable: true,
  14277. get: function get() {
  14278. return _sentence.diffSentences;
  14279. }
  14280. });
  14281. Object.defineProperty(exports, "diffCss", {
  14282. enumerable: true,
  14283. get: function get() {
  14284. return _css.diffCss;
  14285. }
  14286. });
  14287. Object.defineProperty(exports, "diffJson", {
  14288. enumerable: true,
  14289. get: function get() {
  14290. return _json.diffJson;
  14291. }
  14292. });
  14293. Object.defineProperty(exports, "canonicalize", {
  14294. enumerable: true,
  14295. get: function get() {
  14296. return _json.canonicalize;
  14297. }
  14298. });
  14299. Object.defineProperty(exports, "diffArrays", {
  14300. enumerable: true,
  14301. get: function get() {
  14302. return _array.diffArrays;
  14303. }
  14304. });
  14305. Object.defineProperty(exports, "applyPatch", {
  14306. enumerable: true,
  14307. get: function get() {
  14308. return _apply.applyPatch;
  14309. }
  14310. });
  14311. Object.defineProperty(exports, "applyPatches", {
  14312. enumerable: true,
  14313. get: function get() {
  14314. return _apply.applyPatches;
  14315. }
  14316. });
  14317. Object.defineProperty(exports, "parsePatch", {
  14318. enumerable: true,
  14319. get: function get() {
  14320. return _parse.parsePatch;
  14321. }
  14322. });
  14323. Object.defineProperty(exports, "merge", {
  14324. enumerable: true,
  14325. get: function get() {
  14326. return _merge.merge;
  14327. }
  14328. });
  14329. Object.defineProperty(exports, "structuredPatch", {
  14330. enumerable: true,
  14331. get: function get() {
  14332. return _create.structuredPatch;
  14333. }
  14334. });
  14335. Object.defineProperty(exports, "createTwoFilesPatch", {
  14336. enumerable: true,
  14337. get: function get() {
  14338. return _create.createTwoFilesPatch;
  14339. }
  14340. });
  14341. Object.defineProperty(exports, "createPatch", {
  14342. enumerable: true,
  14343. get: function get() {
  14344. return _create.createPatch;
  14345. }
  14346. });
  14347. Object.defineProperty(exports, "convertChangesToDMP", {
  14348. enumerable: true,
  14349. get: function get() {
  14350. return _dmp.convertChangesToDMP;
  14351. }
  14352. });
  14353. Object.defineProperty(exports, "convertChangesToXML", {
  14354. enumerable: true,
  14355. get: function get() {
  14356. return _xml.convertChangesToXML;
  14357. }
  14358. });
  14359. /*istanbul ignore end*/
  14360. var
  14361. /*istanbul ignore start*/
  14362. _base = _interopRequireDefault(base)
  14363. /*istanbul ignore end*/
  14364. ;
  14365. var
  14366. /*istanbul ignore start*/
  14367. _character = character
  14368. /*istanbul ignore end*/
  14369. ;
  14370. var
  14371. /*istanbul ignore start*/
  14372. _word = word
  14373. /*istanbul ignore end*/
  14374. ;
  14375. var
  14376. /*istanbul ignore start*/
  14377. _line = line
  14378. /*istanbul ignore end*/
  14379. ;
  14380. var
  14381. /*istanbul ignore start*/
  14382. _sentence = sentence
  14383. /*istanbul ignore end*/
  14384. ;
  14385. var
  14386. /*istanbul ignore start*/
  14387. _css = css
  14388. /*istanbul ignore end*/
  14389. ;
  14390. var
  14391. /*istanbul ignore start*/
  14392. _json = json
  14393. /*istanbul ignore end*/
  14394. ;
  14395. var
  14396. /*istanbul ignore start*/
  14397. _array = array$1
  14398. /*istanbul ignore end*/
  14399. ;
  14400. var
  14401. /*istanbul ignore start*/
  14402. _apply = apply$2
  14403. /*istanbul ignore end*/
  14404. ;
  14405. var
  14406. /*istanbul ignore start*/
  14407. _parse = parse
  14408. /*istanbul ignore end*/
  14409. ;
  14410. var
  14411. /*istanbul ignore start*/
  14412. _merge = merge$1
  14413. /*istanbul ignore end*/
  14414. ;
  14415. var
  14416. /*istanbul ignore start*/
  14417. _create = create$1
  14418. /*istanbul ignore end*/
  14419. ;
  14420. var
  14421. /*istanbul ignore start*/
  14422. _dmp = dmp
  14423. /*istanbul ignore end*/
  14424. ;
  14425. var
  14426. /*istanbul ignore start*/
  14427. _xml = xml
  14428. /*istanbul ignore end*/
  14429. ;
  14430. /*istanbul ignore start*/
  14431. function _interopRequireDefault(obj) {
  14432. return obj && obj.__esModule ? obj : {
  14433. "default": obj
  14434. };
  14435. }
  14436. /*istanbul ignore end*/
  14437. })(lib$1);
  14438. const {
  14439. promises: fs
  14440. } = require$$0__default$4["default"];
  14441. const path$1 = require$$0__default$1["default"];
  14442. const chalk$1 = source; // eslint-disable-next-line no-restricted-modules
  14443. const prettier$4 = require$$3; // eslint-disable-next-line no-restricted-modules
  14444. const {
  14445. getStdin
  14446. } = require$$4;
  14447. const {
  14448. createIgnorer,
  14449. errors
  14450. } = prettierInternal;
  14451. const {
  14452. expandPatterns,
  14453. fixWindowsSlashes
  14454. } = expandPatterns_1;
  14455. const {
  14456. getOptionsForFile
  14457. } = option;
  14458. const isTTY = isTty;
  14459. function diff(a, b) {
  14460. return lib$1.createTwoFilesPatch("", "", a, b, "", "", {
  14461. context: 2
  14462. });
  14463. }
  14464. function handleError(context, filename, error, printedFilename) {
  14465. if (error instanceof errors.UndefinedParserError) {
  14466. // Can't test on CI, `isTTY()` is always false, see ./is-tty.js
  14467. /* istanbul ignore next */
  14468. if ((context.argv.write || context.argv["ignore-unknown"]) && printedFilename) {
  14469. printedFilename.clear();
  14470. }
  14471. if (context.argv["ignore-unknown"]) {
  14472. return;
  14473. }
  14474. if (!context.argv.check && !context.argv["list-different"]) {
  14475. process.exitCode = 2;
  14476. }
  14477. context.logger.error(error.message);
  14478. return;
  14479. }
  14480. if (context.argv.write) {
  14481. // Add newline to split errors from filename line.
  14482. process.stdout.write("\n");
  14483. }
  14484. const isParseError = Boolean(error && error.loc);
  14485. const isValidationError = /^Invalid \S+ value\./.test(error && error.message);
  14486. if (isParseError) {
  14487. // `invalid.js: SyntaxError: Unexpected token (1:1)`.
  14488. context.logger.error(`${filename}: ${String(error)}`);
  14489. } else if (isValidationError || error instanceof errors.ConfigError) {
  14490. // `Invalid printWidth value. Expected an integer, but received 0.5.`
  14491. context.logger.error(error.message); // If validation fails for one file, it will fail for all of them.
  14492. process.exit(1);
  14493. } else if (error instanceof errors.DebugError) {
  14494. // `invalid.js: Some debug error message`
  14495. context.logger.error(`${filename}: ${error.message}`);
  14496. } else {
  14497. // `invalid.js: Error: Some unexpected error\n[stack trace]`
  14498. /* istanbul ignore next */
  14499. context.logger.error(filename + ": " + (error.stack || error));
  14500. } // Don't exit the process if one file failed
  14501. process.exitCode = 2;
  14502. }
  14503. function writeOutput(context, result, options) {
  14504. // Don't use `console.log` here since it adds an extra newline at the end.
  14505. process.stdout.write(context.argv["debug-check"] ? result.filepath : result.formatted);
  14506. if (options && options.cursorOffset >= 0) {
  14507. process.stderr.write(result.cursorOffset + "\n");
  14508. }
  14509. }
  14510. function listDifferent(context, input, options, filename) {
  14511. if (!context.argv.check && !context.argv["list-different"]) {
  14512. return;
  14513. }
  14514. try {
  14515. if (!options.filepath && !options.parser) {
  14516. throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
  14517. }
  14518. if (!prettier$4.check(input, options)) {
  14519. if (!context.argv.write) {
  14520. context.logger.log(filename);
  14521. process.exitCode = 1;
  14522. }
  14523. }
  14524. } catch (error) {
  14525. context.logger.error(error.message);
  14526. }
  14527. return true;
  14528. }
  14529. function format$1(context, input, opt) {
  14530. if (!opt.parser && !opt.filepath) {
  14531. throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
  14532. }
  14533. if (context.argv["debug-print-doc"]) {
  14534. const doc = prettier$4.__debug.printToDoc(input, opt);
  14535. return {
  14536. formatted: prettier$4.__debug.formatDoc(doc) + "\n"
  14537. };
  14538. }
  14539. if (context.argv["debug-print-comments"]) {
  14540. return {
  14541. formatted: prettier$4.format(JSON.stringify(prettier$4.formatWithCursor(input, opt).comments || []), {
  14542. parser: "json"
  14543. })
  14544. };
  14545. }
  14546. if (context.argv["debug-print-ast"]) {
  14547. const {
  14548. ast
  14549. } = prettier$4.__debug.parse(input, opt);
  14550. return {
  14551. formatted: JSON.stringify(ast)
  14552. };
  14553. }
  14554. if (context.argv["debug-check"]) {
  14555. const pp = prettier$4.format(input, opt);
  14556. const pppp = prettier$4.format(pp, opt);
  14557. if (pp !== pppp) {
  14558. throw new errors.DebugError("prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp));
  14559. } else {
  14560. const stringify = obj => JSON.stringify(obj, null, 2);
  14561. const ast = stringify(prettier$4.__debug.parse(input, opt,
  14562. /* massage */
  14563. true).ast);
  14564. const past = stringify(prettier$4.__debug.parse(pp, opt,
  14565. /* massage */
  14566. true).ast);
  14567. /* istanbul ignore next */
  14568. if (ast !== past) {
  14569. const MAX_AST_SIZE = 2097152; // 2MB
  14570. const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past);
  14571. throw new errors.DebugError("ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp));
  14572. }
  14573. }
  14574. return {
  14575. formatted: pp,
  14576. filepath: opt.filepath || "(stdin)\n"
  14577. };
  14578. }
  14579. /* istanbul ignore next */
  14580. if (context.argv["debug-benchmark"]) {
  14581. let benchmark;
  14582. try {
  14583. // eslint-disable-next-line import/no-extraneous-dependencies
  14584. benchmark = require("benchmark");
  14585. } catch {
  14586. context.logger.debug("'--debug-benchmark' requires the 'benchmark' package to be installed.");
  14587. process.exit(2);
  14588. }
  14589. context.logger.debug("'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module.");
  14590. const suite = new benchmark.Suite();
  14591. suite.add("format", () => {
  14592. prettier$4.formatWithCursor(input, opt);
  14593. }).on("cycle", event => {
  14594. const results = {
  14595. benchmark: String(event.target),
  14596. hz: event.target.hz,
  14597. ms: event.target.times.cycle * 1000
  14598. };
  14599. context.logger.debug("'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
  14600. }).run({
  14601. async: false
  14602. });
  14603. } else if (context.argv["debug-repeat"] > 0) {
  14604. const repeat = context.argv["debug-repeat"];
  14605. context.logger.debug("'--debug-repeat' option found, running formatWithCursor " + repeat + " times.");
  14606. let totalMs = 0;
  14607. for (let i = 0; i < repeat; ++i) {
  14608. // should be using `performance.now()`, but only `Date` is cross-platform enough
  14609. const startMs = Date.now();
  14610. prettier$4.formatWithCursor(input, opt);
  14611. totalMs += Date.now() - startMs;
  14612. }
  14613. const averageMs = totalMs / repeat;
  14614. const results = {
  14615. repeat,
  14616. hz: 1000 / averageMs,
  14617. ms: averageMs
  14618. };
  14619. context.logger.debug("'--debug-repeat' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
  14620. }
  14621. return prettier$4.formatWithCursor(input, opt);
  14622. }
  14623. async function createIgnorerFromContextOrDie(context) {
  14624. try {
  14625. return await createIgnorer(context.argv["ignore-path"], context.argv["with-node-modules"]);
  14626. } catch (e) {
  14627. context.logger.error(e.message);
  14628. process.exit(2);
  14629. }
  14630. }
  14631. async function formatStdin$1(context) {
  14632. const filepath = context.argv["stdin-filepath"] ? path$1.resolve(process.cwd(), context.argv["stdin-filepath"]) : process.cwd();
  14633. const ignorer = await createIgnorerFromContextOrDie(context); // If there's an ignore-path set, the filename must be relative to the
  14634. // ignore path, not the current working directory.
  14635. const relativeFilepath = context.argv["ignore-path"] ? path$1.relative(path$1.dirname(context.argv["ignore-path"]), filepath) : path$1.relative(process.cwd(), filepath);
  14636. try {
  14637. const input = await getStdin();
  14638. if (relativeFilepath && ignorer.ignores(fixWindowsSlashes(relativeFilepath))) {
  14639. writeOutput(context, {
  14640. formatted: input
  14641. });
  14642. return;
  14643. }
  14644. const options = await getOptionsForFile(context, filepath);
  14645. if (listDifferent(context, input, options, "(stdin)")) {
  14646. return;
  14647. }
  14648. writeOutput(context, format$1(context, input, options), options);
  14649. } catch (error) {
  14650. handleError(context, relativeFilepath || "stdin", error);
  14651. }
  14652. }
  14653. async function formatFiles$1(context) {
  14654. // The ignorer will be used to filter file paths after the glob is checked,
  14655. // before any files are actually written
  14656. const ignorer = await createIgnorerFromContextOrDie(context);
  14657. let numberOfUnformattedFilesFound = 0;
  14658. if (context.argv.check) {
  14659. context.logger.log("Checking formatting...");
  14660. }
  14661. for await (const pathOrError of expandPatterns(context)) {
  14662. if (typeof pathOrError === "object") {
  14663. context.logger.error(pathOrError.error); // Don't exit, but set the exit code to 2
  14664. process.exitCode = 2;
  14665. continue;
  14666. }
  14667. const filename = pathOrError; // If there's an ignore-path set, the filename must be relative to the
  14668. // ignore path, not the current working directory.
  14669. const ignoreFilename = context.argv["ignore-path"] ? path$1.relative(path$1.dirname(context.argv["ignore-path"]), filename) : filename;
  14670. const fileIgnored = ignorer.ignores(fixWindowsSlashes(ignoreFilename));
  14671. if (fileIgnored && (context.argv["debug-check"] || context.argv.write || context.argv.check || context.argv["list-different"])) {
  14672. continue;
  14673. }
  14674. const options = Object.assign(Object.assign({}, await getOptionsForFile(context, filename)), {}, {
  14675. filepath: filename
  14676. });
  14677. let printedFilename;
  14678. if (isTTY()) {
  14679. printedFilename = context.logger.log(filename, {
  14680. newline: false,
  14681. clearable: true
  14682. });
  14683. }
  14684. let input;
  14685. try {
  14686. input = await fs.readFile(filename, "utf8");
  14687. } catch (error) {
  14688. // Add newline to split errors from filename line.
  14689. /* istanbul ignore next */
  14690. context.logger.log("");
  14691. /* istanbul ignore next */
  14692. context.logger.error(`Unable to read file: ${filename}\n${error.message}`); // Don't exit the process if one file failed
  14693. /* istanbul ignore next */
  14694. process.exitCode = 2;
  14695. /* istanbul ignore next */
  14696. continue;
  14697. }
  14698. if (fileIgnored) {
  14699. writeOutput(context, {
  14700. formatted: input
  14701. }, options);
  14702. continue;
  14703. }
  14704. const start = Date.now();
  14705. let result;
  14706. let output;
  14707. try {
  14708. result = format$1(context, input, options);
  14709. output = result.formatted;
  14710. } catch (error) {
  14711. handleError(context, filename, error, printedFilename);
  14712. continue;
  14713. }
  14714. const isDifferent = output !== input;
  14715. if (printedFilename) {
  14716. // Remove previously printed filename to log it with duration.
  14717. printedFilename.clear();
  14718. }
  14719. if (context.argv.write) {
  14720. // Don't write the file if it won't change in order not to invalidate
  14721. // mtime based caches.
  14722. if (isDifferent) {
  14723. if (!context.argv.check && !context.argv["list-different"]) {
  14724. context.logger.log(`${filename} ${Date.now() - start}ms`);
  14725. }
  14726. try {
  14727. await fs.writeFile(filename, output, "utf8");
  14728. } catch (error) {
  14729. /* istanbul ignore next */
  14730. context.logger.error(`Unable to write file: ${filename}\n${error.message}`); // Don't exit the process if one file failed
  14731. /* istanbul ignore next */
  14732. process.exitCode = 2;
  14733. }
  14734. } else if (!context.argv.check && !context.argv["list-different"]) {
  14735. context.logger.log(`${chalk$1.grey(filename)} ${Date.now() - start}ms`);
  14736. }
  14737. } else if (context.argv["debug-check"]) {
  14738. /* istanbul ignore else */
  14739. if (result.filepath) {
  14740. context.logger.log(result.filepath);
  14741. } else {
  14742. process.exitCode = 2;
  14743. }
  14744. } else if (!context.argv.check && !context.argv["list-different"]) {
  14745. writeOutput(context, result, options);
  14746. }
  14747. if (isDifferent) {
  14748. if (context.argv.check) {
  14749. context.logger.warn(filename);
  14750. } else if (context.argv["list-different"]) {
  14751. context.logger.log(filename);
  14752. }
  14753. numberOfUnformattedFilesFound += 1;
  14754. }
  14755. } // Print check summary based on expected exit code
  14756. if (context.argv.check) {
  14757. if (numberOfUnformattedFilesFound === 0) {
  14758. context.logger.log("All matched files use Prettier code style!");
  14759. } else {
  14760. context.logger.warn(context.argv.write ? "Code style issues fixed in the above file(s)." : "Code style issues found in the above file(s). Forgot to run Prettier?");
  14761. }
  14762. } // Ensure non-zero exitCode when using --check/list-different is not combined with --write
  14763. if ((context.argv.check || context.argv["list-different"]) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
  14764. process.exitCode = 1;
  14765. }
  14766. }
  14767. var format_1 = {
  14768. format: format$1,
  14769. formatStdin: formatStdin$1,
  14770. formatFiles: formatFiles$1
  14771. };
  14772. var getNative = _getNative;
  14773. var defineProperty$2 = function () {
  14774. try {
  14775. var func = getNative(Object, 'defineProperty');
  14776. func({}, '', {});
  14777. return func;
  14778. } catch (e) {}
  14779. }();
  14780. var _defineProperty = defineProperty$2;
  14781. var defineProperty$1 = _defineProperty;
  14782. /**
  14783. * The base implementation of `assignValue` and `assignMergeValue` without
  14784. * value checks.
  14785. *
  14786. * @private
  14787. * @param {Object} object The object to modify.
  14788. * @param {string} key The key of the property to assign.
  14789. * @param {*} value The value to assign.
  14790. */
  14791. function baseAssignValue$2(object, key, value) {
  14792. if (key == '__proto__' && defineProperty$1) {
  14793. defineProperty$1(object, key, {
  14794. 'configurable': true,
  14795. 'enumerable': true,
  14796. 'value': value,
  14797. 'writable': true
  14798. });
  14799. } else {
  14800. object[key] = value;
  14801. }
  14802. }
  14803. var _baseAssignValue = baseAssignValue$2;
  14804. var baseAssignValue$1 = _baseAssignValue,
  14805. eq = eq_1;
  14806. /** Used for built-in method references. */
  14807. var objectProto$1 = Object.prototype;
  14808. /** Used to check objects for own properties. */
  14809. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  14810. /**
  14811. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  14812. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  14813. * for equality comparisons.
  14814. *
  14815. * @private
  14816. * @param {Object} object The object to modify.
  14817. * @param {string} key The key of the property to assign.
  14818. * @param {*} value The value to assign.
  14819. */
  14820. function assignValue$1(object, key, value) {
  14821. var objValue = object[key];
  14822. if (!(hasOwnProperty$1.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
  14823. baseAssignValue$1(object, key, value);
  14824. }
  14825. }
  14826. var _assignValue = assignValue$1;
  14827. var assignValue = _assignValue,
  14828. castPath$1 = _castPath,
  14829. isIndex = _isIndex,
  14830. isObject = isObject_1,
  14831. toKey = _toKey;
  14832. /**
  14833. * The base implementation of `_.set`.
  14834. *
  14835. * @private
  14836. * @param {Object} object The object to modify.
  14837. * @param {Array|string} path The path of the property to set.
  14838. * @param {*} value The value to set.
  14839. * @param {Function} [customizer] The function to customize path creation.
  14840. * @returns {Object} Returns `object`.
  14841. */
  14842. function baseSet$1(object, path, value, customizer) {
  14843. if (!isObject(object)) {
  14844. return object;
  14845. }
  14846. path = castPath$1(path, object);
  14847. var index = -1,
  14848. length = path.length,
  14849. lastIndex = length - 1,
  14850. nested = object;
  14851. while (nested != null && ++index < length) {
  14852. var key = toKey(path[index]),
  14853. newValue = value;
  14854. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  14855. return object;
  14856. }
  14857. if (index != lastIndex) {
  14858. var objValue = nested[key];
  14859. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  14860. if (newValue === undefined) {
  14861. newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
  14862. }
  14863. }
  14864. assignValue(nested, key, newValue);
  14865. nested = nested[key];
  14866. }
  14867. return object;
  14868. }
  14869. var _baseSet = baseSet$1;
  14870. var baseGet = _baseGet,
  14871. baseSet = _baseSet,
  14872. castPath = _castPath;
  14873. /**
  14874. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  14875. *
  14876. * @private
  14877. * @param {Object} object The source object.
  14878. * @param {string[]} paths The property paths to pick.
  14879. * @param {Function} predicate The function invoked per property.
  14880. * @returns {Object} Returns the new object.
  14881. */
  14882. function basePickBy$1(object, paths, predicate) {
  14883. var index = -1,
  14884. length = paths.length,
  14885. result = {};
  14886. while (++index < length) {
  14887. var path = paths[index],
  14888. value = baseGet(object, path);
  14889. if (predicate(value, path)) {
  14890. baseSet(result, castPath(path, object), value);
  14891. }
  14892. }
  14893. return result;
  14894. }
  14895. var _basePickBy = basePickBy$1;
  14896. var basePickBy = _basePickBy,
  14897. hasIn = hasIn_1;
  14898. /**
  14899. * The base implementation of `_.pick` without support for individual
  14900. * property identifiers.
  14901. *
  14902. * @private
  14903. * @param {Object} object The source object.
  14904. * @param {string[]} paths The property paths to pick.
  14905. * @returns {Object} Returns the new object.
  14906. */
  14907. function basePick$1(object, paths) {
  14908. return basePickBy(object, paths, function (value, path) {
  14909. return hasIn(object, path);
  14910. });
  14911. }
  14912. var _basePick = basePick$1;
  14913. var Symbol$1 = _Symbol,
  14914. isArguments = isArguments_1,
  14915. isArray = isArray_1;
  14916. /** Built-in value references. */
  14917. var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
  14918. /**
  14919. * Checks if `value` is a flattenable `arguments` object or array.
  14920. *
  14921. * @private
  14922. * @param {*} value The value to check.
  14923. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  14924. */
  14925. function isFlattenable$1(value) {
  14926. return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
  14927. }
  14928. var _isFlattenable = isFlattenable$1;
  14929. var arrayPush = _arrayPush,
  14930. isFlattenable = _isFlattenable;
  14931. /**
  14932. * The base implementation of `_.flatten` with support for restricting flattening.
  14933. *
  14934. * @private
  14935. * @param {Array} array The array to flatten.
  14936. * @param {number} depth The maximum recursion depth.
  14937. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  14938. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  14939. * @param {Array} [result=[]] The initial result value.
  14940. * @returns {Array} Returns the new flattened array.
  14941. */
  14942. function baseFlatten$1(array, depth, predicate, isStrict, result) {
  14943. var index = -1,
  14944. length = array.length;
  14945. predicate || (predicate = isFlattenable);
  14946. result || (result = []);
  14947. while (++index < length) {
  14948. var value = array[index];
  14949. if (depth > 0 && predicate(value)) {
  14950. if (depth > 1) {
  14951. // Recursively flatten arrays (susceptible to call stack limits).
  14952. baseFlatten$1(value, depth - 1, predicate, isStrict, result);
  14953. } else {
  14954. arrayPush(result, value);
  14955. }
  14956. } else if (!isStrict) {
  14957. result[result.length] = value;
  14958. }
  14959. }
  14960. return result;
  14961. }
  14962. var _baseFlatten = baseFlatten$1;
  14963. var baseFlatten = _baseFlatten;
  14964. /**
  14965. * Flattens `array` a single level deep.
  14966. *
  14967. * @static
  14968. * @memberOf _
  14969. * @since 0.1.0
  14970. * @category Array
  14971. * @param {Array} array The array to flatten.
  14972. * @returns {Array} Returns the new flattened array.
  14973. * @example
  14974. *
  14975. * _.flatten([1, [2, [3, [4]], 5]]);
  14976. * // => [1, 2, [3, [4]], 5]
  14977. */
  14978. function flatten$1(array) {
  14979. var length = array == null ? 0 : array.length;
  14980. return length ? baseFlatten(array, 1) : [];
  14981. }
  14982. var flatten_1 = flatten$1;
  14983. /**
  14984. * A faster alternative to `Function#apply`, this function invokes `func`
  14985. * with the `this` binding of `thisArg` and the arguments of `args`.
  14986. *
  14987. * @private
  14988. * @param {Function} func The function to invoke.
  14989. * @param {*} thisArg The `this` binding of `func`.
  14990. * @param {Array} args The arguments to invoke `func` with.
  14991. * @returns {*} Returns the result of `func`.
  14992. */
  14993. function apply$1(func, thisArg, args) {
  14994. switch (args.length) {
  14995. case 0:
  14996. return func.call(thisArg);
  14997. case 1:
  14998. return func.call(thisArg, args[0]);
  14999. case 2:
  15000. return func.call(thisArg, args[0], args[1]);
  15001. case 3:
  15002. return func.call(thisArg, args[0], args[1], args[2]);
  15003. }
  15004. return func.apply(thisArg, args);
  15005. }
  15006. var _apply = apply$1;
  15007. var apply = _apply;
  15008. /* Built-in method references for those with the same name as other `lodash` methods. */
  15009. var nativeMax = Math.max;
  15010. /**
  15011. * A specialized version of `baseRest` which transforms the rest array.
  15012. *
  15013. * @private
  15014. * @param {Function} func The function to apply a rest parameter to.
  15015. * @param {number} [start=func.length-1] The start position of the rest parameter.
  15016. * @param {Function} transform The rest array transform.
  15017. * @returns {Function} Returns the new function.
  15018. */
  15019. function overRest$1(func, start, transform) {
  15020. start = nativeMax(start === undefined ? func.length - 1 : start, 0);
  15021. return function () {
  15022. var args = arguments,
  15023. index = -1,
  15024. length = nativeMax(args.length - start, 0),
  15025. array = Array(length);
  15026. while (++index < length) {
  15027. array[index] = args[start + index];
  15028. }
  15029. index = -1;
  15030. var otherArgs = Array(start + 1);
  15031. while (++index < start) {
  15032. otherArgs[index] = args[index];
  15033. }
  15034. otherArgs[start] = transform(array);
  15035. return apply(func, this, otherArgs);
  15036. };
  15037. }
  15038. var _overRest = overRest$1;
  15039. /**
  15040. * Creates a function that returns `value`.
  15041. *
  15042. * @static
  15043. * @memberOf _
  15044. * @since 2.4.0
  15045. * @category Util
  15046. * @param {*} value The value to return from the new function.
  15047. * @returns {Function} Returns the new constant function.
  15048. * @example
  15049. *
  15050. * var objects = _.times(2, _.constant({ 'a': 1 }));
  15051. *
  15052. * console.log(objects);
  15053. * // => [{ 'a': 1 }, { 'a': 1 }]
  15054. *
  15055. * console.log(objects[0] === objects[1]);
  15056. * // => true
  15057. */
  15058. function constant$4(value) {
  15059. return function () {
  15060. return value;
  15061. };
  15062. }
  15063. var constant_1 = constant$4;
  15064. var constant$3 = constant_1,
  15065. defineProperty = _defineProperty,
  15066. identity = identity_1;
  15067. /**
  15068. * The base implementation of `setToString` without support for hot loop shorting.
  15069. *
  15070. * @private
  15071. * @param {Function} func The function to modify.
  15072. * @param {Function} string The `toString` result.
  15073. * @returns {Function} Returns `func`.
  15074. */
  15075. var baseSetToString$1 = !defineProperty ? identity : function (func, string) {
  15076. return defineProperty(func, 'toString', {
  15077. 'configurable': true,
  15078. 'enumerable': false,
  15079. 'value': constant$3(string),
  15080. 'writable': true
  15081. });
  15082. };
  15083. var _baseSetToString = baseSetToString$1;
  15084. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  15085. var HOT_COUNT = 800,
  15086. HOT_SPAN = 16;
  15087. /* Built-in method references for those with the same name as other `lodash` methods. */
  15088. var nativeNow = Date.now;
  15089. /**
  15090. * Creates a function that'll short out and invoke `identity` instead
  15091. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  15092. * milliseconds.
  15093. *
  15094. * @private
  15095. * @param {Function} func The function to restrict.
  15096. * @returns {Function} Returns the new shortable function.
  15097. */
  15098. function shortOut$1(func) {
  15099. var count = 0,
  15100. lastCalled = 0;
  15101. return function () {
  15102. var stamp = nativeNow(),
  15103. remaining = HOT_SPAN - (stamp - lastCalled);
  15104. lastCalled = stamp;
  15105. if (remaining > 0) {
  15106. if (++count >= HOT_COUNT) {
  15107. return arguments[0];
  15108. }
  15109. } else {
  15110. count = 0;
  15111. }
  15112. return func.apply(undefined, arguments);
  15113. };
  15114. }
  15115. var _shortOut = shortOut$1;
  15116. var baseSetToString = _baseSetToString,
  15117. shortOut = _shortOut;
  15118. /**
  15119. * Sets the `toString` method of `func` to return `string`.
  15120. *
  15121. * @private
  15122. * @param {Function} func The function to modify.
  15123. * @param {Function} string The `toString` result.
  15124. * @returns {Function} Returns `func`.
  15125. */
  15126. var setToString$1 = shortOut(baseSetToString);
  15127. var _setToString = setToString$1;
  15128. var flatten = flatten_1,
  15129. overRest = _overRest,
  15130. setToString = _setToString;
  15131. /**
  15132. * A specialized version of `baseRest` which flattens the rest array.
  15133. *
  15134. * @private
  15135. * @param {Function} func The function to apply a rest parameter to.
  15136. * @returns {Function} Returns the new function.
  15137. */
  15138. function flatRest$1(func) {
  15139. return setToString(overRest(func, undefined, flatten), func + '');
  15140. }
  15141. var _flatRest = flatRest$1;
  15142. var basePick = _basePick,
  15143. flatRest = _flatRest;
  15144. /**
  15145. * Creates an object composed of the picked `object` properties.
  15146. *
  15147. * @static
  15148. * @since 0.1.0
  15149. * @memberOf _
  15150. * @category Object
  15151. * @param {Object} object The source object.
  15152. * @param {...(string|string[])} [paths] The property paths to pick.
  15153. * @returns {Object} Returns the new object.
  15154. * @example
  15155. *
  15156. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  15157. *
  15158. * _.pick(object, ['a', 'c']);
  15159. * // => { 'a': 1, 'c': 3 }
  15160. */
  15161. var pick$1 = flatRest(function (object, paths) {
  15162. return object == null ? {} : basePick(object, paths);
  15163. });
  15164. var pick_1 = pick$1;
  15165. var lib = {exports: {}};
  15166. (function (module, exports) {
  15167. Object.defineProperty(exports, "__esModule", {
  15168. value: true
  15169. });
  15170. exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
  15171. function noop() {
  15172. var args = [];
  15173. for (var _i = 0; _i < arguments.length; _i++) {
  15174. args[_i] = arguments[_i];
  15175. }
  15176. }
  15177. function createWeakMap() {
  15178. if (typeof WeakMap !== "undefined") {
  15179. return new WeakMap();
  15180. } else {
  15181. return fakeSetOrMap();
  15182. }
  15183. }
  15184. /**
  15185. * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
  15186. */
  15187. function fakeSetOrMap() {
  15188. return {
  15189. add: noop,
  15190. delete: noop,
  15191. get: noop,
  15192. set: noop,
  15193. has: function (k) {
  15194. return false;
  15195. }
  15196. };
  15197. } // Safe hasOwnProperty
  15198. var hop = Object.prototype.hasOwnProperty;
  15199. var has = function (obj, prop) {
  15200. return hop.call(obj, prop);
  15201. }; // Copy all own enumerable properties from source to target
  15202. function extend(target, source) {
  15203. for (var prop in source) {
  15204. if (has(source, prop)) {
  15205. target[prop] = source[prop];
  15206. }
  15207. }
  15208. return target;
  15209. }
  15210. var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
  15211. var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
  15212. var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
  15213. var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
  15214. var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
  15215. function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
  15216. // If first interpolated value is a reference to outdent,
  15217. // determine indentation level from the indentation of the interpolated value.
  15218. var indentationLevel = 0;
  15219. var match = strings[0].match(reDetectIndentation);
  15220. if (match) {
  15221. indentationLevel = match[1].length;
  15222. }
  15223. var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
  15224. var reMatchIndent = new RegExp(reSource, "g");
  15225. if (firstInterpolatedValueSetsIndentationLevel) {
  15226. strings = strings.slice(1);
  15227. }
  15228. var newline = options.newline,
  15229. trimLeadingNewline = options.trimLeadingNewline,
  15230. trimTrailingNewline = options.trimTrailingNewline;
  15231. var normalizeNewlines = typeof newline === "string";
  15232. var l = strings.length;
  15233. var outdentedStrings = strings.map(function (v, i) {
  15234. // Remove leading indentation from all lines
  15235. v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
  15236. if (i === 0 && trimLeadingNewline) {
  15237. v = v.replace(reLeadingNewline, "");
  15238. } // Trim a trailing newline from the last string
  15239. if (i === l - 1 && trimTrailingNewline) {
  15240. v = v.replace(reTrailingNewline, "");
  15241. } // Normalize newlines
  15242. if (normalizeNewlines) {
  15243. v = v.replace(/\r\n|\n|\r/g, function (_) {
  15244. return newline;
  15245. });
  15246. }
  15247. return v;
  15248. });
  15249. return outdentedStrings;
  15250. }
  15251. function concatStringsAndValues(strings, values) {
  15252. var ret = "";
  15253. for (var i = 0, l = strings.length; i < l; i++) {
  15254. ret += strings[i];
  15255. if (i < l - 1) {
  15256. ret += values[i];
  15257. }
  15258. }
  15259. return ret;
  15260. }
  15261. function isTemplateStringsArray(v) {
  15262. return has(v, "raw") && has(v, "length");
  15263. }
  15264. /**
  15265. * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
  15266. * makeInstance
  15267. * @param options
  15268. * @return {outdent}
  15269. */
  15270. function createInstance(options) {
  15271. /** Cache of pre-processed template literal arrays */
  15272. var arrayAutoIndentCache = createWeakMap();
  15273. /**
  15274. * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
  15275. * before interpolated values are injected.
  15276. */
  15277. var arrayFirstInterpSetsIndentCache = createWeakMap();
  15278. function outdent(stringsOrOptions) {
  15279. var values = [];
  15280. for (var _i = 1; _i < arguments.length; _i++) {
  15281. values[_i - 1] = arguments[_i];
  15282. }
  15283. /* tslint:enable:no-shadowed-variable */
  15284. if (isTemplateStringsArray(stringsOrOptions)) {
  15285. var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
  15286. var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
  15287. var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
  15288. var renderedArray = cache.get(strings);
  15289. if (!renderedArray) {
  15290. renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
  15291. cache.set(strings, renderedArray);
  15292. }
  15293. /** If no interpolated values, skip concatenation step */
  15294. if (values.length === 0) {
  15295. return renderedArray[0];
  15296. }
  15297. /** Concatenate string literals with interpolated values */
  15298. var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
  15299. return rendered;
  15300. } else {
  15301. // Create and return a new instance of outdent with the given options
  15302. return createInstance(extend(extend({}, options), stringsOrOptions || {}));
  15303. }
  15304. }
  15305. var fullOutdent = extend(outdent, {
  15306. string: function (str) {
  15307. return _outdentArray([str], false, options)[0];
  15308. }
  15309. });
  15310. return fullOutdent;
  15311. }
  15312. var defaultOutdent = createInstance({
  15313. trimLeadingNewline: true,
  15314. trimTrailingNewline: true
  15315. });
  15316. exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
  15317. // import outdent from 'outdent';
  15318. exports.default = defaultOutdent;
  15319. {
  15320. // In webpack harmony-modules environments, module.exports is read-only,
  15321. // so we fail gracefully.
  15322. try {
  15323. module.exports = defaultOutdent;
  15324. Object.defineProperty(defaultOutdent, "__esModule", {
  15325. value: true
  15326. });
  15327. defaultOutdent.default = defaultOutdent;
  15328. defaultOutdent.outdent = defaultOutdent;
  15329. } catch (e) {}
  15330. }
  15331. })(lib, lib.exports);
  15332. const {
  15333. outdent
  15334. } = lib.exports;
  15335. const {
  15336. coreOptions: coreOptions$1
  15337. } = prettierInternal;
  15338. const categoryOrder = [coreOptions$1.CATEGORY_OUTPUT, coreOptions$1.CATEGORY_FORMAT, coreOptions$1.CATEGORY_CONFIG, coreOptions$1.CATEGORY_EDITOR, coreOptions$1.CATEGORY_OTHER];
  15339. /**
  15340. * {
  15341. * [optionName]: {
  15342. * // The type of the option. For 'choice', see also `choices` below.
  15343. * // When passing a type other than the ones listed below, the option is
  15344. * // treated as taking any string as argument, and `--option <${type}>` will
  15345. * // be displayed in --help.
  15346. * type: "boolean" | "choice" | "int" | string;
  15347. *
  15348. * // Default value to be passed to the minimist option `default`.
  15349. * default?: any;
  15350. *
  15351. * // Alias name to be passed to the minimist option `alias`.
  15352. * alias?: string;
  15353. *
  15354. * // For grouping options by category in --help.
  15355. * category?: string;
  15356. *
  15357. * // Description to be displayed in --help. If omitted, the option won't be
  15358. * // shown at all in --help (but see also `oppositeDescription` below).
  15359. * description?: string;
  15360. *
  15361. * // Description for `--no-${name}` to be displayed in --help. If omitted,
  15362. * // `--no-${name}` won't be shown.
  15363. * oppositeDescription?: string;
  15364. *
  15365. * // Indicate if this option is simply passed to the API.
  15366. * // true: use camelified name as the API option name.
  15367. * // string: use this value as the API option name.
  15368. * forwardToApi?: boolean | string;
  15369. *
  15370. * // Indicate that a CLI flag should be an array when forwarded to the API.
  15371. * array?: boolean;
  15372. *
  15373. * // Specify available choices for validation. They will also be displayed
  15374. * // in --help as <a|b|c>.
  15375. * // Use an object instead of a string if a choice is deprecated and should
  15376. * // be treated as `redirect` instead, or if you'd like to add description for
  15377. * // the choice.
  15378. * choices?: Array<
  15379. * | string
  15380. * | { value: string, description?: string, deprecated?: boolean, redirect?: string }
  15381. * >;
  15382. *
  15383. * // If the option has a value that is an exception to the regular value
  15384. * // constraints, indicate that value here (or use a function for more
  15385. * // flexibility).
  15386. * exception?: ((value: any) => boolean);
  15387. *
  15388. * // Indicate that the option is deprecated. Use a string to add an extra
  15389. * // message to --help for the option, for example to suggest a replacement
  15390. * // option.
  15391. * deprecated?: true | string;
  15392. * }
  15393. * }
  15394. *
  15395. * Note: The options below are sorted alphabetically.
  15396. */
  15397. const options = {
  15398. check: {
  15399. type: "boolean",
  15400. category: coreOptions$1.CATEGORY_OUTPUT,
  15401. alias: "c",
  15402. description: outdent`
  15403. Check if the given files are formatted, print a human-friendly summary
  15404. message and paths to unformatted files (see also --list-different).
  15405. `
  15406. },
  15407. color: {
  15408. // The supports-color package (a sub sub dependency) looks directly at
  15409. // `process.argv` for `--no-color` and such-like options. The reason it is
  15410. // listed here is to avoid "Ignored unknown option: --no-color" warnings.
  15411. // See https://github.com/chalk/supports-color/#info for more information.
  15412. type: "boolean",
  15413. default: true,
  15414. description: "Colorize error messages.",
  15415. oppositeDescription: "Do not colorize error messages."
  15416. },
  15417. config: {
  15418. type: "path",
  15419. category: coreOptions$1.CATEGORY_CONFIG,
  15420. description: "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).",
  15421. oppositeDescription: "Do not look for a configuration file.",
  15422. exception: value => value === false
  15423. },
  15424. "config-precedence": {
  15425. type: "choice",
  15426. category: coreOptions$1.CATEGORY_CONFIG,
  15427. default: "cli-override",
  15428. choices: [{
  15429. value: "cli-override",
  15430. description: "CLI options take precedence over config file"
  15431. }, {
  15432. value: "file-override",
  15433. description: "Config file take precedence over CLI options"
  15434. }, {
  15435. value: "prefer-file",
  15436. description: outdent`
  15437. If a config file is found will evaluate it and ignore other CLI options.
  15438. If no config file is found CLI options will evaluate as normal.
  15439. `
  15440. }],
  15441. description: "Define in which order config files and CLI options should be evaluated."
  15442. },
  15443. "debug-benchmark": {
  15444. // Run the formatting benchmarks. Requires 'benchmark' module to be installed.
  15445. type: "boolean"
  15446. },
  15447. "debug-check": {
  15448. // Run the formatting once again on the formatted output, throw if different.
  15449. type: "boolean"
  15450. },
  15451. "debug-print-doc": {
  15452. type: "boolean"
  15453. },
  15454. "debug-print-comments": {
  15455. type: "boolean"
  15456. },
  15457. "debug-print-ast": {
  15458. type: "boolean"
  15459. },
  15460. "debug-repeat": {
  15461. // Repeat the formatting a few times and measure the average duration.
  15462. type: "int",
  15463. default: 0
  15464. },
  15465. editorconfig: {
  15466. type: "boolean",
  15467. category: coreOptions$1.CATEGORY_CONFIG,
  15468. description: "Take .editorconfig into account when parsing configuration.",
  15469. oppositeDescription: "Don't take .editorconfig into account when parsing configuration.",
  15470. default: true
  15471. },
  15472. "error-on-unmatched-pattern": {
  15473. type: "boolean",
  15474. oppositeDescription: "Prevent errors when pattern is unmatched."
  15475. },
  15476. "find-config-path": {
  15477. type: "path",
  15478. category: coreOptions$1.CATEGORY_CONFIG,
  15479. description: "Find and print the path to a configuration file for the given input file."
  15480. },
  15481. "file-info": {
  15482. type: "path",
  15483. description: outdent`
  15484. Extract the following info (as JSON) for a given file path. Reported fields:
  15485. * ignored (boolean) - true if file path is filtered by --ignore-path
  15486. * inferredParser (string | null) - name of parser inferred from file path
  15487. `
  15488. },
  15489. help: {
  15490. type: "flag",
  15491. alias: "h",
  15492. description: outdent`
  15493. Show CLI usage, or details about the given flag.
  15494. Example: --help write
  15495. `,
  15496. exception: value => value === ""
  15497. },
  15498. "ignore-path": {
  15499. type: "path",
  15500. category: coreOptions$1.CATEGORY_CONFIG,
  15501. default: ".prettierignore",
  15502. description: "Path to a file with patterns describing files to ignore."
  15503. },
  15504. "ignore-unknown": {
  15505. type: "boolean",
  15506. alias: "u",
  15507. description: "Ignore unknown files."
  15508. },
  15509. "list-different": {
  15510. type: "boolean",
  15511. category: coreOptions$1.CATEGORY_OUTPUT,
  15512. alias: "l",
  15513. description: "Print the names of files that are different from Prettier's formatting (see also --check)."
  15514. },
  15515. loglevel: {
  15516. type: "choice",
  15517. description: "What level of logs to report.",
  15518. default: "log",
  15519. choices: ["silent", "error", "warn", "log", "debug"]
  15520. },
  15521. "support-info": {
  15522. type: "boolean",
  15523. description: "Print support information as JSON."
  15524. },
  15525. version: {
  15526. type: "boolean",
  15527. alias: "v",
  15528. description: "Print Prettier version."
  15529. },
  15530. "with-node-modules": {
  15531. type: "boolean",
  15532. category: coreOptions$1.CATEGORY_CONFIG,
  15533. description: "Process files inside 'node_modules' directory."
  15534. },
  15535. write: {
  15536. type: "boolean",
  15537. alias: "w",
  15538. category: coreOptions$1.CATEGORY_OUTPUT,
  15539. description: "Edit files in-place. (Beware!)"
  15540. }
  15541. };
  15542. const usageSummary = outdent`
  15543. Usage: prettier [options] [file/dir/glob ...]
  15544. By default, output is written to stdout.
  15545. Stdin is read if it is piped to Prettier and no files are given.
  15546. `;
  15547. var constant$2 = {
  15548. categoryOrder,
  15549. options,
  15550. usageSummary
  15551. };
  15552. const dashify = dashify$2;
  15553. const {
  15554. coreOptions
  15555. } = prettierInternal;
  15556. function normalizeDetailedOption(name, option) {
  15557. return Object.assign(Object.assign({
  15558. category: coreOptions.CATEGORY_OTHER
  15559. }, option), {}, {
  15560. choices: option.choices && option.choices.map(choice => {
  15561. const newChoice = Object.assign({
  15562. description: "",
  15563. deprecated: false
  15564. }, typeof choice === "object" ? choice : {
  15565. value: choice
  15566. });
  15567. /* istanbul ignore next */
  15568. if (newChoice.value === true) {
  15569. newChoice.value = ""; // backward compatibility for original boolean option
  15570. }
  15571. return newChoice;
  15572. })
  15573. });
  15574. }
  15575. function normalizeDetailedOptionMap$2(detailedOptionMap) {
  15576. return Object.fromEntries(Object.entries(detailedOptionMap).sort(([leftName], [rightName]) => leftName.localeCompare(rightName)).map(([name, option]) => [name, normalizeDetailedOption(name, option)]));
  15577. }
  15578. function createDetailedOptionMap$2(supportOptions) {
  15579. return Object.fromEntries(supportOptions.map(option => {
  15580. const newOption = Object.assign(Object.assign({}, option), {}, {
  15581. name: option.cliName || dashify(option.name),
  15582. description: option.cliDescription || option.description,
  15583. category: option.cliCategory || coreOptions.CATEGORY_FORMAT,
  15584. forwardToApi: option.name
  15585. });
  15586. /* istanbul ignore next */
  15587. if (option.deprecated) {
  15588. delete newOption.forwardToApi;
  15589. delete newOption.description;
  15590. delete newOption.oppositeDescription;
  15591. newOption.deprecated = true;
  15592. }
  15593. return [newOption.name, newOption];
  15594. }));
  15595. }
  15596. var optionMap = {
  15597. normalizeDetailedOptionMap: normalizeDetailedOptionMap$2,
  15598. createDetailedOptionMap: createDetailedOptionMap$2
  15599. };
  15600. const pick = pick_1; // eslint-disable-next-line no-restricted-modules
  15601. const prettier$3 = require$$3;
  15602. const {
  15603. optionsModule,
  15604. optionsNormalizer: {
  15605. normalizeCliOptions
  15606. },
  15607. utils: {
  15608. arrayify
  15609. }
  15610. } = prettierInternal;
  15611. const minimist = minimist_1;
  15612. const constant$1 = constant$2;
  15613. const {
  15614. createDetailedOptionMap: createDetailedOptionMap$1,
  15615. normalizeDetailedOptionMap: normalizeDetailedOptionMap$1
  15616. } = optionMap;
  15617. const createMinimistOptions = createMinimistOptions$2;
  15618. /**
  15619. * @typedef {Object} Context
  15620. * @property logger
  15621. * @property {string[]} rawArguments
  15622. * @property argv
  15623. * @property {string[]} filePatterns
  15624. * @property {any[]} supportOptions
  15625. * @property detailedOptions
  15626. * @property detailedOptionMap
  15627. * @property apiDefaultOptions
  15628. * @property languages
  15629. * @property {Partial<Context>[]} stack
  15630. * @property pushContextPlugins
  15631. * @property popContextPlugins
  15632. */
  15633. class Context$1 {
  15634. constructor({
  15635. rawArguments,
  15636. logger
  15637. }) {
  15638. this.rawArguments = rawArguments;
  15639. this.logger = logger;
  15640. this.stack = [];
  15641. const {
  15642. plugin: plugins,
  15643. "plugin-search-dir": pluginSearchDirs
  15644. } = parseArgvWithoutPlugins$1(rawArguments, logger, ["plugin", "plugin-search-dir"]);
  15645. this.pushContextPlugins(plugins, pluginSearchDirs);
  15646. const argv = parseArgv(rawArguments, this.detailedOptions, logger);
  15647. this.argv = argv;
  15648. this.filePatterns = argv._.map(file => String(file));
  15649. }
  15650. /**
  15651. * @param {string[]} plugins
  15652. * @param {string[]=} pluginSearchDirs
  15653. */
  15654. pushContextPlugins(plugins, pluginSearchDirs) {
  15655. this.stack.push(pick(this, ["supportOptions", "detailedOptions", "detailedOptionMap", "apiDefaultOptions", "languages"]));
  15656. Object.assign(this, getContextOptions(plugins, pluginSearchDirs));
  15657. }
  15658. popContextPlugins() {
  15659. Object.assign(this, this.stack.pop());
  15660. }
  15661. }
  15662. function getContextOptions(plugins, pluginSearchDirs) {
  15663. const {
  15664. options: supportOptions,
  15665. languages
  15666. } = prettier$3.getSupportInfo({
  15667. showDeprecated: true,
  15668. showUnreleased: true,
  15669. showInternal: true,
  15670. plugins,
  15671. pluginSearchDirs
  15672. });
  15673. const detailedOptionMap = normalizeDetailedOptionMap$1(Object.assign(Object.assign({}, createDetailedOptionMap$1(supportOptions)), constant$1.options));
  15674. const detailedOptions = arrayify(detailedOptionMap, "name");
  15675. const apiDefaultOptions = Object.assign(Object.assign({}, optionsModule.hiddenDefaults), Object.fromEntries(supportOptions.filter(({
  15676. deprecated
  15677. }) => !deprecated).map(option => [option.name, option.default])));
  15678. return {
  15679. supportOptions,
  15680. detailedOptions,
  15681. detailedOptionMap,
  15682. apiDefaultOptions,
  15683. languages
  15684. };
  15685. }
  15686. function parseArgv(rawArguments, detailedOptions, logger, keys) {
  15687. const minimistOptions = createMinimistOptions(detailedOptions);
  15688. let argv = minimist(rawArguments, minimistOptions);
  15689. if (keys) {
  15690. detailedOptions = detailedOptions.filter(option => keys.includes(option.name));
  15691. argv = pick(argv, keys);
  15692. }
  15693. return normalizeCliOptions(argv, detailedOptions, {
  15694. logger
  15695. });
  15696. }
  15697. const detailedOptionsWithoutPlugins = getContextOptions().detailedOptions;
  15698. function parseArgvWithoutPlugins$1(rawArguments, logger, keys) {
  15699. return parseArgv(rawArguments, detailedOptionsWithoutPlugins, logger, typeof keys === "string" ? [keys] : keys);
  15700. }
  15701. var context = {
  15702. Context: Context$1,
  15703. parseArgvWithoutPlugins: parseArgvWithoutPlugins$1
  15704. };
  15705. var $ = _export;
  15706. var flattenIntoArray = flattenIntoArray_1;
  15707. var toObject = toObject$4;
  15708. var lengthOfArrayLike = lengthOfArrayLike$6;
  15709. var toIntegerOrInfinity = toIntegerOrInfinity$3;
  15710. var arraySpeciesCreate = arraySpeciesCreate$2;
  15711. // `Array.prototype.flat` method
  15712. // https://tc39.es/ecma262/#sec-array.prototype.flat
  15713. $({ target: 'Array', proto: true }, {
  15714. flat: function flat(/* depthArg = 1 */) {
  15715. var depthArg = arguments.length ? arguments[0] : undefined;
  15716. var O = toObject(this);
  15717. var sourceLen = lengthOfArrayLike(O);
  15718. var A = arraySpeciesCreate(O, 0);
  15719. A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
  15720. return A;
  15721. }
  15722. });
  15723. var internalObjectKeys = objectKeysInternal;
  15724. var enumBugKeys$1 = enumBugKeys$3;
  15725. // `Object.keys` method
  15726. // https://tc39.es/ecma262/#sec-object.keys
  15727. // eslint-disable-next-line es/no-object-keys -- safe
  15728. var objectKeys$1 = Object.keys || function keys(O) {
  15729. return internalObjectKeys(O, enumBugKeys$1);
  15730. };
  15731. var DESCRIPTORS = descriptors;
  15732. var definePropertyModule$1 = objectDefineProperty;
  15733. var anObject$1 = anObject$7;
  15734. var toIndexedObject = toIndexedObject$4;
  15735. var objectKeys = objectKeys$1;
  15736. // `Object.defineProperties` method
  15737. // https://tc39.es/ecma262/#sec-object.defineproperties
  15738. // eslint-disable-next-line es/no-object-defineproperties -- safe
  15739. var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  15740. anObject$1(O);
  15741. var props = toIndexedObject(Properties);
  15742. var keys = objectKeys(Properties);
  15743. var length = keys.length;
  15744. var index = 0;
  15745. var key;
  15746. while (length > index) definePropertyModule$1.f(O, key = keys[index++], props[key]);
  15747. return O;
  15748. };
  15749. var getBuiltIn = getBuiltIn$5;
  15750. var html$1 = getBuiltIn('document', 'documentElement');
  15751. /* global ActiveXObject -- old IE, WSH */
  15752. var anObject = anObject$7;
  15753. var defineProperties = objectDefineProperties;
  15754. var enumBugKeys = enumBugKeys$3;
  15755. var hiddenKeys = hiddenKeys$4;
  15756. var html = html$1;
  15757. var documentCreateElement = documentCreateElement$1;
  15758. var sharedKey = sharedKey$2;
  15759. var GT = '>';
  15760. var LT = '<';
  15761. var PROTOTYPE = 'prototype';
  15762. var SCRIPT = 'script';
  15763. var IE_PROTO = sharedKey('IE_PROTO');
  15764. var EmptyConstructor = function () { /* empty */ };
  15765. var scriptTag = function (content) {
  15766. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  15767. };
  15768. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  15769. var NullProtoObjectViaActiveX = function (activeXDocument) {
  15770. activeXDocument.write(scriptTag(''));
  15771. activeXDocument.close();
  15772. var temp = activeXDocument.parentWindow.Object;
  15773. activeXDocument = null; // avoid memory leak
  15774. return temp;
  15775. };
  15776. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  15777. var NullProtoObjectViaIFrame = function () {
  15778. // Thrash, waste and sodomy: IE GC bug
  15779. var iframe = documentCreateElement('iframe');
  15780. var JS = 'java' + SCRIPT + ':';
  15781. var iframeDocument;
  15782. iframe.style.display = 'none';
  15783. html.appendChild(iframe);
  15784. // https://github.com/zloirock/core-js/issues/475
  15785. iframe.src = String(JS);
  15786. iframeDocument = iframe.contentWindow.document;
  15787. iframeDocument.open();
  15788. iframeDocument.write(scriptTag('document.F=Object'));
  15789. iframeDocument.close();
  15790. return iframeDocument.F;
  15791. };
  15792. // Check for document.domain and active x support
  15793. // No need to use active x approach when document.domain is not set
  15794. // see https://github.com/es-shims/es5-shim/issues/150
  15795. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  15796. // avoid IE GC bug
  15797. var activeXDocument;
  15798. var NullProtoObject = function () {
  15799. try {
  15800. activeXDocument = new ActiveXObject('htmlfile');
  15801. } catch (error) { /* ignore */ }
  15802. NullProtoObject = typeof document != 'undefined'
  15803. ? document.domain && activeXDocument
  15804. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  15805. : NullProtoObjectViaIFrame()
  15806. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  15807. var length = enumBugKeys.length;
  15808. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  15809. return NullProtoObject();
  15810. };
  15811. hiddenKeys[IE_PROTO] = true;
  15812. // `Object.create` method
  15813. // https://tc39.es/ecma262/#sec-object.create
  15814. var objectCreate = Object.create || function create(O, Properties) {
  15815. var result;
  15816. if (O !== null) {
  15817. EmptyConstructor[PROTOTYPE] = anObject(O);
  15818. result = new EmptyConstructor();
  15819. EmptyConstructor[PROTOTYPE] = null;
  15820. // add "__proto__" for Object.getPrototypeOf polyfill
  15821. result[IE_PROTO] = O;
  15822. } else result = NullProtoObject();
  15823. return Properties === undefined ? result : defineProperties(result, Properties);
  15824. };
  15825. var wellKnownSymbol = wellKnownSymbol$7;
  15826. var create = objectCreate;
  15827. var definePropertyModule = objectDefineProperty;
  15828. var UNSCOPABLES = wellKnownSymbol('unscopables');
  15829. var ArrayPrototype = Array.prototype;
  15830. // Array.prototype[@@unscopables]
  15831. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  15832. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  15833. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  15834. configurable: true,
  15835. value: create(null)
  15836. });
  15837. }
  15838. // add a key to Array.prototype[@@unscopables]
  15839. var addToUnscopables$1 = function (key) {
  15840. ArrayPrototype[UNSCOPABLES][key] = true;
  15841. };
  15842. // this method was added to unscopables after implementation
  15843. // in popular engines, so it's moved to a separate module
  15844. var addToUnscopables = addToUnscopables$1;
  15845. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  15846. addToUnscopables('flat');
  15847. var baseAssignValue = _baseAssignValue,
  15848. createAggregator = _createAggregator;
  15849. /** Used for built-in method references. */
  15850. var objectProto = Object.prototype;
  15851. /** Used to check objects for own properties. */
  15852. var hasOwnProperty = objectProto.hasOwnProperty;
  15853. /**
  15854. * Creates an object composed of keys generated from the results of running
  15855. * each element of `collection` thru `iteratee`. The order of grouped values
  15856. * is determined by the order they occur in `collection`. The corresponding
  15857. * value of each key is an array of elements responsible for generating the
  15858. * key. The iteratee is invoked with one argument: (value).
  15859. *
  15860. * @static
  15861. * @memberOf _
  15862. * @since 0.1.0
  15863. * @category Collection
  15864. * @param {Array|Object} collection The collection to iterate over.
  15865. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  15866. * @returns {Object} Returns the composed aggregate object.
  15867. * @example
  15868. *
  15869. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  15870. * // => { '4': [4.2], '6': [6.1, 6.3] }
  15871. *
  15872. * // The `_.property` iteratee shorthand.
  15873. * _.groupBy(['one', 'two', 'three'], 'length');
  15874. * // => { '3': ['one', 'two'], '5': ['three'] }
  15875. */
  15876. var groupBy$1 = createAggregator(function (result, value, key) {
  15877. if (hasOwnProperty.call(result, key)) {
  15878. result[key].push(value);
  15879. } else {
  15880. baseAssignValue(result, key, [value]);
  15881. }
  15882. });
  15883. var groupBy_1 = groupBy$1;
  15884. var camelcase = {exports: {}};
  15885. const UPPERCASE = /[\p{Lu}]/u;
  15886. const LOWERCASE = /[\p{Ll}]/u;
  15887. const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
  15888. const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
  15889. const SEPARATORS = /[_.\- ]+/;
  15890. const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
  15891. const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
  15892. const NUMBERS_AND_IDENTIFIER = new RegExp('\\d+' + IDENTIFIER.source, 'gu');
  15893. const preserveCamelCase = (string, locale) => {
  15894. let isLastCharLower = false;
  15895. let isLastCharUpper = false;
  15896. let isLastLastCharUpper = false;
  15897. for (let i = 0; i < string.length; i++) {
  15898. const character = string[i];
  15899. if (isLastCharLower && UPPERCASE.test(character)) {
  15900. string = string.slice(0, i) + '-' + string.slice(i);
  15901. isLastCharLower = false;
  15902. isLastLastCharUpper = isLastCharUpper;
  15903. isLastCharUpper = true;
  15904. i++;
  15905. } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character)) {
  15906. string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
  15907. isLastLastCharUpper = isLastCharUpper;
  15908. isLastCharUpper = false;
  15909. isLastCharLower = true;
  15910. } else {
  15911. isLastCharLower = character.toLocaleLowerCase(locale) === character && character.toLocaleUpperCase(locale) !== character;
  15912. isLastLastCharUpper = isLastCharUpper;
  15913. isLastCharUpper = character.toLocaleUpperCase(locale) === character && character.toLocaleLowerCase(locale) !== character;
  15914. }
  15915. }
  15916. return string;
  15917. };
  15918. const preserveConsecutiveUppercase = input => {
  15919. LEADING_CAPITAL.lastIndex = 0;
  15920. return input.replace(LEADING_CAPITAL, m1 => m1.toLowerCase());
  15921. };
  15922. const postProcess = (input, options) => {
  15923. SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
  15924. NUMBERS_AND_IDENTIFIER.lastIndex = 0;
  15925. return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => identifier.toLocaleUpperCase(options.locale)).replace(NUMBERS_AND_IDENTIFIER, m => m.toLocaleUpperCase(options.locale));
  15926. };
  15927. const camelCase$1 = (input, options) => {
  15928. if (!(typeof input === 'string' || Array.isArray(input))) {
  15929. throw new TypeError('Expected the input to be `string | string[]`');
  15930. }
  15931. options = Object.assign({
  15932. pascalCase: false,
  15933. preserveConsecutiveUppercase: false
  15934. }, options);
  15935. if (Array.isArray(input)) {
  15936. input = input.map(x => x.trim()).filter(x => x.length).join('-');
  15937. } else {
  15938. input = input.trim();
  15939. }
  15940. if (input.length === 0) {
  15941. return '';
  15942. }
  15943. if (input.length === 1) {
  15944. return options.pascalCase ? input.toLocaleUpperCase(options.locale) : input.toLocaleLowerCase(options.locale);
  15945. }
  15946. const hasUpperCase = input !== input.toLocaleLowerCase(options.locale);
  15947. if (hasUpperCase) {
  15948. input = preserveCamelCase(input, options.locale);
  15949. }
  15950. input = input.replace(LEADING_SEPARATORS, '');
  15951. if (options.preserveConsecutiveUppercase) {
  15952. input = preserveConsecutiveUppercase(input);
  15953. } else {
  15954. input = input.toLocaleLowerCase();
  15955. }
  15956. if (options.pascalCase) {
  15957. input = input.charAt(0).toLocaleUpperCase(options.locale) + input.slice(1);
  15958. }
  15959. return postProcess(input, options);
  15960. };
  15961. camelcase.exports = camelCase$1; // TODO: Remove this for the next major release
  15962. camelcase.exports.default = camelCase$1;
  15963. const groupBy = groupBy_1;
  15964. const camelCase = camelcase.exports;
  15965. const constant = constant$2;
  15966. const OPTION_USAGE_THRESHOLD = 25;
  15967. const CHOICE_USAGE_MARGIN = 3;
  15968. const CHOICE_USAGE_INDENTATION = 2;
  15969. function indent(str, spaces) {
  15970. return str.replace(/^/gm, " ".repeat(spaces));
  15971. }
  15972. function createDefaultValueDisplay(value) {
  15973. return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
  15974. }
  15975. function getOptionDefaultValue(context, optionName) {
  15976. // --no-option
  15977. if (!(optionName in context.detailedOptionMap)) {
  15978. return;
  15979. }
  15980. const option = context.detailedOptionMap[optionName];
  15981. if (option.default !== undefined) {
  15982. return option.default;
  15983. }
  15984. const optionCamelName = camelCase(optionName);
  15985. if (optionCamelName in context.apiDefaultOptions) {
  15986. return context.apiDefaultOptions[optionCamelName];
  15987. }
  15988. }
  15989. function createOptionUsageHeader(option) {
  15990. const name = `--${option.name}`;
  15991. const alias = option.alias ? `-${option.alias},` : null;
  15992. const type = createOptionUsageType(option);
  15993. return [alias, name, type].filter(Boolean).join(" ");
  15994. }
  15995. function createOptionUsageRow(header, content, threshold) {
  15996. const separator = header.length >= threshold ? `\n${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
  15997. const description = content.replace(/\n/g, `\n${" ".repeat(threshold)}`);
  15998. return `${header}${separator}${description}`;
  15999. }
  16000. function createOptionUsageType(option) {
  16001. switch (option.type) {
  16002. case "boolean":
  16003. return null;
  16004. case "choice":
  16005. return `<${option.choices.filter(choice => !choice.deprecated && choice.since !== null).map(choice => choice.value).join("|")}>`;
  16006. default:
  16007. return `<${option.type}>`;
  16008. }
  16009. }
  16010. function createChoiceUsages(choices, margin, indentation) {
  16011. const activeChoices = choices.filter(choice => !choice.deprecated && choice.since !== null);
  16012. const threshold = Math.max(0, ...activeChoices.map(choice => choice.value.length)) + margin;
  16013. return activeChoices.map(choice => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
  16014. }
  16015. function createOptionUsage(context, option, threshold) {
  16016. const header = createOptionUsageHeader(option);
  16017. const optionDefaultValue = getOptionDefaultValue(context, option.name);
  16018. return createOptionUsageRow(header, `${option.description}${optionDefaultValue === undefined ? "" : `\nDefaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
  16019. }
  16020. function getOptionsWithOpposites(options) {
  16021. // Add --no-foo after --foo.
  16022. const optionsWithOpposites = options.map(option => [option.description ? option : null, option.oppositeDescription ? Object.assign(Object.assign({}, option), {}, {
  16023. name: `no-${option.name}`,
  16024. type: "boolean",
  16025. description: option.oppositeDescription
  16026. }) : null]);
  16027. return optionsWithOpposites.flat().filter(Boolean);
  16028. }
  16029. function createUsage$1(context) {
  16030. const options = getOptionsWithOpposites(context.detailedOptions).filter( // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
  16031. option => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-")));
  16032. const groupedOptions = groupBy(options, option => option.category);
  16033. const firstCategories = constant.categoryOrder.slice(0, -1);
  16034. const lastCategories = constant.categoryOrder.slice(-1);
  16035. const restCategories = Object.keys(groupedOptions).filter(category => !constant.categoryOrder.includes(category));
  16036. const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
  16037. const optionsUsage = allCategories.map(category => {
  16038. const categoryOptions = groupedOptions[category].map(option => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
  16039. return `${category} options:\n\n${indent(categoryOptions, 2)}`;
  16040. });
  16041. return [constant.usageSummary, ...optionsUsage, ""].join("\n\n");
  16042. }
  16043. function createDetailedUsage$1(context, flag) {
  16044. const option = getOptionsWithOpposites(context.detailedOptions).find(option => option.name === flag || option.alias === flag);
  16045. const header = createOptionUsageHeader(option);
  16046. const description = `\n\n${indent(option.description, 2)}`;
  16047. const choices = option.type !== "choice" ? "" : `\n\nValid options:\n\n${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
  16048. const optionDefaultValue = getOptionDefaultValue(context, option.name);
  16049. const defaults = optionDefaultValue !== undefined ? `\n\nDefault: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
  16050. const pluginDefaults = option.pluginDefaults && Object.keys(option.pluginDefaults).length > 0 ? `\nPlugin defaults:${Object.entries(option.pluginDefaults).map(([key, value]) => `\n* ${key}: ${createDefaultValueDisplay(value)}`)}` : "";
  16051. return `${header}${description}${choices}${defaults}${pluginDefaults}`;
  16052. }
  16053. var usage = {
  16054. createUsage: createUsage$1,
  16055. createDetailedUsage: createDetailedUsage$1
  16056. };
  16057. var ansiRegex$1 = ({
  16058. onlyFirst = false
  16059. } = {}) => {
  16060. const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  16061. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  16062. };
  16063. const ansiRegex = ansiRegex$1;
  16064. var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
  16065. var wcwidth$2 = {exports: {}};
  16066. var clone$1 = {exports: {}};
  16067. (function (module) {
  16068. var clone = function () {
  16069. /**
  16070. * Clones (copies) an Object using deep copying.
  16071. *
  16072. * This function supports circular references by default, but if you are certain
  16073. * there are no circular references in your object, you can save some CPU time
  16074. * by calling clone(obj, false).
  16075. *
  16076. * Caution: if `circular` is false and `parent` contains circular references,
  16077. * your program may enter an infinite loop and crash.
  16078. *
  16079. * @param `parent` - the object to be cloned
  16080. * @param `circular` - set to true if the object to be cloned may contain
  16081. * circular references. (optional - true by default)
  16082. * @param `depth` - set to a number if the object is only to be cloned to
  16083. * a particular depth. (optional - defaults to Infinity)
  16084. * @param `prototype` - sets the prototype to be used when cloning an object.
  16085. * (optional - defaults to parent prototype).
  16086. */
  16087. function clone(parent, circular, depth, prototype) {
  16088. if (typeof circular === 'object') {
  16089. depth = circular.depth;
  16090. prototype = circular.prototype;
  16091. circular = circular.circular;
  16092. } // maintain two arrays for circular references, where corresponding parents
  16093. // and children have the same index
  16094. var allParents = [];
  16095. var allChildren = [];
  16096. var useBuffer = typeof Buffer != 'undefined';
  16097. if (typeof circular == 'undefined') circular = true;
  16098. if (typeof depth == 'undefined') depth = Infinity; // recurse this function so we don't reset allParents and allChildren
  16099. function _clone(parent, depth) {
  16100. // cloning null always returns null
  16101. if (parent === null) return null;
  16102. if (depth == 0) return parent;
  16103. var child;
  16104. var proto;
  16105. if (typeof parent != 'object') {
  16106. return parent;
  16107. }
  16108. if (clone.__isArray(parent)) {
  16109. child = [];
  16110. } else if (clone.__isRegExp(parent)) {
  16111. child = new RegExp(parent.source, __getRegExpFlags(parent));
  16112. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  16113. } else if (clone.__isDate(parent)) {
  16114. child = new Date(parent.getTime());
  16115. } else if (useBuffer && Buffer.isBuffer(parent)) {
  16116. if (Buffer.allocUnsafe) {
  16117. // Node.js >= 4.5.0
  16118. child = Buffer.allocUnsafe(parent.length);
  16119. } else {
  16120. // Older Node.js versions
  16121. child = new Buffer(parent.length);
  16122. }
  16123. parent.copy(child);
  16124. return child;
  16125. } else {
  16126. if (typeof prototype == 'undefined') {
  16127. proto = Object.getPrototypeOf(parent);
  16128. child = Object.create(proto);
  16129. } else {
  16130. child = Object.create(prototype);
  16131. proto = prototype;
  16132. }
  16133. }
  16134. if (circular) {
  16135. var index = allParents.indexOf(parent);
  16136. if (index != -1) {
  16137. return allChildren[index];
  16138. }
  16139. allParents.push(parent);
  16140. allChildren.push(child);
  16141. }
  16142. for (var i in parent) {
  16143. var attrs;
  16144. if (proto) {
  16145. attrs = Object.getOwnPropertyDescriptor(proto, i);
  16146. }
  16147. if (attrs && attrs.set == null) {
  16148. continue;
  16149. }
  16150. child[i] = _clone(parent[i], depth - 1);
  16151. }
  16152. return child;
  16153. }
  16154. return _clone(parent, depth);
  16155. }
  16156. /**
  16157. * Simple flat clone using prototype, accepts only objects, usefull for property
  16158. * override on FLAT configuration object (no nested props).
  16159. *
  16160. * USE WITH CAUTION! This may not behave as you wish if you do not know how this
  16161. * works.
  16162. */
  16163. clone.clonePrototype = function clonePrototype(parent) {
  16164. if (parent === null) return null;
  16165. var c = function () {};
  16166. c.prototype = parent;
  16167. return new c();
  16168. }; // private utility functions
  16169. function __objToStr(o) {
  16170. return Object.prototype.toString.call(o);
  16171. }
  16172. clone.__objToStr = __objToStr;
  16173. function __isDate(o) {
  16174. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  16175. }
  16176. clone.__isDate = __isDate;
  16177. function __isArray(o) {
  16178. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  16179. }
  16180. clone.__isArray = __isArray;
  16181. function __isRegExp(o) {
  16182. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  16183. }
  16184. clone.__isRegExp = __isRegExp;
  16185. function __getRegExpFlags(re) {
  16186. var flags = '';
  16187. if (re.global) flags += 'g';
  16188. if (re.ignoreCase) flags += 'i';
  16189. if (re.multiline) flags += 'm';
  16190. return flags;
  16191. }
  16192. clone.__getRegExpFlags = __getRegExpFlags;
  16193. return clone;
  16194. }();
  16195. if (module.exports) {
  16196. module.exports = clone;
  16197. }
  16198. })(clone$1);
  16199. var clone = clone$1.exports;
  16200. var defaults$1 = function (options, defaults) {
  16201. options = options || {};
  16202. Object.keys(defaults).forEach(function (key) {
  16203. if (typeof options[key] === 'undefined') {
  16204. options[key] = clone(defaults[key]);
  16205. }
  16206. });
  16207. return options;
  16208. };
  16209. var combining$1 = [[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489], [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2], [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603], [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670], [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED], [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A], [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902], [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D], [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981], [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD], [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C], [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D], [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC], [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD], [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C], [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D], [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0], [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48], [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC], [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD], [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D], [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6], [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E], [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC], [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35], [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E], [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97], [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030], [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039], [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F], [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753], [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD], [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD], [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922], [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B], [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34], [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42], [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF], [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063], [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F], [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B], [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F], [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB], [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F], [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169], [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD], [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F], [0xE0100, 0xE01EF]];
  16210. var defaults = defaults$1;
  16211. var combining = combining$1;
  16212. var DEFAULTS = {
  16213. nul: 0,
  16214. control: 0
  16215. };
  16216. wcwidth$2.exports = function wcwidth(str) {
  16217. return wcswidth(str, DEFAULTS);
  16218. };
  16219. wcwidth$2.exports.config = function (opts) {
  16220. opts = defaults(opts || {}, DEFAULTS);
  16221. return function wcwidth(str) {
  16222. return wcswidth(str, opts);
  16223. };
  16224. };
  16225. /*
  16226. * The following functions define the column width of an ISO 10646
  16227. * character as follows:
  16228. * - The null character (U+0000) has a column width of 0.
  16229. * - Other C0/C1 control characters and DEL will lead to a return value
  16230. * of -1.
  16231. * - Non-spacing and enclosing combining characters (general category
  16232. * code Mn or Me in the
  16233. * Unicode database) have a column width of 0.
  16234. * - SOFT HYPHEN (U+00AD) has a column width of 1.
  16235. * - Other format characters (general category code Cf in the Unicode
  16236. * database) and ZERO WIDTH
  16237. * SPACE (U+200B) have a column width of 0.
  16238. * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
  16239. * have a column width of 0.
  16240. * - Spacing characters in the East Asian Wide (W) or East Asian
  16241. * Full-width (F) category as
  16242. * defined in Unicode Technical Report #11 have a column width of 2.
  16243. * - All remaining characters (including all printable ISO 8859-1 and
  16244. * WGL4 characters, Unicode control characters, etc.) have a column
  16245. * width of 1.
  16246. * This implementation assumes that characters are encoded in ISO 10646.
  16247. */
  16248. function wcswidth(str, opts) {
  16249. if (typeof str !== 'string') return wcwidth$1(str, opts);
  16250. var s = 0;
  16251. for (var i = 0; i < str.length; i++) {
  16252. var n = wcwidth$1(str.charCodeAt(i), opts);
  16253. if (n < 0) return -1;
  16254. s += n;
  16255. }
  16256. return s;
  16257. }
  16258. function wcwidth$1(ucs, opts) {
  16259. // test for 8-bit control characters
  16260. if (ucs === 0) return opts.nul;
  16261. if (ucs < 32 || ucs >= 0x7f && ucs < 0xa0) return opts.control; // binary search in table of non-spacing characters
  16262. if (bisearch(ucs)) return 0; // if we arrive here, ucs is not a combining or C0/C1 control character
  16263. return 1 + (ucs >= 0x1100 && (ucs <= 0x115f || // Hangul Jamo init. consonants
  16264. ucs == 0x2329 || ucs == 0x232a || ucs >= 0x2e80 && ucs <= 0xa4cf && ucs != 0x303f || // CJK ... Yi
  16265. ucs >= 0xac00 && ucs <= 0xd7a3 || // Hangul Syllables
  16266. ucs >= 0xf900 && ucs <= 0xfaff || // CJK Compatibility Ideographs
  16267. ucs >= 0xfe10 && ucs <= 0xfe19 || // Vertical forms
  16268. ucs >= 0xfe30 && ucs <= 0xfe6f || // CJK Compatibility Forms
  16269. ucs >= 0xff00 && ucs <= 0xff60 || // Fullwidth Forms
  16270. ucs >= 0xffe0 && ucs <= 0xffe6 || ucs >= 0x20000 && ucs <= 0x2fffd || ucs >= 0x30000 && ucs <= 0x3fffd));
  16271. }
  16272. function bisearch(ucs) {
  16273. var min = 0;
  16274. var max = combining.length - 1;
  16275. var mid;
  16276. if (ucs < combining[0][0] || ucs > combining[max][1]) return false;
  16277. while (max >= min) {
  16278. mid = Math.floor((min + max) / 2);
  16279. if (ucs > combining[mid][1]) min = mid + 1;else if (ucs < combining[mid][0]) max = mid - 1;else return true;
  16280. }
  16281. return false;
  16282. }
  16283. const readline = require$$0__default$6["default"];
  16284. const chalk = source;
  16285. const stripAnsi = stripAnsi$1;
  16286. const wcwidth = wcwidth$2.exports;
  16287. const countLines = (stream, text) => {
  16288. const columns = stream.columns || 80;
  16289. let lineCount = 0;
  16290. for (const line of stripAnsi(text).split("\n")) {
  16291. lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns));
  16292. }
  16293. return lineCount;
  16294. };
  16295. const clear = (stream, text) => () => {
  16296. const lineCount = countLines(stream, text);
  16297. for (let line = 0; line < lineCount; line++) {
  16298. if (line > 0) {
  16299. readline.moveCursor(stream, 0, -1);
  16300. }
  16301. readline.clearLine(stream, 0);
  16302. readline.cursorTo(stream, 0);
  16303. }
  16304. };
  16305. const emptyLogResult = {
  16306. clear() {}
  16307. };
  16308. function createLogger$1(logLevel = "log") {
  16309. return {
  16310. logLevel,
  16311. warn: createLogFunc("warn", "yellow"),
  16312. error: createLogFunc("error", "red"),
  16313. debug: createLogFunc("debug", "blue"),
  16314. log: createLogFunc("log")
  16315. };
  16316. function createLogFunc(loggerName, color) {
  16317. if (!shouldLog(loggerName)) {
  16318. return () => emptyLogResult;
  16319. }
  16320. const prefix = color ? `[${chalk[color](loggerName)}] ` : "";
  16321. const stream = process[loggerName === "log" ? "stdout" : "stderr"];
  16322. return (message, options) => {
  16323. options = Object.assign({
  16324. newline: true,
  16325. clearable: false
  16326. }, options);
  16327. message = message.replace(/^/gm, prefix) + (options.newline ? "\n" : "");
  16328. stream.write(message);
  16329. if (options.clearable) {
  16330. return {
  16331. clear: clear(stream, message)
  16332. };
  16333. }
  16334. };
  16335. }
  16336. function shouldLog(loggerName) {
  16337. switch (logLevel) {
  16338. case "silent":
  16339. return false;
  16340. case "debug":
  16341. if (loggerName === "debug") {
  16342. return true;
  16343. }
  16344. // fall through
  16345. case "log":
  16346. if (loggerName === "log") {
  16347. return true;
  16348. }
  16349. // fall through
  16350. case "warn":
  16351. if (loggerName === "warn") {
  16352. return true;
  16353. }
  16354. // fall through
  16355. case "error":
  16356. return loggerName === "error";
  16357. }
  16358. }
  16359. }
  16360. var logger = {
  16361. createLogger: createLogger$1
  16362. };
  16363. const path = require$$0__default$1["default"];
  16364. const stringify$1 = fastJsonStableStringify; // eslint-disable-next-line no-restricted-modules
  16365. const prettier$2 = require$$3;
  16366. const {
  16367. format,
  16368. formatStdin,
  16369. formatFiles
  16370. } = format_1;
  16371. const {
  16372. Context,
  16373. parseArgvWithoutPlugins
  16374. } = context;
  16375. const {
  16376. normalizeDetailedOptionMap,
  16377. createDetailedOptionMap
  16378. } = optionMap;
  16379. const {
  16380. createDetailedUsage,
  16381. createUsage
  16382. } = usage;
  16383. const {
  16384. createLogger
  16385. } = logger;
  16386. async function logResolvedConfigPathOrDie(context) {
  16387. const file = context.argv["find-config-path"];
  16388. const configFile = await prettier$2.resolveConfigFile(file);
  16389. if (configFile) {
  16390. context.logger.log(path.relative(process.cwd(), configFile));
  16391. } else {
  16392. throw new Error(`Can not find configure file for "${file}"`);
  16393. }
  16394. }
  16395. async function logFileInfoOrDie(context) {
  16396. const options = {
  16397. ignorePath: context.argv["ignore-path"],
  16398. withNodeModules: context.argv["with-node-modules"],
  16399. plugins: context.argv.plugin,
  16400. pluginSearchDirs: context.argv["plugin-search-dir"],
  16401. resolveConfig: context.argv.config !== false
  16402. };
  16403. context.logger.log(prettier$2.format(stringify$1(await prettier$2.getFileInfo(context.argv["file-info"], options)), {
  16404. parser: "json"
  16405. }));
  16406. }
  16407. var core$1 = {
  16408. Context,
  16409. createDetailedOptionMap,
  16410. createDetailedUsage,
  16411. createUsage,
  16412. format,
  16413. formatFiles,
  16414. formatStdin,
  16415. logResolvedConfigPathOrDie,
  16416. logFileInfoOrDie,
  16417. normalizeDetailedOptionMap,
  16418. parseArgvWithoutPlugins,
  16419. createLogger
  16420. };
  16421. const packageJson = require$$0;
  16422. pleaseUpgradeNode(packageJson); // eslint-disable-next-line import/order
  16423. const stringify = fastJsonStableStringify; // eslint-disable-next-line no-restricted-modules
  16424. const prettier$1 = require$$3;
  16425. const core = core$1;
  16426. async function run(rawArguments) {
  16427. // Create a default level logger, so we can log errors during `logLevel` parsing
  16428. let logger = core.createLogger();
  16429. try {
  16430. const logLevel = core.parseArgvWithoutPlugins(rawArguments, logger, "loglevel").loglevel;
  16431. if (logLevel !== logger.logLevel) {
  16432. logger = core.createLogger(logLevel);
  16433. }
  16434. await main(rawArguments, logger);
  16435. } catch (error) {
  16436. logger.error(error.message);
  16437. process.exitCode = 1;
  16438. }
  16439. }
  16440. async function main(rawArguments, logger) {
  16441. const context = new core.Context({
  16442. rawArguments,
  16443. logger
  16444. });
  16445. logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
  16446. if (context.argv.check && context.argv["list-different"]) {
  16447. throw new Error("Cannot use --check and --list-different together.");
  16448. }
  16449. if (context.argv.write && context.argv["debug-check"]) {
  16450. throw new Error("Cannot use --write and --debug-check together.");
  16451. }
  16452. if (context.argv["find-config-path"] && context.filePatterns.length > 0) {
  16453. throw new Error("Cannot use --find-config-path with multiple files");
  16454. }
  16455. if (context.argv["file-info"] && context.filePatterns.length > 0) {
  16456. throw new Error("Cannot use --file-info with multiple files");
  16457. }
  16458. if (context.argv.version) {
  16459. logger.log(prettier$1.version);
  16460. return;
  16461. }
  16462. if (context.argv.help !== undefined) {
  16463. logger.log(typeof context.argv.help === "string" && context.argv.help !== "" ? core.createDetailedUsage(context, context.argv.help) : core.createUsage(context));
  16464. return;
  16465. }
  16466. if (context.argv["support-info"]) {
  16467. logger.log(prettier$1.format(stringify(prettier$1.getSupportInfo()), {
  16468. parser: "json"
  16469. }));
  16470. return;
  16471. }
  16472. const hasFilePatterns = context.filePatterns.length > 0;
  16473. const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv["stdin-filepath"]);
  16474. if (context.argv["find-config-path"]) {
  16475. await core.logResolvedConfigPathOrDie(context);
  16476. } else if (context.argv["file-info"]) {
  16477. await core.logFileInfoOrDie(context);
  16478. } else if (useStdin) {
  16479. await core.formatStdin(context);
  16480. } else if (hasFilePatterns) {
  16481. await core.formatFiles(context);
  16482. } else {
  16483. logger.log(core.createUsage(context));
  16484. process.exitCode = 1;
  16485. }
  16486. }
  16487. var cli = {
  16488. run
  16489. };
  16490. var prettier = cli.run(process.argv.slice(2));
  16491. module.exports = prettier;