dependencies.js 275 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828
  1. import require$$0$1, { format } from 'util';
  2. import { normalize as normalize$1, resolve } from 'path';
  3. import { readFileSync } from 'fs';
  4. import path$1 from 'node:path';
  5. import process$2 from 'node:process';
  6. import { fileURLToPath } from 'node:url';
  7. import fs$1 from 'node:fs';
  8. import require$$0$2 from 'os';
  9. import require$$0 from 'url';
  10. function camelCase$1(str) {
  11. const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
  12. if (!isCamelCase) {
  13. str = str.toLowerCase();
  14. }
  15. if (str.indexOf('-') === -1 && str.indexOf('_') === -1) {
  16. return str;
  17. }
  18. else {
  19. let camelcase = '';
  20. let nextChrUpper = false;
  21. const leadingHyphens = str.match(/^-+/);
  22. for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
  23. let chr = str.charAt(i);
  24. if (nextChrUpper) {
  25. nextChrUpper = false;
  26. chr = chr.toUpperCase();
  27. }
  28. if (i !== 0 && (chr === '-' || chr === '_')) {
  29. nextChrUpper = true;
  30. }
  31. else if (chr !== '-' && chr !== '_') {
  32. camelcase += chr;
  33. }
  34. }
  35. return camelcase;
  36. }
  37. }
  38. function decamelize$1(str, joinString) {
  39. const lowercase = str.toLowerCase();
  40. joinString = joinString || '-';
  41. let notCamelcase = '';
  42. for (let i = 0; i < str.length; i++) {
  43. const chrLower = lowercase.charAt(i);
  44. const chrString = str.charAt(i);
  45. if (chrLower !== chrString && i > 0) {
  46. notCamelcase += `${joinString}${lowercase.charAt(i)}`;
  47. }
  48. else {
  49. notCamelcase += chrString;
  50. }
  51. }
  52. return notCamelcase;
  53. }
  54. function looksLikeNumber(x) {
  55. if (x === null || x === undefined)
  56. return false;
  57. if (typeof x === 'number')
  58. return true;
  59. if (/^0x[0-9a-f]+$/i.test(x))
  60. return true;
  61. if (/^0[^.]/.test(x))
  62. return false;
  63. return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
  64. }
  65. function tokenizeArgString(argString) {
  66. if (Array.isArray(argString)) {
  67. return argString.map(e => typeof e !== 'string' ? e + '' : e);
  68. }
  69. argString = argString.trim();
  70. let i = 0;
  71. let prevC = null;
  72. let c = null;
  73. let opening = null;
  74. const args = [];
  75. for (let ii = 0; ii < argString.length; ii++) {
  76. prevC = c;
  77. c = argString.charAt(ii);
  78. if (c === ' ' && !opening) {
  79. if (!(prevC === ' ')) {
  80. i++;
  81. }
  82. continue;
  83. }
  84. if (c === opening) {
  85. opening = null;
  86. }
  87. else if ((c === "'" || c === '"') && !opening) {
  88. opening = c;
  89. }
  90. if (!args[i])
  91. args[i] = '';
  92. args[i] += c;
  93. }
  94. return args;
  95. }
  96. var DefaultValuesForTypeKey;
  97. (function (DefaultValuesForTypeKey) {
  98. DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
  99. DefaultValuesForTypeKey["STRING"] = "string";
  100. DefaultValuesForTypeKey["NUMBER"] = "number";
  101. DefaultValuesForTypeKey["ARRAY"] = "array";
  102. })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
  103. let mixin;
  104. class YargsParser {
  105. constructor(_mixin) {
  106. mixin = _mixin;
  107. }
  108. parse(argsInput, options) {
  109. const opts = Object.assign({
  110. alias: undefined,
  111. array: undefined,
  112. boolean: undefined,
  113. config: undefined,
  114. configObjects: undefined,
  115. configuration: undefined,
  116. coerce: undefined,
  117. count: undefined,
  118. default: undefined,
  119. envPrefix: undefined,
  120. narg: undefined,
  121. normalize: undefined,
  122. string: undefined,
  123. number: undefined,
  124. __: undefined,
  125. key: undefined
  126. }, options);
  127. const args = tokenizeArgString(argsInput);
  128. const inputIsString = typeof argsInput === 'string';
  129. const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
  130. const configuration = Object.assign({
  131. 'boolean-negation': true,
  132. 'camel-case-expansion': true,
  133. 'combine-arrays': false,
  134. 'dot-notation': true,
  135. 'duplicate-arguments-array': true,
  136. 'flatten-duplicate-arrays': true,
  137. 'greedy-arrays': true,
  138. 'halt-at-non-option': false,
  139. 'nargs-eats-options': false,
  140. 'negation-prefix': 'no-',
  141. 'parse-numbers': true,
  142. 'parse-positional-numbers': true,
  143. 'populate--': false,
  144. 'set-placeholder-key': false,
  145. 'short-option-groups': true,
  146. 'strip-aliased': false,
  147. 'strip-dashed': false,
  148. 'unknown-options-as-args': false
  149. }, opts.configuration);
  150. const defaults = Object.assign(Object.create(null), opts.default);
  151. const configObjects = opts.configObjects || [];
  152. const envPrefix = opts.envPrefix;
  153. const notFlagsOption = configuration['populate--'];
  154. const notFlagsArgv = notFlagsOption ? '--' : '_';
  155. const newAliases = Object.create(null);
  156. const defaulted = Object.create(null);
  157. const __ = opts.__ || mixin.format;
  158. const flags = {
  159. aliases: Object.create(null),
  160. arrays: Object.create(null),
  161. bools: Object.create(null),
  162. strings: Object.create(null),
  163. numbers: Object.create(null),
  164. counts: Object.create(null),
  165. normalize: Object.create(null),
  166. configs: Object.create(null),
  167. nargs: Object.create(null),
  168. coercions: Object.create(null),
  169. keys: []
  170. };
  171. const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
  172. const negatedBoolean = new RegExp('^--' + configuration['negation-prefix'] + '(.+)');
  173. [].concat(opts.array || []).filter(Boolean).forEach(function (opt) {
  174. const key = typeof opt === 'object' ? opt.key : opt;
  175. const assignment = Object.keys(opt).map(function (key) {
  176. const arrayFlagKeys = {
  177. boolean: 'bools',
  178. string: 'strings',
  179. number: 'numbers'
  180. };
  181. return arrayFlagKeys[key];
  182. }).filter(Boolean).pop();
  183. if (assignment) {
  184. flags[assignment][key] = true;
  185. }
  186. flags.arrays[key] = true;
  187. flags.keys.push(key);
  188. });
  189. [].concat(opts.boolean || []).filter(Boolean).forEach(function (key) {
  190. flags.bools[key] = true;
  191. flags.keys.push(key);
  192. });
  193. [].concat(opts.string || []).filter(Boolean).forEach(function (key) {
  194. flags.strings[key] = true;
  195. flags.keys.push(key);
  196. });
  197. [].concat(opts.number || []).filter(Boolean).forEach(function (key) {
  198. flags.numbers[key] = true;
  199. flags.keys.push(key);
  200. });
  201. [].concat(opts.count || []).filter(Boolean).forEach(function (key) {
  202. flags.counts[key] = true;
  203. flags.keys.push(key);
  204. });
  205. [].concat(opts.normalize || []).filter(Boolean).forEach(function (key) {
  206. flags.normalize[key] = true;
  207. flags.keys.push(key);
  208. });
  209. if (typeof opts.narg === 'object') {
  210. Object.entries(opts.narg).forEach(([key, value]) => {
  211. if (typeof value === 'number') {
  212. flags.nargs[key] = value;
  213. flags.keys.push(key);
  214. }
  215. });
  216. }
  217. if (typeof opts.coerce === 'object') {
  218. Object.entries(opts.coerce).forEach(([key, value]) => {
  219. if (typeof value === 'function') {
  220. flags.coercions[key] = value;
  221. flags.keys.push(key);
  222. }
  223. });
  224. }
  225. if (typeof opts.config !== 'undefined') {
  226. if (Array.isArray(opts.config) || typeof opts.config === 'string') {
  227. [].concat(opts.config).filter(Boolean).forEach(function (key) {
  228. flags.configs[key] = true;
  229. });
  230. }
  231. else if (typeof opts.config === 'object') {
  232. Object.entries(opts.config).forEach(([key, value]) => {
  233. if (typeof value === 'boolean' || typeof value === 'function') {
  234. flags.configs[key] = value;
  235. }
  236. });
  237. }
  238. }
  239. extendAliases(opts.key, aliases, opts.default, flags.arrays);
  240. Object.keys(defaults).forEach(function (key) {
  241. (flags.aliases[key] || []).forEach(function (alias) {
  242. defaults[alias] = defaults[key];
  243. });
  244. });
  245. let error = null;
  246. checkConfiguration();
  247. let notFlags = [];
  248. const argv = Object.assign(Object.create(null), { _: [] });
  249. const argvReturn = {};
  250. for (let i = 0; i < args.length; i++) {
  251. const arg = args[i];
  252. const truncatedArg = arg.replace(/^-{3,}/, '---');
  253. let broken;
  254. let key;
  255. let letters;
  256. let m;
  257. let next;
  258. let value;
  259. if (arg !== '--' && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
  260. pushPositional(arg);
  261. }
  262. else if (truncatedArg.match(/^---+(=|$)/)) {
  263. pushPositional(arg);
  264. continue;
  265. }
  266. else if (arg.match(/^--.+=/) || (!configuration['short-option-groups'] && arg.match(/^-.+=/))) {
  267. m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
  268. if (m !== null && Array.isArray(m) && m.length >= 3) {
  269. if (checkAllAliases(m[1], flags.arrays)) {
  270. i = eatArray(i, m[1], args, m[2]);
  271. }
  272. else if (checkAllAliases(m[1], flags.nargs) !== false) {
  273. i = eatNargs(i, m[1], args, m[2]);
  274. }
  275. else {
  276. setArg(m[1], m[2], true);
  277. }
  278. }
  279. }
  280. else if (arg.match(negatedBoolean) && configuration['boolean-negation']) {
  281. m = arg.match(negatedBoolean);
  282. if (m !== null && Array.isArray(m) && m.length >= 2) {
  283. key = m[1];
  284. setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
  285. }
  286. }
  287. else if (arg.match(/^--.+/) || (!configuration['short-option-groups'] && arg.match(/^-[^-]+/))) {
  288. m = arg.match(/^--?(.+)/);
  289. if (m !== null && Array.isArray(m) && m.length >= 2) {
  290. key = m[1];
  291. if (checkAllAliases(key, flags.arrays)) {
  292. i = eatArray(i, key, args);
  293. }
  294. else if (checkAllAliases(key, flags.nargs) !== false) {
  295. i = eatNargs(i, key, args);
  296. }
  297. else {
  298. next = args[i + 1];
  299. if (next !== undefined && (!next.match(/^-/) ||
  300. next.match(negative)) &&
  301. !checkAllAliases(key, flags.bools) &&
  302. !checkAllAliases(key, flags.counts)) {
  303. setArg(key, next);
  304. i++;
  305. }
  306. else if (/^(true|false)$/.test(next)) {
  307. setArg(key, next);
  308. i++;
  309. }
  310. else {
  311. setArg(key, defaultValue(key));
  312. }
  313. }
  314. }
  315. }
  316. else if (arg.match(/^-.\..+=/)) {
  317. m = arg.match(/^-([^=]+)=([\s\S]*)$/);
  318. if (m !== null && Array.isArray(m) && m.length >= 3) {
  319. setArg(m[1], m[2]);
  320. }
  321. }
  322. else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
  323. next = args[i + 1];
  324. m = arg.match(/^-(.\..+)/);
  325. if (m !== null && Array.isArray(m) && m.length >= 2) {
  326. key = m[1];
  327. if (next !== undefined && !next.match(/^-/) &&
  328. !checkAllAliases(key, flags.bools) &&
  329. !checkAllAliases(key, flags.counts)) {
  330. setArg(key, next);
  331. i++;
  332. }
  333. else {
  334. setArg(key, defaultValue(key));
  335. }
  336. }
  337. }
  338. else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
  339. letters = arg.slice(1, -1).split('');
  340. broken = false;
  341. for (let j = 0; j < letters.length; j++) {
  342. next = arg.slice(j + 2);
  343. if (letters[j + 1] && letters[j + 1] === '=') {
  344. value = arg.slice(j + 3);
  345. key = letters[j];
  346. if (checkAllAliases(key, flags.arrays)) {
  347. i = eatArray(i, key, args, value);
  348. }
  349. else if (checkAllAliases(key, flags.nargs) !== false) {
  350. i = eatNargs(i, key, args, value);
  351. }
  352. else {
  353. setArg(key, value);
  354. }
  355. broken = true;
  356. break;
  357. }
  358. if (next === '-') {
  359. setArg(letters[j], next);
  360. continue;
  361. }
  362. if (/[A-Za-z]/.test(letters[j]) &&
  363. /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) &&
  364. checkAllAliases(next, flags.bools) === false) {
  365. setArg(letters[j], next);
  366. broken = true;
  367. break;
  368. }
  369. if (letters[j + 1] && letters[j + 1].match(/\W/)) {
  370. setArg(letters[j], next);
  371. broken = true;
  372. break;
  373. }
  374. else {
  375. setArg(letters[j], defaultValue(letters[j]));
  376. }
  377. }
  378. key = arg.slice(-1)[0];
  379. if (!broken && key !== '-') {
  380. if (checkAllAliases(key, flags.arrays)) {
  381. i = eatArray(i, key, args);
  382. }
  383. else if (checkAllAliases(key, flags.nargs) !== false) {
  384. i = eatNargs(i, key, args);
  385. }
  386. else {
  387. next = args[i + 1];
  388. if (next !== undefined && (!/^(-|--)[^-]/.test(next) ||
  389. next.match(negative)) &&
  390. !checkAllAliases(key, flags.bools) &&
  391. !checkAllAliases(key, flags.counts)) {
  392. setArg(key, next);
  393. i++;
  394. }
  395. else if (/^(true|false)$/.test(next)) {
  396. setArg(key, next);
  397. i++;
  398. }
  399. else {
  400. setArg(key, defaultValue(key));
  401. }
  402. }
  403. }
  404. }
  405. else if (arg.match(/^-[0-9]$/) &&
  406. arg.match(negative) &&
  407. checkAllAliases(arg.slice(1), flags.bools)) {
  408. key = arg.slice(1);
  409. setArg(key, defaultValue(key));
  410. }
  411. else if (arg === '--') {
  412. notFlags = args.slice(i + 1);
  413. break;
  414. }
  415. else if (configuration['halt-at-non-option']) {
  416. notFlags = args.slice(i);
  417. break;
  418. }
  419. else {
  420. pushPositional(arg);
  421. }
  422. }
  423. applyEnvVars(argv, true);
  424. applyEnvVars(argv, false);
  425. setConfig(argv);
  426. setConfigObjects();
  427. applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
  428. applyCoercions(argv);
  429. if (configuration['set-placeholder-key'])
  430. setPlaceholderKeys(argv);
  431. Object.keys(flags.counts).forEach(function (key) {
  432. if (!hasKey(argv, key.split('.')))
  433. setArg(key, 0);
  434. });
  435. if (notFlagsOption && notFlags.length)
  436. argv[notFlagsArgv] = [];
  437. notFlags.forEach(function (key) {
  438. argv[notFlagsArgv].push(key);
  439. });
  440. if (configuration['camel-case-expansion'] && configuration['strip-dashed']) {
  441. Object.keys(argv).filter(key => key !== '--' && key.includes('-')).forEach(key => {
  442. delete argv[key];
  443. });
  444. }
  445. if (configuration['strip-aliased']) {
  446. [].concat(...Object.keys(aliases).map(k => aliases[k])).forEach(alias => {
  447. if (configuration['camel-case-expansion'] && alias.includes('-')) {
  448. delete argv[alias.split('.').map(prop => camelCase$1(prop)).join('.')];
  449. }
  450. delete argv[alias];
  451. });
  452. }
  453. function pushPositional(arg) {
  454. const maybeCoercedNumber = maybeCoerceNumber('_', arg);
  455. if (typeof maybeCoercedNumber === 'string' || typeof maybeCoercedNumber === 'number') {
  456. argv._.push(maybeCoercedNumber);
  457. }
  458. }
  459. function eatNargs(i, key, args, argAfterEqualSign) {
  460. let ii;
  461. let toEat = checkAllAliases(key, flags.nargs);
  462. toEat = typeof toEat !== 'number' || isNaN(toEat) ? 1 : toEat;
  463. if (toEat === 0) {
  464. if (!isUndefined(argAfterEqualSign)) {
  465. error = Error(__('Argument unexpected for: %s', key));
  466. }
  467. setArg(key, defaultValue(key));
  468. return i;
  469. }
  470. let available = isUndefined(argAfterEqualSign) ? 0 : 1;
  471. if (configuration['nargs-eats-options']) {
  472. if (args.length - (i + 1) + available < toEat) {
  473. error = Error(__('Not enough arguments following: %s', key));
  474. }
  475. available = toEat;
  476. }
  477. else {
  478. for (ii = i + 1; ii < args.length; ii++) {
  479. if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii]))
  480. available++;
  481. else
  482. break;
  483. }
  484. if (available < toEat)
  485. error = Error(__('Not enough arguments following: %s', key));
  486. }
  487. let consumed = Math.min(available, toEat);
  488. if (!isUndefined(argAfterEqualSign) && consumed > 0) {
  489. setArg(key, argAfterEqualSign);
  490. consumed--;
  491. }
  492. for (ii = i + 1; ii < (consumed + i + 1); ii++) {
  493. setArg(key, args[ii]);
  494. }
  495. return (i + consumed);
  496. }
  497. function eatArray(i, key, args, argAfterEqualSign) {
  498. let argsToSet = [];
  499. let next = argAfterEqualSign || args[i + 1];
  500. const nargsCount = checkAllAliases(key, flags.nargs);
  501. if (checkAllAliases(key, flags.bools) && !(/^(true|false)$/.test(next))) {
  502. argsToSet.push(true);
  503. }
  504. else if (isUndefined(next) ||
  505. (isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))) {
  506. if (defaults[key] !== undefined) {
  507. const defVal = defaults[key];
  508. argsToSet = Array.isArray(defVal) ? defVal : [defVal];
  509. }
  510. }
  511. else {
  512. if (!isUndefined(argAfterEqualSign)) {
  513. argsToSet.push(processValue(key, argAfterEqualSign, true));
  514. }
  515. for (let ii = i + 1; ii < args.length; ii++) {
  516. if ((!configuration['greedy-arrays'] && argsToSet.length > 0) ||
  517. (nargsCount && typeof nargsCount === 'number' && argsToSet.length >= nargsCount))
  518. break;
  519. next = args[ii];
  520. if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
  521. break;
  522. i = ii;
  523. argsToSet.push(processValue(key, next, inputIsString));
  524. }
  525. }
  526. if (typeof nargsCount === 'number' && ((nargsCount && argsToSet.length < nargsCount) ||
  527. (isNaN(nargsCount) && argsToSet.length === 0))) {
  528. error = Error(__('Not enough arguments following: %s', key));
  529. }
  530. setArg(key, argsToSet);
  531. return i;
  532. }
  533. function setArg(key, val, shouldStripQuotes = inputIsString) {
  534. if (/-/.test(key) && configuration['camel-case-expansion']) {
  535. const alias = key.split('.').map(function (prop) {
  536. return camelCase$1(prop);
  537. }).join('.');
  538. addNewAlias(key, alias);
  539. }
  540. const value = processValue(key, val, shouldStripQuotes);
  541. const splitKey = key.split('.');
  542. setKey(argv, splitKey, value);
  543. if (flags.aliases[key]) {
  544. flags.aliases[key].forEach(function (x) {
  545. const keyProperties = x.split('.');
  546. setKey(argv, keyProperties, value);
  547. });
  548. }
  549. if (splitKey.length > 1 && configuration['dot-notation']) {
  550. (flags.aliases[splitKey[0]] || []).forEach(function (x) {
  551. let keyProperties = x.split('.');
  552. const a = [].concat(splitKey);
  553. a.shift();
  554. keyProperties = keyProperties.concat(a);
  555. if (!(flags.aliases[key] || []).includes(keyProperties.join('.'))) {
  556. setKey(argv, keyProperties, value);
  557. }
  558. });
  559. }
  560. if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
  561. const keys = [key].concat(flags.aliases[key] || []);
  562. keys.forEach(function (key) {
  563. Object.defineProperty(argvReturn, key, {
  564. enumerable: true,
  565. get() {
  566. return val;
  567. },
  568. set(value) {
  569. val = typeof value === 'string' ? mixin.normalize(value) : value;
  570. }
  571. });
  572. });
  573. }
  574. }
  575. function addNewAlias(key, alias) {
  576. if (!(flags.aliases[key] && flags.aliases[key].length)) {
  577. flags.aliases[key] = [alias];
  578. newAliases[alias] = true;
  579. }
  580. if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
  581. addNewAlias(alias, key);
  582. }
  583. }
  584. function processValue(key, val, shouldStripQuotes) {
  585. if (shouldStripQuotes) {
  586. val = stripQuotes(val);
  587. }
  588. if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
  589. if (typeof val === 'string')
  590. val = val === 'true';
  591. }
  592. let value = Array.isArray(val)
  593. ? val.map(function (v) { return maybeCoerceNumber(key, v); })
  594. : maybeCoerceNumber(key, val);
  595. if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
  596. value = increment();
  597. }
  598. if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
  599. if (Array.isArray(val))
  600. value = val.map((val) => { return mixin.normalize(val); });
  601. else
  602. value = mixin.normalize(val);
  603. }
  604. return value;
  605. }
  606. function maybeCoerceNumber(key, value) {
  607. if (!configuration['parse-positional-numbers'] && key === '_')
  608. return value;
  609. if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
  610. const shouldCoerceNumber = looksLikeNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(Math.floor(parseFloat(`${value}`))));
  611. if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) {
  612. value = Number(value);
  613. }
  614. }
  615. return value;
  616. }
  617. function setConfig(argv) {
  618. const configLookup = Object.create(null);
  619. applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
  620. Object.keys(flags.configs).forEach(function (configKey) {
  621. const configPath = argv[configKey] || configLookup[configKey];
  622. if (configPath) {
  623. try {
  624. let config = null;
  625. const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
  626. const resolveConfig = flags.configs[configKey];
  627. if (typeof resolveConfig === 'function') {
  628. try {
  629. config = resolveConfig(resolvedConfigPath);
  630. }
  631. catch (e) {
  632. config = e;
  633. }
  634. if (config instanceof Error) {
  635. error = config;
  636. return;
  637. }
  638. }
  639. else {
  640. config = mixin.require(resolvedConfigPath);
  641. }
  642. setConfigObject(config);
  643. }
  644. catch (ex) {
  645. if (ex.name === 'PermissionDenied')
  646. error = ex;
  647. else if (argv[configKey])
  648. error = Error(__('Invalid JSON config file: %s', configPath));
  649. }
  650. }
  651. });
  652. }
  653. function setConfigObject(config, prev) {
  654. Object.keys(config).forEach(function (key) {
  655. const value = config[key];
  656. const fullKey = prev ? prev + '.' + key : key;
  657. if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
  658. setConfigObject(value, fullKey);
  659. }
  660. else {
  661. if (!hasKey(argv, fullKey.split('.')) || (checkAllAliases(fullKey, flags.arrays) && configuration['combine-arrays'])) {
  662. setArg(fullKey, value);
  663. }
  664. }
  665. });
  666. }
  667. function setConfigObjects() {
  668. if (typeof configObjects !== 'undefined') {
  669. configObjects.forEach(function (configObject) {
  670. setConfigObject(configObject);
  671. });
  672. }
  673. }
  674. function applyEnvVars(argv, configOnly) {
  675. if (typeof envPrefix === 'undefined')
  676. return;
  677. const prefix = typeof envPrefix === 'string' ? envPrefix : '';
  678. const env = mixin.env();
  679. Object.keys(env).forEach(function (envVar) {
  680. if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) {
  681. const keys = envVar.split('__').map(function (key, i) {
  682. if (i === 0) {
  683. key = key.substring(prefix.length);
  684. }
  685. return camelCase$1(key);
  686. });
  687. if (((configOnly && flags.configs[keys.join('.')]) || !configOnly) && !hasKey(argv, keys)) {
  688. setArg(keys.join('.'), env[envVar]);
  689. }
  690. }
  691. });
  692. }
  693. function applyCoercions(argv) {
  694. let coerce;
  695. const applied = new Set();
  696. Object.keys(argv).forEach(function (key) {
  697. if (!applied.has(key)) {
  698. coerce = checkAllAliases(key, flags.coercions);
  699. if (typeof coerce === 'function') {
  700. try {
  701. const value = maybeCoerceNumber(key, coerce(argv[key]));
  702. ([].concat(flags.aliases[key] || [], key)).forEach(ali => {
  703. applied.add(ali);
  704. argv[ali] = value;
  705. });
  706. }
  707. catch (err) {
  708. error = err;
  709. }
  710. }
  711. }
  712. });
  713. }
  714. function setPlaceholderKeys(argv) {
  715. flags.keys.forEach((key) => {
  716. if (~key.indexOf('.'))
  717. return;
  718. if (typeof argv[key] === 'undefined')
  719. argv[key] = undefined;
  720. });
  721. return argv;
  722. }
  723. function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
  724. Object.keys(defaults).forEach(function (key) {
  725. if (!hasKey(obj, key.split('.'))) {
  726. setKey(obj, key.split('.'), defaults[key]);
  727. if (canLog)
  728. defaulted[key] = true;
  729. (aliases[key] || []).forEach(function (x) {
  730. if (hasKey(obj, x.split('.')))
  731. return;
  732. setKey(obj, x.split('.'), defaults[key]);
  733. });
  734. }
  735. });
  736. }
  737. function hasKey(obj, keys) {
  738. let o = obj;
  739. if (!configuration['dot-notation'])
  740. keys = [keys.join('.')];
  741. keys.slice(0, -1).forEach(function (key) {
  742. o = (o[key] || {});
  743. });
  744. const key = keys[keys.length - 1];
  745. if (typeof o !== 'object')
  746. return false;
  747. else
  748. return key in o;
  749. }
  750. function setKey(obj, keys, value) {
  751. let o = obj;
  752. if (!configuration['dot-notation'])
  753. keys = [keys.join('.')];
  754. keys.slice(0, -1).forEach(function (key) {
  755. key = sanitizeKey(key);
  756. if (typeof o === 'object' && o[key] === undefined) {
  757. o[key] = {};
  758. }
  759. if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
  760. if (Array.isArray(o[key])) {
  761. o[key].push({});
  762. }
  763. else {
  764. o[key] = [o[key], {}];
  765. }
  766. o = o[key][o[key].length - 1];
  767. }
  768. else {
  769. o = o[key];
  770. }
  771. });
  772. const key = sanitizeKey(keys[keys.length - 1]);
  773. const isTypeArray = checkAllAliases(keys.join('.'), flags.arrays);
  774. const isValueArray = Array.isArray(value);
  775. let duplicate = configuration['duplicate-arguments-array'];
  776. if (!duplicate && checkAllAliases(key, flags.nargs)) {
  777. duplicate = true;
  778. if ((!isUndefined(o[key]) && flags.nargs[key] === 1) || (Array.isArray(o[key]) && o[key].length === flags.nargs[key])) {
  779. o[key] = undefined;
  780. }
  781. }
  782. if (value === increment()) {
  783. o[key] = increment(o[key]);
  784. }
  785. else if (Array.isArray(o[key])) {
  786. if (duplicate && isTypeArray && isValueArray) {
  787. o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
  788. }
  789. else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
  790. o[key] = value;
  791. }
  792. else {
  793. o[key] = o[key].concat([value]);
  794. }
  795. }
  796. else if (o[key] === undefined && isTypeArray) {
  797. o[key] = isValueArray ? value : [value];
  798. }
  799. else if (duplicate && !(o[key] === undefined ||
  800. checkAllAliases(key, flags.counts) ||
  801. checkAllAliases(key, flags.bools))) {
  802. o[key] = [o[key], value];
  803. }
  804. else {
  805. o[key] = value;
  806. }
  807. }
  808. function extendAliases(...args) {
  809. args.forEach(function (obj) {
  810. Object.keys(obj || {}).forEach(function (key) {
  811. if (flags.aliases[key])
  812. return;
  813. flags.aliases[key] = [].concat(aliases[key] || []);
  814. flags.aliases[key].concat(key).forEach(function (x) {
  815. if (/-/.test(x) && configuration['camel-case-expansion']) {
  816. const c = camelCase$1(x);
  817. if (c !== key && flags.aliases[key].indexOf(c) === -1) {
  818. flags.aliases[key].push(c);
  819. newAliases[c] = true;
  820. }
  821. }
  822. });
  823. flags.aliases[key].concat(key).forEach(function (x) {
  824. if (x.length > 1 && /[A-Z]/.test(x) && configuration['camel-case-expansion']) {
  825. const c = decamelize$1(x, '-');
  826. if (c !== key && flags.aliases[key].indexOf(c) === -1) {
  827. flags.aliases[key].push(c);
  828. newAliases[c] = true;
  829. }
  830. }
  831. });
  832. flags.aliases[key].forEach(function (x) {
  833. flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
  834. return x !== y;
  835. }));
  836. });
  837. });
  838. });
  839. }
  840. function checkAllAliases(key, flag) {
  841. const toCheck = [].concat(flags.aliases[key] || [], key);
  842. const keys = Object.keys(flag);
  843. const setAlias = toCheck.find(key => keys.includes(key));
  844. return setAlias ? flag[setAlias] : false;
  845. }
  846. function hasAnyFlag(key) {
  847. const flagsKeys = Object.keys(flags);
  848. const toCheck = [].concat(flagsKeys.map(k => flags[k]));
  849. return toCheck.some(function (flag) {
  850. return Array.isArray(flag) ? flag.includes(key) : flag[key];
  851. });
  852. }
  853. function hasFlagsMatching(arg, ...patterns) {
  854. const toCheck = [].concat(...patterns);
  855. return toCheck.some(function (pattern) {
  856. const match = arg.match(pattern);
  857. return match && hasAnyFlag(match[1]);
  858. });
  859. }
  860. function hasAllShortFlags(arg) {
  861. if (arg.match(negative) || !arg.match(/^-[^-]+/)) {
  862. return false;
  863. }
  864. let hasAllFlags = true;
  865. let next;
  866. const letters = arg.slice(1).split('');
  867. for (let j = 0; j < letters.length; j++) {
  868. next = arg.slice(j + 2);
  869. if (!hasAnyFlag(letters[j])) {
  870. hasAllFlags = false;
  871. break;
  872. }
  873. if ((letters[j + 1] && letters[j + 1] === '=') ||
  874. next === '-' ||
  875. (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) ||
  876. (letters[j + 1] && letters[j + 1].match(/\W/))) {
  877. break;
  878. }
  879. }
  880. return hasAllFlags;
  881. }
  882. function isUnknownOptionAsArg(arg) {
  883. return configuration['unknown-options-as-args'] && isUnknownOption(arg);
  884. }
  885. function isUnknownOption(arg) {
  886. arg = arg.replace(/^-{3,}/, '--');
  887. if (arg.match(negative)) {
  888. return false;
  889. }
  890. if (hasAllShortFlags(arg)) {
  891. return false;
  892. }
  893. const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/;
  894. const normalFlag = /^-+([^=]+?)$/;
  895. const flagEndingInHyphen = /^-+([^=]+?)-$/;
  896. const flagEndingInDigits = /^-+([^=]+?\d+)$/;
  897. const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/;
  898. return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters);
  899. }
  900. function defaultValue(key) {
  901. if (!checkAllAliases(key, flags.bools) &&
  902. !checkAllAliases(key, flags.counts) &&
  903. `${key}` in defaults) {
  904. return defaults[key];
  905. }
  906. else {
  907. return defaultForType(guessType(key));
  908. }
  909. }
  910. function defaultForType(type) {
  911. const def = {
  912. [DefaultValuesForTypeKey.BOOLEAN]: true,
  913. [DefaultValuesForTypeKey.STRING]: '',
  914. [DefaultValuesForTypeKey.NUMBER]: undefined,
  915. [DefaultValuesForTypeKey.ARRAY]: []
  916. };
  917. return def[type];
  918. }
  919. function guessType(key) {
  920. let type = DefaultValuesForTypeKey.BOOLEAN;
  921. if (checkAllAliases(key, flags.strings))
  922. type = DefaultValuesForTypeKey.STRING;
  923. else if (checkAllAliases(key, flags.numbers))
  924. type = DefaultValuesForTypeKey.NUMBER;
  925. else if (checkAllAliases(key, flags.bools))
  926. type = DefaultValuesForTypeKey.BOOLEAN;
  927. else if (checkAllAliases(key, flags.arrays))
  928. type = DefaultValuesForTypeKey.ARRAY;
  929. return type;
  930. }
  931. function isUndefined(num) {
  932. return num === undefined;
  933. }
  934. function checkConfiguration() {
  935. Object.keys(flags.counts).find(key => {
  936. if (checkAllAliases(key, flags.arrays)) {
  937. error = Error(__('Invalid configuration: %s, opts.count excludes opts.array.', key));
  938. return true;
  939. }
  940. else if (checkAllAliases(key, flags.nargs)) {
  941. error = Error(__('Invalid configuration: %s, opts.count excludes opts.narg.', key));
  942. return true;
  943. }
  944. return false;
  945. });
  946. }
  947. return {
  948. aliases: Object.assign({}, flags.aliases),
  949. argv: Object.assign(argvReturn, argv),
  950. configuration: configuration,
  951. defaulted: Object.assign({}, defaulted),
  952. error: error,
  953. newAliases: Object.assign({}, newAliases)
  954. };
  955. }
  956. }
  957. function combineAliases(aliases) {
  958. const aliasArrays = [];
  959. const combined = Object.create(null);
  960. let change = true;
  961. Object.keys(aliases).forEach(function (key) {
  962. aliasArrays.push([].concat(aliases[key], key));
  963. });
  964. while (change) {
  965. change = false;
  966. for (let i = 0; i < aliasArrays.length; i++) {
  967. for (let ii = i + 1; ii < aliasArrays.length; ii++) {
  968. const intersect = aliasArrays[i].filter(function (v) {
  969. return aliasArrays[ii].indexOf(v) !== -1;
  970. });
  971. if (intersect.length) {
  972. aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
  973. aliasArrays.splice(ii, 1);
  974. change = true;
  975. break;
  976. }
  977. }
  978. }
  979. }
  980. aliasArrays.forEach(function (aliasArray) {
  981. aliasArray = aliasArray.filter(function (v, i, self) {
  982. return self.indexOf(v) === i;
  983. });
  984. const lastAlias = aliasArray.pop();
  985. if (lastAlias !== undefined && typeof lastAlias === 'string') {
  986. combined[lastAlias] = aliasArray;
  987. }
  988. });
  989. return combined;
  990. }
  991. function increment(orig) {
  992. return orig !== undefined ? orig + 1 : 1;
  993. }
  994. function sanitizeKey(key) {
  995. if (key === '__proto__')
  996. return '___proto___';
  997. return key;
  998. }
  999. function stripQuotes(val) {
  1000. return (typeof val === 'string' &&
  1001. (val[0] === "'" || val[0] === '"') &&
  1002. val[val.length - 1] === val[0])
  1003. ? val.substring(1, val.length - 1)
  1004. : val;
  1005. }
  1006. var _a, _b, _c;
  1007. const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
  1008. ? Number(process.env.YARGS_MIN_NODE_VERSION)
  1009. : 12;
  1010. const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
  1011. if (nodeVersion) {
  1012. const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
  1013. if (major < minNodeVersion) {
  1014. throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
  1015. }
  1016. }
  1017. const env$2 = process ? process.env : {};
  1018. const parser = new YargsParser({
  1019. cwd: process.cwd,
  1020. env: () => {
  1021. return env$2;
  1022. },
  1023. format,
  1024. normalize: normalize$1,
  1025. resolve,
  1026. require: (path) => {
  1027. if (typeof require !== 'undefined') {
  1028. return require(path);
  1029. }
  1030. else if (path.match(/\.json$/)) {
  1031. return JSON.parse(readFileSync(path, 'utf8'));
  1032. }
  1033. else {
  1034. throw Error('only .json config files are supported in ESM');
  1035. }
  1036. }
  1037. });
  1038. const yargsParser = function Parser(args, opts) {
  1039. const result = parser.parse(args.slice(), opts);
  1040. return result.argv;
  1041. };
  1042. yargsParser.detailed = function (args, opts) {
  1043. return parser.parse(args.slice(), opts);
  1044. };
  1045. yargsParser.camelCase = camelCase$1;
  1046. yargsParser.decamelize = decamelize$1;
  1047. yargsParser.looksLikeNumber = looksLikeNumber;
  1048. const isObject$3 = value => typeof value === 'object' && value !== null;
  1049. const isObjectCustom$1 = value =>
  1050. isObject$3(value)
  1051. && !(value instanceof RegExp)
  1052. && !(value instanceof Error)
  1053. && !(value instanceof Date);
  1054. const mapObjectSkip$1 = Symbol('mapObjectSkip');
  1055. const _mapObject = (object, mapper, options, isSeen = new WeakMap()) => {
  1056. options = {
  1057. deep: false,
  1058. target: {},
  1059. ...options,
  1060. };
  1061. if (isSeen.has(object)) {
  1062. return isSeen.get(object);
  1063. }
  1064. isSeen.set(object, options.target);
  1065. const {target} = options;
  1066. delete options.target;
  1067. const mapArray = array => array.map(element => isObjectCustom$1(element) ? _mapObject(element, mapper, options, isSeen) : element);
  1068. if (Array.isArray(object)) {
  1069. return mapArray(object);
  1070. }
  1071. for (const [key, value] of Object.entries(object)) {
  1072. const mapResult = mapper(key, value, object);
  1073. if (mapResult === mapObjectSkip$1) {
  1074. continue;
  1075. }
  1076. let [newKey, newValue, {shouldRecurse = true} = {}] = mapResult;
  1077. if (newKey === '__proto__') {
  1078. continue;
  1079. }
  1080. if (options.deep && shouldRecurse && isObjectCustom$1(newValue)) {
  1081. newValue = Array.isArray(newValue)
  1082. ? mapArray(newValue)
  1083. : _mapObject(newValue, mapper, options, isSeen);
  1084. }
  1085. target[newKey] = newValue;
  1086. }
  1087. return target;
  1088. };
  1089. function mapObject$2(object, mapper, options) {
  1090. if (!isObject$3(object)) {
  1091. throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
  1092. }
  1093. return _mapObject(object, mapper, options);
  1094. }
  1095. const UPPERCASE = /[\p{Lu}]/u;
  1096. const LOWERCASE = /[\p{Ll}]/u;
  1097. const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
  1098. const IDENTIFIER$1 = /([\p{Alpha}\p{N}_]|$)/u;
  1099. const SEPARATORS = /[_.\- ]+/;
  1100. const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
  1101. const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER$1.source, 'gu');
  1102. const NUMBERS_AND_IDENTIFIER = new RegExp('\\d+' + IDENTIFIER$1.source, 'gu');
  1103. const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {
  1104. let isLastCharLower = false;
  1105. let isLastCharUpper = false;
  1106. let isLastLastCharUpper = false;
  1107. let isLastLastCharPreserved = false;
  1108. for (let index = 0; index < string.length; index++) {
  1109. const character = string[index];
  1110. isLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;
  1111. if (isLastCharLower && UPPERCASE.test(character)) {
  1112. string = string.slice(0, index) + '-' + string.slice(index);
  1113. isLastCharLower = false;
  1114. isLastLastCharUpper = isLastCharUpper;
  1115. isLastCharUpper = true;
  1116. index++;
  1117. } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase)) {
  1118. string = string.slice(0, index - 1) + '-' + string.slice(index - 1);
  1119. isLastLastCharUpper = isLastCharUpper;
  1120. isLastCharUpper = false;
  1121. isLastCharLower = true;
  1122. } else {
  1123. isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
  1124. isLastLastCharUpper = isLastCharUpper;
  1125. isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
  1126. }
  1127. }
  1128. return string;
  1129. };
  1130. const preserveConsecutiveUppercase = (input, toLowerCase) => {
  1131. LEADING_CAPITAL.lastIndex = 0;
  1132. return input.replaceAll(LEADING_CAPITAL, match => toLowerCase(match));
  1133. };
  1134. const postProcess = (input, toUpperCase) => {
  1135. SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
  1136. NUMBERS_AND_IDENTIFIER.lastIndex = 0;
  1137. return input
  1138. .replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))
  1139. .replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));
  1140. };
  1141. function camelCase(input, options) {
  1142. if (!(typeof input === 'string' || Array.isArray(input))) {
  1143. throw new TypeError('Expected the input to be `string | string[]`');
  1144. }
  1145. options = {
  1146. pascalCase: false,
  1147. preserveConsecutiveUppercase: false,
  1148. ...options,
  1149. };
  1150. if (Array.isArray(input)) {
  1151. input = input.map(x => x.trim())
  1152. .filter(x => x.length)
  1153. .join('-');
  1154. } else {
  1155. input = input.trim();
  1156. }
  1157. if (input.length === 0) {
  1158. return '';
  1159. }
  1160. const toLowerCase = options.locale === false
  1161. ? string => string.toLowerCase()
  1162. : string => string.toLocaleLowerCase(options.locale);
  1163. const toUpperCase = options.locale === false
  1164. ? string => string.toUpperCase()
  1165. : string => string.toLocaleUpperCase(options.locale);
  1166. if (input.length === 1) {
  1167. if (SEPARATORS.test(input)) {
  1168. return '';
  1169. }
  1170. return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
  1171. }
  1172. const hasUpperCase = input !== toLowerCase(input);
  1173. if (hasUpperCase) {
  1174. input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
  1175. }
  1176. input = input.replace(LEADING_SEPARATORS, '');
  1177. input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
  1178. if (options.pascalCase) {
  1179. input = toUpperCase(input.charAt(0)) + input.slice(1);
  1180. }
  1181. return postProcess(input, toUpperCase);
  1182. }
  1183. class QuickLRU extends Map {
  1184. constructor(options = {}) {
  1185. super();
  1186. if (!(options.maxSize && options.maxSize > 0)) {
  1187. throw new TypeError('`maxSize` must be a number greater than 0');
  1188. }
  1189. if (typeof options.maxAge === 'number' && options.maxAge === 0) {
  1190. throw new TypeError('`maxAge` must be a number greater than 0');
  1191. }
  1192. this.maxSize = options.maxSize;
  1193. this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
  1194. this.onEviction = options.onEviction;
  1195. this.cache = new Map();
  1196. this.oldCache = new Map();
  1197. this._size = 0;
  1198. }
  1199. _emitEvictions(cache) {
  1200. if (typeof this.onEviction !== 'function') {
  1201. return;
  1202. }
  1203. for (const [key, item] of cache) {
  1204. this.onEviction(key, item.value);
  1205. }
  1206. }
  1207. _deleteIfExpired(key, item) {
  1208. if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
  1209. if (typeof this.onEviction === 'function') {
  1210. this.onEviction(key, item.value);
  1211. }
  1212. return this.delete(key);
  1213. }
  1214. return false;
  1215. }
  1216. _getOrDeleteIfExpired(key, item) {
  1217. const deleted = this._deleteIfExpired(key, item);
  1218. if (deleted === false) {
  1219. return item.value;
  1220. }
  1221. }
  1222. _getItemValue(key, item) {
  1223. return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
  1224. }
  1225. _peek(key, cache) {
  1226. const item = cache.get(key);
  1227. return this._getItemValue(key, item);
  1228. }
  1229. _set(key, value) {
  1230. this.cache.set(key, value);
  1231. this._size++;
  1232. if (this._size >= this.maxSize) {
  1233. this._size = 0;
  1234. this._emitEvictions(this.oldCache);
  1235. this.oldCache = this.cache;
  1236. this.cache = new Map();
  1237. }
  1238. }
  1239. _moveToRecent(key, item) {
  1240. this.oldCache.delete(key);
  1241. this._set(key, item);
  1242. }
  1243. * _entriesAscending() {
  1244. for (const item of this.oldCache) {
  1245. const [key, value] = item;
  1246. if (!this.cache.has(key)) {
  1247. const deleted = this._deleteIfExpired(key, value);
  1248. if (deleted === false) {
  1249. yield item;
  1250. }
  1251. }
  1252. }
  1253. for (const item of this.cache) {
  1254. const [key, value] = item;
  1255. const deleted = this._deleteIfExpired(key, value);
  1256. if (deleted === false) {
  1257. yield item;
  1258. }
  1259. }
  1260. }
  1261. get(key) {
  1262. if (this.cache.has(key)) {
  1263. const item = this.cache.get(key);
  1264. return this._getItemValue(key, item);
  1265. }
  1266. if (this.oldCache.has(key)) {
  1267. const item = this.oldCache.get(key);
  1268. if (this._deleteIfExpired(key, item) === false) {
  1269. this._moveToRecent(key, item);
  1270. return item.value;
  1271. }
  1272. }
  1273. }
  1274. set(key, value, {maxAge = this.maxAge} = {}) {
  1275. const expiry =
  1276. typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY ?
  1277. Date.now() + maxAge :
  1278. undefined;
  1279. if (this.cache.has(key)) {
  1280. this.cache.set(key, {
  1281. value,
  1282. expiry
  1283. });
  1284. } else {
  1285. this._set(key, {value, expiry});
  1286. }
  1287. return this;
  1288. }
  1289. has(key) {
  1290. if (this.cache.has(key)) {
  1291. return !this._deleteIfExpired(key, this.cache.get(key));
  1292. }
  1293. if (this.oldCache.has(key)) {
  1294. return !this._deleteIfExpired(key, this.oldCache.get(key));
  1295. }
  1296. return false;
  1297. }
  1298. peek(key) {
  1299. if (this.cache.has(key)) {
  1300. return this._peek(key, this.cache);
  1301. }
  1302. if (this.oldCache.has(key)) {
  1303. return this._peek(key, this.oldCache);
  1304. }
  1305. }
  1306. delete(key) {
  1307. const deleted = this.cache.delete(key);
  1308. if (deleted) {
  1309. this._size--;
  1310. }
  1311. return this.oldCache.delete(key) || deleted;
  1312. }
  1313. clear() {
  1314. this.cache.clear();
  1315. this.oldCache.clear();
  1316. this._size = 0;
  1317. }
  1318. resize(newSize) {
  1319. if (!(newSize && newSize > 0)) {
  1320. throw new TypeError('`maxSize` must be a number greater than 0');
  1321. }
  1322. const items = [...this._entriesAscending()];
  1323. const removeCount = items.length - newSize;
  1324. if (removeCount < 0) {
  1325. this.cache = new Map(items);
  1326. this.oldCache = new Map();
  1327. this._size = items.length;
  1328. } else {
  1329. if (removeCount > 0) {
  1330. this._emitEvictions(items.slice(0, removeCount));
  1331. }
  1332. this.oldCache = new Map(items.slice(removeCount));
  1333. this.cache = new Map();
  1334. this._size = 0;
  1335. }
  1336. this.maxSize = newSize;
  1337. }
  1338. * keys() {
  1339. for (const [key] of this) {
  1340. yield key;
  1341. }
  1342. }
  1343. * values() {
  1344. for (const [, value] of this) {
  1345. yield value;
  1346. }
  1347. }
  1348. * [Symbol.iterator]() {
  1349. for (const item of this.cache) {
  1350. const [key, value] = item;
  1351. const deleted = this._deleteIfExpired(key, value);
  1352. if (deleted === false) {
  1353. yield [key, value.value];
  1354. }
  1355. }
  1356. for (const item of this.oldCache) {
  1357. const [key, value] = item;
  1358. if (!this.cache.has(key)) {
  1359. const deleted = this._deleteIfExpired(key, value);
  1360. if (deleted === false) {
  1361. yield [key, value.value];
  1362. }
  1363. }
  1364. }
  1365. }
  1366. * entriesDescending() {
  1367. let items = [...this.cache];
  1368. for (let i = items.length - 1; i >= 0; --i) {
  1369. const item = items[i];
  1370. const [key, value] = item;
  1371. const deleted = this._deleteIfExpired(key, value);
  1372. if (deleted === false) {
  1373. yield [key, value.value];
  1374. }
  1375. }
  1376. items = [...this.oldCache];
  1377. for (let i = items.length - 1; i >= 0; --i) {
  1378. const item = items[i];
  1379. const [key, value] = item;
  1380. if (!this.cache.has(key)) {
  1381. const deleted = this._deleteIfExpired(key, value);
  1382. if (deleted === false) {
  1383. yield [key, value.value];
  1384. }
  1385. }
  1386. }
  1387. }
  1388. * entriesAscending() {
  1389. for (const [key, value] of this._entriesAscending()) {
  1390. yield [key, value.value];
  1391. }
  1392. }
  1393. get size() {
  1394. if (!this._size) {
  1395. return this.oldCache.size;
  1396. }
  1397. let oldCacheSize = 0;
  1398. for (const key of this.oldCache.keys()) {
  1399. if (!this.cache.has(key)) {
  1400. oldCacheSize++;
  1401. }
  1402. }
  1403. return Math.min(this._size + oldCacheSize, this.maxSize);
  1404. }
  1405. entries() {
  1406. return this.entriesAscending();
  1407. }
  1408. forEach(callbackFunction, thisArgument = this) {
  1409. for (const [key, value] of this.entriesAscending()) {
  1410. callbackFunction.call(thisArgument, value, key, this);
  1411. }
  1412. }
  1413. get [Symbol.toStringTag]() {
  1414. return JSON.stringify([...this.entriesAscending()]);
  1415. }
  1416. }
  1417. const has$1 = (array, key) => array.some(element => {
  1418. if (typeof element === 'string') {
  1419. return element === key;
  1420. }
  1421. element.lastIndex = 0;
  1422. return element.test(key);
  1423. });
  1424. const cache$2 = new QuickLRU({maxSize: 100_000});
  1425. const isObject$2 = value =>
  1426. typeof value === 'object'
  1427. && value !== null
  1428. && !(value instanceof RegExp)
  1429. && !(value instanceof Error)
  1430. && !(value instanceof Date);
  1431. const transform$1 = (input, options = {}) => {
  1432. if (!isObject$2(input)) {
  1433. return input;
  1434. }
  1435. const {
  1436. exclude,
  1437. pascalCase = false,
  1438. stopPaths,
  1439. deep = false,
  1440. preserveConsecutiveUppercase = false,
  1441. } = options;
  1442. const stopPathsSet = new Set(stopPaths);
  1443. const makeMapper = parentPath => (key, value) => {
  1444. if (deep && isObject$2(value)) {
  1445. const path = parentPath === undefined ? key : `${parentPath}.${key}`;
  1446. if (!stopPathsSet.has(path)) {
  1447. value = mapObject$2(value, makeMapper(path));
  1448. }
  1449. }
  1450. if (!(exclude && has$1(exclude, key))) {
  1451. const cacheKey = pascalCase ? `${key}_` : key;
  1452. if (cache$2.has(cacheKey)) {
  1453. key = cache$2.get(cacheKey);
  1454. } else {
  1455. const returnValue = camelCase(key, {pascalCase, locale: false, preserveConsecutiveUppercase});
  1456. if (key.length < 100) {
  1457. cache$2.set(cacheKey, returnValue);
  1458. }
  1459. key = returnValue;
  1460. }
  1461. }
  1462. return [key, value];
  1463. };
  1464. return mapObject$2(input, makeMapper(undefined));
  1465. };
  1466. function camelcaseKeys(input, options) {
  1467. if (Array.isArray(input)) {
  1468. return Object.keys(input).map(key => transform$1(input[key], options));
  1469. }
  1470. return transform$1(input, options);
  1471. }
  1472. function trimNewlines(string) {
  1473. let start = 0;
  1474. let end = string.length;
  1475. while (start < end && (string[start] === '\r' || string[start] === '\n')) {
  1476. start++;
  1477. }
  1478. while (end > start && (string[end - 1] === '\r' || string[end - 1] === '\n')) {
  1479. end--;
  1480. }
  1481. return (start > 0 || end < string.length) ? string.slice(start, end) : string;
  1482. }
  1483. function getDefaultExportFromCjs (x) {
  1484. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  1485. }
  1486. var minIndent = string => {
  1487. const match = string.match(/^[ \t]*(?=\S)/gm);
  1488. if (!match) {
  1489. return 0;
  1490. }
  1491. return match.reduce((r, a) => Math.min(r, a.length), Infinity);
  1492. };
  1493. const minIndent$1 = getDefaultExportFromCjs(minIndent);
  1494. function stripIndent(string) {
  1495. const indent = minIndent$1(string);
  1496. if (indent === 0) {
  1497. return string;
  1498. }
  1499. const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
  1500. return string.replace(regex, '');
  1501. }
  1502. function indentString(string, count = 1, options = {}) {
  1503. const {
  1504. indent = ' ',
  1505. includeEmptyLines = false
  1506. } = options;
  1507. if (typeof string !== 'string') {
  1508. throw new TypeError(
  1509. `Expected \`input\` to be a \`string\`, got \`${typeof string}\``
  1510. );
  1511. }
  1512. if (typeof count !== 'number') {
  1513. throw new TypeError(
  1514. `Expected \`count\` to be a \`number\`, got \`${typeof count}\``
  1515. );
  1516. }
  1517. if (count < 0) {
  1518. throw new RangeError(
  1519. `Expected \`count\` to be at least 0, got \`${count}\``
  1520. );
  1521. }
  1522. if (typeof indent !== 'string') {
  1523. throw new TypeError(
  1524. `Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
  1525. );
  1526. }
  1527. if (count === 0) {
  1528. return string;
  1529. }
  1530. const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
  1531. return string.replace(regex, indent.repeat(count));
  1532. }
  1533. function redent(string, count = 0, options = {}) {
  1534. return indentString(stripIndent(string), count, options);
  1535. }
  1536. const debug$1 = (
  1537. typeof process === 'object' &&
  1538. process.env &&
  1539. process.env.NODE_DEBUG &&
  1540. /\bsemver\b/i.test(process.env.NODE_DEBUG)
  1541. ) ? (...args) => console.error('SEMVER', ...args)
  1542. : () => {};
  1543. var debug_1 = debug$1;
  1544. const SEMVER_SPEC_VERSION = '2.0.0';
  1545. const MAX_LENGTH$1 = 256;
  1546. const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
  1547. 9007199254740991;
  1548. const MAX_SAFE_COMPONENT_LENGTH = 16;
  1549. const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
  1550. const RELEASE_TYPES = [
  1551. 'major',
  1552. 'premajor',
  1553. 'minor',
  1554. 'preminor',
  1555. 'patch',
  1556. 'prepatch',
  1557. 'prerelease',
  1558. ];
  1559. var constants$1 = {
  1560. MAX_LENGTH: MAX_LENGTH$1,
  1561. MAX_SAFE_COMPONENT_LENGTH,
  1562. MAX_SAFE_BUILD_LENGTH,
  1563. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
  1564. RELEASE_TYPES,
  1565. SEMVER_SPEC_VERSION,
  1566. FLAG_INCLUDE_PRERELEASE: 0b001,
  1567. FLAG_LOOSE: 0b010,
  1568. };
  1569. var re$1 = {exports: {}};
  1570. (function (module, exports) {
  1571. const {
  1572. MAX_SAFE_COMPONENT_LENGTH,
  1573. MAX_SAFE_BUILD_LENGTH,
  1574. MAX_LENGTH,
  1575. } = constants$1;
  1576. const debug = debug_1;
  1577. exports = module.exports = {};
  1578. const re = exports.re = [];
  1579. const safeRe = exports.safeRe = [];
  1580. const src = exports.src = [];
  1581. const t = exports.t = {};
  1582. let R = 0;
  1583. const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
  1584. const safeRegexReplacements = [
  1585. ['\\s', 1],
  1586. ['\\d', MAX_LENGTH],
  1587. [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
  1588. ];
  1589. const makeSafeRegex = (value) => {
  1590. for (const [token, max] of safeRegexReplacements) {
  1591. value = value
  1592. .split(`${token}*`).join(`${token}{0,${max}}`)
  1593. .split(`${token}+`).join(`${token}{1,${max}}`);
  1594. }
  1595. return value
  1596. };
  1597. const createToken = (name, value, isGlobal) => {
  1598. const safe = makeSafeRegex(value);
  1599. const index = R++;
  1600. debug(name, index, value);
  1601. t[name] = index;
  1602. src[index] = value;
  1603. re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
  1604. safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
  1605. };
  1606. createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
  1607. createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
  1608. createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
  1609. createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
  1610. `(${src[t.NUMERICIDENTIFIER]})\\.` +
  1611. `(${src[t.NUMERICIDENTIFIER]})`);
  1612. createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
  1613. `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
  1614. `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
  1615. createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
  1616. }|${src[t.NONNUMERICIDENTIFIER]})`);
  1617. createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
  1618. }|${src[t.NONNUMERICIDENTIFIER]})`);
  1619. createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
  1620. }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
  1621. createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
  1622. }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
  1623. createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
  1624. createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
  1625. }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
  1626. createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
  1627. }${src[t.PRERELEASE]}?${
  1628. src[t.BUILD]}?`);
  1629. createToken('FULL', `^${src[t.FULLPLAIN]}$`);
  1630. createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
  1631. }${src[t.PRERELEASELOOSE]}?${
  1632. src[t.BUILD]}?`);
  1633. createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
  1634. createToken('GTLT', '((?:<|>)?=?)');
  1635. createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
  1636. createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
  1637. createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
  1638. `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
  1639. `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
  1640. `(?:${src[t.PRERELEASE]})?${
  1641. src[t.BUILD]}?` +
  1642. `)?)?`);
  1643. createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  1644. `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  1645. `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  1646. `(?:${src[t.PRERELEASELOOSE]})?${
  1647. src[t.BUILD]}?` +
  1648. `)?)?`);
  1649. createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
  1650. createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
  1651. createToken('COERCEPLAIN', `${'(^|[^\\d])' +
  1652. '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
  1653. `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
  1654. `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
  1655. createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
  1656. createToken('COERCEFULL', src[t.COERCEPLAIN] +
  1657. `(?:${src[t.PRERELEASE]})?` +
  1658. `(?:${src[t.BUILD]})?` +
  1659. `(?:$|[^\\d])`);
  1660. createToken('COERCERTL', src[t.COERCE], true);
  1661. createToken('COERCERTLFULL', src[t.COERCEFULL], true);
  1662. createToken('LONETILDE', '(?:~>?)');
  1663. createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
  1664. exports.tildeTrimReplace = '$1~';
  1665. createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
  1666. createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
  1667. createToken('LONECARET', '(?:\\^)');
  1668. createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
  1669. exports.caretTrimReplace = '$1^';
  1670. createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
  1671. createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
  1672. createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
  1673. createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
  1674. createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
  1675. }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
  1676. exports.comparatorTrimReplace = '$1$2$3';
  1677. createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
  1678. `\\s+-\\s+` +
  1679. `(${src[t.XRANGEPLAIN]})` +
  1680. `\\s*$`);
  1681. createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
  1682. `\\s+-\\s+` +
  1683. `(${src[t.XRANGEPLAINLOOSE]})` +
  1684. `\\s*$`);
  1685. createToken('STAR', '(<|>)?=?\\s*\\*');
  1686. createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
  1687. createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
  1688. } (re$1, re$1.exports));
  1689. var reExports = re$1.exports;
  1690. const looseOption = Object.freeze({ loose: true });
  1691. const emptyOpts = Object.freeze({ });
  1692. const parseOptions$1 = options => {
  1693. if (!options) {
  1694. return emptyOpts
  1695. }
  1696. if (typeof options !== 'object') {
  1697. return looseOption
  1698. }
  1699. return options
  1700. };
  1701. var parseOptions_1 = parseOptions$1;
  1702. const numeric = /^[0-9]+$/;
  1703. const compareIdentifiers$1 = (a, b) => {
  1704. const anum = numeric.test(a);
  1705. const bnum = numeric.test(b);
  1706. if (anum && bnum) {
  1707. a = +a;
  1708. b = +b;
  1709. }
  1710. return a === b ? 0
  1711. : (anum && !bnum) ? -1
  1712. : (bnum && !anum) ? 1
  1713. : a < b ? -1
  1714. : 1
  1715. };
  1716. const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
  1717. var identifiers = {
  1718. compareIdentifiers: compareIdentifiers$1,
  1719. rcompareIdentifiers,
  1720. };
  1721. const debug = debug_1;
  1722. const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants$1;
  1723. const { safeRe: re, t } = reExports;
  1724. const parseOptions = parseOptions_1;
  1725. const { compareIdentifiers } = identifiers;
  1726. let SemVer$1 = class SemVer {
  1727. constructor (version, options) {
  1728. options = parseOptions(options);
  1729. if (version instanceof SemVer) {
  1730. if (version.loose === !!options.loose &&
  1731. version.includePrerelease === !!options.includePrerelease) {
  1732. return version
  1733. } else {
  1734. version = version.version;
  1735. }
  1736. } else if (typeof version !== 'string') {
  1737. throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
  1738. }
  1739. if (version.length > MAX_LENGTH) {
  1740. throw new TypeError(
  1741. `version is longer than ${MAX_LENGTH} characters`
  1742. )
  1743. }
  1744. debug('SemVer', version, options);
  1745. this.options = options;
  1746. this.loose = !!options.loose;
  1747. this.includePrerelease = !!options.includePrerelease;
  1748. const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  1749. if (!m) {
  1750. throw new TypeError(`Invalid Version: ${version}`)
  1751. }
  1752. this.raw = version;
  1753. this.major = +m[1];
  1754. this.minor = +m[2];
  1755. this.patch = +m[3];
  1756. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  1757. throw new TypeError('Invalid major version')
  1758. }
  1759. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  1760. throw new TypeError('Invalid minor version')
  1761. }
  1762. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  1763. throw new TypeError('Invalid patch version')
  1764. }
  1765. if (!m[4]) {
  1766. this.prerelease = [];
  1767. } else {
  1768. this.prerelease = m[4].split('.').map((id) => {
  1769. if (/^[0-9]+$/.test(id)) {
  1770. const num = +id;
  1771. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  1772. return num
  1773. }
  1774. }
  1775. return id
  1776. });
  1777. }
  1778. this.build = m[5] ? m[5].split('.') : [];
  1779. this.format();
  1780. }
  1781. format () {
  1782. this.version = `${this.major}.${this.minor}.${this.patch}`;
  1783. if (this.prerelease.length) {
  1784. this.version += `-${this.prerelease.join('.')}`;
  1785. }
  1786. return this.version
  1787. }
  1788. toString () {
  1789. return this.version
  1790. }
  1791. compare (other) {
  1792. debug('SemVer.compare', this.version, this.options, other);
  1793. if (!(other instanceof SemVer)) {
  1794. if (typeof other === 'string' && other === this.version) {
  1795. return 0
  1796. }
  1797. other = new SemVer(other, this.options);
  1798. }
  1799. if (other.version === this.version) {
  1800. return 0
  1801. }
  1802. return this.compareMain(other) || this.comparePre(other)
  1803. }
  1804. compareMain (other) {
  1805. if (!(other instanceof SemVer)) {
  1806. other = new SemVer(other, this.options);
  1807. }
  1808. return (
  1809. compareIdentifiers(this.major, other.major) ||
  1810. compareIdentifiers(this.minor, other.minor) ||
  1811. compareIdentifiers(this.patch, other.patch)
  1812. )
  1813. }
  1814. comparePre (other) {
  1815. if (!(other instanceof SemVer)) {
  1816. other = new SemVer(other, this.options);
  1817. }
  1818. if (this.prerelease.length && !other.prerelease.length) {
  1819. return -1
  1820. } else if (!this.prerelease.length && other.prerelease.length) {
  1821. return 1
  1822. } else if (!this.prerelease.length && !other.prerelease.length) {
  1823. return 0
  1824. }
  1825. let i = 0;
  1826. do {
  1827. const a = this.prerelease[i];
  1828. const b = other.prerelease[i];
  1829. debug('prerelease compare', i, a, b);
  1830. if (a === undefined && b === undefined) {
  1831. return 0
  1832. } else if (b === undefined) {
  1833. return 1
  1834. } else if (a === undefined) {
  1835. return -1
  1836. } else if (a === b) {
  1837. continue
  1838. } else {
  1839. return compareIdentifiers(a, b)
  1840. }
  1841. } while (++i)
  1842. }
  1843. compareBuild (other) {
  1844. if (!(other instanceof SemVer)) {
  1845. other = new SemVer(other, this.options);
  1846. }
  1847. let i = 0;
  1848. do {
  1849. const a = this.build[i];
  1850. const b = other.build[i];
  1851. debug('prerelease compare', i, a, b);
  1852. if (a === undefined && b === undefined) {
  1853. return 0
  1854. } else if (b === undefined) {
  1855. return 1
  1856. } else if (a === undefined) {
  1857. return -1
  1858. } else if (a === b) {
  1859. continue
  1860. } else {
  1861. return compareIdentifiers(a, b)
  1862. }
  1863. } while (++i)
  1864. }
  1865. inc (release, identifier, identifierBase) {
  1866. switch (release) {
  1867. case 'premajor':
  1868. this.prerelease.length = 0;
  1869. this.patch = 0;
  1870. this.minor = 0;
  1871. this.major++;
  1872. this.inc('pre', identifier, identifierBase);
  1873. break
  1874. case 'preminor':
  1875. this.prerelease.length = 0;
  1876. this.patch = 0;
  1877. this.minor++;
  1878. this.inc('pre', identifier, identifierBase);
  1879. break
  1880. case 'prepatch':
  1881. this.prerelease.length = 0;
  1882. this.inc('patch', identifier, identifierBase);
  1883. this.inc('pre', identifier, identifierBase);
  1884. break
  1885. case 'prerelease':
  1886. if (this.prerelease.length === 0) {
  1887. this.inc('patch', identifier, identifierBase);
  1888. }
  1889. this.inc('pre', identifier, identifierBase);
  1890. break
  1891. case 'major':
  1892. if (
  1893. this.minor !== 0 ||
  1894. this.patch !== 0 ||
  1895. this.prerelease.length === 0
  1896. ) {
  1897. this.major++;
  1898. }
  1899. this.minor = 0;
  1900. this.patch = 0;
  1901. this.prerelease = [];
  1902. break
  1903. case 'minor':
  1904. if (this.patch !== 0 || this.prerelease.length === 0) {
  1905. this.minor++;
  1906. }
  1907. this.patch = 0;
  1908. this.prerelease = [];
  1909. break
  1910. case 'patch':
  1911. if (this.prerelease.length === 0) {
  1912. this.patch++;
  1913. }
  1914. this.prerelease = [];
  1915. break
  1916. case 'pre': {
  1917. const base = Number(identifierBase) ? 1 : 0;
  1918. if (!identifier && identifierBase === false) {
  1919. throw new Error('invalid increment argument: identifier is empty')
  1920. }
  1921. if (this.prerelease.length === 0) {
  1922. this.prerelease = [base];
  1923. } else {
  1924. let i = this.prerelease.length;
  1925. while (--i >= 0) {
  1926. if (typeof this.prerelease[i] === 'number') {
  1927. this.prerelease[i]++;
  1928. i = -2;
  1929. }
  1930. }
  1931. if (i === -1) {
  1932. if (identifier === this.prerelease.join('.') && identifierBase === false) {
  1933. throw new Error('invalid increment argument: identifier already exists')
  1934. }
  1935. this.prerelease.push(base);
  1936. }
  1937. }
  1938. if (identifier) {
  1939. let prerelease = [identifier, base];
  1940. if (identifierBase === false) {
  1941. prerelease = [identifier];
  1942. }
  1943. if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
  1944. if (isNaN(this.prerelease[1])) {
  1945. this.prerelease = prerelease;
  1946. }
  1947. } else {
  1948. this.prerelease = prerelease;
  1949. }
  1950. }
  1951. break
  1952. }
  1953. default:
  1954. throw new Error(`invalid increment argument: ${release}`)
  1955. }
  1956. this.raw = this.format();
  1957. if (this.build.length) {
  1958. this.raw += `+${this.build.join('.')}`;
  1959. }
  1960. return this
  1961. }
  1962. };
  1963. var semver = SemVer$1;
  1964. const SemVer = semver;
  1965. const parse$6 = (version, options, throwErrors = false) => {
  1966. if (version instanceof SemVer) {
  1967. return version
  1968. }
  1969. try {
  1970. return new SemVer(version, options)
  1971. } catch (er) {
  1972. if (!throwErrors) {
  1973. return null
  1974. }
  1975. throw er
  1976. }
  1977. };
  1978. var parse_1 = parse$6;
  1979. const parse$5 = parse_1;
  1980. const valid$1 = (version, options) => {
  1981. const v = parse$5(version, options);
  1982. return v ? v.version : null
  1983. };
  1984. var valid_1 = valid$1;
  1985. const parse$4 = parse_1;
  1986. const clean = (version, options) => {
  1987. const s = parse$4(version.trim().replace(/^[=v]+/, ''), options);
  1988. return s ? s.version : null
  1989. };
  1990. var clean_1 = clean;
  1991. const require$$1$3 = [
  1992. "0BSD",
  1993. "AAL",
  1994. "ADSL",
  1995. "AFL-1.1",
  1996. "AFL-1.2",
  1997. "AFL-2.0",
  1998. "AFL-2.1",
  1999. "AFL-3.0",
  2000. "AGPL-1.0-only",
  2001. "AGPL-1.0-or-later",
  2002. "AGPL-3.0-only",
  2003. "AGPL-3.0-or-later",
  2004. "AMDPLPA",
  2005. "AML",
  2006. "AMPAS",
  2007. "ANTLR-PD",
  2008. "ANTLR-PD-fallback",
  2009. "APAFML",
  2010. "APL-1.0",
  2011. "APSL-1.0",
  2012. "APSL-1.1",
  2013. "APSL-1.2",
  2014. "APSL-2.0",
  2015. "ASWF-Digital-Assets-1.0",
  2016. "ASWF-Digital-Assets-1.1",
  2017. "Abstyles",
  2018. "AdaCore-doc",
  2019. "Adobe-2006",
  2020. "Adobe-Glyph",
  2021. "Adobe-Utopia",
  2022. "Afmparse",
  2023. "Aladdin",
  2024. "Apache-1.0",
  2025. "Apache-1.1",
  2026. "Apache-2.0",
  2027. "App-s2p",
  2028. "Arphic-1999",
  2029. "Artistic-1.0",
  2030. "Artistic-1.0-Perl",
  2031. "Artistic-1.0-cl8",
  2032. "Artistic-2.0",
  2033. "BSD-1-Clause",
  2034. "BSD-2-Clause",
  2035. "BSD-2-Clause-Patent",
  2036. "BSD-2-Clause-Views",
  2037. "BSD-3-Clause",
  2038. "BSD-3-Clause-Attribution",
  2039. "BSD-3-Clause-Clear",
  2040. "BSD-3-Clause-HP",
  2041. "BSD-3-Clause-LBNL",
  2042. "BSD-3-Clause-Modification",
  2043. "BSD-3-Clause-No-Military-License",
  2044. "BSD-3-Clause-No-Nuclear-License",
  2045. "BSD-3-Clause-No-Nuclear-License-2014",
  2046. "BSD-3-Clause-No-Nuclear-Warranty",
  2047. "BSD-3-Clause-Open-MPI",
  2048. "BSD-3-Clause-Sun",
  2049. "BSD-3-Clause-flex",
  2050. "BSD-4-Clause",
  2051. "BSD-4-Clause-Shortened",
  2052. "BSD-4-Clause-UC",
  2053. "BSD-4.3RENO",
  2054. "BSD-4.3TAHOE",
  2055. "BSD-Advertising-Acknowledgement",
  2056. "BSD-Attribution-HPND-disclaimer",
  2057. "BSD-Inferno-Nettverk",
  2058. "BSD-Protection",
  2059. "BSD-Source-Code",
  2060. "BSD-Systemics",
  2061. "BSL-1.0",
  2062. "BUSL-1.1",
  2063. "Baekmuk",
  2064. "Bahyph",
  2065. "Barr",
  2066. "Beerware",
  2067. "BitTorrent-1.0",
  2068. "BitTorrent-1.1",
  2069. "Bitstream-Charter",
  2070. "Bitstream-Vera",
  2071. "BlueOak-1.0.0",
  2072. "Boehm-GC",
  2073. "Borceux",
  2074. "Brian-Gladman-3-Clause",
  2075. "C-UDA-1.0",
  2076. "CAL-1.0",
  2077. "CAL-1.0-Combined-Work-Exception",
  2078. "CATOSL-1.1",
  2079. "CC-BY-1.0",
  2080. "CC-BY-2.0",
  2081. "CC-BY-2.5",
  2082. "CC-BY-2.5-AU",
  2083. "CC-BY-3.0",
  2084. "CC-BY-3.0-AT",
  2085. "CC-BY-3.0-DE",
  2086. "CC-BY-3.0-IGO",
  2087. "CC-BY-3.0-NL",
  2088. "CC-BY-3.0-US",
  2089. "CC-BY-4.0",
  2090. "CC-BY-NC-1.0",
  2091. "CC-BY-NC-2.0",
  2092. "CC-BY-NC-2.5",
  2093. "CC-BY-NC-3.0",
  2094. "CC-BY-NC-3.0-DE",
  2095. "CC-BY-NC-4.0",
  2096. "CC-BY-NC-ND-1.0",
  2097. "CC-BY-NC-ND-2.0",
  2098. "CC-BY-NC-ND-2.5",
  2099. "CC-BY-NC-ND-3.0",
  2100. "CC-BY-NC-ND-3.0-DE",
  2101. "CC-BY-NC-ND-3.0-IGO",
  2102. "CC-BY-NC-ND-4.0",
  2103. "CC-BY-NC-SA-1.0",
  2104. "CC-BY-NC-SA-2.0",
  2105. "CC-BY-NC-SA-2.0-DE",
  2106. "CC-BY-NC-SA-2.0-FR",
  2107. "CC-BY-NC-SA-2.0-UK",
  2108. "CC-BY-NC-SA-2.5",
  2109. "CC-BY-NC-SA-3.0",
  2110. "CC-BY-NC-SA-3.0-DE",
  2111. "CC-BY-NC-SA-3.0-IGO",
  2112. "CC-BY-NC-SA-4.0",
  2113. "CC-BY-ND-1.0",
  2114. "CC-BY-ND-2.0",
  2115. "CC-BY-ND-2.5",
  2116. "CC-BY-ND-3.0",
  2117. "CC-BY-ND-3.0-DE",
  2118. "CC-BY-ND-4.0",
  2119. "CC-BY-SA-1.0",
  2120. "CC-BY-SA-2.0",
  2121. "CC-BY-SA-2.0-UK",
  2122. "CC-BY-SA-2.1-JP",
  2123. "CC-BY-SA-2.5",
  2124. "CC-BY-SA-3.0",
  2125. "CC-BY-SA-3.0-AT",
  2126. "CC-BY-SA-3.0-DE",
  2127. "CC-BY-SA-3.0-IGO",
  2128. "CC-BY-SA-4.0",
  2129. "CC-PDDC",
  2130. "CC0-1.0",
  2131. "CDDL-1.0",
  2132. "CDDL-1.1",
  2133. "CDL-1.0",
  2134. "CDLA-Permissive-1.0",
  2135. "CDLA-Permissive-2.0",
  2136. "CDLA-Sharing-1.0",
  2137. "CECILL-1.0",
  2138. "CECILL-1.1",
  2139. "CECILL-2.0",
  2140. "CECILL-2.1",
  2141. "CECILL-B",
  2142. "CECILL-C",
  2143. "CERN-OHL-1.1",
  2144. "CERN-OHL-1.2",
  2145. "CERN-OHL-P-2.0",
  2146. "CERN-OHL-S-2.0",
  2147. "CERN-OHL-W-2.0",
  2148. "CFITSIO",
  2149. "CMU-Mach",
  2150. "CNRI-Jython",
  2151. "CNRI-Python",
  2152. "CNRI-Python-GPL-Compatible",
  2153. "COIL-1.0",
  2154. "CPAL-1.0",
  2155. "CPL-1.0",
  2156. "CPOL-1.02",
  2157. "CUA-OPL-1.0",
  2158. "Caldera",
  2159. "ClArtistic",
  2160. "Clips",
  2161. "Community-Spec-1.0",
  2162. "Condor-1.1",
  2163. "Cornell-Lossless-JPEG",
  2164. "Cronyx",
  2165. "Crossword",
  2166. "CrystalStacker",
  2167. "Cube",
  2168. "D-FSL-1.0",
  2169. "DL-DE-BY-2.0",
  2170. "DL-DE-ZERO-2.0",
  2171. "DOC",
  2172. "DRL-1.0",
  2173. "DSDP",
  2174. "Dotseqn",
  2175. "ECL-1.0",
  2176. "ECL-2.0",
  2177. "EFL-1.0",
  2178. "EFL-2.0",
  2179. "EPICS",
  2180. "EPL-1.0",
  2181. "EPL-2.0",
  2182. "EUDatagrid",
  2183. "EUPL-1.0",
  2184. "EUPL-1.1",
  2185. "EUPL-1.2",
  2186. "Elastic-2.0",
  2187. "Entessa",
  2188. "ErlPL-1.1",
  2189. "Eurosym",
  2190. "FBM",
  2191. "FDK-AAC",
  2192. "FSFAP",
  2193. "FSFUL",
  2194. "FSFULLR",
  2195. "FSFULLRWD",
  2196. "FTL",
  2197. "Fair",
  2198. "Ferguson-Twofish",
  2199. "Frameworx-1.0",
  2200. "FreeBSD-DOC",
  2201. "FreeImage",
  2202. "Furuseth",
  2203. "GD",
  2204. "GFDL-1.1-invariants-only",
  2205. "GFDL-1.1-invariants-or-later",
  2206. "GFDL-1.1-no-invariants-only",
  2207. "GFDL-1.1-no-invariants-or-later",
  2208. "GFDL-1.1-only",
  2209. "GFDL-1.1-or-later",
  2210. "GFDL-1.2-invariants-only",
  2211. "GFDL-1.2-invariants-or-later",
  2212. "GFDL-1.2-no-invariants-only",
  2213. "GFDL-1.2-no-invariants-or-later",
  2214. "GFDL-1.2-only",
  2215. "GFDL-1.2-or-later",
  2216. "GFDL-1.3-invariants-only",
  2217. "GFDL-1.3-invariants-or-later",
  2218. "GFDL-1.3-no-invariants-only",
  2219. "GFDL-1.3-no-invariants-or-later",
  2220. "GFDL-1.3-only",
  2221. "GFDL-1.3-or-later",
  2222. "GL2PS",
  2223. "GLWTPL",
  2224. "GPL-1.0-only",
  2225. "GPL-1.0-or-later",
  2226. "GPL-2.0-only",
  2227. "GPL-2.0-or-later",
  2228. "GPL-3.0-only",
  2229. "GPL-3.0-or-later",
  2230. "Giftware",
  2231. "Glide",
  2232. "Glulxe",
  2233. "Graphics-Gems",
  2234. "HP-1986",
  2235. "HP-1989",
  2236. "HPND",
  2237. "HPND-DEC",
  2238. "HPND-Markus-Kuhn",
  2239. "HPND-Pbmplus",
  2240. "HPND-UC",
  2241. "HPND-doc",
  2242. "HPND-doc-sell",
  2243. "HPND-export-US",
  2244. "HPND-export-US-modify",
  2245. "HPND-sell-regexpr",
  2246. "HPND-sell-variant",
  2247. "HPND-sell-variant-MIT-disclaimer",
  2248. "HTMLTIDY",
  2249. "HaskellReport",
  2250. "Hippocratic-2.1",
  2251. "IBM-pibs",
  2252. "ICU",
  2253. "IEC-Code-Components-EULA",
  2254. "IJG",
  2255. "IJG-short",
  2256. "IPA",
  2257. "IPL-1.0",
  2258. "ISC",
  2259. "ImageMagick",
  2260. "Imlib2",
  2261. "Info-ZIP",
  2262. "Inner-Net-2.0",
  2263. "Intel",
  2264. "Intel-ACPI",
  2265. "Interbase-1.0",
  2266. "JPL-image",
  2267. "JPNIC",
  2268. "JSON",
  2269. "Jam",
  2270. "JasPer-2.0",
  2271. "Kastrup",
  2272. "Kazlib",
  2273. "Knuth-CTAN",
  2274. "LAL-1.2",
  2275. "LAL-1.3",
  2276. "LGPL-2.0-only",
  2277. "LGPL-2.0-or-later",
  2278. "LGPL-2.1-only",
  2279. "LGPL-2.1-or-later",
  2280. "LGPL-3.0-only",
  2281. "LGPL-3.0-or-later",
  2282. "LGPLLR",
  2283. "LOOP",
  2284. "LPL-1.0",
  2285. "LPL-1.02",
  2286. "LPPL-1.0",
  2287. "LPPL-1.1",
  2288. "LPPL-1.2",
  2289. "LPPL-1.3a",
  2290. "LPPL-1.3c",
  2291. "LZMA-SDK-9.11-to-9.20",
  2292. "LZMA-SDK-9.22",
  2293. "Latex2e",
  2294. "Latex2e-translated-notice",
  2295. "Leptonica",
  2296. "LiLiQ-P-1.1",
  2297. "LiLiQ-R-1.1",
  2298. "LiLiQ-Rplus-1.1",
  2299. "Libpng",
  2300. "Linux-OpenIB",
  2301. "Linux-man-pages-1-para",
  2302. "Linux-man-pages-copyleft",
  2303. "Linux-man-pages-copyleft-2-para",
  2304. "Linux-man-pages-copyleft-var",
  2305. "Lucida-Bitmap-Fonts",
  2306. "MIT",
  2307. "MIT-0",
  2308. "MIT-CMU",
  2309. "MIT-Festival",
  2310. "MIT-Modern-Variant",
  2311. "MIT-Wu",
  2312. "MIT-advertising",
  2313. "MIT-enna",
  2314. "MIT-feh",
  2315. "MIT-open-group",
  2316. "MIT-testregex",
  2317. "MITNFA",
  2318. "MMIXware",
  2319. "MPEG-SSG",
  2320. "MPL-1.0",
  2321. "MPL-1.1",
  2322. "MPL-2.0",
  2323. "MPL-2.0-no-copyleft-exception",
  2324. "MS-LPL",
  2325. "MS-PL",
  2326. "MS-RL",
  2327. "MTLL",
  2328. "MakeIndex",
  2329. "Martin-Birgmeier",
  2330. "McPhee-slideshow",
  2331. "Minpack",
  2332. "MirOS",
  2333. "Motosoto",
  2334. "MulanPSL-1.0",
  2335. "MulanPSL-2.0",
  2336. "Multics",
  2337. "Mup",
  2338. "NAIST-2003",
  2339. "NASA-1.3",
  2340. "NBPL-1.0",
  2341. "NCGL-UK-2.0",
  2342. "NCSA",
  2343. "NGPL",
  2344. "NICTA-1.0",
  2345. "NIST-PD",
  2346. "NIST-PD-fallback",
  2347. "NIST-Software",
  2348. "NLOD-1.0",
  2349. "NLOD-2.0",
  2350. "NLPL",
  2351. "NOSL",
  2352. "NPL-1.0",
  2353. "NPL-1.1",
  2354. "NPOSL-3.0",
  2355. "NRL",
  2356. "NTP",
  2357. "NTP-0",
  2358. "Naumen",
  2359. "Net-SNMP",
  2360. "NetCDF",
  2361. "Newsletr",
  2362. "Nokia",
  2363. "Noweb",
  2364. "O-UDA-1.0",
  2365. "OCCT-PL",
  2366. "OCLC-2.0",
  2367. "ODC-By-1.0",
  2368. "ODbL-1.0",
  2369. "OFFIS",
  2370. "OFL-1.0",
  2371. "OFL-1.0-RFN",
  2372. "OFL-1.0-no-RFN",
  2373. "OFL-1.1",
  2374. "OFL-1.1-RFN",
  2375. "OFL-1.1-no-RFN",
  2376. "OGC-1.0",
  2377. "OGDL-Taiwan-1.0",
  2378. "OGL-Canada-2.0",
  2379. "OGL-UK-1.0",
  2380. "OGL-UK-2.0",
  2381. "OGL-UK-3.0",
  2382. "OGTSL",
  2383. "OLDAP-1.1",
  2384. "OLDAP-1.2",
  2385. "OLDAP-1.3",
  2386. "OLDAP-1.4",
  2387. "OLDAP-2.0",
  2388. "OLDAP-2.0.1",
  2389. "OLDAP-2.1",
  2390. "OLDAP-2.2",
  2391. "OLDAP-2.2.1",
  2392. "OLDAP-2.2.2",
  2393. "OLDAP-2.3",
  2394. "OLDAP-2.4",
  2395. "OLDAP-2.5",
  2396. "OLDAP-2.6",
  2397. "OLDAP-2.7",
  2398. "OLDAP-2.8",
  2399. "OLFL-1.3",
  2400. "OML",
  2401. "OPL-1.0",
  2402. "OPL-UK-3.0",
  2403. "OPUBL-1.0",
  2404. "OSET-PL-2.1",
  2405. "OSL-1.0",
  2406. "OSL-1.1",
  2407. "OSL-2.0",
  2408. "OSL-2.1",
  2409. "OSL-3.0",
  2410. "OpenPBS-2.3",
  2411. "OpenSSL",
  2412. "PADL",
  2413. "PDDL-1.0",
  2414. "PHP-3.0",
  2415. "PHP-3.01",
  2416. "PSF-2.0",
  2417. "Parity-6.0.0",
  2418. "Parity-7.0.0",
  2419. "Plexus",
  2420. "PolyForm-Noncommercial-1.0.0",
  2421. "PolyForm-Small-Business-1.0.0",
  2422. "PostgreSQL",
  2423. "Python-2.0",
  2424. "Python-2.0.1",
  2425. "QPL-1.0",
  2426. "QPL-1.0-INRIA-2004",
  2427. "Qhull",
  2428. "RHeCos-1.1",
  2429. "RPL-1.1",
  2430. "RPL-1.5",
  2431. "RPSL-1.0",
  2432. "RSA-MD",
  2433. "RSCPL",
  2434. "Rdisc",
  2435. "Ruby",
  2436. "SAX-PD",
  2437. "SCEA",
  2438. "SGI-B-1.0",
  2439. "SGI-B-1.1",
  2440. "SGI-B-2.0",
  2441. "SGI-OpenGL",
  2442. "SGP4",
  2443. "SHL-0.5",
  2444. "SHL-0.51",
  2445. "SISSL",
  2446. "SISSL-1.2",
  2447. "SL",
  2448. "SMLNJ",
  2449. "SMPPL",
  2450. "SNIA",
  2451. "SPL-1.0",
  2452. "SSH-OpenSSH",
  2453. "SSH-short",
  2454. "SSPL-1.0",
  2455. "SWL",
  2456. "Saxpath",
  2457. "SchemeReport",
  2458. "Sendmail",
  2459. "Sendmail-8.23",
  2460. "SimPL-2.0",
  2461. "Sleepycat",
  2462. "Soundex",
  2463. "Spencer-86",
  2464. "Spencer-94",
  2465. "Spencer-99",
  2466. "SugarCRM-1.1.3",
  2467. "SunPro",
  2468. "Symlinks",
  2469. "TAPR-OHL-1.0",
  2470. "TCL",
  2471. "TCP-wrappers",
  2472. "TMate",
  2473. "TORQUE-1.1",
  2474. "TOSL",
  2475. "TPDL",
  2476. "TPL-1.0",
  2477. "TTWL",
  2478. "TTYP0",
  2479. "TU-Berlin-1.0",
  2480. "TU-Berlin-2.0",
  2481. "TermReadKey",
  2482. "UCAR",
  2483. "UCL-1.0",
  2484. "UPL-1.0",
  2485. "URT-RLE",
  2486. "Unicode-DFS-2015",
  2487. "Unicode-DFS-2016",
  2488. "Unicode-TOU",
  2489. "UnixCrypt",
  2490. "Unlicense",
  2491. "VOSTROM",
  2492. "VSL-1.0",
  2493. "Vim",
  2494. "W3C",
  2495. "W3C-19980720",
  2496. "W3C-20150513",
  2497. "WTFPL",
  2498. "Watcom-1.0",
  2499. "Widget-Workshop",
  2500. "Wsuipa",
  2501. "X11",
  2502. "X11-distribute-modifications-variant",
  2503. "XFree86-1.1",
  2504. "XSkat",
  2505. "Xdebug-1.03",
  2506. "Xerox",
  2507. "Xfig",
  2508. "Xnet",
  2509. "YPL-1.0",
  2510. "YPL-1.1",
  2511. "ZPL-1.1",
  2512. "ZPL-2.0",
  2513. "ZPL-2.1",
  2514. "Zed",
  2515. "Zeeff",
  2516. "Zend-2.0",
  2517. "Zimbra-1.3",
  2518. "Zimbra-1.4",
  2519. "Zlib",
  2520. "blessing",
  2521. "bzip2-1.0.6",
  2522. "check-cvs",
  2523. "checkmk",
  2524. "copyleft-next-0.3.0",
  2525. "copyleft-next-0.3.1",
  2526. "curl",
  2527. "diffmark",
  2528. "dtoa",
  2529. "dvipdfm",
  2530. "eGenix",
  2531. "etalab-2.0",
  2532. "fwlw",
  2533. "gSOAP-1.3b",
  2534. "gnuplot",
  2535. "iMatix",
  2536. "libpng-2.0",
  2537. "libselinux-1.0",
  2538. "libtiff",
  2539. "libutil-David-Nugent",
  2540. "lsof",
  2541. "magaz",
  2542. "metamail",
  2543. "mpi-permissive",
  2544. "mpich2",
  2545. "mplus",
  2546. "pnmstitch",
  2547. "psfrag",
  2548. "psutils",
  2549. "python-ldap",
  2550. "snprintf",
  2551. "ssh-keyscan",
  2552. "swrule",
  2553. "ulem",
  2554. "w3m",
  2555. "xinetd",
  2556. "xlock",
  2557. "xpp",
  2558. "zlib-acknowledgement"
  2559. ];
  2560. const require$$1$2 = [
  2561. "AGPL-1.0",
  2562. "AGPL-3.0",
  2563. "BSD-2-Clause-FreeBSD",
  2564. "BSD-2-Clause-NetBSD",
  2565. "GFDL-1.1",
  2566. "GFDL-1.2",
  2567. "GFDL-1.3",
  2568. "GPL-1.0",
  2569. "GPL-1.0+",
  2570. "GPL-2.0",
  2571. "GPL-2.0+",
  2572. "GPL-2.0-with-GCC-exception",
  2573. "GPL-2.0-with-autoconf-exception",
  2574. "GPL-2.0-with-bison-exception",
  2575. "GPL-2.0-with-classpath-exception",
  2576. "GPL-2.0-with-font-exception",
  2577. "GPL-3.0",
  2578. "GPL-3.0+",
  2579. "GPL-3.0-with-GCC-exception",
  2580. "GPL-3.0-with-autoconf-exception",
  2581. "LGPL-2.0",
  2582. "LGPL-2.0+",
  2583. "LGPL-2.1",
  2584. "LGPL-2.1+",
  2585. "LGPL-3.0",
  2586. "LGPL-3.0+",
  2587. "Nunit",
  2588. "StandardML-NJ",
  2589. "bzip2-1.0.5",
  2590. "eCos-2.0",
  2591. "wxWindows"
  2592. ];
  2593. const require$$2 = [
  2594. "389-exception",
  2595. "Asterisk-exception",
  2596. "Autoconf-exception-2.0",
  2597. "Autoconf-exception-3.0",
  2598. "Autoconf-exception-generic",
  2599. "Autoconf-exception-generic-3.0",
  2600. "Autoconf-exception-macro",
  2601. "Bison-exception-2.2",
  2602. "Bootloader-exception",
  2603. "Classpath-exception-2.0",
  2604. "CLISP-exception-2.0",
  2605. "cryptsetup-OpenSSL-exception",
  2606. "DigiRule-FOSS-exception",
  2607. "eCos-exception-2.0",
  2608. "Fawkes-Runtime-exception",
  2609. "FLTK-exception",
  2610. "Font-exception-2.0",
  2611. "freertos-exception-2.0",
  2612. "GCC-exception-2.0",
  2613. "GCC-exception-2.0-note",
  2614. "GCC-exception-3.1",
  2615. "GNAT-exception",
  2616. "GNU-compiler-exception",
  2617. "gnu-javamail-exception",
  2618. "GPL-3.0-interface-exception",
  2619. "GPL-3.0-linking-exception",
  2620. "GPL-3.0-linking-source-exception",
  2621. "GPL-CC-1.0",
  2622. "GStreamer-exception-2005",
  2623. "GStreamer-exception-2008",
  2624. "i2p-gpl-java-exception",
  2625. "KiCad-libraries-exception",
  2626. "LGPL-3.0-linking-exception",
  2627. "libpri-OpenH323-exception",
  2628. "Libtool-exception",
  2629. "Linux-syscall-note",
  2630. "LLGPL",
  2631. "LLVM-exception",
  2632. "LZMA-exception",
  2633. "mif-exception",
  2634. "OCaml-LGPL-linking-exception",
  2635. "OCCT-exception-1.0",
  2636. "OpenJDK-assembly-exception-1.0",
  2637. "openvpn-openssl-exception",
  2638. "PS-or-PDF-font-exception-20170817",
  2639. "QPL-1.0-INRIA-2004-exception",
  2640. "Qt-GPL-exception-1.0",
  2641. "Qt-LGPL-exception-1.1",
  2642. "Qwt-exception-1.0",
  2643. "SANE-exception",
  2644. "SHL-2.0",
  2645. "SHL-2.1",
  2646. "stunnel-exception",
  2647. "SWI-exception",
  2648. "Swift-exception",
  2649. "Texinfo-exception",
  2650. "u-boot-exception-2.0",
  2651. "UBDL-exception",
  2652. "Universal-FOSS-exception-1.0",
  2653. "vsftpd-openssl-exception",
  2654. "WxWindows-exception-3.1",
  2655. "x11vnc-openssl-exception"
  2656. ];
  2657. var licenses = []
  2658. .concat(require$$1$3)
  2659. .concat(require$$1$2);
  2660. var exceptions = require$$2;
  2661. var scan$1 = function (source) {
  2662. var index = 0;
  2663. function hasMore () {
  2664. return index < source.length
  2665. }
  2666. function read (value) {
  2667. if (value instanceof RegExp) {
  2668. var chars = source.slice(index);
  2669. var match = chars.match(value);
  2670. if (match) {
  2671. index += match[0].length;
  2672. return match[0]
  2673. }
  2674. } else {
  2675. if (source.indexOf(value, index) === index) {
  2676. index += value.length;
  2677. return value
  2678. }
  2679. }
  2680. }
  2681. function skipWhitespace () {
  2682. read(/[ ]*/);
  2683. }
  2684. function operator () {
  2685. var string;
  2686. var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+'];
  2687. for (var i = 0; i < possibilities.length; i++) {
  2688. string = read(possibilities[i]);
  2689. if (string) {
  2690. break
  2691. }
  2692. }
  2693. if (string === '+' && index > 1 && source[index - 2] === ' ') {
  2694. throw new Error('Space before `+`')
  2695. }
  2696. return string && {
  2697. type: 'OPERATOR',
  2698. string: string
  2699. }
  2700. }
  2701. function idstring () {
  2702. return read(/[A-Za-z0-9-.]+/)
  2703. }
  2704. function expectIdstring () {
  2705. var string = idstring();
  2706. if (!string) {
  2707. throw new Error('Expected idstring at offset ' + index)
  2708. }
  2709. return string
  2710. }
  2711. function documentRef () {
  2712. if (read('DocumentRef-')) {
  2713. var string = expectIdstring();
  2714. return { type: 'DOCUMENTREF', string: string }
  2715. }
  2716. }
  2717. function licenseRef () {
  2718. if (read('LicenseRef-')) {
  2719. var string = expectIdstring();
  2720. return { type: 'LICENSEREF', string: string }
  2721. }
  2722. }
  2723. function identifier () {
  2724. var begin = index;
  2725. var string = idstring();
  2726. if (licenses.indexOf(string) !== -1) {
  2727. return {
  2728. type: 'LICENSE',
  2729. string: string
  2730. }
  2731. } else if (exceptions.indexOf(string) !== -1) {
  2732. return {
  2733. type: 'EXCEPTION',
  2734. string: string
  2735. }
  2736. }
  2737. index = begin;
  2738. }
  2739. function parseToken () {
  2740. return (
  2741. operator() ||
  2742. documentRef() ||
  2743. licenseRef() ||
  2744. identifier()
  2745. )
  2746. }
  2747. var tokens = [];
  2748. while (hasMore()) {
  2749. skipWhitespace();
  2750. if (!hasMore()) {
  2751. break
  2752. }
  2753. var token = parseToken();
  2754. if (!token) {
  2755. throw new Error('Unexpected `' + source[index] +
  2756. '` at offset ' + index)
  2757. }
  2758. tokens.push(token);
  2759. }
  2760. return tokens
  2761. };
  2762. var parse$3 = function (tokens) {
  2763. var index = 0;
  2764. function hasMore () {
  2765. return index < tokens.length
  2766. }
  2767. function token () {
  2768. return hasMore() ? tokens[index] : null
  2769. }
  2770. function next () {
  2771. if (!hasMore()) {
  2772. throw new Error()
  2773. }
  2774. index++;
  2775. }
  2776. function parseOperator (operator) {
  2777. var t = token();
  2778. if (t && t.type === 'OPERATOR' && operator === t.string) {
  2779. next();
  2780. return t.string
  2781. }
  2782. }
  2783. function parseWith () {
  2784. if (parseOperator('WITH')) {
  2785. var t = token();
  2786. if (t && t.type === 'EXCEPTION') {
  2787. next();
  2788. return t.string
  2789. }
  2790. throw new Error('Expected exception after `WITH`')
  2791. }
  2792. }
  2793. function parseLicenseRef () {
  2794. var begin = index;
  2795. var string = '';
  2796. var t = token();
  2797. if (t.type === 'DOCUMENTREF') {
  2798. next();
  2799. string += 'DocumentRef-' + t.string + ':';
  2800. if (!parseOperator(':')) {
  2801. throw new Error('Expected `:` after `DocumentRef-...`')
  2802. }
  2803. }
  2804. t = token();
  2805. if (t.type === 'LICENSEREF') {
  2806. next();
  2807. string += 'LicenseRef-' + t.string;
  2808. return { license: string }
  2809. }
  2810. index = begin;
  2811. }
  2812. function parseLicense () {
  2813. var t = token();
  2814. if (t && t.type === 'LICENSE') {
  2815. next();
  2816. var node = { license: t.string };
  2817. if (parseOperator('+')) {
  2818. node.plus = true;
  2819. }
  2820. var exception = parseWith();
  2821. if (exception) {
  2822. node.exception = exception;
  2823. }
  2824. return node
  2825. }
  2826. }
  2827. function parseParenthesizedExpression () {
  2828. var left = parseOperator('(');
  2829. if (!left) {
  2830. return
  2831. }
  2832. var expr = parseExpression();
  2833. if (!parseOperator(')')) {
  2834. throw new Error('Expected `)`')
  2835. }
  2836. return expr
  2837. }
  2838. function parseAtom () {
  2839. return (
  2840. parseParenthesizedExpression() ||
  2841. parseLicenseRef() ||
  2842. parseLicense()
  2843. )
  2844. }
  2845. function makeBinaryOpParser (operator, nextParser) {
  2846. return function parseBinaryOp () {
  2847. var left = nextParser();
  2848. if (!left) {
  2849. return
  2850. }
  2851. if (!parseOperator(operator)) {
  2852. return left
  2853. }
  2854. var right = parseBinaryOp();
  2855. if (!right) {
  2856. throw new Error('Expected expression')
  2857. }
  2858. return {
  2859. left: left,
  2860. conjunction: operator.toLowerCase(),
  2861. right: right
  2862. }
  2863. }
  2864. }
  2865. var parseAnd = makeBinaryOpParser('AND', parseAtom);
  2866. var parseExpression = makeBinaryOpParser('OR', parseAnd);
  2867. var node = parseExpression();
  2868. if (!node || hasMore()) {
  2869. throw new Error('Syntax error')
  2870. }
  2871. return node
  2872. };
  2873. var scan = scan$1;
  2874. var parse$2 = parse$3;
  2875. var spdxExpressionParse = function (source) {
  2876. return parse$2(scan(source))
  2877. };
  2878. var parse$1 = spdxExpressionParse;
  2879. var spdxLicenseIds = require$$1$3;
  2880. function valid (string) {
  2881. try {
  2882. parse$1(string);
  2883. return true
  2884. } catch (error) {
  2885. return false
  2886. }
  2887. }
  2888. function sortTranspositions(a, b) {
  2889. var length = b[0].length - a[0].length;
  2890. if (length !== 0) return length
  2891. return a[0].toUpperCase().localeCompare(b[0].toUpperCase())
  2892. }
  2893. var transpositions = [
  2894. ['APGL', 'AGPL'],
  2895. ['Gpl', 'GPL'],
  2896. ['GLP', 'GPL'],
  2897. ['APL', 'Apache'],
  2898. ['ISD', 'ISC'],
  2899. ['GLP', 'GPL'],
  2900. ['IST', 'ISC'],
  2901. ['Claude', 'Clause'],
  2902. [' or later', '+'],
  2903. [' International', ''],
  2904. ['GNU', 'GPL'],
  2905. ['GUN', 'GPL'],
  2906. ['+', ''],
  2907. ['GNU GPL', 'GPL'],
  2908. ['GNU LGPL', 'LGPL'],
  2909. ['GNU/GPL', 'GPL'],
  2910. ['GNU GLP', 'GPL'],
  2911. ['GNU LESSER GENERAL PUBLIC LICENSE', 'LGPL'],
  2912. ['GNU Lesser General Public License', 'LGPL'],
  2913. ['GNU LESSER GENERAL PUBLIC LICENSE', 'LGPL-2.1'],
  2914. ['GNU Lesser General Public License', 'LGPL-2.1'],
  2915. ['LESSER GENERAL PUBLIC LICENSE', 'LGPL'],
  2916. ['Lesser General Public License', 'LGPL'],
  2917. ['LESSER GENERAL PUBLIC LICENSE', 'LGPL-2.1'],
  2918. ['Lesser General Public License', 'LGPL-2.1'],
  2919. ['GNU General Public License', 'GPL'],
  2920. ['Gnu public license', 'GPL'],
  2921. ['GNU Public License', 'GPL'],
  2922. ['GNU GENERAL PUBLIC LICENSE', 'GPL'],
  2923. ['MTI', 'MIT'],
  2924. ['Mozilla Public License', 'MPL'],
  2925. ['Universal Permissive License', 'UPL'],
  2926. ['WTH', 'WTF'],
  2927. ['WTFGPL', 'WTFPL'],
  2928. ['-License', '']
  2929. ].sort(sortTranspositions);
  2930. var TRANSPOSED = 0;
  2931. var CORRECT = 1;
  2932. var transforms = [
  2933. function (argument) {
  2934. return argument.toUpperCase()
  2935. },
  2936. function (argument) {
  2937. return argument.trim()
  2938. },
  2939. function (argument) {
  2940. return argument.replace(/\./g, '')
  2941. },
  2942. function (argument) {
  2943. return argument.replace(/\s+/g, '')
  2944. },
  2945. function (argument) {
  2946. return argument.replace(/\s+/g, '-')
  2947. },
  2948. function (argument) {
  2949. return argument.replace('v', '-')
  2950. },
  2951. function (argument) {
  2952. return argument.replace(/,?\s*(\d)/, '-$1')
  2953. },
  2954. function (argument) {
  2955. return argument.replace(/,?\s*(\d)/, '-$1.0')
  2956. },
  2957. function (argument) {
  2958. return argument
  2959. .replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2')
  2960. },
  2961. function (argument) {
  2962. return argument
  2963. .replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2.0')
  2964. },
  2965. function (argument) {
  2966. return argument[0].toUpperCase() + argument.slice(1)
  2967. },
  2968. function (argument) {
  2969. return argument.replace('/', '-')
  2970. },
  2971. function (argument) {
  2972. return argument
  2973. .replace(/\s*V\s*(\d)/, '-$1')
  2974. .replace(/(\d)$/, '$1.0')
  2975. },
  2976. function (argument) {
  2977. if (argument.indexOf('3.0') !== -1) {
  2978. return argument + '-or-later'
  2979. } else {
  2980. return argument + '-only'
  2981. }
  2982. },
  2983. function (argument) {
  2984. return argument + 'only'
  2985. },
  2986. function (argument) {
  2987. return argument.replace(/(\d)$/, '-$1.0')
  2988. },
  2989. function (argument) {
  2990. return argument.replace(/(-| )?(\d)$/, '-$2-Clause')
  2991. },
  2992. function (argument) {
  2993. return argument.replace(/(-| )clause(-| )(\d)/, '-$3-Clause')
  2994. },
  2995. function (argument) {
  2996. return argument.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i, 'BSD-3-Clause')
  2997. },
  2998. function (argument) {
  2999. return argument.replace(/\bSimplified(-| )?BSD((-| )License)?/i, 'BSD-2-Clause')
  3000. },
  3001. function (argument) {
  3002. return argument.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i, 'BSD-2-Clause-$1BSD')
  3003. },
  3004. function (argument) {
  3005. return argument.replace(/\bClear(-| )?BSD((-| )License)?/i, 'BSD-3-Clause-Clear')
  3006. },
  3007. function (argument) {
  3008. return argument.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i, 'BSD-4-Clause')
  3009. },
  3010. function (argument) {
  3011. return 'CC-' + argument
  3012. },
  3013. function (argument) {
  3014. return 'CC-' + argument + '-4.0'
  3015. },
  3016. function (argument) {
  3017. return argument
  3018. .replace('Attribution', 'BY')
  3019. .replace('NonCommercial', 'NC')
  3020. .replace('NoDerivatives', 'ND')
  3021. .replace(/ (\d)/, '-$1')
  3022. .replace(/ ?International/, '')
  3023. },
  3024. function (argument) {
  3025. return 'CC-' +
  3026. argument
  3027. .replace('Attribution', 'BY')
  3028. .replace('NonCommercial', 'NC')
  3029. .replace('NoDerivatives', 'ND')
  3030. .replace(/ (\d)/, '-$1')
  3031. .replace(/ ?International/, '') +
  3032. '-4.0'
  3033. }
  3034. ];
  3035. var licensesWithVersions = spdxLicenseIds
  3036. .map(function (id) {
  3037. var match = /^(.*)-\d+\.\d+$/.exec(id);
  3038. return match
  3039. ? [match[0], match[1]]
  3040. : [id, null]
  3041. })
  3042. .reduce(function (objectMap, item) {
  3043. var key = item[1];
  3044. objectMap[key] = objectMap[key] || [];
  3045. objectMap[key].push(item[0]);
  3046. return objectMap
  3047. }, {});
  3048. var licensesWithOneVersion = Object.keys(licensesWithVersions)
  3049. .map(function makeEntries (key) {
  3050. return [key, licensesWithVersions[key]]
  3051. })
  3052. .filter(function identifySoleVersions (item) {
  3053. return (
  3054. item[1].length === 1 &&
  3055. item[0] !== null &&
  3056. item[0] !== 'APL'
  3057. )
  3058. })
  3059. .map(function createLastResorts (item) {
  3060. return [item[0], item[1][0]]
  3061. });
  3062. licensesWithVersions = undefined;
  3063. var lastResorts = [
  3064. ['UNLI', 'Unlicense'],
  3065. ['WTF', 'WTFPL'],
  3066. ['2 CLAUSE', 'BSD-2-Clause'],
  3067. ['2-CLAUSE', 'BSD-2-Clause'],
  3068. ['3 CLAUSE', 'BSD-3-Clause'],
  3069. ['3-CLAUSE', 'BSD-3-Clause'],
  3070. ['AFFERO', 'AGPL-3.0-or-later'],
  3071. ['AGPL', 'AGPL-3.0-or-later'],
  3072. ['APACHE', 'Apache-2.0'],
  3073. ['ARTISTIC', 'Artistic-2.0'],
  3074. ['Affero', 'AGPL-3.0-or-later'],
  3075. ['BEER', 'Beerware'],
  3076. ['BOOST', 'BSL-1.0'],
  3077. ['BSD', 'BSD-2-Clause'],
  3078. ['CDDL', 'CDDL-1.1'],
  3079. ['ECLIPSE', 'EPL-1.0'],
  3080. ['FUCK', 'WTFPL'],
  3081. ['GNU', 'GPL-3.0-or-later'],
  3082. ['LGPL', 'LGPL-3.0-or-later'],
  3083. ['GPLV1', 'GPL-1.0-only'],
  3084. ['GPL-1', 'GPL-1.0-only'],
  3085. ['GPLV2', 'GPL-2.0-only'],
  3086. ['GPL-2', 'GPL-2.0-only'],
  3087. ['GPL', 'GPL-3.0-or-later'],
  3088. ['MIT +NO-FALSE-ATTRIBS', 'MITNFA'],
  3089. ['MIT', 'MIT'],
  3090. ['MPL', 'MPL-2.0'],
  3091. ['X11', 'X11'],
  3092. ['ZLIB', 'Zlib']
  3093. ].concat(licensesWithOneVersion).sort(sortTranspositions);
  3094. var SUBSTRING = 0;
  3095. var IDENTIFIER = 1;
  3096. var validTransformation = function (identifier) {
  3097. for (var i = 0; i < transforms.length; i++) {
  3098. var transformed = transforms[i](identifier).trim();
  3099. if (transformed !== identifier && valid(transformed)) {
  3100. return transformed
  3101. }
  3102. }
  3103. return null
  3104. };
  3105. var validLastResort = function (identifier) {
  3106. var upperCased = identifier.toUpperCase();
  3107. for (var i = 0; i < lastResorts.length; i++) {
  3108. var lastResort = lastResorts[i];
  3109. if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
  3110. return lastResort[IDENTIFIER]
  3111. }
  3112. }
  3113. return null
  3114. };
  3115. var anyCorrection = function (identifier, check) {
  3116. for (var i = 0; i < transpositions.length; i++) {
  3117. var transposition = transpositions[i];
  3118. var transposed = transposition[TRANSPOSED];
  3119. if (identifier.indexOf(transposed) > -1) {
  3120. var corrected = identifier.replace(
  3121. transposed,
  3122. transposition[CORRECT]
  3123. );
  3124. var checked = check(corrected);
  3125. if (checked !== null) {
  3126. return checked
  3127. }
  3128. }
  3129. }
  3130. return null
  3131. };
  3132. var spdxCorrect = function (identifier, options) {
  3133. options = options || {};
  3134. var upgrade = options.upgrade === undefined ? true : !!options.upgrade;
  3135. function postprocess (value) {
  3136. return upgrade ? upgradeGPLs(value) : value
  3137. }
  3138. var validArugment = (
  3139. typeof identifier === 'string' &&
  3140. identifier.trim().length !== 0
  3141. );
  3142. if (!validArugment) {
  3143. throw Error('Invalid argument. Expected non-empty string.')
  3144. }
  3145. identifier = identifier.trim();
  3146. if (valid(identifier)) {
  3147. return postprocess(identifier)
  3148. }
  3149. var noPlus = identifier.replace(/\+$/, '').trim();
  3150. if (valid(noPlus)) {
  3151. return postprocess(noPlus)
  3152. }
  3153. var transformed = validTransformation(identifier);
  3154. if (transformed !== null) {
  3155. return postprocess(transformed)
  3156. }
  3157. transformed = anyCorrection(identifier, function (argument) {
  3158. if (valid(argument)) {
  3159. return argument
  3160. }
  3161. return validTransformation(argument)
  3162. });
  3163. if (transformed !== null) {
  3164. return postprocess(transformed)
  3165. }
  3166. transformed = validLastResort(identifier);
  3167. if (transformed !== null) {
  3168. return postprocess(transformed)
  3169. }
  3170. transformed = anyCorrection(identifier, validLastResort);
  3171. if (transformed !== null) {
  3172. return postprocess(transformed)
  3173. }
  3174. return null
  3175. };
  3176. function upgradeGPLs (value) {
  3177. if ([
  3178. 'GPL-1.0', 'LGPL-1.0', 'AGPL-1.0',
  3179. 'GPL-2.0', 'LGPL-2.0', 'AGPL-2.0',
  3180. 'LGPL-2.1'
  3181. ].indexOf(value) !== -1) {
  3182. return value + '-only'
  3183. } else if ([
  3184. 'GPL-1.0+', 'GPL-2.0+', 'GPL-3.0+',
  3185. 'LGPL-2.0+', 'LGPL-2.1+', 'LGPL-3.0+',
  3186. 'AGPL-1.0+', 'AGPL-3.0+'
  3187. ].indexOf(value) !== -1) {
  3188. return value.replace(/\+$/, '-or-later')
  3189. } else if (['GPL-3.0', 'LGPL-3.0', 'AGPL-3.0'].indexOf(value) !== -1) {
  3190. return value + '-or-later'
  3191. } else {
  3192. return value
  3193. }
  3194. }
  3195. var parse = spdxExpressionParse;
  3196. var correct = spdxCorrect;
  3197. var genericWarning = (
  3198. 'license should be ' +
  3199. 'a valid SPDX license expression (without "LicenseRef"), ' +
  3200. '"UNLICENSED", or ' +
  3201. '"SEE LICENSE IN <filename>"'
  3202. );
  3203. var fileReferenceRE = /^SEE LICEN[CS]E IN (.+)$/;
  3204. function startsWith(prefix, string) {
  3205. return string.slice(0, prefix.length) === prefix;
  3206. }
  3207. function usesLicenseRef(ast) {
  3208. if (ast.hasOwnProperty('license')) {
  3209. var license = ast.license;
  3210. return (
  3211. startsWith('LicenseRef', license) ||
  3212. startsWith('DocumentRef', license)
  3213. );
  3214. } else {
  3215. return (
  3216. usesLicenseRef(ast.left) ||
  3217. usesLicenseRef(ast.right)
  3218. );
  3219. }
  3220. }
  3221. var validateNpmPackageLicense = function(argument) {
  3222. var ast;
  3223. try {
  3224. ast = parse(argument);
  3225. } catch (e) {
  3226. var match;
  3227. if (
  3228. argument === 'UNLICENSED' ||
  3229. argument === 'UNLICENCED'
  3230. ) {
  3231. return {
  3232. validForOldPackages: true,
  3233. validForNewPackages: true,
  3234. unlicensed: true
  3235. };
  3236. } else if (match = fileReferenceRE.exec(argument)) {
  3237. return {
  3238. validForOldPackages: true,
  3239. validForNewPackages: true,
  3240. inFile: match[1]
  3241. };
  3242. } else {
  3243. var result = {
  3244. validForOldPackages: false,
  3245. validForNewPackages: false,
  3246. warnings: [genericWarning]
  3247. };
  3248. if (argument.trim().length !== 0) {
  3249. var corrected = correct(argument);
  3250. if (corrected) {
  3251. result.warnings.push(
  3252. 'license is similar to the valid expression "' + corrected + '"'
  3253. );
  3254. }
  3255. }
  3256. return result;
  3257. }
  3258. }
  3259. if (usesLicenseRef(ast)) {
  3260. return {
  3261. validForNewPackages: false,
  3262. validForOldPackages: false,
  3263. spdx: true,
  3264. warnings: [genericWarning]
  3265. };
  3266. } else {
  3267. return {
  3268. validForNewPackages: true,
  3269. validForOldPackages: true,
  3270. spdx: true
  3271. };
  3272. }
  3273. };
  3274. var commonjs = {};
  3275. Object.defineProperty(commonjs, "__esModule", { value: true });
  3276. commonjs.LRUCache = void 0;
  3277. const perf = typeof performance === 'object' &&
  3278. performance &&
  3279. typeof performance.now === 'function'
  3280. ? performance
  3281. : Date;
  3282. const warned = new Set();
  3283. const PROCESS = (typeof process === 'object' && !!process ? process : {});
  3284. const emitWarning = (msg, type, code, fn) => {
  3285. typeof PROCESS.emitWarning === 'function'
  3286. ? PROCESS.emitWarning(msg, type, code, fn)
  3287. : console.error(`[${code}] ${type}: ${msg}`);
  3288. };
  3289. let AC = globalThis.AbortController;
  3290. let AS = globalThis.AbortSignal;
  3291. if (typeof AC === 'undefined') {
  3292. AS = class AbortSignal {
  3293. onabort;
  3294. _onabort = [];
  3295. reason;
  3296. aborted = false;
  3297. addEventListener(_, fn) {
  3298. this._onabort.push(fn);
  3299. }
  3300. };
  3301. AC = class AbortController {
  3302. constructor() {
  3303. warnACPolyfill();
  3304. }
  3305. signal = new AS();
  3306. abort(reason) {
  3307. if (this.signal.aborted)
  3308. return;
  3309. this.signal.reason = reason;
  3310. this.signal.aborted = true;
  3311. for (const fn of this.signal._onabort) {
  3312. fn(reason);
  3313. }
  3314. this.signal.onabort?.(reason);
  3315. }
  3316. };
  3317. let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
  3318. const warnACPolyfill = () => {
  3319. if (!printACPolyfillWarning)
  3320. return;
  3321. printACPolyfillWarning = false;
  3322. emitWarning('AbortController is not defined. If using lru-cache in ' +
  3323. 'node 14, load an AbortController polyfill from the ' +
  3324. '`node-abort-controller` package. A minimal polyfill is ' +
  3325. 'provided for use by LRUCache.fetch(), but it should not be ' +
  3326. 'relied upon in other contexts (eg, passing it to other APIs that ' +
  3327. 'use AbortController/AbortSignal might have undesirable effects). ' +
  3328. 'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
  3329. };
  3330. }
  3331. const shouldWarn = (code) => !warned.has(code);
  3332. const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
  3333. const getUintArray = (max) => !isPosInt(max)
  3334. ? null
  3335. : max <= Math.pow(2, 8)
  3336. ? Uint8Array
  3337. : max <= Math.pow(2, 16)
  3338. ? Uint16Array
  3339. : max <= Math.pow(2, 32)
  3340. ? Uint32Array
  3341. : max <= Number.MAX_SAFE_INTEGER
  3342. ? ZeroArray
  3343. : null;
  3344. class ZeroArray extends Array {
  3345. constructor(size) {
  3346. super(size);
  3347. this.fill(0);
  3348. }
  3349. }
  3350. class Stack {
  3351. heap;
  3352. length;
  3353. static #constructing = false;
  3354. static create(max) {
  3355. const HeapCls = getUintArray(max);
  3356. if (!HeapCls)
  3357. return [];
  3358. Stack.#constructing = true;
  3359. const s = new Stack(max, HeapCls);
  3360. Stack.#constructing = false;
  3361. return s;
  3362. }
  3363. constructor(max, HeapCls) {
  3364. if (!Stack.#constructing) {
  3365. throw new TypeError('instantiate Stack using Stack.create(n)');
  3366. }
  3367. this.heap = new HeapCls(max);
  3368. this.length = 0;
  3369. }
  3370. push(n) {
  3371. this.heap[this.length++] = n;
  3372. }
  3373. pop() {
  3374. return this.heap[--this.length];
  3375. }
  3376. }
  3377. let LRUCache$1 = class LRUCache {
  3378. #max;
  3379. #maxSize;
  3380. #dispose;
  3381. #disposeAfter;
  3382. #fetchMethod;
  3383. ttl;
  3384. ttlResolution;
  3385. ttlAutopurge;
  3386. updateAgeOnGet;
  3387. updateAgeOnHas;
  3388. allowStale;
  3389. noDisposeOnSet;
  3390. noUpdateTTL;
  3391. maxEntrySize;
  3392. sizeCalculation;
  3393. noDeleteOnFetchRejection;
  3394. noDeleteOnStaleGet;
  3395. allowStaleOnFetchAbort;
  3396. allowStaleOnFetchRejection;
  3397. ignoreFetchAbort;
  3398. #size;
  3399. #calculatedSize;
  3400. #keyMap;
  3401. #keyList;
  3402. #valList;
  3403. #next;
  3404. #prev;
  3405. #head;
  3406. #tail;
  3407. #free;
  3408. #disposed;
  3409. #sizes;
  3410. #starts;
  3411. #ttls;
  3412. #hasDispose;
  3413. #hasFetchMethod;
  3414. #hasDisposeAfter;
  3415. static unsafeExposeInternals(c) {
  3416. return {
  3417. starts: c.#starts,
  3418. ttls: c.#ttls,
  3419. sizes: c.#sizes,
  3420. keyMap: c.#keyMap,
  3421. keyList: c.#keyList,
  3422. valList: c.#valList,
  3423. next: c.#next,
  3424. prev: c.#prev,
  3425. get head() {
  3426. return c.#head;
  3427. },
  3428. get tail() {
  3429. return c.#tail;
  3430. },
  3431. free: c.#free,
  3432. isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
  3433. backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
  3434. moveToTail: (index) => c.#moveToTail(index),
  3435. indexes: (options) => c.#indexes(options),
  3436. rindexes: (options) => c.#rindexes(options),
  3437. isStale: (index) => c.#isStale(index),
  3438. };
  3439. }
  3440. get max() {
  3441. return this.#max;
  3442. }
  3443. get maxSize() {
  3444. return this.#maxSize;
  3445. }
  3446. get calculatedSize() {
  3447. return this.#calculatedSize;
  3448. }
  3449. get size() {
  3450. return this.#size;
  3451. }
  3452. get fetchMethod() {
  3453. return this.#fetchMethod;
  3454. }
  3455. get dispose() {
  3456. return this.#dispose;
  3457. }
  3458. get disposeAfter() {
  3459. return this.#disposeAfter;
  3460. }
  3461. constructor(options) {
  3462. const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
  3463. if (max !== 0 && !isPosInt(max)) {
  3464. throw new TypeError('max option must be a nonnegative integer');
  3465. }
  3466. const UintArray = max ? getUintArray(max) : Array;
  3467. if (!UintArray) {
  3468. throw new Error('invalid max value: ' + max);
  3469. }
  3470. this.#max = max;
  3471. this.#maxSize = maxSize;
  3472. this.maxEntrySize = maxEntrySize || this.#maxSize;
  3473. this.sizeCalculation = sizeCalculation;
  3474. if (this.sizeCalculation) {
  3475. if (!this.#maxSize && !this.maxEntrySize) {
  3476. throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
  3477. }
  3478. if (typeof this.sizeCalculation !== 'function') {
  3479. throw new TypeError('sizeCalculation set to non-function');
  3480. }
  3481. }
  3482. if (fetchMethod !== undefined &&
  3483. typeof fetchMethod !== 'function') {
  3484. throw new TypeError('fetchMethod must be a function if specified');
  3485. }
  3486. this.#fetchMethod = fetchMethod;
  3487. this.#hasFetchMethod = !!fetchMethod;
  3488. this.#keyMap = new Map();
  3489. this.#keyList = new Array(max).fill(undefined);
  3490. this.#valList = new Array(max).fill(undefined);
  3491. this.#next = new UintArray(max);
  3492. this.#prev = new UintArray(max);
  3493. this.#head = 0;
  3494. this.#tail = 0;
  3495. this.#free = Stack.create(max);
  3496. this.#size = 0;
  3497. this.#calculatedSize = 0;
  3498. if (typeof dispose === 'function') {
  3499. this.#dispose = dispose;
  3500. }
  3501. if (typeof disposeAfter === 'function') {
  3502. this.#disposeAfter = disposeAfter;
  3503. this.#disposed = [];
  3504. }
  3505. else {
  3506. this.#disposeAfter = undefined;
  3507. this.#disposed = undefined;
  3508. }
  3509. this.#hasDispose = !!this.#dispose;
  3510. this.#hasDisposeAfter = !!this.#disposeAfter;
  3511. this.noDisposeOnSet = !!noDisposeOnSet;
  3512. this.noUpdateTTL = !!noUpdateTTL;
  3513. this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
  3514. this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
  3515. this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
  3516. this.ignoreFetchAbort = !!ignoreFetchAbort;
  3517. if (this.maxEntrySize !== 0) {
  3518. if (this.#maxSize !== 0) {
  3519. if (!isPosInt(this.#maxSize)) {
  3520. throw new TypeError('maxSize must be a positive integer if specified');
  3521. }
  3522. }
  3523. if (!isPosInt(this.maxEntrySize)) {
  3524. throw new TypeError('maxEntrySize must be a positive integer if specified');
  3525. }
  3526. this.#initializeSizeTracking();
  3527. }
  3528. this.allowStale = !!allowStale;
  3529. this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
  3530. this.updateAgeOnGet = !!updateAgeOnGet;
  3531. this.updateAgeOnHas = !!updateAgeOnHas;
  3532. this.ttlResolution =
  3533. isPosInt(ttlResolution) || ttlResolution === 0
  3534. ? ttlResolution
  3535. : 1;
  3536. this.ttlAutopurge = !!ttlAutopurge;
  3537. this.ttl = ttl || 0;
  3538. if (this.ttl) {
  3539. if (!isPosInt(this.ttl)) {
  3540. throw new TypeError('ttl must be a positive integer if specified');
  3541. }
  3542. this.#initializeTTLTracking();
  3543. }
  3544. if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
  3545. throw new TypeError('At least one of max, maxSize, or ttl is required');
  3546. }
  3547. if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
  3548. const code = 'LRU_CACHE_UNBOUNDED';
  3549. if (shouldWarn(code)) {
  3550. warned.add(code);
  3551. const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
  3552. 'result in unbounded memory consumption.';
  3553. emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
  3554. }
  3555. }
  3556. }
  3557. getRemainingTTL(key) {
  3558. return this.#keyMap.has(key) ? Infinity : 0;
  3559. }
  3560. #initializeTTLTracking() {
  3561. const ttls = new ZeroArray(this.#max);
  3562. const starts = new ZeroArray(this.#max);
  3563. this.#ttls = ttls;
  3564. this.#starts = starts;
  3565. this.#setItemTTL = (index, ttl, start = perf.now()) => {
  3566. starts[index] = ttl !== 0 ? start : 0;
  3567. ttls[index] = ttl;
  3568. if (ttl !== 0 && this.ttlAutopurge) {
  3569. const t = setTimeout(() => {
  3570. if (this.#isStale(index)) {
  3571. this.delete(this.#keyList[index]);
  3572. }
  3573. }, ttl + 1);
  3574. if (t.unref) {
  3575. t.unref();
  3576. }
  3577. }
  3578. };
  3579. this.#updateItemAge = index => {
  3580. starts[index] = ttls[index] !== 0 ? perf.now() : 0;
  3581. };
  3582. this.#statusTTL = (status, index) => {
  3583. if (ttls[index]) {
  3584. const ttl = ttls[index];
  3585. const start = starts[index];
  3586. if (!ttl || !start)
  3587. return;
  3588. status.ttl = ttl;
  3589. status.start = start;
  3590. status.now = cachedNow || getNow();
  3591. const age = status.now - start;
  3592. status.remainingTTL = ttl - age;
  3593. }
  3594. };
  3595. let cachedNow = 0;
  3596. const getNow = () => {
  3597. const n = perf.now();
  3598. if (this.ttlResolution > 0) {
  3599. cachedNow = n;
  3600. const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
  3601. if (t.unref) {
  3602. t.unref();
  3603. }
  3604. }
  3605. return n;
  3606. };
  3607. this.getRemainingTTL = key => {
  3608. const index = this.#keyMap.get(key);
  3609. if (index === undefined) {
  3610. return 0;
  3611. }
  3612. const ttl = ttls[index];
  3613. const start = starts[index];
  3614. if (!ttl || !start) {
  3615. return Infinity;
  3616. }
  3617. const age = (cachedNow || getNow()) - start;
  3618. return ttl - age;
  3619. };
  3620. this.#isStale = index => {
  3621. const s = starts[index];
  3622. const t = ttls[index];
  3623. return !!t && !!s && (cachedNow || getNow()) - s > t;
  3624. };
  3625. }
  3626. #updateItemAge = () => { };
  3627. #statusTTL = () => { };
  3628. #setItemTTL = () => { };
  3629. #isStale = () => false;
  3630. #initializeSizeTracking() {
  3631. const sizes = new ZeroArray(this.#max);
  3632. this.#calculatedSize = 0;
  3633. this.#sizes = sizes;
  3634. this.#removeItemSize = index => {
  3635. this.#calculatedSize -= sizes[index];
  3636. sizes[index] = 0;
  3637. };
  3638. this.#requireSize = (k, v, size, sizeCalculation) => {
  3639. if (this.#isBackgroundFetch(v)) {
  3640. return 0;
  3641. }
  3642. if (!isPosInt(size)) {
  3643. if (sizeCalculation) {
  3644. if (typeof sizeCalculation !== 'function') {
  3645. throw new TypeError('sizeCalculation must be a function');
  3646. }
  3647. size = sizeCalculation(v, k);
  3648. if (!isPosInt(size)) {
  3649. throw new TypeError('sizeCalculation return invalid (expect positive integer)');
  3650. }
  3651. }
  3652. else {
  3653. throw new TypeError('invalid size value (must be positive integer). ' +
  3654. 'When maxSize or maxEntrySize is used, sizeCalculation ' +
  3655. 'or size must be set.');
  3656. }
  3657. }
  3658. return size;
  3659. };
  3660. this.#addItemSize = (index, size, status) => {
  3661. sizes[index] = size;
  3662. if (this.#maxSize) {
  3663. const maxSize = this.#maxSize - sizes[index];
  3664. while (this.#calculatedSize > maxSize) {
  3665. this.#evict(true);
  3666. }
  3667. }
  3668. this.#calculatedSize += sizes[index];
  3669. if (status) {
  3670. status.entrySize = size;
  3671. status.totalCalculatedSize = this.#calculatedSize;
  3672. }
  3673. };
  3674. }
  3675. #removeItemSize = _i => { };
  3676. #addItemSize = (_i, _s, _st) => { };
  3677. #requireSize = (_k, _v, size, sizeCalculation) => {
  3678. if (size || sizeCalculation) {
  3679. throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
  3680. }
  3681. return 0;
  3682. };
  3683. *#indexes({ allowStale = this.allowStale } = {}) {
  3684. if (this.#size) {
  3685. for (let i = this.#tail; true;) {
  3686. if (!this.#isValidIndex(i)) {
  3687. break;
  3688. }
  3689. if (allowStale || !this.#isStale(i)) {
  3690. yield i;
  3691. }
  3692. if (i === this.#head) {
  3693. break;
  3694. }
  3695. else {
  3696. i = this.#prev[i];
  3697. }
  3698. }
  3699. }
  3700. }
  3701. *#rindexes({ allowStale = this.allowStale } = {}) {
  3702. if (this.#size) {
  3703. for (let i = this.#head; true;) {
  3704. if (!this.#isValidIndex(i)) {
  3705. break;
  3706. }
  3707. if (allowStale || !this.#isStale(i)) {
  3708. yield i;
  3709. }
  3710. if (i === this.#tail) {
  3711. break;
  3712. }
  3713. else {
  3714. i = this.#next[i];
  3715. }
  3716. }
  3717. }
  3718. }
  3719. #isValidIndex(index) {
  3720. return (index !== undefined &&
  3721. this.#keyMap.get(this.#keyList[index]) === index);
  3722. }
  3723. *entries() {
  3724. for (const i of this.#indexes()) {
  3725. if (this.#valList[i] !== undefined &&
  3726. this.#keyList[i] !== undefined &&
  3727. !this.#isBackgroundFetch(this.#valList[i])) {
  3728. yield [this.#keyList[i], this.#valList[i]];
  3729. }
  3730. }
  3731. }
  3732. *rentries() {
  3733. for (const i of this.#rindexes()) {
  3734. if (this.#valList[i] !== undefined &&
  3735. this.#keyList[i] !== undefined &&
  3736. !this.#isBackgroundFetch(this.#valList[i])) {
  3737. yield [this.#keyList[i], this.#valList[i]];
  3738. }
  3739. }
  3740. }
  3741. *keys() {
  3742. for (const i of this.#indexes()) {
  3743. const k = this.#keyList[i];
  3744. if (k !== undefined &&
  3745. !this.#isBackgroundFetch(this.#valList[i])) {
  3746. yield k;
  3747. }
  3748. }
  3749. }
  3750. *rkeys() {
  3751. for (const i of this.#rindexes()) {
  3752. const k = this.#keyList[i];
  3753. if (k !== undefined &&
  3754. !this.#isBackgroundFetch(this.#valList[i])) {
  3755. yield k;
  3756. }
  3757. }
  3758. }
  3759. *values() {
  3760. for (const i of this.#indexes()) {
  3761. const v = this.#valList[i];
  3762. if (v !== undefined &&
  3763. !this.#isBackgroundFetch(this.#valList[i])) {
  3764. yield this.#valList[i];
  3765. }
  3766. }
  3767. }
  3768. *rvalues() {
  3769. for (const i of this.#rindexes()) {
  3770. const v = this.#valList[i];
  3771. if (v !== undefined &&
  3772. !this.#isBackgroundFetch(this.#valList[i])) {
  3773. yield this.#valList[i];
  3774. }
  3775. }
  3776. }
  3777. [Symbol.iterator]() {
  3778. return this.entries();
  3779. }
  3780. [Symbol.toStringTag] = 'LRUCache';
  3781. find(fn, getOptions = {}) {
  3782. for (const i of this.#indexes()) {
  3783. const v = this.#valList[i];
  3784. const value = this.#isBackgroundFetch(v)
  3785. ? v.__staleWhileFetching
  3786. : v;
  3787. if (value === undefined)
  3788. continue;
  3789. if (fn(value, this.#keyList[i], this)) {
  3790. return this.get(this.#keyList[i], getOptions);
  3791. }
  3792. }
  3793. }
  3794. forEach(fn, thisp = this) {
  3795. for (const i of this.#indexes()) {
  3796. const v = this.#valList[i];
  3797. const value = this.#isBackgroundFetch(v)
  3798. ? v.__staleWhileFetching
  3799. : v;
  3800. if (value === undefined)
  3801. continue;
  3802. fn.call(thisp, value, this.#keyList[i], this);
  3803. }
  3804. }
  3805. rforEach(fn, thisp = this) {
  3806. for (const i of this.#rindexes()) {
  3807. const v = this.#valList[i];
  3808. const value = this.#isBackgroundFetch(v)
  3809. ? v.__staleWhileFetching
  3810. : v;
  3811. if (value === undefined)
  3812. continue;
  3813. fn.call(thisp, value, this.#keyList[i], this);
  3814. }
  3815. }
  3816. purgeStale() {
  3817. let deleted = false;
  3818. for (const i of this.#rindexes({ allowStale: true })) {
  3819. if (this.#isStale(i)) {
  3820. this.delete(this.#keyList[i]);
  3821. deleted = true;
  3822. }
  3823. }
  3824. return deleted;
  3825. }
  3826. info(key) {
  3827. const i = this.#keyMap.get(key);
  3828. if (i === undefined)
  3829. return undefined;
  3830. const v = this.#valList[i];
  3831. const value = this.#isBackgroundFetch(v)
  3832. ? v.__staleWhileFetching
  3833. : v;
  3834. if (value === undefined)
  3835. return undefined;
  3836. const entry = { value };
  3837. if (this.#ttls && this.#starts) {
  3838. const ttl = this.#ttls[i];
  3839. const start = this.#starts[i];
  3840. if (ttl && start) {
  3841. const remain = ttl - (perf.now() - start);
  3842. entry.ttl = remain;
  3843. entry.start = Date.now();
  3844. }
  3845. }
  3846. if (this.#sizes) {
  3847. entry.size = this.#sizes[i];
  3848. }
  3849. return entry;
  3850. }
  3851. dump() {
  3852. const arr = [];
  3853. for (const i of this.#indexes({ allowStale: true })) {
  3854. const key = this.#keyList[i];
  3855. const v = this.#valList[i];
  3856. const value = this.#isBackgroundFetch(v)
  3857. ? v.__staleWhileFetching
  3858. : v;
  3859. if (value === undefined || key === undefined)
  3860. continue;
  3861. const entry = { value };
  3862. if (this.#ttls && this.#starts) {
  3863. entry.ttl = this.#ttls[i];
  3864. const age = perf.now() - this.#starts[i];
  3865. entry.start = Math.floor(Date.now() - age);
  3866. }
  3867. if (this.#sizes) {
  3868. entry.size = this.#sizes[i];
  3869. }
  3870. arr.unshift([key, entry]);
  3871. }
  3872. return arr;
  3873. }
  3874. load(arr) {
  3875. this.clear();
  3876. for (const [key, entry] of arr) {
  3877. if (entry.start) {
  3878. const age = Date.now() - entry.start;
  3879. entry.start = perf.now() - age;
  3880. }
  3881. this.set(key, entry.value, entry);
  3882. }
  3883. }
  3884. set(k, v, setOptions = {}) {
  3885. if (v === undefined) {
  3886. this.delete(k);
  3887. return this;
  3888. }
  3889. const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
  3890. let { noUpdateTTL = this.noUpdateTTL } = setOptions;
  3891. const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
  3892. if (this.maxEntrySize && size > this.maxEntrySize) {
  3893. if (status) {
  3894. status.set = 'miss';
  3895. status.maxEntrySizeExceeded = true;
  3896. }
  3897. this.delete(k);
  3898. return this;
  3899. }
  3900. let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
  3901. if (index === undefined) {
  3902. index = (this.#size === 0
  3903. ? this.#tail
  3904. : this.#free.length !== 0
  3905. ? this.#free.pop()
  3906. : this.#size === this.#max
  3907. ? this.#evict(false)
  3908. : this.#size);
  3909. this.#keyList[index] = k;
  3910. this.#valList[index] = v;
  3911. this.#keyMap.set(k, index);
  3912. this.#next[this.#tail] = index;
  3913. this.#prev[index] = this.#tail;
  3914. this.#tail = index;
  3915. this.#size++;
  3916. this.#addItemSize(index, size, status);
  3917. if (status)
  3918. status.set = 'add';
  3919. noUpdateTTL = false;
  3920. }
  3921. else {
  3922. this.#moveToTail(index);
  3923. const oldVal = this.#valList[index];
  3924. if (v !== oldVal) {
  3925. if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
  3926. oldVal.__abortController.abort(new Error('replaced'));
  3927. const { __staleWhileFetching: s } = oldVal;
  3928. if (s !== undefined && !noDisposeOnSet) {
  3929. if (this.#hasDispose) {
  3930. this.#dispose?.(s, k, 'set');
  3931. }
  3932. if (this.#hasDisposeAfter) {
  3933. this.#disposed?.push([s, k, 'set']);
  3934. }
  3935. }
  3936. }
  3937. else if (!noDisposeOnSet) {
  3938. if (this.#hasDispose) {
  3939. this.#dispose?.(oldVal, k, 'set');
  3940. }
  3941. if (this.#hasDisposeAfter) {
  3942. this.#disposed?.push([oldVal, k, 'set']);
  3943. }
  3944. }
  3945. this.#removeItemSize(index);
  3946. this.#addItemSize(index, size, status);
  3947. this.#valList[index] = v;
  3948. if (status) {
  3949. status.set = 'replace';
  3950. const oldValue = oldVal && this.#isBackgroundFetch(oldVal)
  3951. ? oldVal.__staleWhileFetching
  3952. : oldVal;
  3953. if (oldValue !== undefined)
  3954. status.oldValue = oldValue;
  3955. }
  3956. }
  3957. else if (status) {
  3958. status.set = 'update';
  3959. }
  3960. }
  3961. if (ttl !== 0 && !this.#ttls) {
  3962. this.#initializeTTLTracking();
  3963. }
  3964. if (this.#ttls) {
  3965. if (!noUpdateTTL) {
  3966. this.#setItemTTL(index, ttl, start);
  3967. }
  3968. if (status)
  3969. this.#statusTTL(status, index);
  3970. }
  3971. if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
  3972. const dt = this.#disposed;
  3973. let task;
  3974. while ((task = dt?.shift())) {
  3975. this.#disposeAfter?.(...task);
  3976. }
  3977. }
  3978. return this;
  3979. }
  3980. pop() {
  3981. try {
  3982. while (this.#size) {
  3983. const val = this.#valList[this.#head];
  3984. this.#evict(true);
  3985. if (this.#isBackgroundFetch(val)) {
  3986. if (val.__staleWhileFetching) {
  3987. return val.__staleWhileFetching;
  3988. }
  3989. }
  3990. else if (val !== undefined) {
  3991. return val;
  3992. }
  3993. }
  3994. }
  3995. finally {
  3996. if (this.#hasDisposeAfter && this.#disposed) {
  3997. const dt = this.#disposed;
  3998. let task;
  3999. while ((task = dt?.shift())) {
  4000. this.#disposeAfter?.(...task);
  4001. }
  4002. }
  4003. }
  4004. }
  4005. #evict(free) {
  4006. const head = this.#head;
  4007. const k = this.#keyList[head];
  4008. const v = this.#valList[head];
  4009. if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
  4010. v.__abortController.abort(new Error('evicted'));
  4011. }
  4012. else if (this.#hasDispose || this.#hasDisposeAfter) {
  4013. if (this.#hasDispose) {
  4014. this.#dispose?.(v, k, 'evict');
  4015. }
  4016. if (this.#hasDisposeAfter) {
  4017. this.#disposed?.push([v, k, 'evict']);
  4018. }
  4019. }
  4020. this.#removeItemSize(head);
  4021. if (free) {
  4022. this.#keyList[head] = undefined;
  4023. this.#valList[head] = undefined;
  4024. this.#free.push(head);
  4025. }
  4026. if (this.#size === 1) {
  4027. this.#head = this.#tail = 0;
  4028. this.#free.length = 0;
  4029. }
  4030. else {
  4031. this.#head = this.#next[head];
  4032. }
  4033. this.#keyMap.delete(k);
  4034. this.#size--;
  4035. return head;
  4036. }
  4037. has(k, hasOptions = {}) {
  4038. const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
  4039. const index = this.#keyMap.get(k);
  4040. if (index !== undefined) {
  4041. const v = this.#valList[index];
  4042. if (this.#isBackgroundFetch(v) &&
  4043. v.__staleWhileFetching === undefined) {
  4044. return false;
  4045. }
  4046. if (!this.#isStale(index)) {
  4047. if (updateAgeOnHas) {
  4048. this.#updateItemAge(index);
  4049. }
  4050. if (status) {
  4051. status.has = 'hit';
  4052. this.#statusTTL(status, index);
  4053. }
  4054. return true;
  4055. }
  4056. else if (status) {
  4057. status.has = 'stale';
  4058. this.#statusTTL(status, index);
  4059. }
  4060. }
  4061. else if (status) {
  4062. status.has = 'miss';
  4063. }
  4064. return false;
  4065. }
  4066. peek(k, peekOptions = {}) {
  4067. const { allowStale = this.allowStale } = peekOptions;
  4068. const index = this.#keyMap.get(k);
  4069. if (index === undefined ||
  4070. (!allowStale && this.#isStale(index))) {
  4071. return;
  4072. }
  4073. const v = this.#valList[index];
  4074. return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
  4075. }
  4076. #backgroundFetch(k, index, options, context) {
  4077. const v = index === undefined ? undefined : this.#valList[index];
  4078. if (this.#isBackgroundFetch(v)) {
  4079. return v;
  4080. }
  4081. const ac = new AC();
  4082. const { signal } = options;
  4083. signal?.addEventListener('abort', () => ac.abort(signal.reason), {
  4084. signal: ac.signal,
  4085. });
  4086. const fetchOpts = {
  4087. signal: ac.signal,
  4088. options,
  4089. context,
  4090. };
  4091. const cb = (v, updateCache = false) => {
  4092. const { aborted } = ac.signal;
  4093. const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
  4094. if (options.status) {
  4095. if (aborted && !updateCache) {
  4096. options.status.fetchAborted = true;
  4097. options.status.fetchError = ac.signal.reason;
  4098. if (ignoreAbort)
  4099. options.status.fetchAbortIgnored = true;
  4100. }
  4101. else {
  4102. options.status.fetchResolved = true;
  4103. }
  4104. }
  4105. if (aborted && !ignoreAbort && !updateCache) {
  4106. return fetchFail(ac.signal.reason);
  4107. }
  4108. const bf = p;
  4109. if (this.#valList[index] === p) {
  4110. if (v === undefined) {
  4111. if (bf.__staleWhileFetching) {
  4112. this.#valList[index] = bf.__staleWhileFetching;
  4113. }
  4114. else {
  4115. this.delete(k);
  4116. }
  4117. }
  4118. else {
  4119. if (options.status)
  4120. options.status.fetchUpdated = true;
  4121. this.set(k, v, fetchOpts.options);
  4122. }
  4123. }
  4124. return v;
  4125. };
  4126. const eb = (er) => {
  4127. if (options.status) {
  4128. options.status.fetchRejected = true;
  4129. options.status.fetchError = er;
  4130. }
  4131. return fetchFail(er);
  4132. };
  4133. const fetchFail = (er) => {
  4134. const { aborted } = ac.signal;
  4135. const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
  4136. const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
  4137. const noDelete = allowStale || options.noDeleteOnFetchRejection;
  4138. const bf = p;
  4139. if (this.#valList[index] === p) {
  4140. const del = !noDelete || bf.__staleWhileFetching === undefined;
  4141. if (del) {
  4142. this.delete(k);
  4143. }
  4144. else if (!allowStaleAborted) {
  4145. this.#valList[index] = bf.__staleWhileFetching;
  4146. }
  4147. }
  4148. if (allowStale) {
  4149. if (options.status && bf.__staleWhileFetching !== undefined) {
  4150. options.status.returnedStale = true;
  4151. }
  4152. return bf.__staleWhileFetching;
  4153. }
  4154. else if (bf.__returned === bf) {
  4155. throw er;
  4156. }
  4157. };
  4158. const pcall = (res, rej) => {
  4159. const fmp = this.#fetchMethod?.(k, v, fetchOpts);
  4160. if (fmp && fmp instanceof Promise) {
  4161. fmp.then(v => res(v === undefined ? undefined : v), rej);
  4162. }
  4163. ac.signal.addEventListener('abort', () => {
  4164. if (!options.ignoreFetchAbort ||
  4165. options.allowStaleOnFetchAbort) {
  4166. res(undefined);
  4167. if (options.allowStaleOnFetchAbort) {
  4168. res = v => cb(v, true);
  4169. }
  4170. }
  4171. });
  4172. };
  4173. if (options.status)
  4174. options.status.fetchDispatched = true;
  4175. const p = new Promise(pcall).then(cb, eb);
  4176. const bf = Object.assign(p, {
  4177. __abortController: ac,
  4178. __staleWhileFetching: v,
  4179. __returned: undefined,
  4180. });
  4181. if (index === undefined) {
  4182. this.set(k, bf, { ...fetchOpts.options, status: undefined });
  4183. index = this.#keyMap.get(k);
  4184. }
  4185. else {
  4186. this.#valList[index] = bf;
  4187. }
  4188. return bf;
  4189. }
  4190. #isBackgroundFetch(p) {
  4191. if (!this.#hasFetchMethod)
  4192. return false;
  4193. const b = p;
  4194. return (!!b &&
  4195. b instanceof Promise &&
  4196. b.hasOwnProperty('__staleWhileFetching') &&
  4197. b.__abortController instanceof AC);
  4198. }
  4199. async fetch(k, fetchOptions = {}) {
  4200. const {
  4201. allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
  4202. ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
  4203. noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
  4204. if (!this.#hasFetchMethod) {
  4205. if (status)
  4206. status.fetch = 'get';
  4207. return this.get(k, {
  4208. allowStale,
  4209. updateAgeOnGet,
  4210. noDeleteOnStaleGet,
  4211. status,
  4212. });
  4213. }
  4214. const options = {
  4215. allowStale,
  4216. updateAgeOnGet,
  4217. noDeleteOnStaleGet,
  4218. ttl,
  4219. noDisposeOnSet,
  4220. size,
  4221. sizeCalculation,
  4222. noUpdateTTL,
  4223. noDeleteOnFetchRejection,
  4224. allowStaleOnFetchRejection,
  4225. allowStaleOnFetchAbort,
  4226. ignoreFetchAbort,
  4227. status,
  4228. signal,
  4229. };
  4230. let index = this.#keyMap.get(k);
  4231. if (index === undefined) {
  4232. if (status)
  4233. status.fetch = 'miss';
  4234. const p = this.#backgroundFetch(k, index, options, context);
  4235. return (p.__returned = p);
  4236. }
  4237. else {
  4238. const v = this.#valList[index];
  4239. if (this.#isBackgroundFetch(v)) {
  4240. const stale = allowStale && v.__staleWhileFetching !== undefined;
  4241. if (status) {
  4242. status.fetch = 'inflight';
  4243. if (stale)
  4244. status.returnedStale = true;
  4245. }
  4246. return stale ? v.__staleWhileFetching : (v.__returned = v);
  4247. }
  4248. const isStale = this.#isStale(index);
  4249. if (!forceRefresh && !isStale) {
  4250. if (status)
  4251. status.fetch = 'hit';
  4252. this.#moveToTail(index);
  4253. if (updateAgeOnGet) {
  4254. this.#updateItemAge(index);
  4255. }
  4256. if (status)
  4257. this.#statusTTL(status, index);
  4258. return v;
  4259. }
  4260. const p = this.#backgroundFetch(k, index, options, context);
  4261. const hasStale = p.__staleWhileFetching !== undefined;
  4262. const staleVal = hasStale && allowStale;
  4263. if (status) {
  4264. status.fetch = isStale ? 'stale' : 'refresh';
  4265. if (staleVal && isStale)
  4266. status.returnedStale = true;
  4267. }
  4268. return staleVal ? p.__staleWhileFetching : (p.__returned = p);
  4269. }
  4270. }
  4271. get(k, getOptions = {}) {
  4272. const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
  4273. const index = this.#keyMap.get(k);
  4274. if (index !== undefined) {
  4275. const value = this.#valList[index];
  4276. const fetching = this.#isBackgroundFetch(value);
  4277. if (status)
  4278. this.#statusTTL(status, index);
  4279. if (this.#isStale(index)) {
  4280. if (status)
  4281. status.get = 'stale';
  4282. if (!fetching) {
  4283. if (!noDeleteOnStaleGet) {
  4284. this.delete(k);
  4285. }
  4286. if (status && allowStale)
  4287. status.returnedStale = true;
  4288. return allowStale ? value : undefined;
  4289. }
  4290. else {
  4291. if (status &&
  4292. allowStale &&
  4293. value.__staleWhileFetching !== undefined) {
  4294. status.returnedStale = true;
  4295. }
  4296. return allowStale ? value.__staleWhileFetching : undefined;
  4297. }
  4298. }
  4299. else {
  4300. if (status)
  4301. status.get = 'hit';
  4302. if (fetching) {
  4303. return value.__staleWhileFetching;
  4304. }
  4305. this.#moveToTail(index);
  4306. if (updateAgeOnGet) {
  4307. this.#updateItemAge(index);
  4308. }
  4309. return value;
  4310. }
  4311. }
  4312. else if (status) {
  4313. status.get = 'miss';
  4314. }
  4315. }
  4316. #connect(p, n) {
  4317. this.#prev[n] = p;
  4318. this.#next[p] = n;
  4319. }
  4320. #moveToTail(index) {
  4321. if (index !== this.#tail) {
  4322. if (index === this.#head) {
  4323. this.#head = this.#next[index];
  4324. }
  4325. else {
  4326. this.#connect(this.#prev[index], this.#next[index]);
  4327. }
  4328. this.#connect(this.#tail, index);
  4329. this.#tail = index;
  4330. }
  4331. }
  4332. delete(k) {
  4333. let deleted = false;
  4334. if (this.#size !== 0) {
  4335. const index = this.#keyMap.get(k);
  4336. if (index !== undefined) {
  4337. deleted = true;
  4338. if (this.#size === 1) {
  4339. this.clear();
  4340. }
  4341. else {
  4342. this.#removeItemSize(index);
  4343. const v = this.#valList[index];
  4344. if (this.#isBackgroundFetch(v)) {
  4345. v.__abortController.abort(new Error('deleted'));
  4346. }
  4347. else if (this.#hasDispose || this.#hasDisposeAfter) {
  4348. if (this.#hasDispose) {
  4349. this.#dispose?.(v, k, 'delete');
  4350. }
  4351. if (this.#hasDisposeAfter) {
  4352. this.#disposed?.push([v, k, 'delete']);
  4353. }
  4354. }
  4355. this.#keyMap.delete(k);
  4356. this.#keyList[index] = undefined;
  4357. this.#valList[index] = undefined;
  4358. if (index === this.#tail) {
  4359. this.#tail = this.#prev[index];
  4360. }
  4361. else if (index === this.#head) {
  4362. this.#head = this.#next[index];
  4363. }
  4364. else {
  4365. const pi = this.#prev[index];
  4366. this.#next[pi] = this.#next[index];
  4367. const ni = this.#next[index];
  4368. this.#prev[ni] = this.#prev[index];
  4369. }
  4370. this.#size--;
  4371. this.#free.push(index);
  4372. }
  4373. }
  4374. }
  4375. if (this.#hasDisposeAfter && this.#disposed?.length) {
  4376. const dt = this.#disposed;
  4377. let task;
  4378. while ((task = dt?.shift())) {
  4379. this.#disposeAfter?.(...task);
  4380. }
  4381. }
  4382. return deleted;
  4383. }
  4384. clear() {
  4385. for (const index of this.#rindexes({ allowStale: true })) {
  4386. const v = this.#valList[index];
  4387. if (this.#isBackgroundFetch(v)) {
  4388. v.__abortController.abort(new Error('deleted'));
  4389. }
  4390. else {
  4391. const k = this.#keyList[index];
  4392. if (this.#hasDispose) {
  4393. this.#dispose?.(v, k, 'delete');
  4394. }
  4395. if (this.#hasDisposeAfter) {
  4396. this.#disposed?.push([v, k, 'delete']);
  4397. }
  4398. }
  4399. }
  4400. this.#keyMap.clear();
  4401. this.#valList.fill(undefined);
  4402. this.#keyList.fill(undefined);
  4403. if (this.#ttls && this.#starts) {
  4404. this.#ttls.fill(0);
  4405. this.#starts.fill(0);
  4406. }
  4407. if (this.#sizes) {
  4408. this.#sizes.fill(0);
  4409. }
  4410. this.#head = 0;
  4411. this.#tail = 0;
  4412. this.#free.length = 0;
  4413. this.#calculatedSize = 0;
  4414. this.#size = 0;
  4415. if (this.#hasDisposeAfter && this.#disposed) {
  4416. const dt = this.#disposed;
  4417. let task;
  4418. while ((task = dt?.shift())) {
  4419. this.#disposeAfter?.(...task);
  4420. }
  4421. }
  4422. }
  4423. };
  4424. commonjs.LRUCache = LRUCache$1;
  4425. const maybeJoin = (...args) => args.every(arg => arg) ? args.join('') : '';
  4426. const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : '';
  4427. const formatHashFragment = (f) => f.toLowerCase().replace(/^\W+|\/|\W+$/g, '').replace(/\W+/g, '-');
  4428. const defaults = {
  4429. sshtemplate: ({ domain, user, project, committish }) =>
  4430. `git@${domain}:${user}/${project}.git${maybeJoin('#', committish)}`,
  4431. sshurltemplate: ({ domain, user, project, committish }) =>
  4432. `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
  4433. edittemplate: ({ domain, user, project, committish, editpath, path }) =>
  4434. `https://${domain}/${user}/${project}${maybeJoin('/', editpath, '/', maybeEncode(committish || 'HEAD'), '/', path)}`,
  4435. browsetemplate: ({ domain, user, project, committish, treepath }) =>
  4436. `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}`,
  4437. browsetreetemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) =>
  4438. `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || 'HEAD')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`,
  4439. browseblobtemplate: ({ domain, user, project, committish, blobpath, path, fragment, hashformat }) =>
  4440. `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || 'HEAD')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`,
  4441. docstemplate: ({ domain, user, project, treepath, committish }) =>
  4442. `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}#readme`,
  4443. httpstemplate: ({ auth, domain, user, project, committish }) =>
  4444. `git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
  4445. filetemplate: ({ domain, user, project, committish, path }) =>
  4446. `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || 'HEAD')}/${path}`,
  4447. shortcuttemplate: ({ type, user, project, committish }) =>
  4448. `${type}:${user}/${project}${maybeJoin('#', committish)}`,
  4449. pathtemplate: ({ user, project, committish }) =>
  4450. `${user}/${project}${maybeJoin('#', committish)}`,
  4451. bugstemplate: ({ domain, user, project }) =>
  4452. `https://${domain}/${user}/${project}/issues`,
  4453. hashformat: formatHashFragment,
  4454. };
  4455. const hosts$1 = {};
  4456. hosts$1.github = {
  4457. protocols: ['git:', 'http:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'],
  4458. domain: 'github.com',
  4459. treepath: 'tree',
  4460. blobpath: 'blob',
  4461. editpath: 'edit',
  4462. filetemplate: ({ auth, user, project, committish, path }) =>
  4463. `https://${maybeJoin(auth, '@')}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || 'HEAD')}/${path}`,
  4464. gittemplate: ({ auth, domain, user, project, committish }) =>
  4465. `git://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
  4466. tarballtemplate: ({ domain, user, project, committish }) =>
  4467. `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || 'HEAD')}`,
  4468. extract: (url) => {
  4469. let [, user, project, type, committish] = url.pathname.split('/', 5);
  4470. if (type && type !== 'tree') {
  4471. return
  4472. }
  4473. if (!type) {
  4474. committish = url.hash.slice(1);
  4475. }
  4476. if (project && project.endsWith('.git')) {
  4477. project = project.slice(0, -4);
  4478. }
  4479. if (!user || !project) {
  4480. return
  4481. }
  4482. return { user, project, committish }
  4483. },
  4484. };
  4485. hosts$1.bitbucket = {
  4486. protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'],
  4487. domain: 'bitbucket.org',
  4488. treepath: 'src',
  4489. blobpath: 'src',
  4490. editpath: '?mode=edit',
  4491. edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) =>
  4492. `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish || 'HEAD'), '/', path, editpath)}`,
  4493. tarballtemplate: ({ domain, user, project, committish }) =>
  4494. `https://${domain}/${user}/${project}/get/${maybeEncode(committish || 'HEAD')}.tar.gz`,
  4495. extract: (url) => {
  4496. let [, user, project, aux] = url.pathname.split('/', 4);
  4497. if (['get'].includes(aux)) {
  4498. return
  4499. }
  4500. if (project && project.endsWith('.git')) {
  4501. project = project.slice(0, -4);
  4502. }
  4503. if (!user || !project) {
  4504. return
  4505. }
  4506. return { user, project, committish: url.hash.slice(1) }
  4507. },
  4508. };
  4509. hosts$1.gitlab = {
  4510. protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'],
  4511. domain: 'gitlab.com',
  4512. treepath: 'tree',
  4513. blobpath: 'tree',
  4514. editpath: '-/edit',
  4515. httpstemplate: ({ auth, domain, user, project, committish }) =>
  4516. `git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
  4517. tarballtemplate: ({ domain, user, project, committish }) =>
  4518. `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish || 'HEAD')}`,
  4519. extract: (url) => {
  4520. const path = url.pathname.slice(1);
  4521. if (path.includes('/-/') || path.includes('/archive.tar.gz')) {
  4522. return
  4523. }
  4524. const segments = path.split('/');
  4525. let project = segments.pop();
  4526. if (project.endsWith('.git')) {
  4527. project = project.slice(0, -4);
  4528. }
  4529. const user = segments.join('/');
  4530. if (!user || !project) {
  4531. return
  4532. }
  4533. return { user, project, committish: url.hash.slice(1) }
  4534. },
  4535. };
  4536. hosts$1.gist = {
  4537. protocols: ['git:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'],
  4538. domain: 'gist.github.com',
  4539. editpath: 'edit',
  4540. sshtemplate: ({ domain, project, committish }) =>
  4541. `git@${domain}:${project}.git${maybeJoin('#', committish)}`,
  4542. sshurltemplate: ({ domain, project, committish }) =>
  4543. `git+ssh://git@${domain}/${project}.git${maybeJoin('#', committish)}`,
  4544. edittemplate: ({ domain, user, project, committish, editpath }) =>
  4545. `https://${domain}/${user}/${project}${maybeJoin('/', maybeEncode(committish))}/${editpath}`,
  4546. browsetemplate: ({ domain, project, committish }) =>
  4547. `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`,
  4548. browsetreetemplate: ({ domain, project, committish, path, hashformat }) =>
  4549. `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`,
  4550. browseblobtemplate: ({ domain, project, committish, path, hashformat }) =>
  4551. `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`,
  4552. docstemplate: ({ domain, project, committish }) =>
  4553. `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`,
  4554. httpstemplate: ({ domain, project, committish }) =>
  4555. `git+https://${domain}/${project}.git${maybeJoin('#', committish)}`,
  4556. filetemplate: ({ user, project, committish, path }) =>
  4557. `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin('/', maybeEncode(committish))}/${path}`,
  4558. shortcuttemplate: ({ type, project, committish }) =>
  4559. `${type}:${project}${maybeJoin('#', committish)}`,
  4560. pathtemplate: ({ project, committish }) =>
  4561. `${project}${maybeJoin('#', committish)}`,
  4562. bugstemplate: ({ domain, project }) =>
  4563. `https://${domain}/${project}`,
  4564. gittemplate: ({ domain, project, committish }) =>
  4565. `git://${domain}/${project}.git${maybeJoin('#', committish)}`,
  4566. tarballtemplate: ({ project, committish }) =>
  4567. `https://codeload.github.com/gist/${project}/tar.gz/${maybeEncode(committish || 'HEAD')}`,
  4568. extract: (url) => {
  4569. let [, user, project, aux] = url.pathname.split('/', 4);
  4570. if (aux === 'raw') {
  4571. return
  4572. }
  4573. if (!project) {
  4574. if (!user) {
  4575. return
  4576. }
  4577. project = user;
  4578. user = null;
  4579. }
  4580. if (project.endsWith('.git')) {
  4581. project = project.slice(0, -4);
  4582. }
  4583. return { user, project, committish: url.hash.slice(1) }
  4584. },
  4585. hashformat: function (fragment) {
  4586. return fragment && 'file-' + formatHashFragment(fragment)
  4587. },
  4588. };
  4589. hosts$1.sourcehut = {
  4590. protocols: ['git+ssh:', 'https:'],
  4591. domain: 'git.sr.ht',
  4592. treepath: 'tree',
  4593. blobpath: 'tree',
  4594. filetemplate: ({ domain, user, project, committish, path }) =>
  4595. `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || 'HEAD'}/${path}`,
  4596. httpstemplate: ({ domain, user, project, committish }) =>
  4597. `https://${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
  4598. tarballtemplate: ({ domain, user, project, committish }) =>
  4599. `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || 'HEAD'}.tar.gz`,
  4600. bugstemplate: ({ user, project }) => null,
  4601. extract: (url) => {
  4602. let [, user, project, aux] = url.pathname.split('/', 4);
  4603. if (['archive'].includes(aux)) {
  4604. return
  4605. }
  4606. if (project && project.endsWith('.git')) {
  4607. project = project.slice(0, -4);
  4608. }
  4609. if (!user || !project) {
  4610. return
  4611. }
  4612. return { user, project, committish: url.hash.slice(1) }
  4613. },
  4614. };
  4615. for (const [name, host] of Object.entries(hosts$1)) {
  4616. hosts$1[name] = Object.assign({}, defaults, host);
  4617. }
  4618. var hosts_1 = hosts$1;
  4619. const url$2 = require$$0;
  4620. const lastIndexOfBefore = (str, char, beforeChar) => {
  4621. const startPosition = str.indexOf(beforeChar);
  4622. return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity)
  4623. };
  4624. const safeUrl = (u) => {
  4625. try {
  4626. return new url$2.URL(u)
  4627. } catch {
  4628. }
  4629. };
  4630. const correctProtocol = (arg, protocols) => {
  4631. const firstColon = arg.indexOf(':');
  4632. const proto = arg.slice(0, firstColon + 1);
  4633. if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
  4634. return arg
  4635. }
  4636. const firstAt = arg.indexOf('@');
  4637. if (firstAt > -1) {
  4638. if (firstAt > firstColon) {
  4639. return `git+ssh://${arg}`
  4640. } else {
  4641. return arg
  4642. }
  4643. }
  4644. const doubleSlash = arg.indexOf('//');
  4645. if (doubleSlash === firstColon + 1) {
  4646. return arg
  4647. }
  4648. return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`
  4649. };
  4650. const correctUrl = (giturl) => {
  4651. const firstAt = lastIndexOfBefore(giturl, '@', '#');
  4652. const lastColonBeforeHash = lastIndexOfBefore(giturl, ':', '#');
  4653. if (lastColonBeforeHash > firstAt) {
  4654. giturl = giturl.slice(0, lastColonBeforeHash) + '/' + giturl.slice(lastColonBeforeHash + 1);
  4655. }
  4656. if (lastIndexOfBefore(giturl, ':', '#') === -1 && giturl.indexOf('//') === -1) {
  4657. giturl = `git+ssh://${giturl}`;
  4658. }
  4659. return giturl
  4660. };
  4661. var parseUrl$2 = (giturl, protocols) => {
  4662. const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl;
  4663. return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol))
  4664. };
  4665. const parseUrl$1 = parseUrl$2;
  4666. const isGitHubShorthand = (arg) => {
  4667. const firstHash = arg.indexOf('#');
  4668. const firstSlash = arg.indexOf('/');
  4669. const secondSlash = arg.indexOf('/', firstSlash + 1);
  4670. const firstColon = arg.indexOf(':');
  4671. const firstSpace = /\s/.exec(arg);
  4672. const firstAt = arg.indexOf('@');
  4673. const spaceOnlyAfterHash = !firstSpace || (firstHash > -1 && firstSpace.index > firstHash);
  4674. const atOnlyAfterHash = firstAt === -1 || (firstHash > -1 && firstAt > firstHash);
  4675. const colonOnlyAfterHash = firstColon === -1 || (firstHash > -1 && firstColon > firstHash);
  4676. const secondSlashOnlyAfterHash = secondSlash === -1 || (firstHash > -1 && secondSlash > firstHash);
  4677. const hasSlash = firstSlash > 0;
  4678. const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== '/' : !arg.endsWith('/');
  4679. const doesNotStartWithDot = !arg.startsWith('.');
  4680. return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash &&
  4681. doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash &&
  4682. secondSlashOnlyAfterHash
  4683. };
  4684. var fromUrl$1 = (giturl, opts, { gitHosts, protocols }) => {
  4685. if (!giturl) {
  4686. return
  4687. }
  4688. const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
  4689. const parsed = parseUrl$1(correctedUrl, protocols);
  4690. if (!parsed) {
  4691. return
  4692. }
  4693. const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
  4694. const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.')
  4695. ? parsed.hostname.slice(4)
  4696. : parsed.hostname];
  4697. const gitHostName = gitHostShortcut || gitHostDomain;
  4698. if (!gitHostName) {
  4699. return
  4700. }
  4701. const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain];
  4702. let auth = null;
  4703. if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) {
  4704. auth = `${parsed.username}${parsed.password ? ':' + parsed.password : ''}`;
  4705. }
  4706. let committish = null;
  4707. let user = null;
  4708. let project = null;
  4709. let defaultRepresentation = null;
  4710. try {
  4711. if (gitHostShortcut) {
  4712. let pathname = parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname;
  4713. const firstAt = pathname.indexOf('@');
  4714. if (firstAt > -1) {
  4715. pathname = pathname.slice(firstAt + 1);
  4716. }
  4717. const lastSlash = pathname.lastIndexOf('/');
  4718. if (lastSlash > -1) {
  4719. user = decodeURIComponent(pathname.slice(0, lastSlash));
  4720. if (!user) {
  4721. user = null;
  4722. }
  4723. project = decodeURIComponent(pathname.slice(lastSlash + 1));
  4724. } else {
  4725. project = decodeURIComponent(pathname);
  4726. }
  4727. if (project.endsWith('.git')) {
  4728. project = project.slice(0, -4);
  4729. }
  4730. if (parsed.hash) {
  4731. committish = decodeURIComponent(parsed.hash.slice(1));
  4732. }
  4733. defaultRepresentation = 'shortcut';
  4734. } else {
  4735. if (!gitHostInfo.protocols.includes(parsed.protocol)) {
  4736. return
  4737. }
  4738. const segments = gitHostInfo.extract(parsed);
  4739. if (!segments) {
  4740. return
  4741. }
  4742. user = segments.user && decodeURIComponent(segments.user);
  4743. project = decodeURIComponent(segments.project);
  4744. committish = decodeURIComponent(segments.committish);
  4745. defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1);
  4746. }
  4747. } catch (err) {
  4748. if (err instanceof URIError) {
  4749. return
  4750. } else {
  4751. throw err
  4752. }
  4753. }
  4754. return [gitHostName, user, auth, project, committish, defaultRepresentation, opts]
  4755. };
  4756. const { LRUCache } = commonjs;
  4757. const hosts = hosts_1;
  4758. const fromUrl = fromUrl$1;
  4759. const parseUrl = parseUrl$2;
  4760. const cache$1 = new LRUCache({ max: 1000 });
  4761. class GitHost {
  4762. constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {
  4763. Object.assign(this, GitHost.#gitHosts[type], {
  4764. type,
  4765. user,
  4766. auth,
  4767. project,
  4768. committish,
  4769. default: defaultRepresentation,
  4770. opts,
  4771. });
  4772. }
  4773. static #gitHosts = { byShortcut: {}, byDomain: {} }
  4774. static #protocols = {
  4775. 'git+ssh:': { name: 'sshurl' },
  4776. 'ssh:': { name: 'sshurl' },
  4777. 'git+https:': { name: 'https', auth: true },
  4778. 'git:': { auth: true },
  4779. 'http:': { auth: true },
  4780. 'https:': { auth: true },
  4781. 'git+http:': { auth: true },
  4782. }
  4783. static addHost (name, host) {
  4784. GitHost.#gitHosts[name] = host;
  4785. GitHost.#gitHosts.byDomain[host.domain] = name;
  4786. GitHost.#gitHosts.byShortcut[`${name}:`] = name;
  4787. GitHost.#protocols[`${name}:`] = { name };
  4788. }
  4789. static fromUrl (giturl, opts) {
  4790. if (typeof giturl !== 'string') {
  4791. return
  4792. }
  4793. const key = giturl + JSON.stringify(opts || {});
  4794. if (!cache$1.has(key)) {
  4795. const hostArgs = fromUrl(giturl, opts, {
  4796. gitHosts: GitHost.#gitHosts,
  4797. protocols: GitHost.#protocols,
  4798. });
  4799. cache$1.set(key, hostArgs ? new GitHost(...hostArgs) : undefined);
  4800. }
  4801. return cache$1.get(key)
  4802. }
  4803. static parseUrl (url) {
  4804. return parseUrl(url)
  4805. }
  4806. #fill (template, opts) {
  4807. if (typeof template !== 'function') {
  4808. return null
  4809. }
  4810. const options = { ...this, ...this.opts, ...opts };
  4811. if (!options.path) {
  4812. options.path = '';
  4813. }
  4814. if (options.path.startsWith('/')) {
  4815. options.path = options.path.slice(1);
  4816. }
  4817. if (options.noCommittish) {
  4818. options.committish = null;
  4819. }
  4820. const result = template(options);
  4821. return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result
  4822. }
  4823. hash () {
  4824. return this.committish ? `#${this.committish}` : ''
  4825. }
  4826. ssh (opts) {
  4827. return this.#fill(this.sshtemplate, opts)
  4828. }
  4829. sshurl (opts) {
  4830. return this.#fill(this.sshurltemplate, opts)
  4831. }
  4832. browse (path, ...args) {
  4833. if (typeof path !== 'string') {
  4834. return this.#fill(this.browsetemplate, path)
  4835. }
  4836. if (typeof args[0] !== 'string') {
  4837. return this.#fill(this.browsetreetemplate, { ...args[0], path })
  4838. }
  4839. return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path })
  4840. }
  4841. browseFile (path, ...args) {
  4842. if (typeof args[0] !== 'string') {
  4843. return this.#fill(this.browseblobtemplate, { ...args[0], path })
  4844. }
  4845. return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path })
  4846. }
  4847. docs (opts) {
  4848. return this.#fill(this.docstemplate, opts)
  4849. }
  4850. bugs (opts) {
  4851. return this.#fill(this.bugstemplate, opts)
  4852. }
  4853. https (opts) {
  4854. return this.#fill(this.httpstemplate, opts)
  4855. }
  4856. git (opts) {
  4857. return this.#fill(this.gittemplate, opts)
  4858. }
  4859. shortcut (opts) {
  4860. return this.#fill(this.shortcuttemplate, opts)
  4861. }
  4862. path (opts) {
  4863. return this.#fill(this.pathtemplate, opts)
  4864. }
  4865. tarball (opts) {
  4866. return this.#fill(this.tarballtemplate, { ...opts, noCommittish: false })
  4867. }
  4868. file (path, opts) {
  4869. return this.#fill(this.filetemplate, { ...opts, path })
  4870. }
  4871. edit (path, opts) {
  4872. return this.#fill(this.edittemplate, { ...opts, path })
  4873. }
  4874. getDefaultRepresentation () {
  4875. return this.default
  4876. }
  4877. toString (opts) {
  4878. if (this.default && typeof this[this.default] === 'function') {
  4879. return this[this.default](opts)
  4880. }
  4881. return this.sshurl(opts)
  4882. }
  4883. }
  4884. for (const [name, host] of Object.entries(hosts)) {
  4885. GitHost.addHost(name, host);
  4886. }
  4887. var lib$3 = GitHost;
  4888. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  4889. var toStr = Object.prototype.toString;
  4890. var max = Math.max;
  4891. var funcType = '[object Function]';
  4892. var concatty = function concatty(a, b) {
  4893. var arr = [];
  4894. for (var i = 0; i < a.length; i += 1) {
  4895. arr[i] = a[i];
  4896. }
  4897. for (var j = 0; j < b.length; j += 1) {
  4898. arr[j + a.length] = b[j];
  4899. }
  4900. return arr;
  4901. };
  4902. var slicy = function slicy(arrLike, offset) {
  4903. var arr = [];
  4904. for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
  4905. arr[j] = arrLike[i];
  4906. }
  4907. return arr;
  4908. };
  4909. var joiny = function (arr, joiner) {
  4910. var str = '';
  4911. for (var i = 0; i < arr.length; i += 1) {
  4912. str += arr[i];
  4913. if (i + 1 < arr.length) {
  4914. str += joiner;
  4915. }
  4916. }
  4917. return str;
  4918. };
  4919. var implementation$1 = function bind(that) {
  4920. var target = this;
  4921. if (typeof target !== 'function' || toStr.apply(target) !== funcType) {
  4922. throw new TypeError(ERROR_MESSAGE + target);
  4923. }
  4924. var args = slicy(arguments, 1);
  4925. var bound;
  4926. var binder = function () {
  4927. if (this instanceof bound) {
  4928. var result = target.apply(
  4929. this,
  4930. concatty(args, arguments)
  4931. );
  4932. if (Object(result) === result) {
  4933. return result;
  4934. }
  4935. return this;
  4936. }
  4937. return target.apply(
  4938. that,
  4939. concatty(args, arguments)
  4940. );
  4941. };
  4942. var boundLength = max(0, target.length - args.length);
  4943. var boundArgs = [];
  4944. for (var i = 0; i < boundLength; i++) {
  4945. boundArgs[i] = '$' + i;
  4946. }
  4947. bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);
  4948. if (target.prototype) {
  4949. var Empty = function Empty() {};
  4950. Empty.prototype = target.prototype;
  4951. bound.prototype = new Empty();
  4952. Empty.prototype = null;
  4953. }
  4954. return bound;
  4955. };
  4956. var implementation = implementation$1;
  4957. var functionBind = Function.prototype.bind || implementation;
  4958. var call = Function.prototype.call;
  4959. var $hasOwn = Object.prototype.hasOwnProperty;
  4960. var bind = functionBind;
  4961. var hasown = bind.call(call, $hasOwn);
  4962. var assert = true;
  4963. var async_hooks = ">= 8";
  4964. var buffer_ieee754 = ">= 0.5 && < 0.9.7";
  4965. var buffer = true;
  4966. var child_process = true;
  4967. var cluster = ">= 0.5";
  4968. var console$1 = true;
  4969. var constants = true;
  4970. var crypto = true;
  4971. var _debug_agent = ">= 1 && < 8";
  4972. var _debugger = "< 8";
  4973. var dgram = true;
  4974. var diagnostics_channel = [
  4975. ">= 14.17 && < 15",
  4976. ">= 15.1"
  4977. ];
  4978. var dns = true;
  4979. var domain = ">= 0.7.12";
  4980. var events = true;
  4981. var freelist = "< 6";
  4982. var fs = true;
  4983. var _http_agent = ">= 0.11.1";
  4984. var _http_client = ">= 0.11.1";
  4985. var _http_common = ">= 0.11.1";
  4986. var _http_incoming = ">= 0.11.1";
  4987. var _http_outgoing = ">= 0.11.1";
  4988. var _http_server = ">= 0.11.1";
  4989. var http = true;
  4990. var http2 = ">= 8.8";
  4991. var https = true;
  4992. var inspector = ">= 8";
  4993. var _linklist = "< 8";
  4994. var module = true;
  4995. var net = true;
  4996. var os$2 = true;
  4997. var path = true;
  4998. var perf_hooks = ">= 8.5";
  4999. var process$1 = ">= 1";
  5000. var punycode = ">= 0.5";
  5001. var querystring = true;
  5002. var readline = true;
  5003. var repl = true;
  5004. var smalloc = ">= 0.11.5 && < 3";
  5005. var _stream_duplex = ">= 0.9.4";
  5006. var _stream_transform = ">= 0.9.4";
  5007. var _stream_wrap = ">= 1.4.1";
  5008. var _stream_passthrough = ">= 0.9.4";
  5009. var _stream_readable = ">= 0.9.4";
  5010. var _stream_writable = ">= 0.9.4";
  5011. var stream = true;
  5012. var string_decoder = true;
  5013. var sys = [
  5014. ">= 0.4 && < 0.7",
  5015. ">= 0.8"
  5016. ];
  5017. var timers = true;
  5018. var _tls_common = ">= 0.11.13";
  5019. var _tls_legacy = ">= 0.11.3 && < 10";
  5020. var _tls_wrap = ">= 0.11.3";
  5021. var tls = true;
  5022. var trace_events = ">= 10";
  5023. var tty = true;
  5024. var url$1 = true;
  5025. var util$1 = true;
  5026. var v8 = ">= 1";
  5027. var vm = true;
  5028. var wasi = [
  5029. ">= 13.4 && < 13.5",
  5030. ">= 18.17 && < 19",
  5031. ">= 20"
  5032. ];
  5033. var worker_threads = ">= 11.7";
  5034. var zlib = ">= 0.5";
  5035. const require$$1$1 = {
  5036. assert: assert,
  5037. "node:assert": [
  5038. ">= 14.18 && < 15",
  5039. ">= 16"
  5040. ],
  5041. "assert/strict": ">= 15",
  5042. "node:assert/strict": ">= 16",
  5043. async_hooks: async_hooks,
  5044. "node:async_hooks": [
  5045. ">= 14.18 && < 15",
  5046. ">= 16"
  5047. ],
  5048. buffer_ieee754: buffer_ieee754,
  5049. buffer: buffer,
  5050. "node:buffer": [
  5051. ">= 14.18 && < 15",
  5052. ">= 16"
  5053. ],
  5054. child_process: child_process,
  5055. "node:child_process": [
  5056. ">= 14.18 && < 15",
  5057. ">= 16"
  5058. ],
  5059. cluster: cluster,
  5060. "node:cluster": [
  5061. ">= 14.18 && < 15",
  5062. ">= 16"
  5063. ],
  5064. console: console$1,
  5065. "node:console": [
  5066. ">= 14.18 && < 15",
  5067. ">= 16"
  5068. ],
  5069. constants: constants,
  5070. "node:constants": [
  5071. ">= 14.18 && < 15",
  5072. ">= 16"
  5073. ],
  5074. crypto: crypto,
  5075. "node:crypto": [
  5076. ">= 14.18 && < 15",
  5077. ">= 16"
  5078. ],
  5079. _debug_agent: _debug_agent,
  5080. _debugger: _debugger,
  5081. dgram: dgram,
  5082. "node:dgram": [
  5083. ">= 14.18 && < 15",
  5084. ">= 16"
  5085. ],
  5086. diagnostics_channel: diagnostics_channel,
  5087. "node:diagnostics_channel": [
  5088. ">= 14.18 && < 15",
  5089. ">= 16"
  5090. ],
  5091. dns: dns,
  5092. "node:dns": [
  5093. ">= 14.18 && < 15",
  5094. ">= 16"
  5095. ],
  5096. "dns/promises": ">= 15",
  5097. "node:dns/promises": ">= 16",
  5098. domain: domain,
  5099. "node:domain": [
  5100. ">= 14.18 && < 15",
  5101. ">= 16"
  5102. ],
  5103. events: events,
  5104. "node:events": [
  5105. ">= 14.18 && < 15",
  5106. ">= 16"
  5107. ],
  5108. freelist: freelist,
  5109. fs: fs,
  5110. "node:fs": [
  5111. ">= 14.18 && < 15",
  5112. ">= 16"
  5113. ],
  5114. "fs/promises": [
  5115. ">= 10 && < 10.1",
  5116. ">= 14"
  5117. ],
  5118. "node:fs/promises": [
  5119. ">= 14.18 && < 15",
  5120. ">= 16"
  5121. ],
  5122. _http_agent: _http_agent,
  5123. "node:_http_agent": [
  5124. ">= 14.18 && < 15",
  5125. ">= 16"
  5126. ],
  5127. _http_client: _http_client,
  5128. "node:_http_client": [
  5129. ">= 14.18 && < 15",
  5130. ">= 16"
  5131. ],
  5132. _http_common: _http_common,
  5133. "node:_http_common": [
  5134. ">= 14.18 && < 15",
  5135. ">= 16"
  5136. ],
  5137. _http_incoming: _http_incoming,
  5138. "node:_http_incoming": [
  5139. ">= 14.18 && < 15",
  5140. ">= 16"
  5141. ],
  5142. _http_outgoing: _http_outgoing,
  5143. "node:_http_outgoing": [
  5144. ">= 14.18 && < 15",
  5145. ">= 16"
  5146. ],
  5147. _http_server: _http_server,
  5148. "node:_http_server": [
  5149. ">= 14.18 && < 15",
  5150. ">= 16"
  5151. ],
  5152. http: http,
  5153. "node:http": [
  5154. ">= 14.18 && < 15",
  5155. ">= 16"
  5156. ],
  5157. http2: http2,
  5158. "node:http2": [
  5159. ">= 14.18 && < 15",
  5160. ">= 16"
  5161. ],
  5162. https: https,
  5163. "node:https": [
  5164. ">= 14.18 && < 15",
  5165. ">= 16"
  5166. ],
  5167. inspector: inspector,
  5168. "node:inspector": [
  5169. ">= 14.18 && < 15",
  5170. ">= 16"
  5171. ],
  5172. "inspector/promises": [
  5173. ">= 19"
  5174. ],
  5175. "node:inspector/promises": [
  5176. ">= 19"
  5177. ],
  5178. _linklist: _linklist,
  5179. module: module,
  5180. "node:module": [
  5181. ">= 14.18 && < 15",
  5182. ">= 16"
  5183. ],
  5184. net: net,
  5185. "node:net": [
  5186. ">= 14.18 && < 15",
  5187. ">= 16"
  5188. ],
  5189. "node-inspect/lib/_inspect": ">= 7.6 && < 12",
  5190. "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
  5191. "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
  5192. os: os$2,
  5193. "node:os": [
  5194. ">= 14.18 && < 15",
  5195. ">= 16"
  5196. ],
  5197. path: path,
  5198. "node:path": [
  5199. ">= 14.18 && < 15",
  5200. ">= 16"
  5201. ],
  5202. "path/posix": ">= 15.3",
  5203. "node:path/posix": ">= 16",
  5204. "path/win32": ">= 15.3",
  5205. "node:path/win32": ">= 16",
  5206. perf_hooks: perf_hooks,
  5207. "node:perf_hooks": [
  5208. ">= 14.18 && < 15",
  5209. ">= 16"
  5210. ],
  5211. process: process$1,
  5212. "node:process": [
  5213. ">= 14.18 && < 15",
  5214. ">= 16"
  5215. ],
  5216. punycode: punycode,
  5217. "node:punycode": [
  5218. ">= 14.18 && < 15",
  5219. ">= 16"
  5220. ],
  5221. querystring: querystring,
  5222. "node:querystring": [
  5223. ">= 14.18 && < 15",
  5224. ">= 16"
  5225. ],
  5226. readline: readline,
  5227. "node:readline": [
  5228. ">= 14.18 && < 15",
  5229. ">= 16"
  5230. ],
  5231. "readline/promises": ">= 17",
  5232. "node:readline/promises": ">= 17",
  5233. repl: repl,
  5234. "node:repl": [
  5235. ">= 14.18 && < 15",
  5236. ">= 16"
  5237. ],
  5238. smalloc: smalloc,
  5239. _stream_duplex: _stream_duplex,
  5240. "node:_stream_duplex": [
  5241. ">= 14.18 && < 15",
  5242. ">= 16"
  5243. ],
  5244. _stream_transform: _stream_transform,
  5245. "node:_stream_transform": [
  5246. ">= 14.18 && < 15",
  5247. ">= 16"
  5248. ],
  5249. _stream_wrap: _stream_wrap,
  5250. "node:_stream_wrap": [
  5251. ">= 14.18 && < 15",
  5252. ">= 16"
  5253. ],
  5254. _stream_passthrough: _stream_passthrough,
  5255. "node:_stream_passthrough": [
  5256. ">= 14.18 && < 15",
  5257. ">= 16"
  5258. ],
  5259. _stream_readable: _stream_readable,
  5260. "node:_stream_readable": [
  5261. ">= 14.18 && < 15",
  5262. ">= 16"
  5263. ],
  5264. _stream_writable: _stream_writable,
  5265. "node:_stream_writable": [
  5266. ">= 14.18 && < 15",
  5267. ">= 16"
  5268. ],
  5269. stream: stream,
  5270. "node:stream": [
  5271. ">= 14.18 && < 15",
  5272. ">= 16"
  5273. ],
  5274. "stream/consumers": ">= 16.7",
  5275. "node:stream/consumers": ">= 16.7",
  5276. "stream/promises": ">= 15",
  5277. "node:stream/promises": ">= 16",
  5278. "stream/web": ">= 16.5",
  5279. "node:stream/web": ">= 16.5",
  5280. string_decoder: string_decoder,
  5281. "node:string_decoder": [
  5282. ">= 14.18 && < 15",
  5283. ">= 16"
  5284. ],
  5285. sys: sys,
  5286. "node:sys": [
  5287. ">= 14.18 && < 15",
  5288. ">= 16"
  5289. ],
  5290. "test/reporters": ">= 19.9 && < 20.2",
  5291. "node:test/reporters": [
  5292. ">= 18.17 && < 19",
  5293. ">= 19.9",
  5294. ">= 20"
  5295. ],
  5296. "node:test": [
  5297. ">= 16.17 && < 17",
  5298. ">= 18"
  5299. ],
  5300. timers: timers,
  5301. "node:timers": [
  5302. ">= 14.18 && < 15",
  5303. ">= 16"
  5304. ],
  5305. "timers/promises": ">= 15",
  5306. "node:timers/promises": ">= 16",
  5307. _tls_common: _tls_common,
  5308. "node:_tls_common": [
  5309. ">= 14.18 && < 15",
  5310. ">= 16"
  5311. ],
  5312. _tls_legacy: _tls_legacy,
  5313. _tls_wrap: _tls_wrap,
  5314. "node:_tls_wrap": [
  5315. ">= 14.18 && < 15",
  5316. ">= 16"
  5317. ],
  5318. tls: tls,
  5319. "node:tls": [
  5320. ">= 14.18 && < 15",
  5321. ">= 16"
  5322. ],
  5323. trace_events: trace_events,
  5324. "node:trace_events": [
  5325. ">= 14.18 && < 15",
  5326. ">= 16"
  5327. ],
  5328. tty: tty,
  5329. "node:tty": [
  5330. ">= 14.18 && < 15",
  5331. ">= 16"
  5332. ],
  5333. url: url$1,
  5334. "node:url": [
  5335. ">= 14.18 && < 15",
  5336. ">= 16"
  5337. ],
  5338. util: util$1,
  5339. "node:util": [
  5340. ">= 14.18 && < 15",
  5341. ">= 16"
  5342. ],
  5343. "util/types": ">= 15.3",
  5344. "node:util/types": ">= 16",
  5345. "v8/tools/arguments": ">= 10 && < 12",
  5346. "v8/tools/codemap": [
  5347. ">= 4.4 && < 5",
  5348. ">= 5.2 && < 12"
  5349. ],
  5350. "v8/tools/consarray": [
  5351. ">= 4.4 && < 5",
  5352. ">= 5.2 && < 12"
  5353. ],
  5354. "v8/tools/csvparser": [
  5355. ">= 4.4 && < 5",
  5356. ">= 5.2 && < 12"
  5357. ],
  5358. "v8/tools/logreader": [
  5359. ">= 4.4 && < 5",
  5360. ">= 5.2 && < 12"
  5361. ],
  5362. "v8/tools/profile_view": [
  5363. ">= 4.4 && < 5",
  5364. ">= 5.2 && < 12"
  5365. ],
  5366. "v8/tools/splaytree": [
  5367. ">= 4.4 && < 5",
  5368. ">= 5.2 && < 12"
  5369. ],
  5370. v8: v8,
  5371. "node:v8": [
  5372. ">= 14.18 && < 15",
  5373. ">= 16"
  5374. ],
  5375. vm: vm,
  5376. "node:vm": [
  5377. ">= 14.18 && < 15",
  5378. ">= 16"
  5379. ],
  5380. wasi: wasi,
  5381. "node:wasi": [
  5382. ">= 18.17 && < 19",
  5383. ">= 20"
  5384. ],
  5385. worker_threads: worker_threads,
  5386. "node:worker_threads": [
  5387. ">= 14.18 && < 15",
  5388. ">= 16"
  5389. ],
  5390. zlib: zlib,
  5391. "node:zlib": [
  5392. ">= 14.18 && < 15",
  5393. ">= 16"
  5394. ]
  5395. };
  5396. var hasOwn = hasown;
  5397. function specifierIncluded(current, specifier) {
  5398. var nodeParts = current.split('.');
  5399. var parts = specifier.split(' ');
  5400. var op = parts.length > 1 ? parts[0] : '=';
  5401. var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
  5402. for (var i = 0; i < 3; ++i) {
  5403. var cur = parseInt(nodeParts[i] || 0, 10);
  5404. var ver = parseInt(versionParts[i] || 0, 10);
  5405. if (cur === ver) {
  5406. continue;
  5407. }
  5408. if (op === '<') {
  5409. return cur < ver;
  5410. }
  5411. if (op === '>=') {
  5412. return cur >= ver;
  5413. }
  5414. return false;
  5415. }
  5416. return op === '>=';
  5417. }
  5418. function matchesRange(current, range) {
  5419. var specifiers = range.split(/ ?&& ?/);
  5420. if (specifiers.length === 0) {
  5421. return false;
  5422. }
  5423. for (var i = 0; i < specifiers.length; ++i) {
  5424. if (!specifierIncluded(current, specifiers[i])) {
  5425. return false;
  5426. }
  5427. }
  5428. return true;
  5429. }
  5430. function versionIncluded(nodeVersion, specifierValue) {
  5431. if (typeof specifierValue === 'boolean') {
  5432. return specifierValue;
  5433. }
  5434. var current = typeof nodeVersion === 'undefined'
  5435. ? process.versions && process.versions.node
  5436. : nodeVersion;
  5437. if (typeof current !== 'string') {
  5438. throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
  5439. }
  5440. if (specifierValue && typeof specifierValue === 'object') {
  5441. for (var i = 0; i < specifierValue.length; ++i) {
  5442. if (matchesRange(current, specifierValue[i])) {
  5443. return true;
  5444. }
  5445. }
  5446. return false;
  5447. }
  5448. return matchesRange(current, specifierValue);
  5449. }
  5450. var data = require$$1$1;
  5451. var isCoreModule = function isCore(x, nodeVersion) {
  5452. return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]);
  5453. };
  5454. var extract_description = extractDescription$1;
  5455. function extractDescription$1 (d) {
  5456. if (!d) {
  5457. return
  5458. }
  5459. if (d === 'ERROR: No README data found!') {
  5460. return
  5461. }
  5462. d = d.trim().split('\n');
  5463. let s = 0;
  5464. while (d[s] && d[s].trim().match(/^(#|$)/)) {
  5465. s++;
  5466. }
  5467. const l = d.length;
  5468. let e = s + 1;
  5469. while (e < l && d[e].trim()) {
  5470. e++;
  5471. }
  5472. return d.slice(s, e).join(' ').trim()
  5473. }
  5474. var topLevel = {
  5475. dependancies: "dependencies",
  5476. dependecies: "dependencies",
  5477. depdenencies: "dependencies",
  5478. devEependencies: "devDependencies",
  5479. depends: "dependencies",
  5480. "dev-dependencies": "devDependencies",
  5481. devDependences: "devDependencies",
  5482. devDepenencies: "devDependencies",
  5483. devdependencies: "devDependencies",
  5484. repostitory: "repository",
  5485. repo: "repository",
  5486. prefereGlobal: "preferGlobal",
  5487. hompage: "homepage",
  5488. hampage: "homepage",
  5489. autohr: "author",
  5490. autor: "author",
  5491. contributers: "contributors",
  5492. publicationConfig: "publishConfig",
  5493. script: "scripts"
  5494. };
  5495. var bugs = {
  5496. web: "url",
  5497. name: "url"
  5498. };
  5499. var script = {
  5500. server: "start",
  5501. tests: "test"
  5502. };
  5503. const require$$7 = {
  5504. topLevel: topLevel,
  5505. bugs: bugs,
  5506. script: script
  5507. };
  5508. var isValidSemver = valid_1;
  5509. var cleanSemver = clean_1;
  5510. var validateLicense = validateNpmPackageLicense;
  5511. var hostedGitInfo = lib$3;
  5512. var isBuiltinModule = isCoreModule;
  5513. var depTypes = ['dependencies', 'devDependencies', 'optionalDependencies'];
  5514. var extractDescription = extract_description;
  5515. var url = require$$0;
  5516. var typos = require$$7;
  5517. var isEmail = str => str.includes('@') && (str.indexOf('@') < str.lastIndexOf('.'));
  5518. var fixer$1 = {
  5519. warn: function () {},
  5520. fixRepositoryField: function (data) {
  5521. if (data.repositories) {
  5522. this.warn('repositories');
  5523. data.repository = data.repositories[0];
  5524. }
  5525. if (!data.repository) {
  5526. return this.warn('missingRepository')
  5527. }
  5528. if (typeof data.repository === 'string') {
  5529. data.repository = {
  5530. type: 'git',
  5531. url: data.repository,
  5532. };
  5533. }
  5534. var r = data.repository.url || '';
  5535. if (r) {
  5536. var hosted = hostedGitInfo.fromUrl(r);
  5537. if (hosted) {
  5538. r = data.repository.url
  5539. = hosted.getDefaultRepresentation() === 'shortcut' ? hosted.https() : hosted.toString();
  5540. }
  5541. }
  5542. if (r.match(/github.com\/[^/]+\/[^/]+\.git\.git$/)) {
  5543. this.warn('brokenGitUrl', r);
  5544. }
  5545. },
  5546. fixTypos: function (data) {
  5547. Object.keys(typos.topLevel).forEach(function (d) {
  5548. if (Object.prototype.hasOwnProperty.call(data, d)) {
  5549. this.warn('typo', d, typos.topLevel[d]);
  5550. }
  5551. }, this);
  5552. },
  5553. fixScriptsField: function (data) {
  5554. if (!data.scripts) {
  5555. return
  5556. }
  5557. if (typeof data.scripts !== 'object') {
  5558. this.warn('nonObjectScripts');
  5559. delete data.scripts;
  5560. return
  5561. }
  5562. Object.keys(data.scripts).forEach(function (k) {
  5563. if (typeof data.scripts[k] !== 'string') {
  5564. this.warn('nonStringScript');
  5565. delete data.scripts[k];
  5566. } else if (typos.script[k] && !data.scripts[typos.script[k]]) {
  5567. this.warn('typo', k, typos.script[k], 'scripts');
  5568. }
  5569. }, this);
  5570. },
  5571. fixFilesField: function (data) {
  5572. var files = data.files;
  5573. if (files && !Array.isArray(files)) {
  5574. this.warn('nonArrayFiles');
  5575. delete data.files;
  5576. } else if (data.files) {
  5577. data.files = data.files.filter(function (file) {
  5578. if (!file || typeof file !== 'string') {
  5579. this.warn('invalidFilename', file);
  5580. return false
  5581. } else {
  5582. return true
  5583. }
  5584. }, this);
  5585. }
  5586. },
  5587. fixBinField: function (data) {
  5588. if (!data.bin) {
  5589. return
  5590. }
  5591. if (typeof data.bin === 'string') {
  5592. var b = {};
  5593. var match;
  5594. if (match = data.name.match(/^@[^/]+[/](.*)$/)) {
  5595. b[match[1]] = data.bin;
  5596. } else {
  5597. b[data.name] = data.bin;
  5598. }
  5599. data.bin = b;
  5600. }
  5601. },
  5602. fixManField: function (data) {
  5603. if (!data.man) {
  5604. return
  5605. }
  5606. if (typeof data.man === 'string') {
  5607. data.man = [data.man];
  5608. }
  5609. },
  5610. fixBundleDependenciesField: function (data) {
  5611. var bdd = 'bundledDependencies';
  5612. var bd = 'bundleDependencies';
  5613. if (data[bdd] && !data[bd]) {
  5614. data[bd] = data[bdd];
  5615. delete data[bdd];
  5616. }
  5617. if (data[bd] && !Array.isArray(data[bd])) {
  5618. this.warn('nonArrayBundleDependencies');
  5619. delete data[bd];
  5620. } else if (data[bd]) {
  5621. data[bd] = data[bd].filter(function (filtered) {
  5622. if (!filtered || typeof filtered !== 'string') {
  5623. this.warn('nonStringBundleDependency', filtered);
  5624. return false
  5625. } else {
  5626. if (!data.dependencies) {
  5627. data.dependencies = {};
  5628. }
  5629. if (!Object.prototype.hasOwnProperty.call(data.dependencies, filtered)) {
  5630. this.warn('nonDependencyBundleDependency', filtered);
  5631. data.dependencies[filtered] = '*';
  5632. }
  5633. return true
  5634. }
  5635. }, this);
  5636. }
  5637. },
  5638. fixDependencies: function (data, strict) {
  5639. objectifyDeps(data, this.warn);
  5640. addOptionalDepsToDeps(data, this.warn);
  5641. this.fixBundleDependenciesField(data)
  5642. ;['dependencies', 'devDependencies'].forEach(function (deps) {
  5643. if (!(deps in data)) {
  5644. return
  5645. }
  5646. if (!data[deps] || typeof data[deps] !== 'object') {
  5647. this.warn('nonObjectDependencies', deps);
  5648. delete data[deps];
  5649. return
  5650. }
  5651. Object.keys(data[deps]).forEach(function (d) {
  5652. var r = data[deps][d];
  5653. if (typeof r !== 'string') {
  5654. this.warn('nonStringDependency', d, JSON.stringify(r));
  5655. delete data[deps][d];
  5656. }
  5657. var hosted = hostedGitInfo.fromUrl(data[deps][d]);
  5658. if (hosted) {
  5659. data[deps][d] = hosted.toString();
  5660. }
  5661. }, this);
  5662. }, this);
  5663. },
  5664. fixModulesField: function (data) {
  5665. if (data.modules) {
  5666. this.warn('deprecatedModules');
  5667. delete data.modules;
  5668. }
  5669. },
  5670. fixKeywordsField: function (data) {
  5671. if (typeof data.keywords === 'string') {
  5672. data.keywords = data.keywords.split(/,\s+/);
  5673. }
  5674. if (data.keywords && !Array.isArray(data.keywords)) {
  5675. delete data.keywords;
  5676. this.warn('nonArrayKeywords');
  5677. } else if (data.keywords) {
  5678. data.keywords = data.keywords.filter(function (kw) {
  5679. if (typeof kw !== 'string' || !kw) {
  5680. this.warn('nonStringKeyword');
  5681. return false
  5682. } else {
  5683. return true
  5684. }
  5685. }, this);
  5686. }
  5687. },
  5688. fixVersionField: function (data, strict) {
  5689. var loose = !strict;
  5690. if (!data.version) {
  5691. data.version = '';
  5692. return true
  5693. }
  5694. if (!isValidSemver(data.version, loose)) {
  5695. throw new Error('Invalid version: "' + data.version + '"')
  5696. }
  5697. data.version = cleanSemver(data.version, loose);
  5698. return true
  5699. },
  5700. fixPeople: function (data) {
  5701. modifyPeople(data, unParsePerson);
  5702. modifyPeople(data, parsePerson);
  5703. },
  5704. fixNameField: function (data, options) {
  5705. if (typeof options === 'boolean') {
  5706. options = { strict: options };
  5707. } else if (typeof options === 'undefined') {
  5708. options = {};
  5709. }
  5710. var strict = options.strict;
  5711. if (!data.name && !strict) {
  5712. data.name = '';
  5713. return
  5714. }
  5715. if (typeof data.name !== 'string') {
  5716. throw new Error('name field must be a string.')
  5717. }
  5718. if (!strict) {
  5719. data.name = data.name.trim();
  5720. }
  5721. ensureValidName(data.name, strict, options.allowLegacyCase);
  5722. if (isBuiltinModule(data.name)) {
  5723. this.warn('conflictingName', data.name);
  5724. }
  5725. },
  5726. fixDescriptionField: function (data) {
  5727. if (data.description && typeof data.description !== 'string') {
  5728. this.warn('nonStringDescription');
  5729. delete data.description;
  5730. }
  5731. if (data.readme && !data.description) {
  5732. data.description = extractDescription(data.readme);
  5733. }
  5734. if (data.description === undefined) {
  5735. delete data.description;
  5736. }
  5737. if (!data.description) {
  5738. this.warn('missingDescription');
  5739. }
  5740. },
  5741. fixReadmeField: function (data) {
  5742. if (!data.readme) {
  5743. this.warn('missingReadme');
  5744. data.readme = 'ERROR: No README data found!';
  5745. }
  5746. },
  5747. fixBugsField: function (data) {
  5748. if (!data.bugs && data.repository && data.repository.url) {
  5749. var hosted = hostedGitInfo.fromUrl(data.repository.url);
  5750. if (hosted && hosted.bugs()) {
  5751. data.bugs = { url: hosted.bugs() };
  5752. }
  5753. } else if (data.bugs) {
  5754. if (typeof data.bugs === 'string') {
  5755. if (isEmail(data.bugs)) {
  5756. data.bugs = { email: data.bugs };
  5757. } else if (url.parse(data.bugs).protocol) {
  5758. data.bugs = { url: data.bugs };
  5759. } else {
  5760. this.warn('nonEmailUrlBugsString');
  5761. }
  5762. } else {
  5763. bugsTypos(data.bugs, this.warn);
  5764. var oldBugs = data.bugs;
  5765. data.bugs = {};
  5766. if (oldBugs.url) {
  5767. if (typeof (oldBugs.url) === 'string' && url.parse(oldBugs.url).protocol) {
  5768. data.bugs.url = oldBugs.url;
  5769. } else {
  5770. this.warn('nonUrlBugsUrlField');
  5771. }
  5772. }
  5773. if (oldBugs.email) {
  5774. if (typeof (oldBugs.email) === 'string' && isEmail(oldBugs.email)) {
  5775. data.bugs.email = oldBugs.email;
  5776. } else {
  5777. this.warn('nonEmailBugsEmailField');
  5778. }
  5779. }
  5780. }
  5781. if (!data.bugs.email && !data.bugs.url) {
  5782. delete data.bugs;
  5783. this.warn('emptyNormalizedBugs');
  5784. }
  5785. }
  5786. },
  5787. fixHomepageField: function (data) {
  5788. if (!data.homepage && data.repository && data.repository.url) {
  5789. var hosted = hostedGitInfo.fromUrl(data.repository.url);
  5790. if (hosted && hosted.docs()) {
  5791. data.homepage = hosted.docs();
  5792. }
  5793. }
  5794. if (!data.homepage) {
  5795. return
  5796. }
  5797. if (typeof data.homepage !== 'string') {
  5798. this.warn('nonUrlHomepage');
  5799. return delete data.homepage
  5800. }
  5801. if (!url.parse(data.homepage).protocol) {
  5802. data.homepage = 'http://' + data.homepage;
  5803. }
  5804. },
  5805. fixLicenseField: function (data) {
  5806. const license = data.license || data.licence;
  5807. if (!license) {
  5808. return this.warn('missingLicense')
  5809. }
  5810. if (
  5811. typeof (license) !== 'string' ||
  5812. license.length < 1 ||
  5813. license.trim() === ''
  5814. ) {
  5815. return this.warn('invalidLicense')
  5816. }
  5817. if (!validateLicense(license).validForNewPackages) {
  5818. return this.warn('invalidLicense')
  5819. }
  5820. },
  5821. };
  5822. function isValidScopedPackageName (spec) {
  5823. if (spec.charAt(0) !== '@') {
  5824. return false
  5825. }
  5826. var rest = spec.slice(1).split('/');
  5827. if (rest.length !== 2) {
  5828. return false
  5829. }
  5830. return rest[0] && rest[1] &&
  5831. rest[0] === encodeURIComponent(rest[0]) &&
  5832. rest[1] === encodeURIComponent(rest[1])
  5833. }
  5834. function isCorrectlyEncodedName (spec) {
  5835. return !spec.match(/[/@\s+%:]/) &&
  5836. spec === encodeURIComponent(spec)
  5837. }
  5838. function ensureValidName (name, strict, allowLegacyCase) {
  5839. if (name.charAt(0) === '.' ||
  5840. !(isValidScopedPackageName(name) || isCorrectlyEncodedName(name)) ||
  5841. (strict && (!allowLegacyCase) && name !== name.toLowerCase()) ||
  5842. name.toLowerCase() === 'node_modules' ||
  5843. name.toLowerCase() === 'favicon.ico') {
  5844. throw new Error('Invalid name: ' + JSON.stringify(name))
  5845. }
  5846. }
  5847. function modifyPeople (data, fn) {
  5848. if (data.author) {
  5849. data.author = fn(data.author);
  5850. }['maintainers', 'contributors'].forEach(function (set) {
  5851. if (!Array.isArray(data[set])) {
  5852. return
  5853. }
  5854. data[set] = data[set].map(fn);
  5855. });
  5856. return data
  5857. }
  5858. function unParsePerson (person) {
  5859. if (typeof person === 'string') {
  5860. return person
  5861. }
  5862. var name = person.name || '';
  5863. var u = person.url || person.web;
  5864. var wrappedUrl = u ? (' (' + u + ')') : '';
  5865. var e = person.email || person.mail;
  5866. var wrappedEmail = e ? (' <' + e + '>') : '';
  5867. return name + wrappedEmail + wrappedUrl
  5868. }
  5869. function parsePerson (person) {
  5870. if (typeof person !== 'string') {
  5871. return person
  5872. }
  5873. var matchedName = person.match(/^([^(<]+)/);
  5874. var matchedUrl = person.match(/\(([^()]+)\)/);
  5875. var matchedEmail = person.match(/<([^<>]+)>/);
  5876. var obj = {};
  5877. if (matchedName && matchedName[0].trim()) {
  5878. obj.name = matchedName[0].trim();
  5879. }
  5880. if (matchedEmail) {
  5881. obj.email = matchedEmail[1];
  5882. }
  5883. if (matchedUrl) {
  5884. obj.url = matchedUrl[1];
  5885. }
  5886. return obj
  5887. }
  5888. function addOptionalDepsToDeps (data, warn) {
  5889. var o = data.optionalDependencies;
  5890. if (!o) {
  5891. return
  5892. }
  5893. var d = data.dependencies || {};
  5894. Object.keys(o).forEach(function (k) {
  5895. d[k] = o[k];
  5896. });
  5897. data.dependencies = d;
  5898. }
  5899. function depObjectify (deps, type, warn) {
  5900. if (!deps) {
  5901. return {}
  5902. }
  5903. if (typeof deps === 'string') {
  5904. deps = deps.trim().split(/[\n\r\s\t ,]+/);
  5905. }
  5906. if (!Array.isArray(deps)) {
  5907. return deps
  5908. }
  5909. warn('deprecatedArrayDependencies', type);
  5910. var o = {};
  5911. deps.filter(function (d) {
  5912. return typeof d === 'string'
  5913. }).forEach(function (d) {
  5914. d = d.trim().split(/(:?[@\s><=])/);
  5915. var dn = d.shift();
  5916. var dv = d.join('');
  5917. dv = dv.trim();
  5918. dv = dv.replace(/^@/, '');
  5919. o[dn] = dv;
  5920. });
  5921. return o
  5922. }
  5923. function objectifyDeps (data, warn) {
  5924. depTypes.forEach(function (type) {
  5925. if (!data[type]) {
  5926. return
  5927. }
  5928. data[type] = depObjectify(data[type], type, warn);
  5929. });
  5930. }
  5931. function bugsTypos (bugs, warn) {
  5932. if (!bugs) {
  5933. return
  5934. }
  5935. Object.keys(bugs).forEach(function (k) {
  5936. if (typos.bugs[k]) {
  5937. warn('typo', k, typos.bugs[k], 'bugs');
  5938. bugs[typos.bugs[k]] = bugs[k];
  5939. delete bugs[k];
  5940. }
  5941. });
  5942. }
  5943. var repositories = "'repositories' (plural) Not supported. Please pick one as the 'repository' field";
  5944. var missingRepository = "No repository field.";
  5945. var brokenGitUrl = "Probably broken git url: %s";
  5946. var nonObjectScripts = "scripts must be an object";
  5947. var nonStringScript = "script values must be string commands";
  5948. var nonArrayFiles = "Invalid 'files' member";
  5949. var invalidFilename = "Invalid filename in 'files' list: %s";
  5950. var nonArrayBundleDependencies = "Invalid 'bundleDependencies' list. Must be array of package names";
  5951. var nonStringBundleDependency = "Invalid bundleDependencies member: %s";
  5952. var nonDependencyBundleDependency = "Non-dependency in bundleDependencies: %s";
  5953. var nonObjectDependencies = "%s field must be an object";
  5954. var nonStringDependency = "Invalid dependency: %s %s";
  5955. var deprecatedArrayDependencies = "specifying %s as array is deprecated";
  5956. var deprecatedModules = "modules field is deprecated";
  5957. var nonArrayKeywords = "keywords should be an array of strings";
  5958. var nonStringKeyword = "keywords should be an array of strings";
  5959. var conflictingName = "%s is also the name of a node core module.";
  5960. var nonStringDescription = "'description' field should be a string";
  5961. var missingDescription = "No description";
  5962. var missingReadme = "No README data";
  5963. var missingLicense = "No license field.";
  5964. var nonEmailUrlBugsString = "Bug string field must be url, email, or {email,url}";
  5965. var nonUrlBugsUrlField = "bugs.url field must be a string url. Deleted.";
  5966. var nonEmailBugsEmailField = "bugs.email field must be a string email. Deleted.";
  5967. var emptyNormalizedBugs = "Normalized value of bugs field is an empty object. Deleted.";
  5968. var nonUrlHomepage = "homepage field must be a string url. Deleted.";
  5969. var invalidLicense = "license should be a valid SPDX license expression";
  5970. var typo = "%s should probably be %s.";
  5971. const require$$1 = {
  5972. repositories: repositories,
  5973. missingRepository: missingRepository,
  5974. brokenGitUrl: brokenGitUrl,
  5975. nonObjectScripts: nonObjectScripts,
  5976. nonStringScript: nonStringScript,
  5977. nonArrayFiles: nonArrayFiles,
  5978. invalidFilename: invalidFilename,
  5979. nonArrayBundleDependencies: nonArrayBundleDependencies,
  5980. nonStringBundleDependency: nonStringBundleDependency,
  5981. nonDependencyBundleDependency: nonDependencyBundleDependency,
  5982. nonObjectDependencies: nonObjectDependencies,
  5983. nonStringDependency: nonStringDependency,
  5984. deprecatedArrayDependencies: deprecatedArrayDependencies,
  5985. deprecatedModules: deprecatedModules,
  5986. nonArrayKeywords: nonArrayKeywords,
  5987. nonStringKeyword: nonStringKeyword,
  5988. conflictingName: conflictingName,
  5989. nonStringDescription: nonStringDescription,
  5990. missingDescription: missingDescription,
  5991. missingReadme: missingReadme,
  5992. missingLicense: missingLicense,
  5993. nonEmailUrlBugsString: nonEmailUrlBugsString,
  5994. nonUrlBugsUrlField: nonUrlBugsUrlField,
  5995. nonEmailBugsEmailField: nonEmailBugsEmailField,
  5996. emptyNormalizedBugs: emptyNormalizedBugs,
  5997. nonUrlHomepage: nonUrlHomepage,
  5998. invalidLicense: invalidLicense,
  5999. typo: typo
  6000. };
  6001. var util = require$$0$1;
  6002. var messages = require$$1;
  6003. var make_warning = function () {
  6004. var args = Array.prototype.slice.call(arguments, 0);
  6005. var warningName = args.shift();
  6006. if (warningName === 'typo') {
  6007. return makeTypoWarning.apply(null, args)
  6008. } else {
  6009. var msgTemplate = messages[warningName] ? messages[warningName] : warningName + ": '%s'";
  6010. args.unshift(msgTemplate);
  6011. return util.format.apply(null, args)
  6012. }
  6013. };
  6014. function makeTypoWarning (providedName, probableName, field) {
  6015. if (field) {
  6016. providedName = field + "['" + providedName + "']";
  6017. probableName = field + "['" + probableName + "']";
  6018. }
  6019. return util.format(messages.typo, providedName, probableName)
  6020. }
  6021. var normalize_1 = normalize;
  6022. var fixer = fixer$1;
  6023. normalize.fixer = fixer;
  6024. var makeWarning = make_warning;
  6025. var fieldsToFix = ['name', 'version', 'description', 'repository', 'modules', 'scripts',
  6026. 'files', 'bin', 'man', 'bugs', 'keywords', 'readme', 'homepage', 'license'];
  6027. var otherThingsToFix = ['dependencies', 'people', 'typos'];
  6028. var thingsToFix = fieldsToFix.map(function (fieldName) {
  6029. return ucFirst(fieldName) + 'Field'
  6030. });
  6031. thingsToFix = thingsToFix.concat(otherThingsToFix);
  6032. function normalize (data, warn, strict) {
  6033. if (warn === true) {
  6034. warn = null;
  6035. strict = true;
  6036. }
  6037. if (!strict) {
  6038. strict = false;
  6039. }
  6040. if (!warn || data.private) {
  6041. warn = function (msg) { };
  6042. }
  6043. if (data.scripts &&
  6044. data.scripts.install === 'node-gyp rebuild' &&
  6045. !data.scripts.preinstall) {
  6046. data.gypfile = true;
  6047. }
  6048. fixer.warn = function () {
  6049. warn(makeWarning.apply(null, arguments));
  6050. };
  6051. thingsToFix.forEach(function (thingName) {
  6052. fixer['fix' + ucFirst(thingName)](data, strict);
  6053. });
  6054. data._id = data.name + '@' + data.version;
  6055. }
  6056. function ucFirst (string) {
  6057. return string.charAt(0).toUpperCase() + string.slice(1)
  6058. }
  6059. const normalizePackageData = getDefaultExportFromCjs(normalize_1);
  6060. const toPath$1 = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
  6061. function findUpSync(name, {
  6062. cwd = process$2.cwd(),
  6063. type = 'file',
  6064. stopAt,
  6065. } = {}) {
  6066. let directory = path$1.resolve(toPath$1(cwd) ?? '');
  6067. const {root} = path$1.parse(directory);
  6068. stopAt = path$1.resolve(directory, toPath$1(stopAt) ?? root);
  6069. while (directory && directory !== stopAt && directory !== root) {
  6070. const filePath = path$1.isAbsolute(name) ? name : path$1.join(directory, name);
  6071. try {
  6072. const stats = fs$1.statSync(filePath, {throwIfNoEntry: false});
  6073. if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
  6074. return filePath;
  6075. }
  6076. } catch {}
  6077. directory = path$1.dirname(directory);
  6078. }
  6079. }
  6080. var lib$2 = {};
  6081. var lib$1 = {};
  6082. var jsTokens = {};
  6083. Object.defineProperty(jsTokens, "__esModule", {
  6084. value: true
  6085. });
  6086. jsTokens.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
  6087. jsTokens.matchToToken = function(match) {
  6088. var token = {type: "invalid", value: match[0], closed: undefined};
  6089. if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4]);
  6090. else if (match[ 5]) token.type = "comment";
  6091. else if (match[ 6]) token.type = "comment", token.closed = !!match[7];
  6092. else if (match[ 8]) token.type = "regex";
  6093. else if (match[ 9]) token.type = "number";
  6094. else if (match[10]) token.type = "name";
  6095. else if (match[11]) token.type = "punctuator";
  6096. else if (match[12]) token.type = "whitespace";
  6097. return token
  6098. };
  6099. var lib = {};
  6100. var identifier = {};
  6101. Object.defineProperty(identifier, "__esModule", {
  6102. value: true
  6103. });
  6104. identifier.isIdentifierChar = isIdentifierChar;
  6105. identifier.isIdentifierName = isIdentifierName;
  6106. identifier.isIdentifierStart = isIdentifierStart;
  6107. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  6108. let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
  6109. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  6110. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  6111. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  6112. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
  6113. const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  6114. function isInAstralSet(code, set) {
  6115. let pos = 0x10000;
  6116. for (let i = 0, length = set.length; i < length; i += 2) {
  6117. pos += set[i];
  6118. if (pos > code) return false;
  6119. pos += set[i + 1];
  6120. if (pos >= code) return true;
  6121. }
  6122. return false;
  6123. }
  6124. function isIdentifierStart(code) {
  6125. if (code < 65) return code === 36;
  6126. if (code <= 90) return true;
  6127. if (code < 97) return code === 95;
  6128. if (code <= 122) return true;
  6129. if (code <= 0xffff) {
  6130. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  6131. }
  6132. return isInAstralSet(code, astralIdentifierStartCodes);
  6133. }
  6134. function isIdentifierChar(code) {
  6135. if (code < 48) return code === 36;
  6136. if (code < 58) return true;
  6137. if (code < 65) return false;
  6138. if (code <= 90) return true;
  6139. if (code < 97) return code === 95;
  6140. if (code <= 122) return true;
  6141. if (code <= 0xffff) {
  6142. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  6143. }
  6144. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  6145. }
  6146. function isIdentifierName(name) {
  6147. let isFirst = true;
  6148. for (let i = 0; i < name.length; i++) {
  6149. let cp = name.charCodeAt(i);
  6150. if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
  6151. const trail = name.charCodeAt(++i);
  6152. if ((trail & 0xfc00) === 0xdc00) {
  6153. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  6154. }
  6155. }
  6156. if (isFirst) {
  6157. isFirst = false;
  6158. if (!isIdentifierStart(cp)) {
  6159. return false;
  6160. }
  6161. } else if (!isIdentifierChar(cp)) {
  6162. return false;
  6163. }
  6164. }
  6165. return !isFirst;
  6166. }
  6167. var keyword = {};
  6168. Object.defineProperty(keyword, "__esModule", {
  6169. value: true
  6170. });
  6171. keyword.isKeyword = isKeyword;
  6172. keyword.isReservedWord = isReservedWord;
  6173. keyword.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
  6174. keyword.isStrictBindReservedWord = isStrictBindReservedWord;
  6175. keyword.isStrictReservedWord = isStrictReservedWord;
  6176. const reservedWords = {
  6177. keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
  6178. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  6179. strictBind: ["eval", "arguments"]
  6180. };
  6181. const keywords = new Set(reservedWords.keyword);
  6182. const reservedWordsStrictSet = new Set(reservedWords.strict);
  6183. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  6184. function isReservedWord(word, inModule) {
  6185. return inModule && word === "await" || word === "enum";
  6186. }
  6187. function isStrictReservedWord(word, inModule) {
  6188. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  6189. }
  6190. function isStrictBindOnlyReservedWord(word) {
  6191. return reservedWordsStrictBindSet.has(word);
  6192. }
  6193. function isStrictBindReservedWord(word, inModule) {
  6194. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  6195. }
  6196. function isKeyword(word) {
  6197. return keywords.has(word);
  6198. }
  6199. (function (exports) {
  6200. Object.defineProperty(exports, "__esModule", {
  6201. value: true
  6202. });
  6203. Object.defineProperty(exports, "isIdentifierChar", {
  6204. enumerable: true,
  6205. get: function () {
  6206. return _identifier.isIdentifierChar;
  6207. }
  6208. });
  6209. Object.defineProperty(exports, "isIdentifierName", {
  6210. enumerable: true,
  6211. get: function () {
  6212. return _identifier.isIdentifierName;
  6213. }
  6214. });
  6215. Object.defineProperty(exports, "isIdentifierStart", {
  6216. enumerable: true,
  6217. get: function () {
  6218. return _identifier.isIdentifierStart;
  6219. }
  6220. });
  6221. Object.defineProperty(exports, "isKeyword", {
  6222. enumerable: true,
  6223. get: function () {
  6224. return _keyword.isKeyword;
  6225. }
  6226. });
  6227. Object.defineProperty(exports, "isReservedWord", {
  6228. enumerable: true,
  6229. get: function () {
  6230. return _keyword.isReservedWord;
  6231. }
  6232. });
  6233. Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
  6234. enumerable: true,
  6235. get: function () {
  6236. return _keyword.isStrictBindOnlyReservedWord;
  6237. }
  6238. });
  6239. Object.defineProperty(exports, "isStrictBindReservedWord", {
  6240. enumerable: true,
  6241. get: function () {
  6242. return _keyword.isStrictBindReservedWord;
  6243. }
  6244. });
  6245. Object.defineProperty(exports, "isStrictReservedWord", {
  6246. enumerable: true,
  6247. get: function () {
  6248. return _keyword.isStrictReservedWord;
  6249. }
  6250. });
  6251. var _identifier = identifier;
  6252. var _keyword = keyword;
  6253. } (lib));
  6254. var chalk$1 = {exports: {}};
  6255. var matchOperatorsRe$1 = /[|\\{}()[\]^$+*?.]/g;
  6256. var escapeStringRegexp$1 = function (str) {
  6257. if (typeof str !== 'string') {
  6258. throw new TypeError('Expected a string');
  6259. }
  6260. return str.replace(matchOperatorsRe$1, '\\$&');
  6261. };
  6262. var ansiStyles$1 = {exports: {}};
  6263. var conversions$2 = {exports: {}};
  6264. var colorName = { "aliceblue": [240, 248, 255], "antiquewhite": [250, 235, 215], "aqua": [0, 255, 255], "aquamarine": [127, 255, 212], "azure": [240, 255, 255], "beige": [245, 245, 220], "bisque": [255, 228, 196], "black": [0, 0, 0], "blanchedalmond": [255, 235, 205], "blue": [0, 0, 255], "blueviolet": [138, 43, 226], "brown": [165, 42, 42], "burlywood": [222, 184, 135], "cadetblue": [95, 158, 160], "chartreuse": [127, 255, 0], "chocolate": [210, 105, 30], "coral": [255, 127, 80], "cornflowerblue": [100, 149, 237], "cornsilk": [255, 248, 220], "crimson": [220, 20, 60], "cyan": [0, 255, 255], "darkblue": [0, 0, 139], "darkcyan": [0, 139, 139], "darkgoldenrod": [184, 134, 11], "darkgray": [169, 169, 169], "darkgreen": [0, 100, 0], "darkgrey": [169, 169, 169], "darkkhaki": [189, 183, 107], "darkmagenta": [139, 0, 139], "darkolivegreen": [85, 107, 47], "darkorange": [255, 140, 0], "darkorchid": [153, 50, 204], "darkred": [139, 0, 0], "darksalmon": [233, 150, 122], "darkseagreen": [143, 188, 143], "darkslateblue": [72, 61, 139], "darkslategray": [47, 79, 79], "darkslategrey": [47, 79, 79], "darkturquoise": [0, 206, 209], "darkviolet": [148, 0, 211], "deeppink": [255, 20, 147], "deepskyblue": [0, 191, 255], "dimgray": [105, 105, 105], "dimgrey": [105, 105, 105], "dodgerblue": [30, 144, 255], "firebrick": [178, 34, 34], "floralwhite": [255, 250, 240], "forestgreen": [34, 139, 34], "fuchsia": [255, 0, 255], "gainsboro": [220, 220, 220], "ghostwhite": [248, 248, 255], "gold": [255, 215, 0], "goldenrod": [218, 165, 32], "gray": [128, 128, 128], "green": [0, 128, 0], "greenyellow": [173, 255, 47], "grey": [128, 128, 128], "honeydew": [240, 255, 240], "hotpink": [255, 105, 180], "indianred": [205, 92, 92], "indigo": [75, 0, 130], "ivory": [255, 255, 240], "khaki": [240, 230, 140], "lavender": [230, 230, 250], "lavenderblush": [255, 240, 245], "lawngreen": [124, 252, 0], "lemonchiffon": [255, 250, 205], "lightblue": [173, 216, 230], "lightcoral": [240, 128, 128], "lightcyan": [224, 255, 255], "lightgoldenrodyellow": [250, 250, 210], "lightgray": [211, 211, 211], "lightgreen": [144, 238, 144], "lightgrey": [211, 211, 211], "lightpink": [255, 182, 193], "lightsalmon": [255, 160, 122], "lightseagreen": [32, 178, 170], "lightskyblue": [135, 206, 250], "lightslategray": [119, 136, 153], "lightslategrey": [119, 136, 153], "lightsteelblue": [176, 196, 222], "lightyellow": [255, 255, 224], "lime": [0, 255, 0], "limegreen": [50, 205, 50], "linen": [250, 240, 230], "magenta": [255, 0, 255], "maroon": [128, 0, 0], "mediumaquamarine": [102, 205, 170], "mediumblue": [0, 0, 205], "mediumorchid": [186, 85, 211], "mediumpurple": [147, 112, 219], "mediumseagreen": [60, 179, 113], "mediumslateblue": [123, 104, 238], "mediumspringgreen": [0, 250, 154], "mediumturquoise": [72, 209, 204], "mediumvioletred": [199, 21, 133], "midnightblue": [25, 25, 112], "mintcream": [245, 255, 250], "mistyrose": [255, 228, 225], "moccasin": [255, 228, 181], "navajowhite": [255, 222, 173], "navy": [0, 0, 128], "oldlace": [253, 245, 230], "olive": [128, 128, 0], "olivedrab": [107, 142, 35], "orange": [255, 165, 0], "orangered": [255, 69, 0], "orchid": [218, 112, 214], "palegoldenrod": [238, 232, 170], "palegreen": [152, 251, 152], "paleturquoise": [175, 238, 238], "palevioletred": [219, 112, 147], "papayawhip": [255, 239, 213], "peachpuff": [255, 218, 185], "peru": [205, 133, 63], "pink": [255, 192, 203], "plum": [221, 160, 221], "powderblue": [176, 224, 230], "purple": [128, 0, 128], "rebeccapurple": [102, 51, 153], "red": [255, 0, 0], "rosybrown": [188, 143, 143], "royalblue": [65, 105, 225], "saddlebrown": [139, 69, 19], "salmon": [250, 128, 114], "sandybrown": [244, 164, 96], "seagreen": [46, 139, 87], "seashell": [255, 245, 238], "sienna": [160, 82, 45], "silver": [192, 192, 192], "skyblue": [135, 206, 235], "slateblue": [106, 90, 205], "slategray": [112, 128, 144], "slategrey": [112, 128, 144], "snow": [255, 250, 250], "springgreen": [0, 255, 127], "steelblue": [70, 130, 180], "tan": [210, 180, 140], "teal": [0, 128, 128], "thistle": [216, 191, 216], "tomato": [255, 99, 71], "turquoise": [64, 224, 208], "violet": [238, 130, 238], "wheat": [245, 222, 179], "white": [255, 255, 255], "whitesmoke": [245, 245, 245], "yellow": [255, 255, 0], "yellowgreen": [154, 205, 50] };
  6265. var cssKeywords = colorName;
  6266. var reverseKeywords = {};
  6267. for (var key in cssKeywords) {
  6268. if (cssKeywords.hasOwnProperty(key)) {
  6269. reverseKeywords[cssKeywords[key]] = key;
  6270. }
  6271. }
  6272. var convert$1 = conversions$2.exports = {
  6273. rgb: {channels: 3, labels: 'rgb'},
  6274. hsl: {channels: 3, labels: 'hsl'},
  6275. hsv: {channels: 3, labels: 'hsv'},
  6276. hwb: {channels: 3, labels: 'hwb'},
  6277. cmyk: {channels: 4, labels: 'cmyk'},
  6278. xyz: {channels: 3, labels: 'xyz'},
  6279. lab: {channels: 3, labels: 'lab'},
  6280. lch: {channels: 3, labels: 'lch'},
  6281. hex: {channels: 1, labels: ['hex']},
  6282. keyword: {channels: 1, labels: ['keyword']},
  6283. ansi16: {channels: 1, labels: ['ansi16']},
  6284. ansi256: {channels: 1, labels: ['ansi256']},
  6285. hcg: {channels: 3, labels: ['h', 'c', 'g']},
  6286. apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
  6287. gray: {channels: 1, labels: ['gray']}
  6288. };
  6289. for (var model in convert$1) {
  6290. if (convert$1.hasOwnProperty(model)) {
  6291. if (!('channels' in convert$1[model])) {
  6292. throw new Error('missing channels property: ' + model);
  6293. }
  6294. if (!('labels' in convert$1[model])) {
  6295. throw new Error('missing channel labels property: ' + model);
  6296. }
  6297. if (convert$1[model].labels.length !== convert$1[model].channels) {
  6298. throw new Error('channel and label counts mismatch: ' + model);
  6299. }
  6300. var channels = convert$1[model].channels;
  6301. var labels = convert$1[model].labels;
  6302. delete convert$1[model].channels;
  6303. delete convert$1[model].labels;
  6304. Object.defineProperty(convert$1[model], 'channels', {value: channels});
  6305. Object.defineProperty(convert$1[model], 'labels', {value: labels});
  6306. }
  6307. }
  6308. convert$1.rgb.hsl = function (rgb) {
  6309. var r = rgb[0] / 255;
  6310. var g = rgb[1] / 255;
  6311. var b = rgb[2] / 255;
  6312. var min = Math.min(r, g, b);
  6313. var max = Math.max(r, g, b);
  6314. var delta = max - min;
  6315. var h;
  6316. var s;
  6317. var l;
  6318. if (max === min) {
  6319. h = 0;
  6320. } else if (r === max) {
  6321. h = (g - b) / delta;
  6322. } else if (g === max) {
  6323. h = 2 + (b - r) / delta;
  6324. } else if (b === max) {
  6325. h = 4 + (r - g) / delta;
  6326. }
  6327. h = Math.min(h * 60, 360);
  6328. if (h < 0) {
  6329. h += 360;
  6330. }
  6331. l = (min + max) / 2;
  6332. if (max === min) {
  6333. s = 0;
  6334. } else if (l <= 0.5) {
  6335. s = delta / (max + min);
  6336. } else {
  6337. s = delta / (2 - max - min);
  6338. }
  6339. return [h, s * 100, l * 100];
  6340. };
  6341. convert$1.rgb.hsv = function (rgb) {
  6342. var rdif;
  6343. var gdif;
  6344. var bdif;
  6345. var h;
  6346. var s;
  6347. var r = rgb[0] / 255;
  6348. var g = rgb[1] / 255;
  6349. var b = rgb[2] / 255;
  6350. var v = Math.max(r, g, b);
  6351. var diff = v - Math.min(r, g, b);
  6352. var diffc = function (c) {
  6353. return (v - c) / 6 / diff + 1 / 2;
  6354. };
  6355. if (diff === 0) {
  6356. h = s = 0;
  6357. } else {
  6358. s = diff / v;
  6359. rdif = diffc(r);
  6360. gdif = diffc(g);
  6361. bdif = diffc(b);
  6362. if (r === v) {
  6363. h = bdif - gdif;
  6364. } else if (g === v) {
  6365. h = (1 / 3) + rdif - bdif;
  6366. } else if (b === v) {
  6367. h = (2 / 3) + gdif - rdif;
  6368. }
  6369. if (h < 0) {
  6370. h += 1;
  6371. } else if (h > 1) {
  6372. h -= 1;
  6373. }
  6374. }
  6375. return [
  6376. h * 360,
  6377. s * 100,
  6378. v * 100
  6379. ];
  6380. };
  6381. convert$1.rgb.hwb = function (rgb) {
  6382. var r = rgb[0];
  6383. var g = rgb[1];
  6384. var b = rgb[2];
  6385. var h = convert$1.rgb.hsl(rgb)[0];
  6386. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  6387. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  6388. return [h, w * 100, b * 100];
  6389. };
  6390. convert$1.rgb.cmyk = function (rgb) {
  6391. var r = rgb[0] / 255;
  6392. var g = rgb[1] / 255;
  6393. var b = rgb[2] / 255;
  6394. var c;
  6395. var m;
  6396. var y;
  6397. var k;
  6398. k = Math.min(1 - r, 1 - g, 1 - b);
  6399. c = (1 - r - k) / (1 - k) || 0;
  6400. m = (1 - g - k) / (1 - k) || 0;
  6401. y = (1 - b - k) / (1 - k) || 0;
  6402. return [c * 100, m * 100, y * 100, k * 100];
  6403. };
  6404. function comparativeDistance(x, y) {
  6405. return (
  6406. Math.pow(x[0] - y[0], 2) +
  6407. Math.pow(x[1] - y[1], 2) +
  6408. Math.pow(x[2] - y[2], 2)
  6409. );
  6410. }
  6411. convert$1.rgb.keyword = function (rgb) {
  6412. var reversed = reverseKeywords[rgb];
  6413. if (reversed) {
  6414. return reversed;
  6415. }
  6416. var currentClosestDistance = Infinity;
  6417. var currentClosestKeyword;
  6418. for (var keyword in cssKeywords) {
  6419. if (cssKeywords.hasOwnProperty(keyword)) {
  6420. var value = cssKeywords[keyword];
  6421. var distance = comparativeDistance(rgb, value);
  6422. if (distance < currentClosestDistance) {
  6423. currentClosestDistance = distance;
  6424. currentClosestKeyword = keyword;
  6425. }
  6426. }
  6427. }
  6428. return currentClosestKeyword;
  6429. };
  6430. convert$1.keyword.rgb = function (keyword) {
  6431. return cssKeywords[keyword];
  6432. };
  6433. convert$1.rgb.xyz = function (rgb) {
  6434. var r = rgb[0] / 255;
  6435. var g = rgb[1] / 255;
  6436. var b = rgb[2] / 255;
  6437. r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
  6438. g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
  6439. b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
  6440. var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  6441. var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  6442. var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  6443. return [x * 100, y * 100, z * 100];
  6444. };
  6445. convert$1.rgb.lab = function (rgb) {
  6446. var xyz = convert$1.rgb.xyz(rgb);
  6447. var x = xyz[0];
  6448. var y = xyz[1];
  6449. var z = xyz[2];
  6450. var l;
  6451. var a;
  6452. var b;
  6453. x /= 95.047;
  6454. y /= 100;
  6455. z /= 108.883;
  6456. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  6457. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  6458. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  6459. l = (116 * y) - 16;
  6460. a = 500 * (x - y);
  6461. b = 200 * (y - z);
  6462. return [l, a, b];
  6463. };
  6464. convert$1.hsl.rgb = function (hsl) {
  6465. var h = hsl[0] / 360;
  6466. var s = hsl[1] / 100;
  6467. var l = hsl[2] / 100;
  6468. var t1;
  6469. var t2;
  6470. var t3;
  6471. var rgb;
  6472. var val;
  6473. if (s === 0) {
  6474. val = l * 255;
  6475. return [val, val, val];
  6476. }
  6477. if (l < 0.5) {
  6478. t2 = l * (1 + s);
  6479. } else {
  6480. t2 = l + s - l * s;
  6481. }
  6482. t1 = 2 * l - t2;
  6483. rgb = [0, 0, 0];
  6484. for (var i = 0; i < 3; i++) {
  6485. t3 = h + 1 / 3 * -(i - 1);
  6486. if (t3 < 0) {
  6487. t3++;
  6488. }
  6489. if (t3 > 1) {
  6490. t3--;
  6491. }
  6492. if (6 * t3 < 1) {
  6493. val = t1 + (t2 - t1) * 6 * t3;
  6494. } else if (2 * t3 < 1) {
  6495. val = t2;
  6496. } else if (3 * t3 < 2) {
  6497. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  6498. } else {
  6499. val = t1;
  6500. }
  6501. rgb[i] = val * 255;
  6502. }
  6503. return rgb;
  6504. };
  6505. convert$1.hsl.hsv = function (hsl) {
  6506. var h = hsl[0];
  6507. var s = hsl[1] / 100;
  6508. var l = hsl[2] / 100;
  6509. var smin = s;
  6510. var lmin = Math.max(l, 0.01);
  6511. var sv;
  6512. var v;
  6513. l *= 2;
  6514. s *= (l <= 1) ? l : 2 - l;
  6515. smin *= lmin <= 1 ? lmin : 2 - lmin;
  6516. v = (l + s) / 2;
  6517. sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
  6518. return [h, sv * 100, v * 100];
  6519. };
  6520. convert$1.hsv.rgb = function (hsv) {
  6521. var h = hsv[0] / 60;
  6522. var s = hsv[1] / 100;
  6523. var v = hsv[2] / 100;
  6524. var hi = Math.floor(h) % 6;
  6525. var f = h - Math.floor(h);
  6526. var p = 255 * v * (1 - s);
  6527. var q = 255 * v * (1 - (s * f));
  6528. var t = 255 * v * (1 - (s * (1 - f)));
  6529. v *= 255;
  6530. switch (hi) {
  6531. case 0:
  6532. return [v, t, p];
  6533. case 1:
  6534. return [q, v, p];
  6535. case 2:
  6536. return [p, v, t];
  6537. case 3:
  6538. return [p, q, v];
  6539. case 4:
  6540. return [t, p, v];
  6541. case 5:
  6542. return [v, p, q];
  6543. }
  6544. };
  6545. convert$1.hsv.hsl = function (hsv) {
  6546. var h = hsv[0];
  6547. var s = hsv[1] / 100;
  6548. var v = hsv[2] / 100;
  6549. var vmin = Math.max(v, 0.01);
  6550. var lmin;
  6551. var sl;
  6552. var l;
  6553. l = (2 - s) * v;
  6554. lmin = (2 - s) * vmin;
  6555. sl = s * vmin;
  6556. sl /= (lmin <= 1) ? lmin : 2 - lmin;
  6557. sl = sl || 0;
  6558. l /= 2;
  6559. return [h, sl * 100, l * 100];
  6560. };
  6561. convert$1.hwb.rgb = function (hwb) {
  6562. var h = hwb[0] / 360;
  6563. var wh = hwb[1] / 100;
  6564. var bl = hwb[2] / 100;
  6565. var ratio = wh + bl;
  6566. var i;
  6567. var v;
  6568. var f;
  6569. var n;
  6570. if (ratio > 1) {
  6571. wh /= ratio;
  6572. bl /= ratio;
  6573. }
  6574. i = Math.floor(6 * h);
  6575. v = 1 - bl;
  6576. f = 6 * h - i;
  6577. if ((i & 0x01) !== 0) {
  6578. f = 1 - f;
  6579. }
  6580. n = wh + f * (v - wh);
  6581. var r;
  6582. var g;
  6583. var b;
  6584. switch (i) {
  6585. default:
  6586. case 6:
  6587. case 0: r = v; g = n; b = wh; break;
  6588. case 1: r = n; g = v; b = wh; break;
  6589. case 2: r = wh; g = v; b = n; break;
  6590. case 3: r = wh; g = n; b = v; break;
  6591. case 4: r = n; g = wh; b = v; break;
  6592. case 5: r = v; g = wh; b = n; break;
  6593. }
  6594. return [r * 255, g * 255, b * 255];
  6595. };
  6596. convert$1.cmyk.rgb = function (cmyk) {
  6597. var c = cmyk[0] / 100;
  6598. var m = cmyk[1] / 100;
  6599. var y = cmyk[2] / 100;
  6600. var k = cmyk[3] / 100;
  6601. var r;
  6602. var g;
  6603. var b;
  6604. r = 1 - Math.min(1, c * (1 - k) + k);
  6605. g = 1 - Math.min(1, m * (1 - k) + k);
  6606. b = 1 - Math.min(1, y * (1 - k) + k);
  6607. return [r * 255, g * 255, b * 255];
  6608. };
  6609. convert$1.xyz.rgb = function (xyz) {
  6610. var x = xyz[0] / 100;
  6611. var y = xyz[1] / 100;
  6612. var z = xyz[2] / 100;
  6613. var r;
  6614. var g;
  6615. var b;
  6616. r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  6617. g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  6618. b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  6619. r = r > 0.0031308
  6620. ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
  6621. : r * 12.92;
  6622. g = g > 0.0031308
  6623. ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
  6624. : g * 12.92;
  6625. b = b > 0.0031308
  6626. ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
  6627. : b * 12.92;
  6628. r = Math.min(Math.max(0, r), 1);
  6629. g = Math.min(Math.max(0, g), 1);
  6630. b = Math.min(Math.max(0, b), 1);
  6631. return [r * 255, g * 255, b * 255];
  6632. };
  6633. convert$1.xyz.lab = function (xyz) {
  6634. var x = xyz[0];
  6635. var y = xyz[1];
  6636. var z = xyz[2];
  6637. var l;
  6638. var a;
  6639. var b;
  6640. x /= 95.047;
  6641. y /= 100;
  6642. z /= 108.883;
  6643. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  6644. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  6645. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  6646. l = (116 * y) - 16;
  6647. a = 500 * (x - y);
  6648. b = 200 * (y - z);
  6649. return [l, a, b];
  6650. };
  6651. convert$1.lab.xyz = function (lab) {
  6652. var l = lab[0];
  6653. var a = lab[1];
  6654. var b = lab[2];
  6655. var x;
  6656. var y;
  6657. var z;
  6658. y = (l + 16) / 116;
  6659. x = a / 500 + y;
  6660. z = y - b / 200;
  6661. var y2 = Math.pow(y, 3);
  6662. var x2 = Math.pow(x, 3);
  6663. var z2 = Math.pow(z, 3);
  6664. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  6665. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  6666. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  6667. x *= 95.047;
  6668. y *= 100;
  6669. z *= 108.883;
  6670. return [x, y, z];
  6671. };
  6672. convert$1.lab.lch = function (lab) {
  6673. var l = lab[0];
  6674. var a = lab[1];
  6675. var b = lab[2];
  6676. var hr;
  6677. var h;
  6678. var c;
  6679. hr = Math.atan2(b, a);
  6680. h = hr * 360 / 2 / Math.PI;
  6681. if (h < 0) {
  6682. h += 360;
  6683. }
  6684. c = Math.sqrt(a * a + b * b);
  6685. return [l, c, h];
  6686. };
  6687. convert$1.lch.lab = function (lch) {
  6688. var l = lch[0];
  6689. var c = lch[1];
  6690. var h = lch[2];
  6691. var a;
  6692. var b;
  6693. var hr;
  6694. hr = h / 360 * 2 * Math.PI;
  6695. a = c * Math.cos(hr);
  6696. b = c * Math.sin(hr);
  6697. return [l, a, b];
  6698. };
  6699. convert$1.rgb.ansi16 = function (args) {
  6700. var r = args[0];
  6701. var g = args[1];
  6702. var b = args[2];
  6703. var value = 1 in arguments ? arguments[1] : convert$1.rgb.hsv(args)[2];
  6704. value = Math.round(value / 50);
  6705. if (value === 0) {
  6706. return 30;
  6707. }
  6708. var ansi = 30
  6709. + ((Math.round(b / 255) << 2)
  6710. | (Math.round(g / 255) << 1)
  6711. | Math.round(r / 255));
  6712. if (value === 2) {
  6713. ansi += 60;
  6714. }
  6715. return ansi;
  6716. };
  6717. convert$1.hsv.ansi16 = function (args) {
  6718. return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
  6719. };
  6720. convert$1.rgb.ansi256 = function (args) {
  6721. var r = args[0];
  6722. var g = args[1];
  6723. var b = args[2];
  6724. if (r === g && g === b) {
  6725. if (r < 8) {
  6726. return 16;
  6727. }
  6728. if (r > 248) {
  6729. return 231;
  6730. }
  6731. return Math.round(((r - 8) / 247) * 24) + 232;
  6732. }
  6733. var ansi = 16
  6734. + (36 * Math.round(r / 255 * 5))
  6735. + (6 * Math.round(g / 255 * 5))
  6736. + Math.round(b / 255 * 5);
  6737. return ansi;
  6738. };
  6739. convert$1.ansi16.rgb = function (args) {
  6740. var color = args % 10;
  6741. if (color === 0 || color === 7) {
  6742. if (args > 50) {
  6743. color += 3.5;
  6744. }
  6745. color = color / 10.5 * 255;
  6746. return [color, color, color];
  6747. }
  6748. var mult = (~~(args > 50) + 1) * 0.5;
  6749. var r = ((color & 1) * mult) * 255;
  6750. var g = (((color >> 1) & 1) * mult) * 255;
  6751. var b = (((color >> 2) & 1) * mult) * 255;
  6752. return [r, g, b];
  6753. };
  6754. convert$1.ansi256.rgb = function (args) {
  6755. if (args >= 232) {
  6756. var c = (args - 232) * 10 + 8;
  6757. return [c, c, c];
  6758. }
  6759. args -= 16;
  6760. var rem;
  6761. var r = Math.floor(args / 36) / 5 * 255;
  6762. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  6763. var b = (rem % 6) / 5 * 255;
  6764. return [r, g, b];
  6765. };
  6766. convert$1.rgb.hex = function (args) {
  6767. var integer = ((Math.round(args[0]) & 0xFF) << 16)
  6768. + ((Math.round(args[1]) & 0xFF) << 8)
  6769. + (Math.round(args[2]) & 0xFF);
  6770. var string = integer.toString(16).toUpperCase();
  6771. return '000000'.substring(string.length) + string;
  6772. };
  6773. convert$1.hex.rgb = function (args) {
  6774. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  6775. if (!match) {
  6776. return [0, 0, 0];
  6777. }
  6778. var colorString = match[0];
  6779. if (match[0].length === 3) {
  6780. colorString = colorString.split('').map(function (char) {
  6781. return char + char;
  6782. }).join('');
  6783. }
  6784. var integer = parseInt(colorString, 16);
  6785. var r = (integer >> 16) & 0xFF;
  6786. var g = (integer >> 8) & 0xFF;
  6787. var b = integer & 0xFF;
  6788. return [r, g, b];
  6789. };
  6790. convert$1.rgb.hcg = function (rgb) {
  6791. var r = rgb[0] / 255;
  6792. var g = rgb[1] / 255;
  6793. var b = rgb[2] / 255;
  6794. var max = Math.max(Math.max(r, g), b);
  6795. var min = Math.min(Math.min(r, g), b);
  6796. var chroma = (max - min);
  6797. var grayscale;
  6798. var hue;
  6799. if (chroma < 1) {
  6800. grayscale = min / (1 - chroma);
  6801. } else {
  6802. grayscale = 0;
  6803. }
  6804. if (chroma <= 0) {
  6805. hue = 0;
  6806. } else
  6807. if (max === r) {
  6808. hue = ((g - b) / chroma) % 6;
  6809. } else
  6810. if (max === g) {
  6811. hue = 2 + (b - r) / chroma;
  6812. } else {
  6813. hue = 4 + (r - g) / chroma + 4;
  6814. }
  6815. hue /= 6;
  6816. hue %= 1;
  6817. return [hue * 360, chroma * 100, grayscale * 100];
  6818. };
  6819. convert$1.hsl.hcg = function (hsl) {
  6820. var s = hsl[1] / 100;
  6821. var l = hsl[2] / 100;
  6822. var c = 1;
  6823. var f = 0;
  6824. if (l < 0.5) {
  6825. c = 2.0 * s * l;
  6826. } else {
  6827. c = 2.0 * s * (1.0 - l);
  6828. }
  6829. if (c < 1.0) {
  6830. f = (l - 0.5 * c) / (1.0 - c);
  6831. }
  6832. return [hsl[0], c * 100, f * 100];
  6833. };
  6834. convert$1.hsv.hcg = function (hsv) {
  6835. var s = hsv[1] / 100;
  6836. var v = hsv[2] / 100;
  6837. var c = s * v;
  6838. var f = 0;
  6839. if (c < 1.0) {
  6840. f = (v - c) / (1 - c);
  6841. }
  6842. return [hsv[0], c * 100, f * 100];
  6843. };
  6844. convert$1.hcg.rgb = function (hcg) {
  6845. var h = hcg[0] / 360;
  6846. var c = hcg[1] / 100;
  6847. var g = hcg[2] / 100;
  6848. if (c === 0.0) {
  6849. return [g * 255, g * 255, g * 255];
  6850. }
  6851. var pure = [0, 0, 0];
  6852. var hi = (h % 1) * 6;
  6853. var v = hi % 1;
  6854. var w = 1 - v;
  6855. var mg = 0;
  6856. switch (Math.floor(hi)) {
  6857. case 0:
  6858. pure[0] = 1; pure[1] = v; pure[2] = 0; break;
  6859. case 1:
  6860. pure[0] = w; pure[1] = 1; pure[2] = 0; break;
  6861. case 2:
  6862. pure[0] = 0; pure[1] = 1; pure[2] = v; break;
  6863. case 3:
  6864. pure[0] = 0; pure[1] = w; pure[2] = 1; break;
  6865. case 4:
  6866. pure[0] = v; pure[1] = 0; pure[2] = 1; break;
  6867. default:
  6868. pure[0] = 1; pure[1] = 0; pure[2] = w;
  6869. }
  6870. mg = (1.0 - c) * g;
  6871. return [
  6872. (c * pure[0] + mg) * 255,
  6873. (c * pure[1] + mg) * 255,
  6874. (c * pure[2] + mg) * 255
  6875. ];
  6876. };
  6877. convert$1.hcg.hsv = function (hcg) {
  6878. var c = hcg[1] / 100;
  6879. var g = hcg[2] / 100;
  6880. var v = c + g * (1.0 - c);
  6881. var f = 0;
  6882. if (v > 0.0) {
  6883. f = c / v;
  6884. }
  6885. return [hcg[0], f * 100, v * 100];
  6886. };
  6887. convert$1.hcg.hsl = function (hcg) {
  6888. var c = hcg[1] / 100;
  6889. var g = hcg[2] / 100;
  6890. var l = g * (1.0 - c) + 0.5 * c;
  6891. var s = 0;
  6892. if (l > 0.0 && l < 0.5) {
  6893. s = c / (2 * l);
  6894. } else
  6895. if (l >= 0.5 && l < 1.0) {
  6896. s = c / (2 * (1 - l));
  6897. }
  6898. return [hcg[0], s * 100, l * 100];
  6899. };
  6900. convert$1.hcg.hwb = function (hcg) {
  6901. var c = hcg[1] / 100;
  6902. var g = hcg[2] / 100;
  6903. var v = c + g * (1.0 - c);
  6904. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  6905. };
  6906. convert$1.hwb.hcg = function (hwb) {
  6907. var w = hwb[1] / 100;
  6908. var b = hwb[2] / 100;
  6909. var v = 1 - b;
  6910. var c = v - w;
  6911. var g = 0;
  6912. if (c < 1) {
  6913. g = (v - c) / (1 - c);
  6914. }
  6915. return [hwb[0], c * 100, g * 100];
  6916. };
  6917. convert$1.apple.rgb = function (apple) {
  6918. return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
  6919. };
  6920. convert$1.rgb.apple = function (rgb) {
  6921. return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
  6922. };
  6923. convert$1.gray.rgb = function (args) {
  6924. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  6925. };
  6926. convert$1.gray.hsl = convert$1.gray.hsv = function (args) {
  6927. return [0, 0, args[0]];
  6928. };
  6929. convert$1.gray.hwb = function (gray) {
  6930. return [0, 100, gray[0]];
  6931. };
  6932. convert$1.gray.cmyk = function (gray) {
  6933. return [0, 0, 0, gray[0]];
  6934. };
  6935. convert$1.gray.lab = function (gray) {
  6936. return [gray[0], 0, 0];
  6937. };
  6938. convert$1.gray.hex = function (gray) {
  6939. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  6940. var integer = (val << 16) + (val << 8) + val;
  6941. var string = integer.toString(16).toUpperCase();
  6942. return '000000'.substring(string.length) + string;
  6943. };
  6944. convert$1.rgb.gray = function (rgb) {
  6945. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  6946. return [val / 255 * 100];
  6947. };
  6948. var conversionsExports = conversions$2.exports;
  6949. var conversions$1 = conversionsExports;
  6950. function buildGraph() {
  6951. var graph = {};
  6952. var models = Object.keys(conversions$1);
  6953. for (var len = models.length, i = 0; i < len; i++) {
  6954. graph[models[i]] = {
  6955. distance: -1,
  6956. parent: null
  6957. };
  6958. }
  6959. return graph;
  6960. }
  6961. function deriveBFS(fromModel) {
  6962. var graph = buildGraph();
  6963. var queue = [fromModel];
  6964. graph[fromModel].distance = 0;
  6965. while (queue.length) {
  6966. var current = queue.pop();
  6967. var adjacents = Object.keys(conversions$1[current]);
  6968. for (var len = adjacents.length, i = 0; i < len; i++) {
  6969. var adjacent = adjacents[i];
  6970. var node = graph[adjacent];
  6971. if (node.distance === -1) {
  6972. node.distance = graph[current].distance + 1;
  6973. node.parent = current;
  6974. queue.unshift(adjacent);
  6975. }
  6976. }
  6977. }
  6978. return graph;
  6979. }
  6980. function link(from, to) {
  6981. return function (args) {
  6982. return to(from(args));
  6983. };
  6984. }
  6985. function wrapConversion(toModel, graph) {
  6986. var path = [graph[toModel].parent, toModel];
  6987. var fn = conversions$1[graph[toModel].parent][toModel];
  6988. var cur = graph[toModel].parent;
  6989. while (graph[cur].parent) {
  6990. path.unshift(graph[cur].parent);
  6991. fn = link(conversions$1[graph[cur].parent][cur], fn);
  6992. cur = graph[cur].parent;
  6993. }
  6994. fn.conversion = path;
  6995. return fn;
  6996. }
  6997. var route$1 = function (fromModel) {
  6998. var graph = deriveBFS(fromModel);
  6999. var conversion = {};
  7000. var models = Object.keys(graph);
  7001. for (var len = models.length, i = 0; i < len; i++) {
  7002. var toModel = models[i];
  7003. var node = graph[toModel];
  7004. if (node.parent === null) {
  7005. continue;
  7006. }
  7007. conversion[toModel] = wrapConversion(toModel, graph);
  7008. }
  7009. return conversion;
  7010. };
  7011. var conversions = conversionsExports;
  7012. var route = route$1;
  7013. var convert = {};
  7014. var models = Object.keys(conversions);
  7015. function wrapRaw(fn) {
  7016. var wrappedFn = function (args) {
  7017. if (args === undefined || args === null) {
  7018. return args;
  7019. }
  7020. if (arguments.length > 1) {
  7021. args = Array.prototype.slice.call(arguments);
  7022. }
  7023. return fn(args);
  7024. };
  7025. if ('conversion' in fn) {
  7026. wrappedFn.conversion = fn.conversion;
  7027. }
  7028. return wrappedFn;
  7029. }
  7030. function wrapRounded(fn) {
  7031. var wrappedFn = function (args) {
  7032. if (args === undefined || args === null) {
  7033. return args;
  7034. }
  7035. if (arguments.length > 1) {
  7036. args = Array.prototype.slice.call(arguments);
  7037. }
  7038. var result = fn(args);
  7039. if (typeof result === 'object') {
  7040. for (var len = result.length, i = 0; i < len; i++) {
  7041. result[i] = Math.round(result[i]);
  7042. }
  7043. }
  7044. return result;
  7045. };
  7046. if ('conversion' in fn) {
  7047. wrappedFn.conversion = fn.conversion;
  7048. }
  7049. return wrappedFn;
  7050. }
  7051. models.forEach(function (fromModel) {
  7052. convert[fromModel] = {};
  7053. Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
  7054. Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
  7055. var routes = route(fromModel);
  7056. var routeModels = Object.keys(routes);
  7057. routeModels.forEach(function (toModel) {
  7058. var fn = routes[toModel];
  7059. convert[fromModel][toModel] = wrapRounded(fn);
  7060. convert[fromModel][toModel].raw = wrapRaw(fn);
  7061. });
  7062. });
  7063. var colorConvert = convert;
  7064. ansiStyles$1.exports;
  7065. (function (module) {
  7066. const colorConvert$1 = colorConvert;
  7067. const wrapAnsi16 = (fn, offset) => function () {
  7068. const code = fn.apply(colorConvert$1, arguments);
  7069. return `\u001B[${code + offset}m`;
  7070. };
  7071. const wrapAnsi256 = (fn, offset) => function () {
  7072. const code = fn.apply(colorConvert$1, arguments);
  7073. return `\u001B[${38 + offset};5;${code}m`;
  7074. };
  7075. const wrapAnsi16m = (fn, offset) => function () {
  7076. const rgb = fn.apply(colorConvert$1, arguments);
  7077. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  7078. };
  7079. function assembleStyles() {
  7080. const codes = new Map();
  7081. const styles = {
  7082. modifier: {
  7083. reset: [0, 0],
  7084. bold: [1, 22],
  7085. dim: [2, 22],
  7086. italic: [3, 23],
  7087. underline: [4, 24],
  7088. inverse: [7, 27],
  7089. hidden: [8, 28],
  7090. strikethrough: [9, 29]
  7091. },
  7092. color: {
  7093. black: [30, 39],
  7094. red: [31, 39],
  7095. green: [32, 39],
  7096. yellow: [33, 39],
  7097. blue: [34, 39],
  7098. magenta: [35, 39],
  7099. cyan: [36, 39],
  7100. white: [37, 39],
  7101. gray: [90, 39],
  7102. redBright: [91, 39],
  7103. greenBright: [92, 39],
  7104. yellowBright: [93, 39],
  7105. blueBright: [94, 39],
  7106. magentaBright: [95, 39],
  7107. cyanBright: [96, 39],
  7108. whiteBright: [97, 39]
  7109. },
  7110. bgColor: {
  7111. bgBlack: [40, 49],
  7112. bgRed: [41, 49],
  7113. bgGreen: [42, 49],
  7114. bgYellow: [43, 49],
  7115. bgBlue: [44, 49],
  7116. bgMagenta: [45, 49],
  7117. bgCyan: [46, 49],
  7118. bgWhite: [47, 49],
  7119. bgBlackBright: [100, 49],
  7120. bgRedBright: [101, 49],
  7121. bgGreenBright: [102, 49],
  7122. bgYellowBright: [103, 49],
  7123. bgBlueBright: [104, 49],
  7124. bgMagentaBright: [105, 49],
  7125. bgCyanBright: [106, 49],
  7126. bgWhiteBright: [107, 49]
  7127. }
  7128. };
  7129. styles.color.grey = styles.color.gray;
  7130. for (const groupName of Object.keys(styles)) {
  7131. const group = styles[groupName];
  7132. for (const styleName of Object.keys(group)) {
  7133. const style = group[styleName];
  7134. styles[styleName] = {
  7135. open: `\u001B[${style[0]}m`,
  7136. close: `\u001B[${style[1]}m`
  7137. };
  7138. group[styleName] = styles[styleName];
  7139. codes.set(style[0], style[1]);
  7140. }
  7141. Object.defineProperty(styles, groupName, {
  7142. value: group,
  7143. enumerable: false
  7144. });
  7145. Object.defineProperty(styles, 'codes', {
  7146. value: codes,
  7147. enumerable: false
  7148. });
  7149. }
  7150. const ansi2ansi = n => n;
  7151. const rgb2rgb = (r, g, b) => [r, g, b];
  7152. styles.color.close = '\u001B[39m';
  7153. styles.bgColor.close = '\u001B[49m';
  7154. styles.color.ansi = {
  7155. ansi: wrapAnsi16(ansi2ansi, 0)
  7156. };
  7157. styles.color.ansi256 = {
  7158. ansi256: wrapAnsi256(ansi2ansi, 0)
  7159. };
  7160. styles.color.ansi16m = {
  7161. rgb: wrapAnsi16m(rgb2rgb, 0)
  7162. };
  7163. styles.bgColor.ansi = {
  7164. ansi: wrapAnsi16(ansi2ansi, 10)
  7165. };
  7166. styles.bgColor.ansi256 = {
  7167. ansi256: wrapAnsi256(ansi2ansi, 10)
  7168. };
  7169. styles.bgColor.ansi16m = {
  7170. rgb: wrapAnsi16m(rgb2rgb, 10)
  7171. };
  7172. for (let key of Object.keys(colorConvert$1)) {
  7173. if (typeof colorConvert$1[key] !== 'object') {
  7174. continue;
  7175. }
  7176. const suite = colorConvert$1[key];
  7177. if (key === 'ansi16') {
  7178. key = 'ansi';
  7179. }
  7180. if ('ansi16' in suite) {
  7181. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  7182. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  7183. }
  7184. if ('ansi256' in suite) {
  7185. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  7186. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  7187. }
  7188. if ('rgb' in suite) {
  7189. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  7190. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  7191. }
  7192. }
  7193. return styles;
  7194. }
  7195. Object.defineProperty(module, 'exports', {
  7196. enumerable: true,
  7197. get: assembleStyles
  7198. });
  7199. } (ansiStyles$1));
  7200. var ansiStylesExports$1 = ansiStyles$1.exports;
  7201. var hasFlag$3 = (flag, argv) => {
  7202. argv = argv || process.argv;
  7203. const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
  7204. const pos = argv.indexOf(prefix + flag);
  7205. const terminatorPos = argv.indexOf('--');
  7206. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  7207. };
  7208. const os$1 = require$$0$2;
  7209. const hasFlag$2 = hasFlag$3;
  7210. const env$1 = process.env;
  7211. let forceColor$1;
  7212. if (hasFlag$2('no-color') ||
  7213. hasFlag$2('no-colors') ||
  7214. hasFlag$2('color=false')) {
  7215. forceColor$1 = false;
  7216. } else if (hasFlag$2('color') ||
  7217. hasFlag$2('colors') ||
  7218. hasFlag$2('color=true') ||
  7219. hasFlag$2('color=always')) {
  7220. forceColor$1 = true;
  7221. }
  7222. if ('FORCE_COLOR' in env$1) {
  7223. forceColor$1 = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0;
  7224. }
  7225. function translateLevel$1(level) {
  7226. if (level === 0) {
  7227. return false;
  7228. }
  7229. return {
  7230. level,
  7231. hasBasic: true,
  7232. has256: level >= 2,
  7233. has16m: level >= 3
  7234. };
  7235. }
  7236. function supportsColor$1(stream) {
  7237. if (forceColor$1 === false) {
  7238. return 0;
  7239. }
  7240. if (hasFlag$2('color=16m') ||
  7241. hasFlag$2('color=full') ||
  7242. hasFlag$2('color=truecolor')) {
  7243. return 3;
  7244. }
  7245. if (hasFlag$2('color=256')) {
  7246. return 2;
  7247. }
  7248. if (stream && !stream.isTTY && forceColor$1 !== true) {
  7249. return 0;
  7250. }
  7251. const min = forceColor$1 ? 1 : 0;
  7252. if (process.platform === 'win32') {
  7253. const osRelease = os$1.release().split('.');
  7254. if (
  7255. Number(process.versions.node.split('.')[0]) >= 8 &&
  7256. Number(osRelease[0]) >= 10 &&
  7257. Number(osRelease[2]) >= 10586
  7258. ) {
  7259. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  7260. }
  7261. return 1;
  7262. }
  7263. if ('CI' in env$1) {
  7264. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
  7265. return 1;
  7266. }
  7267. return min;
  7268. }
  7269. if ('TEAMCITY_VERSION' in env$1) {
  7270. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  7271. }
  7272. if (env$1.COLORTERM === 'truecolor') {
  7273. return 3;
  7274. }
  7275. if ('TERM_PROGRAM' in env$1) {
  7276. const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  7277. switch (env$1.TERM_PROGRAM) {
  7278. case 'iTerm.app':
  7279. return version >= 3 ? 3 : 2;
  7280. case 'Apple_Terminal':
  7281. return 2;
  7282. }
  7283. }
  7284. if (/-256(color)?$/i.test(env$1.TERM)) {
  7285. return 2;
  7286. }
  7287. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  7288. return 1;
  7289. }
  7290. if ('COLORTERM' in env$1) {
  7291. return 1;
  7292. }
  7293. if (env$1.TERM === 'dumb') {
  7294. return min;
  7295. }
  7296. return min;
  7297. }
  7298. function getSupportLevel$1(stream) {
  7299. const level = supportsColor$1(stream);
  7300. return translateLevel$1(level);
  7301. }
  7302. var supportsColor_1$1 = {
  7303. supportsColor: getSupportLevel$1,
  7304. stdout: getSupportLevel$1(process.stdout),
  7305. stderr: getSupportLevel$1(process.stderr)
  7306. };
  7307. const TEMPLATE_REGEX$1 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7308. const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7309. const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7310. const ESCAPE_REGEX$1 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7311. const ESCAPES$1 = new Map([
  7312. ['n', '\n'],
  7313. ['r', '\r'],
  7314. ['t', '\t'],
  7315. ['b', '\b'],
  7316. ['f', '\f'],
  7317. ['v', '\v'],
  7318. ['0', '\0'],
  7319. ['\\', '\\'],
  7320. ['e', '\u001B'],
  7321. ['a', '\u0007']
  7322. ]);
  7323. function unescape$1(c) {
  7324. if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
  7325. return String.fromCharCode(parseInt(c.slice(1), 16));
  7326. }
  7327. return ESCAPES$1.get(c) || c;
  7328. }
  7329. function parseArguments$1(name, args) {
  7330. const results = [];
  7331. const chunks = args.trim().split(/\s*,\s*/g);
  7332. let matches;
  7333. for (const chunk of chunks) {
  7334. if (!isNaN(chunk)) {
  7335. results.push(Number(chunk));
  7336. } else if ((matches = chunk.match(STRING_REGEX$1))) {
  7337. results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, chr) => escape ? unescape$1(escape) : chr));
  7338. } else {
  7339. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  7340. }
  7341. }
  7342. return results;
  7343. }
  7344. function parseStyle$1(style) {
  7345. STYLE_REGEX$1.lastIndex = 0;
  7346. const results = [];
  7347. let matches;
  7348. while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
  7349. const name = matches[1];
  7350. if (matches[2]) {
  7351. const args = parseArguments$1(name, matches[2]);
  7352. results.push([name].concat(args));
  7353. } else {
  7354. results.push([name]);
  7355. }
  7356. }
  7357. return results;
  7358. }
  7359. function buildStyle$1(chalk, styles) {
  7360. const enabled = {};
  7361. for (const layer of styles) {
  7362. for (const style of layer.styles) {
  7363. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  7364. }
  7365. }
  7366. let current = chalk;
  7367. for (const styleName of Object.keys(enabled)) {
  7368. if (Array.isArray(enabled[styleName])) {
  7369. if (!(styleName in current)) {
  7370. throw new Error(`Unknown Chalk style: ${styleName}`);
  7371. }
  7372. if (enabled[styleName].length > 0) {
  7373. current = current[styleName].apply(current, enabled[styleName]);
  7374. } else {
  7375. current = current[styleName];
  7376. }
  7377. }
  7378. }
  7379. return current;
  7380. }
  7381. var templates$1 = (chalk, tmp) => {
  7382. const styles = [];
  7383. const chunks = [];
  7384. let chunk = [];
  7385. tmp.replace(TEMPLATE_REGEX$1, (m, escapeChar, inverse, style, close, chr) => {
  7386. if (escapeChar) {
  7387. chunk.push(unescape$1(escapeChar));
  7388. } else if (style) {
  7389. const str = chunk.join('');
  7390. chunk = [];
  7391. chunks.push(styles.length === 0 ? str : buildStyle$1(chalk, styles)(str));
  7392. styles.push({inverse, styles: parseStyle$1(style)});
  7393. } else if (close) {
  7394. if (styles.length === 0) {
  7395. throw new Error('Found extraneous } in Chalk template literal');
  7396. }
  7397. chunks.push(buildStyle$1(chalk, styles)(chunk.join('')));
  7398. chunk = [];
  7399. styles.pop();
  7400. } else {
  7401. chunk.push(chr);
  7402. }
  7403. });
  7404. chunks.push(chunk.join(''));
  7405. if (styles.length > 0) {
  7406. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  7407. throw new Error(errMsg);
  7408. }
  7409. return chunks.join('');
  7410. };
  7411. (function (module) {
  7412. const escapeStringRegexp = escapeStringRegexp$1;
  7413. const ansiStyles = ansiStylesExports$1;
  7414. const stdoutColor = supportsColor_1$1.stdout;
  7415. const template = templates$1;
  7416. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
  7417. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
  7418. const skipModels = new Set(['gray']);
  7419. const styles = Object.create(null);
  7420. function applyOptions(obj, options) {
  7421. options = options || {};
  7422. const scLevel = stdoutColor ? stdoutColor.level : 0;
  7423. obj.level = options.level === undefined ? scLevel : options.level;
  7424. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  7425. }
  7426. function Chalk(options) {
  7427. if (!this || !(this instanceof Chalk) || this.template) {
  7428. const chalk = {};
  7429. applyOptions(chalk, options);
  7430. chalk.template = function () {
  7431. const args = [].slice.call(arguments);
  7432. return chalkTag.apply(null, [chalk.template].concat(args));
  7433. };
  7434. Object.setPrototypeOf(chalk, Chalk.prototype);
  7435. Object.setPrototypeOf(chalk.template, chalk);
  7436. chalk.template.constructor = Chalk;
  7437. return chalk.template;
  7438. }
  7439. applyOptions(this, options);
  7440. }
  7441. if (isSimpleWindowsTerm) {
  7442. ansiStyles.blue.open = '\u001B[94m';
  7443. }
  7444. for (const key of Object.keys(ansiStyles)) {
  7445. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  7446. styles[key] = {
  7447. get() {
  7448. const codes = ansiStyles[key];
  7449. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  7450. }
  7451. };
  7452. }
  7453. styles.visible = {
  7454. get() {
  7455. return build.call(this, this._styles || [], true, 'visible');
  7456. }
  7457. };
  7458. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  7459. for (const model of Object.keys(ansiStyles.color.ansi)) {
  7460. if (skipModels.has(model)) {
  7461. continue;
  7462. }
  7463. styles[model] = {
  7464. get() {
  7465. const level = this.level;
  7466. return function () {
  7467. const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7468. const codes = {
  7469. open,
  7470. close: ansiStyles.color.close,
  7471. closeRe: ansiStyles.color.closeRe
  7472. };
  7473. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7474. };
  7475. }
  7476. };
  7477. }
  7478. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7479. for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
  7480. if (skipModels.has(model)) {
  7481. continue;
  7482. }
  7483. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7484. styles[bgModel] = {
  7485. get() {
  7486. const level = this.level;
  7487. return function () {
  7488. const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7489. const codes = {
  7490. open,
  7491. close: ansiStyles.bgColor.close,
  7492. closeRe: ansiStyles.bgColor.closeRe
  7493. };
  7494. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7495. };
  7496. }
  7497. };
  7498. }
  7499. const proto = Object.defineProperties(() => {}, styles);
  7500. function build(_styles, _empty, key) {
  7501. const builder = function () {
  7502. return applyStyle.apply(builder, arguments);
  7503. };
  7504. builder._styles = _styles;
  7505. builder._empty = _empty;
  7506. const self = this;
  7507. Object.defineProperty(builder, 'level', {
  7508. enumerable: true,
  7509. get() {
  7510. return self.level;
  7511. },
  7512. set(level) {
  7513. self.level = level;
  7514. }
  7515. });
  7516. Object.defineProperty(builder, 'enabled', {
  7517. enumerable: true,
  7518. get() {
  7519. return self.enabled;
  7520. },
  7521. set(enabled) {
  7522. self.enabled = enabled;
  7523. }
  7524. });
  7525. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
  7526. builder.__proto__ = proto;
  7527. return builder;
  7528. }
  7529. function applyStyle() {
  7530. const args = arguments;
  7531. const argsLen = args.length;
  7532. let str = String(arguments[0]);
  7533. if (argsLen === 0) {
  7534. return '';
  7535. }
  7536. if (argsLen > 1) {
  7537. for (let a = 1; a < argsLen; a++) {
  7538. str += ' ' + args[a];
  7539. }
  7540. }
  7541. if (!this.enabled || this.level <= 0 || !str) {
  7542. return this._empty ? '' : str;
  7543. }
  7544. const originalDim = ansiStyles.dim.open;
  7545. if (isSimpleWindowsTerm && this.hasGrey) {
  7546. ansiStyles.dim.open = '';
  7547. }
  7548. for (const code of this._styles.slice().reverse()) {
  7549. str = code.open + str.replace(code.closeRe, code.open) + code.close;
  7550. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  7551. }
  7552. ansiStyles.dim.open = originalDim;
  7553. return str;
  7554. }
  7555. function chalkTag(chalk, strings) {
  7556. if (!Array.isArray(strings)) {
  7557. return [].slice.call(arguments, 1).join(' ');
  7558. }
  7559. const args = [].slice.call(arguments, 2);
  7560. const parts = [strings.raw[0]];
  7561. for (let i = 1; i < strings.length; i++) {
  7562. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7563. parts.push(String(strings.raw[i]));
  7564. }
  7565. return template(chalk, parts.join(''));
  7566. }
  7567. Object.defineProperties(Chalk.prototype, styles);
  7568. module.exports = Chalk();
  7569. module.exports.supportsColor = stdoutColor;
  7570. module.exports.default = module.exports;
  7571. } (chalk$1));
  7572. var chalkExports$1 = chalk$1.exports;
  7573. Object.defineProperty(lib$1, "__esModule", {
  7574. value: true
  7575. });
  7576. lib$1.default = highlight;
  7577. lib$1.shouldHighlight = shouldHighlight;
  7578. var _jsTokens = jsTokens;
  7579. var _helperValidatorIdentifier = lib;
  7580. var _chalk$1 = _interopRequireWildcard$1(chalkExports$1, true);
  7581. function _getRequireWildcardCache$1(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache$1 = function (e) { return e ? t : r; })(e); }
  7582. function _interopRequireWildcard$1(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache$1(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
  7583. const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
  7584. function getDefs$1(chalk) {
  7585. return {
  7586. keyword: chalk.cyan,
  7587. capitalized: chalk.yellow,
  7588. jsxIdentifier: chalk.yellow,
  7589. punctuator: chalk.yellow,
  7590. number: chalk.magenta,
  7591. string: chalk.green,
  7592. regex: chalk.magenta,
  7593. comment: chalk.grey,
  7594. invalid: chalk.white.bgRed.bold
  7595. };
  7596. }
  7597. const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
  7598. const BRACKET = /^[()[\]{}]$/;
  7599. let tokenize;
  7600. {
  7601. const JSX_TAG = /^[a-z][\w-]*$/i;
  7602. const getTokenType = function (token, offset, text) {
  7603. if (token.type === "name") {
  7604. if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
  7605. return "keyword";
  7606. }
  7607. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) == "</")) {
  7608. return "jsxIdentifier";
  7609. }
  7610. if (token.value[0] !== token.value[0].toLowerCase()) {
  7611. return "capitalized";
  7612. }
  7613. }
  7614. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  7615. return "bracket";
  7616. }
  7617. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  7618. return "punctuator";
  7619. }
  7620. return token.type;
  7621. };
  7622. tokenize = function* (text) {
  7623. let match;
  7624. while (match = _jsTokens.default.exec(text)) {
  7625. const token = _jsTokens.matchToToken(match);
  7626. yield {
  7627. type: getTokenType(token, match.index, text),
  7628. value: token.value
  7629. };
  7630. }
  7631. };
  7632. }
  7633. function highlightTokens(defs, text) {
  7634. let highlighted = "";
  7635. for (const {
  7636. type,
  7637. value
  7638. } of tokenize(text)) {
  7639. const colorize = defs[type];
  7640. if (colorize) {
  7641. highlighted += value.split(NEWLINE$1).map(str => colorize(str)).join("\n");
  7642. } else {
  7643. highlighted += value;
  7644. }
  7645. }
  7646. return highlighted;
  7647. }
  7648. function shouldHighlight(options) {
  7649. return _chalk$1.default.level > 0 || options.forceColor;
  7650. }
  7651. let chalkWithForcedColor$1 = undefined;
  7652. function getChalk$1(forceColor) {
  7653. if (forceColor) {
  7654. var _chalkWithForcedColor;
  7655. (_chalkWithForcedColor = chalkWithForcedColor$1) != null ? _chalkWithForcedColor : chalkWithForcedColor$1 = new _chalk$1.default.constructor({
  7656. enabled: true,
  7657. level: 1
  7658. });
  7659. return chalkWithForcedColor$1;
  7660. }
  7661. return _chalk$1.default;
  7662. }
  7663. {
  7664. lib$1.getChalk = options => getChalk$1(options.forceColor);
  7665. }
  7666. function highlight(code, options = {}) {
  7667. if (code !== "" && shouldHighlight(options)) {
  7668. const defs = getDefs$1(getChalk$1(options.forceColor));
  7669. return highlightTokens(defs, code);
  7670. } else {
  7671. return code;
  7672. }
  7673. }
  7674. var chalk = {exports: {}};
  7675. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  7676. var escapeStringRegexp = function (str) {
  7677. if (typeof str !== 'string') {
  7678. throw new TypeError('Expected a string');
  7679. }
  7680. return str.replace(matchOperatorsRe, '\\$&');
  7681. };
  7682. var ansiStyles = {exports: {}};
  7683. ansiStyles.exports;
  7684. (function (module) {
  7685. const colorConvert$1 = colorConvert;
  7686. const wrapAnsi16 = (fn, offset) => function () {
  7687. const code = fn.apply(colorConvert$1, arguments);
  7688. return `\u001B[${code + offset}m`;
  7689. };
  7690. const wrapAnsi256 = (fn, offset) => function () {
  7691. const code = fn.apply(colorConvert$1, arguments);
  7692. return `\u001B[${38 + offset};5;${code}m`;
  7693. };
  7694. const wrapAnsi16m = (fn, offset) => function () {
  7695. const rgb = fn.apply(colorConvert$1, arguments);
  7696. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  7697. };
  7698. function assembleStyles() {
  7699. const codes = new Map();
  7700. const styles = {
  7701. modifier: {
  7702. reset: [0, 0],
  7703. bold: [1, 22],
  7704. dim: [2, 22],
  7705. italic: [3, 23],
  7706. underline: [4, 24],
  7707. inverse: [7, 27],
  7708. hidden: [8, 28],
  7709. strikethrough: [9, 29]
  7710. },
  7711. color: {
  7712. black: [30, 39],
  7713. red: [31, 39],
  7714. green: [32, 39],
  7715. yellow: [33, 39],
  7716. blue: [34, 39],
  7717. magenta: [35, 39],
  7718. cyan: [36, 39],
  7719. white: [37, 39],
  7720. gray: [90, 39],
  7721. redBright: [91, 39],
  7722. greenBright: [92, 39],
  7723. yellowBright: [93, 39],
  7724. blueBright: [94, 39],
  7725. magentaBright: [95, 39],
  7726. cyanBright: [96, 39],
  7727. whiteBright: [97, 39]
  7728. },
  7729. bgColor: {
  7730. bgBlack: [40, 49],
  7731. bgRed: [41, 49],
  7732. bgGreen: [42, 49],
  7733. bgYellow: [43, 49],
  7734. bgBlue: [44, 49],
  7735. bgMagenta: [45, 49],
  7736. bgCyan: [46, 49],
  7737. bgWhite: [47, 49],
  7738. bgBlackBright: [100, 49],
  7739. bgRedBright: [101, 49],
  7740. bgGreenBright: [102, 49],
  7741. bgYellowBright: [103, 49],
  7742. bgBlueBright: [104, 49],
  7743. bgMagentaBright: [105, 49],
  7744. bgCyanBright: [106, 49],
  7745. bgWhiteBright: [107, 49]
  7746. }
  7747. };
  7748. styles.color.grey = styles.color.gray;
  7749. for (const groupName of Object.keys(styles)) {
  7750. const group = styles[groupName];
  7751. for (const styleName of Object.keys(group)) {
  7752. const style = group[styleName];
  7753. styles[styleName] = {
  7754. open: `\u001B[${style[0]}m`,
  7755. close: `\u001B[${style[1]}m`
  7756. };
  7757. group[styleName] = styles[styleName];
  7758. codes.set(style[0], style[1]);
  7759. }
  7760. Object.defineProperty(styles, groupName, {
  7761. value: group,
  7762. enumerable: false
  7763. });
  7764. Object.defineProperty(styles, 'codes', {
  7765. value: codes,
  7766. enumerable: false
  7767. });
  7768. }
  7769. const ansi2ansi = n => n;
  7770. const rgb2rgb = (r, g, b) => [r, g, b];
  7771. styles.color.close = '\u001B[39m';
  7772. styles.bgColor.close = '\u001B[49m';
  7773. styles.color.ansi = {
  7774. ansi: wrapAnsi16(ansi2ansi, 0)
  7775. };
  7776. styles.color.ansi256 = {
  7777. ansi256: wrapAnsi256(ansi2ansi, 0)
  7778. };
  7779. styles.color.ansi16m = {
  7780. rgb: wrapAnsi16m(rgb2rgb, 0)
  7781. };
  7782. styles.bgColor.ansi = {
  7783. ansi: wrapAnsi16(ansi2ansi, 10)
  7784. };
  7785. styles.bgColor.ansi256 = {
  7786. ansi256: wrapAnsi256(ansi2ansi, 10)
  7787. };
  7788. styles.bgColor.ansi16m = {
  7789. rgb: wrapAnsi16m(rgb2rgb, 10)
  7790. };
  7791. for (let key of Object.keys(colorConvert$1)) {
  7792. if (typeof colorConvert$1[key] !== 'object') {
  7793. continue;
  7794. }
  7795. const suite = colorConvert$1[key];
  7796. if (key === 'ansi16') {
  7797. key = 'ansi';
  7798. }
  7799. if ('ansi16' in suite) {
  7800. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  7801. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  7802. }
  7803. if ('ansi256' in suite) {
  7804. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  7805. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  7806. }
  7807. if ('rgb' in suite) {
  7808. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  7809. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  7810. }
  7811. }
  7812. return styles;
  7813. }
  7814. Object.defineProperty(module, 'exports', {
  7815. enumerable: true,
  7816. get: assembleStyles
  7817. });
  7818. } (ansiStyles));
  7819. var ansiStylesExports = ansiStyles.exports;
  7820. var hasFlag$1 = (flag, argv) => {
  7821. argv = argv || process.argv;
  7822. const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
  7823. const pos = argv.indexOf(prefix + flag);
  7824. const terminatorPos = argv.indexOf('--');
  7825. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  7826. };
  7827. const os = require$$0$2;
  7828. const hasFlag = hasFlag$1;
  7829. const env = process.env;
  7830. let forceColor;
  7831. if (hasFlag('no-color') ||
  7832. hasFlag('no-colors') ||
  7833. hasFlag('color=false')) {
  7834. forceColor = false;
  7835. } else if (hasFlag('color') ||
  7836. hasFlag('colors') ||
  7837. hasFlag('color=true') ||
  7838. hasFlag('color=always')) {
  7839. forceColor = true;
  7840. }
  7841. if ('FORCE_COLOR' in env) {
  7842. forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
  7843. }
  7844. function translateLevel(level) {
  7845. if (level === 0) {
  7846. return false;
  7847. }
  7848. return {
  7849. level,
  7850. hasBasic: true,
  7851. has256: level >= 2,
  7852. has16m: level >= 3
  7853. };
  7854. }
  7855. function supportsColor(stream) {
  7856. if (forceColor === false) {
  7857. return 0;
  7858. }
  7859. if (hasFlag('color=16m') ||
  7860. hasFlag('color=full') ||
  7861. hasFlag('color=truecolor')) {
  7862. return 3;
  7863. }
  7864. if (hasFlag('color=256')) {
  7865. return 2;
  7866. }
  7867. if (stream && !stream.isTTY && forceColor !== true) {
  7868. return 0;
  7869. }
  7870. const min = forceColor ? 1 : 0;
  7871. if (process.platform === 'win32') {
  7872. const osRelease = os.release().split('.');
  7873. if (
  7874. Number(process.versions.node.split('.')[0]) >= 8 &&
  7875. Number(osRelease[0]) >= 10 &&
  7876. Number(osRelease[2]) >= 10586
  7877. ) {
  7878. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  7879. }
  7880. return 1;
  7881. }
  7882. if ('CI' in env) {
  7883. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
  7884. return 1;
  7885. }
  7886. return min;
  7887. }
  7888. if ('TEAMCITY_VERSION' in env) {
  7889. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  7890. }
  7891. if (env.COLORTERM === 'truecolor') {
  7892. return 3;
  7893. }
  7894. if ('TERM_PROGRAM' in env) {
  7895. const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  7896. switch (env.TERM_PROGRAM) {
  7897. case 'iTerm.app':
  7898. return version >= 3 ? 3 : 2;
  7899. case 'Apple_Terminal':
  7900. return 2;
  7901. }
  7902. }
  7903. if (/-256(color)?$/i.test(env.TERM)) {
  7904. return 2;
  7905. }
  7906. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  7907. return 1;
  7908. }
  7909. if ('COLORTERM' in env) {
  7910. return 1;
  7911. }
  7912. if (env.TERM === 'dumb') {
  7913. return min;
  7914. }
  7915. return min;
  7916. }
  7917. function getSupportLevel(stream) {
  7918. const level = supportsColor(stream);
  7919. return translateLevel(level);
  7920. }
  7921. var supportsColor_1 = {
  7922. supportsColor: getSupportLevel,
  7923. stdout: getSupportLevel(process.stdout),
  7924. stderr: getSupportLevel(process.stderr)
  7925. };
  7926. const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7927. const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7928. const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7929. const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7930. const ESCAPES = new Map([
  7931. ['n', '\n'],
  7932. ['r', '\r'],
  7933. ['t', '\t'],
  7934. ['b', '\b'],
  7935. ['f', '\f'],
  7936. ['v', '\v'],
  7937. ['0', '\0'],
  7938. ['\\', '\\'],
  7939. ['e', '\u001B'],
  7940. ['a', '\u0007']
  7941. ]);
  7942. function unescape(c) {
  7943. if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
  7944. return String.fromCharCode(parseInt(c.slice(1), 16));
  7945. }
  7946. return ESCAPES.get(c) || c;
  7947. }
  7948. function parseArguments(name, args) {
  7949. const results = [];
  7950. const chunks = args.trim().split(/\s*,\s*/g);
  7951. let matches;
  7952. for (const chunk of chunks) {
  7953. if (!isNaN(chunk)) {
  7954. results.push(Number(chunk));
  7955. } else if ((matches = chunk.match(STRING_REGEX))) {
  7956. results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
  7957. } else {
  7958. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  7959. }
  7960. }
  7961. return results;
  7962. }
  7963. function parseStyle(style) {
  7964. STYLE_REGEX.lastIndex = 0;
  7965. const results = [];
  7966. let matches;
  7967. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  7968. const name = matches[1];
  7969. if (matches[2]) {
  7970. const args = parseArguments(name, matches[2]);
  7971. results.push([name].concat(args));
  7972. } else {
  7973. results.push([name]);
  7974. }
  7975. }
  7976. return results;
  7977. }
  7978. function buildStyle(chalk, styles) {
  7979. const enabled = {};
  7980. for (const layer of styles) {
  7981. for (const style of layer.styles) {
  7982. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  7983. }
  7984. }
  7985. let current = chalk;
  7986. for (const styleName of Object.keys(enabled)) {
  7987. if (Array.isArray(enabled[styleName])) {
  7988. if (!(styleName in current)) {
  7989. throw new Error(`Unknown Chalk style: ${styleName}`);
  7990. }
  7991. if (enabled[styleName].length > 0) {
  7992. current = current[styleName].apply(current, enabled[styleName]);
  7993. } else {
  7994. current = current[styleName];
  7995. }
  7996. }
  7997. }
  7998. return current;
  7999. }
  8000. var templates = (chalk, tmp) => {
  8001. const styles = [];
  8002. const chunks = [];
  8003. let chunk = [];
  8004. tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
  8005. if (escapeChar) {
  8006. chunk.push(unescape(escapeChar));
  8007. } else if (style) {
  8008. const str = chunk.join('');
  8009. chunk = [];
  8010. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  8011. styles.push({inverse, styles: parseStyle(style)});
  8012. } else if (close) {
  8013. if (styles.length === 0) {
  8014. throw new Error('Found extraneous } in Chalk template literal');
  8015. }
  8016. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  8017. chunk = [];
  8018. styles.pop();
  8019. } else {
  8020. chunk.push(chr);
  8021. }
  8022. });
  8023. chunks.push(chunk.join(''));
  8024. if (styles.length > 0) {
  8025. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  8026. throw new Error(errMsg);
  8027. }
  8028. return chunks.join('');
  8029. };
  8030. (function (module) {
  8031. const escapeStringRegexp$1 = escapeStringRegexp;
  8032. const ansiStyles = ansiStylesExports;
  8033. const stdoutColor = supportsColor_1.stdout;
  8034. const template = templates;
  8035. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
  8036. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
  8037. const skipModels = new Set(['gray']);
  8038. const styles = Object.create(null);
  8039. function applyOptions(obj, options) {
  8040. options = options || {};
  8041. const scLevel = stdoutColor ? stdoutColor.level : 0;
  8042. obj.level = options.level === undefined ? scLevel : options.level;
  8043. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  8044. }
  8045. function Chalk(options) {
  8046. if (!this || !(this instanceof Chalk) || this.template) {
  8047. const chalk = {};
  8048. applyOptions(chalk, options);
  8049. chalk.template = function () {
  8050. const args = [].slice.call(arguments);
  8051. return chalkTag.apply(null, [chalk.template].concat(args));
  8052. };
  8053. Object.setPrototypeOf(chalk, Chalk.prototype);
  8054. Object.setPrototypeOf(chalk.template, chalk);
  8055. chalk.template.constructor = Chalk;
  8056. return chalk.template;
  8057. }
  8058. applyOptions(this, options);
  8059. }
  8060. if (isSimpleWindowsTerm) {
  8061. ansiStyles.blue.open = '\u001B[94m';
  8062. }
  8063. for (const key of Object.keys(ansiStyles)) {
  8064. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles[key].close), 'g');
  8065. styles[key] = {
  8066. get() {
  8067. const codes = ansiStyles[key];
  8068. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  8069. }
  8070. };
  8071. }
  8072. styles.visible = {
  8073. get() {
  8074. return build.call(this, this._styles || [], true, 'visible');
  8075. }
  8076. };
  8077. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.color.close), 'g');
  8078. for (const model of Object.keys(ansiStyles.color.ansi)) {
  8079. if (skipModels.has(model)) {
  8080. continue;
  8081. }
  8082. styles[model] = {
  8083. get() {
  8084. const level = this.level;
  8085. return function () {
  8086. const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  8087. const codes = {
  8088. open,
  8089. close: ansiStyles.color.close,
  8090. closeRe: ansiStyles.color.closeRe
  8091. };
  8092. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8093. };
  8094. }
  8095. };
  8096. }
  8097. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.bgColor.close), 'g');
  8098. for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
  8099. if (skipModels.has(model)) {
  8100. continue;
  8101. }
  8102. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8103. styles[bgModel] = {
  8104. get() {
  8105. const level = this.level;
  8106. return function () {
  8107. const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  8108. const codes = {
  8109. open,
  8110. close: ansiStyles.bgColor.close,
  8111. closeRe: ansiStyles.bgColor.closeRe
  8112. };
  8113. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8114. };
  8115. }
  8116. };
  8117. }
  8118. const proto = Object.defineProperties(() => {}, styles);
  8119. function build(_styles, _empty, key) {
  8120. const builder = function () {
  8121. return applyStyle.apply(builder, arguments);
  8122. };
  8123. builder._styles = _styles;
  8124. builder._empty = _empty;
  8125. const self = this;
  8126. Object.defineProperty(builder, 'level', {
  8127. enumerable: true,
  8128. get() {
  8129. return self.level;
  8130. },
  8131. set(level) {
  8132. self.level = level;
  8133. }
  8134. });
  8135. Object.defineProperty(builder, 'enabled', {
  8136. enumerable: true,
  8137. get() {
  8138. return self.enabled;
  8139. },
  8140. set(enabled) {
  8141. self.enabled = enabled;
  8142. }
  8143. });
  8144. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
  8145. builder.__proto__ = proto;
  8146. return builder;
  8147. }
  8148. function applyStyle() {
  8149. const args = arguments;
  8150. const argsLen = args.length;
  8151. let str = String(arguments[0]);
  8152. if (argsLen === 0) {
  8153. return '';
  8154. }
  8155. if (argsLen > 1) {
  8156. for (let a = 1; a < argsLen; a++) {
  8157. str += ' ' + args[a];
  8158. }
  8159. }
  8160. if (!this.enabled || this.level <= 0 || !str) {
  8161. return this._empty ? '' : str;
  8162. }
  8163. const originalDim = ansiStyles.dim.open;
  8164. if (isSimpleWindowsTerm && this.hasGrey) {
  8165. ansiStyles.dim.open = '';
  8166. }
  8167. for (const code of this._styles.slice().reverse()) {
  8168. str = code.open + str.replace(code.closeRe, code.open) + code.close;
  8169. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  8170. }
  8171. ansiStyles.dim.open = originalDim;
  8172. return str;
  8173. }
  8174. function chalkTag(chalk, strings) {
  8175. if (!Array.isArray(strings)) {
  8176. return [].slice.call(arguments, 1).join(' ');
  8177. }
  8178. const args = [].slice.call(arguments, 2);
  8179. const parts = [strings.raw[0]];
  8180. for (let i = 1; i < strings.length; i++) {
  8181. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  8182. parts.push(String(strings.raw[i]));
  8183. }
  8184. return template(chalk, parts.join(''));
  8185. }
  8186. Object.defineProperties(Chalk.prototype, styles);
  8187. module.exports = Chalk();
  8188. module.exports.supportsColor = stdoutColor;
  8189. module.exports.default = module.exports;
  8190. } (chalk));
  8191. var chalkExports = chalk.exports;
  8192. Object.defineProperty(lib$2, "__esModule", {
  8193. value: true
  8194. });
  8195. var codeFrameColumns_1 = lib$2.codeFrameColumns = codeFrameColumns;
  8196. lib$2.default = _default;
  8197. var _highlight = lib$1;
  8198. var _chalk = _interopRequireWildcard(chalkExports, true);
  8199. function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
  8200. function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
  8201. let chalkWithForcedColor = undefined;
  8202. function getChalk(forceColor) {
  8203. if (forceColor) {
  8204. var _chalkWithForcedColor;
  8205. (_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new _chalk.default.constructor({
  8206. enabled: true,
  8207. level: 1
  8208. });
  8209. return chalkWithForcedColor;
  8210. }
  8211. return _chalk.default;
  8212. }
  8213. let deprecationWarningShown = false;
  8214. function getDefs(chalk) {
  8215. return {
  8216. gutter: chalk.grey,
  8217. marker: chalk.red.bold,
  8218. message: chalk.red.bold
  8219. };
  8220. }
  8221. const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  8222. function getMarkerLines(loc, source, opts) {
  8223. const startLoc = Object.assign({
  8224. column: 0,
  8225. line: -1
  8226. }, loc.start);
  8227. const endLoc = Object.assign({}, startLoc, loc.end);
  8228. const {
  8229. linesAbove = 2,
  8230. linesBelow = 3
  8231. } = opts || {};
  8232. const startLine = startLoc.line;
  8233. const startColumn = startLoc.column;
  8234. const endLine = endLoc.line;
  8235. const endColumn = endLoc.column;
  8236. let start = Math.max(startLine - (linesAbove + 1), 0);
  8237. let end = Math.min(source.length, endLine + linesBelow);
  8238. if (startLine === -1) {
  8239. start = 0;
  8240. }
  8241. if (endLine === -1) {
  8242. end = source.length;
  8243. }
  8244. const lineDiff = endLine - startLine;
  8245. const markerLines = {};
  8246. if (lineDiff) {
  8247. for (let i = 0; i <= lineDiff; i++) {
  8248. const lineNumber = i + startLine;
  8249. if (!startColumn) {
  8250. markerLines[lineNumber] = true;
  8251. } else if (i === 0) {
  8252. const sourceLength = source[lineNumber - 1].length;
  8253. markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
  8254. } else if (i === lineDiff) {
  8255. markerLines[lineNumber] = [0, endColumn];
  8256. } else {
  8257. const sourceLength = source[lineNumber - i].length;
  8258. markerLines[lineNumber] = [0, sourceLength];
  8259. }
  8260. }
  8261. } else {
  8262. if (startColumn === endColumn) {
  8263. if (startColumn) {
  8264. markerLines[startLine] = [startColumn, 0];
  8265. } else {
  8266. markerLines[startLine] = true;
  8267. }
  8268. } else {
  8269. markerLines[startLine] = [startColumn, endColumn - startColumn];
  8270. }
  8271. }
  8272. return {
  8273. start,
  8274. end,
  8275. markerLines
  8276. };
  8277. }
  8278. function codeFrameColumns(rawLines, loc, opts = {}) {
  8279. const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
  8280. const chalk = getChalk(opts.forceColor);
  8281. const defs = getDefs(chalk);
  8282. const maybeHighlight = (chalkFn, string) => {
  8283. return highlighted ? chalkFn(string) : string;
  8284. };
  8285. const lines = rawLines.split(NEWLINE);
  8286. const {
  8287. start,
  8288. end,
  8289. markerLines
  8290. } = getMarkerLines(loc, lines, opts);
  8291. const hasColumns = loc.start && typeof loc.start.column === "number";
  8292. const numberMaxWidth = String(end).length;
  8293. const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
  8294. let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
  8295. const number = start + 1 + index;
  8296. const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
  8297. const gutter = ` ${paddedNumber} |`;
  8298. const hasMarker = markerLines[number];
  8299. const lastMarkerLine = !markerLines[number + 1];
  8300. if (hasMarker) {
  8301. let markerLine = "";
  8302. if (Array.isArray(hasMarker)) {
  8303. const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  8304. const numberOfMarkers = hasMarker[1] || 1;
  8305. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  8306. if (lastMarkerLine && opts.message) {
  8307. markerLine += " " + maybeHighlight(defs.message, opts.message);
  8308. }
  8309. }
  8310. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
  8311. } else {
  8312. return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
  8313. }
  8314. }).join("\n");
  8315. if (opts.message && !hasColumns) {
  8316. frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
  8317. }
  8318. if (highlighted) {
  8319. return chalk.reset(frame);
  8320. } else {
  8321. return frame;
  8322. }
  8323. }
  8324. function _default(rawLines, lineNumber, colNumber, opts = {}) {
  8325. if (!deprecationWarningShown) {
  8326. deprecationWarningShown = true;
  8327. const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  8328. if (process.emitWarning) {
  8329. process.emitWarning(message, "DeprecationWarning");
  8330. } else {
  8331. const deprecationError = new Error(message);
  8332. deprecationError.name = "DeprecationWarning";
  8333. console.warn(new Error(message));
  8334. }
  8335. }
  8336. colNumber = Math.max(colNumber, 0);
  8337. const location = {
  8338. start: {
  8339. column: colNumber,
  8340. line: lineNumber
  8341. }
  8342. };
  8343. return codeFrameColumns(rawLines, location, opts);
  8344. }
  8345. const safeLastIndexOf = (string, searchString, index) =>
  8346. index < 0 ? -1 : string.lastIndexOf(searchString, index);
  8347. function getPosition(text, textIndex) {
  8348. const lineBreakBefore = safeLastIndexOf(text, '\n', textIndex - 1);
  8349. const column = textIndex - lineBreakBefore - 1;
  8350. let line = 0;
  8351. for (
  8352. let index = lineBreakBefore;
  8353. index >= 0;
  8354. index = safeLastIndexOf(text, '\n', index - 1)
  8355. ) {
  8356. line++;
  8357. }
  8358. return {line, column};
  8359. }
  8360. function indexToLineColumn(text, textIndex, {oneBased = false} = {}) {
  8361. if (textIndex < 0 || (textIndex >= text.length && text.length > 0)) {
  8362. throw new RangeError('Index out of bounds');
  8363. }
  8364. const position = getPosition(text, textIndex);
  8365. return oneBased ? {line: position.line + 1, column: position.column + 1} : position;
  8366. }
  8367. const getCodePoint = character => `\\u{${character.codePointAt(0).toString(16)}}`;
  8368. class JSONError extends Error {
  8369. name = 'JSONError';
  8370. fileName;
  8371. codeFrame;
  8372. rawCodeFrame;
  8373. #message;
  8374. constructor(message) {
  8375. super();
  8376. this.#message = message;
  8377. Error.captureStackTrace?.(this, JSONError);
  8378. }
  8379. get message() {
  8380. const {fileName, codeFrame} = this;
  8381. return `${this.#message}${fileName ? ` in ${fileName}` : ''}${codeFrame ? `\n\n${codeFrame}\n` : ''}`;
  8382. }
  8383. set message(message) {
  8384. this.#message = message;
  8385. }
  8386. }
  8387. const generateCodeFrame = (string, location, highlightCode = true) =>
  8388. codeFrameColumns_1(string, {start: location}, {highlightCode});
  8389. const getErrorLocation = (string, message) => {
  8390. const match = message.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);
  8391. if (!match) {
  8392. return;
  8393. }
  8394. let {index, line, column} = match.groups;
  8395. if (line && column) {
  8396. return {line: Number(line), column: Number(column)};
  8397. }
  8398. index = Number(index);
  8399. if (index === string.length) {
  8400. const {line, column} = indexToLineColumn(string, string.length - 1, {oneBased: true});
  8401. return {line, column: column + 1};
  8402. }
  8403. return indexToLineColumn(string, index, {oneBased: true});
  8404. };
  8405. const addCodePointToUnexpectedToken = message => message.replace(
  8406. /(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
  8407. (_, _quote, token) => `"${token}"(${getCodePoint(token)})`,
  8408. );
  8409. function parseJson(string, reviver, fileName) {
  8410. if (typeof reviver === 'string') {
  8411. fileName = reviver;
  8412. reviver = undefined;
  8413. }
  8414. let message;
  8415. try {
  8416. return JSON.parse(string, reviver);
  8417. } catch (error) {
  8418. message = error.message;
  8419. }
  8420. let location;
  8421. if (string) {
  8422. location = getErrorLocation(string, message);
  8423. message = addCodePointToUnexpectedToken(message);
  8424. } else {
  8425. message += ' while parsing empty string';
  8426. }
  8427. const jsonError = new JSONError(message);
  8428. jsonError.fileName = fileName;
  8429. if (location) {
  8430. jsonError.codeFrame = generateCodeFrame(string, location);
  8431. jsonError.rawCodeFrame = generateCodeFrame(string, location, /* highlightCode */ false);
  8432. }
  8433. throw jsonError;
  8434. }
  8435. function toPath(urlOrPath) {
  8436. return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
  8437. }
  8438. const getPackagePath = cwd => path$1.resolve(toPath(cwd) ?? '.', 'package.json');
  8439. const _readPackage = (file, normalize) => {
  8440. const json = typeof file === 'string'
  8441. ? parseJson(file)
  8442. : file;
  8443. if (normalize) {
  8444. normalizePackageData(json);
  8445. }
  8446. return json;
  8447. };
  8448. function readPackageSync({cwd, normalize = true} = {}) {
  8449. const packageFile = fs$1.readFileSync(getPackagePath(cwd), 'utf8');
  8450. return _readPackage(packageFile, normalize);
  8451. }
  8452. function readPackageUpSync(options) {
  8453. const filePath = findUpSync('package.json', options);
  8454. if (!filePath) {
  8455. return;
  8456. }
  8457. return {
  8458. packageJson: readPackageSync({...options, cwd: path$1.dirname(filePath)}),
  8459. path: filePath,
  8460. };
  8461. }
  8462. const handlePreserveConsecutiveUppercase = (decamelized, separator) => {
  8463. // Lowercase all single uppercase characters. As we
  8464. // want to preserve uppercase sequences, we cannot
  8465. // simply lowercase the separated string at the end.
  8466. // `data_For_USACounties` → `data_for_USACounties`
  8467. decamelized = decamelized.replace(
  8468. /((?<![\p{Uppercase_Letter}\d])[\p{Uppercase_Letter}\d](?![\p{Uppercase_Letter}\d]))/gu,
  8469. $0 => $0.toLowerCase(),
  8470. );
  8471. // Remaining uppercase sequences will be separated from lowercase sequences.
  8472. // `data_For_USACounties` → `data_for_USA_counties`
  8473. return decamelized.replace(
  8474. /(\p{Uppercase_Letter}+)(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
  8475. (_, $1, $2) => $1 + separator + $2.toLowerCase(),
  8476. );
  8477. };
  8478. function decamelize(
  8479. text,
  8480. {
  8481. separator = '_',
  8482. preserveConsecutiveUppercase = false,
  8483. } = {},
  8484. ) {
  8485. if (!(typeof text === 'string' && typeof separator === 'string')) {
  8486. throw new TypeError(
  8487. 'The `text` and `separator` arguments should be of type `string`',
  8488. );
  8489. }
  8490. // Checking the second character is done later on. Therefore process shorter strings here.
  8491. if (text.length < 2) {
  8492. return preserveConsecutiveUppercase ? text : text.toLowerCase();
  8493. }
  8494. const replacement = `$1${separator}$2`;
  8495. // Split lowercase sequences followed by uppercase character.
  8496. // `dataForUSACounties` → `data_For_USACounties`
  8497. // `myURLstring → `my_URLstring`
  8498. const decamelized = text.replace(
  8499. /([\p{Lowercase_Letter}\d])(\p{Uppercase_Letter})/gu,
  8500. replacement,
  8501. );
  8502. if (preserveConsecutiveUppercase) {
  8503. return handlePreserveConsecutiveUppercase(decamelized, separator);
  8504. }
  8505. // Split multiple uppercase characters followed by one or more lowercase characters.
  8506. // `my_URLstring` → `my_ur_lstring`
  8507. return decamelized
  8508. .replace(
  8509. /(\p{Uppercase_Letter})(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
  8510. replacement,
  8511. )
  8512. .toLowerCase();
  8513. }
  8514. var minimistOptions = {exports: {}};
  8515. var toString$1 = Object.prototype.toString;
  8516. var isPlainObj = function (x) {
  8517. var prototype;
  8518. return toString$1.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
  8519. };
  8520. var arrify$1 = function (val) {
  8521. if (val === null || val === undefined) {
  8522. return [];
  8523. }
  8524. return Array.isArray(val) ? val : [val];
  8525. };
  8526. var toString = Object.prototype.toString;
  8527. var kindOf$1 = function kindOf(val) {
  8528. if (val === void 0) return 'undefined';
  8529. if (val === null) return 'null';
  8530. var type = typeof val;
  8531. if (type === 'boolean') return 'boolean';
  8532. if (type === 'string') return 'string';
  8533. if (type === 'number') return 'number';
  8534. if (type === 'symbol') return 'symbol';
  8535. if (type === 'function') {
  8536. return isGeneratorFn(val) ? 'generatorfunction' : 'function';
  8537. }
  8538. if (isArray(val)) return 'array';
  8539. if (isBuffer(val)) return 'buffer';
  8540. if (isArguments(val)) return 'arguments';
  8541. if (isDate(val)) return 'date';
  8542. if (isError(val)) return 'error';
  8543. if (isRegexp(val)) return 'regexp';
  8544. switch (ctorName(val)) {
  8545. case 'Symbol': return 'symbol';
  8546. case 'Promise': return 'promise';
  8547. // Set, Map, WeakSet, WeakMap
  8548. case 'WeakMap': return 'weakmap';
  8549. case 'WeakSet': return 'weakset';
  8550. case 'Map': return 'map';
  8551. case 'Set': return 'set';
  8552. // 8-bit typed arrays
  8553. case 'Int8Array': return 'int8array';
  8554. case 'Uint8Array': return 'uint8array';
  8555. case 'Uint8ClampedArray': return 'uint8clampedarray';
  8556. // 16-bit typed arrays
  8557. case 'Int16Array': return 'int16array';
  8558. case 'Uint16Array': return 'uint16array';
  8559. // 32-bit typed arrays
  8560. case 'Int32Array': return 'int32array';
  8561. case 'Uint32Array': return 'uint32array';
  8562. case 'Float32Array': return 'float32array';
  8563. case 'Float64Array': return 'float64array';
  8564. }
  8565. if (isGeneratorObj(val)) {
  8566. return 'generator';
  8567. }
  8568. // Non-plain objects
  8569. type = toString.call(val);
  8570. switch (type) {
  8571. case '[object Object]': return 'object';
  8572. // iterators
  8573. case '[object Map Iterator]': return 'mapiterator';
  8574. case '[object Set Iterator]': return 'setiterator';
  8575. case '[object String Iterator]': return 'stringiterator';
  8576. case '[object Array Iterator]': return 'arrayiterator';
  8577. }
  8578. // other
  8579. return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
  8580. };
  8581. function ctorName(val) {
  8582. return typeof val.constructor === 'function' ? val.constructor.name : null;
  8583. }
  8584. function isArray(val) {
  8585. if (Array.isArray) return Array.isArray(val);
  8586. return val instanceof Array;
  8587. }
  8588. function isError(val) {
  8589. return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
  8590. }
  8591. function isDate(val) {
  8592. if (val instanceof Date) return true;
  8593. return typeof val.toDateString === 'function'
  8594. && typeof val.getDate === 'function'
  8595. && typeof val.setDate === 'function';
  8596. }
  8597. function isRegexp(val) {
  8598. if (val instanceof RegExp) return true;
  8599. return typeof val.flags === 'string'
  8600. && typeof val.ignoreCase === 'boolean'
  8601. && typeof val.multiline === 'boolean'
  8602. && typeof val.global === 'boolean';
  8603. }
  8604. function isGeneratorFn(name, val) {
  8605. return ctorName(name) === 'GeneratorFunction';
  8606. }
  8607. function isGeneratorObj(val) {
  8608. return typeof val.throw === 'function'
  8609. && typeof val.return === 'function'
  8610. && typeof val.next === 'function';
  8611. }
  8612. function isArguments(val) {
  8613. try {
  8614. if (typeof val.length === 'number' && typeof val.callee === 'function') {
  8615. return true;
  8616. }
  8617. } catch (err) {
  8618. if (err.message.indexOf('callee') !== -1) {
  8619. return true;
  8620. }
  8621. }
  8622. return false;
  8623. }
  8624. /**
  8625. * If you need to support Safari 5-7 (8-10 yr-old browser),
  8626. * take a look at https://github.com/feross/is-buffer
  8627. */
  8628. function isBuffer(val) {
  8629. if (val.constructor && typeof val.constructor.isBuffer === 'function') {
  8630. return val.constructor.isBuffer(val);
  8631. }
  8632. return false;
  8633. }
  8634. const isPlainObject = isPlainObj;
  8635. const arrify = arrify$1;
  8636. const kindOf = kindOf$1;
  8637. const push = (obj, prop, value) => {
  8638. if (!obj[prop]) {
  8639. obj[prop] = [];
  8640. }
  8641. obj[prop].push(value);
  8642. };
  8643. const insert = (obj, prop, key, value) => {
  8644. if (!obj[prop]) {
  8645. obj[prop] = {};
  8646. }
  8647. obj[prop][key] = value;
  8648. };
  8649. const prettyPrint = output => {
  8650. return Array.isArray(output) ?
  8651. `[${output.map(prettyPrint).join(', ')}]` :
  8652. kindOf(output) === 'string' ? JSON.stringify(output) : output;
  8653. };
  8654. const resolveType = value => {
  8655. if (Array.isArray(value) && value.length > 0) {
  8656. const [element] = value;
  8657. return `${kindOf(element)}-array`;
  8658. }
  8659. return kindOf(value);
  8660. };
  8661. const normalizeExpectedType = (type, defaultValue) => {
  8662. const inferredType = type === 'array' ? 'string-array' : type;
  8663. if (arrayTypes.includes(inferredType) && Array.isArray(defaultValue) && defaultValue.length === 0) {
  8664. return 'array';
  8665. }
  8666. return inferredType;
  8667. };
  8668. const passthroughOptions = ['stopEarly', 'unknown', '--'];
  8669. const primitiveTypes = ['string', 'boolean', 'number'];
  8670. const arrayTypes = primitiveTypes.map(t => `${t}-array`);
  8671. const availableTypes = [...primitiveTypes, 'array', ...arrayTypes];
  8672. const buildOptions = options => {
  8673. options = options || {};
  8674. const result = {};
  8675. passthroughOptions.forEach(key => {
  8676. if (options[key]) {
  8677. result[key] = options[key];
  8678. }
  8679. });
  8680. Object.keys(options).forEach(key => {
  8681. let value = options[key];
  8682. if (key === 'arguments') {
  8683. key = '_';
  8684. }
  8685. // If short form is used
  8686. // convert it to long form
  8687. // e.g. { 'name': 'string' }
  8688. if (typeof value === 'string') {
  8689. value = {type: value};
  8690. }
  8691. if (isPlainObject(value)) {
  8692. const props = value;
  8693. const {type} = props;
  8694. if (type) {
  8695. if (!availableTypes.includes(type)) {
  8696. throw new TypeError(`Expected type of "${key}" to be one of ${prettyPrint(availableTypes)}, got ${prettyPrint(type)}`);
  8697. }
  8698. if (arrayTypes.includes(type)) {
  8699. const [elementType] = type.split('-');
  8700. push(result, 'array', {key, [elementType]: true});
  8701. } else {
  8702. push(result, type, key);
  8703. }
  8704. }
  8705. if ({}.hasOwnProperty.call(props, 'default')) {
  8706. const {default: defaultValue} = props;
  8707. const defaultType = resolveType(defaultValue);
  8708. const expectedType = normalizeExpectedType(type, defaultValue);
  8709. if (expectedType && expectedType !== defaultType) {
  8710. throw new TypeError(`Expected "${key}" default value to be of type "${expectedType}", got ${prettyPrint(defaultType)}`);
  8711. }
  8712. insert(result, 'default', key, defaultValue);
  8713. }
  8714. arrify(props.alias).forEach(alias => {
  8715. insert(result, 'alias', alias, key);
  8716. });
  8717. }
  8718. });
  8719. return result;
  8720. };
  8721. minimistOptions.exports = buildOptions;
  8722. minimistOptions.exports.default = buildOptions;
  8723. var minimistOptionsExports = minimistOptions.exports;
  8724. const constructParserOptions = /*@__PURE__*/getDefaultExportFromCjs(minimistOptionsExports);
  8725. var mapObj = {exports: {}};
  8726. const isObject$1 = value => typeof value === 'object' && value !== null;
  8727. const mapObjectSkip = Symbol('skip');
  8728. // Customized for this use-case
  8729. const isObjectCustom = value =>
  8730. isObject$1(value) &&
  8731. !(value instanceof RegExp) &&
  8732. !(value instanceof Error) &&
  8733. !(value instanceof Date);
  8734. const mapObject = (object, mapper, options, isSeen = new WeakMap()) => {
  8735. options = {
  8736. deep: false,
  8737. target: {},
  8738. ...options
  8739. };
  8740. if (isSeen.has(object)) {
  8741. return isSeen.get(object);
  8742. }
  8743. isSeen.set(object, options.target);
  8744. const {target} = options;
  8745. delete options.target;
  8746. const mapArray = array => array.map(element => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element);
  8747. if (Array.isArray(object)) {
  8748. return mapArray(object);
  8749. }
  8750. for (const [key, value] of Object.entries(object)) {
  8751. const mapResult = mapper(key, value, object);
  8752. if (mapResult === mapObjectSkip) {
  8753. continue;
  8754. }
  8755. let [newKey, newValue, {shouldRecurse = true} = {}] = mapResult;
  8756. // Drop `__proto__` keys.
  8757. if (newKey === '__proto__') {
  8758. continue;
  8759. }
  8760. if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
  8761. newValue = Array.isArray(newValue) ?
  8762. mapArray(newValue) :
  8763. mapObject(newValue, mapper, options, isSeen);
  8764. }
  8765. target[newKey] = newValue;
  8766. }
  8767. return target;
  8768. };
  8769. mapObj.exports = (object, mapper, options) => {
  8770. if (!isObject$1(object)) {
  8771. throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
  8772. }
  8773. return mapObject(object, mapper, options);
  8774. };
  8775. mapObj.exports.mapObjectSkip = mapObjectSkip;
  8776. var mapObjExports = mapObj.exports;
  8777. const mapObject$1 = /*@__PURE__*/getDefaultExportFromCjs(mapObjExports);
  8778. const has = (array, key) => array.some(element => {
  8779. if (typeof element === 'string') {
  8780. return element === key;
  8781. }
  8782. element.lastIndex = 0;
  8783. return element.test(key);
  8784. });
  8785. const cache = new QuickLRU({maxSize: 100_000});
  8786. // Reproduces behavior from `map-obj`.
  8787. const isObject = value =>
  8788. typeof value === 'object'
  8789. && value !== null
  8790. && !(value instanceof RegExp)
  8791. && !(value instanceof Error)
  8792. && !(value instanceof Date);
  8793. const transform = (input, options = {}) => {
  8794. if (!isObject(input)) {
  8795. return input;
  8796. }
  8797. const {
  8798. separator = '_',
  8799. exclude,
  8800. deep = false,
  8801. } = options;
  8802. const makeMapper = parentPath => (key, value) => {
  8803. if (deep && isObject(value)) {
  8804. value = mapObject$1(value, makeMapper());
  8805. }
  8806. if (!(exclude && has(exclude, key))) {
  8807. const cacheKey = `${separator}${key}`;
  8808. if (cache.has(cacheKey)) {
  8809. key = cache.get(cacheKey);
  8810. } else {
  8811. const returnValue = decamelize(key, {separator});
  8812. if (key.length < 100) { // Prevent abuse
  8813. cache.set(cacheKey, returnValue);
  8814. }
  8815. key = returnValue;
  8816. }
  8817. }
  8818. return [key, value];
  8819. };
  8820. return mapObject$1(input, makeMapper());
  8821. };
  8822. function decamelizeKeys(input, options) {
  8823. if (Array.isArray(input)) {
  8824. return Object.keys(input).map(key => transform(input[key], options));
  8825. }
  8826. return transform(input, options);
  8827. }
  8828. export { readPackageUpSync as a, constructParserOptions as b, camelcaseKeys as c, decamelizeKeys as d, decamelize as e, normalizePackageData as n, redent as r, trimNewlines as t, yargsParser as y };