sunburst.js 203 KB

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