treemap.js 185 KB

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