779.index.js 171 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187
  1. exports.id = 779;
  2. exports.ids = [779];
  3. exports.modules = {
  4. /***/ 18971:
  5. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", ({ value: true }));
  8. exports.execute = void 0;
  9. const child_process_1 = __webpack_require__(63129);
  10. // Executes a subprocess.
  11. // Resolves successfully on exit code 0 with all the info
  12. // available
  13. async function execute(command, args, options) {
  14. const spawnOptions = {
  15. shell: true,
  16. detached: true,
  17. };
  18. if (options && options.cwd) {
  19. spawnOptions.cwd = options.cwd;
  20. }
  21. const fullCommand = `${command} ${args.join(' ')}`;
  22. const startTime = Date.now();
  23. let processId;
  24. try {
  25. const worker = child_process_1.spawn(command, args, options);
  26. processId = worker.pid;
  27. return await new Promise((resolve, reject) => {
  28. let stderr = '';
  29. let stdout = '';
  30. worker.stdout.on('data', (data) => {
  31. stdout += data;
  32. });
  33. worker.stderr.on('data', (data) => {
  34. stderr += data;
  35. });
  36. worker.on('error', (e) => {
  37. reject({
  38. stderr,
  39. stdout,
  40. error: e,
  41. duration: Date.now() - startTime,
  42. command: fullCommand,
  43. });
  44. });
  45. worker.on('exit', (code) => {
  46. if (code && code > 0) {
  47. resolve({
  48. stderr,
  49. stdout,
  50. duration: Date.now() - startTime,
  51. command: fullCommand,
  52. exitCode: code,
  53. });
  54. }
  55. else {
  56. resolve({
  57. stderr,
  58. stdout,
  59. duration: Date.now() - startTime,
  60. command: fullCommand,
  61. exitCode: code,
  62. });
  63. }
  64. });
  65. });
  66. }
  67. finally {
  68. if (processId) {
  69. // Additional anti-zombie protection.
  70. // Process here should be already stopped.
  71. try {
  72. process.kill(processId, 'SIGKILL');
  73. }
  74. catch (e) {
  75. // Process already stopped.
  76. }
  77. }
  78. }
  79. }
  80. exports.execute = execute;
  81. //# sourceMappingURL=child-process.js.map
  82. /***/ }),
  83. /***/ 68026:
  84. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  85. "use strict";
  86. Object.defineProperty(exports, "__esModule", ({ value: true }));
  87. var child_process_1 = __webpack_require__(18971);
  88. Object.defineProperty(exports, "execute", ({ enumerable: true, get: function () { return child_process_1.execute; } }));
  89. //# sourceMappingURL=index.js.map
  90. /***/ }),
  91. /***/ 21591:
  92. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  93. "use strict";
  94. Object.defineProperty(exports, "__esModule", ({ value: true }));
  95. exports.isPipenvInstalled = exports.extractPipenvVersion = void 0;
  96. const debugLib = __webpack_require__(92259);
  97. const child_process_1 = __webpack_require__(68026);
  98. const debug = debugLib('snyk-fix:python:Pipfile');
  99. function extractPipenvVersion(stdout) {
  100. /* stdout example:
  101. * pipenv, version 2018.11.26\n
  102. */
  103. let version = null;
  104. const re = new RegExp(/^pipenv,\sversion\s([0-9.]+)/, 'g');
  105. const match = re.exec(stdout);
  106. if (match) {
  107. version = match[1];
  108. }
  109. return version;
  110. }
  111. exports.extractPipenvVersion = extractPipenvVersion;
  112. async function isPipenvInstalled() {
  113. let res;
  114. try {
  115. res = await child_process_1.execute('pipenv', ['--version'], {});
  116. }
  117. catch (e) {
  118. debug('Execute failed with', e);
  119. res = e;
  120. }
  121. if (res.exitCode !== 0) {
  122. throw res.error;
  123. }
  124. return { version: extractPipenvVersion(res.stdout) };
  125. }
  126. exports.isPipenvInstalled = isPipenvInstalled;
  127. //# sourceMappingURL=check-pip-env-installed.js.map
  128. /***/ }),
  129. /***/ 91989:
  130. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  131. "use strict";
  132. Object.defineProperty(exports, "__esModule", ({ value: true }));
  133. var check_pip_env_installed_1 = __webpack_require__(21591);
  134. Object.defineProperty(exports, "isPipenvInstalled", ({ enumerable: true, get: function () { return check_pip_env_installed_1.isPipenvInstalled; } }));
  135. var is_pipenv_supported_version_1 = __webpack_require__(97149);
  136. Object.defineProperty(exports, "isPipenvSupportedVersion", ({ enumerable: true, get: function () { return is_pipenv_supported_version_1.isPipenvSupportedVersion; } }));
  137. var pipenv_install_1 = __webpack_require__(96194);
  138. Object.defineProperty(exports, "pipenvInstall", ({ enumerable: true, get: function () { return pipenv_install_1.pipenvInstall; } }));
  139. //# sourceMappingURL=index.js.map
  140. /***/ }),
  141. /***/ 97149:
  142. /***/ ((__unused_webpack_module, exports) => {
  143. "use strict";
  144. Object.defineProperty(exports, "__esModule", ({ value: true }));
  145. exports.isPipenvSupportedVersion = void 0;
  146. function isPipenvSupportedVersion(version) {
  147. // See all versions: https://pipenv.pypa.io/en/latest/changelog/
  148. // Update SUPPORTED.md when this is updated
  149. const SUPPORTED_PIPENV_VERSIONS = [
  150. '2020.11.4',
  151. '2020.8.13',
  152. '2020.6.2',
  153. '2020.5.28',
  154. '2018.11.26',
  155. '2018.11.14',
  156. '2018.10.13',
  157. '2018.10.9',
  158. '2018.7.1',
  159. '2018.6.25',
  160. ];
  161. let supported = false;
  162. if (SUPPORTED_PIPENV_VERSIONS.includes(version)) {
  163. supported = true;
  164. }
  165. return {
  166. supported,
  167. versions: SUPPORTED_PIPENV_VERSIONS,
  168. };
  169. }
  170. exports.isPipenvSupportedVersion = isPipenvSupportedVersion;
  171. //# sourceMappingURL=is-pipenv-supported-version.js.map
  172. /***/ }),
  173. /***/ 96194:
  174. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  175. "use strict";
  176. Object.defineProperty(exports, "__esModule", ({ value: true }));
  177. exports.pipenvInstall = void 0;
  178. const debugLib = __webpack_require__(92259);
  179. const bottleneck_1 = __webpack_require__(35861);
  180. const child_process_1 = __webpack_require__(68026);
  181. const debug = debugLib('snyk-fix:python:Pipfile');
  182. const limiter = new bottleneck_1.default({
  183. maxConcurrent: 4,
  184. });
  185. // https://pipenv.pypa.io/en/latest/advanced/#changing-default-python-versions
  186. function getPythonArgs(config) {
  187. const args = [];
  188. if (config.python) {
  189. args.push('--python', config.python); // Performs the installation in a virtualenv using the provided Python interpreter.
  190. }
  191. if (process.env.PIPENV_SKIP_LOCK) {
  192. args.push('--skip-lock');
  193. }
  194. return args;
  195. }
  196. async function runPipenvInstall(projectPath, requirements, config) {
  197. const args = ['install', ...requirements];
  198. const pythonArg = getPythonArgs(config);
  199. if (pythonArg) {
  200. args.push(...pythonArg);
  201. }
  202. let res;
  203. try {
  204. res = await child_process_1.execute('pipenv', args, {
  205. cwd: projectPath,
  206. });
  207. }
  208. catch (e) {
  209. debug('Execute failed with', e);
  210. res = e;
  211. }
  212. return res;
  213. }
  214. exports.pipenvInstall = limiter.wrap(runPipenvInstall);
  215. //# sourceMappingURL=pipenv-install.js.map
  216. /***/ }),
  217. /***/ 35535:
  218. /***/ ((module, exports, __webpack_require__) => {
  219. /* eslint-env browser */
  220. /**
  221. * This is the web browser implementation of `debug()`.
  222. */
  223. exports.formatArgs = formatArgs;
  224. exports.save = save;
  225. exports.load = load;
  226. exports.useColors = useColors;
  227. exports.storage = localstorage();
  228. exports.destroy = (() => {
  229. let warned = false;
  230. return () => {
  231. if (!warned) {
  232. warned = true;
  233. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  234. }
  235. };
  236. })();
  237. /**
  238. * Colors.
  239. */
  240. exports.colors = [
  241. '#0000CC',
  242. '#0000FF',
  243. '#0033CC',
  244. '#0033FF',
  245. '#0066CC',
  246. '#0066FF',
  247. '#0099CC',
  248. '#0099FF',
  249. '#00CC00',
  250. '#00CC33',
  251. '#00CC66',
  252. '#00CC99',
  253. '#00CCCC',
  254. '#00CCFF',
  255. '#3300CC',
  256. '#3300FF',
  257. '#3333CC',
  258. '#3333FF',
  259. '#3366CC',
  260. '#3366FF',
  261. '#3399CC',
  262. '#3399FF',
  263. '#33CC00',
  264. '#33CC33',
  265. '#33CC66',
  266. '#33CC99',
  267. '#33CCCC',
  268. '#33CCFF',
  269. '#6600CC',
  270. '#6600FF',
  271. '#6633CC',
  272. '#6633FF',
  273. '#66CC00',
  274. '#66CC33',
  275. '#9900CC',
  276. '#9900FF',
  277. '#9933CC',
  278. '#9933FF',
  279. '#99CC00',
  280. '#99CC33',
  281. '#CC0000',
  282. '#CC0033',
  283. '#CC0066',
  284. '#CC0099',
  285. '#CC00CC',
  286. '#CC00FF',
  287. '#CC3300',
  288. '#CC3333',
  289. '#CC3366',
  290. '#CC3399',
  291. '#CC33CC',
  292. '#CC33FF',
  293. '#CC6600',
  294. '#CC6633',
  295. '#CC9900',
  296. '#CC9933',
  297. '#CCCC00',
  298. '#CCCC33',
  299. '#FF0000',
  300. '#FF0033',
  301. '#FF0066',
  302. '#FF0099',
  303. '#FF00CC',
  304. '#FF00FF',
  305. '#FF3300',
  306. '#FF3333',
  307. '#FF3366',
  308. '#FF3399',
  309. '#FF33CC',
  310. '#FF33FF',
  311. '#FF6600',
  312. '#FF6633',
  313. '#FF9900',
  314. '#FF9933',
  315. '#FFCC00',
  316. '#FFCC33'
  317. ];
  318. /**
  319. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  320. * and the Firebug extension (any Firefox version) are known
  321. * to support "%c" CSS customizations.
  322. *
  323. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  324. */
  325. // eslint-disable-next-line complexity
  326. function useColors() {
  327. // NB: In an Electron preload script, document will be defined but not fully
  328. // initialized. Since we know we're in Chrome, we'll just detect this case
  329. // explicitly
  330. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  331. return true;
  332. }
  333. // Internet Explorer and Edge do not support colors.
  334. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  335. return false;
  336. }
  337. // Is webkit? http://stackoverflow.com/a/16459606/376773
  338. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  339. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  340. // Is firebug? http://stackoverflow.com/a/398120/376773
  341. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  342. // Is firefox >= v31?
  343. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  344. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  345. // Double check webkit in userAgent just in case we are in a worker
  346. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  347. }
  348. /**
  349. * Colorize log arguments if enabled.
  350. *
  351. * @api public
  352. */
  353. function formatArgs(args) {
  354. args[0] = (this.useColors ? '%c' : '') +
  355. this.namespace +
  356. (this.useColors ? ' %c' : ' ') +
  357. args[0] +
  358. (this.useColors ? '%c ' : ' ') +
  359. '+' + module.exports.humanize(this.diff);
  360. if (!this.useColors) {
  361. return;
  362. }
  363. const c = 'color: ' + this.color;
  364. args.splice(1, 0, c, 'color: inherit');
  365. // The final "%c" is somewhat tricky, because there could be other
  366. // arguments passed either before or after the %c, so we need to
  367. // figure out the correct index to insert the CSS into
  368. let index = 0;
  369. let lastC = 0;
  370. args[0].replace(/%[a-zA-Z%]/g, match => {
  371. if (match === '%%') {
  372. return;
  373. }
  374. index++;
  375. if (match === '%c') {
  376. // We only are interested in the *last* %c
  377. // (the user may have provided their own)
  378. lastC = index;
  379. }
  380. });
  381. args.splice(lastC, 0, c);
  382. }
  383. /**
  384. * Invokes `console.debug()` when available.
  385. * No-op when `console.debug` is not a "function".
  386. * If `console.debug` is not available, falls back
  387. * to `console.log`.
  388. *
  389. * @api public
  390. */
  391. exports.log = console.debug || console.log || (() => {});
  392. /**
  393. * Save `namespaces`.
  394. *
  395. * @param {String} namespaces
  396. * @api private
  397. */
  398. function save(namespaces) {
  399. try {
  400. if (namespaces) {
  401. exports.storage.setItem('debug', namespaces);
  402. } else {
  403. exports.storage.removeItem('debug');
  404. }
  405. } catch (error) {
  406. // Swallow
  407. // XXX (@Qix-) should we be logging these?
  408. }
  409. }
  410. /**
  411. * Load `namespaces`.
  412. *
  413. * @return {String} returns the previously persisted debug modes
  414. * @api private
  415. */
  416. function load() {
  417. let r;
  418. try {
  419. r = exports.storage.getItem('debug');
  420. } catch (error) {
  421. // Swallow
  422. // XXX (@Qix-) should we be logging these?
  423. }
  424. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  425. if (!r && typeof process !== 'undefined' && 'env' in process) {
  426. r = process.env.DEBUG;
  427. }
  428. return r;
  429. }
  430. /**
  431. * Localstorage attempts to return the localstorage.
  432. *
  433. * This is necessary because safari throws
  434. * when a user disables cookies/localstorage
  435. * and you attempt to access it.
  436. *
  437. * @return {LocalStorage}
  438. * @api private
  439. */
  440. function localstorage() {
  441. try {
  442. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  443. // The Browser also has localStorage in the global context.
  444. return localStorage;
  445. } catch (error) {
  446. // Swallow
  447. // XXX (@Qix-) should we be logging these?
  448. }
  449. }
  450. module.exports = __webpack_require__(97977)(exports);
  451. const {formatters} = module.exports;
  452. /**
  453. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  454. */
  455. formatters.j = function (v) {
  456. try {
  457. return JSON.stringify(v);
  458. } catch (error) {
  459. return '[UnexpectedJSONParseError]: ' + error.message;
  460. }
  461. };
  462. /***/ }),
  463. /***/ 97977:
  464. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  465. /**
  466. * This is the common logic for both the Node.js and web browser
  467. * implementations of `debug()`.
  468. */
  469. function setup(env) {
  470. createDebug.debug = createDebug;
  471. createDebug.default = createDebug;
  472. createDebug.coerce = coerce;
  473. createDebug.disable = disable;
  474. createDebug.enable = enable;
  475. createDebug.enabled = enabled;
  476. createDebug.humanize = __webpack_require__(57824);
  477. createDebug.destroy = destroy;
  478. Object.keys(env).forEach(key => {
  479. createDebug[key] = env[key];
  480. });
  481. /**
  482. * The currently active debug mode names, and names to skip.
  483. */
  484. createDebug.names = [];
  485. createDebug.skips = [];
  486. /**
  487. * Map of special "%n" handling functions, for the debug "format" argument.
  488. *
  489. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  490. */
  491. createDebug.formatters = {};
  492. /**
  493. * Selects a color for a debug namespace
  494. * @param {String} namespace The namespace string for the for the debug instance to be colored
  495. * @return {Number|String} An ANSI color code for the given namespace
  496. * @api private
  497. */
  498. function selectColor(namespace) {
  499. let hash = 0;
  500. for (let i = 0; i < namespace.length; i++) {
  501. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  502. hash |= 0; // Convert to 32bit integer
  503. }
  504. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  505. }
  506. createDebug.selectColor = selectColor;
  507. /**
  508. * Create a debugger with the given `namespace`.
  509. *
  510. * @param {String} namespace
  511. * @return {Function}
  512. * @api public
  513. */
  514. function createDebug(namespace) {
  515. let prevTime;
  516. let enableOverride = null;
  517. function debug(...args) {
  518. // Disabled?
  519. if (!debug.enabled) {
  520. return;
  521. }
  522. const self = debug;
  523. // Set `diff` timestamp
  524. const curr = Number(new Date());
  525. const ms = curr - (prevTime || curr);
  526. self.diff = ms;
  527. self.prev = prevTime;
  528. self.curr = curr;
  529. prevTime = curr;
  530. args[0] = createDebug.coerce(args[0]);
  531. if (typeof args[0] !== 'string') {
  532. // Anything else let's inspect with %O
  533. args.unshift('%O');
  534. }
  535. // Apply any `formatters` transformations
  536. let index = 0;
  537. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  538. // If we encounter an escaped % then don't increase the array index
  539. if (match === '%%') {
  540. return '%';
  541. }
  542. index++;
  543. const formatter = createDebug.formatters[format];
  544. if (typeof formatter === 'function') {
  545. const val = args[index];
  546. match = formatter.call(self, val);
  547. // Now we need to remove `args[index]` since it's inlined in the `format`
  548. args.splice(index, 1);
  549. index--;
  550. }
  551. return match;
  552. });
  553. // Apply env-specific formatting (colors, etc.)
  554. createDebug.formatArgs.call(self, args);
  555. const logFn = self.log || createDebug.log;
  556. logFn.apply(self, args);
  557. }
  558. debug.namespace = namespace;
  559. debug.useColors = createDebug.useColors();
  560. debug.color = createDebug.selectColor(namespace);
  561. debug.extend = extend;
  562. debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
  563. Object.defineProperty(debug, 'enabled', {
  564. enumerable: true,
  565. configurable: false,
  566. get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
  567. set: v => {
  568. enableOverride = v;
  569. }
  570. });
  571. // Env-specific initialization logic for debug instances
  572. if (typeof createDebug.init === 'function') {
  573. createDebug.init(debug);
  574. }
  575. return debug;
  576. }
  577. function extend(namespace, delimiter) {
  578. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  579. newDebug.log = this.log;
  580. return newDebug;
  581. }
  582. /**
  583. * Enables a debug mode by namespaces. This can include modes
  584. * separated by a colon and wildcards.
  585. *
  586. * @param {String} namespaces
  587. * @api public
  588. */
  589. function enable(namespaces) {
  590. createDebug.save(namespaces);
  591. createDebug.names = [];
  592. createDebug.skips = [];
  593. let i;
  594. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  595. const len = split.length;
  596. for (i = 0; i < len; i++) {
  597. if (!split[i]) {
  598. // ignore empty strings
  599. continue;
  600. }
  601. namespaces = split[i].replace(/\*/g, '.*?');
  602. if (namespaces[0] === '-') {
  603. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  604. } else {
  605. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  606. }
  607. }
  608. }
  609. /**
  610. * Disable debug output.
  611. *
  612. * @return {String} namespaces
  613. * @api public
  614. */
  615. function disable() {
  616. const namespaces = [
  617. ...createDebug.names.map(toNamespace),
  618. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  619. ].join(',');
  620. createDebug.enable('');
  621. return namespaces;
  622. }
  623. /**
  624. * Returns true if the given mode name is enabled, false otherwise.
  625. *
  626. * @param {String} name
  627. * @return {Boolean}
  628. * @api public
  629. */
  630. function enabled(name) {
  631. if (name[name.length - 1] === '*') {
  632. return true;
  633. }
  634. let i;
  635. let len;
  636. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  637. if (createDebug.skips[i].test(name)) {
  638. return false;
  639. }
  640. }
  641. for (i = 0, len = createDebug.names.length; i < len; i++) {
  642. if (createDebug.names[i].test(name)) {
  643. return true;
  644. }
  645. }
  646. return false;
  647. }
  648. /**
  649. * Convert regexp to namespace
  650. *
  651. * @param {RegExp} regxep
  652. * @return {String} namespace
  653. * @api private
  654. */
  655. function toNamespace(regexp) {
  656. return regexp.toString()
  657. .substring(2, regexp.toString().length - 2)
  658. .replace(/\.\*\?$/, '*');
  659. }
  660. /**
  661. * Coerce `val`.
  662. *
  663. * @param {Mixed} val
  664. * @return {Mixed}
  665. * @api private
  666. */
  667. function coerce(val) {
  668. if (val instanceof Error) {
  669. return val.stack || val.message;
  670. }
  671. return val;
  672. }
  673. /**
  674. * XXX DO NOT USE. This is a temporary stub function.
  675. * XXX It WILL be removed in the next major release.
  676. */
  677. function destroy() {
  678. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  679. }
  680. createDebug.enable(createDebug.load());
  681. return createDebug;
  682. }
  683. module.exports = setup;
  684. /***/ }),
  685. /***/ 92259:
  686. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  687. /**
  688. * Detect Electron renderer / nwjs process, which is node, but we should
  689. * treat as a browser.
  690. */
  691. if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
  692. module.exports = __webpack_require__(35535);
  693. } else {
  694. module.exports = __webpack_require__(66862);
  695. }
  696. /***/ }),
  697. /***/ 66862:
  698. /***/ ((module, exports, __webpack_require__) => {
  699. /**
  700. * Module dependencies.
  701. */
  702. const tty = __webpack_require__(33867);
  703. const util = __webpack_require__(31669);
  704. /**
  705. * This is the Node.js implementation of `debug()`.
  706. */
  707. exports.init = init;
  708. exports.log = log;
  709. exports.formatArgs = formatArgs;
  710. exports.save = save;
  711. exports.load = load;
  712. exports.useColors = useColors;
  713. exports.destroy = util.deprecate(
  714. () => {},
  715. 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
  716. );
  717. /**
  718. * Colors.
  719. */
  720. exports.colors = [6, 2, 3, 4, 5, 1];
  721. try {
  722. // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
  723. // eslint-disable-next-line import/no-extraneous-dependencies
  724. const supportsColor = __webpack_require__(92130);
  725. if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
  726. exports.colors = [
  727. 20,
  728. 21,
  729. 26,
  730. 27,
  731. 32,
  732. 33,
  733. 38,
  734. 39,
  735. 40,
  736. 41,
  737. 42,
  738. 43,
  739. 44,
  740. 45,
  741. 56,
  742. 57,
  743. 62,
  744. 63,
  745. 68,
  746. 69,
  747. 74,
  748. 75,
  749. 76,
  750. 77,
  751. 78,
  752. 79,
  753. 80,
  754. 81,
  755. 92,
  756. 93,
  757. 98,
  758. 99,
  759. 112,
  760. 113,
  761. 128,
  762. 129,
  763. 134,
  764. 135,
  765. 148,
  766. 149,
  767. 160,
  768. 161,
  769. 162,
  770. 163,
  771. 164,
  772. 165,
  773. 166,
  774. 167,
  775. 168,
  776. 169,
  777. 170,
  778. 171,
  779. 172,
  780. 173,
  781. 178,
  782. 179,
  783. 184,
  784. 185,
  785. 196,
  786. 197,
  787. 198,
  788. 199,
  789. 200,
  790. 201,
  791. 202,
  792. 203,
  793. 204,
  794. 205,
  795. 206,
  796. 207,
  797. 208,
  798. 209,
  799. 214,
  800. 215,
  801. 220,
  802. 221
  803. ];
  804. }
  805. } catch (error) {
  806. // Swallow - we only care if `supports-color` is available; it doesn't have to be.
  807. }
  808. /**
  809. * Build up the default `inspectOpts` object from the environment variables.
  810. *
  811. * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
  812. */
  813. exports.inspectOpts = Object.keys(process.env).filter(key => {
  814. return /^debug_/i.test(key);
  815. }).reduce((obj, key) => {
  816. // Camel-case
  817. const prop = key
  818. .substring(6)
  819. .toLowerCase()
  820. .replace(/_([a-z])/g, (_, k) => {
  821. return k.toUpperCase();
  822. });
  823. // Coerce string value into JS value
  824. let val = process.env[key];
  825. if (/^(yes|on|true|enabled)$/i.test(val)) {
  826. val = true;
  827. } else if (/^(no|off|false|disabled)$/i.test(val)) {
  828. val = false;
  829. } else if (val === 'null') {
  830. val = null;
  831. } else {
  832. val = Number(val);
  833. }
  834. obj[prop] = val;
  835. return obj;
  836. }, {});
  837. /**
  838. * Is stdout a TTY? Colored output is enabled when `true`.
  839. */
  840. function useColors() {
  841. return 'colors' in exports.inspectOpts ?
  842. Boolean(exports.inspectOpts.colors) :
  843. tty.isatty(process.stderr.fd);
  844. }
  845. /**
  846. * Adds ANSI color escape codes if enabled.
  847. *
  848. * @api public
  849. */
  850. function formatArgs(args) {
  851. const {namespace: name, useColors} = this;
  852. if (useColors) {
  853. const c = this.color;
  854. const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
  855. const prefix = ` ${colorCode};1m${name} \u001B[0m`;
  856. args[0] = prefix + args[0].split('\n').join('\n' + prefix);
  857. args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
  858. } else {
  859. args[0] = getDate() + name + ' ' + args[0];
  860. }
  861. }
  862. function getDate() {
  863. if (exports.inspectOpts.hideDate) {
  864. return '';
  865. }
  866. return new Date().toISOString() + ' ';
  867. }
  868. /**
  869. * Invokes `util.format()` with the specified arguments and writes to stderr.
  870. */
  871. function log(...args) {
  872. return process.stderr.write(util.format(...args) + '\n');
  873. }
  874. /**
  875. * Save `namespaces`.
  876. *
  877. * @param {String} namespaces
  878. * @api private
  879. */
  880. function save(namespaces) {
  881. if (namespaces) {
  882. process.env.DEBUG = namespaces;
  883. } else {
  884. // If you set a process.env field to null or undefined, it gets cast to the
  885. // string 'null' or 'undefined'. Just delete instead.
  886. delete process.env.DEBUG;
  887. }
  888. }
  889. /**
  890. * Load `namespaces`.
  891. *
  892. * @return {String} returns the previously persisted debug modes
  893. * @api private
  894. */
  895. function load() {
  896. return process.env.DEBUG;
  897. }
  898. /**
  899. * Init logic for `debug` instances.
  900. *
  901. * Create a new `inspectOpts` object in case `useColors` is set
  902. * differently for a particular `debug` instance.
  903. */
  904. function init(debug) {
  905. debug.inspectOpts = {};
  906. const keys = Object.keys(exports.inspectOpts);
  907. for (let i = 0; i < keys.length; i++) {
  908. debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
  909. }
  910. }
  911. module.exports = __webpack_require__(97977)(exports);
  912. const {formatters} = module.exports;
  913. /**
  914. * Map %o to `util.inspect()`, all on a single line.
  915. */
  916. formatters.o = function (v) {
  917. this.inspectOpts.colors = this.useColors;
  918. return util.inspect(v, this.inspectOpts)
  919. .split('\n')
  920. .map(str => str.trim())
  921. .join(' ');
  922. };
  923. /**
  924. * Map %O to `util.inspect()`, allowing multiple lines if needed.
  925. */
  926. formatters.O = function (v) {
  927. this.inspectOpts.colors = this.useColors;
  928. return util.inspect(v, this.inspectOpts);
  929. };
  930. /***/ }),
  931. /***/ 42925:
  932. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  933. "use strict";
  934. Object.defineProperty(exports, "__esModule", ({ value: true }));
  935. exports.isPoetryInstalled = exports.extractPoetryVersion = void 0;
  936. const debugLib = __webpack_require__(15158);
  937. const child_process_1 = __webpack_require__(68026);
  938. const debug = debugLib('snyk-fix:poetry');
  939. function extractPoetryVersion(stdout) {
  940. /* stdout example:
  941. * Poetry version 1.1.4
  942. */
  943. let version = null;
  944. const re = new RegExp(/^Poetry\sversion\s([0-9.]+)/, 'g');
  945. const match = re.exec(stdout);
  946. if (match) {
  947. version = match[1];
  948. }
  949. return version;
  950. }
  951. exports.extractPoetryVersion = extractPoetryVersion;
  952. async function isPoetryInstalled() {
  953. let res;
  954. try {
  955. res = await child_process_1.execute('poetry', ['--version'], {});
  956. }
  957. catch (e) {
  958. debug('Execute failed with', e);
  959. res = e;
  960. }
  961. if (res.exitCode !== 0) {
  962. throw res.error;
  963. }
  964. return { version: extractPoetryVersion(res.stdout) };
  965. }
  966. exports.isPoetryInstalled = isPoetryInstalled;
  967. //# sourceMappingURL=check-poetry-is-installed.js.map
  968. /***/ }),
  969. /***/ 69671:
  970. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  971. "use strict";
  972. Object.defineProperty(exports, "__esModule", ({ value: true }));
  973. var check_poetry_is_installed_1 = __webpack_require__(42925);
  974. Object.defineProperty(exports, "isPoetryInstalled", ({ enumerable: true, get: function () { return check_poetry_is_installed_1.isPoetryInstalled; } }));
  975. var is_poetry_supported_version_1 = __webpack_require__(29257);
  976. Object.defineProperty(exports, "isPoetrySupportedVersion", ({ enumerable: true, get: function () { return is_poetry_supported_version_1.isPoetrySupportedVersion; } }));
  977. var poetry_add_1 = __webpack_require__(10055);
  978. Object.defineProperty(exports, "poetryAdd", ({ enumerable: true, get: function () { return poetry_add_1.poetryAdd; } }));
  979. //# sourceMappingURL=index.js.map
  980. /***/ }),
  981. /***/ 29257:
  982. /***/ ((__unused_webpack_module, exports) => {
  983. "use strict";
  984. Object.defineProperty(exports, "__esModule", ({ value: true }));
  985. exports.isPoetrySupportedVersion = void 0;
  986. function isPoetrySupportedVersion(version) {
  987. // See all versions: https://github.com/python-poetry/poetry/releases
  988. // Update SUPPORTED.md when this is updated
  989. // Not all versions listed below as not all are tested but most likely
  990. // they are supported
  991. const SUPPORTED_POETRY_VERSIONS = [
  992. '1.1.9',
  993. '1.1.8',
  994. '1.1.7',
  995. '1.1.6',
  996. '1.1.5',
  997. '1.1.4',
  998. '1.0.9',
  999. '1.0.8',
  1000. '1.0.7',
  1001. ];
  1002. let supported = false;
  1003. if (SUPPORTED_POETRY_VERSIONS.includes(version)) {
  1004. supported = true;
  1005. }
  1006. return {
  1007. supported,
  1008. versions: SUPPORTED_POETRY_VERSIONS,
  1009. };
  1010. }
  1011. exports.isPoetrySupportedVersion = isPoetrySupportedVersion;
  1012. //# sourceMappingURL=is-poetry-supported-version.js.map
  1013. /***/ }),
  1014. /***/ 10055:
  1015. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1016. "use strict";
  1017. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1018. exports.poetryAdd = void 0;
  1019. const debugLib = __webpack_require__(15158);
  1020. const bottleneck_1 = __webpack_require__(35861);
  1021. const child_process_1 = __webpack_require__(68026);
  1022. const debug = debugLib('snyk-fix:poetry');
  1023. const limiter = new bottleneck_1.default({
  1024. maxConcurrent: 4,
  1025. });
  1026. async function runPoetryAdd(projectPath, dependencyUpdates, config) {
  1027. const args = ['add', ...dependencyUpdates];
  1028. let res;
  1029. if (config.dev) {
  1030. args.push('--dev');
  1031. }
  1032. if (config.python) {
  1033. try {
  1034. // tell poetry to use the given interpreter
  1035. // https://python-poetry.org/docs/managing-environments/
  1036. await child_process_1.execute('poetry', ['env', 'use', config.python], {
  1037. cwd: projectPath,
  1038. });
  1039. }
  1040. catch (e) {
  1041. debug(`'poetry use env ${config.python}' failed with`, e);
  1042. }
  1043. }
  1044. try {
  1045. res = await child_process_1.execute('poetry', args, {
  1046. cwd: projectPath,
  1047. });
  1048. }
  1049. catch (e) {
  1050. debug('Execute failed with', e);
  1051. res = e;
  1052. }
  1053. if (config.python) {
  1054. try {
  1055. // set it back to system python
  1056. await child_process_1.execute('poetry', ['env', 'use', 'system'], {
  1057. cwd: projectPath,
  1058. });
  1059. }
  1060. catch (e) {
  1061. debug(`'poetry use env system' failed with`, e);
  1062. }
  1063. }
  1064. return res;
  1065. }
  1066. exports.poetryAdd = limiter.wrap(runPoetryAdd);
  1067. //# sourceMappingURL=poetry-add.js.map
  1068. /***/ }),
  1069. /***/ 9526:
  1070. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1071. "use strict";
  1072. var Batcher, Events, parser;
  1073. parser = __webpack_require__(88092);
  1074. Events = __webpack_require__(33800);
  1075. Batcher = function () {
  1076. class Batcher {
  1077. constructor(options = {}) {
  1078. this.options = options;
  1079. parser.load(this.options, this.defaults, this);
  1080. this.Events = new Events(this);
  1081. this._arr = [];
  1082. this._resetPromise();
  1083. this._lastFlush = Date.now();
  1084. }
  1085. _resetPromise() {
  1086. return this._promise = new this.Promise((res, rej) => {
  1087. return this._resolve = res;
  1088. });
  1089. }
  1090. _flush() {
  1091. clearTimeout(this._timeout);
  1092. this._lastFlush = Date.now();
  1093. this._resolve();
  1094. this.Events.trigger("batch", this._arr);
  1095. this._arr = [];
  1096. return this._resetPromise();
  1097. }
  1098. add(data) {
  1099. var ret;
  1100. this._arr.push(data);
  1101. ret = this._promise;
  1102. if (this._arr.length === this.maxSize) {
  1103. this._flush();
  1104. } else if (this.maxTime != null && this._arr.length === 1) {
  1105. this._timeout = setTimeout(() => {
  1106. return this._flush();
  1107. }, this.maxTime);
  1108. }
  1109. return ret;
  1110. }
  1111. }
  1112. ;
  1113. Batcher.prototype.defaults = {
  1114. maxTime: null,
  1115. maxSize: null,
  1116. Promise: Promise
  1117. };
  1118. return Batcher;
  1119. }.call(void 0);
  1120. module.exports = Batcher;
  1121. /***/ }),
  1122. /***/ 19529:
  1123. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1124. "use strict";
  1125. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  1126. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  1127. function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }
  1128. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  1129. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  1130. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  1131. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  1132. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  1133. var Bottleneck,
  1134. DEFAULT_PRIORITY,
  1135. Events,
  1136. Job,
  1137. LocalDatastore,
  1138. NUM_PRIORITIES,
  1139. Queues,
  1140. RedisDatastore,
  1141. States,
  1142. Sync,
  1143. parser,
  1144. splice = [].splice;
  1145. NUM_PRIORITIES = 10;
  1146. DEFAULT_PRIORITY = 5;
  1147. parser = __webpack_require__(88092);
  1148. Queues = __webpack_require__(21186);
  1149. Job = __webpack_require__(21262);
  1150. LocalDatastore = __webpack_require__(27705);
  1151. RedisDatastore = __webpack_require__(36220);
  1152. Events = __webpack_require__(33800);
  1153. States = __webpack_require__(65376);
  1154. Sync = __webpack_require__(64915);
  1155. Bottleneck = function () {
  1156. class Bottleneck {
  1157. constructor(options = {}, ...invalid) {
  1158. var storeInstanceOptions, storeOptions;
  1159. this._addToQueue = this._addToQueue.bind(this);
  1160. this._validateOptions(options, invalid);
  1161. parser.load(options, this.instanceDefaults, this);
  1162. this._queues = new Queues(NUM_PRIORITIES);
  1163. this._scheduled = {};
  1164. this._states = new States(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : []));
  1165. this._limiter = null;
  1166. this.Events = new Events(this);
  1167. this._submitLock = new Sync("submit", this.Promise);
  1168. this._registerLock = new Sync("register", this.Promise);
  1169. storeOptions = parser.load(options, this.storeDefaults, {});
  1170. this._store = function () {
  1171. if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) {
  1172. storeInstanceOptions = parser.load(options, this.redisStoreDefaults, {});
  1173. return new RedisDatastore(this, storeOptions, storeInstanceOptions);
  1174. } else if (this.datastore === "local") {
  1175. storeInstanceOptions = parser.load(options, this.localStoreDefaults, {});
  1176. return new LocalDatastore(this, storeOptions, storeInstanceOptions);
  1177. } else {
  1178. throw new Bottleneck.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
  1179. }
  1180. }.call(this);
  1181. this._queues.on("leftzero", () => {
  1182. var ref;
  1183. return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
  1184. });
  1185. this._queues.on("zero", () => {
  1186. var ref;
  1187. return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
  1188. });
  1189. }
  1190. _validateOptions(options, invalid) {
  1191. if (!(options != null && typeof options === "object" && invalid.length === 0)) {
  1192. throw new Bottleneck.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.");
  1193. }
  1194. }
  1195. ready() {
  1196. return this._store.ready;
  1197. }
  1198. clients() {
  1199. return this._store.clients;
  1200. }
  1201. channel() {
  1202. return `b_${this.id}`;
  1203. }
  1204. channel_client() {
  1205. return `b_${this.id}_${this._store.clientId}`;
  1206. }
  1207. publish(message) {
  1208. return this._store.__publish__(message);
  1209. }
  1210. disconnect(flush = true) {
  1211. return this._store.__disconnect__(flush);
  1212. }
  1213. chain(_limiter) {
  1214. this._limiter = _limiter;
  1215. return this;
  1216. }
  1217. queued(priority) {
  1218. return this._queues.queued(priority);
  1219. }
  1220. clusterQueued() {
  1221. return this._store.__queued__();
  1222. }
  1223. empty() {
  1224. return this.queued() === 0 && this._submitLock.isEmpty();
  1225. }
  1226. running() {
  1227. return this._store.__running__();
  1228. }
  1229. done() {
  1230. return this._store.__done__();
  1231. }
  1232. jobStatus(id) {
  1233. return this._states.jobStatus(id);
  1234. }
  1235. jobs(status) {
  1236. return this._states.statusJobs(status);
  1237. }
  1238. counts() {
  1239. return this._states.statusCounts();
  1240. }
  1241. _randomIndex() {
  1242. return Math.random().toString(36).slice(2);
  1243. }
  1244. check(weight = 1) {
  1245. return this._store.__check__(weight);
  1246. }
  1247. _clearGlobalState(index) {
  1248. if (this._scheduled[index] != null) {
  1249. clearTimeout(this._scheduled[index].expiration);
  1250. delete this._scheduled[index];
  1251. return true;
  1252. } else {
  1253. return false;
  1254. }
  1255. }
  1256. _free(index, job, options, eventInfo) {
  1257. var _this = this;
  1258. return _asyncToGenerator(function* () {
  1259. var e, running;
  1260. try {
  1261. var _ref = yield _this._store.__free__(index, options.weight);
  1262. running = _ref.running;
  1263. _this.Events.trigger("debug", `Freed ${options.id}`, eventInfo);
  1264. if (running === 0 && _this.empty()) {
  1265. return _this.Events.trigger("idle");
  1266. }
  1267. } catch (error1) {
  1268. e = error1;
  1269. return _this.Events.trigger("error", e);
  1270. }
  1271. })();
  1272. }
  1273. _run(index, job, wait) {
  1274. var clearGlobalState, free, run;
  1275. job.doRun();
  1276. clearGlobalState = this._clearGlobalState.bind(this, index);
  1277. run = this._run.bind(this, index, job);
  1278. free = this._free.bind(this, index, job);
  1279. return this._scheduled[index] = {
  1280. timeout: setTimeout(() => {
  1281. return job.doExecute(this._limiter, clearGlobalState, run, free);
  1282. }, wait),
  1283. expiration: job.options.expiration != null ? setTimeout(function () {
  1284. return job.doExpire(clearGlobalState, run, free);
  1285. }, wait + job.options.expiration) : void 0,
  1286. job: job
  1287. };
  1288. }
  1289. _drainOne(capacity) {
  1290. return this._registerLock.schedule(() => {
  1291. var args, index, next, options, queue;
  1292. if (this.queued() === 0) {
  1293. return this.Promise.resolve(null);
  1294. }
  1295. queue = this._queues.getFirst();
  1296. var _next2 = next = queue.first();
  1297. options = _next2.options;
  1298. args = _next2.args;
  1299. if (capacity != null && options.weight > capacity) {
  1300. return this.Promise.resolve(null);
  1301. }
  1302. this.Events.trigger("debug", `Draining ${options.id}`, {
  1303. args,
  1304. options
  1305. });
  1306. index = this._randomIndex();
  1307. return this._store.__register__(index, options.weight, options.expiration).then(({
  1308. success,
  1309. wait,
  1310. reservoir
  1311. }) => {
  1312. var empty;
  1313. this.Events.trigger("debug", `Drained ${options.id}`, {
  1314. success,
  1315. args,
  1316. options
  1317. });
  1318. if (success) {
  1319. queue.shift();
  1320. empty = this.empty();
  1321. if (empty) {
  1322. this.Events.trigger("empty");
  1323. }
  1324. if (reservoir === 0) {
  1325. this.Events.trigger("depleted", empty);
  1326. }
  1327. this._run(index, next, wait);
  1328. return this.Promise.resolve(options.weight);
  1329. } else {
  1330. return this.Promise.resolve(null);
  1331. }
  1332. });
  1333. });
  1334. }
  1335. _drainAll(capacity, total = 0) {
  1336. return this._drainOne(capacity).then(drained => {
  1337. var newCapacity;
  1338. if (drained != null) {
  1339. newCapacity = capacity != null ? capacity - drained : capacity;
  1340. return this._drainAll(newCapacity, total + drained);
  1341. } else {
  1342. return this.Promise.resolve(total);
  1343. }
  1344. }).catch(e => {
  1345. return this.Events.trigger("error", e);
  1346. });
  1347. }
  1348. _dropAllQueued(message) {
  1349. return this._queues.shiftAll(function (job) {
  1350. return job.doDrop({
  1351. message
  1352. });
  1353. });
  1354. }
  1355. stop(options = {}) {
  1356. var done, waitForExecuting;
  1357. options = parser.load(options, this.stopDefaults);
  1358. waitForExecuting = at => {
  1359. var finished;
  1360. finished = () => {
  1361. var counts;
  1362. counts = this._states.counts;
  1363. return counts[0] + counts[1] + counts[2] + counts[3] === at;
  1364. };
  1365. return new this.Promise((resolve, reject) => {
  1366. if (finished()) {
  1367. return resolve();
  1368. } else {
  1369. return this.on("done", () => {
  1370. if (finished()) {
  1371. this.removeAllListeners("done");
  1372. return resolve();
  1373. }
  1374. });
  1375. }
  1376. });
  1377. };
  1378. done = options.dropWaitingJobs ? (this._run = function (index, next) {
  1379. return next.doDrop({
  1380. message: options.dropErrorMessage
  1381. });
  1382. }, this._drainOne = () => {
  1383. return this.Promise.resolve(null);
  1384. }, this._registerLock.schedule(() => {
  1385. return this._submitLock.schedule(() => {
  1386. var k, ref, v;
  1387. ref = this._scheduled;
  1388. for (k in ref) {
  1389. v = ref[k];
  1390. if (this.jobStatus(v.job.options.id) === "RUNNING") {
  1391. clearTimeout(v.timeout);
  1392. clearTimeout(v.expiration);
  1393. v.job.doDrop({
  1394. message: options.dropErrorMessage
  1395. });
  1396. }
  1397. }
  1398. this._dropAllQueued(options.dropErrorMessage);
  1399. return waitForExecuting(0);
  1400. });
  1401. })) : this.schedule({
  1402. priority: NUM_PRIORITIES - 1,
  1403. weight: 0
  1404. }, () => {
  1405. return waitForExecuting(1);
  1406. });
  1407. this._receive = function (job) {
  1408. return job._reject(new Bottleneck.prototype.BottleneckError(options.enqueueErrorMessage));
  1409. };
  1410. this.stop = () => {
  1411. return this.Promise.reject(new Bottleneck.prototype.BottleneckError("stop() has already been called"));
  1412. };
  1413. return done;
  1414. }
  1415. _addToQueue(job) {
  1416. var _this2 = this;
  1417. return _asyncToGenerator(function* () {
  1418. var args, blocked, error, options, reachedHWM, shifted, strategy;
  1419. args = job.args;
  1420. options = job.options;
  1421. try {
  1422. var _ref2 = yield _this2._store.__submit__(_this2.queued(), options.weight);
  1423. reachedHWM = _ref2.reachedHWM;
  1424. blocked = _ref2.blocked;
  1425. strategy = _ref2.strategy;
  1426. } catch (error1) {
  1427. error = error1;
  1428. _this2.Events.trigger("debug", `Could not queue ${options.id}`, {
  1429. args,
  1430. options,
  1431. error
  1432. });
  1433. job.doDrop({
  1434. error
  1435. });
  1436. return false;
  1437. }
  1438. if (blocked) {
  1439. job.doDrop();
  1440. return true;
  1441. } else if (reachedHWM) {
  1442. shifted = strategy === Bottleneck.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options.priority) : strategy === Bottleneck.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck.prototype.strategy.OVERFLOW ? job : void 0;
  1443. if (shifted != null) {
  1444. shifted.doDrop();
  1445. }
  1446. if (shifted == null || strategy === Bottleneck.prototype.strategy.OVERFLOW) {
  1447. if (shifted == null) {
  1448. job.doDrop();
  1449. }
  1450. return reachedHWM;
  1451. }
  1452. }
  1453. job.doQueue(reachedHWM, blocked);
  1454. _this2._queues.push(job);
  1455. yield _this2._drainAll();
  1456. return reachedHWM;
  1457. })();
  1458. }
  1459. _receive(job) {
  1460. if (this._states.jobStatus(job.options.id) != null) {
  1461. job._reject(new Bottleneck.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
  1462. return false;
  1463. } else {
  1464. job.doReceive();
  1465. return this._submitLock.schedule(this._addToQueue, job);
  1466. }
  1467. }
  1468. submit(...args) {
  1469. var cb, fn, job, options, ref, ref1, task;
  1470. if (typeof args[0] === "function") {
  1471. var _ref3, _ref4, _splice$call, _splice$call2;
  1472. ref = args, (_ref3 = ref, _ref4 = _toArray(_ref3), fn = _ref4[0], args = _ref4.slice(1), _ref3), (_splice$call = splice.call(args, -1), _splice$call2 = _slicedToArray(_splice$call, 1), cb = _splice$call2[0], _splice$call);
  1473. options = parser.load({}, this.jobDefaults);
  1474. } else {
  1475. var _ref5, _ref6, _splice$call3, _splice$call4;
  1476. ref1 = args, (_ref5 = ref1, _ref6 = _toArray(_ref5), options = _ref6[0], fn = _ref6[1], args = _ref6.slice(2), _ref5), (_splice$call3 = splice.call(args, -1), _splice$call4 = _slicedToArray(_splice$call3, 1), cb = _splice$call4[0], _splice$call3);
  1477. options = parser.load(options, this.jobDefaults);
  1478. }
  1479. task = (...args) => {
  1480. return new this.Promise(function (resolve, reject) {
  1481. return fn(...args, function (...args) {
  1482. return (args[0] != null ? reject : resolve)(args);
  1483. });
  1484. });
  1485. };
  1486. job = new Job(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
  1487. job.promise.then(function (args) {
  1488. return typeof cb === "function" ? cb(...args) : void 0;
  1489. }).catch(function (args) {
  1490. if (Array.isArray(args)) {
  1491. return typeof cb === "function" ? cb(...args) : void 0;
  1492. } else {
  1493. return typeof cb === "function" ? cb(args) : void 0;
  1494. }
  1495. });
  1496. return this._receive(job);
  1497. }
  1498. schedule(...args) {
  1499. var job, options, task;
  1500. if (typeof args[0] === "function") {
  1501. var _args = args;
  1502. var _args2 = _toArray(_args);
  1503. task = _args2[0];
  1504. args = _args2.slice(1);
  1505. options = {};
  1506. } else {
  1507. var _args3 = args;
  1508. var _args4 = _toArray(_args3);
  1509. options = _args4[0];
  1510. task = _args4[1];
  1511. args = _args4.slice(2);
  1512. }
  1513. job = new Job(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
  1514. this._receive(job);
  1515. return job.promise;
  1516. }
  1517. wrap(fn) {
  1518. var schedule, wrapped;
  1519. schedule = this.schedule.bind(this);
  1520. wrapped = function wrapped(...args) {
  1521. return schedule(fn.bind(this), ...args);
  1522. };
  1523. wrapped.withOptions = function (options, ...args) {
  1524. return schedule(options, fn, ...args);
  1525. };
  1526. return wrapped;
  1527. }
  1528. updateSettings(options = {}) {
  1529. var _this3 = this;
  1530. return _asyncToGenerator(function* () {
  1531. yield _this3._store.__updateSettings__(parser.overwrite(options, _this3.storeDefaults));
  1532. parser.overwrite(options, _this3.instanceDefaults, _this3);
  1533. return _this3;
  1534. })();
  1535. }
  1536. currentReservoir() {
  1537. return this._store.__currentReservoir__();
  1538. }
  1539. incrementReservoir(incr = 0) {
  1540. return this._store.__incrementReservoir__(incr);
  1541. }
  1542. }
  1543. ;
  1544. Bottleneck.default = Bottleneck;
  1545. Bottleneck.Events = Events;
  1546. Bottleneck.version = Bottleneck.prototype.version = __webpack_require__(82636)/* .version */ .i;
  1547. Bottleneck.strategy = Bottleneck.prototype.strategy = {
  1548. LEAK: 1,
  1549. OVERFLOW: 2,
  1550. OVERFLOW_PRIORITY: 4,
  1551. BLOCK: 3
  1552. };
  1553. Bottleneck.BottleneckError = Bottleneck.prototype.BottleneckError = __webpack_require__(34006);
  1554. Bottleneck.Group = Bottleneck.prototype.Group = __webpack_require__(99158);
  1555. Bottleneck.RedisConnection = Bottleneck.prototype.RedisConnection = __webpack_require__(66427);
  1556. Bottleneck.IORedisConnection = Bottleneck.prototype.IORedisConnection = __webpack_require__(9442);
  1557. Bottleneck.Batcher = Bottleneck.prototype.Batcher = __webpack_require__(9526);
  1558. Bottleneck.prototype.jobDefaults = {
  1559. priority: DEFAULT_PRIORITY,
  1560. weight: 1,
  1561. expiration: null,
  1562. id: "<no-id>"
  1563. };
  1564. Bottleneck.prototype.storeDefaults = {
  1565. maxConcurrent: null,
  1566. minTime: 0,
  1567. highWater: null,
  1568. strategy: Bottleneck.prototype.strategy.LEAK,
  1569. penalty: null,
  1570. reservoir: null,
  1571. reservoirRefreshInterval: null,
  1572. reservoirRefreshAmount: null,
  1573. reservoirIncreaseInterval: null,
  1574. reservoirIncreaseAmount: null,
  1575. reservoirIncreaseMaximum: null
  1576. };
  1577. Bottleneck.prototype.localStoreDefaults = {
  1578. Promise: Promise,
  1579. timeout: null,
  1580. heartbeatInterval: 250
  1581. };
  1582. Bottleneck.prototype.redisStoreDefaults = {
  1583. Promise: Promise,
  1584. timeout: null,
  1585. heartbeatInterval: 5000,
  1586. clientTimeout: 10000,
  1587. Redis: null,
  1588. clientOptions: {},
  1589. clusterNodes: null,
  1590. clearDatastore: false,
  1591. connection: null
  1592. };
  1593. Bottleneck.prototype.instanceDefaults = {
  1594. datastore: "local",
  1595. connection: null,
  1596. id: "<no-id>",
  1597. rejectOnDrop: true,
  1598. trackDoneStatus: false,
  1599. Promise: Promise
  1600. };
  1601. Bottleneck.prototype.stopDefaults = {
  1602. enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.",
  1603. dropWaitingJobs: true,
  1604. dropErrorMessage: "This limiter has been stopped."
  1605. };
  1606. return Bottleneck;
  1607. }.call(void 0);
  1608. module.exports = Bottleneck;
  1609. /***/ }),
  1610. /***/ 34006:
  1611. /***/ ((module) => {
  1612. "use strict";
  1613. var BottleneckError;
  1614. BottleneckError = class BottleneckError extends Error {};
  1615. module.exports = BottleneckError;
  1616. /***/ }),
  1617. /***/ 70938:
  1618. /***/ ((module) => {
  1619. "use strict";
  1620. var DLList;
  1621. DLList = class DLList {
  1622. constructor(incr, decr) {
  1623. this.incr = incr;
  1624. this.decr = decr;
  1625. this._first = null;
  1626. this._last = null;
  1627. this.length = 0;
  1628. }
  1629. push(value) {
  1630. var node;
  1631. this.length++;
  1632. if (typeof this.incr === "function") {
  1633. this.incr();
  1634. }
  1635. node = {
  1636. value,
  1637. prev: this._last,
  1638. next: null
  1639. };
  1640. if (this._last != null) {
  1641. this._last.next = node;
  1642. this._last = node;
  1643. } else {
  1644. this._first = this._last = node;
  1645. }
  1646. return void 0;
  1647. }
  1648. shift() {
  1649. var value;
  1650. if (this._first == null) {
  1651. return;
  1652. } else {
  1653. this.length--;
  1654. if (typeof this.decr === "function") {
  1655. this.decr();
  1656. }
  1657. }
  1658. value = this._first.value;
  1659. if ((this._first = this._first.next) != null) {
  1660. this._first.prev = null;
  1661. } else {
  1662. this._last = null;
  1663. }
  1664. return value;
  1665. }
  1666. first() {
  1667. if (this._first != null) {
  1668. return this._first.value;
  1669. }
  1670. }
  1671. getArray() {
  1672. var node, ref, results;
  1673. node = this._first;
  1674. results = [];
  1675. while (node != null) {
  1676. results.push((ref = node, node = node.next, ref.value));
  1677. }
  1678. return results;
  1679. }
  1680. forEachShift(cb) {
  1681. var node;
  1682. node = this.shift();
  1683. while (node != null) {
  1684. cb(node), node = this.shift();
  1685. }
  1686. return void 0;
  1687. }
  1688. debug() {
  1689. var node, ref, ref1, ref2, results;
  1690. node = this._first;
  1691. results = [];
  1692. while (node != null) {
  1693. results.push((ref = node, node = node.next, {
  1694. value: ref.value,
  1695. prev: (ref1 = ref.prev) != null ? ref1.value : void 0,
  1696. next: (ref2 = ref.next) != null ? ref2.value : void 0
  1697. }));
  1698. }
  1699. return results;
  1700. }
  1701. };
  1702. module.exports = DLList;
  1703. /***/ }),
  1704. /***/ 33800:
  1705. /***/ ((module) => {
  1706. "use strict";
  1707. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  1708. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  1709. var Events;
  1710. Events = class Events {
  1711. constructor(instance) {
  1712. this.instance = instance;
  1713. this._events = {};
  1714. if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) {
  1715. throw new Error("An Emitter already exists for this object");
  1716. }
  1717. this.instance.on = (name, cb) => {
  1718. return this._addListener(name, "many", cb);
  1719. };
  1720. this.instance.once = (name, cb) => {
  1721. return this._addListener(name, "once", cb);
  1722. };
  1723. this.instance.removeAllListeners = (name = null) => {
  1724. if (name != null) {
  1725. return delete this._events[name];
  1726. } else {
  1727. return this._events = {};
  1728. }
  1729. };
  1730. }
  1731. _addListener(name, status, cb) {
  1732. var base;
  1733. if ((base = this._events)[name] == null) {
  1734. base[name] = [];
  1735. }
  1736. this._events[name].push({
  1737. cb,
  1738. status
  1739. });
  1740. return this.instance;
  1741. }
  1742. listenerCount(name) {
  1743. if (this._events[name] != null) {
  1744. return this._events[name].length;
  1745. } else {
  1746. return 0;
  1747. }
  1748. }
  1749. trigger(name, ...args) {
  1750. var _this = this;
  1751. return _asyncToGenerator(function* () {
  1752. var e, promises;
  1753. try {
  1754. if (name !== "debug") {
  1755. _this.trigger("debug", `Event triggered: ${name}`, args);
  1756. }
  1757. if (_this._events[name] == null) {
  1758. return;
  1759. }
  1760. _this._events[name] = _this._events[name].filter(function (listener) {
  1761. return listener.status !== "none";
  1762. });
  1763. promises = _this._events[name].map(
  1764. /*#__PURE__*/
  1765. function () {
  1766. var _ref = _asyncToGenerator(function* (listener) {
  1767. var e, returned;
  1768. if (listener.status === "none") {
  1769. return;
  1770. }
  1771. if (listener.status === "once") {
  1772. listener.status = "none";
  1773. }
  1774. try {
  1775. returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0;
  1776. if (typeof (returned != null ? returned.then : void 0) === "function") {
  1777. return yield returned;
  1778. } else {
  1779. return returned;
  1780. }
  1781. } catch (error) {
  1782. e = error;
  1783. if (true) {
  1784. _this.trigger("error", e);
  1785. }
  1786. return null;
  1787. }
  1788. });
  1789. return function (_x) {
  1790. return _ref.apply(this, arguments);
  1791. };
  1792. }());
  1793. return (yield Promise.all(promises)).find(function (x) {
  1794. return x != null;
  1795. });
  1796. } catch (error) {
  1797. e = error;
  1798. if (true) {
  1799. _this.trigger("error", e);
  1800. }
  1801. return null;
  1802. }
  1803. })();
  1804. }
  1805. };
  1806. module.exports = Events;
  1807. /***/ }),
  1808. /***/ 99158:
  1809. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1810. "use strict";
  1811. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  1812. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  1813. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  1814. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  1815. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  1816. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  1817. var Events, Group, IORedisConnection, RedisConnection, Scripts, parser;
  1818. parser = __webpack_require__(88092);
  1819. Events = __webpack_require__(33800);
  1820. RedisConnection = __webpack_require__(66427);
  1821. IORedisConnection = __webpack_require__(9442);
  1822. Scripts = __webpack_require__(40812);
  1823. Group = function () {
  1824. class Group {
  1825. constructor(limiterOptions = {}) {
  1826. this.deleteKey = this.deleteKey.bind(this);
  1827. this.limiterOptions = limiterOptions;
  1828. parser.load(this.limiterOptions, this.defaults, this);
  1829. this.Events = new Events(this);
  1830. this.instances = {};
  1831. this.Bottleneck = __webpack_require__(19529);
  1832. this._startAutoCleanup();
  1833. this.sharedConnection = this.connection != null;
  1834. if (this.connection == null) {
  1835. if (this.limiterOptions.datastore === "redis") {
  1836. this.connection = new RedisConnection(Object.assign({}, this.limiterOptions, {
  1837. Events: this.Events
  1838. }));
  1839. } else if (this.limiterOptions.datastore === "ioredis") {
  1840. this.connection = new IORedisConnection(Object.assign({}, this.limiterOptions, {
  1841. Events: this.Events
  1842. }));
  1843. }
  1844. }
  1845. }
  1846. key(key = "") {
  1847. var ref;
  1848. return (ref = this.instances[key]) != null ? ref : (() => {
  1849. var limiter;
  1850. limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
  1851. id: `${this.id}-${key}`,
  1852. timeout: this.timeout,
  1853. connection: this.connection
  1854. }));
  1855. this.Events.trigger("created", limiter, key);
  1856. return limiter;
  1857. })();
  1858. }
  1859. deleteKey(key = "") {
  1860. var _this = this;
  1861. return _asyncToGenerator(function* () {
  1862. var deleted, instance;
  1863. instance = _this.instances[key];
  1864. if (_this.connection) {
  1865. deleted = yield _this.connection.__runCommand__(['del', ...Scripts.allKeys(`${_this.id}-${key}`)]);
  1866. }
  1867. if (instance != null) {
  1868. delete _this.instances[key];
  1869. yield instance.disconnect();
  1870. }
  1871. return instance != null || deleted > 0;
  1872. })();
  1873. }
  1874. limiters() {
  1875. var k, ref, results, v;
  1876. ref = this.instances;
  1877. results = [];
  1878. for (k in ref) {
  1879. v = ref[k];
  1880. results.push({
  1881. key: k,
  1882. limiter: v
  1883. });
  1884. }
  1885. return results;
  1886. }
  1887. keys() {
  1888. return Object.keys(this.instances);
  1889. }
  1890. clusterKeys() {
  1891. var _this2 = this;
  1892. return _asyncToGenerator(function* () {
  1893. var cursor, end, found, i, k, keys, len, next, start;
  1894. if (_this2.connection == null) {
  1895. return _this2.Promise.resolve(_this2.keys());
  1896. }
  1897. keys = [];
  1898. cursor = null;
  1899. start = `b_${_this2.id}-`.length;
  1900. end = "_settings".length;
  1901. while (cursor !== 0) {
  1902. var _ref = yield _this2.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${_this2.id}-*_settings`, "count", 10000]);
  1903. var _ref2 = _slicedToArray(_ref, 2);
  1904. next = _ref2[0];
  1905. found = _ref2[1];
  1906. cursor = ~~next;
  1907. for (i = 0, len = found.length; i < len; i++) {
  1908. k = found[i];
  1909. keys.push(k.slice(start, -end));
  1910. }
  1911. }
  1912. return keys;
  1913. })();
  1914. }
  1915. _startAutoCleanup() {
  1916. var _this3 = this;
  1917. var base;
  1918. clearInterval(this.interval);
  1919. return typeof (base = this.interval = setInterval(
  1920. /*#__PURE__*/
  1921. _asyncToGenerator(function* () {
  1922. var e, k, ref, results, time, v;
  1923. time = Date.now();
  1924. ref = _this3.instances;
  1925. results = [];
  1926. for (k in ref) {
  1927. v = ref[k];
  1928. try {
  1929. if (yield v._store.__groupCheck__(time)) {
  1930. results.push(_this3.deleteKey(k));
  1931. } else {
  1932. results.push(void 0);
  1933. }
  1934. } catch (error) {
  1935. e = error;
  1936. results.push(v.Events.trigger("error", e));
  1937. }
  1938. }
  1939. return results;
  1940. }), this.timeout / 2)).unref === "function" ? base.unref() : void 0;
  1941. }
  1942. updateSettings(options = {}) {
  1943. parser.overwrite(options, this.defaults, this);
  1944. parser.overwrite(options, options, this.limiterOptions);
  1945. if (options.timeout != null) {
  1946. return this._startAutoCleanup();
  1947. }
  1948. }
  1949. disconnect(flush = true) {
  1950. var ref;
  1951. if (!this.sharedConnection) {
  1952. return (ref = this.connection) != null ? ref.disconnect(flush) : void 0;
  1953. }
  1954. }
  1955. }
  1956. ;
  1957. Group.prototype.defaults = {
  1958. timeout: 1000 * 60 * 5,
  1959. connection: null,
  1960. Promise: Promise,
  1961. id: "group-key"
  1962. };
  1963. return Group;
  1964. }.call(void 0);
  1965. module.exports = Group;
  1966. /***/ }),
  1967. /***/ 9442:
  1968. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1969. "use strict";
  1970. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  1971. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  1972. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  1973. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  1974. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  1975. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  1976. var Events, IORedisConnection, Scripts, parser;
  1977. parser = __webpack_require__(88092);
  1978. Events = __webpack_require__(33800);
  1979. Scripts = __webpack_require__(40812);
  1980. IORedisConnection = function () {
  1981. class IORedisConnection {
  1982. constructor(options = {}) {
  1983. parser.load(options, this.defaults, this);
  1984. if (this.Redis == null) {
  1985. this.Redis = eval("require")("ioredis"); // Obfuscated or else Webpack/Angular will try to inline the optional ioredis module. To override this behavior: pass the ioredis module to Bottleneck as the 'Redis' option.
  1986. }
  1987. if (this.Events == null) {
  1988. this.Events = new Events(this);
  1989. }
  1990. this.terminated = false;
  1991. if (this.clusterNodes != null) {
  1992. this.client = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
  1993. this.subscriber = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
  1994. } else if (this.client != null && this.client.duplicate == null) {
  1995. this.subscriber = new this.Redis.Cluster(this.client.startupNodes, this.client.options);
  1996. } else {
  1997. if (this.client == null) {
  1998. this.client = new this.Redis(this.clientOptions);
  1999. }
  2000. this.subscriber = this.client.duplicate();
  2001. }
  2002. this.limiters = {};
  2003. this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
  2004. this._loadScripts();
  2005. return {
  2006. client: this.client,
  2007. subscriber: this.subscriber
  2008. };
  2009. });
  2010. }
  2011. _setup(client, sub) {
  2012. client.setMaxListeners(0);
  2013. return new this.Promise((resolve, reject) => {
  2014. client.on("error", e => {
  2015. return this.Events.trigger("error", e);
  2016. });
  2017. if (sub) {
  2018. client.on("message", (channel, message) => {
  2019. var ref;
  2020. return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
  2021. });
  2022. }
  2023. if (client.status === "ready") {
  2024. return resolve();
  2025. } else {
  2026. return client.once("ready", resolve);
  2027. }
  2028. });
  2029. }
  2030. _loadScripts() {
  2031. return Scripts.names.forEach(name => {
  2032. return this.client.defineCommand(name, {
  2033. lua: Scripts.payload(name)
  2034. });
  2035. });
  2036. }
  2037. __runCommand__(cmd) {
  2038. var _this = this;
  2039. return _asyncToGenerator(function* () {
  2040. var _, deleted;
  2041. yield _this.ready;
  2042. var _ref = yield _this.client.pipeline([cmd]).exec();
  2043. var _ref2 = _slicedToArray(_ref, 1);
  2044. var _ref2$ = _slicedToArray(_ref2[0], 2);
  2045. _ = _ref2$[0];
  2046. deleted = _ref2$[1];
  2047. return deleted;
  2048. })();
  2049. }
  2050. __addLimiter__(instance) {
  2051. return this.Promise.all([instance.channel(), instance.channel_client()].map(channel => {
  2052. return new this.Promise((resolve, reject) => {
  2053. return this.subscriber.subscribe(channel, () => {
  2054. this.limiters[channel] = instance;
  2055. return resolve();
  2056. });
  2057. });
  2058. }));
  2059. }
  2060. __removeLimiter__(instance) {
  2061. var _this2 = this;
  2062. return [instance.channel(), instance.channel_client()].forEach(
  2063. /*#__PURE__*/
  2064. function () {
  2065. var _ref3 = _asyncToGenerator(function* (channel) {
  2066. if (!_this2.terminated) {
  2067. yield _this2.subscriber.unsubscribe(channel);
  2068. }
  2069. return delete _this2.limiters[channel];
  2070. });
  2071. return function (_x) {
  2072. return _ref3.apply(this, arguments);
  2073. };
  2074. }());
  2075. }
  2076. __scriptArgs__(name, id, args, cb) {
  2077. var keys;
  2078. keys = Scripts.keys(name, id);
  2079. return [keys.length].concat(keys, args, cb);
  2080. }
  2081. __scriptFn__(name) {
  2082. return this.client[name].bind(this.client);
  2083. }
  2084. disconnect(flush = true) {
  2085. var i, k, len, ref;
  2086. ref = Object.keys(this.limiters);
  2087. for (i = 0, len = ref.length; i < len; i++) {
  2088. k = ref[i];
  2089. clearInterval(this.limiters[k]._store.heartbeat);
  2090. }
  2091. this.limiters = {};
  2092. this.terminated = true;
  2093. if (flush) {
  2094. return this.Promise.all([this.client.quit(), this.subscriber.quit()]);
  2095. } else {
  2096. this.client.disconnect();
  2097. this.subscriber.disconnect();
  2098. return this.Promise.resolve();
  2099. }
  2100. }
  2101. }
  2102. ;
  2103. IORedisConnection.prototype.datastore = "ioredis";
  2104. IORedisConnection.prototype.defaults = {
  2105. Redis: null,
  2106. clientOptions: {},
  2107. clusterNodes: null,
  2108. client: null,
  2109. Promise: Promise,
  2110. Events: null
  2111. };
  2112. return IORedisConnection;
  2113. }.call(void 0);
  2114. module.exports = IORedisConnection;
  2115. /***/ }),
  2116. /***/ 21262:
  2117. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2118. "use strict";
  2119. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2120. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2121. var BottleneckError, DEFAULT_PRIORITY, Job, NUM_PRIORITIES, parser;
  2122. NUM_PRIORITIES = 10;
  2123. DEFAULT_PRIORITY = 5;
  2124. parser = __webpack_require__(88092);
  2125. BottleneckError = __webpack_require__(34006);
  2126. Job = class Job {
  2127. constructor(task, args, options, jobDefaults, rejectOnDrop, Events, _states, Promise) {
  2128. this.task = task;
  2129. this.args = args;
  2130. this.rejectOnDrop = rejectOnDrop;
  2131. this.Events = Events;
  2132. this._states = _states;
  2133. this.Promise = Promise;
  2134. this.options = parser.load(options, jobDefaults);
  2135. this.options.priority = this._sanitizePriority(this.options.priority);
  2136. if (this.options.id === jobDefaults.id) {
  2137. this.options.id = `${this.options.id}-${this._randomIndex()}`;
  2138. }
  2139. this.promise = new this.Promise((_resolve, _reject) => {
  2140. this._resolve = _resolve;
  2141. this._reject = _reject;
  2142. });
  2143. this.retryCount = 0;
  2144. }
  2145. _sanitizePriority(priority) {
  2146. var sProperty;
  2147. sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority;
  2148. if (sProperty < 0) {
  2149. return 0;
  2150. } else if (sProperty > NUM_PRIORITIES - 1) {
  2151. return NUM_PRIORITIES - 1;
  2152. } else {
  2153. return sProperty;
  2154. }
  2155. }
  2156. _randomIndex() {
  2157. return Math.random().toString(36).slice(2);
  2158. }
  2159. doDrop({
  2160. error,
  2161. message = "This job has been dropped by Bottleneck"
  2162. } = {}) {
  2163. if (this._states.remove(this.options.id)) {
  2164. if (this.rejectOnDrop) {
  2165. this._reject(error != null ? error : new BottleneckError(message));
  2166. }
  2167. this.Events.trigger("dropped", {
  2168. args: this.args,
  2169. options: this.options,
  2170. task: this.task,
  2171. promise: this.promise
  2172. });
  2173. return true;
  2174. } else {
  2175. return false;
  2176. }
  2177. }
  2178. _assertStatus(expected) {
  2179. var status;
  2180. status = this._states.jobStatus(this.options.id);
  2181. if (!(status === expected || expected === "DONE" && status === null)) {
  2182. throw new BottleneckError(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`);
  2183. }
  2184. }
  2185. doReceive() {
  2186. this._states.start(this.options.id);
  2187. return this.Events.trigger("received", {
  2188. args: this.args,
  2189. options: this.options
  2190. });
  2191. }
  2192. doQueue(reachedHWM, blocked) {
  2193. this._assertStatus("RECEIVED");
  2194. this._states.next(this.options.id);
  2195. return this.Events.trigger("queued", {
  2196. args: this.args,
  2197. options: this.options,
  2198. reachedHWM,
  2199. blocked
  2200. });
  2201. }
  2202. doRun() {
  2203. if (this.retryCount === 0) {
  2204. this._assertStatus("QUEUED");
  2205. this._states.next(this.options.id);
  2206. } else {
  2207. this._assertStatus("EXECUTING");
  2208. }
  2209. return this.Events.trigger("scheduled", {
  2210. args: this.args,
  2211. options: this.options
  2212. });
  2213. }
  2214. doExecute(chained, clearGlobalState, run, free) {
  2215. var _this = this;
  2216. return _asyncToGenerator(function* () {
  2217. var error, eventInfo, passed;
  2218. if (_this.retryCount === 0) {
  2219. _this._assertStatus("RUNNING");
  2220. _this._states.next(_this.options.id);
  2221. } else {
  2222. _this._assertStatus("EXECUTING");
  2223. }
  2224. eventInfo = {
  2225. args: _this.args,
  2226. options: _this.options,
  2227. retryCount: _this.retryCount
  2228. };
  2229. _this.Events.trigger("executing", eventInfo);
  2230. try {
  2231. passed = yield chained != null ? chained.schedule(_this.options, _this.task, ..._this.args) : _this.task(..._this.args);
  2232. if (clearGlobalState()) {
  2233. _this.doDone(eventInfo);
  2234. yield free(_this.options, eventInfo);
  2235. _this._assertStatus("DONE");
  2236. return _this._resolve(passed);
  2237. }
  2238. } catch (error1) {
  2239. error = error1;
  2240. return _this._onFailure(error, eventInfo, clearGlobalState, run, free);
  2241. }
  2242. })();
  2243. }
  2244. doExpire(clearGlobalState, run, free) {
  2245. var error, eventInfo;
  2246. if (this._states.jobStatus(this.options.id === "RUNNING")) {
  2247. this._states.next(this.options.id);
  2248. }
  2249. this._assertStatus("EXECUTING");
  2250. eventInfo = {
  2251. args: this.args,
  2252. options: this.options,
  2253. retryCount: this.retryCount
  2254. };
  2255. error = new BottleneckError(`This job timed out after ${this.options.expiration} ms.`);
  2256. return this._onFailure(error, eventInfo, clearGlobalState, run, free);
  2257. }
  2258. _onFailure(error, eventInfo, clearGlobalState, run, free) {
  2259. var _this2 = this;
  2260. return _asyncToGenerator(function* () {
  2261. var retry, retryAfter;
  2262. if (clearGlobalState()) {
  2263. retry = yield _this2.Events.trigger("failed", error, eventInfo);
  2264. if (retry != null) {
  2265. retryAfter = ~~retry;
  2266. _this2.Events.trigger("retry", `Retrying ${_this2.options.id} after ${retryAfter} ms`, eventInfo);
  2267. _this2.retryCount++;
  2268. return run(retryAfter);
  2269. } else {
  2270. _this2.doDone(eventInfo);
  2271. yield free(_this2.options, eventInfo);
  2272. _this2._assertStatus("DONE");
  2273. return _this2._reject(error);
  2274. }
  2275. }
  2276. })();
  2277. }
  2278. doDone(eventInfo) {
  2279. this._assertStatus("EXECUTING");
  2280. this._states.next(this.options.id);
  2281. return this.Events.trigger("done", eventInfo);
  2282. }
  2283. };
  2284. module.exports = Job;
  2285. /***/ }),
  2286. /***/ 27705:
  2287. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2288. "use strict";
  2289. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2290. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2291. var BottleneckError, LocalDatastore, parser;
  2292. parser = __webpack_require__(88092);
  2293. BottleneckError = __webpack_require__(34006);
  2294. LocalDatastore = class LocalDatastore {
  2295. constructor(instance, storeOptions, storeInstanceOptions) {
  2296. this.instance = instance;
  2297. this.storeOptions = storeOptions;
  2298. this.clientId = this.instance._randomIndex();
  2299. parser.load(storeInstanceOptions, storeInstanceOptions, this);
  2300. this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now();
  2301. this._running = 0;
  2302. this._done = 0;
  2303. this._unblockTime = 0;
  2304. this.ready = this.Promise.resolve();
  2305. this.clients = {};
  2306. this._startHeartbeat();
  2307. }
  2308. _startHeartbeat() {
  2309. var base;
  2310. if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) {
  2311. return typeof (base = this.heartbeat = setInterval(() => {
  2312. var amount, incr, maximum, now, reservoir;
  2313. now = Date.now();
  2314. if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) {
  2315. this._lastReservoirRefresh = now;
  2316. this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount;
  2317. this.instance._drainAll(this.computeCapacity());
  2318. }
  2319. if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) {
  2320. var _this$storeOptions = this.storeOptions;
  2321. amount = _this$storeOptions.reservoirIncreaseAmount;
  2322. maximum = _this$storeOptions.reservoirIncreaseMaximum;
  2323. reservoir = _this$storeOptions.reservoir;
  2324. this._lastReservoirIncrease = now;
  2325. incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount;
  2326. if (incr > 0) {
  2327. this.storeOptions.reservoir += incr;
  2328. return this.instance._drainAll(this.computeCapacity());
  2329. }
  2330. }
  2331. }, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0;
  2332. } else {
  2333. return clearInterval(this.heartbeat);
  2334. }
  2335. }
  2336. __publish__(message) {
  2337. var _this = this;
  2338. return _asyncToGenerator(function* () {
  2339. yield _this.yieldLoop();
  2340. return _this.instance.Events.trigger("message", message.toString());
  2341. })();
  2342. }
  2343. __disconnect__(flush) {
  2344. var _this2 = this;
  2345. return _asyncToGenerator(function* () {
  2346. yield _this2.yieldLoop();
  2347. clearInterval(_this2.heartbeat);
  2348. return _this2.Promise.resolve();
  2349. })();
  2350. }
  2351. yieldLoop(t = 0) {
  2352. return new this.Promise(function (resolve, reject) {
  2353. return setTimeout(resolve, t);
  2354. });
  2355. }
  2356. computePenalty() {
  2357. var ref;
  2358. return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5000;
  2359. }
  2360. __updateSettings__(options) {
  2361. var _this3 = this;
  2362. return _asyncToGenerator(function* () {
  2363. yield _this3.yieldLoop();
  2364. parser.overwrite(options, options, _this3.storeOptions);
  2365. _this3._startHeartbeat();
  2366. _this3.instance._drainAll(_this3.computeCapacity());
  2367. return true;
  2368. })();
  2369. }
  2370. __running__() {
  2371. var _this4 = this;
  2372. return _asyncToGenerator(function* () {
  2373. yield _this4.yieldLoop();
  2374. return _this4._running;
  2375. })();
  2376. }
  2377. __queued__() {
  2378. var _this5 = this;
  2379. return _asyncToGenerator(function* () {
  2380. yield _this5.yieldLoop();
  2381. return _this5.instance.queued();
  2382. })();
  2383. }
  2384. __done__() {
  2385. var _this6 = this;
  2386. return _asyncToGenerator(function* () {
  2387. yield _this6.yieldLoop();
  2388. return _this6._done;
  2389. })();
  2390. }
  2391. __groupCheck__(time) {
  2392. var _this7 = this;
  2393. return _asyncToGenerator(function* () {
  2394. yield _this7.yieldLoop();
  2395. return _this7._nextRequest + _this7.timeout < time;
  2396. })();
  2397. }
  2398. computeCapacity() {
  2399. var maxConcurrent, reservoir;
  2400. var _this$storeOptions2 = this.storeOptions;
  2401. maxConcurrent = _this$storeOptions2.maxConcurrent;
  2402. reservoir = _this$storeOptions2.reservoir;
  2403. if (maxConcurrent != null && reservoir != null) {
  2404. return Math.min(maxConcurrent - this._running, reservoir);
  2405. } else if (maxConcurrent != null) {
  2406. return maxConcurrent - this._running;
  2407. } else if (reservoir != null) {
  2408. return reservoir;
  2409. } else {
  2410. return null;
  2411. }
  2412. }
  2413. conditionsCheck(weight) {
  2414. var capacity;
  2415. capacity = this.computeCapacity();
  2416. return capacity == null || weight <= capacity;
  2417. }
  2418. __incrementReservoir__(incr) {
  2419. var _this8 = this;
  2420. return _asyncToGenerator(function* () {
  2421. var reservoir;
  2422. yield _this8.yieldLoop();
  2423. reservoir = _this8.storeOptions.reservoir += incr;
  2424. _this8.instance._drainAll(_this8.computeCapacity());
  2425. return reservoir;
  2426. })();
  2427. }
  2428. __currentReservoir__() {
  2429. var _this9 = this;
  2430. return _asyncToGenerator(function* () {
  2431. yield _this9.yieldLoop();
  2432. return _this9.storeOptions.reservoir;
  2433. })();
  2434. }
  2435. isBlocked(now) {
  2436. return this._unblockTime >= now;
  2437. }
  2438. check(weight, now) {
  2439. return this.conditionsCheck(weight) && this._nextRequest - now <= 0;
  2440. }
  2441. __check__(weight) {
  2442. var _this10 = this;
  2443. return _asyncToGenerator(function* () {
  2444. var now;
  2445. yield _this10.yieldLoop();
  2446. now = Date.now();
  2447. return _this10.check(weight, now);
  2448. })();
  2449. }
  2450. __register__(index, weight, expiration) {
  2451. var _this11 = this;
  2452. return _asyncToGenerator(function* () {
  2453. var now, wait;
  2454. yield _this11.yieldLoop();
  2455. now = Date.now();
  2456. if (_this11.conditionsCheck(weight)) {
  2457. _this11._running += weight;
  2458. if (_this11.storeOptions.reservoir != null) {
  2459. _this11.storeOptions.reservoir -= weight;
  2460. }
  2461. wait = Math.max(_this11._nextRequest - now, 0);
  2462. _this11._nextRequest = now + wait + _this11.storeOptions.minTime;
  2463. return {
  2464. success: true,
  2465. wait,
  2466. reservoir: _this11.storeOptions.reservoir
  2467. };
  2468. } else {
  2469. return {
  2470. success: false
  2471. };
  2472. }
  2473. })();
  2474. }
  2475. strategyIsBlock() {
  2476. return this.storeOptions.strategy === 3;
  2477. }
  2478. __submit__(queueLength, weight) {
  2479. var _this12 = this;
  2480. return _asyncToGenerator(function* () {
  2481. var blocked, now, reachedHWM;
  2482. yield _this12.yieldLoop();
  2483. if (_this12.storeOptions.maxConcurrent != null && weight > _this12.storeOptions.maxConcurrent) {
  2484. throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${_this12.storeOptions.maxConcurrent}`);
  2485. }
  2486. now = Date.now();
  2487. reachedHWM = _this12.storeOptions.highWater != null && queueLength === _this12.storeOptions.highWater && !_this12.check(weight, now);
  2488. blocked = _this12.strategyIsBlock() && (reachedHWM || _this12.isBlocked(now));
  2489. if (blocked) {
  2490. _this12._unblockTime = now + _this12.computePenalty();
  2491. _this12._nextRequest = _this12._unblockTime + _this12.storeOptions.minTime;
  2492. _this12.instance._dropAllQueued();
  2493. }
  2494. return {
  2495. reachedHWM,
  2496. blocked,
  2497. strategy: _this12.storeOptions.strategy
  2498. };
  2499. })();
  2500. }
  2501. __free__(index, weight) {
  2502. var _this13 = this;
  2503. return _asyncToGenerator(function* () {
  2504. yield _this13.yieldLoop();
  2505. _this13._running -= weight;
  2506. _this13._done += weight;
  2507. _this13.instance._drainAll(_this13.computeCapacity());
  2508. return {
  2509. running: _this13._running
  2510. };
  2511. })();
  2512. }
  2513. };
  2514. module.exports = LocalDatastore;
  2515. /***/ }),
  2516. /***/ 21186:
  2517. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2518. "use strict";
  2519. var DLList, Events, Queues;
  2520. DLList = __webpack_require__(70938);
  2521. Events = __webpack_require__(33800);
  2522. Queues = class Queues {
  2523. constructor(num_priorities) {
  2524. var i;
  2525. this.Events = new Events(this);
  2526. this._length = 0;
  2527. this._lists = function () {
  2528. var j, ref, results;
  2529. results = [];
  2530. for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {
  2531. results.push(new DLList(() => {
  2532. return this.incr();
  2533. }, () => {
  2534. return this.decr();
  2535. }));
  2536. }
  2537. return results;
  2538. }.call(this);
  2539. }
  2540. incr() {
  2541. if (this._length++ === 0) {
  2542. return this.Events.trigger("leftzero");
  2543. }
  2544. }
  2545. decr() {
  2546. if (--this._length === 0) {
  2547. return this.Events.trigger("zero");
  2548. }
  2549. }
  2550. push(job) {
  2551. return this._lists[job.options.priority].push(job);
  2552. }
  2553. queued(priority) {
  2554. if (priority != null) {
  2555. return this._lists[priority].length;
  2556. } else {
  2557. return this._length;
  2558. }
  2559. }
  2560. shiftAll(fn) {
  2561. return this._lists.forEach(function (list) {
  2562. return list.forEachShift(fn);
  2563. });
  2564. }
  2565. getFirst(arr = this._lists) {
  2566. var j, len, list;
  2567. for (j = 0, len = arr.length; j < len; j++) {
  2568. list = arr[j];
  2569. if (list.length > 0) {
  2570. return list;
  2571. }
  2572. }
  2573. return [];
  2574. }
  2575. shiftLastFrom(priority) {
  2576. return this.getFirst(this._lists.slice(priority).reverse()).shift();
  2577. }
  2578. };
  2579. module.exports = Queues;
  2580. /***/ }),
  2581. /***/ 66427:
  2582. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2583. "use strict";
  2584. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2585. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2586. var Events, RedisConnection, Scripts, parser;
  2587. parser = __webpack_require__(88092);
  2588. Events = __webpack_require__(33800);
  2589. Scripts = __webpack_require__(40812);
  2590. RedisConnection = function () {
  2591. class RedisConnection {
  2592. constructor(options = {}) {
  2593. parser.load(options, this.defaults, this);
  2594. if (this.Redis == null) {
  2595. this.Redis = eval("require")("redis"); // Obfuscated or else Webpack/Angular will try to inline the optional redis module. To override this behavior: pass the redis module to Bottleneck as the 'Redis' option.
  2596. }
  2597. if (this.Events == null) {
  2598. this.Events = new Events(this);
  2599. }
  2600. this.terminated = false;
  2601. if (this.client == null) {
  2602. this.client = this.Redis.createClient(this.clientOptions);
  2603. }
  2604. this.subscriber = this.client.duplicate();
  2605. this.limiters = {};
  2606. this.shas = {};
  2607. this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
  2608. return this._loadScripts();
  2609. }).then(() => {
  2610. return {
  2611. client: this.client,
  2612. subscriber: this.subscriber
  2613. };
  2614. });
  2615. }
  2616. _setup(client, sub) {
  2617. client.setMaxListeners(0);
  2618. return new this.Promise((resolve, reject) => {
  2619. client.on("error", e => {
  2620. return this.Events.trigger("error", e);
  2621. });
  2622. if (sub) {
  2623. client.on("message", (channel, message) => {
  2624. var ref;
  2625. return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
  2626. });
  2627. }
  2628. if (client.ready) {
  2629. return resolve();
  2630. } else {
  2631. return client.once("ready", resolve);
  2632. }
  2633. });
  2634. }
  2635. _loadScript(name) {
  2636. return new this.Promise((resolve, reject) => {
  2637. var payload;
  2638. payload = Scripts.payload(name);
  2639. return this.client.multi([["script", "load", payload]]).exec((err, replies) => {
  2640. if (err != null) {
  2641. return reject(err);
  2642. }
  2643. this.shas[name] = replies[0];
  2644. return resolve(replies[0]);
  2645. });
  2646. });
  2647. }
  2648. _loadScripts() {
  2649. return this.Promise.all(Scripts.names.map(k => {
  2650. return this._loadScript(k);
  2651. }));
  2652. }
  2653. __runCommand__(cmd) {
  2654. var _this = this;
  2655. return _asyncToGenerator(function* () {
  2656. yield _this.ready;
  2657. return new _this.Promise((resolve, reject) => {
  2658. return _this.client.multi([cmd]).exec_atomic(function (err, replies) {
  2659. if (err != null) {
  2660. return reject(err);
  2661. } else {
  2662. return resolve(replies[0]);
  2663. }
  2664. });
  2665. });
  2666. })();
  2667. }
  2668. __addLimiter__(instance) {
  2669. return this.Promise.all([instance.channel(), instance.channel_client()].map(channel => {
  2670. return new this.Promise((resolve, reject) => {
  2671. var handler;
  2672. handler = chan => {
  2673. if (chan === channel) {
  2674. this.subscriber.removeListener("subscribe", handler);
  2675. this.limiters[channel] = instance;
  2676. return resolve();
  2677. }
  2678. };
  2679. this.subscriber.on("subscribe", handler);
  2680. return this.subscriber.subscribe(channel);
  2681. });
  2682. }));
  2683. }
  2684. __removeLimiter__(instance) {
  2685. var _this2 = this;
  2686. return this.Promise.all([instance.channel(), instance.channel_client()].map(
  2687. /*#__PURE__*/
  2688. function () {
  2689. var _ref = _asyncToGenerator(function* (channel) {
  2690. if (!_this2.terminated) {
  2691. yield new _this2.Promise((resolve, reject) => {
  2692. return _this2.subscriber.unsubscribe(channel, function (err, chan) {
  2693. if (err != null) {
  2694. return reject(err);
  2695. }
  2696. if (chan === channel) {
  2697. return resolve();
  2698. }
  2699. });
  2700. });
  2701. }
  2702. return delete _this2.limiters[channel];
  2703. });
  2704. return function (_x) {
  2705. return _ref.apply(this, arguments);
  2706. };
  2707. }()));
  2708. }
  2709. __scriptArgs__(name, id, args, cb) {
  2710. var keys;
  2711. keys = Scripts.keys(name, id);
  2712. return [this.shas[name], keys.length].concat(keys, args, cb);
  2713. }
  2714. __scriptFn__(name) {
  2715. return this.client.evalsha.bind(this.client);
  2716. }
  2717. disconnect(flush = true) {
  2718. var i, k, len, ref;
  2719. ref = Object.keys(this.limiters);
  2720. for (i = 0, len = ref.length; i < len; i++) {
  2721. k = ref[i];
  2722. clearInterval(this.limiters[k]._store.heartbeat);
  2723. }
  2724. this.limiters = {};
  2725. this.terminated = true;
  2726. this.client.end(flush);
  2727. this.subscriber.end(flush);
  2728. return this.Promise.resolve();
  2729. }
  2730. }
  2731. ;
  2732. RedisConnection.prototype.datastore = "redis";
  2733. RedisConnection.prototype.defaults = {
  2734. Redis: null,
  2735. clientOptions: {},
  2736. client: null,
  2737. Promise: Promise,
  2738. Events: null
  2739. };
  2740. return RedisConnection;
  2741. }.call(void 0);
  2742. module.exports = RedisConnection;
  2743. /***/ }),
  2744. /***/ 36220:
  2745. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2746. "use strict";
  2747. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2748. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2749. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  2750. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2751. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2752. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2753. var BottleneckError, IORedisConnection, RedisConnection, RedisDatastore, parser;
  2754. parser = __webpack_require__(88092);
  2755. BottleneckError = __webpack_require__(34006);
  2756. RedisConnection = __webpack_require__(66427);
  2757. IORedisConnection = __webpack_require__(9442);
  2758. RedisDatastore = class RedisDatastore {
  2759. constructor(instance, storeOptions, storeInstanceOptions) {
  2760. this.instance = instance;
  2761. this.storeOptions = storeOptions;
  2762. this.originalId = this.instance.id;
  2763. this.clientId = this.instance._randomIndex();
  2764. parser.load(storeInstanceOptions, storeInstanceOptions, this);
  2765. this.clients = {};
  2766. this.capacityPriorityCounters = {};
  2767. this.sharedConnection = this.connection != null;
  2768. if (this.connection == null) {
  2769. this.connection = this.instance.datastore === "redis" ? new RedisConnection({
  2770. Redis: this.Redis,
  2771. clientOptions: this.clientOptions,
  2772. Promise: this.Promise,
  2773. Events: this.instance.Events
  2774. }) : this.instance.datastore === "ioredis" ? new IORedisConnection({
  2775. Redis: this.Redis,
  2776. clientOptions: this.clientOptions,
  2777. clusterNodes: this.clusterNodes,
  2778. Promise: this.Promise,
  2779. Events: this.instance.Events
  2780. }) : void 0;
  2781. }
  2782. this.instance.connection = this.connection;
  2783. this.instance.datastore = this.connection.datastore;
  2784. this.ready = this.connection.ready.then(clients => {
  2785. this.clients = clients;
  2786. return this.runScript("init", this.prepareInitSettings(this.clearDatastore));
  2787. }).then(() => {
  2788. return this.connection.__addLimiter__(this.instance);
  2789. }).then(() => {
  2790. return this.runScript("register_client", [this.instance.queued()]);
  2791. }).then(() => {
  2792. var base;
  2793. if (typeof (base = this.heartbeat = setInterval(() => {
  2794. return this.runScript("heartbeat", []).catch(e => {
  2795. return this.instance.Events.trigger("error", e);
  2796. });
  2797. }, this.heartbeatInterval)).unref === "function") {
  2798. base.unref();
  2799. }
  2800. return this.clients;
  2801. });
  2802. }
  2803. __publish__(message) {
  2804. var _this = this;
  2805. return _asyncToGenerator(function* () {
  2806. var client;
  2807. var _ref = yield _this.ready;
  2808. client = _ref.client;
  2809. return client.publish(_this.instance.channel(), `message:${message.toString()}`);
  2810. })();
  2811. }
  2812. onMessage(channel, message) {
  2813. var _this2 = this;
  2814. return _asyncToGenerator(function* () {
  2815. var capacity, counter, data, drained, e, newCapacity, pos, priorityClient, rawCapacity, type;
  2816. try {
  2817. pos = message.indexOf(":");
  2818. var _ref2 = [message.slice(0, pos), message.slice(pos + 1)];
  2819. type = _ref2[0];
  2820. data = _ref2[1];
  2821. if (type === "capacity") {
  2822. return yield _this2.instance._drainAll(data.length > 0 ? ~~data : void 0);
  2823. } else if (type === "capacity-priority") {
  2824. var _data$split = data.split(":");
  2825. var _data$split2 = _slicedToArray(_data$split, 3);
  2826. rawCapacity = _data$split2[0];
  2827. priorityClient = _data$split2[1];
  2828. counter = _data$split2[2];
  2829. capacity = rawCapacity.length > 0 ? ~~rawCapacity : void 0;
  2830. if (priorityClient === _this2.clientId) {
  2831. drained = yield _this2.instance._drainAll(capacity);
  2832. newCapacity = capacity != null ? capacity - (drained || 0) : "";
  2833. return yield _this2.clients.client.publish(_this2.instance.channel(), `capacity-priority:${newCapacity}::${counter}`);
  2834. } else if (priorityClient === "") {
  2835. clearTimeout(_this2.capacityPriorityCounters[counter]);
  2836. delete _this2.capacityPriorityCounters[counter];
  2837. return _this2.instance._drainAll(capacity);
  2838. } else {
  2839. return _this2.capacityPriorityCounters[counter] = setTimeout(
  2840. /*#__PURE__*/
  2841. _asyncToGenerator(function* () {
  2842. var e;
  2843. try {
  2844. delete _this2.capacityPriorityCounters[counter];
  2845. yield _this2.runScript("blacklist_client", [priorityClient]);
  2846. return yield _this2.instance._drainAll(capacity);
  2847. } catch (error) {
  2848. e = error;
  2849. return _this2.instance.Events.trigger("error", e);
  2850. }
  2851. }), 1000);
  2852. }
  2853. } else if (type === "message") {
  2854. return _this2.instance.Events.trigger("message", data);
  2855. } else if (type === "blocked") {
  2856. return yield _this2.instance._dropAllQueued();
  2857. }
  2858. } catch (error) {
  2859. e = error;
  2860. return _this2.instance.Events.trigger("error", e);
  2861. }
  2862. })();
  2863. }
  2864. __disconnect__(flush) {
  2865. clearInterval(this.heartbeat);
  2866. if (this.sharedConnection) {
  2867. return this.connection.__removeLimiter__(this.instance);
  2868. } else {
  2869. return this.connection.disconnect(flush);
  2870. }
  2871. }
  2872. runScript(name, args) {
  2873. var _this3 = this;
  2874. return _asyncToGenerator(function* () {
  2875. if (!(name === "init" || name === "register_client")) {
  2876. yield _this3.ready;
  2877. }
  2878. return new _this3.Promise((resolve, reject) => {
  2879. var all_args, arr;
  2880. all_args = [Date.now(), _this3.clientId].concat(args);
  2881. _this3.instance.Events.trigger("debug", `Calling Redis script: ${name}.lua`, all_args);
  2882. arr = _this3.connection.__scriptArgs__(name, _this3.originalId, all_args, function (err, replies) {
  2883. if (err != null) {
  2884. return reject(err);
  2885. }
  2886. return resolve(replies);
  2887. });
  2888. return _this3.connection.__scriptFn__(name)(...arr);
  2889. }).catch(e => {
  2890. if (e.message === "SETTINGS_KEY_NOT_FOUND") {
  2891. if (name === "heartbeat") {
  2892. return _this3.Promise.resolve();
  2893. } else {
  2894. return _this3.runScript("init", _this3.prepareInitSettings(false)).then(() => {
  2895. return _this3.runScript(name, args);
  2896. });
  2897. }
  2898. } else if (e.message === "UNKNOWN_CLIENT") {
  2899. return _this3.runScript("register_client", [_this3.instance.queued()]).then(() => {
  2900. return _this3.runScript(name, args);
  2901. });
  2902. } else {
  2903. return _this3.Promise.reject(e);
  2904. }
  2905. });
  2906. })();
  2907. }
  2908. prepareArray(arr) {
  2909. var i, len, results, x;
  2910. results = [];
  2911. for (i = 0, len = arr.length; i < len; i++) {
  2912. x = arr[i];
  2913. results.push(x != null ? x.toString() : "");
  2914. }
  2915. return results;
  2916. }
  2917. prepareObject(obj) {
  2918. var arr, k, v;
  2919. arr = [];
  2920. for (k in obj) {
  2921. v = obj[k];
  2922. arr.push(k, v != null ? v.toString() : "");
  2923. }
  2924. return arr;
  2925. }
  2926. prepareInitSettings(clear) {
  2927. var args;
  2928. args = this.prepareObject(Object.assign({}, this.storeOptions, {
  2929. id: this.originalId,
  2930. version: this.instance.version,
  2931. groupTimeout: this.timeout,
  2932. clientTimeout: this.clientTimeout
  2933. }));
  2934. args.unshift(clear ? 1 : 0, this.instance.version);
  2935. return args;
  2936. }
  2937. convertBool(b) {
  2938. return !!b;
  2939. }
  2940. __updateSettings__(options) {
  2941. var _this4 = this;
  2942. return _asyncToGenerator(function* () {
  2943. yield _this4.runScript("update_settings", _this4.prepareObject(options));
  2944. return parser.overwrite(options, options, _this4.storeOptions);
  2945. })();
  2946. }
  2947. __running__() {
  2948. return this.runScript("running", []);
  2949. }
  2950. __queued__() {
  2951. return this.runScript("queued", []);
  2952. }
  2953. __done__() {
  2954. return this.runScript("done", []);
  2955. }
  2956. __groupCheck__() {
  2957. var _this5 = this;
  2958. return _asyncToGenerator(function* () {
  2959. return _this5.convertBool((yield _this5.runScript("group_check", [])));
  2960. })();
  2961. }
  2962. __incrementReservoir__(incr) {
  2963. return this.runScript("increment_reservoir", [incr]);
  2964. }
  2965. __currentReservoir__() {
  2966. return this.runScript("current_reservoir", []);
  2967. }
  2968. __check__(weight) {
  2969. var _this6 = this;
  2970. return _asyncToGenerator(function* () {
  2971. return _this6.convertBool((yield _this6.runScript("check", _this6.prepareArray([weight]))));
  2972. })();
  2973. }
  2974. __register__(index, weight, expiration) {
  2975. var _this7 = this;
  2976. return _asyncToGenerator(function* () {
  2977. var reservoir, success, wait;
  2978. var _ref4 = yield _this7.runScript("register", _this7.prepareArray([index, weight, expiration]));
  2979. var _ref5 = _slicedToArray(_ref4, 3);
  2980. success = _ref5[0];
  2981. wait = _ref5[1];
  2982. reservoir = _ref5[2];
  2983. return {
  2984. success: _this7.convertBool(success),
  2985. wait,
  2986. reservoir
  2987. };
  2988. })();
  2989. }
  2990. __submit__(queueLength, weight) {
  2991. var _this8 = this;
  2992. return _asyncToGenerator(function* () {
  2993. var blocked, e, maxConcurrent, overweight, reachedHWM, strategy;
  2994. try {
  2995. var _ref6 = yield _this8.runScript("submit", _this8.prepareArray([queueLength, weight]));
  2996. var _ref7 = _slicedToArray(_ref6, 3);
  2997. reachedHWM = _ref7[0];
  2998. blocked = _ref7[1];
  2999. strategy = _ref7[2];
  3000. return {
  3001. reachedHWM: _this8.convertBool(reachedHWM),
  3002. blocked: _this8.convertBool(blocked),
  3003. strategy
  3004. };
  3005. } catch (error) {
  3006. e = error;
  3007. if (e.message.indexOf("OVERWEIGHT") === 0) {
  3008. var _e$message$split = e.message.split(":");
  3009. var _e$message$split2 = _slicedToArray(_e$message$split, 3);
  3010. overweight = _e$message$split2[0];
  3011. weight = _e$message$split2[1];
  3012. maxConcurrent = _e$message$split2[2];
  3013. throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${maxConcurrent}`);
  3014. } else {
  3015. throw e;
  3016. }
  3017. }
  3018. })();
  3019. }
  3020. __free__(index, weight) {
  3021. var _this9 = this;
  3022. return _asyncToGenerator(function* () {
  3023. var running;
  3024. running = yield _this9.runScript("free", _this9.prepareArray([index]));
  3025. return {
  3026. running
  3027. };
  3028. })();
  3029. }
  3030. };
  3031. module.exports = RedisDatastore;
  3032. /***/ }),
  3033. /***/ 40812:
  3034. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3035. "use strict";
  3036. var headers, lua, templates;
  3037. lua = __webpack_require__(31936);
  3038. headers = {
  3039. refs: lua["refs.lua"],
  3040. validate_keys: lua["validate_keys.lua"],
  3041. validate_client: lua["validate_client.lua"],
  3042. refresh_expiration: lua["refresh_expiration.lua"],
  3043. process_tick: lua["process_tick.lua"],
  3044. conditions_check: lua["conditions_check.lua"],
  3045. get_time: lua["get_time.lua"]
  3046. };
  3047. exports.allKeys = function (id) {
  3048. return [
  3049. /*
  3050. HASH
  3051. */
  3052. `b_${id}_settings`,
  3053. /*
  3054. HASH
  3055. job index -> weight
  3056. */
  3057. `b_${id}_job_weights`,
  3058. /*
  3059. ZSET
  3060. job index -> expiration
  3061. */
  3062. `b_${id}_job_expirations`,
  3063. /*
  3064. HASH
  3065. job index -> client
  3066. */
  3067. `b_${id}_job_clients`,
  3068. /*
  3069. ZSET
  3070. client -> sum running
  3071. */
  3072. `b_${id}_client_running`,
  3073. /*
  3074. HASH
  3075. client -> num queued
  3076. */
  3077. `b_${id}_client_num_queued`,
  3078. /*
  3079. ZSET
  3080. client -> last job registered
  3081. */
  3082. `b_${id}_client_last_registered`,
  3083. /*
  3084. ZSET
  3085. client -> last seen
  3086. */
  3087. `b_${id}_client_last_seen`];
  3088. };
  3089. templates = {
  3090. init: {
  3091. keys: exports.allKeys,
  3092. headers: ["process_tick"],
  3093. refresh_expiration: true,
  3094. code: lua["init.lua"]
  3095. },
  3096. group_check: {
  3097. keys: exports.allKeys,
  3098. headers: [],
  3099. refresh_expiration: false,
  3100. code: lua["group_check.lua"]
  3101. },
  3102. register_client: {
  3103. keys: exports.allKeys,
  3104. headers: ["validate_keys"],
  3105. refresh_expiration: false,
  3106. code: lua["register_client.lua"]
  3107. },
  3108. blacklist_client: {
  3109. keys: exports.allKeys,
  3110. headers: ["validate_keys", "validate_client"],
  3111. refresh_expiration: false,
  3112. code: lua["blacklist_client.lua"]
  3113. },
  3114. heartbeat: {
  3115. keys: exports.allKeys,
  3116. headers: ["validate_keys", "validate_client", "process_tick"],
  3117. refresh_expiration: false,
  3118. code: lua["heartbeat.lua"]
  3119. },
  3120. update_settings: {
  3121. keys: exports.allKeys,
  3122. headers: ["validate_keys", "validate_client", "process_tick"],
  3123. refresh_expiration: true,
  3124. code: lua["update_settings.lua"]
  3125. },
  3126. running: {
  3127. keys: exports.allKeys,
  3128. headers: ["validate_keys", "validate_client", "process_tick"],
  3129. refresh_expiration: false,
  3130. code: lua["running.lua"]
  3131. },
  3132. queued: {
  3133. keys: exports.allKeys,
  3134. headers: ["validate_keys", "validate_client"],
  3135. refresh_expiration: false,
  3136. code: lua["queued.lua"]
  3137. },
  3138. done: {
  3139. keys: exports.allKeys,
  3140. headers: ["validate_keys", "validate_client", "process_tick"],
  3141. refresh_expiration: false,
  3142. code: lua["done.lua"]
  3143. },
  3144. check: {
  3145. keys: exports.allKeys,
  3146. headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
  3147. refresh_expiration: false,
  3148. code: lua["check.lua"]
  3149. },
  3150. submit: {
  3151. keys: exports.allKeys,
  3152. headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
  3153. refresh_expiration: true,
  3154. code: lua["submit.lua"]
  3155. },
  3156. register: {
  3157. keys: exports.allKeys,
  3158. headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
  3159. refresh_expiration: true,
  3160. code: lua["register.lua"]
  3161. },
  3162. free: {
  3163. keys: exports.allKeys,
  3164. headers: ["validate_keys", "validate_client", "process_tick"],
  3165. refresh_expiration: true,
  3166. code: lua["free.lua"]
  3167. },
  3168. current_reservoir: {
  3169. keys: exports.allKeys,
  3170. headers: ["validate_keys", "validate_client", "process_tick"],
  3171. refresh_expiration: false,
  3172. code: lua["current_reservoir.lua"]
  3173. },
  3174. increment_reservoir: {
  3175. keys: exports.allKeys,
  3176. headers: ["validate_keys", "validate_client", "process_tick"],
  3177. refresh_expiration: true,
  3178. code: lua["increment_reservoir.lua"]
  3179. }
  3180. };
  3181. exports.names = Object.keys(templates);
  3182. exports.keys = function (name, id) {
  3183. return templates[name].keys(id);
  3184. };
  3185. exports.payload = function (name) {
  3186. var template;
  3187. template = templates[name];
  3188. return Array.prototype.concat(headers.refs, template.headers.map(function (h) {
  3189. return headers[h];
  3190. }), template.refresh_expiration ? headers.refresh_expiration : "", template.code).join("\n");
  3191. };
  3192. /***/ }),
  3193. /***/ 65376:
  3194. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3195. "use strict";
  3196. var BottleneckError, States;
  3197. BottleneckError = __webpack_require__(34006);
  3198. States = class States {
  3199. constructor(status1) {
  3200. this.status = status1;
  3201. this._jobs = {};
  3202. this.counts = this.status.map(function () {
  3203. return 0;
  3204. });
  3205. }
  3206. next(id) {
  3207. var current, next;
  3208. current = this._jobs[id];
  3209. next = current + 1;
  3210. if (current != null && next < this.status.length) {
  3211. this.counts[current]--;
  3212. this.counts[next]++;
  3213. return this._jobs[id]++;
  3214. } else if (current != null) {
  3215. this.counts[current]--;
  3216. return delete this._jobs[id];
  3217. }
  3218. }
  3219. start(id) {
  3220. var initial;
  3221. initial = 0;
  3222. this._jobs[id] = initial;
  3223. return this.counts[initial]++;
  3224. }
  3225. remove(id) {
  3226. var current;
  3227. current = this._jobs[id];
  3228. if (current != null) {
  3229. this.counts[current]--;
  3230. delete this._jobs[id];
  3231. }
  3232. return current != null;
  3233. }
  3234. jobStatus(id) {
  3235. var ref;
  3236. return (ref = this.status[this._jobs[id]]) != null ? ref : null;
  3237. }
  3238. statusJobs(status) {
  3239. var k, pos, ref, results, v;
  3240. if (status != null) {
  3241. pos = this.status.indexOf(status);
  3242. if (pos < 0) {
  3243. throw new BottleneckError(`status must be one of ${this.status.join(', ')}`);
  3244. }
  3245. ref = this._jobs;
  3246. results = [];
  3247. for (k in ref) {
  3248. v = ref[k];
  3249. if (v === pos) {
  3250. results.push(k);
  3251. }
  3252. }
  3253. return results;
  3254. } else {
  3255. return Object.keys(this._jobs);
  3256. }
  3257. }
  3258. statusCounts() {
  3259. return this.counts.reduce((acc, v, i) => {
  3260. acc[this.status[i]] = v;
  3261. return acc;
  3262. }, {});
  3263. }
  3264. };
  3265. module.exports = States;
  3266. /***/ }),
  3267. /***/ 64915:
  3268. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3269. "use strict";
  3270. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  3271. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  3272. var DLList, Sync;
  3273. DLList = __webpack_require__(70938);
  3274. Sync = class Sync {
  3275. constructor(name, Promise) {
  3276. this.schedule = this.schedule.bind(this);
  3277. this.name = name;
  3278. this.Promise = Promise;
  3279. this._running = 0;
  3280. this._queue = new DLList();
  3281. }
  3282. isEmpty() {
  3283. return this._queue.length === 0;
  3284. }
  3285. _tryToRun() {
  3286. var _this = this;
  3287. return _asyncToGenerator(function* () {
  3288. var args, cb, error, reject, resolve, returned, task;
  3289. if (_this._running < 1 && _this._queue.length > 0) {
  3290. _this._running++;
  3291. var _this$_queue$shift = _this._queue.shift();
  3292. task = _this$_queue$shift.task;
  3293. args = _this$_queue$shift.args;
  3294. resolve = _this$_queue$shift.resolve;
  3295. reject = _this$_queue$shift.reject;
  3296. cb = yield _asyncToGenerator(function* () {
  3297. try {
  3298. returned = yield task(...args);
  3299. return function () {
  3300. return resolve(returned);
  3301. };
  3302. } catch (error1) {
  3303. error = error1;
  3304. return function () {
  3305. return reject(error);
  3306. };
  3307. }
  3308. })();
  3309. _this._running--;
  3310. _this._tryToRun();
  3311. return cb();
  3312. }
  3313. })();
  3314. }
  3315. schedule(task, ...args) {
  3316. var promise, reject, resolve;
  3317. resolve = reject = null;
  3318. promise = new this.Promise(function (_resolve, _reject) {
  3319. resolve = _resolve;
  3320. return reject = _reject;
  3321. });
  3322. this._queue.push({
  3323. task,
  3324. args,
  3325. resolve,
  3326. reject
  3327. });
  3328. this._tryToRun();
  3329. return promise;
  3330. }
  3331. };
  3332. module.exports = Sync;
  3333. /***/ }),
  3334. /***/ 35861:
  3335. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3336. "use strict";
  3337. module.exports = __webpack_require__(19529);
  3338. /***/ }),
  3339. /***/ 88092:
  3340. /***/ ((__unused_webpack_module, exports) => {
  3341. "use strict";
  3342. exports.load = function (received, defaults, onto = {}) {
  3343. var k, ref, v;
  3344. for (k in defaults) {
  3345. v = defaults[k];
  3346. onto[k] = (ref = received[k]) != null ? ref : v;
  3347. }
  3348. return onto;
  3349. };
  3350. exports.overwrite = function (received, defaults, onto = {}) {
  3351. var k, v;
  3352. for (k in received) {
  3353. v = received[k];
  3354. if (defaults[k] !== void 0) {
  3355. onto[k] = v;
  3356. }
  3357. }
  3358. return onto;
  3359. };
  3360. /***/ }),
  3361. /***/ 76158:
  3362. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3363. "use strict";
  3364. /* module decorator */ module = __webpack_require__.nmd(module);
  3365. const wrapAnsi16 = (fn, offset) => (...args) => {
  3366. const code = fn(...args);
  3367. return `\u001B[${code + offset}m`;
  3368. };
  3369. const wrapAnsi256 = (fn, offset) => (...args) => {
  3370. const code = fn(...args);
  3371. return `\u001B[${38 + offset};5;${code}m`;
  3372. };
  3373. const wrapAnsi16m = (fn, offset) => (...args) => {
  3374. const rgb = fn(...args);
  3375. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  3376. };
  3377. const ansi2ansi = n => n;
  3378. const rgb2rgb = (r, g, b) => [r, g, b];
  3379. const setLazyProperty = (object, property, get) => {
  3380. Object.defineProperty(object, property, {
  3381. get: () => {
  3382. const value = get();
  3383. Object.defineProperty(object, property, {
  3384. value,
  3385. enumerable: true,
  3386. configurable: true
  3387. });
  3388. return value;
  3389. },
  3390. enumerable: true,
  3391. configurable: true
  3392. });
  3393. };
  3394. /** @type {typeof import('color-convert')} */
  3395. let colorConvert;
  3396. const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
  3397. if (colorConvert === undefined) {
  3398. colorConvert = __webpack_require__(91497);
  3399. }
  3400. const offset = isBackground ? 10 : 0;
  3401. const styles = {};
  3402. for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
  3403. const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
  3404. if (sourceSpace === targetSpace) {
  3405. styles[name] = wrap(identity, offset);
  3406. } else if (typeof suite === 'object') {
  3407. styles[name] = wrap(suite[targetSpace], offset);
  3408. }
  3409. }
  3410. return styles;
  3411. };
  3412. function assembleStyles() {
  3413. const codes = new Map();
  3414. const styles = {
  3415. modifier: {
  3416. reset: [0, 0],
  3417. // 21 isn't widely supported and 22 does the same thing
  3418. bold: [1, 22],
  3419. dim: [2, 22],
  3420. italic: [3, 23],
  3421. underline: [4, 24],
  3422. inverse: [7, 27],
  3423. hidden: [8, 28],
  3424. strikethrough: [9, 29]
  3425. },
  3426. color: {
  3427. black: [30, 39],
  3428. red: [31, 39],
  3429. green: [32, 39],
  3430. yellow: [33, 39],
  3431. blue: [34, 39],
  3432. magenta: [35, 39],
  3433. cyan: [36, 39],
  3434. white: [37, 39],
  3435. // Bright color
  3436. blackBright: [90, 39],
  3437. redBright: [91, 39],
  3438. greenBright: [92, 39],
  3439. yellowBright: [93, 39],
  3440. blueBright: [94, 39],
  3441. magentaBright: [95, 39],
  3442. cyanBright: [96, 39],
  3443. whiteBright: [97, 39]
  3444. },
  3445. bgColor: {
  3446. bgBlack: [40, 49],
  3447. bgRed: [41, 49],
  3448. bgGreen: [42, 49],
  3449. bgYellow: [43, 49],
  3450. bgBlue: [44, 49],
  3451. bgMagenta: [45, 49],
  3452. bgCyan: [46, 49],
  3453. bgWhite: [47, 49],
  3454. // Bright color
  3455. bgBlackBright: [100, 49],
  3456. bgRedBright: [101, 49],
  3457. bgGreenBright: [102, 49],
  3458. bgYellowBright: [103, 49],
  3459. bgBlueBright: [104, 49],
  3460. bgMagentaBright: [105, 49],
  3461. bgCyanBright: [106, 49],
  3462. bgWhiteBright: [107, 49]
  3463. }
  3464. };
  3465. // Alias bright black as gray (and grey)
  3466. styles.color.gray = styles.color.blackBright;
  3467. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  3468. styles.color.grey = styles.color.blackBright;
  3469. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  3470. for (const [groupName, group] of Object.entries(styles)) {
  3471. for (const [styleName, style] of Object.entries(group)) {
  3472. styles[styleName] = {
  3473. open: `\u001B[${style[0]}m`,
  3474. close: `\u001B[${style[1]}m`
  3475. };
  3476. group[styleName] = styles[styleName];
  3477. codes.set(style[0], style[1]);
  3478. }
  3479. Object.defineProperty(styles, groupName, {
  3480. value: group,
  3481. enumerable: false
  3482. });
  3483. }
  3484. Object.defineProperty(styles, 'codes', {
  3485. value: codes,
  3486. enumerable: false
  3487. });
  3488. styles.color.close = '\u001B[39m';
  3489. styles.bgColor.close = '\u001B[49m';
  3490. setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
  3491. setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
  3492. setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
  3493. setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
  3494. setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
  3495. setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
  3496. return styles;
  3497. }
  3498. // Make the export immutable
  3499. Object.defineProperty(module, 'exports', {
  3500. enumerable: true,
  3501. get: assembleStyles
  3502. });
  3503. /***/ }),
  3504. /***/ 98250:
  3505. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3506. "use strict";
  3507. const ansiStyles = __webpack_require__(76158);
  3508. const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(8442);
  3509. const {
  3510. stringReplaceAll,
  3511. stringEncaseCRLFWithFirstIndex
  3512. } = __webpack_require__(45173);
  3513. const {isArray} = Array;
  3514. // `supportsColor.level` → `ansiStyles.color[name]` mapping
  3515. const levelMapping = [
  3516. 'ansi',
  3517. 'ansi',
  3518. 'ansi256',
  3519. 'ansi16m'
  3520. ];
  3521. const styles = Object.create(null);
  3522. const applyOptions = (object, options = {}) => {
  3523. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  3524. throw new Error('The `level` option should be an integer from 0 to 3');
  3525. }
  3526. // Detect level if not set manually
  3527. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  3528. object.level = options.level === undefined ? colorLevel : options.level;
  3529. };
  3530. class ChalkClass {
  3531. constructor(options) {
  3532. // eslint-disable-next-line no-constructor-return
  3533. return chalkFactory(options);
  3534. }
  3535. }
  3536. const chalkFactory = options => {
  3537. const chalk = {};
  3538. applyOptions(chalk, options);
  3539. chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
  3540. Object.setPrototypeOf(chalk, Chalk.prototype);
  3541. Object.setPrototypeOf(chalk.template, chalk);
  3542. chalk.template.constructor = () => {
  3543. throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
  3544. };
  3545. chalk.template.Instance = ChalkClass;
  3546. return chalk.template;
  3547. };
  3548. function Chalk(options) {
  3549. return chalkFactory(options);
  3550. }
  3551. for (const [styleName, style] of Object.entries(ansiStyles)) {
  3552. styles[styleName] = {
  3553. get() {
  3554. const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
  3555. Object.defineProperty(this, styleName, {value: builder});
  3556. return builder;
  3557. }
  3558. };
  3559. }
  3560. styles.visible = {
  3561. get() {
  3562. const builder = createBuilder(this, this._styler, true);
  3563. Object.defineProperty(this, 'visible', {value: builder});
  3564. return builder;
  3565. }
  3566. };
  3567. const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
  3568. for (const model of usedModels) {
  3569. styles[model] = {
  3570. get() {
  3571. const {level} = this;
  3572. return function (...arguments_) {
  3573. const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
  3574. return createBuilder(this, styler, this._isEmpty);
  3575. };
  3576. }
  3577. };
  3578. }
  3579. for (const model of usedModels) {
  3580. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  3581. styles[bgModel] = {
  3582. get() {
  3583. const {level} = this;
  3584. return function (...arguments_) {
  3585. const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
  3586. return createBuilder(this, styler, this._isEmpty);
  3587. };
  3588. }
  3589. };
  3590. }
  3591. const proto = Object.defineProperties(() => {}, {
  3592. ...styles,
  3593. level: {
  3594. enumerable: true,
  3595. get() {
  3596. return this._generator.level;
  3597. },
  3598. set(level) {
  3599. this._generator.level = level;
  3600. }
  3601. }
  3602. });
  3603. const createStyler = (open, close, parent) => {
  3604. let openAll;
  3605. let closeAll;
  3606. if (parent === undefined) {
  3607. openAll = open;
  3608. closeAll = close;
  3609. } else {
  3610. openAll = parent.openAll + open;
  3611. closeAll = close + parent.closeAll;
  3612. }
  3613. return {
  3614. open,
  3615. close,
  3616. openAll,
  3617. closeAll,
  3618. parent
  3619. };
  3620. };
  3621. const createBuilder = (self, _styler, _isEmpty) => {
  3622. const builder = (...arguments_) => {
  3623. if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
  3624. // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
  3625. return applyStyle(builder, chalkTag(builder, ...arguments_));
  3626. }
  3627. // Single argument is hot path, implicit coercion is faster than anything
  3628. // eslint-disable-next-line no-implicit-coercion
  3629. return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
  3630. };
  3631. // We alter the prototype because we must return a function, but there is
  3632. // no way to create a function with a different prototype
  3633. Object.setPrototypeOf(builder, proto);
  3634. builder._generator = self;
  3635. builder._styler = _styler;
  3636. builder._isEmpty = _isEmpty;
  3637. return builder;
  3638. };
  3639. const applyStyle = (self, string) => {
  3640. if (self.level <= 0 || !string) {
  3641. return self._isEmpty ? '' : string;
  3642. }
  3643. let styler = self._styler;
  3644. if (styler === undefined) {
  3645. return string;
  3646. }
  3647. const {openAll, closeAll} = styler;
  3648. if (string.indexOf('\u001B') !== -1) {
  3649. while (styler !== undefined) {
  3650. // Replace any instances already present with a re-opening code
  3651. // otherwise only the part of the string until said closing code
  3652. // will be colored, and the rest will simply be 'plain'.
  3653. string = stringReplaceAll(string, styler.close, styler.open);
  3654. styler = styler.parent;
  3655. }
  3656. }
  3657. // We can move both next actions out of loop, because remaining actions in loop won't have
  3658. // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
  3659. // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
  3660. const lfIndex = string.indexOf('\n');
  3661. if (lfIndex !== -1) {
  3662. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  3663. }
  3664. return openAll + string + closeAll;
  3665. };
  3666. let template;
  3667. const chalkTag = (chalk, ...strings) => {
  3668. const [firstString] = strings;
  3669. if (!isArray(firstString) || !isArray(firstString.raw)) {
  3670. // If chalk() was called by itself or with a string,
  3671. // return the string itself as a string.
  3672. return strings.join(' ');
  3673. }
  3674. const arguments_ = strings.slice(1);
  3675. const parts = [firstString.raw[0]];
  3676. for (let i = 1; i < firstString.length; i++) {
  3677. parts.push(
  3678. String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
  3679. String(firstString.raw[i])
  3680. );
  3681. }
  3682. if (template === undefined) {
  3683. template = __webpack_require__(68452);
  3684. }
  3685. return template(chalk, parts.join(''));
  3686. };
  3687. Object.defineProperties(Chalk.prototype, styles);
  3688. const chalk = Chalk(); // eslint-disable-line new-cap
  3689. chalk.supportsColor = stdoutColor;
  3690. chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
  3691. chalk.stderr.supportsColor = stderrColor;
  3692. module.exports = chalk;
  3693. /***/ }),
  3694. /***/ 68452:
  3695. /***/ ((module) => {
  3696. "use strict";
  3697. const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  3698. const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  3699. const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  3700. const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
  3701. const ESCAPES = new Map([
  3702. ['n', '\n'],
  3703. ['r', '\r'],
  3704. ['t', '\t'],
  3705. ['b', '\b'],
  3706. ['f', '\f'],
  3707. ['v', '\v'],
  3708. ['0', '\0'],
  3709. ['\\', '\\'],
  3710. ['e', '\u001B'],
  3711. ['a', '\u0007']
  3712. ]);
  3713. function unescape(c) {
  3714. const u = c[0] === 'u';
  3715. const bracket = c[1] === '{';
  3716. if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
  3717. return String.fromCharCode(parseInt(c.slice(1), 16));
  3718. }
  3719. if (u && bracket) {
  3720. return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
  3721. }
  3722. return ESCAPES.get(c) || c;
  3723. }
  3724. function parseArguments(name, arguments_) {
  3725. const results = [];
  3726. const chunks = arguments_.trim().split(/\s*,\s*/g);
  3727. let matches;
  3728. for (const chunk of chunks) {
  3729. const number = Number(chunk);
  3730. if (!Number.isNaN(number)) {
  3731. results.push(number);
  3732. } else if ((matches = chunk.match(STRING_REGEX))) {
  3733. results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
  3734. } else {
  3735. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  3736. }
  3737. }
  3738. return results;
  3739. }
  3740. function parseStyle(style) {
  3741. STYLE_REGEX.lastIndex = 0;
  3742. const results = [];
  3743. let matches;
  3744. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  3745. const name = matches[1];
  3746. if (matches[2]) {
  3747. const args = parseArguments(name, matches[2]);
  3748. results.push([name].concat(args));
  3749. } else {
  3750. results.push([name]);
  3751. }
  3752. }
  3753. return results;
  3754. }
  3755. function buildStyle(chalk, styles) {
  3756. const enabled = {};
  3757. for (const layer of styles) {
  3758. for (const style of layer.styles) {
  3759. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  3760. }
  3761. }
  3762. let current = chalk;
  3763. for (const [styleName, styles] of Object.entries(enabled)) {
  3764. if (!Array.isArray(styles)) {
  3765. continue;
  3766. }
  3767. if (!(styleName in current)) {
  3768. throw new Error(`Unknown Chalk style: ${styleName}`);
  3769. }
  3770. current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
  3771. }
  3772. return current;
  3773. }
  3774. module.exports = (chalk, temporary) => {
  3775. const styles = [];
  3776. const chunks = [];
  3777. let chunk = [];
  3778. // eslint-disable-next-line max-params
  3779. temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
  3780. if (escapeCharacter) {
  3781. chunk.push(unescape(escapeCharacter));
  3782. } else if (style) {
  3783. const string = chunk.join('');
  3784. chunk = [];
  3785. chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
  3786. styles.push({inverse, styles: parseStyle(style)});
  3787. } else if (close) {
  3788. if (styles.length === 0) {
  3789. throw new Error('Found extraneous } in Chalk template literal');
  3790. }
  3791. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  3792. chunk = [];
  3793. styles.pop();
  3794. } else {
  3795. chunk.push(character);
  3796. }
  3797. });
  3798. chunks.push(chunk.join(''));
  3799. if (styles.length > 0) {
  3800. const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  3801. throw new Error(errMessage);
  3802. }
  3803. return chunks.join('');
  3804. };
  3805. /***/ }),
  3806. /***/ 45173:
  3807. /***/ ((module) => {
  3808. "use strict";
  3809. const stringReplaceAll = (string, substring, replacer) => {
  3810. let index = string.indexOf(substring);
  3811. if (index === -1) {
  3812. return string;
  3813. }
  3814. const substringLength = substring.length;
  3815. let endIndex = 0;
  3816. let returnValue = '';
  3817. do {
  3818. returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
  3819. endIndex = index + substringLength;
  3820. index = string.indexOf(substring, endIndex);
  3821. } while (index !== -1);
  3822. returnValue += string.substr(endIndex);
  3823. return returnValue;
  3824. };
  3825. const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
  3826. let endIndex = 0;
  3827. let returnValue = '';
  3828. do {
  3829. const gotCR = string[index - 1] === '\r';
  3830. returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
  3831. endIndex = index + 1;
  3832. index = string.indexOf('\n', endIndex);
  3833. } while (index !== -1);
  3834. returnValue += string.substr(endIndex);
  3835. return returnValue;
  3836. };
  3837. module.exports = {
  3838. stringReplaceAll,
  3839. stringEncaseCRLFWithFirstIndex
  3840. };
  3841. /***/ }),
  3842. /***/ 53302:
  3843. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3844. /* MIT license */
  3845. /* eslint-disable no-mixed-operators */
  3846. const cssKeywords = __webpack_require__(65460);
  3847. // NOTE: conversions should only return primitive values (i.e. arrays, or
  3848. // values that give correct `typeof` results).
  3849. // do not use box values types (i.e. Number(), String(), etc.)
  3850. const reverseKeywords = {};
  3851. for (const key of Object.keys(cssKeywords)) {
  3852. reverseKeywords[cssKeywords[key]] = key;
  3853. }
  3854. const convert = {
  3855. rgb: {channels: 3, labels: 'rgb'},
  3856. hsl: {channels: 3, labels: 'hsl'},
  3857. hsv: {channels: 3, labels: 'hsv'},
  3858. hwb: {channels: 3, labels: 'hwb'},
  3859. cmyk: {channels: 4, labels: 'cmyk'},
  3860. xyz: {channels: 3, labels: 'xyz'},
  3861. lab: {channels: 3, labels: 'lab'},
  3862. lch: {channels: 3, labels: 'lch'},
  3863. hex: {channels: 1, labels: ['hex']},
  3864. keyword: {channels: 1, labels: ['keyword']},
  3865. ansi16: {channels: 1, labels: ['ansi16']},
  3866. ansi256: {channels: 1, labels: ['ansi256']},
  3867. hcg: {channels: 3, labels: ['h', 'c', 'g']},
  3868. apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
  3869. gray: {channels: 1, labels: ['gray']}
  3870. };
  3871. module.exports = convert;
  3872. // Hide .channels and .labels properties
  3873. for (const model of Object.keys(convert)) {
  3874. if (!('channels' in convert[model])) {
  3875. throw new Error('missing channels property: ' + model);
  3876. }
  3877. if (!('labels' in convert[model])) {
  3878. throw new Error('missing channel labels property: ' + model);
  3879. }
  3880. if (convert[model].labels.length !== convert[model].channels) {
  3881. throw new Error('channel and label counts mismatch: ' + model);
  3882. }
  3883. const {channels, labels} = convert[model];
  3884. delete convert[model].channels;
  3885. delete convert[model].labels;
  3886. Object.defineProperty(convert[model], 'channels', {value: channels});
  3887. Object.defineProperty(convert[model], 'labels', {value: labels});
  3888. }
  3889. convert.rgb.hsl = function (rgb) {
  3890. const r = rgb[0] / 255;
  3891. const g = rgb[1] / 255;
  3892. const b = rgb[2] / 255;
  3893. const min = Math.min(r, g, b);
  3894. const max = Math.max(r, g, b);
  3895. const delta = max - min;
  3896. let h;
  3897. let s;
  3898. if (max === min) {
  3899. h = 0;
  3900. } else if (r === max) {
  3901. h = (g - b) / delta;
  3902. } else if (g === max) {
  3903. h = 2 + (b - r) / delta;
  3904. } else if (b === max) {
  3905. h = 4 + (r - g) / delta;
  3906. }
  3907. h = Math.min(h * 60, 360);
  3908. if (h < 0) {
  3909. h += 360;
  3910. }
  3911. const l = (min + max) / 2;
  3912. if (max === min) {
  3913. s = 0;
  3914. } else if (l <= 0.5) {
  3915. s = delta / (max + min);
  3916. } else {
  3917. s = delta / (2 - max - min);
  3918. }
  3919. return [h, s * 100, l * 100];
  3920. };
  3921. convert.rgb.hsv = function (rgb) {
  3922. let rdif;
  3923. let gdif;
  3924. let bdif;
  3925. let h;
  3926. let s;
  3927. const r = rgb[0] / 255;
  3928. const g = rgb[1] / 255;
  3929. const b = rgb[2] / 255;
  3930. const v = Math.max(r, g, b);
  3931. const diff = v - Math.min(r, g, b);
  3932. const diffc = function (c) {
  3933. return (v - c) / 6 / diff + 1 / 2;
  3934. };
  3935. if (diff === 0) {
  3936. h = 0;
  3937. s = 0;
  3938. } else {
  3939. s = diff / v;
  3940. rdif = diffc(r);
  3941. gdif = diffc(g);
  3942. bdif = diffc(b);
  3943. if (r === v) {
  3944. h = bdif - gdif;
  3945. } else if (g === v) {
  3946. h = (1 / 3) + rdif - bdif;
  3947. } else if (b === v) {
  3948. h = (2 / 3) + gdif - rdif;
  3949. }
  3950. if (h < 0) {
  3951. h += 1;
  3952. } else if (h > 1) {
  3953. h -= 1;
  3954. }
  3955. }
  3956. return [
  3957. h * 360,
  3958. s * 100,
  3959. v * 100
  3960. ];
  3961. };
  3962. convert.rgb.hwb = function (rgb) {
  3963. const r = rgb[0];
  3964. const g = rgb[1];
  3965. let b = rgb[2];
  3966. const h = convert.rgb.hsl(rgb)[0];
  3967. const w = 1 / 255 * Math.min(r, Math.min(g, b));
  3968. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  3969. return [h, w * 100, b * 100];
  3970. };
  3971. convert.rgb.cmyk = function (rgb) {
  3972. const r = rgb[0] / 255;
  3973. const g = rgb[1] / 255;
  3974. const b = rgb[2] / 255;
  3975. const k = Math.min(1 - r, 1 - g, 1 - b);
  3976. const c = (1 - r - k) / (1 - k) || 0;
  3977. const m = (1 - g - k) / (1 - k) || 0;
  3978. const y = (1 - b - k) / (1 - k) || 0;
  3979. return [c * 100, m * 100, y * 100, k * 100];
  3980. };
  3981. function comparativeDistance(x, y) {
  3982. /*
  3983. See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  3984. */
  3985. return (
  3986. ((x[0] - y[0]) ** 2) +
  3987. ((x[1] - y[1]) ** 2) +
  3988. ((x[2] - y[2]) ** 2)
  3989. );
  3990. }
  3991. convert.rgb.keyword = function (rgb) {
  3992. const reversed = reverseKeywords[rgb];
  3993. if (reversed) {
  3994. return reversed;
  3995. }
  3996. let currentClosestDistance = Infinity;
  3997. let currentClosestKeyword;
  3998. for (const keyword of Object.keys(cssKeywords)) {
  3999. const value = cssKeywords[keyword];
  4000. // Compute comparative distance
  4001. const distance = comparativeDistance(rgb, value);
  4002. // Check if its less, if so set as closest
  4003. if (distance < currentClosestDistance) {
  4004. currentClosestDistance = distance;
  4005. currentClosestKeyword = keyword;
  4006. }
  4007. }
  4008. return currentClosestKeyword;
  4009. };
  4010. convert.keyword.rgb = function (keyword) {
  4011. return cssKeywords[keyword];
  4012. };
  4013. convert.rgb.xyz = function (rgb) {
  4014. let r = rgb[0] / 255;
  4015. let g = rgb[1] / 255;
  4016. let b = rgb[2] / 255;
  4017. // Assume sRGB
  4018. r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
  4019. g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
  4020. b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
  4021. const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  4022. const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  4023. const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  4024. return [x * 100, y * 100, z * 100];
  4025. };
  4026. convert.rgb.lab = function (rgb) {
  4027. const xyz = convert.rgb.xyz(rgb);
  4028. let x = xyz[0];
  4029. let y = xyz[1];
  4030. let z = xyz[2];
  4031. x /= 95.047;
  4032. y /= 100;
  4033. z /= 108.883;
  4034. x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
  4035. y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
  4036. z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
  4037. const l = (116 * y) - 16;
  4038. const a = 500 * (x - y);
  4039. const b = 200 * (y - z);
  4040. return [l, a, b];
  4041. };
  4042. convert.hsl.rgb = function (hsl) {
  4043. const h = hsl[0] / 360;
  4044. const s = hsl[1] / 100;
  4045. const l = hsl[2] / 100;
  4046. let t2;
  4047. let t3;
  4048. let val;
  4049. if (s === 0) {
  4050. val = l * 255;
  4051. return [val, val, val];
  4052. }
  4053. if (l < 0.5) {
  4054. t2 = l * (1 + s);
  4055. } else {
  4056. t2 = l + s - l * s;
  4057. }
  4058. const t1 = 2 * l - t2;
  4059. const rgb = [0, 0, 0];
  4060. for (let i = 0; i < 3; i++) {
  4061. t3 = h + 1 / 3 * -(i - 1);
  4062. if (t3 < 0) {
  4063. t3++;
  4064. }
  4065. if (t3 > 1) {
  4066. t3--;
  4067. }
  4068. if (6 * t3 < 1) {
  4069. val = t1 + (t2 - t1) * 6 * t3;
  4070. } else if (2 * t3 < 1) {
  4071. val = t2;
  4072. } else if (3 * t3 < 2) {
  4073. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  4074. } else {
  4075. val = t1;
  4076. }
  4077. rgb[i] = val * 255;
  4078. }
  4079. return rgb;
  4080. };
  4081. convert.hsl.hsv = function (hsl) {
  4082. const h = hsl[0];
  4083. let s = hsl[1] / 100;
  4084. let l = hsl[2] / 100;
  4085. let smin = s;
  4086. const lmin = Math.max(l, 0.01);
  4087. l *= 2;
  4088. s *= (l <= 1) ? l : 2 - l;
  4089. smin *= lmin <= 1 ? lmin : 2 - lmin;
  4090. const v = (l + s) / 2;
  4091. const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
  4092. return [h, sv * 100, v * 100];
  4093. };
  4094. convert.hsv.rgb = function (hsv) {
  4095. const h = hsv[0] / 60;
  4096. const s = hsv[1] / 100;
  4097. let v = hsv[2] / 100;
  4098. const hi = Math.floor(h) % 6;
  4099. const f = h - Math.floor(h);
  4100. const p = 255 * v * (1 - s);
  4101. const q = 255 * v * (1 - (s * f));
  4102. const t = 255 * v * (1 - (s * (1 - f)));
  4103. v *= 255;
  4104. switch (hi) {
  4105. case 0:
  4106. return [v, t, p];
  4107. case 1:
  4108. return [q, v, p];
  4109. case 2:
  4110. return [p, v, t];
  4111. case 3:
  4112. return [p, q, v];
  4113. case 4:
  4114. return [t, p, v];
  4115. case 5:
  4116. return [v, p, q];
  4117. }
  4118. };
  4119. convert.hsv.hsl = function (hsv) {
  4120. const h = hsv[0];
  4121. const s = hsv[1] / 100;
  4122. const v = hsv[2] / 100;
  4123. const vmin = Math.max(v, 0.01);
  4124. let sl;
  4125. let l;
  4126. l = (2 - s) * v;
  4127. const lmin = (2 - s) * vmin;
  4128. sl = s * vmin;
  4129. sl /= (lmin <= 1) ? lmin : 2 - lmin;
  4130. sl = sl || 0;
  4131. l /= 2;
  4132. return [h, sl * 100, l * 100];
  4133. };
  4134. // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  4135. convert.hwb.rgb = function (hwb) {
  4136. const h = hwb[0] / 360;
  4137. let wh = hwb[1] / 100;
  4138. let bl = hwb[2] / 100;
  4139. const ratio = wh + bl;
  4140. let f;
  4141. // Wh + bl cant be > 1
  4142. if (ratio > 1) {
  4143. wh /= ratio;
  4144. bl /= ratio;
  4145. }
  4146. const i = Math.floor(6 * h);
  4147. const v = 1 - bl;
  4148. f = 6 * h - i;
  4149. if ((i & 0x01) !== 0) {
  4150. f = 1 - f;
  4151. }
  4152. const n = wh + f * (v - wh); // Linear interpolation
  4153. let r;
  4154. let g;
  4155. let b;
  4156. /* eslint-disable max-statements-per-line,no-multi-spaces */
  4157. switch (i) {
  4158. default:
  4159. case 6:
  4160. case 0: r = v; g = n; b = wh; break;
  4161. case 1: r = n; g = v; b = wh; break;
  4162. case 2: r = wh; g = v; b = n; break;
  4163. case 3: r = wh; g = n; b = v; break;
  4164. case 4: r = n; g = wh; b = v; break;
  4165. case 5: r = v; g = wh; b = n; break;
  4166. }
  4167. /* eslint-enable max-statements-per-line,no-multi-spaces */
  4168. return [r * 255, g * 255, b * 255];
  4169. };
  4170. convert.cmyk.rgb = function (cmyk) {
  4171. const c = cmyk[0] / 100;
  4172. const m = cmyk[1] / 100;
  4173. const y = cmyk[2] / 100;
  4174. const k = cmyk[3] / 100;
  4175. const r = 1 - Math.min(1, c * (1 - k) + k);
  4176. const g = 1 - Math.min(1, m * (1 - k) + k);
  4177. const b = 1 - Math.min(1, y * (1 - k) + k);
  4178. return [r * 255, g * 255, b * 255];
  4179. };
  4180. convert.xyz.rgb = function (xyz) {
  4181. const x = xyz[0] / 100;
  4182. const y = xyz[1] / 100;
  4183. const z = xyz[2] / 100;
  4184. let r;
  4185. let g;
  4186. let b;
  4187. r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  4188. g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  4189. b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  4190. // Assume sRGB
  4191. r = r > 0.0031308
  4192. ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
  4193. : r * 12.92;
  4194. g = g > 0.0031308
  4195. ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
  4196. : g * 12.92;
  4197. b = b > 0.0031308
  4198. ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
  4199. : b * 12.92;
  4200. r = Math.min(Math.max(0, r), 1);
  4201. g = Math.min(Math.max(0, g), 1);
  4202. b = Math.min(Math.max(0, b), 1);
  4203. return [r * 255, g * 255, b * 255];
  4204. };
  4205. convert.xyz.lab = function (xyz) {
  4206. let x = xyz[0];
  4207. let y = xyz[1];
  4208. let z = xyz[2];
  4209. x /= 95.047;
  4210. y /= 100;
  4211. z /= 108.883;
  4212. x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
  4213. y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
  4214. z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
  4215. const l = (116 * y) - 16;
  4216. const a = 500 * (x - y);
  4217. const b = 200 * (y - z);
  4218. return [l, a, b];
  4219. };
  4220. convert.lab.xyz = function (lab) {
  4221. const l = lab[0];
  4222. const a = lab[1];
  4223. const b = lab[2];
  4224. let x;
  4225. let y;
  4226. let z;
  4227. y = (l + 16) / 116;
  4228. x = a / 500 + y;
  4229. z = y - b / 200;
  4230. const y2 = y ** 3;
  4231. const x2 = x ** 3;
  4232. const z2 = z ** 3;
  4233. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  4234. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  4235. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  4236. x *= 95.047;
  4237. y *= 100;
  4238. z *= 108.883;
  4239. return [x, y, z];
  4240. };
  4241. convert.lab.lch = function (lab) {
  4242. const l = lab[0];
  4243. const a = lab[1];
  4244. const b = lab[2];
  4245. let h;
  4246. const hr = Math.atan2(b, a);
  4247. h = hr * 360 / 2 / Math.PI;
  4248. if (h < 0) {
  4249. h += 360;
  4250. }
  4251. const c = Math.sqrt(a * a + b * b);
  4252. return [l, c, h];
  4253. };
  4254. convert.lch.lab = function (lch) {
  4255. const l = lch[0];
  4256. const c = lch[1];
  4257. const h = lch[2];
  4258. const hr = h / 360 * 2 * Math.PI;
  4259. const a = c * Math.cos(hr);
  4260. const b = c * Math.sin(hr);
  4261. return [l, a, b];
  4262. };
  4263. convert.rgb.ansi16 = function (args, saturation = null) {
  4264. const [r, g, b] = args;
  4265. let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
  4266. value = Math.round(value / 50);
  4267. if (value === 0) {
  4268. return 30;
  4269. }
  4270. let ansi = 30
  4271. + ((Math.round(b / 255) << 2)
  4272. | (Math.round(g / 255) << 1)
  4273. | Math.round(r / 255));
  4274. if (value === 2) {
  4275. ansi += 60;
  4276. }
  4277. return ansi;
  4278. };
  4279. convert.hsv.ansi16 = function (args) {
  4280. // Optimization here; we already know the value and don't need to get
  4281. // it converted for us.
  4282. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  4283. };
  4284. convert.rgb.ansi256 = function (args) {
  4285. const r = args[0];
  4286. const g = args[1];
  4287. const b = args[2];
  4288. // We use the extended greyscale palette here, with the exception of
  4289. // black and white. normal palette only has 4 greyscale shades.
  4290. if (r === g && g === b) {
  4291. if (r < 8) {
  4292. return 16;
  4293. }
  4294. if (r > 248) {
  4295. return 231;
  4296. }
  4297. return Math.round(((r - 8) / 247) * 24) + 232;
  4298. }
  4299. const ansi = 16
  4300. + (36 * Math.round(r / 255 * 5))
  4301. + (6 * Math.round(g / 255 * 5))
  4302. + Math.round(b / 255 * 5);
  4303. return ansi;
  4304. };
  4305. convert.ansi16.rgb = function (args) {
  4306. let color = args % 10;
  4307. // Handle greyscale
  4308. if (color === 0 || color === 7) {
  4309. if (args > 50) {
  4310. color += 3.5;
  4311. }
  4312. color = color / 10.5 * 255;
  4313. return [color, color, color];
  4314. }
  4315. const mult = (~~(args > 50) + 1) * 0.5;
  4316. const r = ((color & 1) * mult) * 255;
  4317. const g = (((color >> 1) & 1) * mult) * 255;
  4318. const b = (((color >> 2) & 1) * mult) * 255;
  4319. return [r, g, b];
  4320. };
  4321. convert.ansi256.rgb = function (args) {
  4322. // Handle greyscale
  4323. if (args >= 232) {
  4324. const c = (args - 232) * 10 + 8;
  4325. return [c, c, c];
  4326. }
  4327. args -= 16;
  4328. let rem;
  4329. const r = Math.floor(args / 36) / 5 * 255;
  4330. const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  4331. const b = (rem % 6) / 5 * 255;
  4332. return [r, g, b];
  4333. };
  4334. convert.rgb.hex = function (args) {
  4335. const integer = ((Math.round(args[0]) & 0xFF) << 16)
  4336. + ((Math.round(args[1]) & 0xFF) << 8)
  4337. + (Math.round(args[2]) & 0xFF);
  4338. const string = integer.toString(16).toUpperCase();
  4339. return '000000'.substring(string.length) + string;
  4340. };
  4341. convert.hex.rgb = function (args) {
  4342. const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  4343. if (!match) {
  4344. return [0, 0, 0];
  4345. }
  4346. let colorString = match[0];
  4347. if (match[0].length === 3) {
  4348. colorString = colorString.split('').map(char => {
  4349. return char + char;
  4350. }).join('');
  4351. }
  4352. const integer = parseInt(colorString, 16);
  4353. const r = (integer >> 16) & 0xFF;
  4354. const g = (integer >> 8) & 0xFF;
  4355. const b = integer & 0xFF;
  4356. return [r, g, b];
  4357. };
  4358. convert.rgb.hcg = function (rgb) {
  4359. const r = rgb[0] / 255;
  4360. const g = rgb[1] / 255;
  4361. const b = rgb[2] / 255;
  4362. const max = Math.max(Math.max(r, g), b);
  4363. const min = Math.min(Math.min(r, g), b);
  4364. const chroma = (max - min);
  4365. let grayscale;
  4366. let hue;
  4367. if (chroma < 1) {
  4368. grayscale = min / (1 - chroma);
  4369. } else {
  4370. grayscale = 0;
  4371. }
  4372. if (chroma <= 0) {
  4373. hue = 0;
  4374. } else
  4375. if (max === r) {
  4376. hue = ((g - b) / chroma) % 6;
  4377. } else
  4378. if (max === g) {
  4379. hue = 2 + (b - r) / chroma;
  4380. } else {
  4381. hue = 4 + (r - g) / chroma;
  4382. }
  4383. hue /= 6;
  4384. hue %= 1;
  4385. return [hue * 360, chroma * 100, grayscale * 100];
  4386. };
  4387. convert.hsl.hcg = function (hsl) {
  4388. const s = hsl[1] / 100;
  4389. const l = hsl[2] / 100;
  4390. const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
  4391. let f = 0;
  4392. if (c < 1.0) {
  4393. f = (l - 0.5 * c) / (1.0 - c);
  4394. }
  4395. return [hsl[0], c * 100, f * 100];
  4396. };
  4397. convert.hsv.hcg = function (hsv) {
  4398. const s = hsv[1] / 100;
  4399. const v = hsv[2] / 100;
  4400. const c = s * v;
  4401. let f = 0;
  4402. if (c < 1.0) {
  4403. f = (v - c) / (1 - c);
  4404. }
  4405. return [hsv[0], c * 100, f * 100];
  4406. };
  4407. convert.hcg.rgb = function (hcg) {
  4408. const h = hcg[0] / 360;
  4409. const c = hcg[1] / 100;
  4410. const g = hcg[2] / 100;
  4411. if (c === 0.0) {
  4412. return [g * 255, g * 255, g * 255];
  4413. }
  4414. const pure = [0, 0, 0];
  4415. const hi = (h % 1) * 6;
  4416. const v = hi % 1;
  4417. const w = 1 - v;
  4418. let mg = 0;
  4419. /* eslint-disable max-statements-per-line */
  4420. switch (Math.floor(hi)) {
  4421. case 0:
  4422. pure[0] = 1; pure[1] = v; pure[2] = 0; break;
  4423. case 1:
  4424. pure[0] = w; pure[1] = 1; pure[2] = 0; break;
  4425. case 2:
  4426. pure[0] = 0; pure[1] = 1; pure[2] = v; break;
  4427. case 3:
  4428. pure[0] = 0; pure[1] = w; pure[2] = 1; break;
  4429. case 4:
  4430. pure[0] = v; pure[1] = 0; pure[2] = 1; break;
  4431. default:
  4432. pure[0] = 1; pure[1] = 0; pure[2] = w;
  4433. }
  4434. /* eslint-enable max-statements-per-line */
  4435. mg = (1.0 - c) * g;
  4436. return [
  4437. (c * pure[0] + mg) * 255,
  4438. (c * pure[1] + mg) * 255,
  4439. (c * pure[2] + mg) * 255
  4440. ];
  4441. };
  4442. convert.hcg.hsv = function (hcg) {
  4443. const c = hcg[1] / 100;
  4444. const g = hcg[2] / 100;
  4445. const v = c + g * (1.0 - c);
  4446. let f = 0;
  4447. if (v > 0.0) {
  4448. f = c / v;
  4449. }
  4450. return [hcg[0], f * 100, v * 100];
  4451. };
  4452. convert.hcg.hsl = function (hcg) {
  4453. const c = hcg[1] / 100;
  4454. const g = hcg[2] / 100;
  4455. const l = g * (1.0 - c) + 0.5 * c;
  4456. let s = 0;
  4457. if (l > 0.0 && l < 0.5) {
  4458. s = c / (2 * l);
  4459. } else
  4460. if (l >= 0.5 && l < 1.0) {
  4461. s = c / (2 * (1 - l));
  4462. }
  4463. return [hcg[0], s * 100, l * 100];
  4464. };
  4465. convert.hcg.hwb = function (hcg) {
  4466. const c = hcg[1] / 100;
  4467. const g = hcg[2] / 100;
  4468. const v = c + g * (1.0 - c);
  4469. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  4470. };
  4471. convert.hwb.hcg = function (hwb) {
  4472. const w = hwb[1] / 100;
  4473. const b = hwb[2] / 100;
  4474. const v = 1 - b;
  4475. const c = v - w;
  4476. let g = 0;
  4477. if (c < 1) {
  4478. g = (v - c) / (1 - c);
  4479. }
  4480. return [hwb[0], c * 100, g * 100];
  4481. };
  4482. convert.apple.rgb = function (apple) {
  4483. return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
  4484. };
  4485. convert.rgb.apple = function (rgb) {
  4486. return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
  4487. };
  4488. convert.gray.rgb = function (args) {
  4489. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  4490. };
  4491. convert.gray.hsl = function (args) {
  4492. return [0, 0, args[0]];
  4493. };
  4494. convert.gray.hsv = convert.gray.hsl;
  4495. convert.gray.hwb = function (gray) {
  4496. return [0, 100, gray[0]];
  4497. };
  4498. convert.gray.cmyk = function (gray) {
  4499. return [0, 0, 0, gray[0]];
  4500. };
  4501. convert.gray.lab = function (gray) {
  4502. return [gray[0], 0, 0];
  4503. };
  4504. convert.gray.hex = function (gray) {
  4505. const val = Math.round(gray[0] / 100 * 255) & 0xFF;
  4506. const integer = (val << 16) + (val << 8) + val;
  4507. const string = integer.toString(16).toUpperCase();
  4508. return '000000'.substring(string.length) + string;
  4509. };
  4510. convert.rgb.gray = function (rgb) {
  4511. const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  4512. return [val / 255 * 100];
  4513. };
  4514. /***/ }),
  4515. /***/ 91497:
  4516. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4517. const conversions = __webpack_require__(53302);
  4518. const route = __webpack_require__(60091);
  4519. const convert = {};
  4520. const models = Object.keys(conversions);
  4521. function wrapRaw(fn) {
  4522. const wrappedFn = function (...args) {
  4523. const arg0 = args[0];
  4524. if (arg0 === undefined || arg0 === null) {
  4525. return arg0;
  4526. }
  4527. if (arg0.length > 1) {
  4528. args = arg0;
  4529. }
  4530. return fn(args);
  4531. };
  4532. // Preserve .conversion property if there is one
  4533. if ('conversion' in fn) {
  4534. wrappedFn.conversion = fn.conversion;
  4535. }
  4536. return wrappedFn;
  4537. }
  4538. function wrapRounded(fn) {
  4539. const wrappedFn = function (...args) {
  4540. const arg0 = args[0];
  4541. if (arg0 === undefined || arg0 === null) {
  4542. return arg0;
  4543. }
  4544. if (arg0.length > 1) {
  4545. args = arg0;
  4546. }
  4547. const result = fn(args);
  4548. // We're assuming the result is an array here.
  4549. // see notice in conversions.js; don't use box types
  4550. // in conversion functions.
  4551. if (typeof result === 'object') {
  4552. for (let len = result.length, i = 0; i < len; i++) {
  4553. result[i] = Math.round(result[i]);
  4554. }
  4555. }
  4556. return result;
  4557. };
  4558. // Preserve .conversion property if there is one
  4559. if ('conversion' in fn) {
  4560. wrappedFn.conversion = fn.conversion;
  4561. }
  4562. return wrappedFn;
  4563. }
  4564. models.forEach(fromModel => {
  4565. convert[fromModel] = {};
  4566. Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
  4567. Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
  4568. const routes = route(fromModel);
  4569. const routeModels = Object.keys(routes);
  4570. routeModels.forEach(toModel => {
  4571. const fn = routes[toModel];
  4572. convert[fromModel][toModel] = wrapRounded(fn);
  4573. convert[fromModel][toModel].raw = wrapRaw(fn);
  4574. });
  4575. });
  4576. module.exports = convert;
  4577. /***/ }),
  4578. /***/ 60091:
  4579. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4580. const conversions = __webpack_require__(53302);
  4581. /*
  4582. This function routes a model to all other models.
  4583. all functions that are routed have a property `.conversion` attached
  4584. to the returned synthetic function. This property is an array
  4585. of strings, each with the steps in between the 'from' and 'to'
  4586. color models (inclusive).
  4587. conversions that are not possible simply are not included.
  4588. */
  4589. function buildGraph() {
  4590. const graph = {};
  4591. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  4592. const models = Object.keys(conversions);
  4593. for (let len = models.length, i = 0; i < len; i++) {
  4594. graph[models[i]] = {
  4595. // http://jsperf.com/1-vs-infinity
  4596. // micro-opt, but this is simple.
  4597. distance: -1,
  4598. parent: null
  4599. };
  4600. }
  4601. return graph;
  4602. }
  4603. // https://en.wikipedia.org/wiki/Breadth-first_search
  4604. function deriveBFS(fromModel) {
  4605. const graph = buildGraph();
  4606. const queue = [fromModel]; // Unshift -> queue -> pop
  4607. graph[fromModel].distance = 0;
  4608. while (queue.length) {
  4609. const current = queue.pop();
  4610. const adjacents = Object.keys(conversions[current]);
  4611. for (let len = adjacents.length, i = 0; i < len; i++) {
  4612. const adjacent = adjacents[i];
  4613. const node = graph[adjacent];
  4614. if (node.distance === -1) {
  4615. node.distance = graph[current].distance + 1;
  4616. node.parent = current;
  4617. queue.unshift(adjacent);
  4618. }
  4619. }
  4620. }
  4621. return graph;
  4622. }
  4623. function link(from, to) {
  4624. return function (args) {
  4625. return to(from(args));
  4626. };
  4627. }
  4628. function wrapConversion(toModel, graph) {
  4629. const path = [graph[toModel].parent, toModel];
  4630. let fn = conversions[graph[toModel].parent][toModel];
  4631. let cur = graph[toModel].parent;
  4632. while (graph[cur].parent) {
  4633. path.unshift(graph[cur].parent);
  4634. fn = link(conversions[graph[cur].parent][cur], fn);
  4635. cur = graph[cur].parent;
  4636. }
  4637. fn.conversion = path;
  4638. return fn;
  4639. }
  4640. module.exports = function (fromModel) {
  4641. const graph = deriveBFS(fromModel);
  4642. const conversion = {};
  4643. const models = Object.keys(graph);
  4644. for (let len = models.length, i = 0; i < len; i++) {
  4645. const toModel = models[i];
  4646. const node = graph[toModel];
  4647. if (node.parent === null) {
  4648. // No possible conversion, or this node is the source model.
  4649. continue;
  4650. }
  4651. conversion[toModel] = wrapConversion(toModel, graph);
  4652. }
  4653. return conversion;
  4654. };
  4655. /***/ }),
  4656. /***/ 65460:
  4657. /***/ ((module) => {
  4658. "use strict";
  4659. module.exports = {
  4660. "aliceblue": [240, 248, 255],
  4661. "antiquewhite": [250, 235, 215],
  4662. "aqua": [0, 255, 255],
  4663. "aquamarine": [127, 255, 212],
  4664. "azure": [240, 255, 255],
  4665. "beige": [245, 245, 220],
  4666. "bisque": [255, 228, 196],
  4667. "black": [0, 0, 0],
  4668. "blanchedalmond": [255, 235, 205],
  4669. "blue": [0, 0, 255],
  4670. "blueviolet": [138, 43, 226],
  4671. "brown": [165, 42, 42],
  4672. "burlywood": [222, 184, 135],
  4673. "cadetblue": [95, 158, 160],
  4674. "chartreuse": [127, 255, 0],
  4675. "chocolate": [210, 105, 30],
  4676. "coral": [255, 127, 80],
  4677. "cornflowerblue": [100, 149, 237],
  4678. "cornsilk": [255, 248, 220],
  4679. "crimson": [220, 20, 60],
  4680. "cyan": [0, 255, 255],
  4681. "darkblue": [0, 0, 139],
  4682. "darkcyan": [0, 139, 139],
  4683. "darkgoldenrod": [184, 134, 11],
  4684. "darkgray": [169, 169, 169],
  4685. "darkgreen": [0, 100, 0],
  4686. "darkgrey": [169, 169, 169],
  4687. "darkkhaki": [189, 183, 107],
  4688. "darkmagenta": [139, 0, 139],
  4689. "darkolivegreen": [85, 107, 47],
  4690. "darkorange": [255, 140, 0],
  4691. "darkorchid": [153, 50, 204],
  4692. "darkred": [139, 0, 0],
  4693. "darksalmon": [233, 150, 122],
  4694. "darkseagreen": [143, 188, 143],
  4695. "darkslateblue": [72, 61, 139],
  4696. "darkslategray": [47, 79, 79],
  4697. "darkslategrey": [47, 79, 79],
  4698. "darkturquoise": [0, 206, 209],
  4699. "darkviolet": [148, 0, 211],
  4700. "deeppink": [255, 20, 147],
  4701. "deepskyblue": [0, 191, 255],
  4702. "dimgray": [105, 105, 105],
  4703. "dimgrey": [105, 105, 105],
  4704. "dodgerblue": [30, 144, 255],
  4705. "firebrick": [178, 34, 34],
  4706. "floralwhite": [255, 250, 240],
  4707. "forestgreen": [34, 139, 34],
  4708. "fuchsia": [255, 0, 255],
  4709. "gainsboro": [220, 220, 220],
  4710. "ghostwhite": [248, 248, 255],
  4711. "gold": [255, 215, 0],
  4712. "goldenrod": [218, 165, 32],
  4713. "gray": [128, 128, 128],
  4714. "green": [0, 128, 0],
  4715. "greenyellow": [173, 255, 47],
  4716. "grey": [128, 128, 128],
  4717. "honeydew": [240, 255, 240],
  4718. "hotpink": [255, 105, 180],
  4719. "indianred": [205, 92, 92],
  4720. "indigo": [75, 0, 130],
  4721. "ivory": [255, 255, 240],
  4722. "khaki": [240, 230, 140],
  4723. "lavender": [230, 230, 250],
  4724. "lavenderblush": [255, 240, 245],
  4725. "lawngreen": [124, 252, 0],
  4726. "lemonchiffon": [255, 250, 205],
  4727. "lightblue": [173, 216, 230],
  4728. "lightcoral": [240, 128, 128],
  4729. "lightcyan": [224, 255, 255],
  4730. "lightgoldenrodyellow": [250, 250, 210],
  4731. "lightgray": [211, 211, 211],
  4732. "lightgreen": [144, 238, 144],
  4733. "lightgrey": [211, 211, 211],
  4734. "lightpink": [255, 182, 193],
  4735. "lightsalmon": [255, 160, 122],
  4736. "lightseagreen": [32, 178, 170],
  4737. "lightskyblue": [135, 206, 250],
  4738. "lightslategray": [119, 136, 153],
  4739. "lightslategrey": [119, 136, 153],
  4740. "lightsteelblue": [176, 196, 222],
  4741. "lightyellow": [255, 255, 224],
  4742. "lime": [0, 255, 0],
  4743. "limegreen": [50, 205, 50],
  4744. "linen": [250, 240, 230],
  4745. "magenta": [255, 0, 255],
  4746. "maroon": [128, 0, 0],
  4747. "mediumaquamarine": [102, 205, 170],
  4748. "mediumblue": [0, 0, 205],
  4749. "mediumorchid": [186, 85, 211],
  4750. "mediumpurple": [147, 112, 219],
  4751. "mediumseagreen": [60, 179, 113],
  4752. "mediumslateblue": [123, 104, 238],
  4753. "mediumspringgreen": [0, 250, 154],
  4754. "mediumturquoise": [72, 209, 204],
  4755. "mediumvioletred": [199, 21, 133],
  4756. "midnightblue": [25, 25, 112],
  4757. "mintcream": [245, 255, 250],
  4758. "mistyrose": [255, 228, 225],
  4759. "moccasin": [255, 228, 181],
  4760. "navajowhite": [255, 222, 173],
  4761. "navy": [0, 0, 128],
  4762. "oldlace": [253, 245, 230],
  4763. "olive": [128, 128, 0],
  4764. "olivedrab": [107, 142, 35],
  4765. "orange": [255, 165, 0],
  4766. "orangered": [255, 69, 0],
  4767. "orchid": [218, 112, 214],
  4768. "palegoldenrod": [238, 232, 170],
  4769. "palegreen": [152, 251, 152],
  4770. "paleturquoise": [175, 238, 238],
  4771. "palevioletred": [219, 112, 147],
  4772. "papayawhip": [255, 239, 213],
  4773. "peachpuff": [255, 218, 185],
  4774. "peru": [205, 133, 63],
  4775. "pink": [255, 192, 203],
  4776. "plum": [221, 160, 221],
  4777. "powderblue": [176, 224, 230],
  4778. "purple": [128, 0, 128],
  4779. "rebeccapurple": [102, 51, 153],
  4780. "red": [255, 0, 0],
  4781. "rosybrown": [188, 143, 143],
  4782. "royalblue": [65, 105, 225],
  4783. "saddlebrown": [139, 69, 19],
  4784. "salmon": [250, 128, 114],
  4785. "sandybrown": [244, 164, 96],
  4786. "seagreen": [46, 139, 87],
  4787. "seashell": [255, 245, 238],
  4788. "sienna": [160, 82, 45],
  4789. "silver": [192, 192, 192],
  4790. "skyblue": [135, 206, 235],
  4791. "slateblue": [106, 90, 205],
  4792. "slategray": [112, 128, 144],
  4793. "slategrey": [112, 128, 144],
  4794. "snow": [255, 250, 250],
  4795. "springgreen": [0, 255, 127],
  4796. "steelblue": [70, 130, 180],
  4797. "tan": [210, 180, 140],
  4798. "teal": [0, 128, 128],
  4799. "thistle": [216, 191, 216],
  4800. "tomato": [255, 99, 71],
  4801. "turquoise": [64, 224, 208],
  4802. "violet": [238, 130, 238],
  4803. "wheat": [245, 222, 179],
  4804. "white": [255, 255, 255],
  4805. "whitesmoke": [245, 245, 245],
  4806. "yellow": [255, 255, 0],
  4807. "yellowgreen": [154, 205, 50]
  4808. };
  4809. /***/ }),
  4810. /***/ 19835:
  4811. /***/ ((module) => {
  4812. "use strict";
  4813. module.exports = (flag, argv = process.argv) => {
  4814. const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
  4815. const position = argv.indexOf(prefix + flag);
  4816. const terminatorPosition = argv.indexOf('--');
  4817. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  4818. };
  4819. /***/ }),
  4820. /***/ 54270:
  4821. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4822. "use strict";
  4823. const AggregateError = __webpack_require__(56455);
  4824. module.exports = async (
  4825. iterable,
  4826. mapper,
  4827. {
  4828. concurrency = Infinity,
  4829. stopOnError = true
  4830. } = {}
  4831. ) => {
  4832. return new Promise((resolve, reject) => {
  4833. if (typeof mapper !== 'function') {
  4834. throw new TypeError('Mapper function is required');
  4835. }
  4836. if (!((Number.isSafeInteger(concurrency) || concurrency === Infinity) && concurrency >= 1)) {
  4837. throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
  4838. }
  4839. const result = [];
  4840. const errors = [];
  4841. const iterator = iterable[Symbol.iterator]();
  4842. let isRejected = false;
  4843. let isIterableDone = false;
  4844. let resolvingCount = 0;
  4845. let currentIndex = 0;
  4846. const next = () => {
  4847. if (isRejected) {
  4848. return;
  4849. }
  4850. const nextItem = iterator.next();
  4851. const index = currentIndex;
  4852. currentIndex++;
  4853. if (nextItem.done) {
  4854. isIterableDone = true;
  4855. if (resolvingCount === 0) {
  4856. if (!stopOnError && errors.length !== 0) {
  4857. reject(new AggregateError(errors));
  4858. } else {
  4859. resolve(result);
  4860. }
  4861. }
  4862. return;
  4863. }
  4864. resolvingCount++;
  4865. (async () => {
  4866. try {
  4867. const element = await nextItem.value;
  4868. result[index] = await mapper(element, index);
  4869. resolvingCount--;
  4870. next();
  4871. } catch (error) {
  4872. if (stopOnError) {
  4873. isRejected = true;
  4874. reject(error);
  4875. } else {
  4876. errors.push(error);
  4877. resolvingCount--;
  4878. next();
  4879. }
  4880. }
  4881. })();
  4882. };
  4883. for (let i = 0; i < concurrency; i++) {
  4884. next();
  4885. if (isIterableDone) {
  4886. break;
  4887. }
  4888. }
  4889. });
  4890. };
  4891. /***/ }),
  4892. /***/ 71990:
  4893. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4894. "use strict";
  4895. const ansiRegex = __webpack_require__(14277);
  4896. module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
  4897. /***/ }),
  4898. /***/ 8442:
  4899. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4900. "use strict";
  4901. const os = __webpack_require__(12087);
  4902. const tty = __webpack_require__(33867);
  4903. const hasFlag = __webpack_require__(19835);
  4904. const {env} = process;
  4905. let forceColor;
  4906. if (hasFlag('no-color') ||
  4907. hasFlag('no-colors') ||
  4908. hasFlag('color=false') ||
  4909. hasFlag('color=never')) {
  4910. forceColor = 0;
  4911. } else if (hasFlag('color') ||
  4912. hasFlag('colors') ||
  4913. hasFlag('color=true') ||
  4914. hasFlag('color=always')) {
  4915. forceColor = 1;
  4916. }
  4917. if ('FORCE_COLOR' in env) {
  4918. if (env.FORCE_COLOR === 'true') {
  4919. forceColor = 1;
  4920. } else if (env.FORCE_COLOR === 'false') {
  4921. forceColor = 0;
  4922. } else {
  4923. forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
  4924. }
  4925. }
  4926. function translateLevel(level) {
  4927. if (level === 0) {
  4928. return false;
  4929. }
  4930. return {
  4931. level,
  4932. hasBasic: true,
  4933. has256: level >= 2,
  4934. has16m: level >= 3
  4935. };
  4936. }
  4937. function supportsColor(haveStream, streamIsTTY) {
  4938. if (forceColor === 0) {
  4939. return 0;
  4940. }
  4941. if (hasFlag('color=16m') ||
  4942. hasFlag('color=full') ||
  4943. hasFlag('color=truecolor')) {
  4944. return 3;
  4945. }
  4946. if (hasFlag('color=256')) {
  4947. return 2;
  4948. }
  4949. if (haveStream && !streamIsTTY && forceColor === undefined) {
  4950. return 0;
  4951. }
  4952. const min = forceColor || 0;
  4953. if (env.TERM === 'dumb') {
  4954. return min;
  4955. }
  4956. if (process.platform === 'win32') {
  4957. // Windows 10 build 10586 is the first Windows release that supports 256 colors.
  4958. // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
  4959. const osRelease = os.release().split('.');
  4960. if (
  4961. Number(osRelease[0]) >= 10 &&
  4962. Number(osRelease[2]) >= 10586
  4963. ) {
  4964. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  4965. }
  4966. return 1;
  4967. }
  4968. if ('CI' in env) {
  4969. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
  4970. return 1;
  4971. }
  4972. return min;
  4973. }
  4974. if ('TEAMCITY_VERSION' in env) {
  4975. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  4976. }
  4977. if (env.COLORTERM === 'truecolor') {
  4978. return 3;
  4979. }
  4980. if ('TERM_PROGRAM' in env) {
  4981. const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  4982. switch (env.TERM_PROGRAM) {
  4983. case 'iTerm.app':
  4984. return version >= 3 ? 3 : 2;
  4985. case 'Apple_Terminal':
  4986. return 2;
  4987. // No default
  4988. }
  4989. }
  4990. if (/-256(color)?$/i.test(env.TERM)) {
  4991. return 2;
  4992. }
  4993. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  4994. return 1;
  4995. }
  4996. if ('COLORTERM' in env) {
  4997. return 1;
  4998. }
  4999. return min;
  5000. }
  5001. function getSupportLevel(stream) {
  5002. const level = supportsColor(stream, stream && stream.isTTY);
  5003. return translateLevel(level);
  5004. }
  5005. module.exports = {
  5006. supportsColor: getSupportLevel,
  5007. stdout: translateLevel(supportsColor(true, tty.isatty(1))),
  5008. stderr: translateLevel(supportsColor(true, tty.isatty(2)))
  5009. };
  5010. /***/ }),
  5011. /***/ 31936:
  5012. /***/ ((module) => {
  5013. "use strict";
  5014. module.exports = JSON.parse('{"blacklist_client.lua":"local blacklist = ARGV[num_static_argv + 1]\\n\\nif redis.call(\'zscore\', client_last_seen_key, blacklist) then\\n redis.call(\'zadd\', client_last_seen_key, 0, blacklist)\\nend\\n\\n\\nreturn {}\\n","check.lua":"local weight = tonumber(ARGV[num_static_argv + 1])\\n\\nlocal capacity = process_tick(now, false)[\'capacity\']\\nlocal nextRequest = tonumber(redis.call(\'hget\', settings_key, \'nextRequest\'))\\n\\nreturn conditions_check(capacity, weight) and nextRequest - now <= 0\\n","conditions_check.lua":"local conditions_check = function (capacity, weight)\\n return capacity == nil or weight <= capacity\\nend\\n","current_reservoir.lua":"return process_tick(now, false)[\'reservoir\']\\n","done.lua":"process_tick(now, false)\\n\\nreturn tonumber(redis.call(\'hget\', settings_key, \'done\'))\\n","free.lua":"local index = ARGV[num_static_argv + 1]\\n\\nredis.call(\'zadd\', job_expirations_key, 0, index)\\n\\nreturn process_tick(now, false)[\'running\']\\n","get_time.lua":"redis.replicate_commands()\\n\\nlocal get_time = function ()\\n local time = redis.call(\'time\')\\n\\n return tonumber(time[1]..string.sub(time[2], 1, 3))\\nend\\n","group_check.lua":"return not (redis.call(\'exists\', settings_key) == 1)\\n","heartbeat.lua":"process_tick(now, true)\\n","increment_reservoir.lua":"local incr = tonumber(ARGV[num_static_argv + 1])\\n\\nredis.call(\'hincrby\', settings_key, \'reservoir\', incr)\\n\\nlocal reservoir = process_tick(now, true)[\'reservoir\']\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn reservoir\\n","init.lua":"local clear = tonumber(ARGV[num_static_argv + 1])\\nlocal limiter_version = ARGV[num_static_argv + 2]\\nlocal num_local_argv = num_static_argv + 2\\n\\nif clear == 1 then\\n redis.call(\'del\', unpack(KEYS))\\nend\\n\\nif redis.call(\'exists\', settings_key) == 0 then\\n -- Create\\n local args = {\'hmset\', settings_key}\\n\\n for i = num_local_argv + 1, #ARGV do\\n table.insert(args, ARGV[i])\\n end\\n\\n redis.call(unpack(args))\\n redis.call(\'hmset\', settings_key,\\n \'nextRequest\', now,\\n \'lastReservoirRefresh\', now,\\n \'lastReservoirIncrease\', now,\\n \'running\', 0,\\n \'done\', 0,\\n \'unblockTime\', 0,\\n \'capacityPriorityCounter\', 0\\n )\\n\\nelse\\n -- Apply migrations\\n local settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'version\'\\n )\\n local id = settings[1]\\n local current_version = settings[2]\\n\\n if current_version ~= limiter_version then\\n local version_digits = {}\\n for k, v in string.gmatch(current_version, \\"([^.]+)\\") do\\n table.insert(version_digits, tonumber(k))\\n end\\n\\n -- 2.10.0\\n if version_digits[2] < 10 then\\n redis.call(\'hsetnx\', settings_key, \'reservoirRefreshInterval\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirRefreshAmount\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'lastReservoirRefresh\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'done\', 0)\\n redis.call(\'hset\', settings_key, \'version\', \'2.10.0\')\\n end\\n\\n -- 2.11.1\\n if version_digits[2] < 11 or (version_digits[2] == 11 and version_digits[3] < 1) then\\n if redis.call(\'hstrlen\', settings_key, \'lastReservoirRefresh\') == 0 then\\n redis.call(\'hmset\', settings_key,\\n \'lastReservoirRefresh\', now,\\n \'version\', \'2.11.1\'\\n )\\n end\\n end\\n\\n -- 2.14.0\\n if version_digits[2] < 14 then\\n local old_running_key = \'b_\'..id..\'_running\'\\n local old_executing_key = \'b_\'..id..\'_executing\'\\n\\n if redis.call(\'exists\', old_running_key) == 1 then\\n redis.call(\'rename\', old_running_key, job_weights_key)\\n end\\n if redis.call(\'exists\', old_executing_key) == 1 then\\n redis.call(\'rename\', old_executing_key, job_expirations_key)\\n end\\n redis.call(\'hset\', settings_key, \'version\', \'2.14.0\')\\n end\\n\\n -- 2.15.2\\n if version_digits[2] < 15 or (version_digits[2] == 15 and version_digits[3] < 2) then\\n redis.call(\'hsetnx\', settings_key, \'capacityPriorityCounter\', 0)\\n redis.call(\'hset\', settings_key, \'version\', \'2.15.2\')\\n end\\n\\n -- 2.17.0\\n if version_digits[2] < 17 then\\n redis.call(\'hsetnx\', settings_key, \'clientTimeout\', 10000)\\n redis.call(\'hset\', settings_key, \'version\', \'2.17.0\')\\n end\\n\\n -- 2.18.0\\n if version_digits[2] < 18 then\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseInterval\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseAmount\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseMaximum\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'lastReservoirIncrease\', now)\\n redis.call(\'hset\', settings_key, \'version\', \'2.18.0\')\\n end\\n\\n end\\n\\n process_tick(now, false)\\nend\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn {}\\n","process_tick.lua":"local process_tick = function (now, always_publish)\\n\\n local compute_capacity = function (maxConcurrent, running, reservoir)\\n if maxConcurrent ~= nil and reservoir ~= nil then\\n return math.min((maxConcurrent - running), reservoir)\\n elseif maxConcurrent ~= nil then\\n return maxConcurrent - running\\n elseif reservoir ~= nil then\\n return reservoir\\n else\\n return nil\\n end\\n end\\n\\n local settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'maxConcurrent\',\\n \'running\',\\n \'reservoir\',\\n \'reservoirRefreshInterval\',\\n \'reservoirRefreshAmount\',\\n \'lastReservoirRefresh\',\\n \'reservoirIncreaseInterval\',\\n \'reservoirIncreaseAmount\',\\n \'reservoirIncreaseMaximum\',\\n \'lastReservoirIncrease\',\\n \'capacityPriorityCounter\',\\n \'clientTimeout\'\\n )\\n local id = settings[1]\\n local maxConcurrent = tonumber(settings[2])\\n local running = tonumber(settings[3])\\n local reservoir = tonumber(settings[4])\\n local reservoirRefreshInterval = tonumber(settings[5])\\n local reservoirRefreshAmount = tonumber(settings[6])\\n local lastReservoirRefresh = tonumber(settings[7])\\n local reservoirIncreaseInterval = tonumber(settings[8])\\n local reservoirIncreaseAmount = tonumber(settings[9])\\n local reservoirIncreaseMaximum = tonumber(settings[10])\\n local lastReservoirIncrease = tonumber(settings[11])\\n local capacityPriorityCounter = tonumber(settings[12])\\n local clientTimeout = tonumber(settings[13])\\n\\n local initial_capacity = compute_capacity(maxConcurrent, running, reservoir)\\n\\n --\\n -- Process \'running\' changes\\n --\\n local expired = redis.call(\'zrangebyscore\', job_expirations_key, \'-inf\', \'(\'..now)\\n\\n if #expired > 0 then\\n redis.call(\'zremrangebyscore\', job_expirations_key, \'-inf\', \'(\'..now)\\n\\n local flush_batch = function (batch, acc)\\n local weights = redis.call(\'hmget\', job_weights_key, unpack(batch))\\n redis.call(\'hdel\', job_weights_key, unpack(batch))\\n local clients = redis.call(\'hmget\', job_clients_key, unpack(batch))\\n redis.call(\'hdel\', job_clients_key, unpack(batch))\\n\\n -- Calculate sum of removed weights\\n for i = 1, #weights do\\n acc[\'total\'] = acc[\'total\'] + (tonumber(weights[i]) or 0)\\n end\\n\\n -- Calculate sum of removed weights by client\\n local client_weights = {}\\n for i = 1, #clients do\\n local removed = tonumber(weights[i]) or 0\\n if removed > 0 then\\n acc[\'client_weights\'][clients[i]] = (acc[\'client_weights\'][clients[i]] or 0) + removed\\n end\\n end\\n end\\n\\n local acc = {\\n [\'total\'] = 0,\\n [\'client_weights\'] = {}\\n }\\n local batch_size = 1000\\n\\n -- Compute changes to Zsets and apply changes to Hashes\\n for i = 1, #expired, batch_size do\\n local batch = {}\\n for j = i, math.min(i + batch_size - 1, #expired) do\\n table.insert(batch, expired[j])\\n end\\n\\n flush_batch(batch, acc)\\n end\\n\\n -- Apply changes to Zsets\\n if acc[\'total\'] > 0 then\\n redis.call(\'hincrby\', settings_key, \'done\', acc[\'total\'])\\n running = tonumber(redis.call(\'hincrby\', settings_key, \'running\', -acc[\'total\']))\\n end\\n\\n for client, weight in pairs(acc[\'client_weights\']) do\\n redis.call(\'zincrby\', client_running_key, -weight, client)\\n end\\n end\\n\\n --\\n -- Process \'reservoir\' changes\\n --\\n local reservoirRefreshActive = reservoirRefreshInterval ~= nil and reservoirRefreshAmount ~= nil\\n if reservoirRefreshActive and now >= lastReservoirRefresh + reservoirRefreshInterval then\\n reservoir = reservoirRefreshAmount\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'lastReservoirRefresh\', now\\n )\\n end\\n\\n local reservoirIncreaseActive = reservoirIncreaseInterval ~= nil and reservoirIncreaseAmount ~= nil\\n if reservoirIncreaseActive and now >= lastReservoirIncrease + reservoirIncreaseInterval then\\n local num_intervals = math.floor((now - lastReservoirIncrease) / reservoirIncreaseInterval)\\n local incr = reservoirIncreaseAmount * num_intervals\\n if reservoirIncreaseMaximum ~= nil then\\n incr = math.min(incr, reservoirIncreaseMaximum - (reservoir or 0))\\n end\\n if incr > 0 then\\n reservoir = (reservoir or 0) + incr\\n end\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'lastReservoirIncrease\', lastReservoirIncrease + (num_intervals * reservoirIncreaseInterval)\\n )\\n end\\n\\n --\\n -- Clear unresponsive clients\\n --\\n local unresponsive = redis.call(\'zrangebyscore\', client_last_seen_key, \'-inf\', (now - clientTimeout))\\n local unresponsive_lookup = {}\\n local terminated_clients = {}\\n for i = 1, #unresponsive do\\n unresponsive_lookup[unresponsive[i]] = true\\n if tonumber(redis.call(\'zscore\', client_running_key, unresponsive[i])) == 0 then\\n table.insert(terminated_clients, unresponsive[i])\\n end\\n end\\n if #terminated_clients > 0 then\\n redis.call(\'zrem\', client_running_key, unpack(terminated_clients))\\n redis.call(\'hdel\', client_num_queued_key, unpack(terminated_clients))\\n redis.call(\'zrem\', client_last_registered_key, unpack(terminated_clients))\\n redis.call(\'zrem\', client_last_seen_key, unpack(terminated_clients))\\n end\\n\\n --\\n -- Broadcast capacity changes\\n --\\n local final_capacity = compute_capacity(maxConcurrent, running, reservoir)\\n\\n if always_publish or (initial_capacity ~= nil and final_capacity == nil) then\\n -- always_publish or was not unlimited, now unlimited\\n redis.call(\'publish\', \'b_\'..id, \'capacity:\'..(final_capacity or \'\'))\\n\\n elseif initial_capacity ~= nil and final_capacity ~= nil and final_capacity > initial_capacity then\\n -- capacity was increased\\n -- send the capacity message to the limiter having the lowest number of running jobs\\n -- the tiebreaker is the limiter having not registered a job in the longest time\\n\\n local lowest_concurrency_value = nil\\n local lowest_concurrency_clients = {}\\n local lowest_concurrency_last_registered = {}\\n local client_concurrencies = redis.call(\'zrange\', client_running_key, 0, -1, \'withscores\')\\n\\n for i = 1, #client_concurrencies, 2 do\\n local client = client_concurrencies[i]\\n local concurrency = tonumber(client_concurrencies[i+1])\\n\\n if (\\n lowest_concurrency_value == nil or lowest_concurrency_value == concurrency\\n ) and (\\n not unresponsive_lookup[client]\\n ) and (\\n tonumber(redis.call(\'hget\', client_num_queued_key, client)) > 0\\n ) then\\n lowest_concurrency_value = concurrency\\n table.insert(lowest_concurrency_clients, client)\\n local last_registered = tonumber(redis.call(\'zscore\', client_last_registered_key, client))\\n table.insert(lowest_concurrency_last_registered, last_registered)\\n end\\n end\\n\\n if #lowest_concurrency_clients > 0 then\\n local position = 1\\n local earliest = lowest_concurrency_last_registered[1]\\n\\n for i,v in ipairs(lowest_concurrency_last_registered) do\\n if v < earliest then\\n position = i\\n earliest = v\\n end\\n end\\n\\n local next_client = lowest_concurrency_clients[position]\\n redis.call(\'publish\', \'b_\'..id,\\n \'capacity-priority:\'..(final_capacity or \'\')..\\n \':\'..next_client..\\n \':\'..capacityPriorityCounter\\n )\\n redis.call(\'hincrby\', settings_key, \'capacityPriorityCounter\', \'1\')\\n else\\n redis.call(\'publish\', \'b_\'..id, \'capacity:\'..(final_capacity or \'\'))\\n end\\n end\\n\\n return {\\n [\'capacity\'] = final_capacity,\\n [\'running\'] = running,\\n [\'reservoir\'] = reservoir\\n }\\nend\\n","queued.lua":"local clientTimeout = tonumber(redis.call(\'hget\', settings_key, \'clientTimeout\'))\\nlocal valid_clients = redis.call(\'zrangebyscore\', client_last_seen_key, (now - clientTimeout), \'inf\')\\nlocal client_queued = redis.call(\'hmget\', client_num_queued_key, unpack(valid_clients))\\n\\nlocal sum = 0\\nfor i = 1, #client_queued do\\n sum = sum + tonumber(client_queued[i])\\nend\\n\\nreturn sum\\n","refresh_expiration.lua":"local refresh_expiration = function (now, nextRequest, groupTimeout)\\n\\n if groupTimeout ~= nil then\\n local ttl = (nextRequest + groupTimeout) - now\\n\\n for i = 1, #KEYS do\\n redis.call(\'pexpire\', KEYS[i], ttl)\\n end\\n end\\n\\nend\\n","refs.lua":"local settings_key = KEYS[1]\\nlocal job_weights_key = KEYS[2]\\nlocal job_expirations_key = KEYS[3]\\nlocal job_clients_key = KEYS[4]\\nlocal client_running_key = KEYS[5]\\nlocal client_num_queued_key = KEYS[6]\\nlocal client_last_registered_key = KEYS[7]\\nlocal client_last_seen_key = KEYS[8]\\n\\nlocal now = tonumber(ARGV[1])\\nlocal client = ARGV[2]\\n\\nlocal num_static_argv = 2\\n","register.lua":"local index = ARGV[num_static_argv + 1]\\nlocal weight = tonumber(ARGV[num_static_argv + 2])\\nlocal expiration = tonumber(ARGV[num_static_argv + 3])\\n\\nlocal state = process_tick(now, false)\\nlocal capacity = state[\'capacity\']\\nlocal reservoir = state[\'reservoir\']\\n\\nlocal settings = redis.call(\'hmget\', settings_key,\\n \'nextRequest\',\\n \'minTime\',\\n \'groupTimeout\'\\n)\\nlocal nextRequest = tonumber(settings[1])\\nlocal minTime = tonumber(settings[2])\\nlocal groupTimeout = tonumber(settings[3])\\n\\nif conditions_check(capacity, weight) then\\n\\n redis.call(\'hincrby\', settings_key, \'running\', weight)\\n redis.call(\'hset\', job_weights_key, index, weight)\\n if expiration ~= nil then\\n redis.call(\'zadd\', job_expirations_key, now + expiration, index)\\n end\\n redis.call(\'hset\', job_clients_key, index, client)\\n redis.call(\'zincrby\', client_running_key, weight, client)\\n redis.call(\'hincrby\', client_num_queued_key, client, -1)\\n redis.call(\'zadd\', client_last_registered_key, now, client)\\n\\n local wait = math.max(nextRequest - now, 0)\\n local newNextRequest = now + wait + minTime\\n\\n if reservoir == nil then\\n redis.call(\'hset\', settings_key,\\n \'nextRequest\', newNextRequest\\n )\\n else\\n reservoir = reservoir - weight\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'nextRequest\', newNextRequest\\n )\\n end\\n\\n refresh_expiration(now, newNextRequest, groupTimeout)\\n\\n return {true, wait, reservoir}\\n\\nelse\\n return {false}\\nend\\n","register_client.lua":"local queued = tonumber(ARGV[num_static_argv + 1])\\n\\n-- Could have been re-registered concurrently\\nif not redis.call(\'zscore\', client_last_seen_key, client) then\\n redis.call(\'zadd\', client_running_key, 0, client)\\n redis.call(\'hset\', client_num_queued_key, client, queued)\\n redis.call(\'zadd\', client_last_registered_key, 0, client)\\nend\\n\\nredis.call(\'zadd\', client_last_seen_key, now, client)\\n\\nreturn {}\\n","running.lua":"return process_tick(now, false)[\'running\']\\n","submit.lua":"local queueLength = tonumber(ARGV[num_static_argv + 1])\\nlocal weight = tonumber(ARGV[num_static_argv + 2])\\n\\nlocal capacity = process_tick(now, false)[\'capacity\']\\n\\nlocal settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'maxConcurrent\',\\n \'highWater\',\\n \'nextRequest\',\\n \'strategy\',\\n \'unblockTime\',\\n \'penalty\',\\n \'minTime\',\\n \'groupTimeout\'\\n)\\nlocal id = settings[1]\\nlocal maxConcurrent = tonumber(settings[2])\\nlocal highWater = tonumber(settings[3])\\nlocal nextRequest = tonumber(settings[4])\\nlocal strategy = tonumber(settings[5])\\nlocal unblockTime = tonumber(settings[6])\\nlocal penalty = tonumber(settings[7])\\nlocal minTime = tonumber(settings[8])\\nlocal groupTimeout = tonumber(settings[9])\\n\\nif maxConcurrent ~= nil and weight > maxConcurrent then\\n return redis.error_reply(\'OVERWEIGHT:\'..weight..\':\'..maxConcurrent)\\nend\\n\\nlocal reachedHWM = (highWater ~= nil and queueLength == highWater\\n and not (\\n conditions_check(capacity, weight)\\n and nextRequest - now <= 0\\n )\\n)\\n\\nlocal blocked = strategy == 3 and (reachedHWM or unblockTime >= now)\\n\\nif blocked then\\n local computedPenalty = penalty\\n if computedPenalty == nil then\\n if minTime == 0 then\\n computedPenalty = 5000\\n else\\n computedPenalty = 15 * minTime\\n end\\n end\\n\\n local newNextRequest = now + computedPenalty + minTime\\n\\n redis.call(\'hmset\', settings_key,\\n \'unblockTime\', now + computedPenalty,\\n \'nextRequest\', newNextRequest\\n )\\n\\n local clients_queued_reset = redis.call(\'hkeys\', client_num_queued_key)\\n local queued_reset = {}\\n for i = 1, #clients_queued_reset do\\n table.insert(queued_reset, clients_queued_reset[i])\\n table.insert(queued_reset, 0)\\n end\\n redis.call(\'hmset\', client_num_queued_key, unpack(queued_reset))\\n\\n redis.call(\'publish\', \'b_\'..id, \'blocked:\')\\n\\n refresh_expiration(now, newNextRequest, groupTimeout)\\nend\\n\\nif not blocked and not reachedHWM then\\n redis.call(\'hincrby\', client_num_queued_key, client, 1)\\nend\\n\\nreturn {reachedHWM, blocked, strategy}\\n","update_settings.lua":"local args = {\'hmset\', settings_key}\\n\\nfor i = num_static_argv + 1, #ARGV do\\n table.insert(args, ARGV[i])\\nend\\n\\nredis.call(unpack(args))\\n\\nprocess_tick(now, true)\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn {}\\n","validate_client.lua":"if not redis.call(\'zscore\', client_last_seen_key, client) then\\n return redis.error_reply(\'UNKNOWN_CLIENT\')\\nend\\n\\nredis.call(\'zadd\', client_last_seen_key, now, client)\\n","validate_keys.lua":"if not (redis.call(\'exists\', settings_key) == 1) then\\n return redis.error_reply(\'SETTINGS_KEY_NOT_FOUND\')\\nend\\n"}');
  5015. /***/ }),
  5016. /***/ 82636:
  5017. /***/ ((module) => {
  5018. "use strict";
  5019. module.exports = {"i":"2.19.5"};
  5020. /***/ })
  5021. };
  5022. ;
  5023. //# sourceMappingURL=779.index.js.map