network.js 210 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471
  1. var drawChart = (function (exports) {
  2. 'use strict';
  3. var n,l$1,u$1,t$1,o$2,r$1,f$1={},e$1=[],c$2=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a$2(n){var l=n.parentNode;l&&l.removeChild(n);}function h$1(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return v$1(l,f,t,o,null)}function v$1(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u$1:r};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function p$1(n){return n.children}function d$1(n,l){this.props=n,this.context=l;}function _$2(n,l){if(null==l)return n.__?_$2(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?_$2(n):null}function k$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k$1(n)}}function b$1(n){(!n.__d&&(n.__d=!0)&&t$1.push(n)&&!g$1.__r++||o$2!==l$1.debounceRendering)&&((o$2=l$1.debounceRendering)||setTimeout)(g$1);}function g$1(){for(var n;g$1.__r=t$1.length;)n=t$1.sort(function(n,l){return n.__v.__b-l.__v.__b}),t$1=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=s({},t)).__v=t.__v+1,j$1(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?_$2(t):o,t.__h),z$1(u,t),t.__e!=o&&k$1(t)));});}function w$1(n,l,u,i,t,o,r,c,s,a){var h,y,d,k,b,g,w,x=i&&i.__k||e$1,C=x.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$1(null,k,null,null,k):Array.isArray(k)?v$1(p$1,{children:k},null,null,null):k.__b>0?v$1(k.type,k.props,k.key,k.ref?k.ref:null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(d=x[h])||d&&k.key==d.key&&k.type===d.type)x[h]=void 0;else for(y=0;y<C;y++){if((d=x[y])&&k.key==d.key&&k.type===d.type){x[y]=void 0;break}d=null;}j$1(n,k,d=d||f$1,t,o,r,c,s,a),b=k.__e,(y=k.ref)&&d.ref!=y&&(w||(w=[]),d.ref&&w.push(d.ref,null,k),w.push(y,k.__c||b,k)),null!=b?(null==g&&(g=b),"function"==typeof k.type&&k.__k===d.__k?k.__d=s=m$2(k,s,n):s=A$1(n,k,d,x,b,s),"function"==typeof u.type&&(u.__d=s)):s&&d.__e==s&&s.parentNode!=n&&(s=_$2(d));}for(u.__e=g,h=C;h--;)null!=x[h]&&N(x[h],x[h]);if(w)for(h=0;h<w.length;h++)M(w[h],w[++h],w[++h]);}function m$2(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?m$2(i,l,u):A$1(u,i,i,t,i.__e,l));return l}function A$1(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=1)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function C$1(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H(n,o,l[o],u[o],i);}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||c$2.test(l)?u:u+"px";}function H(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T$1:I,o):n.removeEventListener(l,o?T$1:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&-1==l.indexOf("-")?n.removeAttribute(l):n.setAttribute(l,u));}}function I(n){this.l[n.type+!1](l$1.event?l$1.event(n):n);}function T$1(n){this.l[n.type+!0](l$1.event?l$1.event(n):n);}function j$1(n,u,i,t,o,r,f,e,c){var a,h,v,y,_,k,b,g,m,x,A,C,$,H,I,T=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=l$1.__b)&&a(u);try{n:if("function"==typeof T){if(g=u.props,m=(a=T.contextType)&&t[a.__c],x=a?m?m.props.value:a.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in T&&T.prototype.render?u.__c=h=new T(g,x):(u.__c=h=new d$1(g,x),h.constructor=T,h.render=O),m&&m.sub(h),h.props=g,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=T.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=s({},h.__s)),s(h.__s,T.getDerivedStateFromProps(g,h.__s))),y=h.props,_=h.state,v)null==T.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==T.getDerivedStateFromProps&&g!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,x)||u.__v===i.__v){for(h.props=g,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),A=0;A<h._sb.length;A++)h.__h.push(h._sb[A]);h._sb=[],h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,_,k);});}if(h.context=x,h.props=g,h.__v=u,h.__P=n,C=l$1.__r,$=0,"prototype"in T&&T.prototype.render){for(h.state=h.__s,h.__d=!1,C&&C(u),a=h.render(h.props,h.state,h.context),H=0;H<h._sb.length;H++)h.__h.push(h._sb[H]);h._sb=[];}else do{h.__d=!1,C&&C(u),a=h.render(h.props,h.state,h.context),h.state=h.__s;}while(h.__d&&++$<25);h.state=h.__s,null!=h.getChildContext&&(t=s(s({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,_)),I=null!=a&&a.type===p$1&&null==a.key?a.props.children:a,w$1(n,Array.isArray(I)?I:[I],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,o,r,f,c);(a=l$1.diffed)&&a(u);}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),l$1.__e(n,u,i);}}function z$1(n,u){l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function L(l,u,i,t,o,r,e,c){var s,h,v,y=i.props,p=u.props,d=u.type,k=0;if("svg"===d&&(o=!0),null!=r)for(;k<r.length;k++)if((s=r[k])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[k]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1;}if(null===d)y===p||c&&l.data===p||(l.data=p);else {if(r=r&&n.call(l.childNodes),h=(y=i.props||f$1).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},k=0;k<l.attributes.length;k++)y[l.attributes[k].name]=l.attributes[k].value;(v||h)&&(v&&(h&&v.__html==h.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""));}if(C$1(l,p,y,o,c),v)u.__k=[];else if(k=u.props.children,w$1(l,Array.isArray(k)?k:[k],u,i,t,o&&"foreignObject"!==d,r,e,r?r[0]:i.__k&&_$2(i,0),c),null!=r)for(k=r.length;k--;)null!=r[k]&&a$2(r[k]);c||("value"in p&&void 0!==(k=p.value)&&(k!==l.value||"progress"===d&&!k||"option"===d&&k!==y.value)&&H(l,"value",k,y.value,!1),"checked"in p&&void 0!==(k=p.checked)&&k!==l.checked&&H(l,"checked",k,y.checked,!1));}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,i);}}function N(n,u,i){var t,o;if(l$1.unmount&&l$1.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l$1.__e(n,u);}t.base=t.__P=null,n.__c=void 0;}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,i||"function"!=typeof n.type);i||null==n.__e||a$2(n.__e),n.__=n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function P(u,i,t){var o,r,e;l$1.__&&l$1.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,e=[],j$1(i,u=(!o&&t||i).__k=h$1(p$1,null,[u]),r||f$1,f$1,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?n.call(i.childNodes):null,e,!o&&t?t:r?r.__e:i.firstChild,o),z$1(e,u);}function B$2(n,l){var u={__c:l="__cC"+r$1++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(b$1);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=e$1.slice,l$1={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l;}throw n}},u$1=0,d$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=s({},this.state),"function"==typeof n&&(n=n(s({},u),this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),b$1(this));},d$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),b$1(this));},d$1.prototype.render=p$1,t$1=[],g$1.__r=0,r$1=0;
  4. var _$1=0;function o$1(o,e,n,t,f){var l,s,u={};for(s in e)"ref"==s?l=e[s]:u[s]=e[s];var a={type:o,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--_$1,__source:f,__self:t};if("function"==typeof o&&(l=o.defaultProps))for(s in l)void 0===u[s]&&(u[s]=l[s]);return l$1.vnode&&l$1.vnode(a),a}
  5. const LABELS = {
  6. renderedLength: "Rendered",
  7. gzipLength: "Gzip",
  8. brotliLength: "Brotli",
  9. };
  10. const getAvailableSizeOptions = (options) => {
  11. const availableSizeProperties = ["renderedLength"];
  12. if (options.gzip) {
  13. availableSizeProperties.push("gzipLength");
  14. }
  15. if (options.brotli) {
  16. availableSizeProperties.push("brotliLength");
  17. }
  18. return availableSizeProperties;
  19. };
  20. var t,r,u,i,o=0,f=[],c$1=[],e=l$1.__b,a$1=l$1.__r,v=l$1.diffed,l=l$1.__c,m$1=l$1.unmount;function d(t,u){l$1.__h&&l$1.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c$1}),i.__[t]}function p(n){return o=1,y$2(B$1,n)}function y$2(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B$1(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}));}],o.__c=r,!r.u)){r.u=!0;var f=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,r){if(!o.__c.__H)return !0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return !n.__N}))return !f||f.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0);}}),!(!i&&o.__c.props===n)&&(!f||f.call(this,n,t,r))};}return o.__N||o.__}function h(u,i){var o=d(t++,3);!l$1.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o));}function _(n){return o=5,F(function(){return {current:n}},[])}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[];}catch(r){t.__H.__h=[],l$1.__e(r,t.__v);}}l$1.__b=function(n){r=null,e&&e(n);},l$1.__r=function(n){a$1&&a$1(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c$1,n.__N=n.i=void 0;})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[])),u=r;},l$1.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===l$1.requestAnimationFrame||((i=l$1.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c$1&&(n.__=n.__V),n.i=void 0,n.__V=c$1;})),u=r=null;},l$1.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return !n.__||w(n)});}catch(u){r.some(function(n){n.__h&&(n.__h=[]);}),r=[],l$1.__e(u,t.__v);}}),l&&l(t,r);},l$1.unmount=function(t){m$1&&m$1(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n);}catch(n){r=n;}}),u.__H=void 0,r&&l$1.__e(r,u.__v));};var g="function"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r));}function k(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function w(n){var t=r;n.__c=n.__(),r=t;}function z(n,t){return !n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B$1(n,t){return "function"==typeof t?t(n):t}
  21. function ascending(a, b) {
  22. return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
  23. }
  24. function descending(a, b) {
  25. return a == null || b == null ? NaN
  26. : b < a ? -1
  27. : b > a ? 1
  28. : b >= a ? 0
  29. : NaN;
  30. }
  31. function bisector(f) {
  32. let compare1, compare2, delta;
  33. // If an accessor is specified, promote it to a comparator. In this case we
  34. // can test whether the search value is (self-) comparable. We can’t do this
  35. // for a comparator (except for specific, known comparators) because we can’t
  36. // tell if the comparator is symmetric, and an asymmetric comparator can’t be
  37. // used to test whether a single value is comparable.
  38. if (f.length !== 2) {
  39. compare1 = ascending;
  40. compare2 = (d, x) => ascending(f(d), x);
  41. delta = (d, x) => f(d) - x;
  42. } else {
  43. compare1 = f === ascending || f === descending ? f : zero$1;
  44. compare2 = f;
  45. delta = f;
  46. }
  47. function left(a, x, lo = 0, hi = a.length) {
  48. if (lo < hi) {
  49. if (compare1(x, x) !== 0) return hi;
  50. do {
  51. const mid = (lo + hi) >>> 1;
  52. if (compare2(a[mid], x) < 0) lo = mid + 1;
  53. else hi = mid;
  54. } while (lo < hi);
  55. }
  56. return lo;
  57. }
  58. function right(a, x, lo = 0, hi = a.length) {
  59. if (lo < hi) {
  60. if (compare1(x, x) !== 0) return hi;
  61. do {
  62. const mid = (lo + hi) >>> 1;
  63. if (compare2(a[mid], x) <= 0) lo = mid + 1;
  64. else hi = mid;
  65. } while (lo < hi);
  66. }
  67. return lo;
  68. }
  69. function center(a, x, lo = 0, hi = a.length) {
  70. const i = left(a, x, lo, hi - 1);
  71. return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
  72. }
  73. return {left, center, right};
  74. }
  75. function zero$1() {
  76. return 0;
  77. }
  78. function number$1(x) {
  79. return x === null ? NaN : +x;
  80. }
  81. const ascendingBisect = bisector(ascending);
  82. const bisectRight = ascendingBisect.right;
  83. bisector(number$1).center;
  84. var e10 = Math.sqrt(50),
  85. e5 = Math.sqrt(10),
  86. e2 = Math.sqrt(2);
  87. function ticks(start, stop, count) {
  88. var reverse,
  89. i = -1,
  90. n,
  91. ticks,
  92. step;
  93. stop = +stop, start = +start, count = +count;
  94. if (start === stop && count > 0) return [start];
  95. if (reverse = stop < start) n = start, start = stop, stop = n;
  96. if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
  97. if (step > 0) {
  98. let r0 = Math.round(start / step), r1 = Math.round(stop / step);
  99. if (r0 * step < start) ++r0;
  100. if (r1 * step > stop) --r1;
  101. ticks = new Array(n = r1 - r0 + 1);
  102. while (++i < n) ticks[i] = (r0 + i) * step;
  103. } else {
  104. step = -step;
  105. let r0 = Math.round(start * step), r1 = Math.round(stop * step);
  106. if (r0 / step < start) ++r0;
  107. if (r1 / step > stop) --r1;
  108. ticks = new Array(n = r1 - r0 + 1);
  109. while (++i < n) ticks[i] = (r0 + i) / step;
  110. }
  111. if (reverse) ticks.reverse();
  112. return ticks;
  113. }
  114. function tickIncrement(start, stop, count) {
  115. var step = (stop - start) / Math.max(0, count),
  116. power = Math.floor(Math.log(step) / Math.LN10),
  117. error = step / Math.pow(10, power);
  118. return power >= 0
  119. ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
  120. : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
  121. }
  122. function tickStep(start, stop, count) {
  123. var step0 = Math.abs(stop - start) / Math.max(0, count),
  124. step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
  125. error = step0 / step1;
  126. if (error >= e10) step1 *= 10;
  127. else if (error >= e5) step1 *= 5;
  128. else if (error >= e2) step1 *= 2;
  129. return stop < start ? -step1 : step1;
  130. }
  131. function max(values, valueof) {
  132. let max;
  133. if (valueof === undefined) {
  134. for (const value of values) {
  135. if (value != null
  136. && (max < value || (max === undefined && value >= value))) {
  137. max = value;
  138. }
  139. }
  140. } else {
  141. let index = -1;
  142. for (let value of values) {
  143. if ((value = valueof(value, ++index, values)) != null
  144. && (max < value || (max === undefined && value >= value))) {
  145. max = value;
  146. }
  147. }
  148. }
  149. return max;
  150. }
  151. function initRange(domain, range) {
  152. switch (arguments.length) {
  153. case 0: break;
  154. case 1: this.range(domain); break;
  155. default: this.range(range).domain(domain); break;
  156. }
  157. return this;
  158. }
  159. function initInterpolator(domain, interpolator) {
  160. switch (arguments.length) {
  161. case 0: break;
  162. case 1: {
  163. if (typeof domain === "function") this.interpolator(domain);
  164. else this.range(domain);
  165. break;
  166. }
  167. default: {
  168. this.domain(domain);
  169. if (typeof interpolator === "function") this.interpolator(interpolator);
  170. else this.range(interpolator);
  171. break;
  172. }
  173. }
  174. return this;
  175. }
  176. function define(constructor, factory, prototype) {
  177. constructor.prototype = factory.prototype = prototype;
  178. prototype.constructor = constructor;
  179. }
  180. function extend(parent, definition) {
  181. var prototype = Object.create(parent.prototype);
  182. for (var key in definition) prototype[key] = definition[key];
  183. return prototype;
  184. }
  185. function Color() {}
  186. var darker = 0.7;
  187. var brighter = 1 / darker;
  188. var reI = "\\s*([+-]?\\d+)\\s*",
  189. reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
  190. reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
  191. reHex = /^#([0-9a-f]{3,8})$/,
  192. reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
  193. reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
  194. reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
  195. reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
  196. reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
  197. reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
  198. var named = {
  199. aliceblue: 0xf0f8ff,
  200. antiquewhite: 0xfaebd7,
  201. aqua: 0x00ffff,
  202. aquamarine: 0x7fffd4,
  203. azure: 0xf0ffff,
  204. beige: 0xf5f5dc,
  205. bisque: 0xffe4c4,
  206. black: 0x000000,
  207. blanchedalmond: 0xffebcd,
  208. blue: 0x0000ff,
  209. blueviolet: 0x8a2be2,
  210. brown: 0xa52a2a,
  211. burlywood: 0xdeb887,
  212. cadetblue: 0x5f9ea0,
  213. chartreuse: 0x7fff00,
  214. chocolate: 0xd2691e,
  215. coral: 0xff7f50,
  216. cornflowerblue: 0x6495ed,
  217. cornsilk: 0xfff8dc,
  218. crimson: 0xdc143c,
  219. cyan: 0x00ffff,
  220. darkblue: 0x00008b,
  221. darkcyan: 0x008b8b,
  222. darkgoldenrod: 0xb8860b,
  223. darkgray: 0xa9a9a9,
  224. darkgreen: 0x006400,
  225. darkgrey: 0xa9a9a9,
  226. darkkhaki: 0xbdb76b,
  227. darkmagenta: 0x8b008b,
  228. darkolivegreen: 0x556b2f,
  229. darkorange: 0xff8c00,
  230. darkorchid: 0x9932cc,
  231. darkred: 0x8b0000,
  232. darksalmon: 0xe9967a,
  233. darkseagreen: 0x8fbc8f,
  234. darkslateblue: 0x483d8b,
  235. darkslategray: 0x2f4f4f,
  236. darkslategrey: 0x2f4f4f,
  237. darkturquoise: 0x00ced1,
  238. darkviolet: 0x9400d3,
  239. deeppink: 0xff1493,
  240. deepskyblue: 0x00bfff,
  241. dimgray: 0x696969,
  242. dimgrey: 0x696969,
  243. dodgerblue: 0x1e90ff,
  244. firebrick: 0xb22222,
  245. floralwhite: 0xfffaf0,
  246. forestgreen: 0x228b22,
  247. fuchsia: 0xff00ff,
  248. gainsboro: 0xdcdcdc,
  249. ghostwhite: 0xf8f8ff,
  250. gold: 0xffd700,
  251. goldenrod: 0xdaa520,
  252. gray: 0x808080,
  253. green: 0x008000,
  254. greenyellow: 0xadff2f,
  255. grey: 0x808080,
  256. honeydew: 0xf0fff0,
  257. hotpink: 0xff69b4,
  258. indianred: 0xcd5c5c,
  259. indigo: 0x4b0082,
  260. ivory: 0xfffff0,
  261. khaki: 0xf0e68c,
  262. lavender: 0xe6e6fa,
  263. lavenderblush: 0xfff0f5,
  264. lawngreen: 0x7cfc00,
  265. lemonchiffon: 0xfffacd,
  266. lightblue: 0xadd8e6,
  267. lightcoral: 0xf08080,
  268. lightcyan: 0xe0ffff,
  269. lightgoldenrodyellow: 0xfafad2,
  270. lightgray: 0xd3d3d3,
  271. lightgreen: 0x90ee90,
  272. lightgrey: 0xd3d3d3,
  273. lightpink: 0xffb6c1,
  274. lightsalmon: 0xffa07a,
  275. lightseagreen: 0x20b2aa,
  276. lightskyblue: 0x87cefa,
  277. lightslategray: 0x778899,
  278. lightslategrey: 0x778899,
  279. lightsteelblue: 0xb0c4de,
  280. lightyellow: 0xffffe0,
  281. lime: 0x00ff00,
  282. limegreen: 0x32cd32,
  283. linen: 0xfaf0e6,
  284. magenta: 0xff00ff,
  285. maroon: 0x800000,
  286. mediumaquamarine: 0x66cdaa,
  287. mediumblue: 0x0000cd,
  288. mediumorchid: 0xba55d3,
  289. mediumpurple: 0x9370db,
  290. mediumseagreen: 0x3cb371,
  291. mediumslateblue: 0x7b68ee,
  292. mediumspringgreen: 0x00fa9a,
  293. mediumturquoise: 0x48d1cc,
  294. mediumvioletred: 0xc71585,
  295. midnightblue: 0x191970,
  296. mintcream: 0xf5fffa,
  297. mistyrose: 0xffe4e1,
  298. moccasin: 0xffe4b5,
  299. navajowhite: 0xffdead,
  300. navy: 0x000080,
  301. oldlace: 0xfdf5e6,
  302. olive: 0x808000,
  303. olivedrab: 0x6b8e23,
  304. orange: 0xffa500,
  305. orangered: 0xff4500,
  306. orchid: 0xda70d6,
  307. palegoldenrod: 0xeee8aa,
  308. palegreen: 0x98fb98,
  309. paleturquoise: 0xafeeee,
  310. palevioletred: 0xdb7093,
  311. papayawhip: 0xffefd5,
  312. peachpuff: 0xffdab9,
  313. peru: 0xcd853f,
  314. pink: 0xffc0cb,
  315. plum: 0xdda0dd,
  316. powderblue: 0xb0e0e6,
  317. purple: 0x800080,
  318. rebeccapurple: 0x663399,
  319. red: 0xff0000,
  320. rosybrown: 0xbc8f8f,
  321. royalblue: 0x4169e1,
  322. saddlebrown: 0x8b4513,
  323. salmon: 0xfa8072,
  324. sandybrown: 0xf4a460,
  325. seagreen: 0x2e8b57,
  326. seashell: 0xfff5ee,
  327. sienna: 0xa0522d,
  328. silver: 0xc0c0c0,
  329. skyblue: 0x87ceeb,
  330. slateblue: 0x6a5acd,
  331. slategray: 0x708090,
  332. slategrey: 0x708090,
  333. snow: 0xfffafa,
  334. springgreen: 0x00ff7f,
  335. steelblue: 0x4682b4,
  336. tan: 0xd2b48c,
  337. teal: 0x008080,
  338. thistle: 0xd8bfd8,
  339. tomato: 0xff6347,
  340. turquoise: 0x40e0d0,
  341. violet: 0xee82ee,
  342. wheat: 0xf5deb3,
  343. white: 0xffffff,
  344. whitesmoke: 0xf5f5f5,
  345. yellow: 0xffff00,
  346. yellowgreen: 0x9acd32
  347. };
  348. define(Color, color, {
  349. copy(channels) {
  350. return Object.assign(new this.constructor, this, channels);
  351. },
  352. displayable() {
  353. return this.rgb().displayable();
  354. },
  355. hex: color_formatHex, // Deprecated! Use color.formatHex.
  356. formatHex: color_formatHex,
  357. formatHex8: color_formatHex8,
  358. formatHsl: color_formatHsl,
  359. formatRgb: color_formatRgb,
  360. toString: color_formatRgb
  361. });
  362. function color_formatHex() {
  363. return this.rgb().formatHex();
  364. }
  365. function color_formatHex8() {
  366. return this.rgb().formatHex8();
  367. }
  368. function color_formatHsl() {
  369. return hslConvert(this).formatHsl();
  370. }
  371. function color_formatRgb() {
  372. return this.rgb().formatRgb();
  373. }
  374. function color(format) {
  375. var m, l;
  376. format = (format + "").trim().toLowerCase();
  377. return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
  378. : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
  379. : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
  380. : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
  381. : null) // invalid hex
  382. : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
  383. : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
  384. : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
  385. : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
  386. : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
  387. : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
  388. : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
  389. : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
  390. : null;
  391. }
  392. function rgbn(n) {
  393. return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
  394. }
  395. function rgba(r, g, b, a) {
  396. if (a <= 0) r = g = b = NaN;
  397. return new Rgb(r, g, b, a);
  398. }
  399. function rgbConvert(o) {
  400. if (!(o instanceof Color)) o = color(o);
  401. if (!o) return new Rgb;
  402. o = o.rgb();
  403. return new Rgb(o.r, o.g, o.b, o.opacity);
  404. }
  405. function rgb$1(r, g, b, opacity) {
  406. return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
  407. }
  408. function Rgb(r, g, b, opacity) {
  409. this.r = +r;
  410. this.g = +g;
  411. this.b = +b;
  412. this.opacity = +opacity;
  413. }
  414. define(Rgb, rgb$1, extend(Color, {
  415. brighter(k) {
  416. k = k == null ? brighter : Math.pow(brighter, k);
  417. return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
  418. },
  419. darker(k) {
  420. k = k == null ? darker : Math.pow(darker, k);
  421. return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
  422. },
  423. rgb() {
  424. return this;
  425. },
  426. clamp() {
  427. return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
  428. },
  429. displayable() {
  430. return (-0.5 <= this.r && this.r < 255.5)
  431. && (-0.5 <= this.g && this.g < 255.5)
  432. && (-0.5 <= this.b && this.b < 255.5)
  433. && (0 <= this.opacity && this.opacity <= 1);
  434. },
  435. hex: rgb_formatHex, // Deprecated! Use color.formatHex.
  436. formatHex: rgb_formatHex,
  437. formatHex8: rgb_formatHex8,
  438. formatRgb: rgb_formatRgb,
  439. toString: rgb_formatRgb
  440. }));
  441. function rgb_formatHex() {
  442. return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
  443. }
  444. function rgb_formatHex8() {
  445. return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
  446. }
  447. function rgb_formatRgb() {
  448. const a = clampa(this.opacity);
  449. return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
  450. }
  451. function clampa(opacity) {
  452. return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
  453. }
  454. function clampi(value) {
  455. return Math.max(0, Math.min(255, Math.round(value) || 0));
  456. }
  457. function hex(value) {
  458. value = clampi(value);
  459. return (value < 16 ? "0" : "") + value.toString(16);
  460. }
  461. function hsla(h, s, l, a) {
  462. if (a <= 0) h = s = l = NaN;
  463. else if (l <= 0 || l >= 1) h = s = NaN;
  464. else if (s <= 0) h = NaN;
  465. return new Hsl(h, s, l, a);
  466. }
  467. function hslConvert(o) {
  468. if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
  469. if (!(o instanceof Color)) o = color(o);
  470. if (!o) return new Hsl;
  471. if (o instanceof Hsl) return o;
  472. o = o.rgb();
  473. var r = o.r / 255,
  474. g = o.g / 255,
  475. b = o.b / 255,
  476. min = Math.min(r, g, b),
  477. max = Math.max(r, g, b),
  478. h = NaN,
  479. s = max - min,
  480. l = (max + min) / 2;
  481. if (s) {
  482. if (r === max) h = (g - b) / s + (g < b) * 6;
  483. else if (g === max) h = (b - r) / s + 2;
  484. else h = (r - g) / s + 4;
  485. s /= l < 0.5 ? max + min : 2 - max - min;
  486. h *= 60;
  487. } else {
  488. s = l > 0 && l < 1 ? 0 : h;
  489. }
  490. return new Hsl(h, s, l, o.opacity);
  491. }
  492. function hsl(h, s, l, opacity) {
  493. return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
  494. }
  495. function Hsl(h, s, l, opacity) {
  496. this.h = +h;
  497. this.s = +s;
  498. this.l = +l;
  499. this.opacity = +opacity;
  500. }
  501. define(Hsl, hsl, extend(Color, {
  502. brighter(k) {
  503. k = k == null ? brighter : Math.pow(brighter, k);
  504. return new Hsl(this.h, this.s, this.l * k, this.opacity);
  505. },
  506. darker(k) {
  507. k = k == null ? darker : Math.pow(darker, k);
  508. return new Hsl(this.h, this.s, this.l * k, this.opacity);
  509. },
  510. rgb() {
  511. var h = this.h % 360 + (this.h < 0) * 360,
  512. s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
  513. l = this.l,
  514. m2 = l + (l < 0.5 ? l : 1 - l) * s,
  515. m1 = 2 * l - m2;
  516. return new Rgb(
  517. hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
  518. hsl2rgb(h, m1, m2),
  519. hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
  520. this.opacity
  521. );
  522. },
  523. clamp() {
  524. return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
  525. },
  526. displayable() {
  527. return (0 <= this.s && this.s <= 1 || isNaN(this.s))
  528. && (0 <= this.l && this.l <= 1)
  529. && (0 <= this.opacity && this.opacity <= 1);
  530. },
  531. formatHsl() {
  532. const a = clampa(this.opacity);
  533. return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
  534. }
  535. }));
  536. function clamph(value) {
  537. value = (value || 0) % 360;
  538. return value < 0 ? value + 360 : value;
  539. }
  540. function clampt(value) {
  541. return Math.max(0, Math.min(1, value || 0));
  542. }
  543. /* From FvD 13.37, CSS Color Module Level 3 */
  544. function hsl2rgb(h, m1, m2) {
  545. return (h < 60 ? m1 + (m2 - m1) * h / 60
  546. : h < 180 ? m2
  547. : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
  548. : m1) * 255;
  549. }
  550. const radians = Math.PI / 180;
  551. const degrees = 180 / Math.PI;
  552. // https://observablehq.com/@mbostock/lab-and-rgb
  553. const K = 18,
  554. Xn = 0.96422,
  555. Yn = 1,
  556. Zn = 0.82521,
  557. t0$1 = 4 / 29,
  558. t1$1 = 6 / 29,
  559. t2 = 3 * t1$1 * t1$1,
  560. t3 = t1$1 * t1$1 * t1$1;
  561. function labConvert(o) {
  562. if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
  563. if (o instanceof Hcl) return hcl2lab(o);
  564. if (!(o instanceof Rgb)) o = rgbConvert(o);
  565. var r = rgb2lrgb(o.r),
  566. g = rgb2lrgb(o.g),
  567. b = rgb2lrgb(o.b),
  568. y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
  569. if (r === g && g === b) x = z = y; else {
  570. x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
  571. z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
  572. }
  573. return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
  574. }
  575. function lab(l, a, b, opacity) {
  576. return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
  577. }
  578. function Lab(l, a, b, opacity) {
  579. this.l = +l;
  580. this.a = +a;
  581. this.b = +b;
  582. this.opacity = +opacity;
  583. }
  584. define(Lab, lab, extend(Color, {
  585. brighter(k) {
  586. return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
  587. },
  588. darker(k) {
  589. return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
  590. },
  591. rgb() {
  592. var y = (this.l + 16) / 116,
  593. x = isNaN(this.a) ? y : y + this.a / 500,
  594. z = isNaN(this.b) ? y : y - this.b / 200;
  595. x = Xn * lab2xyz(x);
  596. y = Yn * lab2xyz(y);
  597. z = Zn * lab2xyz(z);
  598. return new Rgb(
  599. lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
  600. lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
  601. lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
  602. this.opacity
  603. );
  604. }
  605. }));
  606. function xyz2lab(t) {
  607. return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1;
  608. }
  609. function lab2xyz(t) {
  610. return t > t1$1 ? t * t * t : t2 * (t - t0$1);
  611. }
  612. function lrgb2rgb(x) {
  613. return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
  614. }
  615. function rgb2lrgb(x) {
  616. return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
  617. }
  618. function hclConvert(o) {
  619. if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
  620. if (!(o instanceof Lab)) o = labConvert(o);
  621. if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
  622. var h = Math.atan2(o.b, o.a) * degrees;
  623. return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
  624. }
  625. function hcl(h, c, l, opacity) {
  626. return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
  627. }
  628. function Hcl(h, c, l, opacity) {
  629. this.h = +h;
  630. this.c = +c;
  631. this.l = +l;
  632. this.opacity = +opacity;
  633. }
  634. function hcl2lab(o) {
  635. if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
  636. var h = o.h * radians;
  637. return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
  638. }
  639. define(Hcl, hcl, extend(Color, {
  640. brighter(k) {
  641. return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
  642. },
  643. darker(k) {
  644. return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
  645. },
  646. rgb() {
  647. return hcl2lab(this).rgb();
  648. }
  649. }));
  650. var A = -0.14861,
  651. B = +1.78277,
  652. C = -0.29227,
  653. D = -0.90649,
  654. E = +1.97294,
  655. ED = E * D,
  656. EB = E * B,
  657. BC_DA = B * C - D * A;
  658. function cubehelixConvert(o) {
  659. if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
  660. if (!(o instanceof Rgb)) o = rgbConvert(o);
  661. var r = o.r / 255,
  662. g = o.g / 255,
  663. b = o.b / 255,
  664. l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
  665. bl = b - l,
  666. k = (E * (g - l) - C * bl) / D,
  667. s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
  668. h = s ? Math.atan2(k, bl) * degrees - 120 : NaN;
  669. return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
  670. }
  671. function cubehelix$1(h, s, l, opacity) {
  672. return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
  673. }
  674. function Cubehelix(h, s, l, opacity) {
  675. this.h = +h;
  676. this.s = +s;
  677. this.l = +l;
  678. this.opacity = +opacity;
  679. }
  680. define(Cubehelix, cubehelix$1, extend(Color, {
  681. brighter(k) {
  682. k = k == null ? brighter : Math.pow(brighter, k);
  683. return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
  684. },
  685. darker(k) {
  686. k = k == null ? darker : Math.pow(darker, k);
  687. return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
  688. },
  689. rgb() {
  690. var h = isNaN(this.h) ? 0 : (this.h + 120) * radians,
  691. l = +this.l,
  692. a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
  693. cosh = Math.cos(h),
  694. sinh = Math.sin(h);
  695. return new Rgb(
  696. 255 * (l + a * (A * cosh + B * sinh)),
  697. 255 * (l + a * (C * cosh + D * sinh)),
  698. 255 * (l + a * (E * cosh)),
  699. this.opacity
  700. );
  701. }
  702. }));
  703. var constant$1 = x => () => x;
  704. function linear(a, d) {
  705. return function(t) {
  706. return a + t * d;
  707. };
  708. }
  709. function exponential(a, b, y) {
  710. return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
  711. return Math.pow(a + t * b, y);
  712. };
  713. }
  714. function hue(a, b) {
  715. var d = b - a;
  716. return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$1(isNaN(a) ? b : a);
  717. }
  718. function gamma(y) {
  719. return (y = +y) === 1 ? nogamma : function(a, b) {
  720. return b - a ? exponential(a, b, y) : constant$1(isNaN(a) ? b : a);
  721. };
  722. }
  723. function nogamma(a, b) {
  724. var d = b - a;
  725. return d ? linear(a, d) : constant$1(isNaN(a) ? b : a);
  726. }
  727. var rgb = (function rgbGamma(y) {
  728. var color = gamma(y);
  729. function rgb(start, end) {
  730. var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
  731. g = color(start.g, end.g),
  732. b = color(start.b, end.b),
  733. opacity = nogamma(start.opacity, end.opacity);
  734. return function(t) {
  735. start.r = r(t);
  736. start.g = g(t);
  737. start.b = b(t);
  738. start.opacity = opacity(t);
  739. return start + "";
  740. };
  741. }
  742. rgb.gamma = rgbGamma;
  743. return rgb;
  744. })(1);
  745. function numberArray(a, b) {
  746. if (!b) b = [];
  747. var n = a ? Math.min(b.length, a.length) : 0,
  748. c = b.slice(),
  749. i;
  750. return function(t) {
  751. for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
  752. return c;
  753. };
  754. }
  755. function isNumberArray(x) {
  756. return ArrayBuffer.isView(x) && !(x instanceof DataView);
  757. }
  758. function genericArray(a, b) {
  759. var nb = b ? b.length : 0,
  760. na = a ? Math.min(nb, a.length) : 0,
  761. x = new Array(na),
  762. c = new Array(nb),
  763. i;
  764. for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
  765. for (; i < nb; ++i) c[i] = b[i];
  766. return function(t) {
  767. for (i = 0; i < na; ++i) c[i] = x[i](t);
  768. return c;
  769. };
  770. }
  771. function date(a, b) {
  772. var d = new Date;
  773. return a = +a, b = +b, function(t) {
  774. return d.setTime(a * (1 - t) + b * t), d;
  775. };
  776. }
  777. function interpolateNumber(a, b) {
  778. return a = +a, b = +b, function(t) {
  779. return a * (1 - t) + b * t;
  780. };
  781. }
  782. function object(a, b) {
  783. var i = {},
  784. c = {},
  785. k;
  786. if (a === null || typeof a !== "object") a = {};
  787. if (b === null || typeof b !== "object") b = {};
  788. for (k in b) {
  789. if (k in a) {
  790. i[k] = interpolate(a[k], b[k]);
  791. } else {
  792. c[k] = b[k];
  793. }
  794. }
  795. return function(t) {
  796. for (k in i) c[k] = i[k](t);
  797. return c;
  798. };
  799. }
  800. var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
  801. reB = new RegExp(reA.source, "g");
  802. function zero(b) {
  803. return function() {
  804. return b;
  805. };
  806. }
  807. function one(b) {
  808. return function(t) {
  809. return b(t) + "";
  810. };
  811. }
  812. function string(a, b) {
  813. var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
  814. am, // current match in a
  815. bm, // current match in b
  816. bs, // string preceding current number in b, if any
  817. i = -1, // index in s
  818. s = [], // string constants and placeholders
  819. q = []; // number interpolators
  820. // Coerce inputs to strings.
  821. a = a + "", b = b + "";
  822. // Interpolate pairs of numbers in a & b.
  823. while ((am = reA.exec(a))
  824. && (bm = reB.exec(b))) {
  825. if ((bs = bm.index) > bi) { // a string precedes the next number in b
  826. bs = b.slice(bi, bs);
  827. if (s[i]) s[i] += bs; // coalesce with previous string
  828. else s[++i] = bs;
  829. }
  830. if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
  831. if (s[i]) s[i] += bm; // coalesce with previous string
  832. else s[++i] = bm;
  833. } else { // interpolate non-matching numbers
  834. s[++i] = null;
  835. q.push({i: i, x: interpolateNumber(am, bm)});
  836. }
  837. bi = reB.lastIndex;
  838. }
  839. // Add remains of b.
  840. if (bi < b.length) {
  841. bs = b.slice(bi);
  842. if (s[i]) s[i] += bs; // coalesce with previous string
  843. else s[++i] = bs;
  844. }
  845. // Special optimization for only a single match.
  846. // Otherwise, interpolate each of the numbers and rejoin the string.
  847. return s.length < 2 ? (q[0]
  848. ? one(q[0].x)
  849. : zero(b))
  850. : (b = q.length, function(t) {
  851. for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
  852. return s.join("");
  853. });
  854. }
  855. function interpolate(a, b) {
  856. var t = typeof b, c;
  857. return b == null || t === "boolean" ? constant$1(b)
  858. : (t === "number" ? interpolateNumber
  859. : t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
  860. : b instanceof color ? rgb
  861. : b instanceof Date ? date
  862. : isNumberArray(b) ? numberArray
  863. : Array.isArray(b) ? genericArray
  864. : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
  865. : interpolateNumber)(a, b);
  866. }
  867. function interpolateRound(a, b) {
  868. return a = +a, b = +b, function(t) {
  869. return Math.round(a * (1 - t) + b * t);
  870. };
  871. }
  872. var epsilon2 = 1e-12;
  873. function cosh(x) {
  874. return ((x = Math.exp(x)) + 1 / x) / 2;
  875. }
  876. function sinh(x) {
  877. return ((x = Math.exp(x)) - 1 / x) / 2;
  878. }
  879. function tanh(x) {
  880. return ((x = Math.exp(2 * x)) - 1) / (x + 1);
  881. }
  882. ((function zoomRho(rho, rho2, rho4) {
  883. // p0 = [ux0, uy0, w0]
  884. // p1 = [ux1, uy1, w1]
  885. function zoom(p0, p1) {
  886. var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],
  887. ux1 = p1[0], uy1 = p1[1], w1 = p1[2],
  888. dx = ux1 - ux0,
  889. dy = uy1 - uy0,
  890. d2 = dx * dx + dy * dy,
  891. i,
  892. S;
  893. // Special case for u0 ≅ u1.
  894. if (d2 < epsilon2) {
  895. S = Math.log(w1 / w0) / rho;
  896. i = function(t) {
  897. return [
  898. ux0 + t * dx,
  899. uy0 + t * dy,
  900. w0 * Math.exp(rho * t * S)
  901. ];
  902. };
  903. }
  904. // General case.
  905. else {
  906. var d1 = Math.sqrt(d2),
  907. b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
  908. b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
  909. r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
  910. r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
  911. S = (r1 - r0) / rho;
  912. i = function(t) {
  913. var s = t * S,
  914. coshr0 = cosh(r0),
  915. u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
  916. return [
  917. ux0 + u * dx,
  918. uy0 + u * dy,
  919. w0 * coshr0 / cosh(rho * s + r0)
  920. ];
  921. };
  922. }
  923. i.duration = S * 1000 * rho / Math.SQRT2;
  924. return i;
  925. }
  926. zoom.rho = function(_) {
  927. var _1 = Math.max(1e-3, +_), _2 = _1 * _1, _4 = _2 * _2;
  928. return zoomRho(_1, _2, _4);
  929. };
  930. return zoom;
  931. }))(Math.SQRT2, 2, 4);
  932. function cubehelix(hue) {
  933. return (function cubehelixGamma(y) {
  934. y = +y;
  935. function cubehelix(start, end) {
  936. var h = hue((start = cubehelix$1(start)).h, (end = cubehelix$1(end)).h),
  937. s = nogamma(start.s, end.s),
  938. l = nogamma(start.l, end.l),
  939. opacity = nogamma(start.opacity, end.opacity);
  940. return function(t) {
  941. start.h = h(t);
  942. start.s = s(t);
  943. start.l = l(Math.pow(t, y));
  944. start.opacity = opacity(t);
  945. return start + "";
  946. };
  947. }
  948. cubehelix.gamma = cubehelixGamma;
  949. return cubehelix;
  950. })(1);
  951. }
  952. cubehelix(hue);
  953. cubehelix(nogamma);
  954. function constants$3(x) {
  955. return function() {
  956. return x;
  957. };
  958. }
  959. function number(x) {
  960. return +x;
  961. }
  962. var unit = [0, 1];
  963. function identity$1(x) {
  964. return x;
  965. }
  966. function normalize(a, b) {
  967. return (b -= (a = +a))
  968. ? function(x) { return (x - a) / b; }
  969. : constants$3(isNaN(b) ? NaN : 0.5);
  970. }
  971. function clamper(a, b) {
  972. var t;
  973. if (a > b) t = a, a = b, b = t;
  974. return function(x) { return Math.max(a, Math.min(b, x)); };
  975. }
  976. // normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
  977. // interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
  978. function bimap(domain, range, interpolate) {
  979. var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
  980. if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
  981. else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
  982. return function(x) { return r0(d0(x)); };
  983. }
  984. function polymap(domain, range, interpolate) {
  985. var j = Math.min(domain.length, range.length) - 1,
  986. d = new Array(j),
  987. r = new Array(j),
  988. i = -1;
  989. // Reverse descending domains.
  990. if (domain[j] < domain[0]) {
  991. domain = domain.slice().reverse();
  992. range = range.slice().reverse();
  993. }
  994. while (++i < j) {
  995. d[i] = normalize(domain[i], domain[i + 1]);
  996. r[i] = interpolate(range[i], range[i + 1]);
  997. }
  998. return function(x) {
  999. var i = bisectRight(domain, x, 1, j) - 1;
  1000. return r[i](d[i](x));
  1001. };
  1002. }
  1003. function copy$1(source, target) {
  1004. return target
  1005. .domain(source.domain())
  1006. .range(source.range())
  1007. .interpolate(source.interpolate())
  1008. .clamp(source.clamp())
  1009. .unknown(source.unknown());
  1010. }
  1011. function transformer$1() {
  1012. var domain = unit,
  1013. range = unit,
  1014. interpolate$1 = interpolate,
  1015. transform,
  1016. untransform,
  1017. unknown,
  1018. clamp = identity$1,
  1019. piecewise,
  1020. output,
  1021. input;
  1022. function rescale() {
  1023. var n = Math.min(domain.length, range.length);
  1024. if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
  1025. piecewise = n > 2 ? polymap : bimap;
  1026. output = input = null;
  1027. return scale;
  1028. }
  1029. function scale(x) {
  1030. return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
  1031. }
  1032. scale.invert = function(y) {
  1033. return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
  1034. };
  1035. scale.domain = function(_) {
  1036. return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
  1037. };
  1038. scale.range = function(_) {
  1039. return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
  1040. };
  1041. scale.rangeRound = function(_) {
  1042. return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
  1043. };
  1044. scale.clamp = function(_) {
  1045. return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
  1046. };
  1047. scale.interpolate = function(_) {
  1048. return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
  1049. };
  1050. scale.unknown = function(_) {
  1051. return arguments.length ? (unknown = _, scale) : unknown;
  1052. };
  1053. return function(t, u) {
  1054. transform = t, untransform = u;
  1055. return rescale();
  1056. };
  1057. }
  1058. function formatDecimal(x) {
  1059. return Math.abs(x = Math.round(x)) >= 1e21
  1060. ? x.toLocaleString("en").replace(/,/g, "")
  1061. : x.toString(10);
  1062. }
  1063. // Computes the decimal coefficient and exponent of the specified number x with
  1064. // significant digits p, where x is positive and p is in [1, 21] or undefined.
  1065. // For example, formatDecimalParts(1.23) returns ["123", 0].
  1066. function formatDecimalParts(x, p) {
  1067. if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
  1068. var i, coefficient = x.slice(0, i);
  1069. // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
  1070. // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
  1071. return [
  1072. coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
  1073. +x.slice(i + 1)
  1074. ];
  1075. }
  1076. function exponent(x) {
  1077. return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
  1078. }
  1079. function formatGroup(grouping, thousands) {
  1080. return function(value, width) {
  1081. var i = value.length,
  1082. t = [],
  1083. j = 0,
  1084. g = grouping[0],
  1085. length = 0;
  1086. while (i > 0 && g > 0) {
  1087. if (length + g + 1 > width) g = Math.max(1, width - length);
  1088. t.push(value.substring(i -= g, i + g));
  1089. if ((length += g + 1) > width) break;
  1090. g = grouping[j = (j + 1) % grouping.length];
  1091. }
  1092. return t.reverse().join(thousands);
  1093. };
  1094. }
  1095. function formatNumerals(numerals) {
  1096. return function(value) {
  1097. return value.replace(/[0-9]/g, function(i) {
  1098. return numerals[+i];
  1099. });
  1100. };
  1101. }
  1102. // [[fill]align][sign][symbol][0][width][,][.precision][~][type]
  1103. var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
  1104. function formatSpecifier(specifier) {
  1105. if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
  1106. var match;
  1107. return new FormatSpecifier({
  1108. fill: match[1],
  1109. align: match[2],
  1110. sign: match[3],
  1111. symbol: match[4],
  1112. zero: match[5],
  1113. width: match[6],
  1114. comma: match[7],
  1115. precision: match[8] && match[8].slice(1),
  1116. trim: match[9],
  1117. type: match[10]
  1118. });
  1119. }
  1120. formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
  1121. function FormatSpecifier(specifier) {
  1122. this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
  1123. this.align = specifier.align === undefined ? ">" : specifier.align + "";
  1124. this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
  1125. this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
  1126. this.zero = !!specifier.zero;
  1127. this.width = specifier.width === undefined ? undefined : +specifier.width;
  1128. this.comma = !!specifier.comma;
  1129. this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
  1130. this.trim = !!specifier.trim;
  1131. this.type = specifier.type === undefined ? "" : specifier.type + "";
  1132. }
  1133. FormatSpecifier.prototype.toString = function() {
  1134. return this.fill
  1135. + this.align
  1136. + this.sign
  1137. + this.symbol
  1138. + (this.zero ? "0" : "")
  1139. + (this.width === undefined ? "" : Math.max(1, this.width | 0))
  1140. + (this.comma ? "," : "")
  1141. + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
  1142. + (this.trim ? "~" : "")
  1143. + this.type;
  1144. };
  1145. // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
  1146. function formatTrim(s) {
  1147. out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
  1148. switch (s[i]) {
  1149. case ".": i0 = i1 = i; break;
  1150. case "0": if (i0 === 0) i0 = i; i1 = i; break;
  1151. default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
  1152. }
  1153. }
  1154. return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
  1155. }
  1156. var prefixExponent;
  1157. function formatPrefixAuto(x, p) {
  1158. var d = formatDecimalParts(x, p);
  1159. if (!d) return x + "";
  1160. var coefficient = d[0],
  1161. exponent = d[1],
  1162. i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
  1163. n = coefficient.length;
  1164. return i === n ? coefficient
  1165. : i > n ? coefficient + new Array(i - n + 1).join("0")
  1166. : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
  1167. : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
  1168. }
  1169. function formatRounded(x, p) {
  1170. var d = formatDecimalParts(x, p);
  1171. if (!d) return x + "";
  1172. var coefficient = d[0],
  1173. exponent = d[1];
  1174. return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
  1175. : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
  1176. : coefficient + new Array(exponent - coefficient.length + 2).join("0");
  1177. }
  1178. var formatTypes = {
  1179. "%": (x, p) => (x * 100).toFixed(p),
  1180. "b": (x) => Math.round(x).toString(2),
  1181. "c": (x) => x + "",
  1182. "d": formatDecimal,
  1183. "e": (x, p) => x.toExponential(p),
  1184. "f": (x, p) => x.toFixed(p),
  1185. "g": (x, p) => x.toPrecision(p),
  1186. "o": (x) => Math.round(x).toString(8),
  1187. "p": (x, p) => formatRounded(x * 100, p),
  1188. "r": formatRounded,
  1189. "s": formatPrefixAuto,
  1190. "X": (x) => Math.round(x).toString(16).toUpperCase(),
  1191. "x": (x) => Math.round(x).toString(16)
  1192. };
  1193. function identity(x) {
  1194. return x;
  1195. }
  1196. var map = Array.prototype.map,
  1197. prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
  1198. function formatLocale$1(locale) {
  1199. var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
  1200. currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
  1201. currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
  1202. decimal = locale.decimal === undefined ? "." : locale.decimal + "",
  1203. numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
  1204. percent = locale.percent === undefined ? "%" : locale.percent + "",
  1205. minus = locale.minus === undefined ? "−" : locale.minus + "",
  1206. nan = locale.nan === undefined ? "NaN" : locale.nan + "";
  1207. function newFormat(specifier) {
  1208. specifier = formatSpecifier(specifier);
  1209. var fill = specifier.fill,
  1210. align = specifier.align,
  1211. sign = specifier.sign,
  1212. symbol = specifier.symbol,
  1213. zero = specifier.zero,
  1214. width = specifier.width,
  1215. comma = specifier.comma,
  1216. precision = specifier.precision,
  1217. trim = specifier.trim,
  1218. type = specifier.type;
  1219. // The "n" type is an alias for ",g".
  1220. if (type === "n") comma = true, type = "g";
  1221. // The "" type, and any invalid type, is an alias for ".12~g".
  1222. else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
  1223. // If zero fill is specified, padding goes after sign and before digits.
  1224. if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
  1225. // Compute the prefix and suffix.
  1226. // For SI-prefix, the suffix is lazily computed.
  1227. var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
  1228. suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
  1229. // What format function should we use?
  1230. // Is this an integer type?
  1231. // Can this type generate exponential notation?
  1232. var formatType = formatTypes[type],
  1233. maybeSuffix = /[defgprs%]/.test(type);
  1234. // Set the default precision if not specified,
  1235. // or clamp the specified precision to the supported range.
  1236. // For significant precision, it must be in [1, 21].
  1237. // For fixed precision, it must be in [0, 20].
  1238. precision = precision === undefined ? 6
  1239. : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
  1240. : Math.max(0, Math.min(20, precision));
  1241. function format(value) {
  1242. var valuePrefix = prefix,
  1243. valueSuffix = suffix,
  1244. i, n, c;
  1245. if (type === "c") {
  1246. valueSuffix = formatType(value) + valueSuffix;
  1247. value = "";
  1248. } else {
  1249. value = +value;
  1250. // Determine the sign. -0 is not less than 0, but 1 / -0 is!
  1251. var valueNegative = value < 0 || 1 / value < 0;
  1252. // Perform the initial formatting.
  1253. value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
  1254. // Trim insignificant zeros.
  1255. if (trim) value = formatTrim(value);
  1256. // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
  1257. if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
  1258. // Compute the prefix and suffix.
  1259. valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
  1260. valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
  1261. // Break the formatted value into the integer “value” part that can be
  1262. // grouped, and fractional or exponential “suffix” part that is not.
  1263. if (maybeSuffix) {
  1264. i = -1, n = value.length;
  1265. while (++i < n) {
  1266. if (c = value.charCodeAt(i), 48 > c || c > 57) {
  1267. valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
  1268. value = value.slice(0, i);
  1269. break;
  1270. }
  1271. }
  1272. }
  1273. }
  1274. // If the fill character is not "0", grouping is applied before padding.
  1275. if (comma && !zero) value = group(value, Infinity);
  1276. // Compute the padding.
  1277. var length = valuePrefix.length + value.length + valueSuffix.length,
  1278. padding = length < width ? new Array(width - length + 1).join(fill) : "";
  1279. // If the fill character is "0", grouping is applied after padding.
  1280. if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
  1281. // Reconstruct the final output based on the desired alignment.
  1282. switch (align) {
  1283. case "<": value = valuePrefix + value + valueSuffix + padding; break;
  1284. case "=": value = valuePrefix + padding + value + valueSuffix; break;
  1285. case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
  1286. default: value = padding + valuePrefix + value + valueSuffix; break;
  1287. }
  1288. return numerals(value);
  1289. }
  1290. format.toString = function() {
  1291. return specifier + "";
  1292. };
  1293. return format;
  1294. }
  1295. function formatPrefix(specifier, value) {
  1296. var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
  1297. e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
  1298. k = Math.pow(10, -e),
  1299. prefix = prefixes[8 + e / 3];
  1300. return function(value) {
  1301. return f(k * value) + prefix;
  1302. };
  1303. }
  1304. return {
  1305. format: newFormat,
  1306. formatPrefix: formatPrefix
  1307. };
  1308. }
  1309. var locale$1;
  1310. var format;
  1311. var formatPrefix;
  1312. defaultLocale$1({
  1313. thousands: ",",
  1314. grouping: [3],
  1315. currency: ["$", ""]
  1316. });
  1317. function defaultLocale$1(definition) {
  1318. locale$1 = formatLocale$1(definition);
  1319. format = locale$1.format;
  1320. formatPrefix = locale$1.formatPrefix;
  1321. return locale$1;
  1322. }
  1323. function precisionFixed(step) {
  1324. return Math.max(0, -exponent(Math.abs(step)));
  1325. }
  1326. function precisionPrefix(step, value) {
  1327. return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
  1328. }
  1329. function precisionRound(step, max) {
  1330. step = Math.abs(step), max = Math.abs(max) - step;
  1331. return Math.max(0, exponent(max) - exponent(step)) + 1;
  1332. }
  1333. function tickFormat(start, stop, count, specifier) {
  1334. var step = tickStep(start, stop, count),
  1335. precision;
  1336. specifier = formatSpecifier(specifier == null ? ",f" : specifier);
  1337. switch (specifier.type) {
  1338. case "s": {
  1339. var value = Math.max(Math.abs(start), Math.abs(stop));
  1340. if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
  1341. return formatPrefix(specifier, value);
  1342. }
  1343. case "":
  1344. case "e":
  1345. case "g":
  1346. case "p":
  1347. case "r": {
  1348. if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
  1349. break;
  1350. }
  1351. case "f":
  1352. case "%": {
  1353. if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
  1354. break;
  1355. }
  1356. }
  1357. return format(specifier);
  1358. }
  1359. function linearish(scale) {
  1360. var domain = scale.domain;
  1361. scale.ticks = function(count) {
  1362. var d = domain();
  1363. return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
  1364. };
  1365. scale.tickFormat = function(count, specifier) {
  1366. var d = domain();
  1367. return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
  1368. };
  1369. scale.nice = function(count) {
  1370. if (count == null) count = 10;
  1371. var d = domain();
  1372. var i0 = 0;
  1373. var i1 = d.length - 1;
  1374. var start = d[i0];
  1375. var stop = d[i1];
  1376. var prestep;
  1377. var step;
  1378. var maxIter = 10;
  1379. if (stop < start) {
  1380. step = start, start = stop, stop = step;
  1381. step = i0, i0 = i1, i1 = step;
  1382. }
  1383. while (maxIter-- > 0) {
  1384. step = tickIncrement(start, stop, count);
  1385. if (step === prestep) {
  1386. d[i0] = start;
  1387. d[i1] = stop;
  1388. return domain(d);
  1389. } else if (step > 0) {
  1390. start = Math.floor(start / step) * step;
  1391. stop = Math.ceil(stop / step) * step;
  1392. } else if (step < 0) {
  1393. start = Math.ceil(start * step) / step;
  1394. stop = Math.floor(stop * step) / step;
  1395. } else {
  1396. break;
  1397. }
  1398. prestep = step;
  1399. }
  1400. return scale;
  1401. };
  1402. return scale;
  1403. }
  1404. function transformPow(exponent) {
  1405. return function(x) {
  1406. return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
  1407. };
  1408. }
  1409. function transformSqrt(x) {
  1410. return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x);
  1411. }
  1412. function transformSquare(x) {
  1413. return x < 0 ? -x * x : x * x;
  1414. }
  1415. function powish(transform) {
  1416. var scale = transform(identity$1, identity$1),
  1417. exponent = 1;
  1418. function rescale() {
  1419. return exponent === 1 ? transform(identity$1, identity$1)
  1420. : exponent === 0.5 ? transform(transformSqrt, transformSquare)
  1421. : transform(transformPow(exponent), transformPow(1 / exponent));
  1422. }
  1423. scale.exponent = function(_) {
  1424. return arguments.length ? (exponent = +_, rescale()) : exponent;
  1425. };
  1426. return linearish(scale);
  1427. }
  1428. function pow() {
  1429. var scale = powish(transformer$1());
  1430. scale.copy = function() {
  1431. return copy$1(scale, pow()).exponent(scale.exponent());
  1432. };
  1433. initRange.apply(scale, arguments);
  1434. return scale;
  1435. }
  1436. function sqrt() {
  1437. return pow.apply(null, arguments).exponent(0.5);
  1438. }
  1439. const t0 = new Date, t1 = new Date;
  1440. function timeInterval(floori, offseti, count, field) {
  1441. function interval(date) {
  1442. return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date;
  1443. }
  1444. interval.floor = (date) => {
  1445. return floori(date = new Date(+date)), date;
  1446. };
  1447. interval.ceil = (date) => {
  1448. return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
  1449. };
  1450. interval.round = (date) => {
  1451. const d0 = interval(date), d1 = interval.ceil(date);
  1452. return date - d0 < d1 - date ? d0 : d1;
  1453. };
  1454. interval.offset = (date, step) => {
  1455. return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
  1456. };
  1457. interval.range = (start, stop, step) => {
  1458. const range = [];
  1459. start = interval.ceil(start);
  1460. step = step == null ? 1 : Math.floor(step);
  1461. if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date
  1462. let previous;
  1463. do range.push(previous = new Date(+start)), offseti(start, step), floori(start);
  1464. while (previous < start && start < stop);
  1465. return range;
  1466. };
  1467. interval.filter = (test) => {
  1468. return timeInterval((date) => {
  1469. if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1);
  1470. }, (date, step) => {
  1471. if (date >= date) {
  1472. if (step < 0) while (++step <= 0) {
  1473. while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty
  1474. } else while (--step >= 0) {
  1475. while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty
  1476. }
  1477. }
  1478. });
  1479. };
  1480. if (count) {
  1481. interval.count = (start, end) => {
  1482. t0.setTime(+start), t1.setTime(+end);
  1483. floori(t0), floori(t1);
  1484. return Math.floor(count(t0, t1));
  1485. };
  1486. interval.every = (step) => {
  1487. step = Math.floor(step);
  1488. return !isFinite(step) || !(step > 0) ? null
  1489. : !(step > 1) ? interval
  1490. : interval.filter(field
  1491. ? (d) => field(d) % step === 0
  1492. : (d) => interval.count(0, d) % step === 0);
  1493. };
  1494. }
  1495. return interval;
  1496. }
  1497. const millisecond = timeInterval(() => {
  1498. // noop
  1499. }, (date, step) => {
  1500. date.setTime(+date + step);
  1501. }, (start, end) => {
  1502. return end - start;
  1503. });
  1504. // An optimized implementation for this simple case.
  1505. millisecond.every = (k) => {
  1506. k = Math.floor(k);
  1507. if (!isFinite(k) || !(k > 0)) return null;
  1508. if (!(k > 1)) return millisecond;
  1509. return timeInterval((date) => {
  1510. date.setTime(Math.floor(date / k) * k);
  1511. }, (date, step) => {
  1512. date.setTime(+date + step * k);
  1513. }, (start, end) => {
  1514. return (end - start) / k;
  1515. });
  1516. };
  1517. millisecond.range;
  1518. const durationSecond = 1000;
  1519. const durationMinute = durationSecond * 60;
  1520. const durationHour = durationMinute * 60;
  1521. const durationDay = durationHour * 24;
  1522. const durationWeek = durationDay * 7;
  1523. const second = timeInterval((date) => {
  1524. date.setTime(date - date.getMilliseconds());
  1525. }, (date, step) => {
  1526. date.setTime(+date + step * durationSecond);
  1527. }, (start, end) => {
  1528. return (end - start) / durationSecond;
  1529. }, (date) => {
  1530. return date.getUTCSeconds();
  1531. });
  1532. second.range;
  1533. const timeMinute = timeInterval((date) => {
  1534. date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond);
  1535. }, (date, step) => {
  1536. date.setTime(+date + step * durationMinute);
  1537. }, (start, end) => {
  1538. return (end - start) / durationMinute;
  1539. }, (date) => {
  1540. return date.getMinutes();
  1541. });
  1542. timeMinute.range;
  1543. const utcMinute = timeInterval((date) => {
  1544. date.setUTCSeconds(0, 0);
  1545. }, (date, step) => {
  1546. date.setTime(+date + step * durationMinute);
  1547. }, (start, end) => {
  1548. return (end - start) / durationMinute;
  1549. }, (date) => {
  1550. return date.getUTCMinutes();
  1551. });
  1552. utcMinute.range;
  1553. const timeHour = timeInterval((date) => {
  1554. date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute);
  1555. }, (date, step) => {
  1556. date.setTime(+date + step * durationHour);
  1557. }, (start, end) => {
  1558. return (end - start) / durationHour;
  1559. }, (date) => {
  1560. return date.getHours();
  1561. });
  1562. timeHour.range;
  1563. const utcHour = timeInterval((date) => {
  1564. date.setUTCMinutes(0, 0, 0);
  1565. }, (date, step) => {
  1566. date.setTime(+date + step * durationHour);
  1567. }, (start, end) => {
  1568. return (end - start) / durationHour;
  1569. }, (date) => {
  1570. return date.getUTCHours();
  1571. });
  1572. utcHour.range;
  1573. const timeDay = timeInterval(
  1574. date => date.setHours(0, 0, 0, 0),
  1575. (date, step) => date.setDate(date.getDate() + step),
  1576. (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay,
  1577. date => date.getDate() - 1
  1578. );
  1579. timeDay.range;
  1580. const utcDay = timeInterval((date) => {
  1581. date.setUTCHours(0, 0, 0, 0);
  1582. }, (date, step) => {
  1583. date.setUTCDate(date.getUTCDate() + step);
  1584. }, (start, end) => {
  1585. return (end - start) / durationDay;
  1586. }, (date) => {
  1587. return date.getUTCDate() - 1;
  1588. });
  1589. utcDay.range;
  1590. const unixDay = timeInterval((date) => {
  1591. date.setUTCHours(0, 0, 0, 0);
  1592. }, (date, step) => {
  1593. date.setUTCDate(date.getUTCDate() + step);
  1594. }, (start, end) => {
  1595. return (end - start) / durationDay;
  1596. }, (date) => {
  1597. return Math.floor(date / durationDay);
  1598. });
  1599. unixDay.range;
  1600. function timeWeekday(i) {
  1601. return timeInterval((date) => {
  1602. date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
  1603. date.setHours(0, 0, 0, 0);
  1604. }, (date, step) => {
  1605. date.setDate(date.getDate() + step * 7);
  1606. }, (start, end) => {
  1607. return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
  1608. });
  1609. }
  1610. const timeSunday = timeWeekday(0);
  1611. const timeMonday = timeWeekday(1);
  1612. const timeTuesday = timeWeekday(2);
  1613. const timeWednesday = timeWeekday(3);
  1614. const timeThursday = timeWeekday(4);
  1615. const timeFriday = timeWeekday(5);
  1616. const timeSaturday = timeWeekday(6);
  1617. timeSunday.range;
  1618. timeMonday.range;
  1619. timeTuesday.range;
  1620. timeWednesday.range;
  1621. timeThursday.range;
  1622. timeFriday.range;
  1623. timeSaturday.range;
  1624. function utcWeekday(i) {
  1625. return timeInterval((date) => {
  1626. date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
  1627. date.setUTCHours(0, 0, 0, 0);
  1628. }, (date, step) => {
  1629. date.setUTCDate(date.getUTCDate() + step * 7);
  1630. }, (start, end) => {
  1631. return (end - start) / durationWeek;
  1632. });
  1633. }
  1634. const utcSunday = utcWeekday(0);
  1635. const utcMonday = utcWeekday(1);
  1636. const utcTuesday = utcWeekday(2);
  1637. const utcWednesday = utcWeekday(3);
  1638. const utcThursday = utcWeekday(4);
  1639. const utcFriday = utcWeekday(5);
  1640. const utcSaturday = utcWeekday(6);
  1641. utcSunday.range;
  1642. utcMonday.range;
  1643. utcTuesday.range;
  1644. utcWednesday.range;
  1645. utcThursday.range;
  1646. utcFriday.range;
  1647. utcSaturday.range;
  1648. const timeMonth = timeInterval((date) => {
  1649. date.setDate(1);
  1650. date.setHours(0, 0, 0, 0);
  1651. }, (date, step) => {
  1652. date.setMonth(date.getMonth() + step);
  1653. }, (start, end) => {
  1654. return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
  1655. }, (date) => {
  1656. return date.getMonth();
  1657. });
  1658. timeMonth.range;
  1659. const utcMonth = timeInterval((date) => {
  1660. date.setUTCDate(1);
  1661. date.setUTCHours(0, 0, 0, 0);
  1662. }, (date, step) => {
  1663. date.setUTCMonth(date.getUTCMonth() + step);
  1664. }, (start, end) => {
  1665. return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
  1666. }, (date) => {
  1667. return date.getUTCMonth();
  1668. });
  1669. utcMonth.range;
  1670. const timeYear = timeInterval((date) => {
  1671. date.setMonth(0, 1);
  1672. date.setHours(0, 0, 0, 0);
  1673. }, (date, step) => {
  1674. date.setFullYear(date.getFullYear() + step);
  1675. }, (start, end) => {
  1676. return end.getFullYear() - start.getFullYear();
  1677. }, (date) => {
  1678. return date.getFullYear();
  1679. });
  1680. // An optimized implementation for this simple case.
  1681. timeYear.every = (k) => {
  1682. return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
  1683. date.setFullYear(Math.floor(date.getFullYear() / k) * k);
  1684. date.setMonth(0, 1);
  1685. date.setHours(0, 0, 0, 0);
  1686. }, (date, step) => {
  1687. date.setFullYear(date.getFullYear() + step * k);
  1688. });
  1689. };
  1690. timeYear.range;
  1691. const utcYear = timeInterval((date) => {
  1692. date.setUTCMonth(0, 1);
  1693. date.setUTCHours(0, 0, 0, 0);
  1694. }, (date, step) => {
  1695. date.setUTCFullYear(date.getUTCFullYear() + step);
  1696. }, (start, end) => {
  1697. return end.getUTCFullYear() - start.getUTCFullYear();
  1698. }, (date) => {
  1699. return date.getUTCFullYear();
  1700. });
  1701. // An optimized implementation for this simple case.
  1702. utcYear.every = (k) => {
  1703. return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
  1704. date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
  1705. date.setUTCMonth(0, 1);
  1706. date.setUTCHours(0, 0, 0, 0);
  1707. }, (date, step) => {
  1708. date.setUTCFullYear(date.getUTCFullYear() + step * k);
  1709. });
  1710. };
  1711. utcYear.range;
  1712. function localDate(d) {
  1713. if (0 <= d.y && d.y < 100) {
  1714. var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
  1715. date.setFullYear(d.y);
  1716. return date;
  1717. }
  1718. return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
  1719. }
  1720. function utcDate(d) {
  1721. if (0 <= d.y && d.y < 100) {
  1722. var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
  1723. date.setUTCFullYear(d.y);
  1724. return date;
  1725. }
  1726. return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
  1727. }
  1728. function newDate(y, m, d) {
  1729. return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
  1730. }
  1731. function formatLocale(locale) {
  1732. var locale_dateTime = locale.dateTime,
  1733. locale_date = locale.date,
  1734. locale_time = locale.time,
  1735. locale_periods = locale.periods,
  1736. locale_weekdays = locale.days,
  1737. locale_shortWeekdays = locale.shortDays,
  1738. locale_months = locale.months,
  1739. locale_shortMonths = locale.shortMonths;
  1740. var periodRe = formatRe(locale_periods),
  1741. periodLookup = formatLookup(locale_periods),
  1742. weekdayRe = formatRe(locale_weekdays),
  1743. weekdayLookup = formatLookup(locale_weekdays),
  1744. shortWeekdayRe = formatRe(locale_shortWeekdays),
  1745. shortWeekdayLookup = formatLookup(locale_shortWeekdays),
  1746. monthRe = formatRe(locale_months),
  1747. monthLookup = formatLookup(locale_months),
  1748. shortMonthRe = formatRe(locale_shortMonths),
  1749. shortMonthLookup = formatLookup(locale_shortMonths);
  1750. var formats = {
  1751. "a": formatShortWeekday,
  1752. "A": formatWeekday,
  1753. "b": formatShortMonth,
  1754. "B": formatMonth,
  1755. "c": null,
  1756. "d": formatDayOfMonth,
  1757. "e": formatDayOfMonth,
  1758. "f": formatMicroseconds,
  1759. "g": formatYearISO,
  1760. "G": formatFullYearISO,
  1761. "H": formatHour24,
  1762. "I": formatHour12,
  1763. "j": formatDayOfYear,
  1764. "L": formatMilliseconds,
  1765. "m": formatMonthNumber,
  1766. "M": formatMinutes,
  1767. "p": formatPeriod,
  1768. "q": formatQuarter,
  1769. "Q": formatUnixTimestamp,
  1770. "s": formatUnixTimestampSeconds,
  1771. "S": formatSeconds,
  1772. "u": formatWeekdayNumberMonday,
  1773. "U": formatWeekNumberSunday,
  1774. "V": formatWeekNumberISO,
  1775. "w": formatWeekdayNumberSunday,
  1776. "W": formatWeekNumberMonday,
  1777. "x": null,
  1778. "X": null,
  1779. "y": formatYear,
  1780. "Y": formatFullYear,
  1781. "Z": formatZone,
  1782. "%": formatLiteralPercent
  1783. };
  1784. var utcFormats = {
  1785. "a": formatUTCShortWeekday,
  1786. "A": formatUTCWeekday,
  1787. "b": formatUTCShortMonth,
  1788. "B": formatUTCMonth,
  1789. "c": null,
  1790. "d": formatUTCDayOfMonth,
  1791. "e": formatUTCDayOfMonth,
  1792. "f": formatUTCMicroseconds,
  1793. "g": formatUTCYearISO,
  1794. "G": formatUTCFullYearISO,
  1795. "H": formatUTCHour24,
  1796. "I": formatUTCHour12,
  1797. "j": formatUTCDayOfYear,
  1798. "L": formatUTCMilliseconds,
  1799. "m": formatUTCMonthNumber,
  1800. "M": formatUTCMinutes,
  1801. "p": formatUTCPeriod,
  1802. "q": formatUTCQuarter,
  1803. "Q": formatUnixTimestamp,
  1804. "s": formatUnixTimestampSeconds,
  1805. "S": formatUTCSeconds,
  1806. "u": formatUTCWeekdayNumberMonday,
  1807. "U": formatUTCWeekNumberSunday,
  1808. "V": formatUTCWeekNumberISO,
  1809. "w": formatUTCWeekdayNumberSunday,
  1810. "W": formatUTCWeekNumberMonday,
  1811. "x": null,
  1812. "X": null,
  1813. "y": formatUTCYear,
  1814. "Y": formatUTCFullYear,
  1815. "Z": formatUTCZone,
  1816. "%": formatLiteralPercent
  1817. };
  1818. var parses = {
  1819. "a": parseShortWeekday,
  1820. "A": parseWeekday,
  1821. "b": parseShortMonth,
  1822. "B": parseMonth,
  1823. "c": parseLocaleDateTime,
  1824. "d": parseDayOfMonth,
  1825. "e": parseDayOfMonth,
  1826. "f": parseMicroseconds,
  1827. "g": parseYear,
  1828. "G": parseFullYear,
  1829. "H": parseHour24,
  1830. "I": parseHour24,
  1831. "j": parseDayOfYear,
  1832. "L": parseMilliseconds,
  1833. "m": parseMonthNumber,
  1834. "M": parseMinutes,
  1835. "p": parsePeriod,
  1836. "q": parseQuarter,
  1837. "Q": parseUnixTimestamp,
  1838. "s": parseUnixTimestampSeconds,
  1839. "S": parseSeconds,
  1840. "u": parseWeekdayNumberMonday,
  1841. "U": parseWeekNumberSunday,
  1842. "V": parseWeekNumberISO,
  1843. "w": parseWeekdayNumberSunday,
  1844. "W": parseWeekNumberMonday,
  1845. "x": parseLocaleDate,
  1846. "X": parseLocaleTime,
  1847. "y": parseYear,
  1848. "Y": parseFullYear,
  1849. "Z": parseZone,
  1850. "%": parseLiteralPercent
  1851. };
  1852. // These recursive directive definitions must be deferred.
  1853. formats.x = newFormat(locale_date, formats);
  1854. formats.X = newFormat(locale_time, formats);
  1855. formats.c = newFormat(locale_dateTime, formats);
  1856. utcFormats.x = newFormat(locale_date, utcFormats);
  1857. utcFormats.X = newFormat(locale_time, utcFormats);
  1858. utcFormats.c = newFormat(locale_dateTime, utcFormats);
  1859. function newFormat(specifier, formats) {
  1860. return function(date) {
  1861. var string = [],
  1862. i = -1,
  1863. j = 0,
  1864. n = specifier.length,
  1865. c,
  1866. pad,
  1867. format;
  1868. if (!(date instanceof Date)) date = new Date(+date);
  1869. while (++i < n) {
  1870. if (specifier.charCodeAt(i) === 37) {
  1871. string.push(specifier.slice(j, i));
  1872. if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
  1873. else pad = c === "e" ? " " : "0";
  1874. if (format = formats[c]) c = format(date, pad);
  1875. string.push(c);
  1876. j = i + 1;
  1877. }
  1878. }
  1879. string.push(specifier.slice(j, i));
  1880. return string.join("");
  1881. };
  1882. }
  1883. function newParse(specifier, Z) {
  1884. return function(string) {
  1885. var d = newDate(1900, undefined, 1),
  1886. i = parseSpecifier(d, specifier, string += "", 0),
  1887. week, day;
  1888. if (i != string.length) return null;
  1889. // If a UNIX timestamp is specified, return it.
  1890. if ("Q" in d) return new Date(d.Q);
  1891. if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0));
  1892. // If this is utcParse, never use the local timezone.
  1893. if (Z && !("Z" in d)) d.Z = 0;
  1894. // The am-pm flag is 0 for AM, and 1 for PM.
  1895. if ("p" in d) d.H = d.H % 12 + d.p * 12;
  1896. // If the month was not specified, inherit from the quarter.
  1897. if (d.m === undefined) d.m = "q" in d ? d.q : 0;
  1898. // Convert day-of-week and week-of-year to day-of-year.
  1899. if ("V" in d) {
  1900. if (d.V < 1 || d.V > 53) return null;
  1901. if (!("w" in d)) d.w = 1;
  1902. if ("Z" in d) {
  1903. week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
  1904. week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week);
  1905. week = utcDay.offset(week, (d.V - 1) * 7);
  1906. d.y = week.getUTCFullYear();
  1907. d.m = week.getUTCMonth();
  1908. d.d = week.getUTCDate() + (d.w + 6) % 7;
  1909. } else {
  1910. week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
  1911. week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week);
  1912. week = timeDay.offset(week, (d.V - 1) * 7);
  1913. d.y = week.getFullYear();
  1914. d.m = week.getMonth();
  1915. d.d = week.getDate() + (d.w + 6) % 7;
  1916. }
  1917. } else if ("W" in d || "U" in d) {
  1918. if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
  1919. day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
  1920. d.m = 0;
  1921. d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;
  1922. }
  1923. // If a time zone is specified, all fields are interpreted as UTC and then
  1924. // offset according to the specified time zone.
  1925. if ("Z" in d) {
  1926. d.H += d.Z / 100 | 0;
  1927. d.M += d.Z % 100;
  1928. return utcDate(d);
  1929. }
  1930. // Otherwise, all fields are in local time.
  1931. return localDate(d);
  1932. };
  1933. }
  1934. function parseSpecifier(d, specifier, string, j) {
  1935. var i = 0,
  1936. n = specifier.length,
  1937. m = string.length,
  1938. c,
  1939. parse;
  1940. while (i < n) {
  1941. if (j >= m) return -1;
  1942. c = specifier.charCodeAt(i++);
  1943. if (c === 37) {
  1944. c = specifier.charAt(i++);
  1945. parse = parses[c in pads ? specifier.charAt(i++) : c];
  1946. if (!parse || ((j = parse(d, string, j)) < 0)) return -1;
  1947. } else if (c != string.charCodeAt(j++)) {
  1948. return -1;
  1949. }
  1950. }
  1951. return j;
  1952. }
  1953. function parsePeriod(d, string, i) {
  1954. var n = periodRe.exec(string.slice(i));
  1955. return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  1956. }
  1957. function parseShortWeekday(d, string, i) {
  1958. var n = shortWeekdayRe.exec(string.slice(i));
  1959. return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  1960. }
  1961. function parseWeekday(d, string, i) {
  1962. var n = weekdayRe.exec(string.slice(i));
  1963. return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  1964. }
  1965. function parseShortMonth(d, string, i) {
  1966. var n = shortMonthRe.exec(string.slice(i));
  1967. return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  1968. }
  1969. function parseMonth(d, string, i) {
  1970. var n = monthRe.exec(string.slice(i));
  1971. return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
  1972. }
  1973. function parseLocaleDateTime(d, string, i) {
  1974. return parseSpecifier(d, locale_dateTime, string, i);
  1975. }
  1976. function parseLocaleDate(d, string, i) {
  1977. return parseSpecifier(d, locale_date, string, i);
  1978. }
  1979. function parseLocaleTime(d, string, i) {
  1980. return parseSpecifier(d, locale_time, string, i);
  1981. }
  1982. function formatShortWeekday(d) {
  1983. return locale_shortWeekdays[d.getDay()];
  1984. }
  1985. function formatWeekday(d) {
  1986. return locale_weekdays[d.getDay()];
  1987. }
  1988. function formatShortMonth(d) {
  1989. return locale_shortMonths[d.getMonth()];
  1990. }
  1991. function formatMonth(d) {
  1992. return locale_months[d.getMonth()];
  1993. }
  1994. function formatPeriod(d) {
  1995. return locale_periods[+(d.getHours() >= 12)];
  1996. }
  1997. function formatQuarter(d) {
  1998. return 1 + ~~(d.getMonth() / 3);
  1999. }
  2000. function formatUTCShortWeekday(d) {
  2001. return locale_shortWeekdays[d.getUTCDay()];
  2002. }
  2003. function formatUTCWeekday(d) {
  2004. return locale_weekdays[d.getUTCDay()];
  2005. }
  2006. function formatUTCShortMonth(d) {
  2007. return locale_shortMonths[d.getUTCMonth()];
  2008. }
  2009. function formatUTCMonth(d) {
  2010. return locale_months[d.getUTCMonth()];
  2011. }
  2012. function formatUTCPeriod(d) {
  2013. return locale_periods[+(d.getUTCHours() >= 12)];
  2014. }
  2015. function formatUTCQuarter(d) {
  2016. return 1 + ~~(d.getUTCMonth() / 3);
  2017. }
  2018. return {
  2019. format: function(specifier) {
  2020. var f = newFormat(specifier += "", formats);
  2021. f.toString = function() { return specifier; };
  2022. return f;
  2023. },
  2024. parse: function(specifier) {
  2025. var p = newParse(specifier += "", false);
  2026. p.toString = function() { return specifier; };
  2027. return p;
  2028. },
  2029. utcFormat: function(specifier) {
  2030. var f = newFormat(specifier += "", utcFormats);
  2031. f.toString = function() { return specifier; };
  2032. return f;
  2033. },
  2034. utcParse: function(specifier) {
  2035. var p = newParse(specifier += "", true);
  2036. p.toString = function() { return specifier; };
  2037. return p;
  2038. }
  2039. };
  2040. }
  2041. var pads = {"-": "", "_": " ", "0": "0"},
  2042. numberRe = /^\s*\d+/, // note: ignores next directive
  2043. percentRe = /^%/,
  2044. requoteRe = /[\\^$*+?|[\]().{}]/g;
  2045. function pad(value, fill, width) {
  2046. var sign = value < 0 ? "-" : "",
  2047. string = (sign ? -value : value) + "",
  2048. length = string.length;
  2049. return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
  2050. }
  2051. function requote(s) {
  2052. return s.replace(requoteRe, "\\$&");
  2053. }
  2054. function formatRe(names) {
  2055. return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
  2056. }
  2057. function formatLookup(names) {
  2058. return new Map(names.map((name, i) => [name.toLowerCase(), i]));
  2059. }
  2060. function parseWeekdayNumberSunday(d, string, i) {
  2061. var n = numberRe.exec(string.slice(i, i + 1));
  2062. return n ? (d.w = +n[0], i + n[0].length) : -1;
  2063. }
  2064. function parseWeekdayNumberMonday(d, string, i) {
  2065. var n = numberRe.exec(string.slice(i, i + 1));
  2066. return n ? (d.u = +n[0], i + n[0].length) : -1;
  2067. }
  2068. function parseWeekNumberSunday(d, string, i) {
  2069. var n = numberRe.exec(string.slice(i, i + 2));
  2070. return n ? (d.U = +n[0], i + n[0].length) : -1;
  2071. }
  2072. function parseWeekNumberISO(d, string, i) {
  2073. var n = numberRe.exec(string.slice(i, i + 2));
  2074. return n ? (d.V = +n[0], i + n[0].length) : -1;
  2075. }
  2076. function parseWeekNumberMonday(d, string, i) {
  2077. var n = numberRe.exec(string.slice(i, i + 2));
  2078. return n ? (d.W = +n[0], i + n[0].length) : -1;
  2079. }
  2080. function parseFullYear(d, string, i) {
  2081. var n = numberRe.exec(string.slice(i, i + 4));
  2082. return n ? (d.y = +n[0], i + n[0].length) : -1;
  2083. }
  2084. function parseYear(d, string, i) {
  2085. var n = numberRe.exec(string.slice(i, i + 2));
  2086. return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
  2087. }
  2088. function parseZone(d, string, i) {
  2089. var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
  2090. return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
  2091. }
  2092. function parseQuarter(d, string, i) {
  2093. var n = numberRe.exec(string.slice(i, i + 1));
  2094. return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
  2095. }
  2096. function parseMonthNumber(d, string, i) {
  2097. var n = numberRe.exec(string.slice(i, i + 2));
  2098. return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
  2099. }
  2100. function parseDayOfMonth(d, string, i) {
  2101. var n = numberRe.exec(string.slice(i, i + 2));
  2102. return n ? (d.d = +n[0], i + n[0].length) : -1;
  2103. }
  2104. function parseDayOfYear(d, string, i) {
  2105. var n = numberRe.exec(string.slice(i, i + 3));
  2106. return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
  2107. }
  2108. function parseHour24(d, string, i) {
  2109. var n = numberRe.exec(string.slice(i, i + 2));
  2110. return n ? (d.H = +n[0], i + n[0].length) : -1;
  2111. }
  2112. function parseMinutes(d, string, i) {
  2113. var n = numberRe.exec(string.slice(i, i + 2));
  2114. return n ? (d.M = +n[0], i + n[0].length) : -1;
  2115. }
  2116. function parseSeconds(d, string, i) {
  2117. var n = numberRe.exec(string.slice(i, i + 2));
  2118. return n ? (d.S = +n[0], i + n[0].length) : -1;
  2119. }
  2120. function parseMilliseconds(d, string, i) {
  2121. var n = numberRe.exec(string.slice(i, i + 3));
  2122. return n ? (d.L = +n[0], i + n[0].length) : -1;
  2123. }
  2124. function parseMicroseconds(d, string, i) {
  2125. var n = numberRe.exec(string.slice(i, i + 6));
  2126. return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
  2127. }
  2128. function parseLiteralPercent(d, string, i) {
  2129. var n = percentRe.exec(string.slice(i, i + 1));
  2130. return n ? i + n[0].length : -1;
  2131. }
  2132. function parseUnixTimestamp(d, string, i) {
  2133. var n = numberRe.exec(string.slice(i));
  2134. return n ? (d.Q = +n[0], i + n[0].length) : -1;
  2135. }
  2136. function parseUnixTimestampSeconds(d, string, i) {
  2137. var n = numberRe.exec(string.slice(i));
  2138. return n ? (d.s = +n[0], i + n[0].length) : -1;
  2139. }
  2140. function formatDayOfMonth(d, p) {
  2141. return pad(d.getDate(), p, 2);
  2142. }
  2143. function formatHour24(d, p) {
  2144. return pad(d.getHours(), p, 2);
  2145. }
  2146. function formatHour12(d, p) {
  2147. return pad(d.getHours() % 12 || 12, p, 2);
  2148. }
  2149. function formatDayOfYear(d, p) {
  2150. return pad(1 + timeDay.count(timeYear(d), d), p, 3);
  2151. }
  2152. function formatMilliseconds(d, p) {
  2153. return pad(d.getMilliseconds(), p, 3);
  2154. }
  2155. function formatMicroseconds(d, p) {
  2156. return formatMilliseconds(d, p) + "000";
  2157. }
  2158. function formatMonthNumber(d, p) {
  2159. return pad(d.getMonth() + 1, p, 2);
  2160. }
  2161. function formatMinutes(d, p) {
  2162. return pad(d.getMinutes(), p, 2);
  2163. }
  2164. function formatSeconds(d, p) {
  2165. return pad(d.getSeconds(), p, 2);
  2166. }
  2167. function formatWeekdayNumberMonday(d) {
  2168. var day = d.getDay();
  2169. return day === 0 ? 7 : day;
  2170. }
  2171. function formatWeekNumberSunday(d, p) {
  2172. return pad(timeSunday.count(timeYear(d) - 1, d), p, 2);
  2173. }
  2174. function dISO(d) {
  2175. var day = d.getDay();
  2176. return (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d);
  2177. }
  2178. function formatWeekNumberISO(d, p) {
  2179. d = dISO(d);
  2180. return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2);
  2181. }
  2182. function formatWeekdayNumberSunday(d) {
  2183. return d.getDay();
  2184. }
  2185. function formatWeekNumberMonday(d, p) {
  2186. return pad(timeMonday.count(timeYear(d) - 1, d), p, 2);
  2187. }
  2188. function formatYear(d, p) {
  2189. return pad(d.getFullYear() % 100, p, 2);
  2190. }
  2191. function formatYearISO(d, p) {
  2192. d = dISO(d);
  2193. return pad(d.getFullYear() % 100, p, 2);
  2194. }
  2195. function formatFullYear(d, p) {
  2196. return pad(d.getFullYear() % 10000, p, 4);
  2197. }
  2198. function formatFullYearISO(d, p) {
  2199. var day = d.getDay();
  2200. d = (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d);
  2201. return pad(d.getFullYear() % 10000, p, 4);
  2202. }
  2203. function formatZone(d) {
  2204. var z = d.getTimezoneOffset();
  2205. return (z > 0 ? "-" : (z *= -1, "+"))
  2206. + pad(z / 60 | 0, "0", 2)
  2207. + pad(z % 60, "0", 2);
  2208. }
  2209. function formatUTCDayOfMonth(d, p) {
  2210. return pad(d.getUTCDate(), p, 2);
  2211. }
  2212. function formatUTCHour24(d, p) {
  2213. return pad(d.getUTCHours(), p, 2);
  2214. }
  2215. function formatUTCHour12(d, p) {
  2216. return pad(d.getUTCHours() % 12 || 12, p, 2);
  2217. }
  2218. function formatUTCDayOfYear(d, p) {
  2219. return pad(1 + utcDay.count(utcYear(d), d), p, 3);
  2220. }
  2221. function formatUTCMilliseconds(d, p) {
  2222. return pad(d.getUTCMilliseconds(), p, 3);
  2223. }
  2224. function formatUTCMicroseconds(d, p) {
  2225. return formatUTCMilliseconds(d, p) + "000";
  2226. }
  2227. function formatUTCMonthNumber(d, p) {
  2228. return pad(d.getUTCMonth() + 1, p, 2);
  2229. }
  2230. function formatUTCMinutes(d, p) {
  2231. return pad(d.getUTCMinutes(), p, 2);
  2232. }
  2233. function formatUTCSeconds(d, p) {
  2234. return pad(d.getUTCSeconds(), p, 2);
  2235. }
  2236. function formatUTCWeekdayNumberMonday(d) {
  2237. var dow = d.getUTCDay();
  2238. return dow === 0 ? 7 : dow;
  2239. }
  2240. function formatUTCWeekNumberSunday(d, p) {
  2241. return pad(utcSunday.count(utcYear(d) - 1, d), p, 2);
  2242. }
  2243. function UTCdISO(d) {
  2244. var day = d.getUTCDay();
  2245. return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d);
  2246. }
  2247. function formatUTCWeekNumberISO(d, p) {
  2248. d = UTCdISO(d);
  2249. return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
  2250. }
  2251. function formatUTCWeekdayNumberSunday(d) {
  2252. return d.getUTCDay();
  2253. }
  2254. function formatUTCWeekNumberMonday(d, p) {
  2255. return pad(utcMonday.count(utcYear(d) - 1, d), p, 2);
  2256. }
  2257. function formatUTCYear(d, p) {
  2258. return pad(d.getUTCFullYear() % 100, p, 2);
  2259. }
  2260. function formatUTCYearISO(d, p) {
  2261. d = UTCdISO(d);
  2262. return pad(d.getUTCFullYear() % 100, p, 2);
  2263. }
  2264. function formatUTCFullYear(d, p) {
  2265. return pad(d.getUTCFullYear() % 10000, p, 4);
  2266. }
  2267. function formatUTCFullYearISO(d, p) {
  2268. var day = d.getUTCDay();
  2269. d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d);
  2270. return pad(d.getUTCFullYear() % 10000, p, 4);
  2271. }
  2272. function formatUTCZone() {
  2273. return "+0000";
  2274. }
  2275. function formatLiteralPercent() {
  2276. return "%";
  2277. }
  2278. function formatUnixTimestamp(d) {
  2279. return +d;
  2280. }
  2281. function formatUnixTimestampSeconds(d) {
  2282. return Math.floor(+d / 1000);
  2283. }
  2284. var locale;
  2285. var utcFormat;
  2286. var utcParse;
  2287. defaultLocale({
  2288. dateTime: "%x, %X",
  2289. date: "%-m/%-d/%Y",
  2290. time: "%-I:%M:%S %p",
  2291. periods: ["AM", "PM"],
  2292. days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  2293. shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  2294. months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  2295. shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  2296. });
  2297. function defaultLocale(definition) {
  2298. locale = formatLocale(definition);
  2299. locale.format;
  2300. locale.parse;
  2301. utcFormat = locale.utcFormat;
  2302. utcParse = locale.utcParse;
  2303. return locale;
  2304. }
  2305. var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
  2306. function formatIsoNative(date) {
  2307. return date.toISOString();
  2308. }
  2309. Date.prototype.toISOString
  2310. ? formatIsoNative
  2311. : utcFormat(isoSpecifier);
  2312. function parseIsoNative(string) {
  2313. var date = new Date(string);
  2314. return isNaN(date) ? null : date;
  2315. }
  2316. +new Date("2000-01-01T00:00:00.000Z")
  2317. ? parseIsoNative
  2318. : utcParse(isoSpecifier);
  2319. function transformer() {
  2320. var x0 = 0,
  2321. x1 = 1,
  2322. t0,
  2323. t1,
  2324. k10,
  2325. transform,
  2326. interpolator = identity$1,
  2327. clamp = false,
  2328. unknown;
  2329. function scale(x) {
  2330. return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
  2331. }
  2332. scale.domain = function(_) {
  2333. return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
  2334. };
  2335. scale.clamp = function(_) {
  2336. return arguments.length ? (clamp = !!_, scale) : clamp;
  2337. };
  2338. scale.interpolator = function(_) {
  2339. return arguments.length ? (interpolator = _, scale) : interpolator;
  2340. };
  2341. function range(interpolate) {
  2342. return function(_) {
  2343. var r0, r1;
  2344. return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
  2345. };
  2346. }
  2347. scale.range = range(interpolate);
  2348. scale.rangeRound = range(interpolateRound);
  2349. scale.unknown = function(_) {
  2350. return arguments.length ? (unknown = _, scale) : unknown;
  2351. };
  2352. return function(t) {
  2353. transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
  2354. return scale;
  2355. };
  2356. }
  2357. function copy(source, target) {
  2358. return target
  2359. .domain(source.domain())
  2360. .interpolator(source.interpolator())
  2361. .clamp(source.clamp())
  2362. .unknown(source.unknown());
  2363. }
  2364. function sequential() {
  2365. var scale = linearish(transformer()(identity$1));
  2366. scale.copy = function() {
  2367. return copy(scale, sequential());
  2368. };
  2369. return initInterpolator.apply(scale, arguments);
  2370. }
  2371. function tree_add(d) {
  2372. const x = +this._x.call(null, d),
  2373. y = +this._y.call(null, d);
  2374. return add(this.cover(x, y), x, y, d);
  2375. }
  2376. function add(tree, x, y, d) {
  2377. if (isNaN(x) || isNaN(y)) return tree; // ignore invalid points
  2378. var parent,
  2379. node = tree._root,
  2380. leaf = {data: d},
  2381. x0 = tree._x0,
  2382. y0 = tree._y0,
  2383. x1 = tree._x1,
  2384. y1 = tree._y1,
  2385. xm,
  2386. ym,
  2387. xp,
  2388. yp,
  2389. right,
  2390. bottom,
  2391. i,
  2392. j;
  2393. // If the tree is empty, initialize the root as a leaf.
  2394. if (!node) return tree._root = leaf, tree;
  2395. // Find the existing leaf for the new point, or add it.
  2396. while (node.length) {
  2397. if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
  2398. if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
  2399. if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
  2400. }
  2401. // Is the new point is exactly coincident with the existing point?
  2402. xp = +tree._x.call(null, node.data);
  2403. yp = +tree._y.call(null, node.data);
  2404. if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
  2405. // Otherwise, split the leaf node until the old and new point are separated.
  2406. do {
  2407. parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
  2408. if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
  2409. if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
  2410. } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm)));
  2411. return parent[j] = node, parent[i] = leaf, tree;
  2412. }
  2413. function addAll(data) {
  2414. var d, i, n = data.length,
  2415. x,
  2416. y,
  2417. xz = new Array(n),
  2418. yz = new Array(n),
  2419. x0 = Infinity,
  2420. y0 = Infinity,
  2421. x1 = -Infinity,
  2422. y1 = -Infinity;
  2423. // Compute the points and their extent.
  2424. for (i = 0; i < n; ++i) {
  2425. if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue;
  2426. xz[i] = x;
  2427. yz[i] = y;
  2428. if (x < x0) x0 = x;
  2429. if (x > x1) x1 = x;
  2430. if (y < y0) y0 = y;
  2431. if (y > y1) y1 = y;
  2432. }
  2433. // If there were no (valid) points, abort.
  2434. if (x0 > x1 || y0 > y1) return this;
  2435. // Expand the tree to cover the new points.
  2436. this.cover(x0, y0).cover(x1, y1);
  2437. // Add the new points.
  2438. for (i = 0; i < n; ++i) {
  2439. add(this, xz[i], yz[i], data[i]);
  2440. }
  2441. return this;
  2442. }
  2443. function tree_cover(x, y) {
  2444. if (isNaN(x = +x) || isNaN(y = +y)) return this; // ignore invalid points
  2445. var x0 = this._x0,
  2446. y0 = this._y0,
  2447. x1 = this._x1,
  2448. y1 = this._y1;
  2449. // If the quadtree has no extent, initialize them.
  2450. // Integer extent are necessary so that if we later double the extent,
  2451. // the existing quadrant boundaries don’t change due to floating point error!
  2452. if (isNaN(x0)) {
  2453. x1 = (x0 = Math.floor(x)) + 1;
  2454. y1 = (y0 = Math.floor(y)) + 1;
  2455. }
  2456. // Otherwise, double repeatedly to cover.
  2457. else {
  2458. var z = x1 - x0 || 1,
  2459. node = this._root,
  2460. parent,
  2461. i;
  2462. while (x0 > x || x >= x1 || y0 > y || y >= y1) {
  2463. i = (y < y0) << 1 | (x < x0);
  2464. parent = new Array(4), parent[i] = node, node = parent, z *= 2;
  2465. switch (i) {
  2466. case 0: x1 = x0 + z, y1 = y0 + z; break;
  2467. case 1: x0 = x1 - z, y1 = y0 + z; break;
  2468. case 2: x1 = x0 + z, y0 = y1 - z; break;
  2469. case 3: x0 = x1 - z, y0 = y1 - z; break;
  2470. }
  2471. }
  2472. if (this._root && this._root.length) this._root = node;
  2473. }
  2474. this._x0 = x0;
  2475. this._y0 = y0;
  2476. this._x1 = x1;
  2477. this._y1 = y1;
  2478. return this;
  2479. }
  2480. function tree_data() {
  2481. var data = [];
  2482. this.visit(function(node) {
  2483. if (!node.length) do data.push(node.data); while (node = node.next)
  2484. });
  2485. return data;
  2486. }
  2487. function tree_extent(_) {
  2488. return arguments.length
  2489. ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1])
  2490. : isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]];
  2491. }
  2492. function Quad(node, x0, y0, x1, y1) {
  2493. this.node = node;
  2494. this.x0 = x0;
  2495. this.y0 = y0;
  2496. this.x1 = x1;
  2497. this.y1 = y1;
  2498. }
  2499. function tree_find(x, y, radius) {
  2500. var data,
  2501. x0 = this._x0,
  2502. y0 = this._y0,
  2503. x1,
  2504. y1,
  2505. x2,
  2506. y2,
  2507. x3 = this._x1,
  2508. y3 = this._y1,
  2509. quads = [],
  2510. node = this._root,
  2511. q,
  2512. i;
  2513. if (node) quads.push(new Quad(node, x0, y0, x3, y3));
  2514. if (radius == null) radius = Infinity;
  2515. else {
  2516. x0 = x - radius, y0 = y - radius;
  2517. x3 = x + radius, y3 = y + radius;
  2518. radius *= radius;
  2519. }
  2520. while (q = quads.pop()) {
  2521. // Stop searching if this quadrant can’t contain a closer node.
  2522. if (!(node = q.node)
  2523. || (x1 = q.x0) > x3
  2524. || (y1 = q.y0) > y3
  2525. || (x2 = q.x1) < x0
  2526. || (y2 = q.y1) < y0) continue;
  2527. // Bisect the current quadrant.
  2528. if (node.length) {
  2529. var xm = (x1 + x2) / 2,
  2530. ym = (y1 + y2) / 2;
  2531. quads.push(
  2532. new Quad(node[3], xm, ym, x2, y2),
  2533. new Quad(node[2], x1, ym, xm, y2),
  2534. new Quad(node[1], xm, y1, x2, ym),
  2535. new Quad(node[0], x1, y1, xm, ym)
  2536. );
  2537. // Visit the closest quadrant first.
  2538. if (i = (y >= ym) << 1 | (x >= xm)) {
  2539. q = quads[quads.length - 1];
  2540. quads[quads.length - 1] = quads[quads.length - 1 - i];
  2541. quads[quads.length - 1 - i] = q;
  2542. }
  2543. }
  2544. // Visit this point. (Visiting coincident points isn’t necessary!)
  2545. else {
  2546. var dx = x - +this._x.call(null, node.data),
  2547. dy = y - +this._y.call(null, node.data),
  2548. d2 = dx * dx + dy * dy;
  2549. if (d2 < radius) {
  2550. var d = Math.sqrt(radius = d2);
  2551. x0 = x - d, y0 = y - d;
  2552. x3 = x + d, y3 = y + d;
  2553. data = node.data;
  2554. }
  2555. }
  2556. }
  2557. return data;
  2558. }
  2559. function tree_remove(d) {
  2560. if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this; // ignore invalid points
  2561. var parent,
  2562. node = this._root,
  2563. retainer,
  2564. previous,
  2565. next,
  2566. x0 = this._x0,
  2567. y0 = this._y0,
  2568. x1 = this._x1,
  2569. y1 = this._y1,
  2570. x,
  2571. y,
  2572. xm,
  2573. ym,
  2574. right,
  2575. bottom,
  2576. i,
  2577. j;
  2578. // If the tree is empty, initialize the root as a leaf.
  2579. if (!node) return this;
  2580. // Find the leaf node for the point.
  2581. // While descending, also retain the deepest parent with a non-removed sibling.
  2582. if (node.length) while (true) {
  2583. if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
  2584. if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
  2585. if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
  2586. if (!node.length) break;
  2587. if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i;
  2588. }
  2589. // Find the point to remove.
  2590. while (node.data !== d) if (!(previous = node, node = node.next)) return this;
  2591. if (next = node.next) delete node.next;
  2592. // If there are multiple coincident points, remove just the point.
  2593. if (previous) return (next ? previous.next = next : delete previous.next), this;
  2594. // If this is the root point, remove it.
  2595. if (!parent) return this._root = next, this;
  2596. // Remove this leaf.
  2597. next ? parent[i] = next : delete parent[i];
  2598. // If the parent now contains exactly one leaf, collapse superfluous parents.
  2599. if ((node = parent[0] || parent[1] || parent[2] || parent[3])
  2600. && node === (parent[3] || parent[2] || parent[1] || parent[0])
  2601. && !node.length) {
  2602. if (retainer) retainer[j] = node;
  2603. else this._root = node;
  2604. }
  2605. return this;
  2606. }
  2607. function removeAll(data) {
  2608. for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
  2609. return this;
  2610. }
  2611. function tree_root() {
  2612. return this._root;
  2613. }
  2614. function tree_size() {
  2615. var size = 0;
  2616. this.visit(function(node) {
  2617. if (!node.length) do ++size; while (node = node.next)
  2618. });
  2619. return size;
  2620. }
  2621. function tree_visit(callback) {
  2622. var quads = [], q, node = this._root, child, x0, y0, x1, y1;
  2623. if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
  2624. while (q = quads.pop()) {
  2625. if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
  2626. var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
  2627. if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
  2628. if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
  2629. if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
  2630. if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
  2631. }
  2632. }
  2633. return this;
  2634. }
  2635. function tree_visitAfter(callback) {
  2636. var quads = [], next = [], q;
  2637. if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
  2638. while (q = quads.pop()) {
  2639. var node = q.node;
  2640. if (node.length) {
  2641. var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
  2642. if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
  2643. if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
  2644. if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
  2645. if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
  2646. }
  2647. next.push(q);
  2648. }
  2649. while (q = next.pop()) {
  2650. callback(q.node, q.x0, q.y0, q.x1, q.y1);
  2651. }
  2652. return this;
  2653. }
  2654. function defaultX(d) {
  2655. return d[0];
  2656. }
  2657. function tree_x(_) {
  2658. return arguments.length ? (this._x = _, this) : this._x;
  2659. }
  2660. function defaultY(d) {
  2661. return d[1];
  2662. }
  2663. function tree_y(_) {
  2664. return arguments.length ? (this._y = _, this) : this._y;
  2665. }
  2666. function quadtree(nodes, x, y) {
  2667. var tree = new Quadtree(x == null ? defaultX : x, y == null ? defaultY : y, NaN, NaN, NaN, NaN);
  2668. return nodes == null ? tree : tree.addAll(nodes);
  2669. }
  2670. function Quadtree(x, y, x0, y0, x1, y1) {
  2671. this._x = x;
  2672. this._y = y;
  2673. this._x0 = x0;
  2674. this._y0 = y0;
  2675. this._x1 = x1;
  2676. this._y1 = y1;
  2677. this._root = undefined;
  2678. }
  2679. function leaf_copy(leaf) {
  2680. var copy = {data: leaf.data}, next = copy;
  2681. while (leaf = leaf.next) next = next.next = {data: leaf.data};
  2682. return copy;
  2683. }
  2684. var treeProto = quadtree.prototype = Quadtree.prototype;
  2685. treeProto.copy = function() {
  2686. var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1),
  2687. node = this._root,
  2688. nodes,
  2689. child;
  2690. if (!node) return copy;
  2691. if (!node.length) return copy._root = leaf_copy(node), copy;
  2692. nodes = [{source: node, target: copy._root = new Array(4)}];
  2693. while (node = nodes.pop()) {
  2694. for (var i = 0; i < 4; ++i) {
  2695. if (child = node.source[i]) {
  2696. if (child.length) nodes.push({source: child, target: node.target[i] = new Array(4)});
  2697. else node.target[i] = leaf_copy(child);
  2698. }
  2699. }
  2700. }
  2701. return copy;
  2702. };
  2703. treeProto.add = tree_add;
  2704. treeProto.addAll = addAll;
  2705. treeProto.cover = tree_cover;
  2706. treeProto.data = tree_data;
  2707. treeProto.extent = tree_extent;
  2708. treeProto.find = tree_find;
  2709. treeProto.remove = tree_remove;
  2710. treeProto.removeAll = removeAll;
  2711. treeProto.root = tree_root;
  2712. treeProto.size = tree_size;
  2713. treeProto.visit = tree_visit;
  2714. treeProto.visitAfter = tree_visitAfter;
  2715. treeProto.x = tree_x;
  2716. treeProto.y = tree_y;
  2717. function constant(x) {
  2718. return function() {
  2719. return x;
  2720. };
  2721. }
  2722. function jiggle(random) {
  2723. return (random() - 0.5) * 1e-6;
  2724. }
  2725. function x$1(d) {
  2726. return d.x + d.vx;
  2727. }
  2728. function y$1(d) {
  2729. return d.y + d.vy;
  2730. }
  2731. function forceCollide(radius) {
  2732. var nodes,
  2733. radii,
  2734. random,
  2735. strength = 1,
  2736. iterations = 1;
  2737. if (typeof radius !== "function") radius = constant(radius == null ? 1 : +radius);
  2738. function force() {
  2739. var i, n = nodes.length,
  2740. tree,
  2741. node,
  2742. xi,
  2743. yi,
  2744. ri,
  2745. ri2;
  2746. for (var k = 0; k < iterations; ++k) {
  2747. tree = quadtree(nodes, x$1, y$1).visitAfter(prepare);
  2748. for (i = 0; i < n; ++i) {
  2749. node = nodes[i];
  2750. ri = radii[node.index], ri2 = ri * ri;
  2751. xi = node.x + node.vx;
  2752. yi = node.y + node.vy;
  2753. tree.visit(apply);
  2754. }
  2755. }
  2756. function apply(quad, x0, y0, x1, y1) {
  2757. var data = quad.data, rj = quad.r, r = ri + rj;
  2758. if (data) {
  2759. if (data.index > node.index) {
  2760. var x = xi - data.x - data.vx,
  2761. y = yi - data.y - data.vy,
  2762. l = x * x + y * y;
  2763. if (l < r * r) {
  2764. if (x === 0) x = jiggle(random), l += x * x;
  2765. if (y === 0) y = jiggle(random), l += y * y;
  2766. l = (r - (l = Math.sqrt(l))) / l * strength;
  2767. node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj));
  2768. node.vy += (y *= l) * r;
  2769. data.vx -= x * (r = 1 - r);
  2770. data.vy -= y * r;
  2771. }
  2772. }
  2773. return;
  2774. }
  2775. return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
  2776. }
  2777. }
  2778. function prepare(quad) {
  2779. if (quad.data) return quad.r = radii[quad.data.index];
  2780. for (var i = quad.r = 0; i < 4; ++i) {
  2781. if (quad[i] && quad[i].r > quad.r) {
  2782. quad.r = quad[i].r;
  2783. }
  2784. }
  2785. }
  2786. function initialize() {
  2787. if (!nodes) return;
  2788. var i, n = nodes.length, node;
  2789. radii = new Array(n);
  2790. for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
  2791. }
  2792. force.initialize = function(_nodes, _random) {
  2793. nodes = _nodes;
  2794. random = _random;
  2795. initialize();
  2796. };
  2797. force.iterations = function(_) {
  2798. return arguments.length ? (iterations = +_, force) : iterations;
  2799. };
  2800. force.strength = function(_) {
  2801. return arguments.length ? (strength = +_, force) : strength;
  2802. };
  2803. force.radius = function(_) {
  2804. return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
  2805. };
  2806. return force;
  2807. }
  2808. function index(d) {
  2809. return d.index;
  2810. }
  2811. function find(nodeById, nodeId) {
  2812. var node = nodeById.get(nodeId);
  2813. if (!node) throw new Error("node not found: " + nodeId);
  2814. return node;
  2815. }
  2816. function forceLink(links) {
  2817. var id = index,
  2818. strength = defaultStrength,
  2819. strengths,
  2820. distance = constant(30),
  2821. distances,
  2822. nodes,
  2823. count,
  2824. bias,
  2825. random,
  2826. iterations = 1;
  2827. if (links == null) links = [];
  2828. function defaultStrength(link) {
  2829. return 1 / Math.min(count[link.source.index], count[link.target.index]);
  2830. }
  2831. function force(alpha) {
  2832. for (var k = 0, n = links.length; k < iterations; ++k) {
  2833. for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) {
  2834. link = links[i], source = link.source, target = link.target;
  2835. x = target.x + target.vx - source.x - source.vx || jiggle(random);
  2836. y = target.y + target.vy - source.y - source.vy || jiggle(random);
  2837. l = Math.sqrt(x * x + y * y);
  2838. l = (l - distances[i]) / l * alpha * strengths[i];
  2839. x *= l, y *= l;
  2840. target.vx -= x * (b = bias[i]);
  2841. target.vy -= y * b;
  2842. source.vx += x * (b = 1 - b);
  2843. source.vy += y * b;
  2844. }
  2845. }
  2846. }
  2847. function initialize() {
  2848. if (!nodes) return;
  2849. var i,
  2850. n = nodes.length,
  2851. m = links.length,
  2852. nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d])),
  2853. link;
  2854. for (i = 0, count = new Array(n); i < m; ++i) {
  2855. link = links[i], link.index = i;
  2856. if (typeof link.source !== "object") link.source = find(nodeById, link.source);
  2857. if (typeof link.target !== "object") link.target = find(nodeById, link.target);
  2858. count[link.source.index] = (count[link.source.index] || 0) + 1;
  2859. count[link.target.index] = (count[link.target.index] || 0) + 1;
  2860. }
  2861. for (i = 0, bias = new Array(m); i < m; ++i) {
  2862. link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
  2863. }
  2864. strengths = new Array(m), initializeStrength();
  2865. distances = new Array(m), initializeDistance();
  2866. }
  2867. function initializeStrength() {
  2868. if (!nodes) return;
  2869. for (var i = 0, n = links.length; i < n; ++i) {
  2870. strengths[i] = +strength(links[i], i, links);
  2871. }
  2872. }
  2873. function initializeDistance() {
  2874. if (!nodes) return;
  2875. for (var i = 0, n = links.length; i < n; ++i) {
  2876. distances[i] = +distance(links[i], i, links);
  2877. }
  2878. }
  2879. force.initialize = function(_nodes, _random) {
  2880. nodes = _nodes;
  2881. random = _random;
  2882. initialize();
  2883. };
  2884. force.links = function(_) {
  2885. return arguments.length ? (links = _, initialize(), force) : links;
  2886. };
  2887. force.id = function(_) {
  2888. return arguments.length ? (id = _, force) : id;
  2889. };
  2890. force.iterations = function(_) {
  2891. return arguments.length ? (iterations = +_, force) : iterations;
  2892. };
  2893. force.strength = function(_) {
  2894. return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initializeStrength(), force) : strength;
  2895. };
  2896. force.distance = function(_) {
  2897. return arguments.length ? (distance = typeof _ === "function" ? _ : constant(+_), initializeDistance(), force) : distance;
  2898. };
  2899. return force;
  2900. }
  2901. var noop = {value: () => {}};
  2902. function dispatch() {
  2903. for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
  2904. if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
  2905. _[t] = [];
  2906. }
  2907. return new Dispatch(_);
  2908. }
  2909. function Dispatch(_) {
  2910. this._ = _;
  2911. }
  2912. function parseTypenames(typenames, types) {
  2913. return typenames.trim().split(/^|\s+/).map(function(t) {
  2914. var name = "", i = t.indexOf(".");
  2915. if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
  2916. if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
  2917. return {type: t, name: name};
  2918. });
  2919. }
  2920. Dispatch.prototype = dispatch.prototype = {
  2921. constructor: Dispatch,
  2922. on: function(typename, callback) {
  2923. var _ = this._,
  2924. T = parseTypenames(typename + "", _),
  2925. t,
  2926. i = -1,
  2927. n = T.length;
  2928. // If no callback was specified, return the callback of the given type and name.
  2929. if (arguments.length < 2) {
  2930. while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
  2931. return;
  2932. }
  2933. // If a type was specified, set the callback for the given type and name.
  2934. // Otherwise, if a null callback was specified, remove callbacks of the given name.
  2935. if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
  2936. while (++i < n) {
  2937. if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
  2938. else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
  2939. }
  2940. return this;
  2941. },
  2942. copy: function() {
  2943. var copy = {}, _ = this._;
  2944. for (var t in _) copy[t] = _[t].slice();
  2945. return new Dispatch(copy);
  2946. },
  2947. call: function(type, that) {
  2948. if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
  2949. if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
  2950. for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
  2951. },
  2952. apply: function(type, that, args) {
  2953. if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
  2954. for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
  2955. }
  2956. };
  2957. function get(type, name) {
  2958. for (var i = 0, n = type.length, c; i < n; ++i) {
  2959. if ((c = type[i]).name === name) {
  2960. return c.value;
  2961. }
  2962. }
  2963. }
  2964. function set(type, name, callback) {
  2965. for (var i = 0, n = type.length; i < n; ++i) {
  2966. if (type[i].name === name) {
  2967. type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
  2968. break;
  2969. }
  2970. }
  2971. if (callback != null) type.push({name: name, value: callback});
  2972. return type;
  2973. }
  2974. var frame = 0, // is an animation frame pending?
  2975. timeout = 0, // is a timeout pending?
  2976. interval = 0, // are any timers active?
  2977. pokeDelay = 1000, // how frequently we check for clock skew
  2978. taskHead,
  2979. taskTail,
  2980. clockLast = 0,
  2981. clockNow = 0,
  2982. clockSkew = 0,
  2983. clock = typeof performance === "object" && performance.now ? performance : Date,
  2984. setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
  2985. function now() {
  2986. return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
  2987. }
  2988. function clearNow() {
  2989. clockNow = 0;
  2990. }
  2991. function Timer() {
  2992. this._call =
  2993. this._time =
  2994. this._next = null;
  2995. }
  2996. Timer.prototype = timer.prototype = {
  2997. constructor: Timer,
  2998. restart: function(callback, delay, time) {
  2999. if (typeof callback !== "function") throw new TypeError("callback is not a function");
  3000. time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
  3001. if (!this._next && taskTail !== this) {
  3002. if (taskTail) taskTail._next = this;
  3003. else taskHead = this;
  3004. taskTail = this;
  3005. }
  3006. this._call = callback;
  3007. this._time = time;
  3008. sleep();
  3009. },
  3010. stop: function() {
  3011. if (this._call) {
  3012. this._call = null;
  3013. this._time = Infinity;
  3014. sleep();
  3015. }
  3016. }
  3017. };
  3018. function timer(callback, delay, time) {
  3019. var t = new Timer;
  3020. t.restart(callback, delay, time);
  3021. return t;
  3022. }
  3023. function timerFlush() {
  3024. now(); // Get the current time, if not already set.
  3025. ++frame; // Pretend we’ve set an alarm, if we haven’t already.
  3026. var t = taskHead, e;
  3027. while (t) {
  3028. if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e);
  3029. t = t._next;
  3030. }
  3031. --frame;
  3032. }
  3033. function wake() {
  3034. clockNow = (clockLast = clock.now()) + clockSkew;
  3035. frame = timeout = 0;
  3036. try {
  3037. timerFlush();
  3038. } finally {
  3039. frame = 0;
  3040. nap();
  3041. clockNow = 0;
  3042. }
  3043. }
  3044. function poke() {
  3045. var now = clock.now(), delay = now - clockLast;
  3046. if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
  3047. }
  3048. function nap() {
  3049. var t0, t1 = taskHead, t2, time = Infinity;
  3050. while (t1) {
  3051. if (t1._call) {
  3052. if (time > t1._time) time = t1._time;
  3053. t0 = t1, t1 = t1._next;
  3054. } else {
  3055. t2 = t1._next, t1._next = null;
  3056. t1 = t0 ? t0._next = t2 : taskHead = t2;
  3057. }
  3058. }
  3059. taskTail = t0;
  3060. sleep(time);
  3061. }
  3062. function sleep(time) {
  3063. if (frame) return; // Soonest alarm already set, or will be.
  3064. if (timeout) timeout = clearTimeout(timeout);
  3065. var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
  3066. if (delay > 24) {
  3067. if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
  3068. if (interval) interval = clearInterval(interval);
  3069. } else {
  3070. if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
  3071. frame = 1, setFrame(wake);
  3072. }
  3073. }
  3074. // https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
  3075. const a = 1664525;
  3076. const c = 1013904223;
  3077. const m = 4294967296; // 2^32
  3078. function lcg() {
  3079. let s = 1;
  3080. return () => (s = (a * s + c) % m) / m;
  3081. }
  3082. function x(d) {
  3083. return d.x;
  3084. }
  3085. function y(d) {
  3086. return d.y;
  3087. }
  3088. var initialRadius = 10,
  3089. initialAngle = Math.PI * (3 - Math.sqrt(5));
  3090. function forceSimulation(nodes) {
  3091. var simulation,
  3092. alpha = 1,
  3093. alphaMin = 0.001,
  3094. alphaDecay = 1 - Math.pow(alphaMin, 1 / 300),
  3095. alphaTarget = 0,
  3096. velocityDecay = 0.6,
  3097. forces = new Map(),
  3098. stepper = timer(step),
  3099. event = dispatch("tick", "end"),
  3100. random = lcg();
  3101. if (nodes == null) nodes = [];
  3102. function step() {
  3103. tick();
  3104. event.call("tick", simulation);
  3105. if (alpha < alphaMin) {
  3106. stepper.stop();
  3107. event.call("end", simulation);
  3108. }
  3109. }
  3110. function tick(iterations) {
  3111. var i, n = nodes.length, node;
  3112. if (iterations === undefined) iterations = 1;
  3113. for (var k = 0; k < iterations; ++k) {
  3114. alpha += (alphaTarget - alpha) * alphaDecay;
  3115. forces.forEach(function(force) {
  3116. force(alpha);
  3117. });
  3118. for (i = 0; i < n; ++i) {
  3119. node = nodes[i];
  3120. if (node.fx == null) node.x += node.vx *= velocityDecay;
  3121. else node.x = node.fx, node.vx = 0;
  3122. if (node.fy == null) node.y += node.vy *= velocityDecay;
  3123. else node.y = node.fy, node.vy = 0;
  3124. }
  3125. }
  3126. return simulation;
  3127. }
  3128. function initializeNodes() {
  3129. for (var i = 0, n = nodes.length, node; i < n; ++i) {
  3130. node = nodes[i], node.index = i;
  3131. if (node.fx != null) node.x = node.fx;
  3132. if (node.fy != null) node.y = node.fy;
  3133. if (isNaN(node.x) || isNaN(node.y)) {
  3134. var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle;
  3135. node.x = radius * Math.cos(angle);
  3136. node.y = radius * Math.sin(angle);
  3137. }
  3138. if (isNaN(node.vx) || isNaN(node.vy)) {
  3139. node.vx = node.vy = 0;
  3140. }
  3141. }
  3142. }
  3143. function initializeForce(force) {
  3144. if (force.initialize) force.initialize(nodes, random);
  3145. return force;
  3146. }
  3147. initializeNodes();
  3148. return simulation = {
  3149. tick: tick,
  3150. restart: function() {
  3151. return stepper.restart(step), simulation;
  3152. },
  3153. stop: function() {
  3154. return stepper.stop(), simulation;
  3155. },
  3156. nodes: function(_) {
  3157. return arguments.length ? (nodes = _, initializeNodes(), forces.forEach(initializeForce), simulation) : nodes;
  3158. },
  3159. alpha: function(_) {
  3160. return arguments.length ? (alpha = +_, simulation) : alpha;
  3161. },
  3162. alphaMin: function(_) {
  3163. return arguments.length ? (alphaMin = +_, simulation) : alphaMin;
  3164. },
  3165. alphaDecay: function(_) {
  3166. return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay;
  3167. },
  3168. alphaTarget: function(_) {
  3169. return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget;
  3170. },
  3171. velocityDecay: function(_) {
  3172. return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
  3173. },
  3174. randomSource: function(_) {
  3175. return arguments.length ? (random = _, forces.forEach(initializeForce), simulation) : random;
  3176. },
  3177. force: function(name, _) {
  3178. return arguments.length > 1 ? ((_ == null ? forces.delete(name) : forces.set(name, initializeForce(_))), simulation) : forces.get(name);
  3179. },
  3180. find: function(x, y, radius) {
  3181. var i = 0,
  3182. n = nodes.length,
  3183. dx,
  3184. dy,
  3185. d2,
  3186. node,
  3187. closest;
  3188. if (radius == null) radius = Infinity;
  3189. else radius *= radius;
  3190. for (i = 0; i < n; ++i) {
  3191. node = nodes[i];
  3192. dx = x - node.x;
  3193. dy = y - node.y;
  3194. d2 = dx * dx + dy * dy;
  3195. if (d2 < radius) closest = node, radius = d2;
  3196. }
  3197. return closest;
  3198. },
  3199. on: function(name, _) {
  3200. return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);
  3201. }
  3202. };
  3203. }
  3204. function forceManyBody() {
  3205. var nodes,
  3206. node,
  3207. random,
  3208. alpha,
  3209. strength = constant(-30),
  3210. strengths,
  3211. distanceMin2 = 1,
  3212. distanceMax2 = Infinity,
  3213. theta2 = 0.81;
  3214. function force(_) {
  3215. var i, n = nodes.length, tree = quadtree(nodes, x, y).visitAfter(accumulate);
  3216. for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
  3217. }
  3218. function initialize() {
  3219. if (!nodes) return;
  3220. var i, n = nodes.length, node;
  3221. strengths = new Array(n);
  3222. for (i = 0; i < n; ++i) node = nodes[i], strengths[node.index] = +strength(node, i, nodes);
  3223. }
  3224. function accumulate(quad) {
  3225. var strength = 0, q, c, weight = 0, x, y, i;
  3226. // For internal nodes, accumulate forces from child quadrants.
  3227. if (quad.length) {
  3228. for (x = y = i = 0; i < 4; ++i) {
  3229. if ((q = quad[i]) && (c = Math.abs(q.value))) {
  3230. strength += q.value, weight += c, x += c * q.x, y += c * q.y;
  3231. }
  3232. }
  3233. quad.x = x / weight;
  3234. quad.y = y / weight;
  3235. }
  3236. // For leaf nodes, accumulate forces from coincident quadrants.
  3237. else {
  3238. q = quad;
  3239. q.x = q.data.x;
  3240. q.y = q.data.y;
  3241. do strength += strengths[q.data.index];
  3242. while (q = q.next);
  3243. }
  3244. quad.value = strength;
  3245. }
  3246. function apply(quad, x1, _, x2) {
  3247. if (!quad.value) return true;
  3248. var x = quad.x - node.x,
  3249. y = quad.y - node.y,
  3250. w = x2 - x1,
  3251. l = x * x + y * y;
  3252. // Apply the Barnes-Hut approximation if possible.
  3253. // Limit forces for very close nodes; randomize direction if coincident.
  3254. if (w * w / theta2 < l) {
  3255. if (l < distanceMax2) {
  3256. if (x === 0) x = jiggle(random), l += x * x;
  3257. if (y === 0) y = jiggle(random), l += y * y;
  3258. if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
  3259. node.vx += x * quad.value * alpha / l;
  3260. node.vy += y * quad.value * alpha / l;
  3261. }
  3262. return true;
  3263. }
  3264. // Otherwise, process points directly.
  3265. else if (quad.length || l >= distanceMax2) return;
  3266. // Limit forces for very close nodes; randomize direction if coincident.
  3267. if (quad.data !== node || quad.next) {
  3268. if (x === 0) x = jiggle(random), l += x * x;
  3269. if (y === 0) y = jiggle(random), l += y * y;
  3270. if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
  3271. }
  3272. do if (quad.data !== node) {
  3273. w = strengths[quad.data.index] * alpha / l;
  3274. node.vx += x * w;
  3275. node.vy += y * w;
  3276. } while (quad = quad.next);
  3277. }
  3278. force.initialize = function(_nodes, _random) {
  3279. nodes = _nodes;
  3280. random = _random;
  3281. initialize();
  3282. };
  3283. force.strength = function(_) {
  3284. return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
  3285. };
  3286. force.distanceMin = function(_) {
  3287. return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
  3288. };
  3289. force.distanceMax = function(_) {
  3290. return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
  3291. };
  3292. force.theta = function(_) {
  3293. return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
  3294. };
  3295. return force;
  3296. }
  3297. function forceX(x) {
  3298. var strength = constant(0.1),
  3299. nodes,
  3300. strengths,
  3301. xz;
  3302. if (typeof x !== "function") x = constant(x == null ? 0 : +x);
  3303. function force(alpha) {
  3304. for (var i = 0, n = nodes.length, node; i < n; ++i) {
  3305. node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
  3306. }
  3307. }
  3308. function initialize() {
  3309. if (!nodes) return;
  3310. var i, n = nodes.length;
  3311. strengths = new Array(n);
  3312. xz = new Array(n);
  3313. for (i = 0; i < n; ++i) {
  3314. strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
  3315. }
  3316. }
  3317. force.initialize = function(_) {
  3318. nodes = _;
  3319. initialize();
  3320. };
  3321. force.strength = function(_) {
  3322. return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
  3323. };
  3324. force.x = function(_) {
  3325. return arguments.length ? (x = typeof _ === "function" ? _ : constant(+_), initialize(), force) : x;
  3326. };
  3327. return force;
  3328. }
  3329. function forceY(y) {
  3330. var strength = constant(0.1),
  3331. nodes,
  3332. strengths,
  3333. yz;
  3334. if (typeof y !== "function") y = constant(y == null ? 0 : +y);
  3335. function force(alpha) {
  3336. for (var i = 0, n = nodes.length, node; i < n; ++i) {
  3337. node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
  3338. }
  3339. }
  3340. function initialize() {
  3341. if (!nodes) return;
  3342. var i, n = nodes.length;
  3343. strengths = new Array(n);
  3344. yz = new Array(n);
  3345. for (i = 0; i < n; ++i) {
  3346. strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
  3347. }
  3348. }
  3349. force.initialize = function(_) {
  3350. nodes = _;
  3351. initialize();
  3352. };
  3353. force.strength = function(_) {
  3354. return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
  3355. };
  3356. force.y = function(_) {
  3357. return arguments.length ? (y = typeof _ === "function" ? _ : constant(+_), initialize(), force) : y;
  3358. };
  3359. return force;
  3360. }
  3361. const COLOR_BASE = "#cecece";
  3362. function getDefaultExportFromCjs (x) {
  3363. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  3364. }
  3365. var picomatchBrowserExports = {};
  3366. var picomatchBrowser = {
  3367. get exports(){ return picomatchBrowserExports; },
  3368. set exports(v){ picomatchBrowserExports = v; },
  3369. };
  3370. var utils$3 = {};
  3371. const WIN_SLASH = '\\\\/';
  3372. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  3373. /**
  3374. * Posix glob regex
  3375. */
  3376. const DOT_LITERAL = '\\.';
  3377. const PLUS_LITERAL = '\\+';
  3378. const QMARK_LITERAL = '\\?';
  3379. const SLASH_LITERAL = '\\/';
  3380. const ONE_CHAR = '(?=.)';
  3381. const QMARK = '[^/]';
  3382. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  3383. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  3384. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  3385. const NO_DOT = `(?!${DOT_LITERAL})`;
  3386. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  3387. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  3388. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  3389. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  3390. const STAR = `${QMARK}*?`;
  3391. const SEP = '/';
  3392. const POSIX_CHARS = {
  3393. DOT_LITERAL,
  3394. PLUS_LITERAL,
  3395. QMARK_LITERAL,
  3396. SLASH_LITERAL,
  3397. ONE_CHAR,
  3398. QMARK,
  3399. END_ANCHOR,
  3400. DOTS_SLASH,
  3401. NO_DOT,
  3402. NO_DOTS,
  3403. NO_DOT_SLASH,
  3404. NO_DOTS_SLASH,
  3405. QMARK_NO_DOT,
  3406. STAR,
  3407. START_ANCHOR,
  3408. SEP
  3409. };
  3410. /**
  3411. * Windows glob regex
  3412. */
  3413. const WINDOWS_CHARS = {
  3414. ...POSIX_CHARS,
  3415. SLASH_LITERAL: `[${WIN_SLASH}]`,
  3416. QMARK: WIN_NO_SLASH,
  3417. STAR: `${WIN_NO_SLASH}*?`,
  3418. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  3419. NO_DOT: `(?!${DOT_LITERAL})`,
  3420. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  3421. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  3422. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  3423. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  3424. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  3425. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
  3426. SEP: '\\'
  3427. };
  3428. /**
  3429. * POSIX Bracket Regex
  3430. */
  3431. const POSIX_REGEX_SOURCE$1 = {
  3432. alnum: 'a-zA-Z0-9',
  3433. alpha: 'a-zA-Z',
  3434. ascii: '\\x00-\\x7F',
  3435. blank: ' \\t',
  3436. cntrl: '\\x00-\\x1F\\x7F',
  3437. digit: '0-9',
  3438. graph: '\\x21-\\x7E',
  3439. lower: 'a-z',
  3440. print: '\\x20-\\x7E ',
  3441. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  3442. space: ' \\t\\r\\n\\v\\f',
  3443. upper: 'A-Z',
  3444. word: 'A-Za-z0-9_',
  3445. xdigit: 'A-Fa-f0-9'
  3446. };
  3447. var constants$2 = {
  3448. MAX_LENGTH: 1024 * 64,
  3449. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  3450. // regular expressions
  3451. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  3452. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  3453. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  3454. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  3455. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  3456. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  3457. // Replace globs with equivalent patterns to reduce parsing time.
  3458. REPLACEMENTS: {
  3459. '***': '*',
  3460. '**/**': '**',
  3461. '**/**/**': '**'
  3462. },
  3463. // Digits
  3464. CHAR_0: 48, /* 0 */
  3465. CHAR_9: 57, /* 9 */
  3466. // Alphabet chars.
  3467. CHAR_UPPERCASE_A: 65, /* A */
  3468. CHAR_LOWERCASE_A: 97, /* a */
  3469. CHAR_UPPERCASE_Z: 90, /* Z */
  3470. CHAR_LOWERCASE_Z: 122, /* z */
  3471. CHAR_LEFT_PARENTHESES: 40, /* ( */
  3472. CHAR_RIGHT_PARENTHESES: 41, /* ) */
  3473. CHAR_ASTERISK: 42, /* * */
  3474. // Non-alphabetic chars.
  3475. CHAR_AMPERSAND: 38, /* & */
  3476. CHAR_AT: 64, /* @ */
  3477. CHAR_BACKWARD_SLASH: 92, /* \ */
  3478. CHAR_CARRIAGE_RETURN: 13, /* \r */
  3479. CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
  3480. CHAR_COLON: 58, /* : */
  3481. CHAR_COMMA: 44, /* , */
  3482. CHAR_DOT: 46, /* . */
  3483. CHAR_DOUBLE_QUOTE: 34, /* " */
  3484. CHAR_EQUAL: 61, /* = */
  3485. CHAR_EXCLAMATION_MARK: 33, /* ! */
  3486. CHAR_FORM_FEED: 12, /* \f */
  3487. CHAR_FORWARD_SLASH: 47, /* / */
  3488. CHAR_GRAVE_ACCENT: 96, /* ` */
  3489. CHAR_HASH: 35, /* # */
  3490. CHAR_HYPHEN_MINUS: 45, /* - */
  3491. CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
  3492. CHAR_LEFT_CURLY_BRACE: 123, /* { */
  3493. CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
  3494. CHAR_LINE_FEED: 10, /* \n */
  3495. CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
  3496. CHAR_PERCENT: 37, /* % */
  3497. CHAR_PLUS: 43, /* + */
  3498. CHAR_QUESTION_MARK: 63, /* ? */
  3499. CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
  3500. CHAR_RIGHT_CURLY_BRACE: 125, /* } */
  3501. CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
  3502. CHAR_SEMICOLON: 59, /* ; */
  3503. CHAR_SINGLE_QUOTE: 39, /* ' */
  3504. CHAR_SPACE: 32, /* */
  3505. CHAR_TAB: 9, /* \t */
  3506. CHAR_UNDERSCORE: 95, /* _ */
  3507. CHAR_VERTICAL_LINE: 124, /* | */
  3508. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
  3509. /**
  3510. * Create EXTGLOB_CHARS
  3511. */
  3512. extglobChars(chars) {
  3513. return {
  3514. '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
  3515. '?': { type: 'qmark', open: '(?:', close: ')?' },
  3516. '+': { type: 'plus', open: '(?:', close: ')+' },
  3517. '*': { type: 'star', open: '(?:', close: ')*' },
  3518. '@': { type: 'at', open: '(?:', close: ')' }
  3519. };
  3520. },
  3521. /**
  3522. * Create GLOB_CHARS
  3523. */
  3524. globChars(win32) {
  3525. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  3526. }
  3527. };
  3528. (function (exports) {
  3529. const {
  3530. REGEX_BACKSLASH,
  3531. REGEX_REMOVE_BACKSLASH,
  3532. REGEX_SPECIAL_CHARS,
  3533. REGEX_SPECIAL_CHARS_GLOBAL
  3534. } = constants$2;
  3535. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  3536. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  3537. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  3538. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  3539. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  3540. exports.removeBackslashes = str => {
  3541. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  3542. return match === '\\' ? '' : match;
  3543. });
  3544. };
  3545. exports.supportsLookbehinds = () => {
  3546. const segs = process.version.slice(1).split('.').map(Number);
  3547. if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
  3548. return true;
  3549. }
  3550. return false;
  3551. };
  3552. exports.escapeLast = (input, char, lastIdx) => {
  3553. const idx = input.lastIndexOf(char, lastIdx);
  3554. if (idx === -1) return input;
  3555. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  3556. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  3557. };
  3558. exports.removePrefix = (input, state = {}) => {
  3559. let output = input;
  3560. if (output.startsWith('./')) {
  3561. output = output.slice(2);
  3562. state.prefix = './';
  3563. }
  3564. return output;
  3565. };
  3566. exports.wrapOutput = (input, state = {}, options = {}) => {
  3567. const prepend = options.contains ? '' : '^';
  3568. const append = options.contains ? '' : '$';
  3569. let output = `${prepend}(?:${input})${append}`;
  3570. if (state.negated === true) {
  3571. output = `(?:^(?!${output}).*$)`;
  3572. }
  3573. return output;
  3574. };
  3575. exports.basename = (path, { windows } = {}) => {
  3576. if (windows) {
  3577. return path.replace(/[\\/]$/, '').replace(/.*[\\/]/, '');
  3578. } else {
  3579. return path.replace(/\/$/, '').replace(/.*\//, '');
  3580. }
  3581. };
  3582. } (utils$3));
  3583. const utils$2 = utils$3;
  3584. const {
  3585. CHAR_ASTERISK, /* * */
  3586. CHAR_AT, /* @ */
  3587. CHAR_BACKWARD_SLASH, /* \ */
  3588. CHAR_COMMA, /* , */
  3589. CHAR_DOT, /* . */
  3590. CHAR_EXCLAMATION_MARK, /* ! */
  3591. CHAR_FORWARD_SLASH, /* / */
  3592. CHAR_LEFT_CURLY_BRACE, /* { */
  3593. CHAR_LEFT_PARENTHESES, /* ( */
  3594. CHAR_LEFT_SQUARE_BRACKET, /* [ */
  3595. CHAR_PLUS, /* + */
  3596. CHAR_QUESTION_MARK, /* ? */
  3597. CHAR_RIGHT_CURLY_BRACE, /* } */
  3598. CHAR_RIGHT_PARENTHESES, /* ) */
  3599. CHAR_RIGHT_SQUARE_BRACKET /* ] */
  3600. } = constants$2;
  3601. const isPathSeparator = code => {
  3602. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  3603. };
  3604. const depth = token => {
  3605. if (token.isPrefix !== true) {
  3606. token.depth = token.isGlobstar ? Infinity : 1;
  3607. }
  3608. };
  3609. /**
  3610. * Quickly scans a glob pattern and returns an object with a handful of
  3611. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  3612. * `glob` (the actual pattern), and `negated` (true if the path starts with `!`).
  3613. *
  3614. * ```js
  3615. * const pm = require('picomatch');
  3616. * console.log(pm.scan('foo/bar/*.js'));
  3617. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  3618. * ```
  3619. * @param {String} `str`
  3620. * @param {Object} `options`
  3621. * @return {Object} Returns an object with tokens and regex source string.
  3622. * @api public
  3623. */
  3624. const scan$1 = (input, options) => {
  3625. const opts = options || {};
  3626. const length = input.length - 1;
  3627. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  3628. const slashes = [];
  3629. const tokens = [];
  3630. const parts = [];
  3631. let str = input;
  3632. let index = -1;
  3633. let start = 0;
  3634. let lastIndex = 0;
  3635. let isBrace = false;
  3636. let isBracket = false;
  3637. let isGlob = false;
  3638. let isExtglob = false;
  3639. let isGlobstar = false;
  3640. let braceEscaped = false;
  3641. let backslashes = false;
  3642. let negated = false;
  3643. let finished = false;
  3644. let braces = 0;
  3645. let prev;
  3646. let code;
  3647. let token = { value: '', depth: 0, isGlob: false };
  3648. const eos = () => index >= length;
  3649. const peek = () => str.charCodeAt(index + 1);
  3650. const advance = () => {
  3651. prev = code;
  3652. return str.charCodeAt(++index);
  3653. };
  3654. while (index < length) {
  3655. code = advance();
  3656. let next;
  3657. if (code === CHAR_BACKWARD_SLASH) {
  3658. backslashes = token.backslashes = true;
  3659. code = advance();
  3660. if (code === CHAR_LEFT_CURLY_BRACE) {
  3661. braceEscaped = true;
  3662. }
  3663. continue;
  3664. }
  3665. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  3666. braces++;
  3667. while (eos() !== true && (code = advance())) {
  3668. if (code === CHAR_BACKWARD_SLASH) {
  3669. backslashes = token.backslashes = true;
  3670. advance();
  3671. continue;
  3672. }
  3673. if (code === CHAR_LEFT_CURLY_BRACE) {
  3674. braces++;
  3675. continue;
  3676. }
  3677. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  3678. isBrace = token.isBrace = true;
  3679. isGlob = token.isGlob = true;
  3680. finished = true;
  3681. if (scanToEnd === true) {
  3682. continue;
  3683. }
  3684. break;
  3685. }
  3686. if (braceEscaped !== true && code === CHAR_COMMA) {
  3687. isBrace = token.isBrace = true;
  3688. isGlob = token.isGlob = true;
  3689. finished = true;
  3690. if (scanToEnd === true) {
  3691. continue;
  3692. }
  3693. break;
  3694. }
  3695. if (code === CHAR_RIGHT_CURLY_BRACE) {
  3696. braces--;
  3697. if (braces === 0) {
  3698. braceEscaped = false;
  3699. isBrace = token.isBrace = true;
  3700. finished = true;
  3701. break;
  3702. }
  3703. }
  3704. }
  3705. if (scanToEnd === true) {
  3706. continue;
  3707. }
  3708. break;
  3709. }
  3710. if (code === CHAR_FORWARD_SLASH) {
  3711. slashes.push(index);
  3712. tokens.push(token);
  3713. token = { value: '', depth: 0, isGlob: false };
  3714. if (finished === true) continue;
  3715. if (prev === CHAR_DOT && index === (start + 1)) {
  3716. start += 2;
  3717. continue;
  3718. }
  3719. lastIndex = index + 1;
  3720. continue;
  3721. }
  3722. if (opts.noext !== true) {
  3723. const isExtglobChar = code === CHAR_PLUS
  3724. || code === CHAR_AT
  3725. || code === CHAR_ASTERISK
  3726. || code === CHAR_QUESTION_MARK
  3727. || code === CHAR_EXCLAMATION_MARK;
  3728. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  3729. isGlob = token.isGlob = true;
  3730. isExtglob = token.isExtglob = true;
  3731. finished = true;
  3732. if (scanToEnd === true) {
  3733. while (eos() !== true && (code = advance())) {
  3734. if (code === CHAR_BACKWARD_SLASH) {
  3735. backslashes = token.backslashes = true;
  3736. code = advance();
  3737. continue;
  3738. }
  3739. if (code === CHAR_RIGHT_PARENTHESES) {
  3740. isGlob = token.isGlob = true;
  3741. finished = true;
  3742. break;
  3743. }
  3744. }
  3745. continue;
  3746. }
  3747. break;
  3748. }
  3749. }
  3750. if (code === CHAR_ASTERISK) {
  3751. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  3752. isGlob = token.isGlob = true;
  3753. finished = true;
  3754. if (scanToEnd === true) {
  3755. continue;
  3756. }
  3757. break;
  3758. }
  3759. if (code === CHAR_QUESTION_MARK) {
  3760. isGlob = token.isGlob = true;
  3761. finished = true;
  3762. if (scanToEnd === true) {
  3763. continue;
  3764. }
  3765. break;
  3766. }
  3767. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  3768. while (eos() !== true && (next = advance())) {
  3769. if (next === CHAR_BACKWARD_SLASH) {
  3770. backslashes = token.backslashes = true;
  3771. advance();
  3772. continue;
  3773. }
  3774. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  3775. isBracket = token.isBracket = true;
  3776. isGlob = token.isGlob = true;
  3777. finished = true;
  3778. if (scanToEnd === true) {
  3779. continue;
  3780. }
  3781. break;
  3782. }
  3783. }
  3784. }
  3785. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  3786. negated = token.negated = true;
  3787. start++;
  3788. continue;
  3789. }
  3790. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  3791. isGlob = token.isGlob = true;
  3792. if (scanToEnd === true) {
  3793. while (eos() !== true && (code = advance())) {
  3794. if (code === CHAR_LEFT_PARENTHESES) {
  3795. backslashes = token.backslashes = true;
  3796. code = advance();
  3797. continue;
  3798. }
  3799. if (code === CHAR_RIGHT_PARENTHESES) {
  3800. finished = true;
  3801. break;
  3802. }
  3803. }
  3804. continue;
  3805. }
  3806. break;
  3807. }
  3808. if (isGlob === true) {
  3809. finished = true;
  3810. if (scanToEnd === true) {
  3811. continue;
  3812. }
  3813. break;
  3814. }
  3815. }
  3816. if (opts.noext === true) {
  3817. isExtglob = false;
  3818. isGlob = false;
  3819. }
  3820. let base = str;
  3821. let prefix = '';
  3822. let glob = '';
  3823. if (start > 0) {
  3824. prefix = str.slice(0, start);
  3825. str = str.slice(start);
  3826. lastIndex -= start;
  3827. }
  3828. if (base && isGlob === true && lastIndex > 0) {
  3829. base = str.slice(0, lastIndex);
  3830. glob = str.slice(lastIndex);
  3831. } else if (isGlob === true) {
  3832. base = '';
  3833. glob = str;
  3834. } else {
  3835. base = str;
  3836. }
  3837. if (base && base !== '' && base !== '/' && base !== str) {
  3838. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  3839. base = base.slice(0, -1);
  3840. }
  3841. }
  3842. if (opts.unescape === true) {
  3843. if (glob) glob = utils$2.removeBackslashes(glob);
  3844. if (base && backslashes === true) {
  3845. base = utils$2.removeBackslashes(base);
  3846. }
  3847. }
  3848. const state = {
  3849. prefix,
  3850. input,
  3851. start,
  3852. base,
  3853. glob,
  3854. isBrace,
  3855. isBracket,
  3856. isGlob,
  3857. isExtglob,
  3858. isGlobstar,
  3859. negated
  3860. };
  3861. if (opts.tokens === true) {
  3862. state.maxDepth = 0;
  3863. if (!isPathSeparator(code)) {
  3864. tokens.push(token);
  3865. }
  3866. state.tokens = tokens;
  3867. }
  3868. if (opts.parts === true || opts.tokens === true) {
  3869. let prevIndex;
  3870. for (let idx = 0; idx < slashes.length; idx++) {
  3871. const n = prevIndex ? prevIndex + 1 : start;
  3872. const i = slashes[idx];
  3873. const value = input.slice(n, i);
  3874. if (opts.tokens) {
  3875. if (idx === 0 && start !== 0) {
  3876. tokens[idx].isPrefix = true;
  3877. tokens[idx].value = prefix;
  3878. } else {
  3879. tokens[idx].value = value;
  3880. }
  3881. depth(tokens[idx]);
  3882. state.maxDepth += tokens[idx].depth;
  3883. }
  3884. if (idx !== 0 || value !== '') {
  3885. parts.push(value);
  3886. }
  3887. prevIndex = i;
  3888. }
  3889. if (prevIndex && prevIndex + 1 < input.length) {
  3890. const value = input.slice(prevIndex + 1);
  3891. parts.push(value);
  3892. if (opts.tokens) {
  3893. tokens[tokens.length - 1].value = value;
  3894. depth(tokens[tokens.length - 1]);
  3895. state.maxDepth += tokens[tokens.length - 1].depth;
  3896. }
  3897. }
  3898. state.slashes = slashes;
  3899. state.parts = parts;
  3900. }
  3901. return state;
  3902. };
  3903. var scan_1 = scan$1;
  3904. const constants$1 = constants$2;
  3905. const utils$1 = utils$3;
  3906. /**
  3907. * Constants
  3908. */
  3909. const {
  3910. MAX_LENGTH,
  3911. POSIX_REGEX_SOURCE,
  3912. REGEX_NON_SPECIAL_CHARS,
  3913. REGEX_SPECIAL_CHARS_BACKREF,
  3914. REPLACEMENTS
  3915. } = constants$1;
  3916. /**
  3917. * Helpers
  3918. */
  3919. const expandRange = (args, options) => {
  3920. if (typeof options.expandRange === 'function') {
  3921. return options.expandRange(...args, options);
  3922. }
  3923. args.sort();
  3924. const value = `[${args.join('-')}]`;
  3925. try {
  3926. /* eslint-disable-next-line no-new */
  3927. new RegExp(value);
  3928. } catch (ex) {
  3929. return args.map(v => utils$1.escapeRegex(v)).join('..');
  3930. }
  3931. return value;
  3932. };
  3933. /**
  3934. * Create the message for a syntax error
  3935. */
  3936. const syntaxError = (type, char) => {
  3937. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  3938. };
  3939. /**
  3940. * Parse the given input string.
  3941. * @param {String} input
  3942. * @param {Object} options
  3943. * @return {Object}
  3944. */
  3945. const parse$1 = (input, options) => {
  3946. if (typeof input !== 'string') {
  3947. throw new TypeError('Expected a string');
  3948. }
  3949. input = REPLACEMENTS[input] || input;
  3950. const opts = { ...options };
  3951. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  3952. let len = input.length;
  3953. if (len > max) {
  3954. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  3955. }
  3956. const bos = { type: 'bos', value: '', output: opts.prepend || '' };
  3957. const tokens = [bos];
  3958. const capture = opts.capture ? '' : '?:';
  3959. // create constants based on platform, for windows or posix
  3960. const PLATFORM_CHARS = constants$1.globChars(opts.windows);
  3961. const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
  3962. const {
  3963. DOT_LITERAL,
  3964. PLUS_LITERAL,
  3965. SLASH_LITERAL,
  3966. ONE_CHAR,
  3967. DOTS_SLASH,
  3968. NO_DOT,
  3969. NO_DOT_SLASH,
  3970. NO_DOTS_SLASH,
  3971. QMARK,
  3972. QMARK_NO_DOT,
  3973. STAR,
  3974. START_ANCHOR
  3975. } = PLATFORM_CHARS;
  3976. const globstar = (opts) => {
  3977. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  3978. };
  3979. const nodot = opts.dot ? '' : NO_DOT;
  3980. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  3981. let star = opts.bash === true ? globstar(opts) : STAR;
  3982. if (opts.capture) {
  3983. star = `(${star})`;
  3984. }
  3985. // minimatch options support
  3986. if (typeof opts.noext === 'boolean') {
  3987. opts.noextglob = opts.noext;
  3988. }
  3989. const state = {
  3990. input,
  3991. index: -1,
  3992. start: 0,
  3993. dot: opts.dot === true,
  3994. consumed: '',
  3995. output: '',
  3996. prefix: '',
  3997. backtrack: false,
  3998. negated: false,
  3999. brackets: 0,
  4000. braces: 0,
  4001. parens: 0,
  4002. quotes: 0,
  4003. globstar: false,
  4004. tokens
  4005. };
  4006. input = utils$1.removePrefix(input, state);
  4007. len = input.length;
  4008. const extglobs = [];
  4009. const braces = [];
  4010. const stack = [];
  4011. let prev = bos;
  4012. let value;
  4013. /**
  4014. * Tokenizing helpers
  4015. */
  4016. const eos = () => state.index === len - 1;
  4017. const peek = state.peek = (n = 1) => input[state.index + n];
  4018. const advance = state.advance = () => input[++state.index];
  4019. const remaining = () => input.slice(state.index + 1);
  4020. const consume = (value = '', num = 0) => {
  4021. state.consumed += value;
  4022. state.index += num;
  4023. };
  4024. const append = token => {
  4025. state.output += token.output != null ? token.output : token.value;
  4026. consume(token.value);
  4027. };
  4028. const negate = () => {
  4029. let count = 1;
  4030. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  4031. advance();
  4032. state.start++;
  4033. count++;
  4034. }
  4035. if (count % 2 === 0) {
  4036. return false;
  4037. }
  4038. state.negated = true;
  4039. state.start++;
  4040. return true;
  4041. };
  4042. const increment = type => {
  4043. state[type]++;
  4044. stack.push(type);
  4045. };
  4046. const decrement = type => {
  4047. state[type]--;
  4048. stack.pop();
  4049. };
  4050. /**
  4051. * Push tokens onto the tokens array. This helper speeds up
  4052. * tokenizing by 1) helping us avoid backtracking as much as possible,
  4053. * and 2) helping us avoid creating extra tokens when consecutive
  4054. * characters are plain text. This improves performance and simplifies
  4055. * lookbehinds.
  4056. */
  4057. const push = tok => {
  4058. if (prev.type === 'globstar') {
  4059. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  4060. const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
  4061. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  4062. state.output = state.output.slice(0, -prev.output.length);
  4063. prev.type = 'star';
  4064. prev.value = '*';
  4065. prev.output = star;
  4066. state.output += prev.output;
  4067. }
  4068. }
  4069. if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) {
  4070. extglobs[extglobs.length - 1].inner += tok.value;
  4071. }
  4072. if (tok.value || tok.output) append(tok);
  4073. if (prev && prev.type === 'text' && tok.type === 'text') {
  4074. prev.value += tok.value;
  4075. prev.output = (prev.output || '') + tok.value;
  4076. return;
  4077. }
  4078. tok.prev = prev;
  4079. tokens.push(tok);
  4080. prev = tok;
  4081. };
  4082. const extglobOpen = (type, value) => {
  4083. const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
  4084. token.prev = prev;
  4085. token.parens = state.parens;
  4086. token.output = state.output;
  4087. const output = (opts.capture ? '(' : '') + token.open;
  4088. increment('parens');
  4089. push({ type, value, output: state.output ? '' : ONE_CHAR });
  4090. push({ type: 'paren', extglob: true, value: advance(), output });
  4091. extglobs.push(token);
  4092. };
  4093. const extglobClose = token => {
  4094. let output = token.close + (opts.capture ? ')' : '');
  4095. if (token.type === 'negate') {
  4096. let extglobStar = star;
  4097. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  4098. extglobStar = globstar(opts);
  4099. }
  4100. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  4101. output = token.close = `)$))${extglobStar}`;
  4102. }
  4103. if (token.prev.type === 'bos' && eos()) {
  4104. state.negatedExtglob = true;
  4105. }
  4106. }
  4107. push({ type: 'paren', extglob: true, value, output });
  4108. decrement('parens');
  4109. };
  4110. /**
  4111. * Fast paths
  4112. */
  4113. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  4114. let backslashes = false;
  4115. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  4116. if (first === '\\') {
  4117. backslashes = true;
  4118. return m;
  4119. }
  4120. if (first === '?') {
  4121. if (esc) {
  4122. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  4123. }
  4124. if (index === 0) {
  4125. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  4126. }
  4127. return QMARK.repeat(chars.length);
  4128. }
  4129. if (first === '.') {
  4130. return DOT_LITERAL.repeat(chars.length);
  4131. }
  4132. if (first === '*') {
  4133. if (esc) {
  4134. return esc + first + (rest ? star : '');
  4135. }
  4136. return star;
  4137. }
  4138. return esc ? m : `\\${m}`;
  4139. });
  4140. if (backslashes === true) {
  4141. if (opts.unescape === true) {
  4142. output = output.replace(/\\/g, '');
  4143. } else {
  4144. output = output.replace(/\\+/g, m => {
  4145. return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
  4146. });
  4147. }
  4148. }
  4149. if (output === input && opts.contains === true) {
  4150. state.output = input;
  4151. return state;
  4152. }
  4153. state.output = utils$1.wrapOutput(output, state, options);
  4154. return state;
  4155. }
  4156. /**
  4157. * Tokenize input until we reach end-of-string
  4158. */
  4159. while (!eos()) {
  4160. value = advance();
  4161. if (value === '\u0000') {
  4162. continue;
  4163. }
  4164. /**
  4165. * Escaped characters
  4166. */
  4167. if (value === '\\') {
  4168. const next = peek();
  4169. if (next === '/' && opts.bash !== true) {
  4170. continue;
  4171. }
  4172. if (next === '.' || next === ';') {
  4173. continue;
  4174. }
  4175. if (!next) {
  4176. value += '\\';
  4177. push({ type: 'text', value });
  4178. continue;
  4179. }
  4180. // collapse slashes to reduce potential for exploits
  4181. const match = /^\\+/.exec(remaining());
  4182. let slashes = 0;
  4183. if (match && match[0].length > 2) {
  4184. slashes = match[0].length;
  4185. state.index += slashes;
  4186. if (slashes % 2 !== 0) {
  4187. value += '\\';
  4188. }
  4189. }
  4190. if (opts.unescape === true) {
  4191. value = advance() || '';
  4192. } else {
  4193. value += advance() || '';
  4194. }
  4195. if (state.brackets === 0) {
  4196. push({ type: 'text', value });
  4197. continue;
  4198. }
  4199. }
  4200. /**
  4201. * If we're inside a regex character class, continue
  4202. * until we reach the closing bracket.
  4203. */
  4204. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  4205. if (opts.posix !== false && value === ':') {
  4206. const inner = prev.value.slice(1);
  4207. if (inner.includes('[')) {
  4208. prev.posix = true;
  4209. if (inner.includes(':')) {
  4210. const idx = prev.value.lastIndexOf('[');
  4211. const pre = prev.value.slice(0, idx);
  4212. const rest = prev.value.slice(idx + 2);
  4213. const posix = POSIX_REGEX_SOURCE[rest];
  4214. if (posix) {
  4215. prev.value = pre + posix;
  4216. state.backtrack = true;
  4217. advance();
  4218. if (!bos.output && tokens.indexOf(prev) === 1) {
  4219. bos.output = ONE_CHAR;
  4220. }
  4221. continue;
  4222. }
  4223. }
  4224. }
  4225. }
  4226. if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
  4227. value = `\\${value}`;
  4228. }
  4229. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  4230. value = `\\${value}`;
  4231. }
  4232. if (opts.posix === true && value === '!' && prev.value === '[') {
  4233. value = '^';
  4234. }
  4235. prev.value += value;
  4236. append({ value });
  4237. continue;
  4238. }
  4239. /**
  4240. * If we're inside a quoted string, continue
  4241. * until we reach the closing double quote.
  4242. */
  4243. if (state.quotes === 1 && value !== '"') {
  4244. value = utils$1.escapeRegex(value);
  4245. prev.value += value;
  4246. append({ value });
  4247. continue;
  4248. }
  4249. /**
  4250. * Double quotes
  4251. */
  4252. if (value === '"') {
  4253. state.quotes = state.quotes === 1 ? 0 : 1;
  4254. if (opts.keepQuotes === true) {
  4255. push({ type: 'text', value });
  4256. }
  4257. continue;
  4258. }
  4259. /**
  4260. * Parentheses
  4261. */
  4262. if (value === '(') {
  4263. increment('parens');
  4264. push({ type: 'paren', value });
  4265. continue;
  4266. }
  4267. if (value === ')') {
  4268. if (state.parens === 0 && opts.strictBrackets === true) {
  4269. throw new SyntaxError(syntaxError('opening', '('));
  4270. }
  4271. const extglob = extglobs[extglobs.length - 1];
  4272. if (extglob && state.parens === extglob.parens + 1) {
  4273. extglobClose(extglobs.pop());
  4274. continue;
  4275. }
  4276. push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
  4277. decrement('parens');
  4278. continue;
  4279. }
  4280. /**
  4281. * Square brackets
  4282. */
  4283. if (value === '[') {
  4284. if (opts.nobracket === true || !remaining().includes(']')) {
  4285. if (opts.nobracket !== true && opts.strictBrackets === true) {
  4286. throw new SyntaxError(syntaxError('closing', ']'));
  4287. }
  4288. value = `\\${value}`;
  4289. } else {
  4290. increment('brackets');
  4291. }
  4292. push({ type: 'bracket', value });
  4293. continue;
  4294. }
  4295. if (value === ']') {
  4296. if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
  4297. push({ type: 'text', value, output: `\\${value}` });
  4298. continue;
  4299. }
  4300. if (state.brackets === 0) {
  4301. if (opts.strictBrackets === true) {
  4302. throw new SyntaxError(syntaxError('opening', '['));
  4303. }
  4304. push({ type: 'text', value, output: `\\${value}` });
  4305. continue;
  4306. }
  4307. decrement('brackets');
  4308. const prevValue = prev.value.slice(1);
  4309. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  4310. value = `/${value}`;
  4311. }
  4312. prev.value += value;
  4313. append({ value });
  4314. // when literal brackets are explicitly disabled
  4315. // assume we should match with a regex character class
  4316. if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
  4317. continue;
  4318. }
  4319. const escaped = utils$1.escapeRegex(prev.value);
  4320. state.output = state.output.slice(0, -prev.value.length);
  4321. // when literal brackets are explicitly enabled
  4322. // assume we should escape the brackets to match literal characters
  4323. if (opts.literalBrackets === true) {
  4324. state.output += escaped;
  4325. prev.value = escaped;
  4326. continue;
  4327. }
  4328. // when the user specifies nothing, try to match both
  4329. prev.value = `(${capture}${escaped}|${prev.value})`;
  4330. state.output += prev.value;
  4331. continue;
  4332. }
  4333. /**
  4334. * Braces
  4335. */
  4336. if (value === '{' && opts.nobrace !== true) {
  4337. increment('braces');
  4338. const open = {
  4339. type: 'brace',
  4340. value,
  4341. output: '(',
  4342. outputIndex: state.output.length,
  4343. tokensIndex: state.tokens.length
  4344. };
  4345. braces.push(open);
  4346. push(open);
  4347. continue;
  4348. }
  4349. if (value === '}') {
  4350. const brace = braces[braces.length - 1];
  4351. if (opts.nobrace === true || !brace) {
  4352. push({ type: 'text', value, output: value });
  4353. continue;
  4354. }
  4355. let output = ')';
  4356. if (brace.dots === true) {
  4357. const arr = tokens.slice();
  4358. const range = [];
  4359. for (let i = arr.length - 1; i >= 0; i--) {
  4360. tokens.pop();
  4361. if (arr[i].type === 'brace') {
  4362. break;
  4363. }
  4364. if (arr[i].type !== 'dots') {
  4365. range.unshift(arr[i].value);
  4366. }
  4367. }
  4368. output = expandRange(range, opts);
  4369. state.backtrack = true;
  4370. }
  4371. if (brace.comma !== true && brace.dots !== true) {
  4372. const out = state.output.slice(0, brace.outputIndex);
  4373. const toks = state.tokens.slice(brace.tokensIndex);
  4374. brace.value = brace.output = '\\{';
  4375. value = output = '\\}';
  4376. state.output = out;
  4377. for (const t of toks) {
  4378. state.output += (t.output || t.value);
  4379. }
  4380. }
  4381. push({ type: 'brace', value, output });
  4382. decrement('braces');
  4383. braces.pop();
  4384. continue;
  4385. }
  4386. /**
  4387. * Pipes
  4388. */
  4389. if (value === '|') {
  4390. if (extglobs.length > 0) {
  4391. extglobs[extglobs.length - 1].conditions++;
  4392. }
  4393. push({ type: 'text', value });
  4394. continue;
  4395. }
  4396. /**
  4397. * Commas
  4398. */
  4399. if (value === ',') {
  4400. let output = value;
  4401. const brace = braces[braces.length - 1];
  4402. if (brace && stack[stack.length - 1] === 'braces') {
  4403. brace.comma = true;
  4404. output = '|';
  4405. }
  4406. push({ type: 'comma', value, output });
  4407. continue;
  4408. }
  4409. /**
  4410. * Slashes
  4411. */
  4412. if (value === '/') {
  4413. // if the beginning of the glob is "./", advance the start
  4414. // to the current index, and don't add the "./" characters
  4415. // to the state. This greatly simplifies lookbehinds when
  4416. // checking for BOS characters like "!" and "." (not "./")
  4417. if (prev.type === 'dot' && state.index === state.start + 1) {
  4418. state.start = state.index + 1;
  4419. state.consumed = '';
  4420. state.output = '';
  4421. tokens.pop();
  4422. prev = bos; // reset "prev" to the first token
  4423. continue;
  4424. }
  4425. push({ type: 'slash', value, output: SLASH_LITERAL });
  4426. continue;
  4427. }
  4428. /**
  4429. * Dots
  4430. */
  4431. if (value === '.') {
  4432. if (state.braces > 0 && prev.type === 'dot') {
  4433. if (prev.value === '.') prev.output = DOT_LITERAL;
  4434. const brace = braces[braces.length - 1];
  4435. prev.type = 'dots';
  4436. prev.output += value;
  4437. prev.value += value;
  4438. brace.dots = true;
  4439. continue;
  4440. }
  4441. if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  4442. push({ type: 'text', value, output: DOT_LITERAL });
  4443. continue;
  4444. }
  4445. push({ type: 'dot', value, output: DOT_LITERAL });
  4446. continue;
  4447. }
  4448. /**
  4449. * Question marks
  4450. */
  4451. if (value === '?') {
  4452. const isGroup = prev && prev.value === '(';
  4453. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  4454. extglobOpen('qmark', value);
  4455. continue;
  4456. }
  4457. if (prev && prev.type === 'paren') {
  4458. const next = peek();
  4459. let output = value;
  4460. if (next === '<' && !utils$1.supportsLookbehinds()) {
  4461. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  4462. }
  4463. if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
  4464. output = `\\${value}`;
  4465. }
  4466. push({ type: 'text', value, output });
  4467. continue;
  4468. }
  4469. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  4470. push({ type: 'qmark', value, output: QMARK_NO_DOT });
  4471. continue;
  4472. }
  4473. push({ type: 'qmark', value, output: QMARK });
  4474. continue;
  4475. }
  4476. /**
  4477. * Exclamation
  4478. */
  4479. if (value === '!') {
  4480. if (opts.noextglob !== true && peek() === '(') {
  4481. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  4482. extglobOpen('negate', value);
  4483. continue;
  4484. }
  4485. }
  4486. if (opts.nonegate !== true && state.index === 0) {
  4487. negate();
  4488. continue;
  4489. }
  4490. }
  4491. /**
  4492. * Plus
  4493. */
  4494. if (value === '+') {
  4495. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  4496. extglobOpen('plus', value);
  4497. continue;
  4498. }
  4499. if ((prev && prev.value === '(') || opts.regex === false) {
  4500. push({ type: 'plus', value, output: PLUS_LITERAL });
  4501. continue;
  4502. }
  4503. if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
  4504. push({ type: 'plus', value });
  4505. continue;
  4506. }
  4507. push({ type: 'plus', value: PLUS_LITERAL });
  4508. continue;
  4509. }
  4510. /**
  4511. * Plain text
  4512. */
  4513. if (value === '@') {
  4514. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  4515. push({ type: 'at', extglob: true, value, output: '' });
  4516. continue;
  4517. }
  4518. push({ type: 'text', value });
  4519. continue;
  4520. }
  4521. /**
  4522. * Plain text
  4523. */
  4524. if (value !== '*') {
  4525. if (value === '$' || value === '^') {
  4526. value = `\\${value}`;
  4527. }
  4528. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  4529. if (match) {
  4530. value += match[0];
  4531. state.index += match[0].length;
  4532. }
  4533. push({ type: 'text', value });
  4534. continue;
  4535. }
  4536. /**
  4537. * Stars
  4538. */
  4539. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  4540. prev.type = 'star';
  4541. prev.star = true;
  4542. prev.value += value;
  4543. prev.output = star;
  4544. state.backtrack = true;
  4545. state.globstar = true;
  4546. consume(value);
  4547. continue;
  4548. }
  4549. let rest = remaining();
  4550. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  4551. extglobOpen('star', value);
  4552. continue;
  4553. }
  4554. if (prev.type === 'star') {
  4555. if (opts.noglobstar === true) {
  4556. consume(value);
  4557. continue;
  4558. }
  4559. const prior = prev.prev;
  4560. const before = prior.prev;
  4561. const isStart = prior.type === 'slash' || prior.type === 'bos';
  4562. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  4563. if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
  4564. push({ type: 'star', value, output: '' });
  4565. continue;
  4566. }
  4567. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  4568. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  4569. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  4570. push({ type: 'star', value, output: '' });
  4571. continue;
  4572. }
  4573. // strip consecutive `/**/`
  4574. while (rest.slice(0, 3) === '/**') {
  4575. const after = input[state.index + 4];
  4576. if (after && after !== '/') {
  4577. break;
  4578. }
  4579. rest = rest.slice(3);
  4580. consume('/**', 3);
  4581. }
  4582. if (prior.type === 'bos' && eos()) {
  4583. prev.type = 'globstar';
  4584. prev.value += value;
  4585. prev.output = globstar(opts);
  4586. state.output = prev.output;
  4587. state.globstar = true;
  4588. consume(value);
  4589. continue;
  4590. }
  4591. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  4592. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  4593. prior.output = `(?:${prior.output}`;
  4594. prev.type = 'globstar';
  4595. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  4596. prev.value += value;
  4597. state.globstar = true;
  4598. state.output += prior.output + prev.output;
  4599. consume(value);
  4600. continue;
  4601. }
  4602. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  4603. const end = rest[1] !== void 0 ? '|$' : '';
  4604. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  4605. prior.output = `(?:${prior.output}`;
  4606. prev.type = 'globstar';
  4607. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  4608. prev.value += value;
  4609. state.output += prior.output + prev.output;
  4610. state.globstar = true;
  4611. consume(value + advance());
  4612. push({ type: 'slash', value: '/', output: '' });
  4613. continue;
  4614. }
  4615. if (prior.type === 'bos' && rest[0] === '/') {
  4616. prev.type = 'globstar';
  4617. prev.value += value;
  4618. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  4619. state.output = prev.output;
  4620. state.globstar = true;
  4621. consume(value + advance());
  4622. push({ type: 'slash', value: '/', output: '' });
  4623. continue;
  4624. }
  4625. // remove single star from output
  4626. state.output = state.output.slice(0, -prev.output.length);
  4627. // reset previous token to globstar
  4628. prev.type = 'globstar';
  4629. prev.output = globstar(opts);
  4630. prev.value += value;
  4631. // reset output with globstar
  4632. state.output += prev.output;
  4633. state.globstar = true;
  4634. consume(value);
  4635. continue;
  4636. }
  4637. const token = { type: 'star', value, output: star };
  4638. if (opts.bash === true) {
  4639. token.output = '.*?';
  4640. if (prev.type === 'bos' || prev.type === 'slash') {
  4641. token.output = nodot + token.output;
  4642. }
  4643. push(token);
  4644. continue;
  4645. }
  4646. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  4647. token.output = value;
  4648. push(token);
  4649. continue;
  4650. }
  4651. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  4652. if (prev.type === 'dot') {
  4653. state.output += NO_DOT_SLASH;
  4654. prev.output += NO_DOT_SLASH;
  4655. } else if (opts.dot === true) {
  4656. state.output += NO_DOTS_SLASH;
  4657. prev.output += NO_DOTS_SLASH;
  4658. } else {
  4659. state.output += nodot;
  4660. prev.output += nodot;
  4661. }
  4662. if (peek() !== '*') {
  4663. state.output += ONE_CHAR;
  4664. prev.output += ONE_CHAR;
  4665. }
  4666. }
  4667. push(token);
  4668. }
  4669. while (state.brackets > 0) {
  4670. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
  4671. state.output = utils$1.escapeLast(state.output, '[');
  4672. decrement('brackets');
  4673. }
  4674. while (state.parens > 0) {
  4675. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
  4676. state.output = utils$1.escapeLast(state.output, '(');
  4677. decrement('parens');
  4678. }
  4679. while (state.braces > 0) {
  4680. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
  4681. state.output = utils$1.escapeLast(state.output, '{');
  4682. decrement('braces');
  4683. }
  4684. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  4685. push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
  4686. }
  4687. // rebuild the output if we had to backtrack at any point
  4688. if (state.backtrack === true) {
  4689. state.output = '';
  4690. for (const token of state.tokens) {
  4691. state.output += token.output != null ? token.output : token.value;
  4692. if (token.suffix) {
  4693. state.output += token.suffix;
  4694. }
  4695. }
  4696. }
  4697. return state;
  4698. };
  4699. /**
  4700. * Fast paths for creating regular expressions for common glob patterns.
  4701. * This can significantly speed up processing and has very little downside
  4702. * impact when none of the fast paths match.
  4703. */
  4704. parse$1.fastpaths = (input, options) => {
  4705. const opts = { ...options };
  4706. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  4707. const len = input.length;
  4708. if (len > max) {
  4709. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  4710. }
  4711. input = REPLACEMENTS[input] || input;
  4712. // create constants based on platform, for windows or posix
  4713. const {
  4714. DOT_LITERAL,
  4715. SLASH_LITERAL,
  4716. ONE_CHAR,
  4717. DOTS_SLASH,
  4718. NO_DOT,
  4719. NO_DOTS,
  4720. NO_DOTS_SLASH,
  4721. STAR,
  4722. START_ANCHOR
  4723. } = constants$1.globChars(opts.windows);
  4724. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  4725. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  4726. const capture = opts.capture ? '' : '?:';
  4727. const state = { negated: false, prefix: '' };
  4728. let star = opts.bash === true ? '.*?' : STAR;
  4729. if (opts.capture) {
  4730. star = `(${star})`;
  4731. }
  4732. const globstar = (opts) => {
  4733. if (opts.noglobstar === true) return star;
  4734. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  4735. };
  4736. const create = str => {
  4737. switch (str) {
  4738. case '*':
  4739. return `${nodot}${ONE_CHAR}${star}`;
  4740. case '.*':
  4741. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  4742. case '*.*':
  4743. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  4744. case '*/*':
  4745. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  4746. case '**':
  4747. return nodot + globstar(opts);
  4748. case '**/*':
  4749. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  4750. case '**/*.*':
  4751. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  4752. case '**/.*':
  4753. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  4754. default: {
  4755. const match = /^(.*?)\.(\w+)$/.exec(str);
  4756. if (!match) return;
  4757. const source = create(match[1]);
  4758. if (!source) return;
  4759. return source + DOT_LITERAL + match[2];
  4760. }
  4761. }
  4762. };
  4763. const output = utils$1.removePrefix(input, state);
  4764. let source = create(output);
  4765. if (source && opts.strictSlashes !== true) {
  4766. source += `${SLASH_LITERAL}?`;
  4767. }
  4768. return source;
  4769. };
  4770. var parse_1 = parse$1;
  4771. const scan = scan_1;
  4772. const parse = parse_1;
  4773. const utils = utils$3;
  4774. const constants = constants$2;
  4775. const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
  4776. /**
  4777. * Creates a matcher function from one or more glob patterns. The
  4778. * returned function takes a string to match as its first argument,
  4779. * and returns true if the string is a match. The returned matcher
  4780. * function also takes a boolean as the second argument that, when true,
  4781. * returns an object with additional information.
  4782. *
  4783. * ```js
  4784. * const picomatch = require('picomatch');
  4785. * // picomatch(glob[, options]);
  4786. *
  4787. * const isMatch = picomatch('*.!(*a)');
  4788. * console.log(isMatch('a.a')); //=> false
  4789. * console.log(isMatch('a.b')); //=> true
  4790. * ```
  4791. * @name picomatch
  4792. * @param {String|Array} `globs` One or more glob patterns.
  4793. * @param {Object=} `options`
  4794. * @return {Function=} Returns a matcher function.
  4795. * @api public
  4796. */
  4797. const picomatch = (glob, options, returnState = false) => {
  4798. if (Array.isArray(glob)) {
  4799. const fns = glob.map(input => picomatch(input, options, returnState));
  4800. const arrayMatcher = str => {
  4801. for (const isMatch of fns) {
  4802. const state = isMatch(str);
  4803. if (state) return state;
  4804. }
  4805. return false;
  4806. };
  4807. return arrayMatcher;
  4808. }
  4809. const isState = isObject(glob) && glob.tokens && glob.input;
  4810. if (glob === '' || (typeof glob !== 'string' && !isState)) {
  4811. throw new TypeError('Expected pattern to be a non-empty string');
  4812. }
  4813. const opts = options || {};
  4814. const posix = opts.windows;
  4815. const regex = isState
  4816. ? picomatch.compileRe(glob, options)
  4817. : picomatch.makeRe(glob, options, false, true);
  4818. const state = regex.state;
  4819. delete regex.state;
  4820. let isIgnored = () => false;
  4821. if (opts.ignore) {
  4822. const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
  4823. isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
  4824. }
  4825. const matcher = (input, returnObject = false) => {
  4826. const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
  4827. const result = { glob, state, regex, posix, input, output, match, isMatch };
  4828. if (typeof opts.onResult === 'function') {
  4829. opts.onResult(result);
  4830. }
  4831. if (isMatch === false) {
  4832. result.isMatch = false;
  4833. return returnObject ? result : false;
  4834. }
  4835. if (isIgnored(input)) {
  4836. if (typeof opts.onIgnore === 'function') {
  4837. opts.onIgnore(result);
  4838. }
  4839. result.isMatch = false;
  4840. return returnObject ? result : false;
  4841. }
  4842. if (typeof opts.onMatch === 'function') {
  4843. opts.onMatch(result);
  4844. }
  4845. return returnObject ? result : true;
  4846. };
  4847. if (returnState) {
  4848. matcher.state = state;
  4849. }
  4850. return matcher;
  4851. };
  4852. /**
  4853. * Test `input` with the given `regex`. This is used by the main
  4854. * `picomatch()` function to test the input string.
  4855. *
  4856. * ```js
  4857. * const picomatch = require('picomatch');
  4858. * // picomatch.test(input, regex[, options]);
  4859. *
  4860. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  4861. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  4862. * ```
  4863. * @param {String} `input` String to test.
  4864. * @param {RegExp} `regex`
  4865. * @return {Object} Returns an object with matching info.
  4866. * @api public
  4867. */
  4868. picomatch.test = (input, regex, options, { glob, posix } = {}) => {
  4869. if (typeof input !== 'string') {
  4870. throw new TypeError('Expected input to be a string');
  4871. }
  4872. if (input === '') {
  4873. return { isMatch: false, output: '' };
  4874. }
  4875. const opts = options || {};
  4876. const format = opts.format || (posix ? utils.toPosixSlashes : null);
  4877. let match = input === glob;
  4878. let output = (match && format) ? format(input) : input;
  4879. if (match === false) {
  4880. output = format ? format(input) : input;
  4881. match = output === glob;
  4882. }
  4883. if (match === false || opts.capture === true) {
  4884. if (opts.matchBase === true || opts.basename === true) {
  4885. match = picomatch.matchBase(input, regex, options, posix);
  4886. } else {
  4887. match = regex.exec(output);
  4888. }
  4889. }
  4890. return { isMatch: Boolean(match), match, output };
  4891. };
  4892. /**
  4893. * Match the basename of a filepath.
  4894. *
  4895. * ```js
  4896. * const picomatch = require('picomatch');
  4897. * // picomatch.matchBase(input, glob[, options]);
  4898. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  4899. * ```
  4900. * @param {String} `input` String to test.
  4901. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  4902. * @return {Boolean}
  4903. * @api public
  4904. */
  4905. picomatch.matchBase = (input, glob, options) => {
  4906. const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
  4907. return regex.test(utils.basename(input));
  4908. };
  4909. /**
  4910. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  4911. *
  4912. * ```js
  4913. * const picomatch = require('picomatch');
  4914. * // picomatch.isMatch(string, patterns[, options]);
  4915. *
  4916. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  4917. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  4918. * ```
  4919. * @param {String|Array} str The string to test.
  4920. * @param {String|Array} patterns One or more glob patterns to use for matching.
  4921. * @param {Object} [options] See available [options](#options).
  4922. * @return {Boolean} Returns true if any patterns match `str`
  4923. * @api public
  4924. */
  4925. picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
  4926. /**
  4927. * Parse a glob pattern to create the source string for a regular
  4928. * expression.
  4929. *
  4930. * ```js
  4931. * const picomatch = require('picomatch');
  4932. * const result = picomatch.parse(pattern[, options]);
  4933. * ```
  4934. * @param {String} `pattern`
  4935. * @param {Object} `options`
  4936. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  4937. * @api public
  4938. */
  4939. picomatch.parse = (pattern, options) => {
  4940. if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
  4941. return parse(pattern, { ...options, fastpaths: false });
  4942. };
  4943. /**
  4944. * Scan a glob pattern to separate the pattern into segments.
  4945. *
  4946. * ```js
  4947. * const picomatch = require('picomatch');
  4948. * // picomatch.scan(input[, options]);
  4949. *
  4950. * const result = picomatch.scan('!./foo/*.js');
  4951. * console.log(result);
  4952. * { prefix: '!./',
  4953. * input: '!./foo/*.js',
  4954. * start: 3,
  4955. * base: 'foo',
  4956. * glob: '*.js',
  4957. * isBrace: false,
  4958. * isBracket: false,
  4959. * isGlob: true,
  4960. * isExtglob: false,
  4961. * isGlobstar: false,
  4962. * negated: true }
  4963. * ```
  4964. * @param {String} `input` Glob pattern to scan.
  4965. * @param {Object} `options`
  4966. * @return {Object} Returns an object with
  4967. * @api public
  4968. */
  4969. picomatch.scan = (input, options) => scan(input, options);
  4970. /**
  4971. * Create a regular expression from a parsed glob pattern.
  4972. *
  4973. * ```js
  4974. * const picomatch = require('picomatch');
  4975. * const state = picomatch.parse('*.js');
  4976. * // picomatch.compileRe(state[, options]);
  4977. *
  4978. * console.log(picomatch.compileRe(state));
  4979. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  4980. * ```
  4981. * @param {String} `state` The object returned from the `.parse` method.
  4982. * @param {Object} `options`
  4983. * @return {RegExp} Returns a regex created from the given pattern.
  4984. * @api public
  4985. */
  4986. picomatch.compileRe = (parsed, options, returnOutput = false, returnState = false) => {
  4987. if (returnOutput === true) {
  4988. return parsed.output;
  4989. }
  4990. const opts = options || {};
  4991. const prepend = opts.contains ? '' : '^';
  4992. const append = opts.contains ? '' : '$';
  4993. let source = `${prepend}(?:${parsed.output})${append}`;
  4994. if (parsed && parsed.negated === true) {
  4995. source = `^(?!${source}).*$`;
  4996. }
  4997. const regex = picomatch.toRegex(source, options);
  4998. if (returnState === true) {
  4999. regex.state = parsed;
  5000. }
  5001. return regex;
  5002. };
  5003. picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => {
  5004. if (!input || typeof input !== 'string') {
  5005. throw new TypeError('Expected a non-empty string');
  5006. }
  5007. const opts = options || {};
  5008. let parsed = { negated: false, fastpaths: true };
  5009. let prefix = '';
  5010. let output;
  5011. if (input.startsWith('./')) {
  5012. input = input.slice(2);
  5013. prefix = parsed.prefix = './';
  5014. }
  5015. if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  5016. output = parse.fastpaths(input, options);
  5017. }
  5018. if (output === undefined) {
  5019. parsed = parse(input, options);
  5020. parsed.prefix = prefix + (parsed.prefix || '');
  5021. } else {
  5022. parsed.output = output;
  5023. }
  5024. return picomatch.compileRe(parsed, options, returnOutput, returnState);
  5025. };
  5026. /**
  5027. * Create a regular expression from the given regex source string.
  5028. *
  5029. * ```js
  5030. * const picomatch = require('picomatch');
  5031. * // picomatch.toRegex(source[, options]);
  5032. *
  5033. * const { output } = picomatch.parse('*.js');
  5034. * console.log(picomatch.toRegex(output));
  5035. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  5036. * ```
  5037. * @param {String} `source` Regular expression source string.
  5038. * @param {Object} `options`
  5039. * @return {RegExp}
  5040. * @api public
  5041. */
  5042. picomatch.toRegex = (source, options) => {
  5043. try {
  5044. const opts = options || {};
  5045. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  5046. } catch (err) {
  5047. if (options && options.debug === true) throw err;
  5048. return /$^/;
  5049. }
  5050. };
  5051. /**
  5052. * Picomatch constants.
  5053. * @return {Object}
  5054. */
  5055. picomatch.constants = constants;
  5056. /**
  5057. * Expose "picomatch"
  5058. */
  5059. var picomatch_1 = picomatch;
  5060. (function (module) {
  5061. module.exports = picomatch_1;
  5062. } (picomatchBrowser));
  5063. var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchBrowserExports);
  5064. function isArray(arg) {
  5065. return Array.isArray(arg);
  5066. }
  5067. function ensureArray(thing) {
  5068. if (isArray(thing))
  5069. return thing;
  5070. if (thing == null)
  5071. return [];
  5072. return [thing];
  5073. }
  5074. const globToTest = (glob) => {
  5075. const pattern = glob;
  5076. const fn = pm(pattern, { dot: true });
  5077. return {
  5078. test: (what) => {
  5079. const result = fn(what);
  5080. return result;
  5081. },
  5082. };
  5083. };
  5084. const testTrue = {
  5085. test: () => true,
  5086. };
  5087. const getMatcher = (filter) => {
  5088. const bundleTest = "bundle" in filter && filter.bundle != null ? globToTest(filter.bundle) : testTrue;
  5089. const fileTest = "file" in filter && filter.file != null ? globToTest(filter.file) : testTrue;
  5090. return { bundleTest, fileTest };
  5091. };
  5092. const createFilter = (include, exclude) => {
  5093. const includeMatchers = ensureArray(include).map(getMatcher);
  5094. const excludeMatchers = ensureArray(exclude).map(getMatcher);
  5095. return (bundleId, id) => {
  5096. for (let i = 0; i < excludeMatchers.length; ++i) {
  5097. const { bundleTest, fileTest } = excludeMatchers[i];
  5098. if (bundleTest.test(bundleId) && fileTest.test(id))
  5099. return false;
  5100. }
  5101. for (let i = 0; i < includeMatchers.length; ++i) {
  5102. const { bundleTest, fileTest } = includeMatchers[i];
  5103. if (bundleTest.test(bundleId) && fileTest.test(id))
  5104. return true;
  5105. }
  5106. return !includeMatchers.length;
  5107. };
  5108. };
  5109. const throttleFilter = (callback, limit) => {
  5110. let waiting = false;
  5111. return (val) => {
  5112. if (!waiting) {
  5113. callback(val);
  5114. waiting = true;
  5115. setTimeout(() => {
  5116. waiting = false;
  5117. }, limit);
  5118. }
  5119. };
  5120. };
  5121. const prepareFilter = (filt) => {
  5122. if (filt === "")
  5123. return [];
  5124. return (filt
  5125. .split(",")
  5126. // remove spaces before and after
  5127. .map((entry) => entry.trim())
  5128. // unquote "
  5129. .map((entry) => entry.startsWith('"') && entry.endsWith('"') ? entry.substring(1, entry.length - 1) : entry)
  5130. // unquote '
  5131. .map((entry) => entry.startsWith("'") && entry.endsWith("'") ? entry.substring(1, entry.length - 1) : entry)
  5132. // remove empty strings
  5133. .filter((entry) => entry)
  5134. // parse bundle:file
  5135. .map((entry) => entry.split(":"))
  5136. // normalize entry just in case
  5137. .flatMap((entry) => {
  5138. if (entry.length === 0)
  5139. return [];
  5140. let bundle = null;
  5141. let file = null;
  5142. if (entry.length === 1 && entry[0]) {
  5143. file = entry[0];
  5144. return [{ file, bundle }];
  5145. }
  5146. bundle = entry[0] || null;
  5147. file = entry.slice(1).join(":") || null;
  5148. return [{ bundle, file }];
  5149. }));
  5150. };
  5151. const useFilter = () => {
  5152. const [includeFilter, setIncludeFilter] = p("");
  5153. const [excludeFilter, setExcludeFilter] = p("");
  5154. const setIncludeFilterTrottled = F(() => throttleFilter(setIncludeFilter, 200), []);
  5155. const setExcludeFilterTrottled = F(() => throttleFilter(setExcludeFilter, 200), []);
  5156. const isIncluded = F(() => createFilter(prepareFilter(includeFilter), prepareFilter(excludeFilter)), [includeFilter, excludeFilter]);
  5157. const getModuleFilterMultiplier = T((bundleId, data) => {
  5158. return isIncluded(bundleId, data.id) ? 1 : 0;
  5159. }, [isIncluded]);
  5160. return {
  5161. getModuleFilterMultiplier,
  5162. includeFilter,
  5163. excludeFilter,
  5164. setExcludeFilter: setExcludeFilterTrottled,
  5165. setIncludeFilter: setIncludeFilterTrottled,
  5166. };
  5167. };
  5168. const PLACEHOLDER = "bundle-*:**/file/**,**/file**, bundle-*:";
  5169. const SideBar = ({ availableSizeProperties, sizeProperty, setSizeProperty, onExcludeChange, onIncludeChange, }) => {
  5170. const [includeValue, setIncludeValue] = p("");
  5171. const [excludeValue, setExcludeValue] = p("");
  5172. const handleSizePropertyChange = (sizeProp) => () => {
  5173. if (sizeProp !== sizeProperty) {
  5174. setSizeProperty(sizeProp);
  5175. }
  5176. };
  5177. const handleIncludeChange = (event) => {
  5178. const value = event.currentTarget.value;
  5179. setIncludeValue(value);
  5180. onIncludeChange(value);
  5181. };
  5182. const handleExcludeChange = (event) => {
  5183. const value = event.currentTarget.value;
  5184. setExcludeValue(value);
  5185. onExcludeChange(value);
  5186. };
  5187. return (o$1("aside", Object.assign({ className: "sidebar" }, { children: [o$1("div", Object.assign({ className: "size-selectors" }, { children: availableSizeProperties.length > 1 &&
  5188. availableSizeProperties.map((sizeProp) => {
  5189. const id = `selector-${sizeProp}`;
  5190. return (o$1("div", Object.assign({ className: "size-selector" }, { children: [o$1("input", { type: "radio", id: id, checked: sizeProp === sizeProperty, onChange: handleSizePropertyChange(sizeProp) }), o$1("label", Object.assign({ htmlFor: id }, { children: LABELS[sizeProp] }))] }), sizeProp));
  5191. }) })), o$1("div", Object.assign({ className: "module-filters" }, { children: [o$1("div", Object.assign({ className: "module-filter" }, { children: [o$1("label", Object.assign({ htmlFor: "module-filter-exclude" }, { children: "Exclude" })), o$1("input", { type: "text", id: "module-filter-exclude", value: excludeValue, onInput: handleExcludeChange, placeholder: PLACEHOLDER })] })), o$1("div", Object.assign({ className: "module-filter" }, { children: [o$1("label", Object.assign({ htmlFor: "module-filter-include" }, { children: "Include" })), o$1("input", { type: "text", id: "module-filter-include", value: includeValue, onInput: handleIncludeChange, placeholder: PLACEHOLDER })] }))] }))] })));
  5192. };
  5193. const Tooltip_marginX = 10;
  5194. const Tooltip_marginY = 30;
  5195. const Tooltip = ({ node, visible }) => {
  5196. const { data } = q(StaticContext);
  5197. const ref = _(null);
  5198. const [style, setStyle] = p({});
  5199. const content = F(() => {
  5200. if (!node)
  5201. return null;
  5202. return (o$1(p$1, { children: [o$1("div", { children: node.id }), node.uid && (o$1("div", { children: [o$1("div", { children: [o$1("b", { children: "Imported By" }), ":"] }), data.nodeMetas[node.uid].importedBy.map(({ uid }) => {
  5203. const { id } = data.nodeMetas[uid];
  5204. return o$1("div", { children: id }, id);
  5205. })] }))] }));
  5206. }, [data, node]);
  5207. const updatePosition = (mouseCoords) => {
  5208. if (!ref.current)
  5209. return;
  5210. const pos = {
  5211. left: mouseCoords.x + Tooltip_marginX,
  5212. top: mouseCoords.y + Tooltip_marginY,
  5213. };
  5214. const boundingRect = ref.current.getBoundingClientRect();
  5215. if (pos.left + boundingRect.width > window.innerWidth) {
  5216. // Shifting horizontally
  5217. pos.left = window.innerWidth - boundingRect.width;
  5218. }
  5219. if (pos.top + boundingRect.height > window.innerHeight) {
  5220. // Flipping vertically
  5221. pos.top = mouseCoords.y - Tooltip_marginY - boundingRect.height;
  5222. }
  5223. setStyle(pos);
  5224. };
  5225. h(() => {
  5226. const handleMouseMove = (event) => {
  5227. updatePosition({
  5228. x: event.pageX,
  5229. y: event.pageY,
  5230. });
  5231. };
  5232. document.addEventListener("mousemove", handleMouseMove, true);
  5233. return () => {
  5234. document.removeEventListener("mousemove", handleMouseMove, true);
  5235. };
  5236. }, []);
  5237. return (o$1("div", Object.assign({ className: `tooltip ${visible ? "" : "tooltip-hidden"}`, ref: ref, style: style }, { children: content })));
  5238. };
  5239. class Transform {
  5240. constructor(k, x, y) {
  5241. this.k = k;
  5242. this.x = x;
  5243. this.y = y;
  5244. }
  5245. scaled(k) {
  5246. return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
  5247. }
  5248. translated(x, y) {
  5249. return x === 0 && y === 0
  5250. ? this
  5251. : new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
  5252. }
  5253. invertPoint(location) {
  5254. return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
  5255. }
  5256. toString() {
  5257. return "translate(" + String(this.x) + "," + String(this.y) + ") scale(" + String(this.k) + ")";
  5258. }
  5259. }
  5260. const identityTransform = new Transform(1, 0, 0);
  5261. const noEvent = (event) => {
  5262. event.preventDefault();
  5263. event.stopImmediatePropagation();
  5264. };
  5265. const translate = (transform, p0, p1) => {
  5266. const x = p0[0] - p1[0] * transform.k, y = p0[1] - p1[1] * transform.k;
  5267. return x === transform.x && y === transform.y ? transform : new Transform(transform.k, x, y);
  5268. };
  5269. const Network = ({ links, nodes, onNodeHover, onNodeDblClick, getColor, onCanvasClick, onNodeClick, }) => {
  5270. const { width, height } = q(StaticContext);
  5271. const [transform, setTransform] = p(identityTransform);
  5272. const startPosRef = _();
  5273. const [dragging, setDragging] = p(false);
  5274. const handleMouseDown = (event) => {
  5275. if (event.ctrlKey || event.button) {
  5276. // context menu
  5277. return;
  5278. }
  5279. noEvent(event);
  5280. startPosRef.current = transform.invertPoint([event.clientX, event.clientY]);
  5281. setDragging(true);
  5282. };
  5283. const handleMouseMove = (event) => {
  5284. noEvent(event);
  5285. if (!startPosRef.current || !dragging)
  5286. return;
  5287. setTransform(translate(transform, [event.clientX, event.clientY], startPosRef.current));
  5288. };
  5289. const handleMouseUp = (event) => {
  5290. noEvent(event);
  5291. if (!dragging)
  5292. return;
  5293. setDragging(false);
  5294. };
  5295. return (o$1("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: `${-width / 2} ${-height / 2} ${width} ${height}`, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onClick: onCanvasClick }, { children: o$1("g", Object.assign({ transform: transform.toString() }, { children: [o$1("g", Object.assign({ stroke: "#fff", "stroke-opacity": "0.9" }, { children: links.map((link) => {
  5296. return (o$1("line", { "stroke-width": "1", x1: link.source.x, y1: link.source.y, x2: link.target.x, y2: link.target.y }, `${link.source.uid} - ${link.target.uid}`));
  5297. }) })), o$1("g", Object.assign({ stroke: "#fff", "stroke-width": "1.5" }, { children: nodes.map((node) => {
  5298. return (o$1("circle", { r: node.radius, fill: getColor(node), cx: node.x, cy: node.y, onMouseOver: (evt) => {
  5299. noEvent(evt);
  5300. onNodeHover(node);
  5301. }, onClick: (evt) => {
  5302. noEvent(evt);
  5303. onNodeClick(node);
  5304. }, onDblClick: (evt) => {
  5305. noEvent(evt);
  5306. onNodeDblClick(node);
  5307. } }, node.uid));
  5308. }) }))] })) })));
  5309. };
  5310. const Chart = ({ links, nodes, onNodeExclude, getColor, onNodeSelect, }) => {
  5311. const [showTooltip, setShowTooltip] = p(false);
  5312. const [tooltipNode, setTooltipNode] = p(undefined);
  5313. h(() => {
  5314. const handleMouseOut = () => {
  5315. setShowTooltip(false);
  5316. };
  5317. document.addEventListener("mouseover", handleMouseOut);
  5318. return () => {
  5319. document.removeEventListener("mouseover", handleMouseOut);
  5320. };
  5321. }, []);
  5322. return (o$1(p$1, { children: [o$1(Network, { links: links, nodes: nodes, onNodeHover: (node) => {
  5323. setTooltipNode(node);
  5324. setShowTooltip(true);
  5325. }, onNodeDblClick: onNodeExclude, onNodeClick: (node) => onNodeSelect(node.uid), onCanvasClick: () => {
  5326. onNodeSelect(undefined);
  5327. }, getColor: getColor }), o$1(Tooltip, { visible: showTooltip, node: tooltipNode })] }));
  5328. };
  5329. const createRainbowColor = (groups) => {
  5330. const groupColor = new Map();
  5331. const groupNames = Object.keys(groups);
  5332. const colorScale = sequential([0, groupNames.length], (n) => hsl(360 * n, 0.3, 0.5));
  5333. groupNames.forEach((c, id) => {
  5334. groupColor.set(c, colorScale(id).toString());
  5335. });
  5336. const getBackgroundColor = (node) => {
  5337. const colorStr = groupColor.get(node.group);
  5338. const hslColor = hsl(colorStr);
  5339. hslColor.l = node.renderedLength === 0 ? 0.9 : hslColor.l;
  5340. return hslColor;
  5341. };
  5342. return (node) => {
  5343. const backgroundColor = getBackgroundColor(node);
  5344. return backgroundColor.toString();
  5345. };
  5346. };
  5347. const Main = () => {
  5348. const { nodes, data, width, height, nodeGroups, groupLayers, groups } = q(StaticContext);
  5349. const sizeScale = F(() => {
  5350. const maxLines = max(nodes, (d) => d.renderedLength);
  5351. const size = sqrt().domain([1, maxLines]).range([5, 30]);
  5352. return size;
  5353. }, [nodes]);
  5354. const getModuleColor = F(() => {
  5355. return createRainbowColor(groups);
  5356. }, [groups]);
  5357. const [excludedNodes, setExcludedNodes] = p([]);
  5358. const [selectedNode, setSelectedNode] = p();
  5359. const { getModuleFilterMultiplier, setExcludeFilter, setIncludeFilter } = useFilter();
  5360. const getColor = (node) => {
  5361. if (selectedNode != null) {
  5362. if (node.uid === selectedNode ||
  5363. data.nodeMetas[selectedNode].importedBy.some(({ uid }) => node.uid === uid)) {
  5364. return getModuleColor(node);
  5365. }
  5366. return COLOR_BASE;
  5367. }
  5368. else {
  5369. return getModuleColor(node);
  5370. }
  5371. };
  5372. const processedNodes = F(() => {
  5373. var _a;
  5374. const newNodes = [];
  5375. for (const node of nodes) {
  5376. //if (node.renderedLength === 0) continue;
  5377. if (excludedNodes.includes(node.uid))
  5378. continue;
  5379. const bundleId = (_a = Object.entries(node.moduleParts).find(([bundleId, uid]) => uid == node.uid)) === null || _a === void 0 ? void 0 : _a[0];
  5380. const filterMultiplier = getModuleFilterMultiplier(bundleId, node);
  5381. if (filterMultiplier === 0)
  5382. continue;
  5383. const nodeGroup = nodeGroups[node.uid];
  5384. const layerIndex = groupLayers.findIndex((layer) => layer.includes(nodeGroup));
  5385. const groupId = groupLayers[layerIndex].indexOf(nodeGroup);
  5386. const groupsTotal = groupLayers[layerIndex].length;
  5387. newNodes.push(Object.assign(Object.assign({}, node), { x: layerIndex * Math.cos((groupId / groupsTotal) * 2 * Math.PI) * 200, y: layerIndex * Math.sin((groupId / groupsTotal) * 2 * Math.PI) * 200, radius: sizeScale(node.renderedLength) }));
  5388. }
  5389. return newNodes;
  5390. }, [excludedNodes, getModuleFilterMultiplier, groupLayers, nodeGroups, nodes, sizeScale]);
  5391. const links = F(() => {
  5392. const nodesCache = Object.fromEntries(processedNodes.map((d) => [d.uid, d]));
  5393. return Object.entries(data.nodeMetas)
  5394. .flatMap(([sourceUid, { imported }]) => {
  5395. return imported.map(({ uid: targetUid }) => {
  5396. return {
  5397. source: nodesCache[sourceUid],
  5398. target: nodesCache[targetUid],
  5399. value: 1,
  5400. };
  5401. });
  5402. })
  5403. .filter(({ source, target }) => {
  5404. return source && target;
  5405. });
  5406. }, [data.nodeMetas, processedNodes]);
  5407. const [animatedNodes, setAnimatedNodes] = p([]);
  5408. h(() => {
  5409. const simulation = forceSimulation()
  5410. .force("collision", forceCollide().radius((node) => node.radius))
  5411. .force("charge", forceManyBody().strength(-30))
  5412. .force("link", forceLink(links)
  5413. .strength((link) => {
  5414. if (nodeGroups[link.source.uid] === nodeGroups[link.target.uid]) {
  5415. return 1;
  5416. }
  5417. else {
  5418. return 0.1;
  5419. }
  5420. })
  5421. .iterations(2))
  5422. .force("x", forceX(0))
  5423. .force("y", forceY(0));
  5424. simulation.on("tick", () => {
  5425. setAnimatedNodes([...simulation.nodes()]);
  5426. });
  5427. simulation.nodes([...processedNodes]);
  5428. // simulation.tick(1).stop();
  5429. simulation.alphaMin(0.03).restart();
  5430. return () => simulation.stop();
  5431. }, [nodeGroups, height, links, processedNodes, width]);
  5432. return (o$1(p$1, { children: [o$1(SideBar, { sizeProperty: "renderedLength", availableSizeProperties: ["renderedLength"], setSizeProperty: () => { }, onExcludeChange: setExcludeFilter, onIncludeChange: setIncludeFilter }), o$1(Chart, { nodes: animatedNodes, onNodeExclude: (node) => setExcludedNodes([...excludedNodes, node.uid]), links: links, getColor: getColor, onNodeSelect: (uid) => setSelectedNode(uid === selectedNode ? undefined : uid) })] }));
  5433. };
  5434. const NODE_MODULES = /.*(?:\/|\\\\)?node_modules(?:\/|\\\\)([^/\\]+)(?:\/|\\\\).+/;
  5435. const StaticContext = B$2({});
  5436. const createNodeInfo = (data, availableSizeProperties, uid) => {
  5437. var _a, _b;
  5438. const meta = data.nodeMetas[uid];
  5439. const entries = Object.values(meta.moduleParts).map((partUid) => data.nodeParts[partUid]);
  5440. const sizes = Object.fromEntries(availableSizeProperties.map((key) => [key, 0]));
  5441. for (const renderInfo of entries) {
  5442. for (const sizeKey of availableSizeProperties) {
  5443. sizes[sizeKey] += (_a = renderInfo[sizeKey]) !== null && _a !== void 0 ? _a : 0;
  5444. }
  5445. }
  5446. const match = NODE_MODULES.exec(meta.id);
  5447. return Object.assign(Object.assign(Object.assign({ uid }, sizes), meta), { group: (_b = match === null || match === void 0 ? void 0 : match[1]) !== null && _b !== void 0 ? _b : "" });
  5448. };
  5449. const drawChart = (parentNode, data, width, height) => {
  5450. var _a, _b;
  5451. const availableSizeProperties = getAvailableSizeOptions(data.options);
  5452. const nodeGroups = {};
  5453. const groups = { "": 0 };
  5454. let groupId = 1;
  5455. const nodes = [];
  5456. for (const uid of Object.keys(data.nodeMetas)) {
  5457. const node = createNodeInfo(data, availableSizeProperties, uid);
  5458. nodes.push(node);
  5459. nodeGroups[uid] = node.group;
  5460. groups[node.group] = (_a = groups[node.group]) !== null && _a !== void 0 ? _a : groupId++;
  5461. }
  5462. const groupLinks = { "": new Set() };
  5463. for (const [sourceUid, { imported }] of Object.entries(data.nodeMetas)) {
  5464. for (const { uid: targetUid } of imported) {
  5465. const sourceGroup = nodeGroups[sourceUid];
  5466. const targetGroup = nodeGroups[targetUid];
  5467. if (!(sourceGroup in groupLinks)) {
  5468. groupLinks[sourceGroup] = new Set();
  5469. }
  5470. groupLinks[sourceGroup].add(targetGroup);
  5471. }
  5472. }
  5473. const groupLayers = [[""]];
  5474. const seen = new Set([""]);
  5475. // eslint-disable-next-line no-constant-condition
  5476. while (true) {
  5477. const lastLayer = groupLayers[groupLayers.length - 1];
  5478. const newLayer = new Set();
  5479. for (const currentGroup of lastLayer) {
  5480. for (const targetGroup of (_b = groupLinks[currentGroup]) !== null && _b !== void 0 ? _b : []) {
  5481. if (seen.has(targetGroup)) {
  5482. continue;
  5483. }
  5484. seen.add(targetGroup);
  5485. newLayer.add(targetGroup);
  5486. }
  5487. }
  5488. if (newLayer.size === 0) {
  5489. break;
  5490. }
  5491. groupLayers.push([...newLayer]);
  5492. }
  5493. P(o$1(StaticContext.Provider, Object.assign({ value: {
  5494. data,
  5495. width,
  5496. height,
  5497. nodes,
  5498. nodeGroups,
  5499. groups,
  5500. groupLayers,
  5501. } }, { children: o$1(Main, {}) })), parentNode);
  5502. };
  5503. exports.StaticContext = StaticContext;
  5504. exports.default = drawChart;
  5505. Object.defineProperty(exports, '__esModule', { value: true });
  5506. return exports;
  5507. })({});